Add support for XIPH_CUE_LOOP pairs found in Super Mario Run (Android) OGGs. Some additional formatting fixes too.

This commit is contained in:
bxaimc 2018-03-29 21:03:23 -04:00
parent ceaa776f83
commit 0e7f19d77a
4 changed files with 33 additions and 26 deletions

View File

@ -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",

View File

@ -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;
}
}
}
}

View File

@ -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;
}

View File

@ -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;
}