mirror of
https://github.com/vgmstream/vgmstream.git
synced 2024-11-28 00:20:47 +01:00
cleanup: crlf/etc
This commit is contained in:
parent
2169f50259
commit
a6a113d813
@ -4,52 +4,51 @@
|
||||
#include "9tav_streamfile.h"
|
||||
|
||||
/* 9TAV - from Metal Gear Solid 2/3 HD (Vita) */
|
||||
VGMSTREAM * init_vgmstream_9tav(STREAMFILE *streamFile) {
|
||||
VGMSTREAM* init_vgmstream_9tav(STREAMFILE* sf) {
|
||||
VGMSTREAM * vgmstream = NULL;
|
||||
off_t start_offset;
|
||||
int loop_flag, channel_count, sample_rate, track_count;
|
||||
int loop_flag, channels, sample_rate, track_count;
|
||||
int32_t num_samples, loop_start, loop_end;
|
||||
size_t track_size;
|
||||
uint32_t config_data;
|
||||
int i, is_padded;
|
||||
layered_layout_data * data = NULL;
|
||||
STREAMFILE* temp_streamFile = NULL;
|
||||
bool is_padded;
|
||||
layered_layout_data* data = NULL;
|
||||
STREAMFILE* temp_sf = NULL;
|
||||
|
||||
|
||||
/* checks */
|
||||
if (!is_id32be(0x00,sf, "9TAV"))
|
||||
return NULL;
|
||||
/* .9tav: header id */
|
||||
if (!check_extensions(streamFile, "9tav"))
|
||||
goto fail;
|
||||
if (!check_extensions(sf, "9tav"))
|
||||
return NULL;
|
||||
|
||||
if (read_32bitBE(0x00,streamFile) != 0x39544156) /* "9TAV" */
|
||||
goto fail;
|
||||
|
||||
/* 0x04: always 0x09 */
|
||||
channel_count = read_16bitLE(0x08,streamFile);
|
||||
track_count = read_16bitLE(0x0a,streamFile); /* MGS3 uses multitracks */
|
||||
sample_rate = read_32bitLE(0x0c,streamFile);
|
||||
track_size = read_32bitLE(0x10,streamFile); /* without padding */
|
||||
//data_size = read_32bitLE(0x14,streamFile); /* without padding */
|
||||
num_samples = read_32bitLE(0x18,streamFile);
|
||||
config_data = read_32bitBE(0x1c,streamFile);
|
||||
/* 0x04: always 0x09 (codec?) */
|
||||
channels = read_u16le(0x08,sf);
|
||||
track_count = read_u16le(0x0a,sf); /* MGS3 uses multitracks */
|
||||
sample_rate = read_s32le(0x0c,sf);
|
||||
track_size = read_u32le(0x10,sf); /* without padding */
|
||||
//data_size = read_u32le(0x14,sf); /* without padding */
|
||||
num_samples = read_s32le(0x18,sf);
|
||||
config_data = read_u32be(0x1c,sf);
|
||||
|
||||
|
||||
if (read_32bitBE(0x20,streamFile) == 0x4D544146) { /* "MTAF" */
|
||||
if (is_id32be(0x20,sf, "MTAF")) {
|
||||
/* MGS3 has a MTAF header (data size and stuff don't match, probably for track info) */
|
||||
loop_start = read_32bitLE(0x78, streamFile);
|
||||
loop_end = read_32bitLE(0x7c, streamFile);
|
||||
loop_flag = read_32bitLE(0x90, streamFile) & 1;
|
||||
loop_start = read_s32le(0x78, sf);
|
||||
loop_end = read_s32le(0x7c, sf);
|
||||
loop_flag = read_u32le(0x90, sf) & 1;
|
||||
|
||||
is_padded = 1; /* data also has padding and other oddities */
|
||||
is_padded = true; /* data also has padding and other oddities */
|
||||
start_offset = 0x00;
|
||||
}
|
||||
else {
|
||||
/* MGS2 doesn't */
|
||||
loop_start = 0;
|
||||
loop_end = 0;
|
||||
loop_flag = 0;
|
||||
loop_flag = false;
|
||||
|
||||
is_padded = 0;
|
||||
is_padded = false;
|
||||
start_offset = 0x20;
|
||||
}
|
||||
|
||||
@ -59,8 +58,8 @@ VGMSTREAM * init_vgmstream_9tav(STREAMFILE *streamFile) {
|
||||
if (!data) goto fail;
|
||||
|
||||
/* open each layer subfile */
|
||||
for (i = 0; i < data->layer_count; i++) {
|
||||
data->layers[i] = allocate_vgmstream(channel_count, loop_flag);
|
||||
for (int i = 0; i < data->layer_count; i++) {
|
||||
data->layers[i] = allocate_vgmstream(channels, loop_flag);
|
||||
if (!data->layers[i]) goto fail;
|
||||
|
||||
data->layers[i]->meta_type = meta_9TAV;
|
||||
@ -72,7 +71,7 @@ VGMSTREAM * init_vgmstream_9tav(STREAMFILE *streamFile) {
|
||||
#ifdef VGM_USE_ATRAC9
|
||||
{
|
||||
atrac9_config cfg = {0};
|
||||
cfg.channels = channel_count;
|
||||
cfg.channels = channels;
|
||||
cfg.config_data = config_data;
|
||||
cfg.encoder_delay = atrac9_bytes_to_samples_cfg(track_size, cfg.config_data) - num_samples; /* seems ok */
|
||||
if (cfg.encoder_delay > 4096) /* doesn't seem too normal */
|
||||
@ -88,15 +87,15 @@ VGMSTREAM * init_vgmstream_9tav(STREAMFILE *streamFile) {
|
||||
#endif
|
||||
|
||||
if (is_padded) {
|
||||
temp_streamFile = setup_9tav_streamfile(streamFile, 0xFE4, track_size, i, track_count);
|
||||
if (!temp_streamFile) goto fail;
|
||||
temp_sf = setup_9tav_streamfile(sf, 0xFE4, track_size, i, track_count);
|
||||
if (!temp_sf) goto fail;
|
||||
}
|
||||
|
||||
if (!vgmstream_open_stream(data->layers[i],temp_streamFile == NULL ? streamFile : temp_streamFile,start_offset))
|
||||
if (!vgmstream_open_stream(data->layers[i],temp_sf == NULL ? sf : temp_sf,start_offset))
|
||||
goto fail;
|
||||
|
||||
close_streamfile(temp_streamFile);
|
||||
temp_streamFile = NULL;
|
||||
close_streamfile(temp_sf);
|
||||
temp_sf = NULL;
|
||||
}
|
||||
|
||||
/* setup layered VGMSTREAMs */
|
||||
@ -110,7 +109,7 @@ VGMSTREAM * init_vgmstream_9tav(STREAMFILE *streamFile) {
|
||||
return vgmstream;
|
||||
|
||||
fail:
|
||||
close_streamfile(temp_streamFile);
|
||||
close_streamfile(temp_sf);
|
||||
close_vgmstream(vgmstream);
|
||||
if (!vgmstream)
|
||||
free_layout_layered(data);
|
||||
|
Loading…
Reference in New Issue
Block a user