From c87aff04f93974a2a2209ff61297de1c96ee3b30 Mon Sep 17 00:00:00 2001 From: bnnm Date: Sat, 1 Dec 2018 02:47:57 +0100 Subject: [PATCH] Add opus+sli looping [Sabbat of the Witch (PC)] --- src/formats.c | 6 +++--- src/meta/sli.c | 41 +++++++++++++++++++++++++++++------------ src/vgmstream.h | 2 +- 3 files changed, 33 insertions(+), 16 deletions(-) diff --git a/src/formats.c b/src/formats.c index d6f1e798..8530d34b 100644 --- a/src/formats.c +++ b/src/formats.c @@ -1046,9 +1046,9 @@ static const meta_info meta_info_list[] = { {meta_PC_FLX, "Ultima IX .FLX header"}, {meta_MOGG, "Harmonix Music Systems MOGG Vorbis"}, {meta_OGG_VORBIS, "Ogg Vorbis"}, - {meta_OGG_SLI, "Ogg Vorbis with .sli (start,length) for looping"}, - {meta_OGG_SLI2, "Ogg Vorbis with .sli (from,to) for looping"}, - {meta_OGG_SFL, "Ogg Vorbis with SFPL for looping"}, + {meta_OGG_SLI, "Ogg Vorbis with .sli looping"}, + {meta_OPUS_SLI, "Ogg Opus with .sli looping"}, + {meta_OGG_SFL, "Ogg Vorbis with SFPL looping"}, {meta_OGG_KOVS, "Ogg Vorbis (KOVS header)"}, {meta_OGG_encrypted, "Ogg Vorbis (encrypted)"}, {meta_KMA9, "Koei Tecmo KMA9 header"}, diff --git a/src/meta/sli.c b/src/meta/sli.c index f4ed5024..2ecf5427 100644 --- a/src/meta/sli.c +++ b/src/meta/sli.c @@ -2,7 +2,7 @@ #include -/* .sli - loop points associated with a similarly named .ogg [Fate/Stay Night (PC), World End Economica (PC)]*/ +/* .sli+ogg/opus - KiriKiri engine / WaveLoopManager loop points loader [Fate/Stay Night (PC), World End Economica (PC)] */ VGMSTREAM * init_vgmstream_sli_ogg(STREAMFILE *streamFile) { VGMSTREAM * vgmstream = NULL; STREAMFILE * streamData = NULL; @@ -14,23 +14,42 @@ VGMSTREAM * init_vgmstream_sli_ogg(STREAMFILE *streamFile) { goto fail; { - /* try with file.ogg.sli=header and file.ogg=data */ + /* try with file.ogg/opus.sli=header and file.ogg/opus=data */ char basename[PATH_LIMIT]; get_streamfile_basename(streamFile,basename,PATH_LIMIT); streamData = open_streamfile_by_filename(streamFile, basename); if (!streamData) goto fail; - - if (!check_extensions(streamData, "ogg")) - goto fail; } -#ifdef VGM_USE_VORBIS + /* let the real initer do the parsing */ - vgmstream = init_vgmstream_ogg_vorbis(streamData); - if (!vgmstream) goto fail; + if (check_extensions(streamData, "ogg")) { /* Fate/Stay Night (PC) */ +#ifdef VGM_USE_VORBIS + vgmstream = init_vgmstream_ogg_vorbis(streamData); + if (!vgmstream) goto fail; + + vgmstream->meta_type = meta_OGG_SLI; #else goto fail; #endif + } + else if (check_extensions(streamData, "opus")) { /* Sabbat of the Witch (PC) */ +#ifdef VGM_USE_FFMPEG + vgmstream = init_vgmstream_ffmpeg(streamData); + if (!vgmstream) goto fail; + + /* FFmpeg's Opus encoder delay is borked but no need to fix: + * somehow sli+opus use 0 in the OpusHead (to simplify looping?) */ + + vgmstream->meta_type = meta_OPUS_SLI; +#else + goto fail; +#endif + } + else { + goto fail; + } + /* find loop text */ { @@ -77,13 +96,11 @@ VGMSTREAM * init_vgmstream_sli_ogg(STREAMFILE *streamFile) { } } - if (loop_start != -1 && loop_length != -1) { + if (loop_start != -1 && loop_length != -1) { /* v1 */ vgmstream_force_loop(vgmstream,1,loop_start, loop_start+loop_length); - vgmstream->meta_type = meta_OGG_SLI; } - else if (loop_from != -1 && loop_to != -1) { + else if (loop_from != -1 && loop_to != -1) { /* v2 */ vgmstream_force_loop(vgmstream,1,loop_to, loop_from); - vgmstream->meta_type = meta_OGG_SLI2; } else { goto fail; /* if there's no loop points the .sli wasn't valid */ diff --git a/src/vgmstream.h b/src/vgmstream.h index 9a3f81d9..da7709b5 100644 --- a/src/vgmstream.h +++ b/src/vgmstream.h @@ -641,7 +641,7 @@ typedef enum { meta_MOGG, /* Harmonix Music Systems MOGG Vorbis */ meta_OGG_VORBIS, /* Ogg Vorbis */ meta_OGG_SLI, /* Ogg Vorbis file w/ companion .sli for looping */ - meta_OGG_SLI2, /* Ogg Vorbis file w/ different styled .sli for looping */ + meta_OPUS_SLI, /* Ogg Opus file w/ companion .sli for looping */ meta_OGG_SFL, /* Ogg Vorbis file w/ .sfl (RIFF SFPL) for looping */ meta_OGG_KOVS, /* Ogg Vorbis with header and encryption (Koei Tecmo Games) */ meta_OGG_encrypted, /* Ogg Vorbis with encryption */