.pcm changed

git-svn-id: https://vgmstream.svn.sourceforge.net/svnroot/vgmstream@379 51a99a44-fe44-0410-b1ba-c3e57ba2b86b
This commit is contained in:
manakoAT 2008-07-30 22:13:25 +00:00
parent de5da88d84
commit fc3f3f751d
5 changed files with 79 additions and 60 deletions

View File

@ -298,6 +298,10 @@
RelativePath=".\meta\ogg_vorbis_file.c"
>
</File>
<File
RelativePath=".\meta\pcm.c"
>
</File>
<File
RelativePath=".\meta\pos.c"
>
@ -370,10 +374,6 @@
RelativePath=".\meta\ps2_npsf.c"
>
</File>
<File
RelativePath=".\meta\ps2_pcm.c"
>
</File>
<File
RelativePath=".\meta\ps2_pnb.c"
>

View File

@ -169,7 +169,7 @@ VGMSTREAM * init_vgmstream_ps2_psh(STREAMFILE * streamFile);
VGMSTREAM * init_vgmstream_mus_acm(STREAMFILE * streamFile);
VGMSTREAM * init_vgmstream_ps2_pcm(STREAMFILE * streamFile);
VGMSTREAM * init_vgmstream_pcm(STREAMFILE * streamFile);
VGMSTREAM * init_vgmstream_ps2_rkv(STREAMFILE * streamFile);

View File

