Updated vgmstream to revision 1029

CQTexperiment
Chris Moeller 2014-04-23 21:55:48 -07:00
parent 607f404361
commit 3c939042f1
6 changed files with 317 additions and 20 deletions

View File

@ -322,6 +322,7 @@
836F705718BDC2190095E648 /* util.h in Headers */ = {isa = PBXBuildFile; fileRef = 836F6F1B18BDC2190095E648 /* util.h */; };
836F705818BDC2190095E648 /* vgmstream.c in Sources */ = {isa = PBXBuildFile; fileRef = 836F6F1C18BDC2190095E648 /* vgmstream.c */; };
836F705918BDC2190095E648 /* vgmstream.h in Headers */ = {isa = PBXBuildFile; fileRef = 836F6F1D18BDC2190095E648 /* vgmstream.h */; settings = {ATTRIBUTES = (Public, ); }; };
83F5F8831908D0A400C8E65F /* fsb5.c in Sources */ = {isa = PBXBuildFile; fileRef = 83F5F8821908D0A400C8E65F /* fsb5.c */; };
/* End PBXBuildFile section */
/* Begin PBXContainerItemProxy section */
@ -685,6 +686,7 @@
836F6F1B18BDC2190095E648 /* util.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = util.h; sourceTree = "<group>"; };
836F6F1C18BDC2190095E648 /* vgmstream.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = vgmstream.c; sourceTree = "<group>"; };
836F6F1D18BDC2190095E648 /* vgmstream.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = vgmstream.h; sourceTree = "<group>"; };
83F5F8821908D0A400C8E65F /* fsb5.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = fsb5.c; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
@ -867,6 +869,7 @@
836F6E2718BDC2180095E648 /* meta */ = {
isa = PBXGroup;
children = (
83F5F8821908D0A400C8E65F /* fsb5.c */,
836F6E2918BDC2180095E648 /* 2dx9.c */,
836F6E2A18BDC2180095E648 /* aax.c */,
836F6E2B18BDC2180095E648 /* acm.c */,
@ -1234,6 +1237,7 @@
836F6F5C18BDC2190095E648 /* wsi_blocked.c in Sources */,
836F6F7418BDC2190095E648 /* bgw.c in Sources */,
836F6F7218BDC2190095E648 /* baf.c in Sources */,
83F5F8831908D0A400C8E65F /* fsb5.c in Sources */,
836F6F4B18BDC2190095E648 /* interleave_byte.c in Sources */,
836F6FD418BDC2190095E648 /* ps2_dxh.c in Sources */,
836F700C18BDC2190095E648 /* ps2_wb.c in Sources */,

View File

@ -0,0 +1,302 @@
#include "meta.h"
#include "../coding/coding.h"
#include "../util.h"
/* FSB5 header */
VGMSTREAM * init_vgmstream_fsb5(STREAMFILE *streamFile) {
VGMSTREAM * vgmstream = NULL;
char filename[260];
off_t StartOffset;
int LoopFlag = 0;
int32_t LoopStart, LoopEnd;
int NumSamples;
int ChannelCount;
int SampleRate;
int DSPInfoStart;
int SampleHeaderStart, SampleHeaderLength, NameTableLength, SampleDataLength, CodingID, SampleMode;
int ExtraFlag, ExtraFlagStart, ExtraFlagType, ExtraFlagSize, ExtraFlagEnd;
size_t fileLength;
/* check extension, case insensitive */
streamFile->get_name(streamFile,filename,sizeof(filename));
if (strcasecmp("fsb",filename_extension(filename))) goto fail;
if (read_32bitBE(0x00,streamFile) != 0x46534235) goto fail; /* "FSB5" */
if (read_32bitLE(0x04,streamFile) != 0x01) goto fail; /* Version ID */
if (read_32bitLE(0x08,streamFile) != 0x01) goto fail; /* Number of Sample Files */
SampleHeaderStart = 0x3C;
SampleHeaderLength = read_32bitLE(0x0C,streamFile);
NameTableLength = read_32bitLE(0x10,streamFile);
SampleDataLength = read_32bitLE(0x14,streamFile);
CodingID = read_32bitLE(0x18,streamFile);
if ((SampleHeaderLength + NameTableLength + SampleDataLength + 0x3C) != get_streamfile_size(streamFile)) goto fail;
StartOffset = SampleHeaderLength + NameTableLength + 0x3C;
SampleMode = read_32bitLE(SampleHeaderStart+0x00,streamFile);
if (SampleMode&0x02)
{
SampleRate = 48000;
} else {
SampleRate = 44100;
}
if (SampleMode&0x20)
{
ChannelCount = 2;
} else {
ChannelCount = 1;
}
ExtraFlagStart = SampleHeaderStart+0x08;
if (SampleMode&0x01)
{
do
{
ExtraFlag = read_32bitLE(ExtraFlagStart,streamFile);
ExtraFlagType = (ExtraFlag>>25)&0x7F;
ExtraFlagSize = (ExtraFlag>>1)&0xFFFFFF;
ExtraFlagEnd = (ExtraFlag&0x01);
switch(ExtraFlagType)
{
case 0x02: /* Sample Rate Info */
{
SampleRate = read_32bitLE(ExtraFlagStart+0x04,streamFile);
}
break;
case 0x03: /* Loop Info */
{
LoopStart = read_32bitLE(ExtraFlagStart+0x04,streamFile);
if (LoopStart != 0x00) {
LoopFlag = 1;
LoopEnd = read_32bitLE(ExtraFlagStart+0x08,streamFile);
}
}
break;
case 0x07: /* DSP Info (Coeffs), only used if coding is DSP??? */
{
DSPInfoStart = ExtraFlagStart+0x04;
}
break;
}
ExtraFlagStart+=ExtraFlagSize+0x04;
}
while (ExtraFlagEnd != 0x00);
}
/* build the VGMSTREAM */
vgmstream = allocate_vgmstream(ChannelCount,LoopFlag);
if (!vgmstream) goto fail;
/* fill in the vital statistics */
vgmstream->channels = ChannelCount;
vgmstream->sample_rate = SampleRate;
switch (CodingID)
{
case 0x00: /* FMOD_SOUND_FORMAT_NONE */
{
goto fail;
}
break;
case 0x01: /* FMOD_SOUND_FORMAT_PCM8 */
{
goto fail;
}
break;
case 0x02: /* FMOD_SOUND_FORMAT_PCM16 */
{
NumSamples = read_32bitLE(SampleHeaderStart+0x04,streamFile)/4;
if (ChannelCount == 1)
{
vgmstream->layout_type = layout_none;
} else {
vgmstream->layout_type = layout_interleave;
vgmstream->interleave_block_size = 0x02;
}
vgmstream->coding_type = coding_PCM16LE;
}
break;
case 0x03:/* FMOD_SOUND_FORMAT_PCM24 */
{
goto fail;
}
break;
case 0x04: /* FMOD_SOUND_FORMAT_PCM32 */
{
goto fail;
}
break;
case 0x05: /* FMOD_SOUND_FORMAT_PCMFLOAT */
{
goto fail;
}
break;
case 0x06: /* FMOD_SOUND_FORMAT_GCADPCM */
{
if (ChannelCount == 1)
{
NumSamples = read_32bitLE(SampleHeaderStart+0x04,streamFile)/4;
vgmstream->layout_type = layout_none;
} else {
NumSamples = read_32bitLE(SampleHeaderStart+0x04,streamFile)/(2*ChannelCount);
vgmstream->layout_type = layout_interleave_byte;
vgmstream->interleave_block_size = 0x02;
}
vgmstream->coding_type = coding_NGC_DSP;
/* DSP Coeffs */
{
int c,i;
for (c=0;c<ChannelCount;c++) {
for (i=0;i<16;i++)
{
vgmstream->ch[c].adpcm_coef[i] = read_16bitBE(DSPInfoStart + c*0x2E + i*2,streamFile);
}
}
}
}
break;
case 0x07: /* FMOD_SOUND_FORMAT_IMAADPCM */
{
NumSamples = read_32bitLE(SampleHeaderStart+0x04,streamFile)/4;
vgmstream->layout_type = layout_none;
vgmstream->coding_type = coding_XBOX;
}
break;
case 0x08: /* FMOD_SOUND_FORMAT_VAG */
{
goto fail;
}
break;
case 0x09: /* FMOD_SOUND_FORMAT_HEVAG */
{
goto fail;
}
break;
case 0x0A: /* FMOD_SOUND_FORMAT_XMA */
{
goto fail;
}
break;
case 0x0B: /* FMOD_SOUND_FORMAT_MPEG */
{
NumSamples = read_32bitLE(SampleHeaderStart+0x04,streamFile)/2/ChannelCount;
#ifdef VGM_USE_MPEG
{
mpeg_codec_data *mpeg_data = NULL;
struct mpg123_frameinfo mi;
coding_t ct;
mpeg_data = init_mpeg_codec_data(streamFile, StartOffset, vgmstream->sample_rate, vgmstream->channels, &ct, NULL, NULL);
if (!mpeg_data) goto fail;
vgmstream->codec_data = mpeg_data;
if (MPG123_OK != mpg123_info(mpeg_data->m, &mi)) goto fail;
vgmstream->coding_type = ct;
vgmstream->layout_type = layout_mpeg;
if (mi.vbr != MPG123_CBR) goto fail;
vgmstream->interleave_block_size = 0;
}
break;
#endif
}
break;
case 0x0C: /* FMOD_SOUND_FORMAT_CELT */
{
goto fail;
}
break;
case 0x0D: /* FMOD_SOUND_FORMAT_AT9 */
{
goto fail;
}
break;
case 0x0E: /* FMOD_SOUND_FORMAT_XWMA */
{
goto fail;
}
break;
case 0x0F: /* FMOD_SOUND_FORMAT_VORBIS */
{
goto fail;
}
break;
default:
goto fail;
}
vgmstream->num_samples = NumSamples;
vgmstream->meta_type = meta_FSB5;
if (LoopFlag)
{
vgmstream->loop_start_sample = LoopStart;
vgmstream->loop_end_sample = LoopEnd;
}
/* 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<ChannelCount;i++) {
vgmstream->ch[i].streamfile = file;
if (vgmstream->coding_type == coding_XBOX) {
/* xbox interleaving is a little odd */
vgmstream->ch[i].channel_start_offset=StartOffset;
} else {
vgmstream->ch[i].channel_start_offset=
StartOffset+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;
}

View File

@ -107,9 +107,6 @@ VGMSTREAM * init_vgmstream_ogg_vorbis_callbacks(STREAMFILE *streamFile, const ch
VGMSTREAM * init_vgmstream_sli_ogg(STREAMFILE * streamFile);
VGMSTREAM * init_vgmstream_sfl(STREAMFILE * streamFile);
#endif
#if defined(VGM_USE_MP4V2) && defined(VGM_USE_FDKAAC)
VGMSTREAM * init_vgmstream_mp4_aac(STREAMFILE * streamFile);
@ -118,6 +115,9 @@ VGMSTREAM * init_vgmstream_mp4_aac_offset(STREAMFILE *streamFile, uint64_t start
VGMSTREAM * init_vgmstream_akb(STREAMFILE *streamFile);
#endif
VGMSTREAM * init_vgmstream_sfl(STREAMFILE * streamFile);
#endif
VGMSTREAM * init_vgmstream_sadb(STREAMFILE *streamFile);
VGMSTREAM * init_vgmstream_ps2_bmdx(STREAMFILE * streamFile);
@ -168,6 +168,8 @@ VGMSTREAM * init_vgmstream_fsb4(STREAMFILE * streamFile);
VGMSTREAM * init_vgmstream_fsb4_wav(STREAMFILE * streamFile);
VGMSTREAM * init_vgmstream_fsb5(STREAMFILE * streamFile);
VGMSTREAM * init_vgmstream_fsb_mpeg(STREAMFILE * streamFile);
VGMSTREAM * init_vgmstream_rwx(STREAMFILE * streamFile);

View File

@ -274,8 +274,6 @@ VGMSTREAM * init_vgmstream_ps2_mib(STREAMFILE *streamFile) {
vgmstream->interleave_block_size=0;
vgmstream->sample_rate = 22050;
vgmstream->channels = 1;
/*vgmstream->start_ch = 1; XXX what the hell?
vgmstream->loop_ch = 1;*/
}
vgmstream->num_samples = (int32_t)(fileLength/16/channel_count*28);

View File

@ -92,6 +92,7 @@ VGMSTREAM * (*init_vgmstream_fcns[])(STREAMFILE *streamFile) = {
init_vgmstream_fsb3,
init_vgmstream_fsb4,
init_vgmstream_fsb4_wav,
init_vgmstream_fsb5,
init_vgmstream_rwx,
init_vgmstream_xwb,
init_vgmstream_xwb2,
@ -2415,6 +2416,9 @@ void describe_vgmstream(VGMSTREAM * vgmstream, char * desc, int length) {
case meta_FSB4_WAV:
snprintf(temp,TEMPSIZE,"FMOD Sample Bank (FSB4) with additional 'WAV' Header");
break;
case meta_FSB5:
snprintf(temp,TEMPSIZE,"FMOD Sample Bank (FSB5) Header");
break;
case meta_RWX:
snprintf(temp,TEMPSIZE,"RWX Header");
break;

View File

@ -16,23 +16,14 @@ enum { PATH_LIMIT = 32768 };
#define VGM_USE_MPEG
/* disabled by default, defined for builds that support it */
//#define VGM_USE_G7221
//#define VGM_USE_MP4V2
//#define VGM_USE_FDKAAC
#include "streamfile.h"
#ifdef BUILD_VGMSTREAM
#include "coding/g72x_state.h"
#else
#include "g72x_state.h"
#endif
#ifdef VGM_USE_VORBIS
#ifdef __APPLE__
#define __MACOSX__
#endif
#include <vorbis/vorbisfile.h>
#endif
#ifdef VGM_USE_MPEG
#include <mpg123/mpg123.h>
#include <mpg123.h>
#endif
#ifdef VGM_USE_G7221
#include "g7221.h"
@ -51,13 +42,8 @@ enum { PATH_LIMIT = 32768 };
#include <maiatrac3plus.h>
#endif
#ifdef BUILD_VGMSTREAM
#include "coding/acm_decoder.h"
#include "coding/nwa_decoder.h"
#else
#include "acm_decoder.h"
#include "nwa_decoder.h"
#endif
/* The encoding type specifies the format the sound data itself takes */
typedef enum {
@ -317,6 +303,7 @@ typedef enum {
meta_FSB4, /* FMOD Sample Bank, version 4 */
meta_FSB_MPEG, /* Just Test */
meta_FSB4_WAV, /* FMOD Sample Bank, version 4 with "WAV" Header */
meta_FSB5, /* FMOD Sample Bank, version 5 */
meta_RWX, /* Air Force Delta Storm (XBOX) */
meta_XWB, /* King of Fighters (XBOX) */
meta_XA30, /* Driver - Parallel Lines (PS2) */