From d4556f33102b0686b34868d81cafa552ce34e366 Mon Sep 17 00:00:00 2001 From: bnnm Date: Sat, 7 Apr 2018 11:37:44 +0200 Subject: [PATCH] Ignore LyN RIFF as it's parsed in its own file now; cleanup --- src/formats.c | 3 +-- src/meta/riff.c | 44 +++----------------------------------------- src/meta/ubi_jade.c | 6 +++--- src/meta/wwise.c | 12 ++++++++++++ src/vgmstream.h | 3 +-- 5 files changed, 20 insertions(+), 48 deletions(-) diff --git a/src/formats.c b/src/formats.c index a517b885..52d6279b 100644 --- a/src/formats.c +++ b/src/formats.c @@ -764,7 +764,7 @@ static const meta_info meta_info_list[] = { {meta_FFXI_SPW, "SPW SeWave header"}, {meta_PS2_ASS, "ASS Header"}, {meta_IDSP, "IDSP Header"}, - {meta_JADE_RIFF, "Ubisoft Jade RIFF header"}, + {meta_UBI_JADE, "Ubisoft Jade RIFF header"}, {meta_PS2_SEG, "SEG (PS2) Header"}, {meta_XBOX_SEG, "SEG (XBOX) Header"}, {meta_NDS_STRM_FFTA2, "Final Fantasy Tactics A2 RIFF Header"}, @@ -790,7 +790,6 @@ static const meta_info meta_info_list[] = { {meta_NGC_DSP_IADP, "IADP Header"}, {meta_RSTM_shrunken, "Nintendo RSTM header, corrupted by Atlus"}, {meta_RIFF_WAVE_MWV, "RIFF WAVE header with .mwv flavoring"}, - {meta_RIFF_WAVE_SNS, "RIFF WAVE header with .sns flavoring"}, {meta_FFCC_STR, "Final Fantasy: Crystal Chronicles STR header"}, {meta_SAT_BAKA, "BAKA header from Crypt Killer"}, {meta_NDS_SWAV, "SWAV Header"}, diff --git a/src/meta/riff.c b/src/meta/riff.c index d41a7d4e..a7f489c8 100644 --- a/src/meta/riff.c +++ b/src/meta/riff.c @@ -90,7 +90,7 @@ typedef struct { int interleave; } riff_fmt_chunk; -static int read_fmt(int big_endian, STREAMFILE * streamFile, off_t current_chunk, riff_fmt_chunk * fmt, int sns, int mwv) { +static int read_fmt(int big_endian, STREAMFILE * streamFile, off_t current_chunk, riff_fmt_chunk * fmt, int mwv) { int32_t (*read_32bit)(off_t,STREAMFILE*) = big_endian ? read_32bitBE : read_32bitLE; int16_t (*read_16bit)(off_t,STREAMFILE*) = big_endian ? read_16bitBE : read_16bitLE; @@ -167,12 +167,6 @@ static int read_fmt(int big_endian, STREAMFILE * streamFile, off_t current_chunk fmt->interleave = 0x12; break; - case 0x5050: /* Ubisoft LyN engine's DSP (unofficial) */ - if (!sns) goto fail; - fmt->coding_type = coding_NGC_DSP; - fmt->interleave = 0x08; - break; - #ifdef VGM_USE_VORBIS case 0x6771: /* Ogg Vorbis (mode 3+) */ fmt->coding_type = coding_OGG_VORBIS; @@ -253,7 +247,6 @@ VGMSTREAM * init_vgmstream_riff(STREAMFILE *streamFile) { int mwv = 0; /* Level-5 .mwv (Dragon Quest VIII, Rogue Galaxy) */ off_t mwv_pflt_offset = -1; off_t mwv_ctrl_offset = -1; - int sns = 0; /* Ubisoft .sns LyN engine (Red Steel 2, Just Dance 3) */ int at3 = 0; /* Sony ATRAC3 / ATRAC3plus */ int at9 = 0; /* Sony ATRAC9 */ @@ -269,9 +262,6 @@ VGMSTREAM * init_vgmstream_riff(STREAMFILE *streamFile) { else if ( check_extensions(streamFile, "mwv") ) { mwv = 1; } - else if ( check_extensions(streamFile, "sns") ) { - sns = 1; - } /* .rws: Climax games (Silent Hill Origins PSP, Oblivion PSP), .aud: EA Replay */ else if ( check_extensions(streamFile, "at3,rws,aud") ) { at3 = 1; @@ -329,7 +319,6 @@ VGMSTREAM * init_vgmstream_riff(STREAMFILE *streamFile) { streamFile, current_chunk, &fmt, - sns, mwv)) goto fail; @@ -395,8 +384,8 @@ VGMSTREAM * init_vgmstream_riff(STREAMFILE *streamFile) { case 0x66616374: /* "fact" */ if (chunk_size == 0x04) { /* standard, usually found with ADPCM */ fact_sample_count = read_32bitLE(current_chunk+0x08, streamFile); - } else if (sns && chunk_size == 0x10) { - fact_sample_count = read_32bitLE(current_chunk+0x08, streamFile); + } else if (chunk_size == 0x10 && read_32bitBE(current_chunk+0x08+0x04, streamFile) == 0x4C794E20) { /* "LyN " */ + goto fail; /* parsed elsewhere */ } else if ((at3 || at9) && chunk_size == 0x08) { fact_sample_count = read_32bitLE(current_chunk+0x08, streamFile); fact_sample_skip = read_32bitLE(current_chunk+0x0c, streamFile); @@ -523,29 +512,6 @@ VGMSTREAM * init_vgmstream_riff(STREAMFILE *streamFile) { vgmstream->num_samples = fact_sample_count; /* some (converted?) Xbox games have bigger fact_samples */ break; - case coding_NGC_DSP: - if (!sns) goto fail; - if (fact_sample_count <= 0) goto fail; - vgmstream->num_samples = fact_sample_count; - //vgmstream->num_samples = dsp_bytes_to_samples(data_size, fmt.channel_count); - - /* coefs */ - { - int i, ch; - static const int16_t coef[16] = { /* common codebook? */ - 0x04ab,0xfced,0x0789,0xfedf,0x09a2,0xfae5,0x0c90,0xfac1, - 0x084d,0xfaa4,0x0982,0xfdf7,0x0af6,0xfafa,0x0be6,0xfbf5 - }; - - for (ch = 0; ch < fmt.channel_count; ch++) { - for (i = 0; i < 16; i++) { - vgmstream->ch[ch].adpcm_coef[i] = coef[i]; - } - } - } - - break; - #ifdef VGM_USE_FFMPEG case coding_FFmpeg: { ffmpeg_codec_data *ffmpeg_data = init_ffmpeg_offset(streamFile, 0x00, streamFile->get_size(streamFile)); @@ -657,9 +623,6 @@ VGMSTREAM * init_vgmstream_riff(STREAMFILE *streamFile) { if (mwv) { vgmstream->meta_type = meta_RIFF_WAVE_MWV; } - if (sns) { - vgmstream->meta_type = meta_RIFF_WAVE_SNS; - } if ( !vgmstream_open_stream(vgmstream,streamFile,start_offset) ) @@ -722,7 +685,6 @@ VGMSTREAM * init_vgmstream_rifx(STREAMFILE *streamFile) { streamFile, current_chunk, &fmt, - 0, /* sns == false */ 0)) /* mwv == false */ goto fail; diff --git a/src/meta/ubi_jade.c b/src/meta/ubi_jade.c index 0eecc4bf..0feb6cc4 100644 --- a/src/meta/ubi_jade.c +++ b/src/meta/ubi_jade.c @@ -4,7 +4,7 @@ static STREAMFILE* setup_jade_streamfile(STREAMFILE *streamFile, off_t subfile_offset, size_t subfile_size, const char* fake_ext); static int get_loop_points(STREAMFILE *streamFile, int *out_loop_start, int *out_loop_end); -/* Jade RIFF - from Jade engine games [Beyond Good & Evil (multi), Rayman Raving Rabbids 1/2 (multi)] */ +/* Jade RIFF - from Ubisoft Jade engine games [Beyond Good & Evil (multi), Rayman Raving Rabbids 1/2 (multi)] */ VGMSTREAM * init_vgmstream_ubi_jade(STREAMFILE *streamFile) { VGMSTREAM * vgmstream = NULL; off_t start_offset, first_offset = 0xc; @@ -21,7 +21,7 @@ VGMSTREAM * init_vgmstream_ubi_jade(STREAMFILE *streamFile) { if (!check_extensions(streamFile,"waa,wac,wad,wam,wav,lwav,psw")) goto fail; - /* an slightly twisted RIFF with custom codecs */ + /* a slightly twisted RIFF with custom codecs */ if (read_32bitBE(0x00,streamFile) != 0x52494646 || /* "RIFF" */ read_32bitBE(0x08,streamFile) != 0x57415645) /* "WAVE" */ goto fail; @@ -101,7 +101,7 @@ VGMSTREAM * init_vgmstream_ubi_jade(STREAMFILE *streamFile) { if (!vgmstream) goto fail; vgmstream->sample_rate = sample_rate; - vgmstream->meta_type = meta_JADE_RIFF; + vgmstream->meta_type = meta_UBI_JADE; if (is_jade_v2) { vgmstream->loop_start_sample = loop_start; vgmstream->loop_end_sample = loop_end; diff --git a/src/meta/wwise.c b/src/meta/wwise.c index 04e720d2..53d1e3e3 100644 --- a/src/meta/wwise.c +++ b/src/meta/wwise.c @@ -78,6 +78,18 @@ VGMSTREAM * init_vgmstream_wwise(STREAMFILE *streamFile) { } #endif + /* ignore LyN RIFF */ + { + off_t fact_offset; + size_t fact_size; + + if (find_chunk(streamFile, 0x66616374,first_offset,0, &fact_offset,&fact_size, 0, 0)) { /* "fact" */ + if (fact_size == 0x10 && read_32bitBE(fact_offset+0x04, streamFile) == 0x4C794E20) /* "LyN " */ + goto fail; /* parsed elsewhere */ + /* Wwise doesn't use "fact", though */ + } + } + /* parse format (roughly spec-compliant but some massaging is needed) */ { diff --git a/src/vgmstream.h b/src/vgmstream.h index 0bb20886..c0b7b580 100644 --- a/src/vgmstream.h +++ b/src/vgmstream.h @@ -394,7 +394,7 @@ typedef enum { meta_GSP_GSB, /* Tecmo games (Super Swing Golf 1 & 2, Quamtum Theory) */ meta_YDSP, /* WWE Day of Reckoning */ meta_FFCC_STR, /* Final Fantasy: Crystal Chronicles */ - meta_JADE_RIFF, /* Beyond Good & Evil, Rayman Raving Rabbids */ + meta_UBI_JADE, /* Beyond Good & Evil, Rayman Raving Rabbids */ meta_GCA, /* Metal Slug Anthology */ meta_MSVP, /* Popcap Hits */ meta_NGC_SSM, /* Golden Gashbell Full Power */ @@ -476,7 +476,6 @@ typedef enum { meta_RIFF_WAVE_smpl, /* RIFF w/ loop data in smpl chunk */ meta_RIFF_WAVE_wsmp, /* RIFF w/ loop data in wsmp chunk */ meta_RIFF_WAVE_MWV, /* .mwv RIFF w/ loop data in ctrl chunk pflt */ - meta_RIFF_WAVE_SNS, /* .sns RIFF */ meta_RIFX_WAVE, /* RIFX, for big-endian WAVs */ meta_RIFX_WAVE_smpl, /* RIFX w/ loop data in smpl chunk */ meta_XNB, /* XNA Game Studio 4.0 */