2008-05-13 13:47:51 +02:00
|
|
|
#include "meta.h"
|
2018-08-16 20:06:14 +02:00
|
|
|
#include "../coding/coding.h"
|
2008-05-11 23:27:10 +02:00
|
|
|
|
2018-08-16 20:06:14 +02:00
|
|
|
/* raw PCM file assumed by extension [PaRappa The Rapper 2 (PS2)? , Amplitude (PS2)?] */
|
2008-05-20 17:18:38 +02:00
|
|
|
VGMSTREAM * init_vgmstream_ps2_int(STREAMFILE *streamFile) {
|
2008-05-13 13:47:51 +02:00
|
|
|
VGMSTREAM * vgmstream = NULL;
|
2018-08-16 20:06:14 +02:00
|
|
|
off_t start_offset;
|
|
|
|
int channel_count;
|
2008-05-13 13:47:51 +02:00
|
|
|
|
2018-08-16 20:06:14 +02:00
|
|
|
/* checks */
|
|
|
|
if (!check_extensions(streamFile, "int,wp2"))
|
|
|
|
goto fail;
|
2008-05-13 13:47:51 +02:00
|
|
|
|
2018-08-16 20:06:14 +02:00
|
|
|
if (check_extensions(streamFile, "int"))
|
|
|
|
channel_count = 2;
|
|
|
|
else
|
|
|
|
channel_count = 4;
|
|
|
|
|
|
|
|
/* try to skip known .int (a horrible idea this parser exists) */
|
|
|
|
{
|
|
|
|
/* ignore A2M .int */
|
|
|
|
if (read_32bitBE(0x00,streamFile) == 0x41324D00) /* "A2M\0" */
|
|
|
|
goto fail;
|
|
|
|
/* ignore EXST .int */
|
|
|
|
if (read_32bitBE(0x10,streamFile) == 0x0C020000 &&
|
|
|
|
read_32bitBE(0x20,streamFile) == 0x0C020000 &&
|
|
|
|
read_32bitBE(0x30,streamFile) == 0x0C020000 &&
|
|
|
|
read_32bitBE(0x40,streamFile) == 0x0C020000) /* check a few empty PS-ADPCM frames */
|
|
|
|
goto fail;
|
|
|
|
}
|
|
|
|
|
|
|
|
start_offset = 0x00;
|
2008-05-13 13:47:51 +02:00
|
|
|
|
2017-12-09 17:03:23 +01:00
|
|
|
|
2008-05-13 13:47:51 +02:00
|
|
|
/* build the VGMSTREAM */
|
2008-05-24 22:22:54 +02:00
|
|
|
vgmstream = allocate_vgmstream(channel_count,0);
|
2008-05-13 13:47:51 +02:00
|
|
|
if (!vgmstream) goto fail;
|
|
|
|
|
|
|
|
vgmstream->sample_rate = 48000;
|
2018-08-16 20:06:14 +02:00
|
|
|
vgmstream->meta_type = meta_PS2_RAW;
|
|
|
|
vgmstream->num_samples = pcm_bytes_to_samples(get_streamfile_size(streamFile), vgmstream->channels, 16);
|
2008-05-13 13:47:51 +02:00
|
|
|
vgmstream->coding_type = coding_PCM16LE;
|
|
|
|
vgmstream->layout_type = layout_interleave;
|
2018-08-16 20:06:14 +02:00
|
|
|
vgmstream->interleave_block_size = 0x200;
|
2008-09-08 20:55:01 +02:00
|
|
|
|
2018-08-16 20:06:14 +02:00
|
|
|
if (!vgmstream_open_stream(vgmstream,streamFile,start_offset))
|
|
|
|
goto fail;
|
2008-09-08 20:55:01 +02:00
|
|
|
return vgmstream;
|
|
|
|
|
|
|
|
fail:
|
|
|
|
if (vgmstream) close_vgmstream(vgmstream);
|
|
|
|
return NULL;
|
|
|
|
}
|