Fix SVAG detection bug [Silent Scope 2 (PS2)]

This commit is contained in:
bnnm 2020-07-16 21:47:50 +02:00
parent 3091930a1d
commit a4331eb04e
5 changed files with 22 additions and 19 deletions

View File

@ -898,7 +898,7 @@ static const meta_info meta_info_list[] = {
{meta_PS2_OMU, "Alter Echo OMU Header"},
{meta_DSP_STM, "Intelligent Systems STM header"},
{meta_PS2_EXST, "Sony EXST header"},
{meta_PS2_SVAG, "Konami SVAG header"},
{meta_SVAG_KCET, "Konami SVAG header"},
{meta_PS_HEADERLESS, "Headerless PS-ADPCM raw header"},
{meta_PS2_MIB_MIH, "Sony MultiStream MIH+MIB header"},
{meta_DSP_MPDSP, "Single DSP header stereo by .mpdsp extension"},

View File

@ -76,7 +76,7 @@ VGMSTREAM * init_vgmstream_raw_int(STREAMFILE *streamFile);
VGMSTREAM * init_vgmstream_ps2_exst(STREAMFILE *streamFile);
VGMSTREAM * init_vgmstream_ps2_svag(STREAMFILE *streamFile);
VGMSTREAM * init_vgmstream_svag_kcet(STREAMFILE *streamFile);
VGMSTREAM * init_vgmstream_ps_headerless(STREAMFILE *streamFile);

View File

@ -2,51 +2,54 @@
#include "../coding/coding.h"
/* SVAG - from Konami Tokyo games [OZ (PS2), Neo Contra (PS2), Silent Hill 2 (PS2)] */
VGMSTREAM * init_vgmstream_ps2_svag(STREAMFILE *streamFile) {
VGMSTREAM * vgmstream = NULL;
VGMSTREAM* init_vgmstream_svag_kcet(STREAMFILE* sf) {
VGMSTREAM* vgmstream = NULL;
off_t start_offset;
size_t data_size;
int loop_flag, channel_count;
/* checks */
if (!check_extensions(streamFile, "svag"))
if (!check_extensions(sf, "svag"))
goto fail;
if (read_32bitBE(0x00,streamFile) != 0x53766167) /* "Svag" */
if (read_32bitBE(0x00,sf) != 0x53766167) /* "Svag" */
goto fail;
channel_count = read_16bitLE(0x0C,streamFile); /* always 2? ("S"tereo vag?) */
loop_flag = (read_32bitLE(0x14,streamFile)==1);
channel_count = read_16bitLE(0x0C,sf); /* always 2? ("S"tereo vag?) */
loop_flag = (read_32bitLE(0x14,sf) ==1);
/* header repeated at 0x400 presumably for stereo */
if (channel_count > 1 && read_32bitBE(0x400,streamFile) != 0x53766167) /* "Svag" */
/* test padding (a set "KCE-Tokyo ..." phrase) after 0x1c to catch bad rips,
* at 0x400 may be header again (Silent Hill 2) or more padding (Silent Scope 2) */
if (channel_count > 1 &&
read_32bitBE(0x400,sf) != 0x53766167 && /* "Svag" */
read_32bitBE(0x400,sf) != 0x44657369) /* "Desi" */
goto fail;
start_offset = 0x800;
data_size = read_32bitLE(0x04,streamFile);
data_size = read_32bitLE(0x04,sf);
/* build the VGMSTREAM */
vgmstream = allocate_vgmstream(channel_count,loop_flag);
if (!vgmstream) goto fail;
vgmstream->sample_rate = read_32bitLE(0x08,streamFile);
vgmstream->sample_rate = read_32bitLE(0x08,sf);
vgmstream->num_samples = ps_bytes_to_samples(read_32bitLE(0x04,streamFile), vgmstream->channels);
vgmstream->num_samples = ps_bytes_to_samples(read_32bitLE(0x04,sf), vgmstream->channels);
if(vgmstream->loop_flag) {
vgmstream->loop_start_sample = ps_bytes_to_samples(read_32bitLE(0x18,streamFile)*vgmstream->channels, vgmstream->channels);
vgmstream->loop_start_sample = ps_bytes_to_samples(read_32bitLE(0x18,sf)*vgmstream->channels, vgmstream->channels);
vgmstream->loop_end_sample = vgmstream->num_samples;
}
vgmstream->meta_type = meta_PS2_SVAG;
vgmstream->meta_type = meta_SVAG_KCET;
vgmstream->coding_type = coding_PSX;
vgmstream->layout_type = layout_interleave;
vgmstream->interleave_block_size = read_32bitLE(0x10,streamFile);
vgmstream->interleave_block_size = read_32bitLE(0x10,sf);
if (vgmstream->interleave_block_size)
vgmstream->interleave_last_block_size = (data_size % (vgmstream->interleave_block_size*vgmstream->channels)) / vgmstream->channels;
if (!vgmstream_open_stream(vgmstream,streamFile,start_offset))
if (!vgmstream_open_stream(vgmstream, sf, start_offset))
goto fail;
return vgmstream;

View File

@ -45,7 +45,7 @@ VGMSTREAM * (*init_vgmstream_functions[])(STREAMFILE *streamFile) = {
init_vgmstream_ps2_rxw,
init_vgmstream_ngc_dsp_stm,
init_vgmstream_ps2_exst,
init_vgmstream_ps2_svag,
init_vgmstream_svag_kcet,
init_vgmstream_mib_mih,
init_vgmstream_ngc_mpdsp,
init_vgmstream_ps2_mic,

View File

@ -349,7 +349,7 @@ typedef enum {
meta_PS2_RXWS, /* Sony games (Genji, Okage Shadow King, Arc The Lad Twilight of Spirits) */
meta_RAW_INT,
meta_PS2_EXST, /* Shadow of Colossus EXST */
meta_PS2_SVAG, /* Konami SVAG */
meta_SVAG_KCET,
meta_PS_HEADERLESS, /* headerless PS-ADPCM */
meta_PS2_MIB_MIH, /* MIB File + MIH Header*/
meta_PS2_MIC, /* KOEI MIC File */