mirror of
https://github.com/vgmstream/vgmstream.git
synced 2025-02-06 14:44:25 +01:00
Reject EXST in .int meta and cleanup
This commit is contained in:
parent
611e556809
commit
2e90f4de57
@ -1,64 +1,52 @@
|
|||||||
#include "meta.h"
|
#include "meta.h"
|
||||||
#include "../util.h"
|
#include "../coding/coding.h"
|
||||||
|
|
||||||
/* INT
|
|
||||||
|
|
||||||
PS2 INT format is a RAW 48khz PCM file without header
|
|
||||||
The only fact about those file, is that the raw is interleaved
|
|
||||||
|
|
||||||
The interleave value is allways 0x200
|
|
||||||
known extensions : INT
|
|
||||||
|
|
||||||
2008-05-11 - Fastelbja : First version ...
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
/* raw PCM file assumed by extension [PaRappa The Rapper 2 (PS2)? , Amplitude (PS2)?] */
|
||||||
VGMSTREAM * init_vgmstream_ps2_int(STREAMFILE *streamFile) {
|
VGMSTREAM * init_vgmstream_ps2_int(STREAMFILE *streamFile) {
|
||||||
VGMSTREAM * vgmstream = NULL;
|
VGMSTREAM * vgmstream = NULL;
|
||||||
char filename[PATH_LIMIT];
|
off_t start_offset;
|
||||||
int i,channel_count;
|
int channel_count;
|
||||||
|
|
||||||
/* check extension, case insensitive */
|
/* checks */
|
||||||
streamFile->get_name(streamFile,filename,sizeof(filename));
|
if (!check_extensions(streamFile, "int,wp2"))
|
||||||
if (strcasecmp("int",filename_extension(filename)) &&
|
goto fail;
|
||||||
strcasecmp("wp2",filename_extension(filename))) goto fail;
|
|
||||||
|
|
||||||
if(!strcasecmp("int",filename_extension(filename)))
|
if (check_extensions(streamFile, "int"))
|
||||||
channel_count = 2;
|
channel_count = 2;
|
||||||
else
|
else
|
||||||
channel_count = 4;
|
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;
|
||||||
|
|
||||||
/* ignore A2M .int */
|
|
||||||
if (read_32bitBE(0x00,streamFile) == 0x41324D00) /* "A2M\0" */
|
|
||||||
goto fail;
|
|
||||||
|
|
||||||
/* build the VGMSTREAM */
|
/* build the VGMSTREAM */
|
||||||
vgmstream = allocate_vgmstream(channel_count,0);
|
vgmstream = allocate_vgmstream(channel_count,0);
|
||||||
if (!vgmstream) goto fail;
|
if (!vgmstream) goto fail;
|
||||||
|
|
||||||
/* fill in the vital statistics */
|
|
||||||
vgmstream->channels=channel_count;
|
|
||||||
vgmstream->sample_rate = 48000;
|
vgmstream->sample_rate = 48000;
|
||||||
vgmstream->coding_type = coding_PCM16LE;
|
|
||||||
vgmstream->num_samples = (int32_t)(get_streamfile_size(streamFile)/(vgmstream->channels*2));
|
|
||||||
vgmstream->interleave_block_size = 0x200;
|
|
||||||
vgmstream->layout_type = layout_interleave;
|
|
||||||
vgmstream->meta_type = meta_PS2_RAW;
|
vgmstream->meta_type = meta_PS2_RAW;
|
||||||
|
vgmstream->num_samples = pcm_bytes_to_samples(get_streamfile_size(streamFile), vgmstream->channels, 16);
|
||||||
|
vgmstream->coding_type = coding_PCM16LE;
|
||||||
|
vgmstream->layout_type = layout_interleave;
|
||||||
|
vgmstream->interleave_block_size = 0x200;
|
||||||
|
|
||||||
/* open the file for reading by each channel */
|
if (!vgmstream_open_stream(vgmstream,streamFile,start_offset))
|
||||||
{
|
goto fail;
|
||||||
for (i=0;i<vgmstream->channels;i++) {
|
|
||||||
vgmstream->ch[i].streamfile = streamFile->open(streamFile,filename,0x8000);
|
|
||||||
|
|
||||||
if (!vgmstream->ch[i].streamfile) goto fail;
|
|
||||||
|
|
||||||
vgmstream->ch[i].channel_start_offset=
|
|
||||||
vgmstream->ch[i].offset=i*vgmstream->interleave_block_size;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return vgmstream;
|
return vgmstream;
|
||||||
|
|
||||||
/* clean up anything we may have opened */
|
|
||||||
fail:
|
fail:
|
||||||
if (vgmstream) close_vgmstream(vgmstream);
|
if (vgmstream) close_vgmstream(vgmstream);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user