@ -2,72 +2,91 @@
#include "../util.h"
/* PCM (from Ephemeral Fantasia) */
VGMSTREAM * init_vgmstream_ps2_pcm(STREAMFILE *streamFile) {
VGMSTREAM * vgmstream = NULL;
char filename[260];
off_t start_offset;
VGMSTREAM * init_vgmstream_pcm(STREAMFILE *streamFile) {
int loop_flag;
int channel_count;
VGMSTREAM * vgmstream = NULL;
char filename[260];
off_t start_offset;
/* check extension, case insensitive */
streamFile->get_name(streamFile,filename,sizeof(filename));
if (strcasecmp("pcm",filename_extension(filename))) goto fail;
int loop_flag;
int channel_count;
/* check header */
if (read_32bitBE(0x410,streamFile) != 0x9CDB0740) /* 0x9CDB0740" */
goto fail;
/* check extension, case insensitive */
streamFile->get_name(streamFile,filename,sizeof(filename));
if (strcasecmp("pcm",filename_extension(filename))) goto fail;
loop_flag = (read_32bitLE(0x08,streamFile)!=0);
channel_count = 2;
/* build the VGMSTREAM */
vgmstream = allocate_vgmstream(channel_count,loop_flag);
if (!vgmstream) goto fail;
/* check header */
if (read_32bitBE(0x0C,streamFile) ==0x0AA00AA0) {
loop_flag = (read_32bitLE(0x02,streamFile)!=0);
channel_count = 1;
/* build the VGMSTREAM */
vgmstream = allocate_vgmstream(channel_count,loop_flag);
if (!vgmstream) goto fail;
/* fill in the vital statistics */
start_offset = 0x200;
vgmstream->channels = channel_count;
vgmstream->sample_rate = 44100;
vgmstream->coding_type = coding_PCM8_SB_int;
vgmstream->num_samples = read_32bitLE(0x02,streamFile)/2/channel_count;
/* fill in the vital statistics */
start_offset = 0x800;
vgmstream->channels = channel_count;
vgmstream->sample_rate = 22050;
vgmstream->coding_type = coding_PCM16LE;
if(loop_flag) {
vgmstream->loop_start_sample = read_32bitBE(0x02,streamFile)*2;
vgmstream->loop_end_sample = read_32bitBE(0x06,streamFile)*2;
}
vgmstream->layout_type = layout_interleave;
vgmstream->interleave_block_size = 0x2;
vgmstream->meta_type = meta_PCM;
if(loop_flag == 0) {
vgmstream->loop_start_sample = read_32bitLE(0x08,streamFile);
vgmstream->loop_end_sample = read_32bitLE(0x00,streamFile)/2/channel_count;
vgmstream->num_samples = read_32bitLE(0x00,streamFile)/2/channel_count;
} else {
} else if (read_32bitBE(0x410,streamFile) ==0x9CDB0740) {
loop_flag = (read_32bitLE(0x08,streamFile)!=0);
channel_count = 2;
/* build the VGMSTREAM */
vgmstream = allocate_vgmstream(channel_count,loop_flag);
if (!vgmstream) goto fail;
/* fill in the vital statistics */
start_offset = 0x800;
vgmstream->channels = channel_count;
vgmstream->sample_rate = 22050;
vgmstream->coding_type = coding_PCM16LE;
vgmstream->num_samples = read_32bitLE(0xC,streamFile);
if(loop_flag == 1) {
vgmstream->loop_start_sample = read_32bitLE(0x08,streamFile);
vgmstream->loop_end_sample = read_32bitLE(0x0C,streamFile);
vgmstream->num_samples = read_32bitLE(0xC,streamFile);
}
vgmstream->layout_type = layout_interleave;
vgmstream->interleave_block_size = 0x2;
vgmstream->meta_type = meta_PS2_PCM;
vgmstream->layout_type = layout_interleave;
vgmstream->interleave_block_size = 0x2;
vgmstream->meta_type = meta_PCM;
} else
goto fail;
/* open the file for reading */
{
int i;
STREAMFILE * file;
file = streamFile->open(streamFile,filename,STREAMFILE_DEFAULT_BUFFER_SIZE);
if (!file) goto fail;
for (i=0;i<channel_count;i++) {
vgmstream->ch[i].streamfile = file;
/* open the file for reading */
{
int i;
STREAMFILE * file;
file = streamFile->open(streamFile,filename,STREAMFILE_DEFAULT_BUFFER_SIZE);
if (!file) goto fail;
for (i=0;i<channel_count;i++) {
vgmstream->ch[i].streamfile = file;
vgmstream->ch[i].channel_start_offset=
vgmstream->ch[i].offset=start_offset+
vgmstream->interleave_block_size*i;
vgmstream->ch[i].channel_start_offset=
vgmstream->ch[i].offset=start_offset+
vgmstream->interleave_block_size*i;
}
}
}
}
return vgmstream;
return vgmstream;
/* clean up anything we may have opened */
/* clean up anything we may have opened */
fail:
if (vgmstream) close_vgmstream(vgmstream);
return NULL;
}
if (vgmstream) close_vgmstream(vgmstream);
return NULL;
}

View File

@ -100,7 +100,7 @@ VGMSTREAM * (*init_vgmstream_fcns[])(STREAMFILE *streamFile) = {
init_vgmstream_ps2_kces,
init_vgmstream_ps2_dxh,
init_vgmstream_ps2_psh,
init_vgmstream_ps2_pcm,
init_vgmstream_pcm,
init_vgmstream_ps2_rkv,
init_vgmstream_ps2_psw,
init_vgmstream_ps2_vas,
@ -1434,8 +1434,8 @@ void describe_vgmstream(VGMSTREAM * vgmstream, char * desc, int length) {
case meta_RIFF_WAVE_labl_Marker:
snprintf(temp,TEMPSIZE,"RIFF WAVE header with loop markers");
break;
case meta_PS2_PCM:
snprintf(temp,TEMPSIZE,"Ephemeral Fantasia PCM Header");
case meta_PCM:
snprintf(temp,TEMPSIZE,"PCM file with custom header");
break;
case meta_PS2_RKV:
snprintf(temp,TEMPSIZE,"Legacy of Kain - Blood Omen 2 RKV Header");

View File

@ -200,7 +200,7 @@ typedef enum {
meta_PS2_KCES, /* Dance Dance Revolution */
meta_PS2_DXH, /* Tokobot Plus - Myteries of the Karakuri */
meta_PS2_PSH, /* Dawn of Mana - Seiken Densetsu 4 */
meta_PS2_PCM, /* Ephemeral Fantasia */
meta_PCM, /* Ephemeral Fantasia, Lunar - Eternal Blue */
meta_PS2_RKV, /* Legacy of Kain - Blood Omen 2 */
meta_PS2_PSW, /* Rayman Raving Rabbids */
meta_PS2_VAS, /* Pro Baseball Spirits 5 */