From ceaa776f835dada4fdbec2838cb61aa06718240a Mon Sep 17 00:00:00 2001 From: bxaimc Date: Mon, 19 Mar 2018 15:19:30 -0400 Subject: [PATCH 1/3] Add -official- VSV extension to PSH meta. Modified channe_count flag in VSF for test files found in FFXII:TZA (PS4). --- src/formats.c | 5 +++-- src/meta/ps2_psh.c | 34 ++++++++++------------------------ src/meta/vsf.c | 40 ++++++++++++---------------------------- src/vgmstream.h | 2 +- 4 files changed, 26 insertions(+), 55 deletions(-) diff --git a/src/formats.c b/src/formats.c index 20ebe87e..c48d07f7 100644 --- a/src/formats.c +++ b/src/formats.c @@ -236,7 +236,7 @@ static const char* extension_list[] = { "pona", "pos", "ps2stm", //fake extension for .stm (to be removed) - "psh", + "psh", // fake extension for VSV(?) Dawn of Mana needs to be checked again "psnd", "psw", @@ -351,6 +351,7 @@ static const char* extension_list[] = { "vpk", "vs", "vsf", + "vsv", // official extension for PSH? TODO: recheck Dawn of Mana "vxn", "waa", @@ -698,7 +699,7 @@ static const meta_info meta_info_list[] = { {meta_MUS_ACM, "InterPlay MUS ACM header"}, {meta_PS2_KCES, "Konami KCES Header"}, {meta_PS2_DXH, "Tokobot Plus DXH Header"}, - {meta_PS2_PSH, "Dawn of Mana - Seiken Densetsu 4 PSH Header"}, + {meta_PS2_PSH, "Square Enix PSH/VSV Header"}, {meta_RIFF_WAVE_labl, "RIFF WAVE header with loop markers"}, {meta_RIFF_WAVE_smpl, "RIFF WAVE header with sample looping info"}, {meta_RIFF_WAVE_wsmp, "RIFF WAVE header with wsmp looping info"}, diff --git a/src/meta/ps2_psh.c b/src/meta/ps2_psh.c index e502a1ee..5d451188 100644 --- a/src/meta/ps2_psh.c +++ b/src/meta/ps2_psh.c @@ -1,11 +1,10 @@ #include "meta.h" #include "../util.h" -/* PSH (from Dawn of Mana - Seiken Densetsu 4) */ +/* PSH (from Dawn of Mana - Seiken Densetsu 4, Kingdom Hearts Re:Chain of Memories) */ /* probably Square Vag Stream */ VGMSTREAM * init_vgmstream_ps2_psh(STREAMFILE *streamFile) { VGMSTREAM * vgmstream = NULL; - char filename[PATH_LIMIT]; off_t start_offset; uint8_t testBuffer[0x10]; off_t loopEnd = 0; @@ -15,9 +14,9 @@ VGMSTREAM * init_vgmstream_ps2_psh(STREAMFILE *streamFile) { int loop_flag; int channel_count; - /* check extension, case insensitive */ - streamFile->get_name(streamFile,filename,sizeof(filename)); - if (strcasecmp("psh",filename_extension(filename))) goto fail; + /* check extension, case insensitive */ + if (!check_extensions(streamFile, "psh,vsv")) // vsv seems to be official extension + goto fail; /* check header */ if (read_16bitBE(0x02,streamFile) != 0x6400) @@ -65,25 +64,12 @@ VGMSTREAM * init_vgmstream_ps2_psh(STREAMFILE *streamFile) { vgmstream->meta_type = meta_PS2_PSH; /* open the file for reading */ - { - int i; - STREAMFILE * file; - file = streamFile->open(streamFile,filename,STREAMFILE_DEFAULT_BUFFER_SIZE); - if (!file) goto fail; - for (i=0;ich[i].streamfile = file; + if (!vgmstream_open_stream(vgmstream, streamFile, start_offset)) + goto fail; + return vgmstream; - vgmstream->ch[i].channel_start_offset= - vgmstream->ch[i].offset=start_offset+ - vgmstream->interleave_block_size*i; - - } - } - - return vgmstream; - - /* clean up anything we may have opened */ + /* clean up anything we may have opened */ fail: - if (vgmstream) close_vgmstream(vgmstream); - return NULL; + close_vgmstream(vgmstream); + return NULL; } diff --git a/src/meta/vsf.c b/src/meta/vsf.c index 36047ece..dc20476e 100644 --- a/src/meta/vsf.c +++ b/src/meta/vsf.c @@ -4,22 +4,19 @@ /* VSF (from Musashi: Samurai Legend) */ VGMSTREAM * init_vgmstream_ps2_vsf(STREAMFILE *streamFile) { VGMSTREAM * vgmstream = NULL; - char filename[PATH_LIMIT]; off_t start_offset; + int loop_flag, channel_count; - int loop_flag; - int channel_count; - - /* check extension, case insensitive */ - streamFile->get_name(streamFile,filename,sizeof(filename)); - if (strcasecmp("vsf",filename_extension(filename))) goto fail; + /* check extension, case insensitive */ + if (!check_extensions(streamFile, "vsf")) + goto fail; /* check header */ if (read_32bitBE(0x00,streamFile) != 0x56534600) /* "VSF" */ goto fail; loop_flag = (read_32bitLE(0x1c,streamFile)==0x13); - if(read_32bitLE(0x8,streamFile)==0x0) + if(read_8bit(0x1C,streamFile)==0x0) channel_count = 1; else channel_count = 2; @@ -43,26 +40,13 @@ VGMSTREAM * init_vgmstream_ps2_vsf(STREAMFILE *streamFile) { vgmstream->interleave_block_size = 0x400; vgmstream->meta_type = meta_PS2_VSF; - /* open the file for reading */ - { - int i; - STREAMFILE * file; - file = streamFile->open(streamFile,filename,STREAMFILE_DEFAULT_BUFFER_SIZE); - if (!file) goto fail; - for (i=0;ich[i].streamfile = file; + /* open the file for reading */ + if (!vgmstream_open_stream(vgmstream, streamFile, start_offset)) + goto fail; + return vgmstream; - vgmstream->ch[i].channel_start_offset= - vgmstream->ch[i].offset=start_offset+ - vgmstream->interleave_block_size*i; - - } - } - - return vgmstream; - - /* clean up anything we may have opened */ + /* clean up anything we may have opened */ fail: - if (vgmstream) close_vgmstream(vgmstream); - return NULL; + close_vgmstream(vgmstream); + return NULL; } diff --git a/src/vgmstream.h b/src/vgmstream.h index 5cc7b03a..9f28e649 100644 --- a/src/vgmstream.h +++ b/src/vgmstream.h @@ -368,7 +368,7 @@ typedef enum { meta_PS2_RSTM, /* Midnight Club 3 */ meta_PS2_KCES, /* Dance Dance Revolution */ meta_PS2_DXH, /* Tokobot Plus - Myteries of the Karakuri */ - meta_PS2_PSH, /* Dawn of Mana - Seiken Densetsu 4 */ + meta_PS2_PSH, /* Square Enix PSH/VSV (Dawn of Mana/KH Re:CoM) */ meta_SCD_PCM, /* Lunar - Eternal Blue */ meta_PS2_PCM, /* Konami KCEJ East: Ephemeral Fantasia, Yu-Gi-Oh! The Duelists of the Roses, 7 Blades */ meta_PS2_RKV, /* Legacy of Kain - Blood Omen 2 */ From 0e7f19d77a152d01c0f3e25687ef510b2b5d9560 Mon Sep 17 00:00:00 2001 From: bxaimc Date: Thu, 29 Mar 2018 21:03:23 -0400 Subject: [PATCH 2/3] Add support for XIPH_CUE_LOOP pairs found in Super Mario Run (Android) OGGs. Some additional formatting fixes too. --- src/formats.c | 2 +- src/meta/ogg_vorbis.c | 9 ++++++++- src/meta/ps2_psh.c | 18 +++++++++--------- src/meta/vsf.c | 30 +++++++++++++++--------------- 4 files changed, 33 insertions(+), 26 deletions(-) diff --git a/src/formats.c b/src/formats.c index c48d07f7..8420c014 100644 --- a/src/formats.c +++ b/src/formats.c @@ -351,7 +351,7 @@ static const char* extension_list[] = { "vpk", "vs", "vsf", - "vsv", // official extension for PSH? TODO: recheck Dawn of Mana + "vsv", // official extension for PSH? TODO: recheck Dawn of Mana "vxn", "waa", diff --git a/src/meta/ogg_vorbis.c b/src/meta/ogg_vorbis.c index 01204ee9..a9c9d543 100644 --- a/src/meta/ogg_vorbis.c +++ b/src/meta/ogg_vorbis.c @@ -386,7 +386,8 @@ VGMSTREAM * init_vgmstream_ogg_vorbis_callbacks(STREAMFILE *streamFile, const ch strstr(user_comment,"LOOPSTART=")==user_comment || strstr(user_comment,"um3.stream.looppoint.start=")==user_comment || strstr(user_comment,"LOOP_BEGIN=")==user_comment || /* Hatsune Miku: Project Diva F (PS3) */ - strstr(user_comment,"LoopStart=")==user_comment) { /* Devil May Cry 4 (PC) */ + strstr(user_comment,"LoopStart=")==user_comment || /* Devil May Cry 4 (PC) */ + strstr(user_comment,"XIPH_CUE_LOOPSTART=")==user_comment) { /* Super Mario Run (Android) */ loop_start = atol(strrchr(user_comment,'=')+1); loop_flag = (loop_start >= 0); } @@ -430,6 +431,12 @@ VGMSTREAM * init_vgmstream_ogg_vorbis_callbacks(STREAMFILE *streamFile, const ch loop_flag = 1; loop_end_found = 1; } + else if (strstr(user_comment, "XIPH_CUE_LOOPEND=") == user_comment) { /* XIPH_CUE_LOOPSTART pair */ + if (loop_flag) { + loop_length = atol(strrchr(user_comment, '=') + 1) - loop_start; + loop_length_found = 1; + } + } } } diff --git a/src/meta/ps2_psh.c b/src/meta/ps2_psh.c index 5d451188..cb9d3a1b 100644 --- a/src/meta/ps2_psh.c +++ b/src/meta/ps2_psh.c @@ -14,9 +14,9 @@ VGMSTREAM * init_vgmstream_ps2_psh(STREAMFILE *streamFile) { int loop_flag; int channel_count; - /* check extension, case insensitive */ - if (!check_extensions(streamFile, "psh,vsv")) // vsv seems to be official extension - goto fail; + /* check extension, case insensitive */ + if (!check_extensions(streamFile, "psh,vsv")) // vsv seems to be official extension + goto fail; /* check header */ if (read_16bitBE(0x02,streamFile) != 0x6400) @@ -64,12 +64,12 @@ VGMSTREAM * init_vgmstream_ps2_psh(STREAMFILE *streamFile) { vgmstream->meta_type = meta_PS2_PSH; /* open the file for reading */ - if (!vgmstream_open_stream(vgmstream, streamFile, start_offset)) - goto fail; - return vgmstream; + if (!vgmstream_open_stream(vgmstream, streamFile, start_offset)) + goto fail; + return vgmstream; - /* clean up anything we may have opened */ + /* clean up anything we may have opened */ fail: - close_vgmstream(vgmstream); - return NULL; + close_vgmstream(vgmstream); + return NULL; } diff --git a/src/meta/vsf.c b/src/meta/vsf.c index dc20476e..07751bea 100644 --- a/src/meta/vsf.c +++ b/src/meta/vsf.c @@ -5,21 +5,21 @@ VGMSTREAM * init_vgmstream_ps2_vsf(STREAMFILE *streamFile) { VGMSTREAM * vgmstream = NULL; off_t start_offset; - int loop_flag, channel_count; + int loop_flag, channel_count; - /* check extension, case insensitive */ - if (!check_extensions(streamFile, "vsf")) - goto fail; + /* check extension, case insensitive */ + if (!check_extensions(streamFile, "vsf")) + goto fail; /* check header */ if (read_32bitBE(0x00,streamFile) != 0x56534600) /* "VSF" */ goto fail; loop_flag = (read_32bitLE(0x1c,streamFile)==0x13); - if(read_8bit(0x1C,streamFile)==0x0) - channel_count = 1; - else - channel_count = 2; + if(read_8bit(0x1C,streamFile)==0x0) + channel_count = 1; + else + channel_count = 2; /* build the VGMSTREAM */ vgmstream = allocate_vgmstream(channel_count,loop_flag); @@ -40,13 +40,13 @@ VGMSTREAM * init_vgmstream_ps2_vsf(STREAMFILE *streamFile) { vgmstream->interleave_block_size = 0x400; vgmstream->meta_type = meta_PS2_VSF; - /* open the file for reading */ - if (!vgmstream_open_stream(vgmstream, streamFile, start_offset)) - goto fail; - return vgmstream; + /* open the file for reading */ + if (!vgmstream_open_stream(vgmstream, streamFile, start_offset)) + goto fail; + return vgmstream; - /* clean up anything we may have opened */ + /* clean up anything we may have opened */ fail: - close_vgmstream(vgmstream); - return NULL; + close_vgmstream(vgmstream); + return NULL; } From 68296163a9daf0e04a84fcd390f5766ffef104ab Mon Sep 17 00:00:00 2001 From: bxaimc Date: Thu, 29 Mar 2018 21:10:05 -0400 Subject: [PATCH 3/3] formatting again, this time for ogg_vorbis.c --- src/meta/ogg_vorbis.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/meta/ogg_vorbis.c b/src/meta/ogg_vorbis.c index 5374dd42..fc030dab 100644 --- a/src/meta/ogg_vorbis.c +++ b/src/meta/ogg_vorbis.c @@ -387,7 +387,7 @@ VGMSTREAM * init_vgmstream_ogg_vorbis_callbacks(STREAMFILE *streamFile, ov_callb strstr(user_comment,"um3.stream.looppoint.start=")==user_comment || strstr(user_comment,"LOOP_BEGIN=")==user_comment || /* Hatsune Miku: Project Diva F (PS3) */ strstr(user_comment,"LoopStart=")==user_comment || /* Devil May Cry 4 (PC) */ - strstr(user_comment,"XIPH_CUE_LOOPSTART=")==user_comment) { /* Super Mario Run (Android) */ + strstr(user_comment,"XIPH_CUE_LOOPSTART=")==user_comment) { /* Super Mario Run (Android) */ loop_start = atol(strrchr(user_comment,'=')+1); loop_flag = (loop_start >= 0); } @@ -431,11 +431,11 @@ VGMSTREAM * init_vgmstream_ogg_vorbis_callbacks(STREAMFILE *streamFile, ov_callb loop_flag = 1; loop_end_found = 1; } - else if (strstr(user_comment, "XIPH_CUE_LOOPEND=") == user_comment) { /* XIPH_CUE_LOOPSTART pair */ - if (loop_flag) { - loop_length = atol(strrchr(user_comment, '=') + 1) - loop_start; - loop_length_found = 1; - } + else if (strstr(user_comment, "XIPH_CUE_LOOPEND=") == user_comment) { /* XIPH_CUE_LOOPSTART pair */ + if (loop_flag) { + loop_length = atol(strrchr(user_comment, '=') + 1) - loop_start; + loop_length_found = 1; + } } } }