Updated VGMStream to r1050-390-g72f34ec.

CQTexperiment
Christopher Snowhill 2017-03-26 18:42:01 -07:00
parent a142a06576
commit aa26a713a0
3 changed files with 20073 additions and 26 deletions

View File

@ -12,6 +12,7 @@
830F885C19C9124C00420FB0 /* Vorbis.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 830F883919C9101900420FB0 /* Vorbis.framework */; };
8313E3E61902020400B4B6F1 /* mpg123.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8313E3431901FBDD00B4B6F1 /* mpg123.framework */; };
8313E3E71902021800B4B6F1 /* mpg123.framework in CopyFiles */ = {isa = PBXBuildFile; fileRef = 8313E3431901FBDD00B4B6F1 /* mpg123.framework */; };
8321405A1E8758D7001A8A5E /* fsb_vorbis_decoder.c in Sources */ = {isa = PBXBuildFile; fileRef = 832140591E8758D7001A8A5E /* fsb_vorbis_decoder.c */; };
8323894A1D22419B00482226 /* clHCA.c in Sources */ = {isa = PBXBuildFile; fileRef = 832389481D22419B00482226 /* clHCA.c */; };
8323894B1D22419B00482226 /* clHCA.h in Headers */ = {isa = PBXBuildFile; fileRef = 832389491D22419B00482226 /* clHCA.h */; settings = {ATTRIBUTES = (Public, ); }; };
832389501D2246C300482226 /* hca.c in Sources */ = {isa = PBXBuildFile; fileRef = 8323894F1D2246C300482226 /* hca.c */; };
@ -24,6 +25,7 @@
834D3A6E19F47C98001C54F6 /* g1l.c in Sources */ = {isa = PBXBuildFile; fileRef = 834D3A6D19F47C98001C54F6 /* g1l.c */; };
8350C0551E071881009E0A93 /* xma.c in Sources */ = {isa = PBXBuildFile; fileRef = 8350C0541E071881009E0A93 /* xma.c */; };
8350C05A1E071990009E0A93 /* ps2_svag_snk.c in Sources */ = {isa = PBXBuildFile; fileRef = 8350C0591E071990009E0A93 /* ps2_svag_snk.c */; };
836E15DE1E88A3380029F8AD /* fsb_vorbis_data.h in Headers */ = {isa = PBXBuildFile; fileRef = 836E15DD1E88A3380029F8AD /* fsb_vorbis_data.h */; };
836F6B4718BDB8880095E648 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 836F6B4518BDB8880095E648 /* InfoPlist.strings */; };
836F6F1E18BDC2190095E648 /* acm_decoder.c in Sources */ = {isa = PBXBuildFile; fileRef = 836F6DE018BDC2180095E648 /* acm_decoder.c */; };
836F6F1F18BDC2190095E648 /* acm_decoder.h in Headers */ = {isa = PBXBuildFile; fileRef = 836F6DE118BDC2180095E648 /* acm_decoder.h */; settings = {ATTRIBUTES = (Public, ); }; };
@ -480,6 +482,7 @@
48C2650E1A5D420800A0A3D6 /* vorbisfile.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = vorbisfile.h; path = ../Vorbis/include/vorbis/vorbisfile.h; sourceTree = "<group>"; };
8313E33D1901FBDC00B4B6F1 /* mpg123.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = mpg123.xcodeproj; path = ../mpg123/mpg123.xcodeproj; sourceTree = "<group>"; };
8315231718BDECA1009AE289 /* VorbisNoDot.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = VorbisNoDot.xcodeproj; path = ../Vorbis/macosx/VorbisNoDot.xcodeproj; sourceTree = "<group>"; };
832140591E8758D7001A8A5E /* fsb_vorbis_decoder.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = fsb_vorbis_decoder.c; sourceTree = "<group>"; };
832389481D22419B00482226 /* clHCA.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = clHCA.c; sourceTree = "<group>"; };
832389491D22419B00482226 /* clHCA.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = clHCA.h; sourceTree = "<group>"; };
8323894F1D2246C300482226 /* hca.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = hca.c; sourceTree = "<group>"; };
@ -492,6 +495,7 @@
834D3A6D19F47C98001C54F6 /* g1l.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = g1l.c; sourceTree = "<group>"; };
8350C0541E071881009E0A93 /* xma.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = xma.c; sourceTree = "<group>"; };
8350C0591E071990009E0A93 /* ps2_svag_snk.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ps2_svag_snk.c; sourceTree = "<group>"; };
836E15DD1E88A3380029F8AD /* fsb_vorbis_data.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = fsb_vorbis_data.h; sourceTree = "<group>"; };
836F6B3918BDB8880095E648 /* vgmstream.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = vgmstream.framework; sourceTree = BUILT_PRODUCTS_DIR; };
836F6B4418BDB8880095E648 /* vgmstream-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "vgmstream-Info.plist"; sourceTree = "<group>"; };
836F6B4618BDB8880095E648 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = "<group>"; };
@ -986,6 +990,8 @@
836F6DDF18BDC2180095E648 /* coding */ = {
isa = PBXGroup;
children = (
836E15DD1E88A3380029F8AD /* fsb_vorbis_data.h */,
832140591E8758D7001A8A5E /* fsb_vorbis_decoder.c */,
83299FC51E76606B003A3242 /* ffmpeg_decoder_utils.c */,
838BDB6B1D3AFAB10022CA6F /* ffmpeg_decoder.c */,
832389511D224C0800482226 /* hca_decoder.c */,
@ -1364,6 +1370,7 @@
836F6F9A18BDC2190095E648 /* meta.h in Headers */,
836F6F4D18BDC2190095E648 /* layout.h in Headers */,
836F6F2318BDC2190095E648 /* coding.h in Headers */,
836E15DE1E88A3380029F8AD /* fsb_vorbis_data.h in Headers */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@ -1524,6 +1531,7 @@
836F6F5C18BDC2190095E648 /* wsi_blocked.c in Sources */,
836F6F7418BDC2190095E648 /* bgw.c in Sources */,
836F6F7218BDC2190095E648 /* baf.c in Sources */,
8321405A1E8758D7001A8A5E /* fsb_vorbis_decoder.c in Sources */,
83F5F8831908D0A400C8E65F /* fsb5.c in Sources */,
836F6F4B18BDC2190095E648 /* interleave_byte.c in Sources */,
836F6FD418BDC2190095E648 /* ps2_dxh.c in Sources */,

File diff suppressed because it is too large Load Diff

View File

@ -3,15 +3,24 @@
#ifdef VGM_USE_VORBIS
#include <vorbis/codec.h>
#define FSB_VORBIS_ON 1 //todo recompile libvorbis with vorbis_* and remove
#define FSB_VORBIS_ON 1 //todo remove once battle-tested
#define FSB_VORBIS_USE_PRECOMPILED_FVS 1 /* if enabled vgmstream weights ~600kb more but doesn't need external .fvs packets */
#if FSB_VORBIS_ON
#if FSB_VORBIS_USE_PRECOMPILED_FVS
#include "fsb_vorbis_data.h"
#endif
#define FSB_VORBIS_DEFAULT_BUFFER_SIZE 0x8000 /* should be at least the size of the setup header, ~0x2000 */
#if FSB_VORBIS_ON
static void pcm_convert_float_to_16(vorbis_codec_data * data, sample * outbuf, int samples_to_do, float ** pcm);
static int vorbis_make_header_identification(uint8_t * buf, size_t bufsize, int channels, int sample_rate, int blocksize_short, int blocksize_long);
static int vorbis_make_header_comment(uint8_t * buf, size_t bufsize);
static int vorbis_make_header_setup(uint8_t * buf, size_t bufsize, uint32_t setup_id, STREAMFILE *streamFile);
static int load_fvs_file_single(uint8_t * buf, size_t bufsize, uint32_t setup_id, STREAMFILE *streamFile);
static int load_fvs_file_multi(uint8_t * buf, size_t bufsize, uint32_t setup_id, STREAMFILE *streamFile);
static int load_fvs_array(uint8_t * buf, size_t bufsize, uint32_t setup_id, STREAMFILE *streamFile);
#endif
/**
@ -116,8 +125,8 @@ void decode_fsb_vorbis(VGMSTREAM * vgmstream, sample * outbuf, int32_t samples_t
/* get max samples and convert from Vorbis float pcm to 16bit pcm */
if (samples_to_get > samples_to_do - samples_done)
samples_to_get = samples_to_do - samples_done;
samples_done += samples_to_get;
pcm_convert_float_to_16(data, outbuf + samples_done * channels, samples_to_get, pcm);
samples_done += samples_to_get;
}
/* mark consumed samples from the buffer
@ -254,49 +263,135 @@ static int vorbis_make_header_comment(uint8_t * buf, size_t bufsize) {
}
static int vorbis_make_header_setup(uint8_t * buf, size_t bufsize, uint32_t setup_id, STREAMFILE *streamFile) {
char setupname[PATH_LIMIT];
char pathname[PATH_LIMIT];
char *path;
int bytes;
/* try to load from external files first */
bytes = load_fvs_file_single(buf, bufsize, setup_id, streamFile);
if (bytes)
return bytes;
bytes = load_fvs_file_multi(buf, bufsize, setup_id, streamFile);
if (bytes)
return bytes;
/* try to locate from the precompiled list */
bytes = load_fvs_array(buf, bufsize, setup_id, streamFile);
if (bytes)
return bytes;
/* not found */
VGM_LOG("FSB Vorbis: setup_id %08x not found\n", setup_id);
return 0;
}
static int load_fvs_file_single(uint8_t * buf, size_t bufsize, uint32_t setup_id, STREAMFILE *streamFile) {
STREAMFILE * streamFileSetup = NULL;
size_t bytes = 0;
{
char setupname[PATH_LIMIT];
char pathname[PATH_LIMIT];
char *path;
streamFile->get_name(streamFile,pathname,sizeof(pathname));
/* read "(dir/).fvs_{setup_id}" */
streamFile->get_name(streamFile,pathname,sizeof(pathname));
path = strrchr(pathname,DIR_SEPARATOR);
if (path)
*(path+1) = '\0';
else
pathname[0] = '\0';
/* try to get setup packet from external file first, using "(dir/).vorbis_{setup_id}" */
path = strrchr(pathname,DIR_SEPARATOR);
if (path) {
*(path+1) = '\0';
} else {
pathname[0] = '\0';
snprintf(setupname,PATH_LIMIT,"%s.fvs_%08x", pathname, setup_id);
streamFileSetup = streamFile->open(streamFile,setupname,STREAMFILE_DEFAULT_BUFFER_SIZE);
}
snprintf(setupname,PATH_LIMIT,"%s.vorbis_%08x", pathname, setup_id);
streamFileSetup = streamFile->open(streamFile,setupname,STREAMFILE_DEFAULT_BUFFER_SIZE);
if (streamFileSetup) {
/* file found, get contents into the buffer */
bytes = streamFileSetup->get_size(streamFileSetup);
size_t bytes = streamFileSetup->get_size(streamFileSetup);
if (bytes > bufsize) goto fail;
if (read_streamfile(buf, 0, bufsize, streamFileSetup) != bytes)
if (read_streamfile(buf, 0, bytes, streamFileSetup) != bytes)
goto fail;
streamFileSetup->close(streamFileSetup);
return bytes;
}
else {
/* check the index list */
VGM_LOG("FSB Vorbis: setup_id %08x not found\n", setup_id);
goto fail;
}
return bytes;
fail:
if (streamFileSetup) streamFileSetup->close(streamFileSetup);
return 0;
}
static int load_fvs_file_multi(uint8_t * buf, size_t bufsize, uint32_t setup_id, STREAMFILE *streamFile) {
STREAMFILE * streamFileSetup = NULL;
{
char setupname[PATH_LIMIT];
char pathname[PATH_LIMIT];
char *path;
/* read "(dir/).fvs" */
streamFile->get_name(streamFile,pathname,sizeof(pathname));
path = strrchr(pathname,DIR_SEPARATOR);
if (path)
*(path+1) = '\0';
else
pathname[0] = '\0';
snprintf(setupname,PATH_LIMIT,"%s.fvs", pathname);
streamFileSetup = streamFile->open(streamFile,setupname,STREAMFILE_DEFAULT_BUFFER_SIZE);
}
if (streamFileSetup) {
/* file found: read mini-header (format by bnnm, feel free to change) and locate FVS */
int entries, i;
uint32_t offset = 0, size = 0;
if (read_32bitBE(0x0, streamFileSetup) != 0x56465653) goto fail; /* "VFVS" */
entries = read_32bitLE(0x08, streamFileSetup); /* 0x04=v0, 0x0c-0x20: reserved */
if (entries <= 0) goto fail;
for (i=0; i < entries; i++) { /* entry = id, offset, size, reserved */
if ((uint32_t)read_32bitLE(0x20 + i*0x10, streamFileSetup) == setup_id) {
offset = read_32bitLE(0x24 + i*0x10, streamFileSetup);
size = read_32bitLE(0x28 + i*0x10, streamFileSetup);
break;
}
}
if (!size || !offset || size > bufsize) goto fail;
/* read into buf */
if (read_streamfile(buf, offset, size, streamFileSetup) != size)
goto fail;
streamFileSetup->close(streamFileSetup);
return size;
}
fail:
if (streamFileSetup) streamFileSetup->close(streamFileSetup);
return 0;
}
static int load_fvs_array(uint8_t * buf, size_t bufsize, uint32_t setup_id, STREAMFILE *streamFile) {
#if FSB_VORBIS_USE_PRECOMPILED_FVS
int i, list_length;
list_length = sizeof(fvs_list) / sizeof(fvs_info);
for (i=0; i < list_length; i++) {
if (fvs_list[i].id == setup_id) {
if (fvs_list[i].size > bufsize) goto fail;
/* found: copy data as-is */
memcpy(buf,fvs_list[i].setup, fvs_list[i].size);
return fvs_list[i].size;
}
}
fail:
#endif
return 0;
}
#endif