mirror of
https://github.com/vgmstream/vgmstream.git
synced 2025-01-18 15:54:05 +01:00
Combined FSB metas
git-svn-id: https://vgmstream.svn.sourceforge.net/svnroot/vgmstream@918 51a99a44-fe44-0410-b1ba-c3e57ba2b86b
This commit is contained in:
parent
7fea3b3211
commit
16bae0a74d
@ -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 \
|
||||
|
@ -328,10 +328,6 @@
|
||||
RelativePath=".\meta\fsb.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\meta\fsb_test.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\meta\gca.c"
|
||||
>
|
||||
@ -942,10 +938,6 @@
|
||||
RelativePath=".\meta\sdt.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\meta\se_scd.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\meta\seg.c"
|
||||
>
|
||||
@ -962,6 +954,10 @@
|
||||
RelativePath=".\meta\spt_spd.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\meta\sqex_scd.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\meta\ss_stream.c"
|
||||
>
|
||||
|
@ -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
|
||||
|
145
src/meta/fsb.c
145
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;c<channel_count;c++)
|
||||
{
|
||||
for (i=0;i<16;i++)
|
||||
{
|
||||
vgmstream->ch[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;i<channel_count;i++) {
|
||||
vgmstream->ch[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) {
|
||||
|
@ -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;c<channel_count;c++)
|
||||
{
|
||||
for (i=0;i<16;i++)
|
||||
{
|
||||
vgmstream->ch[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;i<channel_count;i++) {
|
||||
vgmstream->ch[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;
|
||||
}
|
@ -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);
|
||||
|
||||
|
@ -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 */
|
||||
{
|
@ -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:
|
||||
|
@ -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) */
|
||||
|
Loading…
x
Reference in New Issue
Block a user