cleanup: etc

This commit is contained in:
bnnm 2021-07-29 23:41:27 +02:00
parent 0fcf134cfd
commit 3c03891d13
5 changed files with 328 additions and 331 deletions

View File

@ -420,7 +420,7 @@ static void decode_vima1(sbuf_t* sbuf, uint8_t* buf, size_t data_left, int block
sbuf->filled += data_left / sizeof(int16_t) / chs;
}
static int decode_block1(STREAMFILE* sf, imuse_codec_data* data, uint8_t* block, size_t data_left) {
static int decode_block1(imuse_codec_data* data, uint8_t* block, size_t data_left) {
int block_num = data->current_block;
switch(data->block_table[block_num].flags) {
@ -554,7 +554,7 @@ static void decode_vima2(sbuf_t* sbuf, uint8_t* buf, size_t data_left, uint16_t*
sbuf->filled += data_left / sizeof(int16_t) / chs;
}
static int decode_block2(STREAMFILE* sf, imuse_codec_data* data, uint8_t* block, size_t data_left) {
static int decode_block2(imuse_codec_data* data, uint8_t* block, size_t data_left) {
int block_num = data->current_block;
switch(data->block_table[block_num].flags) {
@ -597,11 +597,11 @@ static int decode_block(STREAMFILE* sf, imuse_codec_data* data) {
switch(data->type) {
case COMP:
ok = decode_block1(sf, data, block, data_left);
ok = decode_block1(data, block, data_left);
break;
case MCMP:
ok = decode_block2(sf, data, block, data_left);
ok = decode_block2(data, block, data_left);
break;
default:

View File

@ -2,8 +2,8 @@
#include "../coding/coding.h"
/* .AIF - from Asobo Studio games [Ratatouille (PC), WALL-E (PC), Up (PC)] */
VGMSTREAM * init_vgmstream_aif_asobo(STREAMFILE *streamFile) {
VGMSTREAM * vgmstream = NULL;
VGMSTREAM* init_vgmstream_aif_asobo(STREAMFILE* sf) {
VGMSTREAM* vgmstream = NULL;
off_t start_offset;
size_t data_size;
int loop_flag, channel_count;
@ -11,23 +11,23 @@ VGMSTREAM * init_vgmstream_aif_asobo(STREAMFILE *streamFile) {
/* checks */
/* aif: standard, .laif/aiffl: for plugins */
if ( !check_extensions(streamFile,"aif,laif,aiffl") )
if ( !check_extensions(sf,"aif,laif,aiffl") )
goto fail;
if ((uint16_t)read_16bitLE(0x00,streamFile) != 0x69) /* Xbox codec */
if ((uint16_t)read_16bitLE(0x00,sf) != 0x69) /* Xbox codec */
goto fail;
channel_count = read_16bitLE(0x02,streamFile); /* assumed, only stereo is known */
channel_count = read_16bitLE(0x02,sf); /* assumed, only stereo is known */
if (channel_count != 2) goto fail;
/* 0x08: ? */
if ((uint16_t)read_16bitLE(0x0c,streamFile) != 0x24*channel_count) /* Xbox block */
if ((uint16_t)read_16bitLE(0x0c,sf) != 0x24*channel_count) /* Xbox block */
goto fail;
if ((uint16_t)read_16bitLE(0x0e,streamFile) != 0x04) /* Xbox bps */
if ((uint16_t)read_16bitLE(0x0e,sf) != 0x04) /* Xbox bps */
goto fail;
loop_flag = 0;
start_offset = 0x14;
data_size = get_streamfile_size(streamFile) - start_offset;
data_size = get_streamfile_size(sf) - start_offset;
/* build the VGMSTREAM */
@ -35,13 +35,13 @@ VGMSTREAM * init_vgmstream_aif_asobo(STREAMFILE *streamFile) {
if (!vgmstream) goto fail;
vgmstream->meta_type = meta_AIF_ASOBO;
vgmstream->sample_rate = read_32bitLE(0x04,streamFile);
vgmstream->sample_rate = read_32bitLE(0x04,sf);
vgmstream->num_samples = xbox_ima_bytes_to_samples(data_size,channel_count);
vgmstream->coding_type = coding_XBOX_IMA;
vgmstream->layout_type = layout_none;
if ( !vgmstream_open_stream(vgmstream, streamFile, start_offset) )
if ( !vgmstream_open_stream(vgmstream, sf, start_offset) )
goto fail;
return vgmstream;

View File

@ -44,7 +44,7 @@ static void get_name_bar(BARSTREAMFILE *streamFile, char *name, size_t length) {
streamFile->real_file->get_name(streamFile->real_file, name, length);
}
STREAMFILE *open_bar(BARSTREAMFILE *streamFile, const char * const filename, size_t buffersize) {
static STREAMFILE *open_bar(BARSTREAMFILE *streamFile, const char * const filename, size_t buffersize) {
STREAMFILE *newfile = streamFile->real_file->open(streamFile->real_file,filename,buffersize);
if (!newfile)
return NULL;

View File

@ -3,7 +3,7 @@
#include "../coding/coding.h"
/* .vs/STRx - from The Bouncer (PS2) */
VGMSTREAM * init_vgmstream_vs_str(STREAMFILE *streamFile) {
VGMSTREAM* init_vgmstream_vs_str(STREAMFILE* sf) {
VGMSTREAM * vgmstream = NULL;
int channel_count, loop_flag;
off_t start_offset;
@ -12,17 +12,17 @@ VGMSTREAM * init_vgmstream_vs_str(STREAMFILE *streamFile) {
/* checks */
/* .vs: real extension (from .nam container)
* .str: fake, partial header id */
if (!check_extensions(streamFile, "vs,str"))
if (!check_extensions(sf, "vs,str"))
goto fail;
if (!(read_32bitBE(0x000,streamFile) == 0x5354524C && /* "STRL" */
read_32bitBE(0x800,streamFile) == 0x53545252) && /* "STRR" */
read_32bitBE(0x00,streamFile) != 0x5354524D) /* "STRM" */
if (!(read_32bitBE(0x000,sf) == 0x5354524C && /* "STRL" */
read_32bitBE(0x800,sf) == 0x53545252) && /* "STRR" */
read_32bitBE(0x00,sf) != 0x5354524D) /* "STRM" */
goto fail;
loop_flag = 0;
channel_count = (read_32bitBE(0x00,streamFile) == 0x5354524D) ? 1 : 2; /* "STRM"=mono (voices) */
channel_count = (read_32bitBE(0x00,sf) == 0x5354524D) ? 1 : 2; /* "STRM"=mono (voices) */
start_offset = 0x00;
/* build the VGMSTREAM */
@ -34,7 +34,7 @@ VGMSTREAM * init_vgmstream_vs_str(STREAMFILE *streamFile) {
vgmstream->coding_type = coding_PSX;
vgmstream->layout_type = layout_blocked_vs_str;
if (!vgmstream_open_stream(vgmstream,streamFile,start_offset))
if (!vgmstream_open_stream(vgmstream,sf,start_offset))
goto fail;
/* calc num_samples */
@ -44,7 +44,7 @@ VGMSTREAM * init_vgmstream_vs_str(STREAMFILE *streamFile) {
block_update(vgmstream->next_block_offset,vgmstream);
vgmstream->num_samples += ps_bytes_to_samples(vgmstream->current_block_size, 1);
}
while (vgmstream->next_block_offset < get_streamfile_size(streamFile));
while (vgmstream->next_block_offset < get_streamfile_size(sf));
block_update(start_offset, vgmstream);
}

View File

@ -2,25 +2,25 @@
#include "../coding/coding.h"
/* WBAT - Firebrand Games header [Need for Speed: The Run (3DS), Fast & Furious: Showdown (3DS)] */
VGMSTREAM * init_vgmstream_wavebatch(STREAMFILE *streamFile) {
VGMSTREAM * init_vgmstream_wavebatch(STREAMFILE *sf) {
VGMSTREAM * vgmstream = NULL;
off_t start_offset, name_offset, offset, stream_offset;
size_t names_size, stream_size;
int loop_flag, channel_count, sample_rate, num_samples;
int big_endian, version, codec;
int total_subsongs, target_subsong = streamFile->stream_index;
int total_subsongs, target_subsong = sf->stream_index;
int32_t (*read_32bit)(off_t,STREAMFILE*) = NULL;
int16_t (*read_16bit)(off_t,STREAMFILE*) = NULL;
/* checks */
if (!check_extensions(streamFile, "wavebatch"))
if (!check_extensions(sf, "wavebatch"))
goto fail;
if (read_32bitBE(0x00,streamFile) != 0x54414257) /* "TABW" */
if (!is_id32be(0x00,sf, "TABW"))
goto fail;
/* section0: base header */
big_endian = ((uint16_t)read_16bitBE(0x04,streamFile) == 0xFEFF); /* BOM (always LE on 3DS/Android) */
big_endian = (read_u16be(0x04,sf) == 0xFEFF); /* BOM (always LE on 3DS/Android) */
if (big_endian) {
read_32bit = read_32bitBE;
read_16bit = read_16bitBE;
@ -30,15 +30,15 @@ VGMSTREAM * init_vgmstream_wavebatch(STREAMFILE *streamFile) {
}
version = read_16bit(0x06, streamFile); /* assumed */
version = read_16bit(0x06, sf); /* assumed */
if (version != 0x06 && version != 0x07) /* v6 = NFS: The Run , v7 = F&F Showndown */
goto fail;
total_subsongs = read_32bit(0x08,streamFile);
total_subsongs = read_32bit(0x08,sf);
if (target_subsong == 0) target_subsong = 1;
if (target_subsong < 0 || target_subsong > total_subsongs || total_subsongs < 1) goto fail;
names_size = read_32bit(0x0c,streamFile);
names_size = read_32bit(0x0c,sf);
/* 0x10/14: see below */
/* 0x18: data size (all subsongs) */
offset = 0x1c + names_size; /* skip names table */
@ -47,14 +47,14 @@ VGMSTREAM * init_vgmstream_wavebatch(STREAMFILE *streamFile) {
/* section1: unknown */
{
size_t unknown_size = read_32bit(0x10,streamFile);
size_t unknown_size = read_32bit(0x10,sf);
/* 0x00: usually 0, rarely 0x20? */
offset += unknown_size*0x04;
}
/* section2: samples */
{
size_t samples_size = read_32bit(0x14,streamFile);
size_t samples_size = read_32bit(0x14,sf);
/* 0x00: num_samples */
offset += samples_size*0x04;
}
@ -63,15 +63,15 @@ VGMSTREAM * init_vgmstream_wavebatch(STREAMFILE *streamFile) {
{
off_t header_offset = offset+(target_subsong-1)*0x24;
name_offset = read_32bit(header_offset+0x00, streamFile) + 0x1c; /* within name table */
codec = read_32bit(header_offset+0x04, streamFile);
sample_rate = read_32bit(header_offset+0x08, streamFile);
channel_count = read_32bit(header_offset+0x0c, streamFile);
name_offset = read_32bit(header_offset+0x00, sf) + 0x1c; /* within name table */
codec = read_32bit(header_offset+0x04, sf);
sample_rate = read_32bit(header_offset+0x08, sf);
channel_count = read_32bit(header_offset+0x0c, sf);
/* 0x10: index within section1/2? */
/* 0x14: flags? 0x01 or (rarely) 0x02 */
stream_offset = read_32bit(header_offset+0x18, streamFile);
stream_size = read_32bit(header_offset+0x1c, streamFile); /* including DSP config */
num_samples = read_32bit(header_offset+0x20, streamFile) / channel_count; /* nibble/PCMs */
stream_offset = read_32bit(header_offset+0x18, sf);
stream_size = read_32bit(header_offset+0x1c, sf); /* including DSP config */
num_samples = read_32bit(header_offset+0x20, sf) / channel_count; /* nibble/PCMs */
offset += total_subsongs*0x24;
}
@ -111,8 +111,8 @@ VGMSTREAM * init_vgmstream_wavebatch(STREAMFILE *streamFile) {
vgmstream->layout_type = layout_interleave;
vgmstream->interleave_block_size = (stream_size - config_size) / channel_count; /* full interleave*/;
dsp_read_coefs(vgmstream,streamFile,start_offset+0x00,0x20+0x14,big_endian);
dsp_read_hist (vgmstream,streamFile,start_offset+0x20,0x14+0x20,big_endian);
dsp_read_coefs(vgmstream,sf,start_offset+0x00,0x20+0x14,big_endian);
dsp_read_hist (vgmstream,sf,start_offset+0x20,0x14+0x20,big_endian);
start_offset += config_size;
break;
@ -123,12 +123,9 @@ VGMSTREAM * init_vgmstream_wavebatch(STREAMFILE *streamFile) {
goto fail;
}
read_string(vgmstream->stream_name,STREAM_NAME_SIZE, name_offset,sf); /* always null-terminated */
read_string(vgmstream->stream_name,STREAM_NAME_SIZE, name_offset,streamFile); /* always null-terminated */
if (!vgmstream_open_stream(vgmstream,streamFile,start_offset))
if (!vgmstream_open_stream(vgmstream, sf, start_offset))
goto fail;
return vgmstream;