From 0e22f0b95c017a5d54acad438b06700ad337a16d Mon Sep 17 00:00:00 2001 From: bnnm Date: Tue, 25 May 2021 23:33:17 +0200 Subject: [PATCH] Fix Opus .wem with metadata [Gears 5 (PC)] --- src/meta/wwise.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/meta/wwise.c b/src/meta/wwise.c index f6777fa7..8127cf20 100644 --- a/src/meta/wwise.c +++ b/src/meta/wwise.c @@ -471,7 +471,7 @@ VGMSTREAM* init_vgmstream_wwise(STREAMFILE* sf) { break; } - case OPUS: { /* fully standard Ogg Opus [Girl Cafe Gun (Mobile)] */ + case OPUS: { /* fully standard Ogg Opus [Girl Cafe Gun (Mobile), Gears 5 (PC)] */ if (ww.block_align != 0 || ww.bits_per_sample != 0) goto fail; /* extra: size 0x12 */ @@ -486,6 +486,15 @@ VGMSTREAM* init_vgmstream_wwise(STREAMFILE* sf) { ww.data_size = ww.file_size - start_offset; } + /* mutant .wem with metadata (voice strings/etc) at data start [Gears 5 (PC)] */ + if (ww.meta_offset) { + /* 0x00: original setup_offset? (0x00 for Opus) */ + uint32_t meta_skip = read_u32(ww.meta_offset + 0x04, sf); + + ww.data_offset += meta_skip; + ww.data_size -= meta_skip; + } + vgmstream->codec_data = init_ffmpeg_offset(sf, ww.data_offset, ww.data_size); if (!vgmstream->codec_data) goto fail; vgmstream->coding_type = coding_FFmpeg;