From 16bae0a74d2af7a7673420c837055dbfdd00fea4 Mon Sep 17 00:00:00 2001 From: bxaimc Date: Tue, 8 Feb 2011 12:56:16 +0000 Subject: [PATCH] Combined FSB metas git-svn-id: https://vgmstream.svn.sourceforge.net/svnroot/vgmstream@918 51a99a44-fe44-0410-b1ba-c3e57ba2b86b --- src/Makefile | 3 +- src/libvgmstream.vcproj | 12 +-- src/meta/Makefile.unix.am | 3 +- src/meta/fsb.c | 145 +++++++++++++++++++++++++++++ src/meta/fsb_test.c | 149 ------------------------------ src/meta/meta.h | 2 +- src/meta/{se_scd.c => sqex_scd.c} | 4 +- src/vgmstream.c | 4 +- src/vgmstream.h | 2 +- 9 files changed, 157 insertions(+), 167 deletions(-) delete mode 100644 src/meta/fsb_test.c rename src/meta/{se_scd.c => sqex_scd.c} (98%) diff --git a/src/Makefile b/src/Makefile index 356913a4..f6526ac6 100644 --- a/src/Makefile +++ b/src/Makefile @@ -220,7 +220,6 @@ META_OBJS=meta/adx_header.o \ meta/exakt_sc.o \ meta/wii_bns.o \ meta/pona.o \ - meta/fsb_test.o \ meta/xbox_hlwav.o \ meta/stx.o \ meta/ps2_stm.o \ @@ -258,7 +257,7 @@ META_OBJS=meta/adx_header.o \ meta/ps2_jstm.o \ meta/ps3_xvag.o \ meta/ps3_cps.o \ - meta/se_scd.o \ + meta/sqex_scd.o \ meta/ngc_nst_dsp.o \ meta/baf.o \ meta/ps3_msf.o \ diff --git a/src/libvgmstream.vcproj b/src/libvgmstream.vcproj index 0b409876..6f7836f3 100644 --- a/src/libvgmstream.vcproj +++ b/src/libvgmstream.vcproj @@ -328,10 +328,6 @@ RelativePath=".\meta\fsb.c" > - - @@ -942,10 +938,6 @@ RelativePath=".\meta\sdt.c" > - - @@ -962,6 +954,10 @@ RelativePath=".\meta\spt_spd.c" > + + diff --git a/src/meta/Makefile.unix.am b/src/meta/Makefile.unix.am index 5962730c..b50e14df 100644 --- a/src/meta/Makefile.unix.am +++ b/src/meta/Makefile.unix.am @@ -168,7 +168,6 @@ libmeta_la_SOURCES += pc_sob.c libmeta_la_SOURCES += exakt_sc.c libmeta_la_SOURCES += wii_bns.c libmeta_la_SOURCES += pona.c -libmeta_la_SOURCES += fsb_test.c libmeta_la_SOURCES += xbox_hlwav.c libmeta_la_SOURCES += stx.c libmeta_la_SOURCES += ps2_stm.c @@ -205,7 +204,7 @@ libmeta_la_SOURCES += ffw.c libmeta_la_SOURCES += ps2_jstm.c libmeta_la_SOURCES += ps3_xvag.c libmeta_la_SOURCES += ps3_cps.c -libmeta_la_SOURCES += se_scd.c +libmeta_la_SOURCES += sqex_scd.c libmeta_la_SOURCES += ngc_nst_dsp.c libmeta_la_SOURCES += baf.c libmeta_la_SOURCES += ps3_msf.c diff --git a/src/meta/fsb.c b/src/meta/fsb.c index e53bd1b9..98c24943 100644 --- a/src/meta/fsb.c +++ b/src/meta/fsb.c @@ -82,6 +82,151 @@ fail: return NULL; } +/* FSB3.0 and FSB3.1 */ +VGMSTREAM * init_vgmstream_fsb3(STREAMFILE *streamFile) { + VGMSTREAM * vgmstream = NULL; + char filename[260]; + int fsb_headerlen; + int channel_count; + int loop_flag = 0; + int FSBFlag = 0; + int i, c; + off_t start_offset; + + /* check extension, case insensitive */ + streamFile->get_name(streamFile,filename,sizeof(filename)); + + if (strcasecmp("fsb",filename_extension(filename))) + goto fail; + + /* check header for "FSB3" string */ + if (read_32bitBE(0x00,streamFile) != 0x46534233) + goto fail; + + /* "Check if the FSB is used as conatiner or as single file" */ + if (read_32bitLE(0x04,streamFile) != 0x1) + goto fail; + + /* Check if we're dealing with a FSB3.0 file */ + if ((read_32bitBE(0x10,streamFile) != 0x00000300) && + ((read_32bitBE(0x10,streamFile) != 0x01000300))) + goto fail; + + channel_count = read_16bitLE(0x56,streamFile); + fsb_headerlen = read_32bitLE(0x08,streamFile); + + FSBFlag = read_32bitLE(0x48,streamFile); + + if (FSBFlag&0x2 || FSBFlag&0x4 || FSBFlag&0x6) + loop_flag = 1; + + /* build the VGMSTREAM */ + vgmstream = allocate_vgmstream(channel_count,loop_flag); + if (!vgmstream) goto fail; + + start_offset = fsb_headerlen+0x18; + vgmstream->sample_rate = (read_32bitLE(0x4C, streamFile)); + + + // Get the Decoder + if (FSBFlag&0x00000100) + { // Ignore format and treat as RAW PCM + vgmstream->coding_type = coding_PCM16LE; + if (channel_count == 1) + { + vgmstream->layout_type = layout_none; + } + else if (channel_count > 1) + { + vgmstream->layout_type = layout_interleave; + vgmstream->interleave_block_size = 0x2; + } + } + else if (FSBFlag&0x00400000) + { // XBOX IMA + vgmstream->coding_type = coding_XBOX; + vgmstream->layout_type = layout_none; + } + else if (FSBFlag&0x00800000) + { // PS2 ADPCM + vgmstream->coding_type = coding_PSX; + if (channel_count == 1) + { + vgmstream->layout_type = layout_none; + } + else if (channel_count > 1) + { + vgmstream->layout_type = layout_interleave; + vgmstream->interleave_block_size = 0x10; + } + } + else if (FSBFlag&0x02000000) + { // Nintendo DSP + vgmstream->coding_type = coding_NGC_DSP; + if (channel_count == 1) + { + vgmstream->layout_type = layout_none; + } + else if (channel_count > 1) + { + vgmstream->layout_type = layout_interleave_byte; + vgmstream->interleave_block_size = 2; + } + // read coeff(s), DSP only + for (c=0;cch[c].adpcm_coef[i]=read_16bitBE(0x68+c*0x2e +i*2,streamFile); + } + } + } + else goto fail; + + + vgmstream->num_samples = read_32bitLE(0x38,streamFile); + if (loop_flag) { + vgmstream->loop_start_sample = read_32bitLE(0x40,streamFile); + vgmstream->loop_end_sample = read_32bitLE(0x44,streamFile); + } + + + if (read_32bitBE(0x10,streamFile) == 0x00000300) + { + vgmstream->meta_type = meta_FSB3_0; + } + else if (read_32bitBE(0x10,streamFile) == 0x01000300) + { + vgmstream->meta_type = meta_FSB3_1; + } + + /* 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->coding_type == coding_XBOX) { + /* xbox interleaving is a little odd */ + vgmstream->ch[i].channel_start_offset=start_offset; + } else { + vgmstream->ch[i].channel_start_offset= + start_offset+vgmstream->interleave_block_size*i; + } + vgmstream->ch[i].offset = vgmstream->ch[i].channel_start_offset; + } + } + + return vgmstream; + + /* clean up anything we may have opened */ +fail: + if (vgmstream) close_vgmstream(vgmstream); + return NULL; +} /* FSB4 */ VGMSTREAM * init_vgmstream_fsb4(STREAMFILE *streamFile) { diff --git a/src/meta/fsb_test.c b/src/meta/fsb_test.c deleted file mode 100644 index 28ee1df0..00000000 --- a/src/meta/fsb_test.c +++ /dev/null @@ -1,149 +0,0 @@ -#include "meta.h" -#include "../util.h" - -/* FSB3.0 and FSB3.1 */ - -VGMSTREAM * init_vgmstream_fsb3(STREAMFILE *streamFile) { - VGMSTREAM * vgmstream = NULL; - char filename[260]; - int fsb_headerlen; - int channel_count; - int loop_flag = 0; - int FSBFlag = 0; - int i, c; - off_t start_offset; - - /* check extension, case insensitive */ - streamFile->get_name(streamFile,filename,sizeof(filename)); - - if (strcasecmp("fsb",filename_extension(filename))) - goto fail; - - /* check header for "FSB3" string */ - if (read_32bitBE(0x00,streamFile) != 0x46534233) - goto fail; - - /* "Check if the FSB is used as conatiner or as single file" */ - if (read_32bitLE(0x04,streamFile) != 0x1) - goto fail; - - /* Check if we're dealing with a FSB3.0 file */ - if ((read_32bitBE(0x10,streamFile) != 0x00000300) && - ((read_32bitBE(0x10,streamFile) != 0x01000300))) - goto fail; - - channel_count = read_16bitLE(0x56,streamFile); - fsb_headerlen = read_32bitLE(0x08,streamFile); - - FSBFlag = read_32bitLE(0x48,streamFile); - - if (FSBFlag&0x2 || FSBFlag&0x4 || FSBFlag&0x6) - loop_flag = 1; - - /* build the VGMSTREAM */ - vgmstream = allocate_vgmstream(channel_count,loop_flag); - if (!vgmstream) goto fail; - - start_offset = fsb_headerlen+0x18; - vgmstream->sample_rate = (read_32bitLE(0x4C, streamFile)); - - - // Get the Decoder - if (FSBFlag&0x00000100) - { // Ignore format and treat as RAW PCM - vgmstream->coding_type = coding_PCM16LE; - if (channel_count == 1) - { - vgmstream->layout_type = layout_none; - } - else if (channel_count > 1) - { - vgmstream->layout_type = layout_interleave; - vgmstream->interleave_block_size = 0x2; - } - } - else if (FSBFlag&0x00400000) - { // XBOX IMA - vgmstream->coding_type = coding_XBOX; - vgmstream->layout_type = layout_none; - } - else if (FSBFlag&0x00800000) - { // PS2 ADPCM - vgmstream->coding_type = coding_PSX; - if (channel_count == 1) - { - vgmstream->layout_type = layout_none; - } - else if (channel_count > 1) - { - vgmstream->layout_type = layout_interleave; - vgmstream->interleave_block_size = 0x10; - } - } - else if (FSBFlag&0x02000000) - { // Nintendo DSP - vgmstream->coding_type = coding_NGC_DSP; - if (channel_count == 1) - { - vgmstream->layout_type = layout_none; - } - else if (channel_count > 1) - { - vgmstream->layout_type = layout_interleave_byte; - vgmstream->interleave_block_size = 2; - } - // read coeff(s), DSP only - for (c=0;cch[c].adpcm_coef[i]=read_16bitBE(0x68+c*0x2e +i*2,streamFile); - } - } - } - else goto fail; - - - vgmstream->num_samples = read_32bitLE(0x38,streamFile); - if (loop_flag) { - vgmstream->loop_start_sample = read_32bitLE(0x40,streamFile); - vgmstream->loop_end_sample = read_32bitLE(0x44,streamFile); - } - - - if (read_32bitBE(0x10,streamFile) == 0x00000300) - { - vgmstream->meta_type = meta_FSB3_0; - } - else if (read_32bitBE(0x10,streamFile) == 0x01000300) - { - vgmstream->meta_type = meta_FSB3_1; - } - - /* 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->coding_type == coding_XBOX) { - /* xbox interleaving is a little odd */ - vgmstream->ch[i].channel_start_offset=start_offset; - } else { - vgmstream->ch[i].channel_start_offset= - start_offset+vgmstream->interleave_block_size*i; - } - vgmstream->ch[i].offset = vgmstream->ch[i].channel_start_offset; - } - } - - return vgmstream; - - /* clean up anything we may have opened */ -fail: - if (vgmstream) close_vgmstream(vgmstream); - return NULL; -} diff --git a/src/meta/meta.h b/src/meta/meta.h index b9c51548..e0c47b68 100644 --- a/src/meta/meta.h +++ b/src/meta/meta.h @@ -525,7 +525,7 @@ VGMSTREAM * init_vgmstream_ps3_xvag(STREAMFILE* streamFile); VGMSTREAM * init_vgmstream_ps3_cps(STREAMFILE* streamFile); -VGMSTREAM * init_vgmstream_se_scd(STREAMFILE* streamFile); +VGMSTREAM * init_vgmstream_sqex_scd(STREAMFILE* streamFile); VGMSTREAM * init_vgmstream_ngc_nst_dsp(STREAMFILE* streamFile); diff --git a/src/meta/se_scd.c b/src/meta/sqex_scd.c similarity index 98% rename from src/meta/se_scd.c rename to src/meta/sqex_scd.c index d33fcc9d..bcb5107f 100644 --- a/src/meta/se_scd.c +++ b/src/meta/sqex_scd.c @@ -3,7 +3,7 @@ #include "../util.h" /* Square-Enix SCD (FF XIII, XIV) */ -VGMSTREAM * init_vgmstream_se_scd(STREAMFILE *streamFile) { +VGMSTREAM * init_vgmstream_sqex_scd(STREAMFILE *streamFile) { VGMSTREAM * vgmstream = NULL; char filename[260]; off_t start_offset, meta_offset_offset, meta_offset, size_offset; @@ -125,7 +125,7 @@ VGMSTREAM * init_vgmstream_se_scd(STREAMFILE *streamFile) { goto fail; } - vgmstream->meta_type = meta_SE_SCD; + vgmstream->meta_type = meta_SQEX_SCD; /* open the file for reading */ { diff --git a/src/vgmstream.c b/src/vgmstream.c index d8bc5edb..f26eee0a 100644 --- a/src/vgmstream.c +++ b/src/vgmstream.c @@ -284,7 +284,7 @@ VGMSTREAM * (*init_vgmstream_fcns[])(STREAMFILE *streamFile) = { init_vgmstream_ps2_jstm, init_vgmstream_ps3_xvag, init_vgmstream_ps3_cps, - init_vgmstream_se_scd, + init_vgmstream_sqex_scd, init_vgmstream_ngc_nst_dsp, init_vgmstream_baf, init_vgmstream_ps3_msf, @@ -2749,7 +2749,7 @@ void describe_vgmstream(VGMSTREAM * vgmstream, char * desc, int length) { case meta_PS3_CPS: snprintf(temp,TEMPSIZE,"CPS Header"); break; - case meta_SE_SCD: + case meta_SQEX_SCD: snprintf(temp,TEMPSIZE,"Square-Enix SCD"); break; case meta_NGC_NST_DSP: diff --git a/src/vgmstream.h b/src/vgmstream.h index 02ad012a..a1b21535 100644 --- a/src/vgmstream.h +++ b/src/vgmstream.h @@ -494,7 +494,7 @@ typedef enum { meta_FFW, /* Freedom Fighters [NGC] */ meta_DSP_DSPW, /* Sengoku Basara 3 [WII] */ meta_PS2_JSTM, /* Tantei Jinguji Saburo - Kind of Blue (PS2) */ - meta_SE_SCD, /* Square-Enix SCD */ + meta_SQEX_SCD, /* Square-Enix SCD */ meta_NGC_NST_DSP, /* Animaniacs [NGC] */ meta_BAF, /* .baf (Blur) */ meta_PS3_XVAG, /* Ratchet & Clank Future: Quest for Booty (PS3) */