From dfe1be9d88dedd8c9bda15dd1b4059819b74dc0b Mon Sep 17 00:00:00 2001 From: Chris Moeller Date: Fri, 14 Mar 2014 22:36:23 -0700 Subject: [PATCH 1/4] Fixed remaining path length limit issues --- src/meta/2dx.c | 2 +- src/meta/dc_dcsw_dcs.c | 2 +- src/meta/dsp_sth_str.c | 6 +++--- src/meta/gsp_gsb.c | 2 +- src/meta/ish_isd.c | 2 +- src/meta/mus_acm.c | 2 +- src/meta/ngc_sck_dsp.c | 2 +- src/meta/nwa.c | 8 ++++---- src/meta/pos.c | 2 +- src/meta/ps2_mib.c | 2 +- src/meta/ps2_wmus.c | 2 +- src/meta/ps3_sgh_sgb.c | 2 +- src/meta/sfl.c | 2 +- src/meta/sli.c | 4 ++-- src/meta/spt_spd.c | 2 +- 15 files changed, 21 insertions(+), 21 deletions(-) diff --git a/src/meta/2dx.c b/src/meta/2dx.c index 7053f310..ebe39903 100644 --- a/src/meta/2dx.c +++ b/src/meta/2dx.c @@ -4,7 +4,7 @@ /* 2DX (found in beatmaniaIIDX16 - EMPRESS (Arcade) */ VGMSTREAM * init_vgmstream_2dx(STREAMFILE *streamFile) { VGMSTREAM * vgmstream = NULL; - char filename[260]; + char filename[PATH_LIMIT]; off_t start_offset; int loop_flag; diff --git a/src/meta/dc_dcsw_dcs.c b/src/meta/dc_dcsw_dcs.c index 128c7a7d..23105fd0 100644 --- a/src/meta/dc_dcsw_dcs.c +++ b/src/meta/dc_dcsw_dcs.c @@ -13,7 +13,7 @@ VGMSTREAM * init_vgmstream_dc_dcsw_dcs(STREAMFILE *streamFile) { VGMSTREAM * vgmstream = NULL; STREAMFILE * streamFileDCSW = NULL; char filename[PATH_LIMIT]; - char filenameDCSW[260]; + char filenameDCSW[PATH_LIMIT]; int i; int channel_count; int loop_flag; diff --git a/src/meta/dsp_sth_str.c b/src/meta/dsp_sth_str.c index e601b6b1..4db018c1 100644 --- a/src/meta/dsp_sth_str.c +++ b/src/meta/dsp_sth_str.c @@ -10,7 +10,7 @@ VGMSTREAM * init_vgmstream_ngc_dsp_sth_str1(STREAMFILE *streamFile) { VGMSTREAM * vgmstream = NULL; STREAMFILE * streamFileSTR = NULL; char filename[PATH_LIMIT]; - char filenameSTR[260]; + char filenameSTR[PATH_LIMIT]; int i, j; int channel_count; int loop_flag; @@ -116,7 +116,7 @@ VGMSTREAM * init_vgmstream_ngc_dsp_sth_str2(STREAMFILE *streamFile) { VGMSTREAM * vgmstream = NULL; STREAMFILE * streamFileSTR = NULL; char filename[PATH_LIMIT]; - char filenameSTR[260]; + char filenameSTR[PATH_LIMIT]; int i, j; int channel_count; int loop_flag; @@ -222,7 +222,7 @@ VGMSTREAM * init_vgmstream_ngc_dsp_sth_str3(STREAMFILE *streamFile) { VGMSTREAM * vgmstream = NULL; STREAMFILE * streamFileSTR = NULL; char filename[PATH_LIMIT]; - char filenameSTR[260]; + char filenameSTR[PATH_LIMIT]; int i, j; int channel_count; int loop_flag; diff --git a/src/meta/gsp_gsb.c b/src/meta/gsp_gsb.c index 6847b88c..dba78710 100644 --- a/src/meta/gsp_gsb.c +++ b/src/meta/gsp_gsb.c @@ -9,7 +9,7 @@ VGMSTREAM * init_vgmstream_gsp_gsb(STREAMFILE *streamFile) { VGMSTREAM * vgmstream = NULL; STREAMFILE * streamFileGSP = NULL; char filename[PATH_LIMIT]; - char filenameGSP[260]; + char filenameGSP[PATH_LIMIT]; int channel_count; int loop_flag; int header_len; diff --git a/src/meta/ish_isd.c b/src/meta/ish_isd.c index 7078a093..6b3c734a 100644 --- a/src/meta/ish_isd.c +++ b/src/meta/ish_isd.c @@ -10,7 +10,7 @@ VGMSTREAM * init_vgmstream_ish_isd(STREAMFILE *streamFile) { VGMSTREAM * vgmstream = NULL; STREAMFILE * streamFileISH = NULL; char filename[PATH_LIMIT]; - char filenameISH[260]; + char filenameISH[PATH_LIMIT]; int i; int channel_count; int loop_flag; diff --git a/src/meta/mus_acm.c b/src/meta/mus_acm.c index 7bd10a8b..6d488785 100644 --- a/src/meta/mus_acm.c +++ b/src/meta/mus_acm.c @@ -13,7 +13,7 @@ #define DIRSEP '/' #endif -#define NAME_LENGTH 260 +#define NAME_LENGTH PATH_LIMIT int exists(char *filename, STREAMFILE *streamfile) { STREAMFILE * temp = diff --git a/src/meta/ngc_sck_dsp.c b/src/meta/ngc_sck_dsp.c index 7f5610c3..ad9e1498 100644 --- a/src/meta/ngc_sck_dsp.c +++ b/src/meta/ngc_sck_dsp.c @@ -11,7 +11,7 @@ VGMSTREAM * init_vgmstream_ngc_sck_dsp(STREAMFILE *streamFile) { VGMSTREAM * vgmstream = NULL; STREAMFILE * streamFileDSP = NULL; char filename[PATH_LIMIT]; - char filenameDSP[260]; + char filenameDSP[PATH_LIMIT]; int i; int channel_count; diff --git a/src/meta/nwa.c b/src/meta/nwa.c index d3f80993..d4743a5c 100644 --- a/src/meta/nwa.c +++ b/src/meta/nwa.c @@ -57,9 +57,9 @@ VGMSTREAM * init_vgmstream_nwa(STREAMFILE *streamFile) { /* try to locate NWAINFO.INI in the same directory */ { - char ininame[260]; + char ininame[PATH_LIMIT]; char * ini_lastslash; - char namebase_array[260]; + char namebase_array[PATH_LIMIT]; char *namebase; STREAMFILE *inistreamfile; @@ -134,9 +134,9 @@ VGMSTREAM * init_vgmstream_nwa(STREAMFILE *streamFile) { /* try to locate Gameexe.ini in the same directory */ { - char ininame[260]; + char ininame[PATH_LIMIT]; char * ini_lastslash; - char namebase_array[260]; + char namebase_array[PATH_LIMIT]; char * namebase; STREAMFILE *inistreamfile; diff --git a/src/meta/pos.c b/src/meta/pos.c index 153f7b11..c5ca20e0 100644 --- a/src/meta/pos.c +++ b/src/meta/pos.c @@ -15,7 +15,7 @@ VGMSTREAM * init_vgmstream_pos(STREAMFILE *streamFile) { VGMSTREAM * vgmstream = NULL; STREAMFILE * streamFileWAV = NULL; char filename[PATH_LIMIT]; - char filenameWAV[260]; + char filenameWAV[PATH_LIMIT]; int i; diff --git a/src/meta/ps2_mib.c b/src/meta/ps2_mib.c index a509d2db..26b669a2 100644 --- a/src/meta/ps2_mib.c +++ b/src/meta/ps2_mib.c @@ -51,7 +51,7 @@ VGMSTREAM * init_vgmstream_ps2_mib(STREAMFILE *streamFile) { off_t readOffset = 0; - char filenameMIH[260]; + char filenameMIH[PATH_LIMIT]; off_t loopStartPoints[0x10]; int loopStartPointsCount=0; diff --git a/src/meta/ps2_wmus.c b/src/meta/ps2_wmus.c index f669f78a..58f64d40 100644 --- a/src/meta/ps2_wmus.c +++ b/src/meta/ps2_wmus.c @@ -20,7 +20,7 @@ VGMSTREAM * init_vgmstream_ps2_wmus(STREAMFILE *streamFile) int shortBlockSize; int lastBlockLocation; - char filenameWHED[260]; + char filenameWHED[PATH_LIMIT]; STREAMFILE * streamFileWHED = NULL; //_TCHAR szBuffer[100]; diff --git a/src/meta/ps3_sgh_sgb.c b/src/meta/ps3_sgh_sgb.c index 3b9b0fb0..a99348a6 100644 --- a/src/meta/ps3_sgh_sgb.c +++ b/src/meta/ps3_sgh_sgb.c @@ -7,7 +7,7 @@ VGMSTREAM * init_vgmstream_ps3_sgh_sgb(STREAMFILE *streamFile) { off_t start_offset = 0; STREAMFILE * streamFileSGH = NULL; char filename[PATH_LIMIT]; - char filenameSGH[260]; + char filenameSGH[PATH_LIMIT]; int channel_count; int loop_flag; diff --git a/src/meta/sfl.c b/src/meta/sfl.c index 388c9c85..c656142b 100644 --- a/src/meta/sfl.c +++ b/src/meta/sfl.c @@ -73,7 +73,7 @@ static void parse_adtl(off_t adtl_offset, off_t adtl_length, STREAMFILE *stream VGMSTREAM * init_vgmstream_sfl(STREAMFILE *streamFile) { VGMSTREAM * vgmstream = NULL; STREAMFILE * streamFileOGG = NULL; - char filenameOGG[260]; + char filenameOGG[PATH_LIMIT]; char filename[PATH_LIMIT]; off_t file_size = -1; diff --git a/src/meta/sli.c b/src/meta/sli.c index 621cfb84..78d2950d 100644 --- a/src/meta/sli.c +++ b/src/meta/sli.c @@ -19,8 +19,8 @@ VGMSTREAM * init_vgmstream_sli_ogg(STREAMFILE *streamFile) { VGMSTREAM * vgmstream = NULL; STREAMFILE * streamFileOGG = NULL; char filename[PATH_LIMIT]; - char filenameOGG[260]; - char linebuffer[260]; + char filenameOGG[PATH_LIMIT]; + char linebuffer[PATH_LIMIT]; off_t bytes_read; off_t sli_offset; int done; diff --git a/src/meta/spt_spd.c b/src/meta/spt_spd.c index 53d73c8f..04b1a0a0 100644 --- a/src/meta/spt_spd.c +++ b/src/meta/spt_spd.c @@ -11,7 +11,7 @@ VGMSTREAM * init_vgmstream_spt_spd(STREAMFILE *streamFile) { VGMSTREAM * vgmstream = NULL; STREAMFILE * streamFileSPT = NULL; char filename[PATH_LIMIT]; - char filenameSPT[260]; + char filenameSPT[PATH_LIMIT]; int channel_count; int loop_flag; int i; From 633eb7b5456e0089a02b0aeba287ed3b3a9073a5 Mon Sep 17 00:00:00 2001 From: Chris Moeller Date: Fri, 14 Mar 2014 22:39:21 -0700 Subject: [PATCH 2/4] replacing meta for bcstm with revision from soneek --- src/meta/bcstm.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/meta/bcstm.c b/src/meta/bcstm.c index 2773a48e..a66f1179 100644 --- a/src/meta/bcstm.c +++ b/src/meta/bcstm.c @@ -79,15 +79,21 @@ VGMSTREAM * init_vgmstream_bcstm(STREAMFILE *streamFile) { if (vgmstream->coding_type == coding_NGC_DSP) { off_t coef_offset; - off_t coef_offset1; - off_t coef_offset2; + off_t tempoffset = head_offset; + int foundcoef = 0; int i, j; int coef_spacing = 0x2E; - - coef_offset1 = read_32bitLE(head_offset + 0x1c, streamFile); - coef_offset = coef_offset1 + 0x40; - + while (!(foundcoef)) + { + if ((uint32_t)read_32bitLE(tempoffset, streamFile) == 0x00004102) + { + coef_offset = read_32bitLE(tempoffset + 4, streamFile) + tempoffset + (channel_count * 8) - 4 - head_offset; + foundcoef++; + break; + } + tempoffset++; + } for (j = 0; jchannels; j++) { for (i = 0; i<16; i++) { From 9148d4e14a44bd49d895263319df5f6f6532bc26 Mon Sep 17 00:00:00 2001 From: Chris Moeller Date: Fri, 14 Mar 2014 22:40:30 -0700 Subject: [PATCH 3/4] another update from soneek for IMA support in BCSTM --- src/meta/bcstm.c | 64 +++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 52 insertions(+), 12 deletions(-) diff --git a/src/meta/bcstm.c b/src/meta/bcstm.c index a66f1179..9ee9d544 100644 --- a/src/meta/bcstm.c +++ b/src/meta/bcstm.c @@ -8,9 +8,11 @@ VGMSTREAM * init_vgmstream_bcstm(STREAMFILE *streamFile) { coding_t coding_type; off_t head_offset; + off_t seek_offset; int codec_number; int channel_count; int loop_flag; + int ima = 0; off_t start_offset; /* check extension, case insensitive */ @@ -29,11 +31,15 @@ VGMSTREAM * init_vgmstream_bcstm(STREAMFILE *streamFile) { /* get head offset, check */ head_offset = read_32bitLE(0x18, streamFile); - + if ((uint32_t)read_32bitBE(head_offset, streamFile) != 0x494E464F) /* "INFO" */ goto fail; - + seek_offset = read_32bitLE(0x24, streamFile); + + if ((uint32_t)read_32bitBE(seek_offset, streamFile) != 0x5345454B) /* "SEEK" If this header doesn't exist, assuming that the file is IMA */ + ima = 1; + /* check type details */ codec_number = read_8bit(head_offset + 0x20, streamFile); loop_flag = read_8bit(head_offset + 0x21, streamFile); @@ -47,7 +53,10 @@ VGMSTREAM * init_vgmstream_bcstm(STREAMFILE *streamFile) { coding_type = coding_PCM16BE; break; case 2: - coding_type = coding_NGC_DSP; + if (ima) + coding_type = coding_INT_IMA; + else + coding_type = coding_NGC_DSP; break; default: goto fail; @@ -64,19 +73,42 @@ VGMSTREAM * init_vgmstream_bcstm(STREAMFILE *streamFile) { vgmstream->num_samples = read_32bitLE(head_offset + 0x2c, streamFile); vgmstream->sample_rate = (uint16_t)read_16bitLE(head_offset + 0x24, streamFile); /* channels and loop flag are set by allocate_vgmstream */ - vgmstream->loop_start_sample = read_32bitLE(head_offset + 0x28, streamFile); - vgmstream->loop_end_sample = vgmstream->num_samples; + if (ima) //Shift the loop points back slightly to avoid stupid pops in some IMA streams due to DC offsetting + { + vgmstream->loop_start_sample = read_32bitLE(head_offset + 0x28, streamFile); + if (vgmstream->loop_start_sample > 10000) + { + vgmstream->loop_start_sample -= 5000; + vgmstream->loop_end_sample = vgmstream->num_samples - 5000; + } + else + vgmstream->loop_end_sample = vgmstream->num_samples; + } + else + { + vgmstream->loop_start_sample = read_32bitLE(head_offset + 0x28, streamFile); + vgmstream->loop_end_sample = vgmstream->num_samples; + } vgmstream->coding_type = coding_type; if (channel_count == 1) vgmstream->layout_type = layout_none; else - vgmstream->layout_type = layout_interleave_shortblock; + { + if (ima) + vgmstream->layout_type = layout_interleave; + else + vgmstream->layout_type = layout_interleave_shortblock; + } vgmstream->meta_type = meta_CSTM; - - vgmstream->interleave_block_size = read_32bitLE(head_offset + 0x34, streamFile); - vgmstream->interleave_smallblock_size = read_32bitLE(head_offset + 0x44, streamFile); - + + if (ima) + vgmstream->interleave_block_size = 0x200; + else { + vgmstream->interleave_block_size = read_32bitLE(head_offset + 0x34, streamFile); + vgmstream->interleave_smallblock_size = read_32bitLE(head_offset + 0x44, streamFile); + } + if (vgmstream->coding_type == coding_NGC_DSP) { off_t coef_offset; off_t tempoffset = head_offset; @@ -101,8 +133,13 @@ VGMSTREAM * init_vgmstream_bcstm(STREAMFILE *streamFile) { } } } - - start_offset = read_32bitLE(0x30, streamFile) + 0x20; + + if (ima) // No SEEK (ADPC) header, so just start where the SEEK header is supposed to be. + start_offset = seek_offset; + else + start_offset = read_32bitLE(0x30, streamFile) + 0x20; + + /* open the file for reading by each channel */ { @@ -111,6 +148,9 @@ VGMSTREAM * init_vgmstream_bcstm(STREAMFILE *streamFile) { if (vgmstream->layout_type == layout_interleave_shortblock) vgmstream->ch[i].streamfile = streamFile->open(streamFile, filename, vgmstream->interleave_block_size); + else if (vgmstream->layout_type == layout_interleave) + vgmstream->ch[i].streamfile = streamFile->open(streamFile, filename, + STREAMFILE_DEFAULT_BUFFER_SIZE); else vgmstream->ch[i].streamfile = streamFile->open(streamFile, filename, 0x1000); From b2c8e5cbacb8e3a16e56e33c6b5d8a6549a0fa83 Mon Sep 17 00:00:00 2001 From: Chris Moeller Date: Fri, 14 Mar 2014 22:42:06 -0700 Subject: [PATCH 4/4] Another Drag-On Dragoon 3weird samplerate (40999) From a set of files called BGM_TEST00_* --- src/meta/sqex_scd.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/meta/sqex_scd.c b/src/meta/sqex_scd.c index 11d1423a..82422b2d 100644 --- a/src/meta/sqex_scd.c +++ b/src/meta/sqex_scd.c @@ -177,6 +177,8 @@ VGMSTREAM * init_vgmstream_sqex_scd(STREAMFILE *streamFile) { if (vgmstream->sample_rate == 47999) vgmstream->sample_rate = 48000; + if (vgmstream->sample_rate == 44099) + vgmstream->sample_rate = 44100; mpeg_data = init_mpeg_codec_data(streamFile, start_offset, vgmstream->sample_rate, vgmstream->channels, &ct, NULL, NULL); if (!mpeg_data) goto fail;