Tweak FSB ifdefs

This commit is contained in:
bnnm 2018-08-15 21:19:25 +02:00
parent a3534d7d11
commit 6eaf516b23
2 changed files with 16 additions and 20 deletions

View File

@ -103,9 +103,7 @@ typedef struct {
/* ********************************************************************************** */ /* ********************************************************************************** */
#ifdef VGM_USE_CELT static layered_layout_data* build_layered_fsb_celt(STREAMFILE *streamFile, fsb_header* fsb, int is_new_lib);
static layered_layout_data* build_layered_fsb_celt(STREAMFILE *streamFile, fsb_header* fsb, celt_lib_t version);
#endif
/* FSB1~4 - from games using FMOD audio middleware */ /* FSB1~4 - from games using FMOD audio middleware */
VGMSTREAM * init_vgmstream_fsb(STREAMFILE *streamFile) { VGMSTREAM * init_vgmstream_fsb(STREAMFILE *streamFile) {
@ -385,7 +383,7 @@ VGMSTREAM * init_vgmstream_fsb(STREAMFILE *streamFile) {
#ifdef VGM_USE_CELT #ifdef VGM_USE_CELT
case CELT: { /* FSB4: War Thunder (PC), The Witcher 2 (PC), Vessel (PC) */ case CELT: { /* FSB4: War Thunder (PC), The Witcher 2 (PC), Vessel (PC) */
celt_lib_t version; int is_new_lib;
/* get libcelt version (set in the first subsong only, but try all extradata just in case) */ /* get libcelt version (set in the first subsong only, but try all extradata just in case) */
if (fsb.first_extradata_offset || fsb.extradata_offset) { if (fsb.first_extradata_offset || fsb.extradata_offset) {
@ -393,8 +391,8 @@ VGMSTREAM * init_vgmstream_fsb(STREAMFILE *streamFile) {
(uint32_t)read_32bitLE(fsb.first_extradata_offset, streamFile) : (uint32_t)read_32bitLE(fsb.first_extradata_offset, streamFile) :
(uint32_t)read_32bitLE(fsb.extradata_offset, streamFile);; (uint32_t)read_32bitLE(fsb.extradata_offset, streamFile);;
switch(lib) { switch(lib) {
case 0x80000009: version = CELT_0_06_1; break; /* War Thunder (PC) */ case 0x80000009: is_new_lib = 0; break; /* War Thunder (PC) */
case 0x80000010: version = CELT_0_11_0; break; /* Vessel (PC) */ case 0x80000010: is_new_lib = 1; break; /* Vessel (PC) */
default: VGM_LOG("FSB: unknown CELT lib 0x%x\n", lib); goto fail; default: VGM_LOG("FSB: unknown CELT lib 0x%x\n", lib); goto fail;
} }
} }
@ -402,20 +400,20 @@ VGMSTREAM * init_vgmstream_fsb(STREAMFILE *streamFile) {
/* split FSBs? try to guess from observed bitstreams */ /* split FSBs? try to guess from observed bitstreams */
uint16_t frame = (uint16_t)read_16bitBE(fsb.stream_offset+0x04+0x04,streamFile); uint16_t frame = (uint16_t)read_16bitBE(fsb.stream_offset+0x04+0x04,streamFile);
if ((frame & 0xF000) == 0x6000 || frame == 0xFFFE) { if ((frame & 0xF000) == 0x6000 || frame == 0xFFFE) {
version = CELT_0_11_0; is_new_lib = 1;
} else { } else {
version = CELT_0_06_1; is_new_lib = 0;
} }
} }
if (fsb.channels > 2) { /* multistreams */ if (fsb.channels > 2) { /* multistreams */
vgmstream->layout_data = build_layered_fsb_celt(streamFile, &fsb, version); vgmstream->layout_data = build_layered_fsb_celt(streamFile, &fsb, is_new_lib);
if (!vgmstream->layout_data) goto fail; if (!vgmstream->layout_data) goto fail;
vgmstream->coding_type = coding_CELT_FSB; vgmstream->coding_type = coding_CELT_FSB;
vgmstream->layout_type = layout_layered; vgmstream->layout_type = layout_layered;
} }
else { else {
vgmstream->codec_data = init_celt_fsb(vgmstream->channels, version); vgmstream->codec_data = init_celt_fsb(vgmstream->channels, is_new_lib ? CELT_0_11_0 : CELT_0_06_1);
if (!vgmstream->codec_data) goto fail; if (!vgmstream->codec_data) goto fail;
vgmstream->coding_type = coding_CELT_FSB; vgmstream->coding_type = coding_CELT_FSB;
vgmstream->layout_type = layout_none; vgmstream->layout_type = layout_none;
@ -455,7 +453,7 @@ fail:
} }
#ifdef VGM_USE_CELT #ifdef VGM_USE_CELT
static layered_layout_data* build_layered_fsb_celt(STREAMFILE *streamFile, fsb_header* fsb, celt_lib_t version) { static layered_layout_data* build_layered_fsb_celt(STREAMFILE *streamFile, fsb_header* fsb, int is_new_lib) {
layered_layout_data* data = NULL; layered_layout_data* data = NULL;
STREAMFILE* temp_streamFile = NULL; STREAMFILE* temp_streamFile = NULL;
int i, layers = (fsb->channels+1) / 2; int i, layers = (fsb->channels+1) / 2;
@ -480,7 +478,7 @@ static layered_layout_data* build_layered_fsb_celt(STREAMFILE *streamFile, fsb_h
data->layers[i]->loop_end_sample = fsb->loop_end; data->layers[i]->loop_end_sample = fsb->loop_end;
#ifdef VGM_USE_CELT #ifdef VGM_USE_CELT
data->layers[i]->codec_data = init_celt_fsb(layer_channels, version); data->layers[i]->codec_data = init_celt_fsb(layer_channels, is_new_lib ? CELT_0_11_0 : CELT_0_06_1);
if (!data->layers[i]->codec_data) goto fail; if (!data->layers[i]->codec_data) goto fail;
data->layers[i]->coding_type = coding_CELT_FSB; data->layers[i]->coding_type = coding_CELT_FSB;
data->layers[i]->layout_type = layout_none; data->layers[i]->layout_type = layout_none;

View File

@ -33,9 +33,7 @@ typedef struct {
/* ********************************************************************************** */ /* ********************************************************************************** */
#ifdef VGM_USE_CELT static layered_layout_data* build_layered_fsb5_celt(STREAMFILE *streamFile, fsb5_header* fsb5);
static layered_layout_data* build_layered_fsb5_celt(STREAMFILE *streamFile, fsb5_header* fsb5, celt_lib_t version);
#endif
static layered_layout_data* build_layered_fsb5_atrac9(STREAMFILE *streamFile, fsb5_header* fsb5, off_t configs_offset, size_t configs_size); static layered_layout_data* build_layered_fsb5_atrac9(STREAMFILE *streamFile, fsb5_header* fsb5, off_t configs_offset, size_t configs_size);
/* FSB5 - FMOD Studio multiplatform format */ /* FSB5 - FMOD Studio multiplatform format */
@ -344,7 +342,7 @@ VGMSTREAM * init_vgmstream_fsb5(STREAMFILE *streamFile) {
int is_multistream = fsb5.channels > 2; int is_multistream = fsb5.channels > 2;
if (is_multistream) { if (is_multistream) {
vgmstream->layout_data = build_layered_fsb5_celt(streamFile, &fsb5, CELT_0_11_0); vgmstream->layout_data = build_layered_fsb5_celt(streamFile, &fsb5);
if (!vgmstream->layout_data) goto fail; if (!vgmstream->layout_data) goto fail;
vgmstream->coding_type = coding_CELT_FSB; vgmstream->coding_type = coding_CELT_FSB;
vgmstream->layout_type = layout_layered; vgmstream->layout_type = layout_layered;
@ -456,8 +454,8 @@ fail:
return NULL; return NULL;
} }
#ifdef VGM_USE_CELT
static layered_layout_data* build_layered_fsb5_celt(STREAMFILE *streamFile, fsb5_header* fsb5, celt_lib_t version) { static layered_layout_data* build_layered_fsb5_celt(STREAMFILE *streamFile, fsb5_header* fsb5) {
layered_layout_data* data = NULL; layered_layout_data* data = NULL;
STREAMFILE* temp_streamFile = NULL; STREAMFILE* temp_streamFile = NULL;
int i, layers = (fsb5->channels+1) / 2; int i, layers = (fsb5->channels+1) / 2;
@ -494,7 +492,7 @@ static layered_layout_data* build_layered_fsb5_celt(STREAMFILE *streamFile, fsb5
data->layers[i]->loop_end_sample = fsb5->loop_end; data->layers[i]->loop_end_sample = fsb5->loop_end;
#ifdef VGM_USE_CELT #ifdef VGM_USE_CELT
data->layers[i]->codec_data = init_celt_fsb(layer_channels, version); data->layers[i]->codec_data = init_celt_fsb(layer_channels, CELT_0_11_0);
if (!data->layers[i]->codec_data) goto fail; if (!data->layers[i]->codec_data) goto fail;
data->layers[i]->coding_type = coding_CELT_FSB; data->layers[i]->coding_type = coding_CELT_FSB;
data->layers[i]->layout_type = layout_none; data->layers[i]->layout_type = layout_none;
@ -520,7 +518,7 @@ fail:
free_layout_layered(data); free_layout_layered(data);
return NULL; return NULL;
} }
#endif
static layered_layout_data* build_layered_fsb5_atrac9(STREAMFILE *streamFile, fsb5_header* fsb5, off_t configs_offset, size_t configs_size) { static layered_layout_data* build_layered_fsb5_atrac9(STREAMFILE *streamFile, fsb5_header* fsb5, off_t configs_offset, size_t configs_size) {
layered_layout_data* data = NULL; layered_layout_data* data = NULL;