mirror of
https://github.com/vgmstream/vgmstream.git
synced 2025-02-06 14:44:25 +01:00
Tweak _0/1 dual extension detection
This commit is contained in:
parent
b2e3058072
commit
bc59318157
@ -2444,13 +2444,13 @@ void describe_vgmstream(VGMSTREAM * vgmstream, char * desc, int length) {
|
|||||||
static void try_dual_file_stereo(VGMSTREAM * opened_vgmstream, STREAMFILE *streamFile, VGMSTREAM*(*init_vgmstream_function)(STREAMFILE *)) {
|
static void try_dual_file_stereo(VGMSTREAM * opened_vgmstream, STREAMFILE *streamFile, VGMSTREAM*(*init_vgmstream_function)(STREAMFILE *)) {
|
||||||
/* filename search pairs for dual file stereo */
|
/* filename search pairs for dual file stereo */
|
||||||
static const char * const dfs_pairs[][2] = {
|
static const char * const dfs_pairs[][2] = {
|
||||||
{"L","R"},
|
{"L","R"}, /* most common in .dsp and .vag */
|
||||||
{"l","r"},
|
{"l","r"}, /* same */
|
||||||
{"left","right"},
|
{"left","right"}, /* Freaky Flyers (GC) .adp, Velocity (PSP) .vag, Hyper Fighters (Wii) .dsp */
|
||||||
{"Left","Right"},
|
{"Left","Right"}, /* Geometry Wars: Galaxies (Wii) .dsp */
|
||||||
{".V0",".V1"}, /* Homura (PS2) */
|
{".V0",".V1"}, /* Homura (PS2) */
|
||||||
{".L",".R"}, /* Crash Nitro Racing (PS2), Gradius V (PS2) */
|
{".L",".R"}, /* Crash Nitro Racing (PS2), Gradius V (PS2) */
|
||||||
{"_0","_1"}, /* fake for Homura/unneeded? */
|
{"_0.dsp","_1.dsp"}, /* Wario World (GC) */
|
||||||
{".adpcm","_NxEncoderOut_.adpcm"}, /* Kill la Kill: IF (Switch) */ //todo can't match R>L
|
{".adpcm","_NxEncoderOut_.adpcm"}, /* Kill la Kill: IF (Switch) */ //todo can't match R>L
|
||||||
};
|
};
|
||||||
char new_filename[PATH_LIMIT];
|
char new_filename[PATH_LIMIT];
|
||||||
@ -2470,7 +2470,7 @@ static void try_dual_file_stereo(VGMSTREAM * opened_vgmstream, STREAMFILE *strea
|
|||||||
//todo other layouts work but some stereo codecs do weird things
|
//todo other layouts work but some stereo codecs do weird things
|
||||||
//if (opened_vgmstream->layout != layout_none) return;
|
//if (opened_vgmstream->layout != layout_none) return;
|
||||||
|
|
||||||
get_streamfile_name(streamFile,new_filename,sizeof(new_filename));
|
get_streamfile_name(streamFile, new_filename, sizeof(new_filename));
|
||||||
filename_len = strlen(new_filename);
|
filename_len = strlen(new_filename);
|
||||||
if (filename_len < 2)
|
if (filename_len < 2)
|
||||||
return;
|
return;
|
||||||
@ -2493,15 +2493,15 @@ static void try_dual_file_stereo(VGMSTREAM * opened_vgmstream, STREAMFILE *strea
|
|||||||
//;VGM_LOG("DFS: l=%s, r=%s\n", this_suffix,that_suffix);
|
//;VGM_LOG("DFS: l=%s, r=%s\n", this_suffix,that_suffix);
|
||||||
|
|
||||||
/* if suffix matches paste opposite suffix (+ terminator) to extension pointer, thus to new_filename */
|
/* if suffix matches paste opposite suffix (+ terminator) to extension pointer, thus to new_filename */
|
||||||
if (this_suffix[0] == '.' && extension_len == this_suffix_len) { /* same extension */
|
if (filename_len > this_suffix_len && strchr(this_suffix, '.') != NULL) { /* same suffix with extension */
|
||||||
//;VGM_LOG("DFS: same ext %s vs %s len %i\n", extension, this_suffix, this_suffix_len);
|
//;VGM_LOG("DFS: suf+ext %s vs %s len %i\n", new_filename, this_suffix, this_suffix_len);
|
||||||
if (memcmp(extension,this_suffix,this_suffix_len) == 0) {
|
if (memcmp(new_filename + (filename_len - this_suffix_len), this_suffix, this_suffix_len) == 0) {
|
||||||
dfs_pair = j;
|
dfs_pair = j;
|
||||||
memcpy (extension, that_suffix,that_suffix_len+1);
|
memcpy (new_filename + (filename_len - this_suffix_len), that_suffix,that_suffix_len+1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (filename_len - extension_len > this_suffix_len) { /* same suffix (without extension) */
|
else if (filename_len - extension_len > this_suffix_len) { /* same suffix without extension */
|
||||||
//;VGM_LOG("DFS: same suf %s vs %s len %i\n", extension - this_suffix_len, this_suffix, this_suffix_len);
|
//;VGM_LOG("DFS: suf-ext %s vs %s len %i\n", extension - this_suffix_len, this_suffix, this_suffix_len);
|
||||||
if (memcmp(extension - this_suffix_len, this_suffix,this_suffix_len) == 0) {
|
if (memcmp(extension - this_suffix_len, this_suffix,this_suffix_len) == 0) {
|
||||||
dfs_pair = j;
|
dfs_pair = j;
|
||||||
memmove(extension + that_suffix_len - this_suffix_len, extension,extension_len+1); /* move old extension to end */
|
memmove(extension + that_suffix_len - this_suffix_len, extension,extension_len+1); /* move old extension to end */
|
||||||
@ -2517,7 +2517,7 @@ static void try_dual_file_stereo(VGMSTREAM * opened_vgmstream, STREAMFILE *strea
|
|||||||
//;VGM_LOG("DFS: match %i filename=%s\n", dfs_pair, new_filename);
|
//;VGM_LOG("DFS: match %i filename=%s\n", dfs_pair, new_filename);
|
||||||
|
|
||||||
/* try to init other channel (new_filename now has the opposite name) */
|
/* try to init other channel (new_filename now has the opposite name) */
|
||||||
dual_streamFile = open_streamfile(streamFile,new_filename);
|
dual_streamFile = open_streamfile(streamFile, new_filename);
|
||||||
if (!dual_streamFile) goto fail;
|
if (!dual_streamFile) goto fail;
|
||||||
|
|
||||||
new_vgmstream = init_vgmstream_function(dual_streamFile); /* use the init that just worked, no other should work */
|
new_vgmstream = init_vgmstream_function(dual_streamFile); /* use the init that just worked, no other should work */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user