From e1262f47e23ad8bd977b95bd8abda3c6ad2b279f Mon Sep 17 00:00:00 2001 From: jurassicpieter Date: Sun, 7 Feb 2010 10:05:55 +0000 Subject: [PATCH] PS2 ADS: some files were considered corrupt while they weren't. git-svn-id: https://vgmstream.svn.sourceforge.net/svnroot/vgmstream@736 51a99a44-fe44-0410-b1ba-c3e57ba2b86b --- src/meta/ps2_ads.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/meta/ps2_ads.c b/src/meta/ps2_ads.c index b55ddbba..b7e88b0b 100644 --- a/src/meta/ps2_ads.c +++ b/src/meta/ps2_ads.c @@ -11,6 +11,7 @@ VGMSTREAM * init_vgmstream_ps2_ads(STREAMFILE *streamFile) { int channel_count; off_t start_offset; off_t check_offset; + int32_t streamSize; uint8_t testBuffer[0x10]; uint8_t isPCM = 0; @@ -34,8 +35,14 @@ VGMSTREAM * init_vgmstream_ps2_ads(STREAMFILE *streamFile) { goto fail; /* check if file is not corrupt */ - if (get_streamfile_size(streamFile)<(size_t)(read_32bitLE(0x24,streamFile) + 0x28)) - goto fail; + /* seems the Gran Turismo 4 ADS files are considered corrupt,*/ + /* so I changed it to adapt the stream size if that's the case */ + /* instead of failing playing them at all*/ + streamSize = read_32bitLE(0x24,streamFile); + if (get_streamfile_size(streamFile)<(size_t)( streamSize+ 0x28)) + { + streamSize = get_streamfile_size(streamFile) - 0x28; + } /* check loop */ loop_flag = (read_32bitLE(0x1C,streamFile)!=0xFFFFFFFF); @@ -52,13 +59,13 @@ VGMSTREAM * init_vgmstream_ps2_ads(STREAMFILE *streamFile) { /* Check for Compression Scheme */ vgmstream->coding_type = coding_PSX; - vgmstream->num_samples = ((read_32bitLE(0x24,streamFile)-0x40)/16*28)/vgmstream->channels; + vgmstream->num_samples = ((streamSize-0x40)/16*28)/vgmstream->channels; /* SS2 container with RAW Interleaved PCM */ if (read_32bitLE(0x08,streamFile)!=0x10) { vgmstream->coding_type=coding_PCM16LE; - vgmstream->num_samples = read_32bitLE(0x24,streamFile)/2/vgmstream->channels; + vgmstream->num_samples = streamSize/2/vgmstream->channels; } vgmstream->interleave_block_size = read_32bitLE(0x14,streamFile);