diff --git a/src/coding/coding_utils.c b/src/coding/coding_utils.c index 809a0480..1252fb2d 100644 --- a/src/coding/coding_utils.c +++ b/src/coding/coding_utils.c @@ -1015,21 +1015,21 @@ size_t aac_get_samples(STREAMFILE* sf, off_t start_offset, size_t bytes) { /* variable-sized var reader */ static int mpc_get_size(uint8_t* header, int header_size, int pos, int32_t* p_size) { - uint8_t tmp; - int32_t size = 0; + uint8_t tmp; + int32_t size = 0; - do { + do { if (pos >= header_size) return pos; - tmp = header[pos]; - size = (size << 7) | (tmp & 0x7F); - pos++; - } + tmp = header[pos]; + size = (size << 7) | (tmp & 0x7F); + pos++; + } while((tmp & 0x80)); - *p_size = size; - return pos; + *p_size = size; + return pos; } int mpc_get_samples(STREAMFILE* sf, off_t offset, int32_t* p_samples, int32_t* p_delay) { diff --git a/src/coding/ea_mt_decoder.c b/src/coding/ea_mt_decoder.c index 26d76b9e..b7b71b2a 100644 --- a/src/coding/ea_mt_decoder.c +++ b/src/coding/ea_mt_decoder.c @@ -115,9 +115,9 @@ void decode_ea_mt(VGMSTREAM* vgmstream, sample_t* outbuf, int channelspacing, in * notify the decoder when a new substream begins (even with looping disabled). */ if (ch_data->loop_sample > 0 && ch_data->samples_done == ch_data->loop_sample) { ch_data->samples_filled = 0; - ch_data->samples_discard = 0; + ch_data->samples_discard = 0; - /* offset is usually at loop_offset here, but not always (ex. loop_sample < 432) */ + /* offset is usually at loop_offset here, but not always (ex. loop_sample < 432) */ ch_data->offset = ch_data->loop_offset; utk_set_ptr(ctx, 0, 0); /* reset the buffer reader */ utk_reset(ctx); /* decoder init (all fields must be reset, for some edge cases) */ diff --git a/src/coding/hca_decoder.c b/src/coding/hca_decoder.c index e807ec63..d4183b62 100644 --- a/src/coding/hca_decoder.c +++ b/src/coding/hca_decoder.c @@ -72,7 +72,7 @@ fail: } void decode_hca(hca_codec_data* data, sample_t* outbuf, int32_t samples_to_do) { - int samples_done = 0; + int samples_done = 0; const unsigned int channels = data->info.channelCount; const unsigned int blockSize = data->info.blockSize; diff --git a/src/coding/hca_decoder_clhca.h b/src/coding/hca_decoder_clhca.h index dc72d39a..16089ce4 100644 --- a/src/coding/hca_decoder_clhca.h +++ b/src/coding/hca_decoder_clhca.h @@ -30,25 +30,25 @@ void clHCA_delete(clHCA *); int clHCA_DecodeHeader(clHCA *, const void *data, unsigned int size); typedef struct clHCA_stInfo { - unsigned int version; - unsigned int headerSize; - unsigned int samplingRate; - unsigned int channelCount; - unsigned int blockSize; - unsigned int blockCount; + unsigned int version; + unsigned int headerSize; + unsigned int samplingRate; + unsigned int channelCount; + unsigned int blockSize; + unsigned int blockCount; unsigned int encoderDelay; /* samples appended to the beginning */ unsigned int encoderPadding; /* samples appended to the end */ - unsigned int loopEnabled; - unsigned int loopStartBlock; - unsigned int loopEndBlock; + unsigned int loopEnabled; + unsigned int loopStartBlock; + unsigned int loopEndBlock; unsigned int loopStartDelay; /* samples in block before loop starts */ unsigned int loopEndPadding; /* samples in block after loop ends */ unsigned int samplesPerBlock; /* should be 1024 */ - const char *comment; - unsigned int encryptionEnabled; /* requires keycode */ + const char *comment; + unsigned int encryptionEnabled; /* requires keycode */ - /* Derived sample formulas: - * - sample count: blockCount*samplesPerBlock - encoderDelay - encoderPadding; + /* Derived sample formulas: + * - sample count: blockCount*samplesPerBlock - encoderDelay - encoderPadding; * - loop start sample = loopStartBlock*samplesPerBlock - encoderDelay + loopStartDelay * - loop end sample = loopEndBlock*samplesPerBlock - encoderDelay + (samplesPerBlock - info.loopEndPadding) */ diff --git a/src/coding/imuse_decoder.c b/src/coding/imuse_decoder.c index 9ce7c546..3b9d35f9 100644 --- a/src/coding/imuse_decoder.c +++ b/src/coding/imuse_decoder.c @@ -289,8 +289,8 @@ imuse_codec_data* init_imuse(STREAMFILE* sf, int channels) { while (counter > 0) { if (counter & i) value += step; - step >>= 1; - counter >>= 1; + step >>= 1; + counter >>= 1; } data->adpcm_table[i + j * 64] = value; /* non sequential: all 64 [0]s, [1]s ... [88]s */ diff --git a/src/coding/mpeg_decoder.c b/src/coding/mpeg_decoder.c index f93da4bf..d73ae220 100644 --- a/src/coding/mpeg_decoder.c +++ b/src/coding/mpeg_decoder.c @@ -250,11 +250,11 @@ static void decode_mpeg_standard(VGMSTREAMCHANNEL* stream, mpeg_codec_data* data data->bytes_in_buffer = read_streamfile(data->buffer,stream->offset,data->buffer_size,stream->streamfile); /* end of stream, fill rest with 0s */ - if (data->bytes_in_buffer <= 0) { - VGM_ASSERT(samples_to_do < samples_done, "MPEG: end of stream, filling %i\n", (samples_to_do - samples_done)); - memset(outbuf + samples_done * channels, 0, (samples_to_do - samples_done) * channels * sizeof(sample)); - break; - } + if (data->bytes_in_buffer <= 0) { + VGM_ASSERT(samples_to_do < samples_done, "MPEG: end of stream, filling %i\n", (samples_to_do - samples_done)); + memset(outbuf + samples_done * channels, 0, (samples_to_do - samples_done) * channels * sizeof(sample)); + break; + } data->buffer_full = 1; data->buffer_used = 0; diff --git a/src/coding/relic_decoder_lib.c b/src/coding/relic_decoder_lib.c index 7e050146..52d85cbf 100644 --- a/src/coding/relic_decoder_lib.c +++ b/src/coding/relic_decoder_lib.c @@ -26,8 +26,8 @@ extern void fft(int n, float* xRe, float* xIm, float* yRe, float* yIm); #define RELIC_MAX_SIZE RELIC_SIZE_HIGH #define RELIC_MAX_FREQ (RELIC_MAX_SIZE / 2) #define RELIC_MAX_FFT (RELIC_MAX_SIZE / 4) -#define RELIC_MIN_BITRATE 256 -#define RELIC_MAX_BITRATE 2048 +#define RELIC_MIN_BITRATE 256 +#define RELIC_MAX_BITRATE 2048 //#define RELIC_MAX_FRAME_SIZE ((RELIC_MAX_BITRATE / 8) + 0x04) /* extra 0x04 for the bitreader */ diff --git a/src/coding/ws_decoder.c b/src/coding/ws_decoder.c index 3dc530a2..ea0a36ed 100644 --- a/src/coding/ws_decoder.c +++ b/src/coding/ws_decoder.c @@ -6,24 +6,22 @@ /* Based on Valery V. Anisimovsky's WS-AUD.txt */ -static char WSTable2bit[4]={-2,-1,0,1}; -static char WSTable4bit[16]={-9,-8,-6,-5,-4,-3,-2,-1, - 0, 1, 2, 3, 4, 5 ,6, 8}; +static char WSTable2bit[4] = { -2,-1,0,1 }; +static char WSTable4bit[16] = { -9,-8,-6,-5,-4,-3,-2,-1, 0, 1, 2, 3, 4, 5 ,6, 8 }; /* We pass in the VGMSTREAM here, unlike in other codings, because the decoder has to know about the block structure. */ void decode_ws(VGMSTREAM * vgmstream, int channel, sample * outbuf, int channelspacing, int32_t first_sample, int32_t samples_to_do) { - VGMSTREAMCHANNEL * stream = &(vgmstream->ch[channel]); - int16_t hist = stream->adpcm_history1_16; + int16_t hist = stream->adpcm_history1_16; off_t offset = stream->offset; int samples_left_in_frame = stream->samples_left_in_frame; off_t header_off = stream->frame_header_offset; - int i; - int32_t sample_count; - + int i; + int32_t sample_count; + if (vgmstream->ws_output_size == vgmstream->current_block_size) { /* uncompressed, we just need to convert to 16-bit */ for (i=first_sample,sample_count=0; icurrent_block_size, 1); break; case coding_XBOX_IMA: block_samples = xbox_ima_bytes_to_samples(vgmstream->current_block_size, 1); break; case coding_NGC_DSP: block_samples = dsp_bytes_to_samples(vgmstream->current_block_size, 1); break; - case coding_PSX: block_samples = ps_bytes_to_samples(vgmstream->current_block_size,1); break; + case coding_PSX: block_samples = ps_bytes_to_samples(vgmstream->current_block_size,1); break; default: VGM_LOG("BLOCKED: missing codec\n"); return; diff --git a/src/meta/adp_bos.c b/src/meta/adp_bos.c index de7a5634..38b05de2 100644 --- a/src/meta/adp_bos.c +++ b/src/meta/adp_bos.c @@ -5,7 +5,7 @@ VGMSTREAM* init_vgmstream_adp_bos(STREAMFILE* sf) { VGMSTREAM* vgmstream = NULL; off_t start_offset; int loop_flag = 0; - int channels; + int channels; /* checks */ if (!check_extensions(sf,"adp")) @@ -19,7 +19,7 @@ VGMSTREAM* init_vgmstream_adp_bos(STREAMFILE* sf) { start_offset = 0x18; - /* build the VGMSTREAM */ + /* build the VGMSTREAM */ vgmstream = allocate_vgmstream(channels, loop_flag); if (!vgmstream) goto fail; diff --git a/src/meta/awb.c b/src/meta/awb.c index e5843529..834fe274 100644 --- a/src/meta/awb.c +++ b/src/meta/awb.c @@ -234,7 +234,7 @@ static void load_awb_name(STREAMFILE* sf, STREAMFILE* sf_acb, VGMSTREAM* vgmstre } } - /* probably loaded */ + /* probably loaded */ load_acb_wave_name(sf_acb, vgmstream, waveid, port, is_memory); close_streamfile(sf_acb); diff --git a/src/meta/cri_utf.c b/src/meta/cri_utf.c index bd9f17d2..e2192916 100644 --- a/src/meta/cri_utf.c +++ b/src/meta/cri_utf.c @@ -5,10 +5,10 @@ #define COLUMN_BITMASK_TYPE 0x0f enum columna_flag_t { - COLUMN_FLAG_NAME = 0x10, - COLUMN_FLAG_DEFAULT = 0x20, - COLUMN_FLAG_ROW = 0x40, - COLUMN_FLAG_UNDEFINED = 0x80 /* shouldn't exist */ + COLUMN_FLAG_NAME = 0x10, + COLUMN_FLAG_DEFAULT = 0x20, + COLUMN_FLAG_ROW = 0x40, + COLUMN_FLAG_UNDEFINED = 0x80 /* shouldn't exist */ }; enum column_type_t { diff --git a/src/meta/dsp_adx.c b/src/meta/dsp_adx.c index addf8dd7..42cbb3d8 100644 --- a/src/meta/dsp_adx.c +++ b/src/meta/dsp_adx.c @@ -2,49 +2,47 @@ #include "../coding/coding.h" #include "../util.h" -/* .ADX - from Xenoblade 3D */ -/* Xenoblade Chronicles 3D uses an adx extension as with - * the Wii version, but it's actually DSP ADPCM. */ -VGMSTREAM * init_vgmstream_dsp_adx(STREAMFILE *streamFile) { - VGMSTREAM * vgmstream = NULL; - int loop_flag, channel_count; +/* .ADX - from Xenoblade 3D (3DS) */ +VGMSTREAM* init_vgmstream_dsp_adx(STREAMFILE *sf) { + VGMSTREAM* vgmstream = NULL; + int loop_flag, channels; int channel_header_spacing = 0x34; - - /* check extension, case insensitive */ - if (!check_extensions(streamFile,"adx")) goto fail; - /* check header */ - if (read_32bitBE(0,streamFile)!=0x02000000) goto fail; + /* checks */ + if (!check_extensions(sf,"adx")) + goto fail; - channel_count = read_32bitLE(0, streamFile); - loop_flag = read_16bitLE(0x6e, streamFile); + if (read_u32be(0x00,sf) != 0x02000000) + goto fail; - if (channel_count > 2 || channel_count < 0) goto fail; + channels = read_32bitLE(0, sf); + loop_flag = read_16bitLE(0x6e, sf); - vgmstream = allocate_vgmstream(channel_count,loop_flag); + if (channels > 2 || channels < 0) goto fail; + + vgmstream = allocate_vgmstream(channels, loop_flag); if (!vgmstream) goto fail; vgmstream->coding_type = coding_NGC_DSP; vgmstream->layout_type = layout_none; vgmstream->meta_type = meta_XB3D_ADX; - vgmstream->sample_rate = read_32bitLE(0x70,streamFile); - vgmstream->num_samples = read_32bitLE(0x74, streamFile); - vgmstream->loop_start_sample = read_32bitLE(0x78, streamFile); - vgmstream->loop_end_sample = read_32bitLE(0x7c, streamFile); - - dsp_read_coefs_le(vgmstream,streamFile, 0x4, channel_header_spacing); + vgmstream->sample_rate = read_32bitLE(0x70,sf); + vgmstream->num_samples = read_32bitLE(0x74, sf); + vgmstream->loop_start_sample = read_32bitLE(0x78, sf); + vgmstream->loop_end_sample = read_32bitLE(0x7c, sf); + dsp_read_coefs_le(vgmstream,sf, 0x4, channel_header_spacing); /* semi-interleave: manually open streams at offset */ { char filename[PATH_LIMIT]; int i; - streamFile->get_name(streamFile,filename,sizeof(filename)); - for (i = 0; ich[i].streamfile = streamFile->open(streamFile, filename, STREAMFILE_DEFAULT_BUFFER_SIZE); + sf->get_name(sf,filename,sizeof(filename)); + for (i = 0; ich[i].streamfile = sf->open(sf, filename, STREAMFILE_DEFAULT_BUFFER_SIZE); vgmstream->ch[i].channel_start_offset = - vgmstream->ch[i].offset = read_32bitLE(0x34+i*channel_header_spacing, streamFile); + vgmstream->ch[i].offset = read_32bitLE(0x34+i*channel_header_spacing, sf); if (!vgmstream->ch[i].streamfile) goto fail; } } diff --git a/src/meta/fsb5_fev.c b/src/meta/fsb5_fev.c index 4014716c..80432a8f 100644 --- a/src/meta/fsb5_fev.c +++ b/src/meta/fsb5_fev.c @@ -128,7 +128,7 @@ VGMSTREAM* init_vgmstream_fsb5_fev_bank(STREAMFILE* sf) { } } - //;VGM_LOG("FSB5 FEV: offset=%lx, size=%x\n", subfile_offset,subfile_size); + //;VGM_LOG("FSB5 FEV: offset=%lx, size=%x\n", subfile_offset,subfile_size); temp_sf = setup_subfile_streamfile(sf, subfile_offset,subfile_size, "fsb"); if (!temp_sf) goto fail; diff --git a/src/meta/wii_bns.c b/src/meta/wii_bns.c index aa4b086f..12fc35c3 100644 --- a/src/meta/wii_bns.c +++ b/src/meta/wii_bns.c @@ -8,7 +8,7 @@ VGMSTREAM* init_vgmstream_wii_bns(STREAMFILE* sf) { off_t bns_offset; uint32_t info_offset = 0, data_offset = 0; uint32_t channel_info_offset_list_offset; - int channels, loop_flag, sample_rate; + int channels, loop_flag, sample_rate; uint32_t sample_count, loop_start; /* checks */ @@ -106,7 +106,7 @@ VGMSTREAM* init_vgmstream_wii_bns(STREAMFILE* sf) { channel_info_offset_list_offset = info_offset + read_u32be(info_offset+0x10,sf); } - /* build the VGMSTREAM */ + /* build the VGMSTREAM */ vgmstream = allocate_vgmstream(channels, loop_flag); if (!vgmstream) goto fail; diff --git a/src/meta/wwise.c b/src/meta/wwise.c index f226d92b..d48a6315 100644 --- a/src/meta/wwise.c +++ b/src/meta/wwise.c @@ -510,7 +510,7 @@ VGMSTREAM* init_vgmstream_wwise(STREAMFILE* sf) { if (ww.bits_per_sample != 16) goto fail; /* original data_size doesn't look related to samples or anything */ - ww.data_size = ww.file_size - ww.data_offset; + ww.data_size = ww.file_size - ww.data_offset; vgmstream->codec_data = init_ffmpeg_offset(sf, ww.data_offset, ww.data_size); if (!vgmstream->codec_data) goto fail; @@ -682,7 +682,7 @@ static int is_dsp_full_interleave(STREAMFILE* sf, wwise_header* ww, off_t coef_o * - .bnk would be memory banks = full * - otherwise small-ish sizes, stereo, with initial predictors for the * second channel matching half size = full - * some files aren't detectable like this though, when predictors are 0 + * some files aren't detectable like this though, when predictors are 0 * (but since memory wem aren't that used this shouldn't be too common) */ if (ww->truncated) @@ -960,7 +960,7 @@ fail: 0x14 (4): LoopInfo.dwLoopEndPacketOffset? 0x18 (4): dwSeekTableSize (0 = no seek table) 0x1c (4): dwVorbisDataOffset (offset within data) -0x20 (2): uMaxPacketSize (not including header) +0x20 (2): uMaxPacketSize (not including header) 0x22 (2): uLastGranuleExtra (0..~0x100) 0x24 (4): dwDecodeAllocSize (0~0x5000) 0x28 (4): dwDecodeX64AllocSize (mid, 0~0x5000) @@ -976,7 +976,7 @@ fail: 0x0c (2): ? (small, 0..~0x400) [(4) when size is 0x2C] 0x10 (4): dwSeekTableSize (0 = no seek table) 0x14 (4): dwVorbisDataOffset (offset within data) -0x18 (2): uMaxPacketSize (not including header) +0x18 (2): uMaxPacketSize (not including header) 0x1a (2): uLastGranuleExtra (0..~0x100) [(4) when size is 0x2C] 0x1c (4): dwDecodeAllocSize (0~0x5000) 0x20 (4): dwDecodeX64AllocSize (0~0x5000) @@ -993,7 +993,7 @@ fail: 0x26 (2): LoopInfo.uLoopEndExtra (extra samples after seek?) 0x28 (4): dwSeekTableSize (0 = no seek table) 0x2c (4): dwVorbisDataOffset (offset within data) -0x30 (2): uMaxPacketSize (not including header) +0x30 (2): uMaxPacketSize (not including header) 0x32 (2): uLastGranuleExtra (small, 0..~0x100) 0x34 (4): dwDecodeAllocSize (mid, 0~0x5000) 0x38 (4): dwDecodeX64AllocSize (mid, 0~0x5000) diff --git a/src/meta/xnb_lz4mg.h b/src/meta/xnb_lz4mg.h index f783fa59..dc61510d 100644 --- a/src/meta/xnb_lz4mg.h +++ b/src/meta/xnb_lz4mg.h @@ -190,7 +190,7 @@ static int lz4mg_decompress(lz4mg_stream_t* strm) { default: goto fail; } - } + } buffer_end: strm->next_out += dst_pos; @@ -208,16 +208,16 @@ fail: #if 0 /* non-streamed form for reference, assumes buffers are big enough */ static void decompress_lz4mg(uint8_t* dst, size_t dst_size, const uint8_t* src, size_t src_size) { - size_t src_pos = 0; - size_t dst_pos = 0; + size_t src_pos = 0; + size_t dst_pos = 0; uint8_t token; int literal_len, match_len, next_len; int match_pos, match_offset; int i; - while (src_pos < src_size && dst_pos < dst_size) { + while (src_pos < src_size && dst_pos < dst_size) { - token = src[src_pos++]; + token = src[src_pos++]; if (src_pos > src_size) break; @@ -259,7 +259,7 @@ static void decompress_lz4mg(uint8_t* dst, size_t dst_size, const uint8_t* src, for(i = 0; i < match_len; i++) { dst[dst_pos++] = dst[match_pos++]; /* note RLE with short offsets */ } - } + } } #endif diff --git a/src/meta/xvag.c b/src/meta/xvag.c index 4236c978..c7a36505 100644 --- a/src/meta/xvag.c +++ b/src/meta/xvag.c @@ -26,8 +26,8 @@ typedef struct { off_t stream_offset; } xvag_header; -static int init_xvag_atrac9(STREAMFILE* sf, VGMSTREAM* vgmstream, xvag_header * xvag, off_t chunk_offset); -static layered_layout_data* build_layered_xvag(STREAMFILE* sf, xvag_header * xvag, off_t chunk_offset, off_t start_offset); +static int init_xvag_atrac9(STREAMFILE* sf, VGMSTREAM* vgmstream, xvag_header* xvag, off_t chunk_offset); +static layered_layout_data* build_layered_xvag(STREAMFILE* sf, xvag_header* xvag, off_t chunk_offset, off_t start_offset); /* XVAG - Sony's Scream Tool/Stream Creator format (God of War III, Ratchet & Clank Future, The Last of Us, Uncharted) */ VGMSTREAM* init_vgmstream_xvag(STREAMFILE* sf) { @@ -42,7 +42,7 @@ VGMSTREAM* init_vgmstream_xvag(STREAMFILE* sf) { /* checks */ /* .xvag: standard - * (extensionless): The Last Of Us (PS3) speech files */ + * (extensionless): The Last of Us (PS3) speech files */ if (!check_extensions(sf,"xvag,")) goto fail; if (!is_id32be(0x00,sf, "XVAG")) @@ -254,7 +254,7 @@ fail: } #ifdef VGM_USE_ATRAC9 -static int init_xvag_atrac9(STREAMFILE* sf, VGMSTREAM* vgmstream, xvag_header * xvag, off_t chunk_offset) { +static int init_xvag_atrac9(STREAMFILE* sf, VGMSTREAM* vgmstream, xvag_header* xvag, off_t chunk_offset) { int32_t (*read_32bit)(off_t,STREAMFILE*) = xvag->big_endian ? read_32bitBE : read_32bitLE; atrac9_config cfg = {0}; @@ -265,7 +265,7 @@ static int init_xvag_atrac9(STREAMFILE* sf, VGMSTREAM* vgmstream, xvag_header * /* 0x08: data size (layer only) */ /* 0x10: decoder delay? */ cfg.encoder_delay = read_32bit(chunk_offset+0x14,sf); - /* sometimes ATRAC9 data starts with a fake RIFF, that has total channels rather than layer channels */ + /* sometimes ATRAC9 data starts with a fake RIFF, that has total channels rather than layer channels */ vgmstream->codec_data = init_atrac9(&cfg); if (!vgmstream->codec_data) goto fail; @@ -278,7 +278,7 @@ fail: } #endif -static layered_layout_data* build_layered_xvag(STREAMFILE* sf, xvag_header * xvag, off_t chunk_offset, off_t start_offset) { +static layered_layout_data* build_layered_xvag(STREAMFILE* sf, xvag_header* xvag, off_t chunk_offset, off_t start_offset) { layered_layout_data* data = NULL; STREAMFILE* temp_sf = NULL; int32_t (*read_32bit)(off_t,STREAMFILE*) = xvag->big_endian ? read_32bitBE : read_32bitLE; @@ -309,7 +309,7 @@ static layered_layout_data* build_layered_xvag(STREAMFILE* sf, xvag_header * xva if (!init_xvag_atrac9(sf, data->layers[i], xvag, chunk_offset)) goto fail; - /* interleaves N layers for custom multichannel, may rarely use subsongs [Days Gone (PS4) multilayer test] + /* interleaves N layers for custom multichannel, may rarely use subsongs [Days Gone (PS4) multilayer test] * ex. 2 layers, 1 subsong : [L1][L2][L1][L2] * ex. 2 layers, 2 subsongs: [L1S1][L2S1][L1S2][L2S2] (assumed, could be [L1S1][L1S2][L2S1][L2S2]) */ chunk = i + xvag->subsongs * (xvag->target_subsong - 1); /* [L1S1][L2S1][L1S2][L2S2] */