mirror of
https://github.com/vgmstream/vgmstream.git
synced 2025-01-31 12:23:44 +01:00
cleanup: etc
This commit is contained in:
parent
0fcf134cfd
commit
3c03891d13
@ -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;
|
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;
|
int block_num = data->current_block;
|
||||||
|
|
||||||
switch(data->block_table[block_num].flags) {
|
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;
|
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;
|
int block_num = data->current_block;
|
||||||
|
|
||||||
switch(data->block_table[block_num].flags) {
|
switch(data->block_table[block_num].flags) {
|
||||||
@ -597,11 +597,11 @@ static int decode_block(STREAMFILE* sf, imuse_codec_data* data) {
|
|||||||
|
|
||||||
switch(data->type) {
|
switch(data->type) {
|
||||||
case COMP:
|
case COMP:
|
||||||
ok = decode_block1(sf, data, block, data_left);
|
ok = decode_block1(data, block, data_left);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MCMP:
|
case MCMP:
|
||||||
ok = decode_block2(sf, data, block, data_left);
|
ok = decode_block2(data, block, data_left);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
@ -1,51 +1,51 @@
|
|||||||
#include "meta.h"
|
#include "meta.h"
|
||||||
#include "../coding/coding.h"
|
#include "../coding/coding.h"
|
||||||
|
|
||||||
/* .AIF - from Asobo Studio games [Ratatouille (PC), WALL-E (PC), Up (PC)] */
|
/* .AIF - from Asobo Studio games [Ratatouille (PC), WALL-E (PC), Up (PC)] */
|
||||||
VGMSTREAM * init_vgmstream_aif_asobo(STREAMFILE *streamFile) {
|
VGMSTREAM* init_vgmstream_aif_asobo(STREAMFILE* sf) {
|
||||||
VGMSTREAM * vgmstream = NULL;
|
VGMSTREAM* vgmstream = NULL;
|
||||||
off_t start_offset;
|
off_t start_offset;
|
||||||
size_t data_size;
|
size_t data_size;
|
||||||
int loop_flag, channel_count;
|
int loop_flag, channel_count;
|
||||||
|
|
||||||
|
|
||||||
/* checks */
|
/* checks */
|
||||||
/* aif: standard, .laif/aiffl: for plugins */
|
/* aif: standard, .laif/aiffl: for plugins */
|
||||||
if ( !check_extensions(streamFile,"aif,laif,aiffl") )
|
if ( !check_extensions(sf,"aif,laif,aiffl") )
|
||||||
goto fail;
|
goto fail;
|
||||||
if ((uint16_t)read_16bitLE(0x00,streamFile) != 0x69) /* Xbox codec */
|
if ((uint16_t)read_16bitLE(0x00,sf) != 0x69) /* Xbox codec */
|
||||||
goto fail;
|
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;
|
if (channel_count != 2) goto fail;
|
||||||
|
|
||||||
/* 0x08: ? */
|
/* 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;
|
goto fail;
|
||||||
if ((uint16_t)read_16bitLE(0x0e,streamFile) != 0x04) /* Xbox bps */
|
if ((uint16_t)read_16bitLE(0x0e,sf) != 0x04) /* Xbox bps */
|
||||||
goto fail;
|
goto fail;
|
||||||
loop_flag = 0;
|
loop_flag = 0;
|
||||||
|
|
||||||
start_offset = 0x14;
|
start_offset = 0x14;
|
||||||
data_size = get_streamfile_size(streamFile) - start_offset;
|
data_size = get_streamfile_size(sf) - start_offset;
|
||||||
|
|
||||||
|
|
||||||
/* build the VGMSTREAM */
|
/* build the VGMSTREAM */
|
||||||
vgmstream = allocate_vgmstream(channel_count,loop_flag);
|
vgmstream = allocate_vgmstream(channel_count,loop_flag);
|
||||||
if (!vgmstream) goto fail;
|
if (!vgmstream) goto fail;
|
||||||
|
|
||||||
vgmstream->meta_type = meta_AIF_ASOBO;
|
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->num_samples = xbox_ima_bytes_to_samples(data_size,channel_count);
|
||||||
|
|
||||||
vgmstream->coding_type = coding_XBOX_IMA;
|
vgmstream->coding_type = coding_XBOX_IMA;
|
||||||
vgmstream->layout_type = layout_none;
|
vgmstream->layout_type = layout_none;
|
||||||
|
|
||||||
if ( !vgmstream_open_stream(vgmstream, streamFile, start_offset) )
|
if ( !vgmstream_open_stream(vgmstream, sf, start_offset) )
|
||||||
goto fail;
|
goto fail;
|
||||||
return vgmstream;
|
return vgmstream;
|
||||||
|
|
||||||
fail:
|
fail:
|
||||||
close_vgmstream(vgmstream);
|
close_vgmstream(vgmstream);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -1,82 +1,82 @@
|
|||||||
#ifndef _BAR_STREAMFILE_H_
|
#ifndef _BAR_STREAMFILE_H_
|
||||||
#define _BAR_STREAMFILE_H_
|
#define _BAR_STREAMFILE_H_
|
||||||
#include "../streamfile.h"
|
#include "../streamfile.h"
|
||||||
|
|
||||||
/* a streamfile wrapping another for decryption */
|
/* a streamfile wrapping another for decryption */
|
||||||
|
|
||||||
enum {BAR_KEY_LENGTH = 16};
|
enum {BAR_KEY_LENGTH = 16};
|
||||||
|
|
||||||
// don't know if this is unique, but seems accurate
|
// don't know if this is unique, but seems accurate
|
||||||
static const uint8_t bar_key[BAR_KEY_LENGTH] = {
|
static const uint8_t bar_key[BAR_KEY_LENGTH] = {
|
||||||
0xbd,0x14,0x0e,0x0a,0x91,0xeb,0xaa,0xf6,
|
0xbd,0x14,0x0e,0x0a,0x91,0xeb,0xaa,0xf6,
|
||||||
0x11,0x44,0x17,0xc2,0x1c,0xe4,0x66,0x80
|
0x11,0x44,0x17,0xc2,0x1c,0xe4,0x66,0x80
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct _BARSTREAMFILE {
|
typedef struct _BARSTREAMFILE {
|
||||||
STREAMFILE sf;
|
STREAMFILE sf;
|
||||||
STREAMFILE *real_file;
|
STREAMFILE *real_file;
|
||||||
} BARSTREAMFILE;
|
} BARSTREAMFILE;
|
||||||
|
|
||||||
|
|
||||||
/*static*/ STREAMFILE *wrap_bar_STREAMFILE(STREAMFILE *file);
|
/*static*/ STREAMFILE *wrap_bar_STREAMFILE(STREAMFILE *file);
|
||||||
|
|
||||||
|
|
||||||
static size_t read_bar(BARSTREAMFILE *streamFile, uint8_t *dest, off_t offset, size_t length) {
|
static size_t read_bar(BARSTREAMFILE *streamFile, uint8_t *dest, off_t offset, size_t length) {
|
||||||
off_t i;
|
off_t i;
|
||||||
size_t read_length = streamFile->real_file->read(streamFile->real_file, dest, offset, length);
|
size_t read_length = streamFile->real_file->read(streamFile->real_file, dest, offset, length);
|
||||||
|
|
||||||
for (i = 0; i < read_length; i++) {
|
for (i = 0; i < read_length; i++) {
|
||||||
dest[i] = dest[i] ^ bar_key[(i+offset)%BAR_KEY_LENGTH];
|
dest[i] = dest[i] ^ bar_key[(i+offset)%BAR_KEY_LENGTH];
|
||||||
}
|
}
|
||||||
|
|
||||||
return read_length;
|
return read_length;
|
||||||
}
|
}
|
||||||
|
|
||||||
static size_t get_size_bar(BARSTREAMFILE *streamFile) {
|
static size_t get_size_bar(BARSTREAMFILE *streamFile) {
|
||||||
return streamFile->real_file->get_size(streamFile->real_file);
|
return streamFile->real_file->get_size(streamFile->real_file);
|
||||||
}
|
}
|
||||||
|
|
||||||
static size_t get_offset_bar(BARSTREAMFILE *streamFile) {
|
static size_t get_offset_bar(BARSTREAMFILE *streamFile) {
|
||||||
return streamFile->real_file->get_offset(streamFile->real_file);
|
return streamFile->real_file->get_offset(streamFile->real_file);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void get_name_bar(BARSTREAMFILE *streamFile, char *name, size_t length) {
|
static void get_name_bar(BARSTREAMFILE *streamFile, char *name, size_t length) {
|
||||||
streamFile->real_file->get_name(streamFile->real_file, name, 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);
|
STREAMFILE *newfile = streamFile->real_file->open(streamFile->real_file,filename,buffersize);
|
||||||
if (!newfile)
|
if (!newfile)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
return wrap_bar_STREAMFILE(newfile);
|
return wrap_bar_STREAMFILE(newfile);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void close_bar(BARSTREAMFILE *streamFile) {
|
static void close_bar(BARSTREAMFILE *streamFile) {
|
||||||
streamFile->real_file->close(streamFile->real_file);
|
streamFile->real_file->close(streamFile->real_file);
|
||||||
free(streamFile);
|
free(streamFile);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*static*/ STREAMFILE *wrap_bar_STREAMFILE(STREAMFILE *file) {
|
/*static*/ STREAMFILE *wrap_bar_STREAMFILE(STREAMFILE *file) {
|
||||||
BARSTREAMFILE *streamfile = malloc(sizeof(BARSTREAMFILE));
|
BARSTREAMFILE *streamfile = malloc(sizeof(BARSTREAMFILE));
|
||||||
|
|
||||||
if (!streamfile)
|
if (!streamfile)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
memset(streamfile, 0, sizeof(BARSTREAMFILE));
|
memset(streamfile, 0, sizeof(BARSTREAMFILE));
|
||||||
|
|
||||||
streamfile->sf.read = (void*)read_bar;
|
streamfile->sf.read = (void*)read_bar;
|
||||||
streamfile->sf.get_size = (void*)get_size_bar;
|
streamfile->sf.get_size = (void*)get_size_bar;
|
||||||
streamfile->sf.get_offset = (void*)get_offset_bar;
|
streamfile->sf.get_offset = (void*)get_offset_bar;
|
||||||
streamfile->sf.get_name = (void*)get_name_bar;
|
streamfile->sf.get_name = (void*)get_name_bar;
|
||||||
streamfile->sf.open = (void*)open_bar;
|
streamfile->sf.open = (void*)open_bar;
|
||||||
streamfile->sf.close = (void*)close_bar;
|
streamfile->sf.close = (void*)close_bar;
|
||||||
|
|
||||||
streamfile->real_file = file;
|
streamfile->real_file = file;
|
||||||
|
|
||||||
return &streamfile->sf;
|
return &streamfile->sf;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* _BAR_STREAMFILE_H_ */
|
#endif /* _BAR_STREAMFILE_H_ */
|
||||||
|
@ -1,56 +1,56 @@
|
|||||||
#include "meta.h"
|
#include "meta.h"
|
||||||
#include "../layout/layout.h"
|
#include "../layout/layout.h"
|
||||||
#include "../coding/coding.h"
|
#include "../coding/coding.h"
|
||||||
|
|
||||||
/* .vs/STRx - from The Bouncer (PS2) */
|
/* .vs/STRx - from The Bouncer (PS2) */
|
||||||
VGMSTREAM * init_vgmstream_vs_str(STREAMFILE *streamFile) {
|
VGMSTREAM* init_vgmstream_vs_str(STREAMFILE* sf) {
|
||||||
VGMSTREAM * vgmstream = NULL;
|
VGMSTREAM * vgmstream = NULL;
|
||||||
int channel_count, loop_flag;
|
int channel_count, loop_flag;
|
||||||
off_t start_offset;
|
off_t start_offset;
|
||||||
|
|
||||||
|
|
||||||
/* checks */
|
/* checks */
|
||||||
/* .vs: real extension (from .nam container)
|
/* .vs: real extension (from .nam container)
|
||||||
* .str: fake, partial header id */
|
* .str: fake, partial header id */
|
||||||
if (!check_extensions(streamFile, "vs,str"))
|
if (!check_extensions(sf, "vs,str"))
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
if (!(read_32bitBE(0x000,streamFile) == 0x5354524C && /* "STRL" */
|
if (!(read_32bitBE(0x000,sf) == 0x5354524C && /* "STRL" */
|
||||||
read_32bitBE(0x800,streamFile) == 0x53545252) && /* "STRR" */
|
read_32bitBE(0x800,sf) == 0x53545252) && /* "STRR" */
|
||||||
read_32bitBE(0x00,streamFile) != 0x5354524D) /* "STRM" */
|
read_32bitBE(0x00,sf) != 0x5354524D) /* "STRM" */
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
|
|
||||||
loop_flag = 0;
|
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;
|
start_offset = 0x00;
|
||||||
|
|
||||||
/* build the VGMSTREAM */
|
/* build the VGMSTREAM */
|
||||||
vgmstream = allocate_vgmstream(channel_count,loop_flag);
|
vgmstream = allocate_vgmstream(channel_count,loop_flag);
|
||||||
if (!vgmstream) goto fail;
|
if (!vgmstream) goto fail;
|
||||||
|
|
||||||
vgmstream->meta_type = meta_VS_STR;
|
vgmstream->meta_type = meta_VS_STR;
|
||||||
vgmstream->sample_rate = 44100;
|
vgmstream->sample_rate = 44100;
|
||||||
vgmstream->coding_type = coding_PSX;
|
vgmstream->coding_type = coding_PSX;
|
||||||
vgmstream->layout_type = layout_blocked_vs_str;
|
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;
|
goto fail;
|
||||||
|
|
||||||
/* calc num_samples */
|
/* calc num_samples */
|
||||||
{
|
{
|
||||||
vgmstream->next_block_offset = start_offset;
|
vgmstream->next_block_offset = start_offset;
|
||||||
do {
|
do {
|
||||||
block_update(vgmstream->next_block_offset,vgmstream);
|
block_update(vgmstream->next_block_offset,vgmstream);
|
||||||
vgmstream->num_samples += ps_bytes_to_samples(vgmstream->current_block_size, 1);
|
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);
|
block_update(start_offset, vgmstream);
|
||||||
}
|
}
|
||||||
|
|
||||||
return vgmstream;
|
return vgmstream;
|
||||||
|
|
||||||
fail:
|
fail:
|
||||||
close_vgmstream(vgmstream);
|
close_vgmstream(vgmstream);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -1,138 +1,135 @@
|
|||||||
#include "meta.h"
|
#include "meta.h"
|
||||||
#include "../coding/coding.h"
|
#include "../coding/coding.h"
|
||||||
|
|
||||||
/* WBAT - Firebrand Games header [Need for Speed: The Run (3DS), Fast & Furious: Showdown (3DS)] */
|
/* 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;
|
VGMSTREAM * vgmstream = NULL;
|
||||||
off_t start_offset, name_offset, offset, stream_offset;
|
off_t start_offset, name_offset, offset, stream_offset;
|
||||||
size_t names_size, stream_size;
|
size_t names_size, stream_size;
|
||||||
int loop_flag, channel_count, sample_rate, num_samples;
|
int loop_flag, channel_count, sample_rate, num_samples;
|
||||||
int big_endian, version, codec;
|
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;
|
int32_t (*read_32bit)(off_t,STREAMFILE*) = NULL;
|
||||||
int16_t (*read_16bit)(off_t,STREAMFILE*) = NULL;
|
int16_t (*read_16bit)(off_t,STREAMFILE*) = NULL;
|
||||||
|
|
||||||
|
|
||||||
/* checks */
|
/* checks */
|
||||||
if (!check_extensions(streamFile, "wavebatch"))
|
if (!check_extensions(sf, "wavebatch"))
|
||||||
goto fail;
|
goto fail;
|
||||||
if (read_32bitBE(0x00,streamFile) != 0x54414257) /* "TABW" */
|
if (!is_id32be(0x00,sf, "TABW"))
|
||||||
goto fail;
|
goto fail;
|
||||||
|
|
||||||
/* section0: base header */
|
/* 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) {
|
if (big_endian) {
|
||||||
read_32bit = read_32bitBE;
|
read_32bit = read_32bitBE;
|
||||||
read_16bit = read_16bitBE;
|
read_16bit = read_16bitBE;
|
||||||
} else {
|
} else {
|
||||||
read_32bit = read_32bitLE;
|
read_32bit = read_32bitLE;
|
||||||
read_16bit = read_16bitLE;
|
read_16bit = read_16bitLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
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 */
|
if (version != 0x06 && version != 0x07) /* v6 = NFS: The Run , v7 = F&F Showndown */
|
||||||
goto fail;
|
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 = 1;
|
||||||
if (target_subsong < 0 || target_subsong > total_subsongs || total_subsongs < 1) goto fail;
|
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 */
|
/* 0x10/14: see below */
|
||||||
/* 0x18: data size (all subsongs) */
|
/* 0x18: data size (all subsongs) */
|
||||||
offset = 0x1c + names_size; /* skip names table */
|
offset = 0x1c + names_size; /* skip names table */
|
||||||
|
|
||||||
/* the following 2 sections (rarely) won't match total_subsongs */
|
/* the following 2 sections (rarely) won't match total_subsongs */
|
||||||
|
|
||||||
/* section1: unknown */
|
/* section1: unknown */
|
||||||
{
|
{
|
||||||
size_t unknown_size = read_32bit(0x10,streamFile);
|
size_t unknown_size = read_32bit(0x10,sf);
|
||||||
/* 0x00: usually 0, rarely 0x20? */
|
/* 0x00: usually 0, rarely 0x20? */
|
||||||
offset += unknown_size*0x04;
|
offset += unknown_size*0x04;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* section2: samples */
|
/* section2: samples */
|
||||||
{
|
{
|
||||||
size_t samples_size = read_32bit(0x14,streamFile);
|
size_t samples_size = read_32bit(0x14,sf);
|
||||||
/* 0x00: num_samples */
|
/* 0x00: num_samples */
|
||||||
offset += samples_size*0x04;
|
offset += samples_size*0x04;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* section3: headers */
|
/* section3: headers */
|
||||||
{
|
{
|
||||||
off_t header_offset = offset+(target_subsong-1)*0x24;
|
off_t header_offset = offset+(target_subsong-1)*0x24;
|
||||||
|
|
||||||
name_offset = read_32bit(header_offset+0x00, streamFile) + 0x1c; /* within name table */
|
name_offset = read_32bit(header_offset+0x00, sf) + 0x1c; /* within name table */
|
||||||
codec = read_32bit(header_offset+0x04, streamFile);
|
codec = read_32bit(header_offset+0x04, sf);
|
||||||
sample_rate = read_32bit(header_offset+0x08, streamFile);
|
sample_rate = read_32bit(header_offset+0x08, sf);
|
||||||
channel_count = read_32bit(header_offset+0x0c, streamFile);
|
channel_count = read_32bit(header_offset+0x0c, sf);
|
||||||
/* 0x10: index within section1/2? */
|
/* 0x10: index within section1/2? */
|
||||||
/* 0x14: flags? 0x01 or (rarely) 0x02 */
|
/* 0x14: flags? 0x01 or (rarely) 0x02 */
|
||||||
stream_offset = read_32bit(header_offset+0x18, streamFile);
|
stream_offset = read_32bit(header_offset+0x18, sf);
|
||||||
stream_size = read_32bit(header_offset+0x1c, streamFile); /* including DSP config */
|
stream_size = read_32bit(header_offset+0x1c, sf); /* including DSP config */
|
||||||
num_samples = read_32bit(header_offset+0x20, streamFile) / channel_count; /* nibble/PCMs */
|
num_samples = read_32bit(header_offset+0x20, sf) / channel_count; /* nibble/PCMs */
|
||||||
|
|
||||||
offset += total_subsongs*0x24;
|
offset += total_subsongs*0x24;
|
||||||
}
|
}
|
||||||
|
|
||||||
loop_flag = 0;
|
loop_flag = 0;
|
||||||
start_offset = offset + stream_offset;
|
start_offset = offset + stream_offset;
|
||||||
|
|
||||||
|
|
||||||
/* build the VGMSTREAM */
|
/* build the VGMSTREAM */
|
||||||
vgmstream = allocate_vgmstream(channel_count, loop_flag);
|
vgmstream = allocate_vgmstream(channel_count, loop_flag);
|
||||||
if (!vgmstream) goto fail;
|
if (!vgmstream) goto fail;
|
||||||
|
|
||||||
vgmstream->sample_rate = sample_rate;
|
vgmstream->sample_rate = sample_rate;
|
||||||
vgmstream->num_samples = num_samples;
|
vgmstream->num_samples = num_samples;
|
||||||
vgmstream->num_streams = total_subsongs;
|
vgmstream->num_streams = total_subsongs;
|
||||||
vgmstream->stream_size = stream_size;
|
vgmstream->stream_size = stream_size;
|
||||||
|
|
||||||
vgmstream->meta_type = meta_WAVEBATCH;
|
vgmstream->meta_type = meta_WAVEBATCH;
|
||||||
|
|
||||||
switch(codec) {
|
switch(codec) {
|
||||||
case 0x00: /* PCM16 [NASCAR Unleashed (3DS), Solar Flux Pocket (Android)] */
|
case 0x00: /* PCM16 [NASCAR Unleashed (3DS), Solar Flux Pocket (Android)] */
|
||||||
vgmstream->coding_type = big_endian ? coding_PCM16BE : coding_PCM16LE;
|
vgmstream->coding_type = big_endian ? coding_PCM16BE : coding_PCM16LE;
|
||||||
vgmstream->layout_type = layout_interleave;
|
vgmstream->layout_type = layout_interleave;
|
||||||
vgmstream->interleave_block_size = 0x02;
|
vgmstream->interleave_block_size = 0x02;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 0x01: /* PCM8 [Cars 2 (3DS)] */
|
case 0x01: /* PCM8 [Cars 2 (3DS)] */
|
||||||
vgmstream->coding_type = coding_PCM8;
|
vgmstream->coding_type = coding_PCM8;
|
||||||
vgmstream->layout_type = layout_interleave;
|
vgmstream->layout_type = layout_interleave;
|
||||||
vgmstream->interleave_block_size = 0x01;
|
vgmstream->interleave_block_size = 0x01;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 0x02: { /* DSP [WRC FIA World Rally Championship (3DS)] */
|
case 0x02: { /* DSP [WRC FIA World Rally Championship (3DS)] */
|
||||||
size_t config_size = (0x20+0x14)*channel_count + (0x0c)*channel_count; /* coefs+hist + padding */
|
size_t config_size = (0x20+0x14)*channel_count + (0x0c)*channel_count; /* coefs+hist + padding */
|
||||||
|
|
||||||
vgmstream->coding_type = coding_NGC_DSP;
|
vgmstream->coding_type = coding_NGC_DSP;
|
||||||
vgmstream->layout_type = layout_interleave;
|
vgmstream->layout_type = layout_interleave;
|
||||||
vgmstream->interleave_block_size = (stream_size - config_size) / channel_count; /* full 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_coefs(vgmstream,sf,start_offset+0x00,0x20+0x14,big_endian);
|
||||||
dsp_read_hist (vgmstream,streamFile,start_offset+0x20,0x14+0x20,big_endian);
|
dsp_read_hist (vgmstream,sf,start_offset+0x20,0x14+0x20,big_endian);
|
||||||
start_offset += config_size;
|
start_offset += config_size;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
VGM_LOG("WAVEBATCH: unknown codec %x\n", codec);
|
VGM_LOG("WAVEBATCH: unknown codec %x\n", codec);
|
||||||
goto fail;
|
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, sf, start_offset))
|
||||||
|
goto fail;
|
||||||
|
return vgmstream;
|
||||||
if (!vgmstream_open_stream(vgmstream,streamFile,start_offset))
|
|
||||||
goto fail;
|
fail:
|
||||||
return vgmstream;
|
close_vgmstream(vgmstream);
|
||||||
|
return NULL;
|
||||||
fail:
|
}
|
||||||
close_vgmstream(vgmstream);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user