mirror of
https://github.com/vgmstream/vgmstream.git
synced 2024-11-28 00:20:47 +01:00
Simplify last block interleave
Remove layout_interleave_shortblock for clarity as the value is enough to signal its use. Also fix .snd last block calculation, and clean some metas since I was testing changes anyway.
This commit is contained in:
parent
91e62e1a43
commit
eca9b83208
@ -552,7 +552,11 @@ static const coding_info coding_info_list[] = {
|
||||
static const layout_info layout_info_list[] = {
|
||||
{layout_none, "flat (no layout)"},
|
||||
{layout_interleave, "interleave"},
|
||||
{layout_interleave_shortblock, "interleave with short last block"},
|
||||
|
||||
{layout_segmented, "segmented"},
|
||||
{layout_aix, "AIX interleave, internally 18-byte interleaved"},
|
||||
{layout_scd_int, "SCD multistream interleave"},
|
||||
|
||||
{layout_mxch_blocked, "MxCh blocked"},
|
||||
{layout_ast_blocked, "AST blocked"},
|
||||
{layout_halpst_blocked, "HALPST blocked"},
|
||||
@ -581,9 +585,6 @@ static const layout_info layout_info_list[] = {
|
||||
{layout_blocked_rws, "blocked (RWS)"},
|
||||
{layout_blocked_hwas, "blocked (HWAS)"},
|
||||
{layout_tra_blocked, "TRA blocked"},
|
||||
{layout_aix, "AIX interleave, internally 18-byte interleaved"},
|
||||
{layout_segmented, "segmented"},
|
||||
{layout_scd_int, "SCD multistream interleave"},
|
||||
{layout_blocked_ea_sns, "blocked (EA SNS)"},
|
||||
{layout_blocked_awc, "blocked (AWC)"},
|
||||
{layout_blocked_vgs, "blocked (VGS)"},
|
||||
|
@ -10,12 +10,12 @@ void render_vgmstream_interleave(sample * buffer, int32_t sample_count, VGMSTREA
|
||||
|
||||
samples_this_block = vgmstream->interleave_block_size / frame_size * samples_per_frame;
|
||||
|
||||
if (vgmstream->layout_type == layout_interleave_shortblock &&
|
||||
if (vgmstream->interleave_last_block_size && vgmstream->channels > 1 &&
|
||||
vgmstream->current_sample - vgmstream->samples_into_block + samples_this_block> vgmstream->num_samples) {
|
||||
frame_size = get_vgmstream_shortframe_size(vgmstream);
|
||||
samples_per_frame = get_vgmstream_samples_per_shortframe(vgmstream);
|
||||
|
||||
samples_this_block = vgmstream->interleave_smallblock_size / frame_size * samples_per_frame;
|
||||
samples_this_block = vgmstream->interleave_last_block_size / frame_size * samples_per_frame;
|
||||
}
|
||||
|
||||
while (samples_written<sample_count) {
|
||||
@ -23,7 +23,7 @@ void render_vgmstream_interleave(sample * buffer, int32_t sample_count, VGMSTREA
|
||||
|
||||
if (vgmstream->loop_flag && vgmstream_do_loop(vgmstream)) {
|
||||
/* we assume that the loop is not back into a short block */
|
||||
if (vgmstream->layout_type == layout_interleave_shortblock) {
|
||||
if (vgmstream->interleave_last_block_size && vgmstream->channels > 1) {
|
||||
frame_size = get_vgmstream_frame_size(vgmstream);
|
||||
samples_per_frame = get_vgmstream_samples_per_frame(vgmstream);
|
||||
samples_this_block = vgmstream->interleave_block_size / frame_size * samples_per_frame;
|
||||
@ -45,14 +45,14 @@ void render_vgmstream_interleave(sample * buffer, int32_t sample_count, VGMSTREA
|
||||
|
||||
if (vgmstream->samples_into_block==samples_this_block) {
|
||||
int chan;
|
||||
if (vgmstream->layout_type == layout_interleave_shortblock &&
|
||||
if (vgmstream->interleave_last_block_size && vgmstream->channels > 1 &&
|
||||
vgmstream->current_sample + samples_this_block > vgmstream->num_samples) {
|
||||
frame_size = get_vgmstream_shortframe_size(vgmstream);
|
||||
samples_per_frame = get_vgmstream_samples_per_shortframe(vgmstream);
|
||||
|
||||
samples_this_block = vgmstream->interleave_smallblock_size / frame_size * samples_per_frame;
|
||||
samples_this_block = vgmstream->interleave_last_block_size / frame_size * samples_per_frame;
|
||||
for (chan=0;chan<vgmstream->channels;chan++)
|
||||
vgmstream->ch[chan].offset+=vgmstream->interleave_block_size*(vgmstream->channels-chan)+vgmstream->interleave_smallblock_size*chan;
|
||||
vgmstream->ch[chan].offset+=vgmstream->interleave_block_size*(vgmstream->channels-chan)+vgmstream->interleave_last_block_size*chan;
|
||||
} else {
|
||||
|
||||
for (chan=0;chan<vgmstream->channels;chan++)
|
||||
|
@ -112,22 +112,14 @@ VGMSTREAM * init_vgmstream_bcstm(STREAMFILE *streamFile) {
|
||||
}
|
||||
|
||||
vgmstream->coding_type = coding_type;
|
||||
if (channel_count == 1)
|
||||
vgmstream->layout_type = layout_none;
|
||||
else
|
||||
{
|
||||
if (ima)
|
||||
vgmstream->layout_type = layout_interleave;
|
||||
else
|
||||
vgmstream->layout_type = layout_interleave_shortblock;
|
||||
}
|
||||
vgmstream->layout_type = (channel_count == 1) ? layout_none : layout_interleave;
|
||||
vgmstream->meta_type = meta_CSTM;
|
||||
|
||||
if (ima)
|
||||
if (ima) {
|
||||
vgmstream->interleave_block_size = 0x200;
|
||||
else {
|
||||
} else {
|
||||
vgmstream->interleave_block_size = read_32bitLE(info_offset + 0x34, streamFile);
|
||||
vgmstream->interleave_smallblock_size = read_32bitLE(info_offset + 0x44, streamFile);
|
||||
vgmstream->interleave_last_block_size = read_32bitLE(info_offset + 0x44, streamFile);
|
||||
}
|
||||
|
||||
if (vgmstream->coding_type == coding_NGC_DSP) {
|
||||
|
@ -121,22 +121,14 @@ VGMSTREAM * init_vgmstream_bfstm(STREAMFILE *streamFile) {
|
||||
}
|
||||
|
||||
vgmstream->coding_type = coding_type;
|
||||
if (channel_count == 1)
|
||||
vgmstream->layout_type = layout_none;
|
||||
else
|
||||
{
|
||||
if (ima)
|
||||
vgmstream->layout_type = layout_interleave;
|
||||
else
|
||||
vgmstream->layout_type = layout_interleave_shortblock;
|
||||
}
|
||||
vgmstream->layout_type = (channel_count == 1) ? layout_none : layout_interleave;
|
||||
vgmstream->meta_type = meta_FSTM;
|
||||
|
||||
if (ima)
|
||||
vgmstream->interleave_block_size = 0x200;
|
||||
else {
|
||||
vgmstream->interleave_block_size = read_32bit(info_offset + 0x34, streamFile);
|
||||
vgmstream->interleave_smallblock_size = read_32bit(info_offset + 0x44, streamFile);
|
||||
vgmstream->interleave_last_block_size = read_32bit(info_offset + 0x44, streamFile);
|
||||
}
|
||||
|
||||
if (vgmstream->coding_type == coding_NGC_DSP) {
|
||||
|
@ -123,15 +123,10 @@ VGMSTREAM * init_vgmstream_bfwav(STREAMFILE *streamFile) {
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i<channel_count; i++) {
|
||||
if (vgmstream->layout_type == layout_interleave_shortblock)
|
||||
vgmstream->ch[i].streamfile = streamFile->open(streamFile, filename,
|
||||
vgmstream->interleave_block_size);
|
||||
else if (vgmstream->layout_type == layout_interleave)
|
||||
vgmstream->ch[i].streamfile = streamFile->open(streamFile, filename,
|
||||
STREAMFILE_DEFAULT_BUFFER_SIZE);
|
||||
if (vgmstream->layout_type == layout_interleave)
|
||||
vgmstream->ch[i].streamfile = streamFile->open(streamFile, filename,STREAMFILE_DEFAULT_BUFFER_SIZE);
|
||||
else
|
||||
vgmstream->ch[i].streamfile = streamFile->open(streamFile, filename,
|
||||
0x1000);
|
||||
vgmstream->ch[i].streamfile = streamFile->open(streamFile, filename,0x1000);
|
||||
|
||||
if (!vgmstream->ch[i].streamfile) goto fail;
|
||||
|
||||
|
@ -91,10 +91,7 @@ VGMSTREAM * init_vgmstream_brstm(STREAMFILE *streamFile) {
|
||||
vgmstream->loop_end_sample = vgmstream->num_samples;
|
||||
|
||||
vgmstream->coding_type = coding_type;
|
||||
if (channel_count==1)
|
||||
vgmstream->layout_type = layout_none;
|
||||
else
|
||||
vgmstream->layout_type = layout_interleave_shortblock;
|
||||
vgmstream->layout_type = (channel_count == 1) ? layout_none : layout_interleave;
|
||||
vgmstream->meta_type = meta_RSTM;
|
||||
if (atlus_shrunken_head)
|
||||
vgmstream->meta_type = meta_RSTM_shrunken;
|
||||
@ -105,7 +102,7 @@ VGMSTREAM * init_vgmstream_brstm(STREAMFILE *streamFile) {
|
||||
}
|
||||
|
||||
vgmstream->interleave_block_size = read_32bitBE(head_offset+0x38,streamFile);
|
||||
vgmstream->interleave_smallblock_size = read_32bitBE(head_offset+0x48,streamFile);
|
||||
vgmstream->interleave_last_block_size = read_32bitBE(head_offset+0x48,streamFile);
|
||||
|
||||
if (vgmstream->coding_type == coding_NGC_DSP) {
|
||||
off_t coef_offset;
|
||||
@ -139,12 +136,7 @@ VGMSTREAM * init_vgmstream_brstm(STREAMFILE *streamFile) {
|
||||
{
|
||||
int i;
|
||||
for (i=0;i<channel_count;i++) {
|
||||
if (vgmstream->layout_type==layout_interleave_shortblock)
|
||||
vgmstream->ch[i].streamfile = streamFile->open(streamFile,filename,
|
||||
vgmstream->interleave_block_size);
|
||||
else
|
||||
vgmstream->ch[i].streamfile = streamFile->open(streamFile,filename,
|
||||
0x1000);
|
||||
vgmstream->ch[i].streamfile = streamFile->open(streamFile,filename,STREAMFILE_DEFAULT_BUFFER_SIZE);
|
||||
|
||||
if (!vgmstream->ch[i].streamfile) goto fail;
|
||||
|
||||
|
@ -5,9 +5,12 @@
|
||||
VGMSTREAM * init_vgmstream_dc_idvi(STREAMFILE *streamFile) {
|
||||
VGMSTREAM * vgmstream = NULL;
|
||||
off_t start_offset;
|
||||
size_t data_size;
|
||||
int loop_flag, channel_count;
|
||||
|
||||
/* check extension (.dvi: original, .idvi: renamed to header id) */
|
||||
|
||||
/* checks*/
|
||||
/* .dvi: original, .idvi: renamed to header id */
|
||||
if ( !check_extensions(streamFile,"dvi,idvi") )
|
||||
goto fail;
|
||||
|
||||
@ -18,28 +21,24 @@ VGMSTREAM * init_vgmstream_dc_idvi(STREAMFILE *streamFile) {
|
||||
loop_flag = (read_32bitLE(0x0C,streamFile) != 0);
|
||||
channel_count = read_32bitLE(0x04,streamFile); /* always 2? */
|
||||
start_offset = 0x800;
|
||||
data_size = get_streamfile_size(streamFile) - start_offset;
|
||||
|
||||
/* build the VGMSTREAM */
|
||||
/* build the VGMSTREAM */
|
||||
vgmstream = allocate_vgmstream(channel_count,loop_flag);
|
||||
if (!vgmstream) goto fail;
|
||||
|
||||
vgmstream->channels = channel_count;
|
||||
vgmstream->channels = channel_count;
|
||||
vgmstream->sample_rate = read_32bitLE(0x08,streamFile);
|
||||
vgmstream->num_samples = ima_bytes_to_samples(get_streamfile_size(streamFile) - start_offset, channel_count);
|
||||
vgmstream->num_samples = ima_bytes_to_samples(data_size, channel_count);
|
||||
vgmstream->loop_start_sample = read_32bitLE(0x0C,streamFile);
|
||||
vgmstream->loop_end_sample = ima_bytes_to_samples(get_streamfile_size(streamFile) - start_offset, channel_count);
|
||||
vgmstream->loop_end_sample = vgmstream->num_samples;
|
||||
|
||||
vgmstream->coding_type = coding_DVI_IMA_int;
|
||||
vgmstream->meta_type = meta_DC_IDVI;
|
||||
|
||||
/* Calculating the short block... */
|
||||
if (channel_count > 1) {
|
||||
vgmstream->interleave_block_size = 0x400;
|
||||
vgmstream->interleave_smallblock_size = ((get_streamfile_size(streamFile)-start_offset)%(vgmstream->channels*vgmstream->interleave_block_size))/vgmstream->channels;
|
||||
vgmstream->layout_type = layout_interleave_shortblock;
|
||||
} else {
|
||||
vgmstream->layout_type = layout_none;
|
||||
}
|
||||
vgmstream->coding_type = coding_DVI_IMA_int;
|
||||
vgmstream->layout_type = layout_interleave;
|
||||
vgmstream->interleave_block_size = 0x400;
|
||||
if (vgmstream->interleave_block_size)
|
||||
vgmstream->interleave_last_block_size = (data_size % (vgmstream->interleave_block_size*vgmstream->channels)) / vgmstream->channels;
|
||||
|
||||
/* open the file for reading */
|
||||
if ( !vgmstream_open_stream(vgmstream, streamFile, start_offset) )
|
||||
|
126
src/meta/idsp.c
126
src/meta/idsp.c
@ -1,16 +1,16 @@
|
||||
#include "meta.h"
|
||||
#include "../util.h"
|
||||
|
||||
/* "idsp/IDSP"
|
||||
Soul Calibur Legends (Wii)
|
||||
Sky Crawlers: Innocent Aces (Wii)
|
||||
/* "idsp/IDSP"
|
||||
Soul Calibur Legends (Wii)
|
||||
Sky Crawlers: Innocent Aces (Wii)
|
||||
*/
|
||||
VGMSTREAM * init_vgmstream_idsp2(STREAMFILE *streamFile) {
|
||||
VGMSTREAM * vgmstream = NULL;
|
||||
char filename[PATH_LIMIT];
|
||||
int loop_flag;
|
||||
int channel_count;
|
||||
int i, j;
|
||||
int channel_count;
|
||||
int i, j;
|
||||
off_t start_offset;
|
||||
|
||||
/* check extension, case insensitive */
|
||||
@ -20,60 +20,53 @@ VGMSTREAM * init_vgmstream_idsp2(STREAMFILE *streamFile) {
|
||||
/* check header */
|
||||
if (read_32bitBE(0x00,streamFile) != 0x69647370 || /* "idsp" */
|
||||
read_32bitBE(0xBC,streamFile) != 0x49445350) /* IDSP */
|
||||
goto fail;
|
||||
goto fail;
|
||||
|
||||
loop_flag = read_32bitBE(0x20,streamFile);
|
||||
channel_count = read_32bitBE(0xC4,streamFile);
|
||||
|
||||
if (channel_count > 8)
|
||||
{
|
||||
goto fail;
|
||||
}
|
||||
goto fail;
|
||||
|
||||
/* build the VGMSTREAM */
|
||||
|
||||
/* build the VGMSTREAM */
|
||||
vgmstream = allocate_vgmstream(channel_count,loop_flag);
|
||||
if (!vgmstream) goto fail;
|
||||
|
||||
/* fill in the vital statistics */
|
||||
start_offset = (channel_count * 0x60) + 0x100;
|
||||
vgmstream->channels = channel_count;
|
||||
vgmstream->sample_rate = read_32bitBE(0xC8,streamFile);
|
||||
vgmstream->coding_type = coding_NGC_DSP;
|
||||
vgmstream->num_samples = (read_32bitBE(0x14,streamFile))*14/8/channel_count;
|
||||
start_offset = (channel_count * 0x60) + 0x100;
|
||||
vgmstream->sample_rate = read_32bitBE(0xC8,streamFile);
|
||||
vgmstream->coding_type = coding_NGC_DSP;
|
||||
vgmstream->num_samples = (read_32bitBE(0x14,streamFile))*14/8/channel_count;
|
||||
if (loop_flag) {
|
||||
vgmstream->loop_start_sample = (read_32bitBE(0xD0,streamFile));
|
||||
vgmstream->loop_end_sample = (read_32bitBE(0xD4,streamFile));
|
||||
}
|
||||
|
||||
if (channel_count == 1)
|
||||
{
|
||||
vgmstream->layout_type = layout_none;
|
||||
|
||||
if (channel_count == 1) {
|
||||
vgmstream->layout_type = layout_none;
|
||||
}
|
||||
else if (channel_count > 1)
|
||||
{
|
||||
if (read_32bitBE(0xD8,streamFile) == 0)
|
||||
{
|
||||
vgmstream->layout_type = layout_none;
|
||||
vgmstream->interleave_block_size = (get_streamfile_size(streamFile)-start_offset)/2;
|
||||
else if (channel_count > 1) {
|
||||
if (read_32bitBE(0xD8,streamFile) == 0) {
|
||||
vgmstream->layout_type = layout_none;
|
||||
vgmstream->interleave_block_size = (get_streamfile_size(streamFile)-start_offset)/2;
|
||||
}
|
||||
else if (read_32bitBE(0xD8,streamFile) > 0)
|
||||
{
|
||||
vgmstream->layout_type = layout_interleave;
|
||||
vgmstream->interleave_block_size = read_32bitBE(0xD8,streamFile);
|
||||
else if (read_32bitBE(0xD8,streamFile) > 0) {
|
||||
vgmstream->layout_type = layout_interleave;
|
||||
vgmstream->interleave_block_size = read_32bitBE(0xD8,streamFile);
|
||||
}
|
||||
}
|
||||
|
||||
vgmstream->meta_type = meta_IDSP;
|
||||
vgmstream->meta_type = meta_IDSP;
|
||||
|
||||
{
|
||||
if (vgmstream->coding_type == coding_NGC_DSP) {
|
||||
off_t coef_table[8] = {0x118,0x178,0x1D8,0x238,0x298,0x2F8,0x358,0x3B8};
|
||||
for (j=0;j<vgmstream->channels;j++) {
|
||||
for (i=0;i<16;i++) {
|
||||
vgmstream->ch[j].adpcm_coef[i] = read_16bitBE(coef_table[j]+i*2,streamFile);
|
||||
}
|
||||
{
|
||||
if (vgmstream->coding_type == coding_NGC_DSP) {
|
||||
off_t coef_table[8] = {0x118,0x178,0x1D8,0x238,0x298,0x2F8,0x358,0x3B8};
|
||||
for (j=0;j<vgmstream->channels;j++) {
|
||||
for (i=0;i<16;i++) {
|
||||
vgmstream->ch[j].adpcm_coef[i] = read_16bitBE(coef_table[j]+i*2,streamFile);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* open the file for reading */
|
||||
@ -121,17 +114,13 @@ VGMSTREAM * init_vgmstream_idsp3(STREAMFILE *streamFile) {
|
||||
channel_count = read_32bitBE(0x24,streamFile);
|
||||
|
||||
if (channel_count > 8)
|
||||
{
|
||||
goto fail;
|
||||
}
|
||||
goto fail;
|
||||
|
||||
/* build the VGMSTREAM */
|
||||
/* build the VGMSTREAM */
|
||||
vgmstream = allocate_vgmstream(channel_count,loop_flag);
|
||||
if (!vgmstream) goto fail;
|
||||
|
||||
/* fill in the vital statistics */
|
||||
start_offset = (channel_count*0x60)+0xC;
|
||||
vgmstream->channels = channel_count;
|
||||
vgmstream->sample_rate = read_32bitBE(0x14,streamFile);
|
||||
vgmstream->coding_type = coding_NGC_DSP;
|
||||
vgmstream->num_samples = read_32bitBE(0x0C,streamFile);
|
||||
@ -141,9 +130,9 @@ VGMSTREAM * init_vgmstream_idsp3(STREAMFILE *streamFile) {
|
||||
}
|
||||
|
||||
vgmstream->interleave_block_size = read_32bitBE(0x04,streamFile);
|
||||
vgmstream->interleave_smallblock_size = ((vgmstream->num_samples/7*8)%(vgmstream->interleave_block_size)/vgmstream->channels);
|
||||
vgmstream->layout_type = layout_interleave_shortblock;
|
||||
|
||||
vgmstream->interleave_last_block_size = ((vgmstream->num_samples/7*8)%(vgmstream->interleave_block_size)/vgmstream->channels);
|
||||
vgmstream->layout_type = layout_interleave;
|
||||
|
||||
vgmstream->meta_type = meta_IDSP;
|
||||
|
||||
if (vgmstream->coding_type == coding_NGC_DSP) {
|
||||
@ -170,7 +159,6 @@ VGMSTREAM * init_vgmstream_idsp3(STREAMFILE *streamFile) {
|
||||
vgmstream->ch[i].channel_start_offset=
|
||||
vgmstream->ch[i].offset=start_offset+
|
||||
vgmstream->interleave_block_size*i;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -187,7 +175,7 @@ VGMSTREAM * init_vgmstream_idsp4(STREAMFILE *streamFile) {
|
||||
VGMSTREAM * vgmstream = NULL;
|
||||
char filename[PATH_LIMIT];
|
||||
int loop_flag = 0;
|
||||
int channel_count;
|
||||
int channel_count;
|
||||
off_t start_offset;
|
||||
|
||||
/* check extension, case insensitive */
|
||||
@ -201,17 +189,13 @@ VGMSTREAM * init_vgmstream_idsp4(STREAMFILE *streamFile) {
|
||||
channel_count = read_32bitBE(0x0C,streamFile);
|
||||
|
||||
if (channel_count > 2) // Refuse everything else for now
|
||||
{
|
||||
goto fail;
|
||||
}
|
||||
goto fail;
|
||||
|
||||
/* build the VGMSTREAM */
|
||||
/* build the VGMSTREAM */
|
||||
vgmstream = allocate_vgmstream(channel_count,loop_flag);
|
||||
if (!vgmstream) goto fail;
|
||||
|
||||
/* fill in the vital statistics */
|
||||
start_offset = 0x70;
|
||||
vgmstream->channels = channel_count;
|
||||
vgmstream->sample_rate = read_32bitBE(0x08,streamFile);
|
||||
vgmstream->coding_type = coding_NGC_DSP;
|
||||
vgmstream->num_samples = read_32bitBE(0x04,streamFile)/channel_count/8*14;
|
||||
@ -220,27 +204,25 @@ VGMSTREAM * init_vgmstream_idsp4(STREAMFILE *streamFile) {
|
||||
vgmstream->loop_end_sample = read_32bitBE(0x04,streamFile)/channel_count/8*14;
|
||||
}
|
||||
|
||||
if (channel_count == 1)
|
||||
{
|
||||
vgmstream->layout_type = layout_none;
|
||||
if (channel_count == 1) {
|
||||
vgmstream->layout_type = layout_none;
|
||||
}
|
||||
else
|
||||
{
|
||||
vgmstream->layout_type = layout_interleave;
|
||||
vgmstream->interleave_block_size = read_32bitBE(0x10,streamFile);
|
||||
else {
|
||||
vgmstream->layout_type = layout_interleave;
|
||||
vgmstream->interleave_block_size = read_32bitBE(0x10,streamFile);
|
||||
}
|
||||
|
||||
vgmstream->meta_type = meta_IDSP;
|
||||
|
||||
{
|
||||
int i;
|
||||
for (i=0;i<16;i++)
|
||||
vgmstream->ch[0].adpcm_coef[i] = read_16bitBE(0x14+i*2,streamFile);
|
||||
if (channel_count == 2) {
|
||||
for (i=0;i<16;i++)
|
||||
vgmstream->ch[1].adpcm_coef[i] = read_16bitBE(0x42+i*2,streamFile);
|
||||
}
|
||||
}
|
||||
{
|
||||
int i;
|
||||
for (i=0;i<16;i++)
|
||||
vgmstream->ch[0].adpcm_coef[i] = read_16bitBE(0x14+i*2,streamFile);
|
||||
if (channel_count == 2) {
|
||||
for (i=0;i<16;i++)
|
||||
vgmstream->ch[1].adpcm_coef[i] = read_16bitBE(0x42+i*2,streamFile);
|
||||
}
|
||||
}
|
||||
|
||||
/* open the file for reading */
|
||||
{
|
||||
|
@ -1,88 +1,55 @@
|
||||
#include "meta.h"
|
||||
#include "../util.h"
|
||||
|
||||
/* SPSD (Guilty Gear X [NAOMI GD-ROM]) */
|
||||
/* SPSD - Naomi GD-ROM streams [Guilty Gear X (Naomi), Crazy Taxi (Naomi), Virtua Tennis 2 (Naomi)] */
|
||||
VGMSTREAM * init_vgmstream_naomi_spsd(STREAMFILE *streamFile) {
|
||||
VGMSTREAM * vgmstream = NULL;
|
||||
char filename[PATH_LIMIT];
|
||||
off_t start_offset;
|
||||
int coding;
|
||||
int loop_flag;
|
||||
int channel_count;
|
||||
size_t data_size;
|
||||
int loop_flag, channel_count;
|
||||
|
||||
/* check extension, case insensitive */
|
||||
streamFile->get_name(streamFile,filename,sizeof(filename));
|
||||
if (strcasecmp("spsd",filename_extension(filename))) goto fail;
|
||||
|
||||
/* check header */
|
||||
/* checks */
|
||||
if (!check_extensions(streamFile, "spsd"))
|
||||
goto fail;
|
||||
if (read_32bitBE(0x00,streamFile) != 0x53505344) /* "SPSD" */
|
||||
goto fail;
|
||||
|
||||
loop_flag = 0;
|
||||
channel_count = 2;
|
||||
|
||||
|
||||
start_offset = 0x40;
|
||||
data_size = get_streamfile_size(streamFile) - start_offset;
|
||||
|
||||
/* build the VGMSTREAM */
|
||||
vgmstream = allocate_vgmstream(channel_count,loop_flag);
|
||||
if (!vgmstream) goto fail;
|
||||
|
||||
/* fill in the vital statistics */
|
||||
start_offset = 0x40;
|
||||
vgmstream->channels = channel_count;
|
||||
vgmstream->sample_rate = (uint16_t)read_16bitLE(0x2A,streamFile);
|
||||
|
||||
switch (read_8bit(0x8,streamFile))
|
||||
{
|
||||
case 0x01:
|
||||
coding = coding_PCM8;
|
||||
break;
|
||||
case 0x03:
|
||||
coding = coding_AICA;
|
||||
break;
|
||||
default:
|
||||
goto fail;
|
||||
}
|
||||
|
||||
vgmstream->coding_type = coding;
|
||||
vgmstream->num_samples = read_32bitLE(0x0C,streamFile);
|
||||
|
||||
#if 0
|
||||
if (loop_flag)
|
||||
{
|
||||
vgmstream->loop_start_sample = 0;
|
||||
vgmstream->loop_end_sample = read_32bitLE(0x0C,streamFile);
|
||||
}
|
||||
#endif
|
||||
|
||||
vgmstream->interleave_block_size = 0x2000;
|
||||
if (channel_count > 1) {
|
||||
vgmstream->interleave_smallblock_size = ((get_streamfile_size(streamFile)-start_offset)%(vgmstream->channels*vgmstream->interleave_block_size))/vgmstream->channels;
|
||||
vgmstream->layout_type = layout_interleave_shortblock;
|
||||
} else {
|
||||
vgmstream->layout_type = layout_none;
|
||||
}
|
||||
|
||||
vgmstream->meta_type = meta_NAOMI_SPSD;
|
||||
|
||||
/* open the file for reading */
|
||||
{
|
||||
int i;
|
||||
STREAMFILE * file;
|
||||
file = streamFile->open(streamFile,filename,STREAMFILE_DEFAULT_BUFFER_SIZE);
|
||||
if (!file) goto fail;
|
||||
for (i=0;i<channel_count;i++) {
|
||||
vgmstream->ch[i].streamfile = file;
|
||||
|
||||
vgmstream->ch[i].channel_start_offset=
|
||||
vgmstream->ch[i].offset=start_offset+
|
||||
vgmstream->interleave_block_size*i;
|
||||
vgmstream->ch[i].adpcm_step_index = 0x7f; /* AICA */
|
||||
}
|
||||
switch (read_8bit(0x08,streamFile)) {
|
||||
case 0x01: /* [Virtua Tennis 2 (Naomi)] */
|
||||
vgmstream->coding_type = coding_PCM8;
|
||||
break;
|
||||
case 0x03:
|
||||
vgmstream->coding_type = coding_AICA;
|
||||
break;
|
||||
default:
|
||||
goto fail;
|
||||
}
|
||||
vgmstream->layout_type = layout_interleave;
|
||||
vgmstream->interleave_block_size = 0x2000;
|
||||
if (vgmstream->interleave_block_size)
|
||||
vgmstream->interleave_last_block_size = (data_size % (vgmstream->interleave_block_size*vgmstream->channels)) / vgmstream->channels;
|
||||
|
||||
|
||||
if (!vgmstream_open_stream(vgmstream,streamFile,start_offset))
|
||||
goto fail;
|
||||
return vgmstream;
|
||||
|
||||
/* clean up anything we may have opened */
|
||||
fail:
|
||||
if (vgmstream) close_vgmstream(vgmstream);
|
||||
close_vgmstream(vgmstream);
|
||||
return NULL;
|
||||
}
|
||||
|
@ -4,103 +4,66 @@
|
||||
/* STRM - common Nintendo NDS streaming format */
|
||||
VGMSTREAM * init_vgmstream_nds_strm(STREAMFILE *streamFile) {
|
||||
VGMSTREAM * vgmstream = NULL;
|
||||
char filename[PATH_LIMIT];
|
||||
|
||||
coding_t coding_type;
|
||||
|
||||
int codec_number;
|
||||
int channel_count;
|
||||
int loop_flag;
|
||||
|
||||
off_t start_offset;
|
||||
int channel_count, loop_flag, codec;
|
||||
|
||||
/* check extension, case insensitive */
|
||||
streamFile->get_name(streamFile,filename,sizeof(filename));
|
||||
if (strcasecmp("strm",filename_extension(filename))) goto fail;
|
||||
|
||||
/* check header */
|
||||
if ((uint32_t)read_32bitBE(0x00,streamFile)!=0x5354524D) /* STRM */
|
||||
goto fail;
|
||||
if ((uint32_t)read_32bitBE(0x04,streamFile)!=0xFFFE0001 && /* Old Header Check */
|
||||
((uint32_t)read_32bitBE(0x04,streamFile)!=0xFEFF0001)) /* Some newer games have a new flag */
|
||||
/* checks */
|
||||
if (!check_extensions(streamFile, "strm"))
|
||||
goto fail;
|
||||
|
||||
|
||||
|
||||
/* check for HEAD section */
|
||||
if ((uint32_t)read_32bitBE(0x10,streamFile)!=0x48454144 && /* "HEAD" */
|
||||
(uint32_t)read_32bitLE(0x14,streamFile)!=0x50) /* 0x50-sized head is all I've seen */
|
||||
if (read_32bitBE(0x00,streamFile) != 0x5354524D) /* "STRM" */
|
||||
goto fail;
|
||||
if (read_32bitBE(0x04,streamFile) != 0xFFFE0001 && /* Old Header Check */
|
||||
(read_32bitBE(0x04,streamFile) != 0xFEFF0001)) /* Some newer games have a new flag */
|
||||
goto fail;
|
||||
|
||||
/* check type details */
|
||||
codec_number = read_8bit(0x18,streamFile);
|
||||
if (read_32bitBE(0x10,streamFile) != 0x48454144 && /* "HEAD" */
|
||||
read_32bitLE(0x14,streamFile) != 0x50) /* 0x50-sized head is all I've seen */
|
||||
goto fail;
|
||||
|
||||
codec = read_8bit(0x18,streamFile);
|
||||
loop_flag = read_8bit(0x19,streamFile);
|
||||
channel_count = read_8bit(0x1a,streamFile);
|
||||
if (channel_count > 2) goto fail;
|
||||
|
||||
switch (codec_number) {
|
||||
case 0:
|
||||
coding_type = coding_PCM8;
|
||||
start_offset = read_32bitLE(0x28,streamFile);
|
||||
|
||||
|
||||
/* build the VGMSTREAM */
|
||||
vgmstream = allocate_vgmstream(channel_count,loop_flag);
|
||||
if (!vgmstream) goto fail;
|
||||
|
||||
vgmstream->sample_rate = (uint16_t)read_16bitLE(0x1c,streamFile);
|
||||
vgmstream->num_samples = read_32bitLE(0x24,streamFile);
|
||||
vgmstream->loop_start_sample = read_32bitLE(0x20,streamFile);
|
||||
vgmstream->loop_end_sample = vgmstream->num_samples;
|
||||
|
||||
vgmstream->meta_type = meta_STRM;
|
||||
|
||||
switch (codec) {
|
||||
case 0x00: /* [Bleach - Dark Souls (DS)] */
|
||||
vgmstream->coding_type = coding_PCM8;
|
||||
break;
|
||||
case 1:
|
||||
coding_type = coding_PCM16LE;
|
||||
case 0x01:
|
||||
vgmstream->coding_type = coding_PCM16LE;
|
||||
break;
|
||||
case 2:
|
||||
coding_type = coding_NDS_IMA;
|
||||
case 0x02: /* [SaGa 2 (DS)] */
|
||||
vgmstream->coding_type = coding_NDS_IMA;
|
||||
break;
|
||||
default:
|
||||
goto fail;
|
||||
}
|
||||
|
||||
/* TODO: only mono and stereo supported */
|
||||
if (channel_count < 1 || channel_count > 2) goto fail;
|
||||
|
||||
/* build the VGMSTREAM */
|
||||
|
||||
vgmstream = allocate_vgmstream(channel_count,loop_flag);
|
||||
if (!vgmstream) goto fail;
|
||||
|
||||
/* fill in the vital statistics */
|
||||
vgmstream->num_samples = read_32bitLE(0x24,streamFile);
|
||||
vgmstream->sample_rate = (uint16_t)read_16bitLE(0x1c,streamFile);
|
||||
/* channels and loop flag are set by allocate_vgmstream */
|
||||
vgmstream->loop_start_sample = read_32bitLE(0x20,streamFile);
|
||||
vgmstream->loop_end_sample = vgmstream->num_samples;
|
||||
|
||||
vgmstream->coding_type = coding_type;
|
||||
vgmstream->meta_type = meta_STRM;
|
||||
|
||||
vgmstream->layout_type = layout_interleave;
|
||||
vgmstream->interleave_block_size = read_32bitLE(0x30,streamFile);
|
||||
vgmstream->interleave_smallblock_size = read_32bitLE(0x38,streamFile);
|
||||
vgmstream->interleave_last_block_size = read_32bitLE(0x38,streamFile);
|
||||
|
||||
if (coding_type==coding_PCM8 || coding_type==coding_PCM16LE)
|
||||
vgmstream->layout_type = layout_none;
|
||||
else
|
||||
vgmstream->layout_type = layout_interleave_shortblock;
|
||||
|
||||
start_offset = read_32bitLE(0x28,streamFile);
|
||||
|
||||
/* open the file for reading by each channel */
|
||||
{
|
||||
int i;
|
||||
for (i=0;i<channel_count;i++) {
|
||||
if (vgmstream->layout_type==layout_interleave_shortblock)
|
||||
vgmstream->ch[i].streamfile = streamFile->open(streamFile,filename,
|
||||
vgmstream->interleave_block_size);
|
||||
else
|
||||
vgmstream->ch[i].streamfile = streamFile->open(streamFile,filename,
|
||||
0x1000);
|
||||
if (!vgmstream->ch[i].streamfile) goto fail;
|
||||
|
||||
vgmstream->ch[i].channel_start_offset=
|
||||
vgmstream->ch[i].offset=
|
||||
start_offset + i*vgmstream->interleave_block_size;
|
||||
}
|
||||
}
|
||||
|
||||
if (!vgmstream_open_stream(vgmstream,streamFile,start_offset))
|
||||
goto fail;
|
||||
return vgmstream;
|
||||
|
||||
/* clean up anything we may have opened */
|
||||
fail:
|
||||
if (vgmstream) close_vgmstream(vgmstream);
|
||||
close_vgmstream(vgmstream);
|
||||
return NULL;
|
||||
}
|
||||
|
@ -302,11 +302,11 @@ VGMSTREAM * init_vgmstream_ngc_mdsp_std(STREAMFILE *streamFile) {
|
||||
vgmstream->loop_end_sample = vgmstream->num_samples;
|
||||
|
||||
vgmstream->coding_type = coding_NGC_DSP;
|
||||
vgmstream->layout_type = channel_count == 1 ? layout_none : layout_interleave_shortblock;
|
||||
vgmstream->layout_type = channel_count == 1 ? layout_none : layout_interleave;
|
||||
vgmstream->meta_type = meta_DSP_STD;
|
||||
vgmstream->interleave_block_size = header.block_size * 8;
|
||||
if (vgmstream->interleave_block_size)
|
||||
vgmstream->interleave_smallblock_size = (header.nibble_count / 2 % vgmstream->interleave_block_size + 7) / 8 * 8;
|
||||
vgmstream->interleave_last_block_size = (header.nibble_count / 2 % vgmstream->interleave_block_size + 7) / 8 * 8;
|
||||
|
||||
for (i = 0; i < channel_count; i++) {
|
||||
if (read_dsp_header(&header, header_size * i, streamFile)) goto fail;
|
||||
|
@ -1,79 +1,53 @@
|
||||
#include "meta.h"
|
||||
#include "../util.h"
|
||||
|
||||
/* SND (Warriors of Might and Magic Heroes of M&M:Dragonbone Staff) */
|
||||
/* SND - Might and Magic games [Warriors of M&M (PS2), Heroes of M&M: Quest for the DragonBone Staff (PS2)] */
|
||||
VGMSTREAM * init_vgmstream_ps2_snd(STREAMFILE *streamFile) {
|
||||
VGMSTREAM * vgmstream = NULL;
|
||||
off_t start_offset;
|
||||
size_t data_size;
|
||||
int loop_flag, channel_count;
|
||||
|
||||
VGMSTREAM * vgmstream = NULL;
|
||||
char filename[PATH_LIMIT];
|
||||
off_t start_offset;
|
||||
/* checks */
|
||||
if (!check_extensions(streamFile, "snd"))
|
||||
goto fail;
|
||||
if (read_32bitBE(0x00,streamFile) != 0x53534E44) /* "SSND" */
|
||||
goto fail;
|
||||
|
||||
int loop_flag;
|
||||
int channel_count;
|
||||
start_offset = read_32bitLE(0x04,streamFile)+0x08;
|
||||
data_size = get_streamfile_size(streamFile) - start_offset;
|
||||
|
||||
/* check extension, case insensitive */
|
||||
streamFile->get_name(streamFile,filename,sizeof(filename));
|
||||
if (strcasecmp("snd",filename_extension(filename))) goto fail;
|
||||
|
||||
/* check header */
|
||||
if (read_32bitBE(0x0,streamFile) !=0x53534e44) goto fail;
|
||||
|
||||
/* Force Loop 0->end */
|
||||
loop_flag = 1;
|
||||
loop_flag = 1; /* force full Loop */
|
||||
channel_count = read_16bitLE(0x0a,streamFile);
|
||||
|
||||
|
||||
/* build the VGMSTREAM */
|
||||
vgmstream = allocate_vgmstream(channel_count,loop_flag);
|
||||
if (!vgmstream) goto fail;
|
||||
|
||||
/* fill in the vital statistics */
|
||||
start_offset = read_32bitLE(0x04,streamFile)+8;
|
||||
vgmstream->sample_rate = (uint16_t)read_16bitLE(0xe,streamFile);
|
||||
|
||||
if(read_8bit(0x08,streamFile)==1) {
|
||||
vgmstream->coding_type = coding_DVI_IMA_int;
|
||||
}
|
||||
else
|
||||
vgmstream->coding_type = coding_PCM16LE;
|
||||
|
||||
vgmstream->sample_rate = (uint16_t)read_16bitLE(0x0e,streamFile);
|
||||
vgmstream->num_samples = read_32bitLE(0x16,streamFile);
|
||||
vgmstream->loop_start_sample = 0;
|
||||
vgmstream->loop_end_sample = vgmstream->num_samples;
|
||||
|
||||
vgmstream->interleave_block_size = (uint16_t)read_16bitLE(0x12,streamFile);
|
||||
|
||||
if((get_streamfile_size(streamFile)-start_offset)%vgmstream->interleave_block_size)
|
||||
{
|
||||
/* not sure if this is right ... */
|
||||
vgmstream->layout_type = layout_interleave_shortblock;
|
||||
vgmstream->interleave_smallblock_size = ((get_streamfile_size(streamFile)-start_offset)%vgmstream->interleave_block_size)/vgmstream->channels;
|
||||
} else {
|
||||
vgmstream->layout_type = layout_interleave;
|
||||
}
|
||||
vgmstream->meta_type = meta_PS2_SND;
|
||||
|
||||
if(loop_flag) {
|
||||
vgmstream->loop_start_sample=0;
|
||||
vgmstream->loop_end_sample=vgmstream->num_samples;
|
||||
}
|
||||
if (read_8bit(0x08,streamFile)==1) {
|
||||
vgmstream->coding_type = coding_DVI_IMA_int; /* Warriors of M&M DragonBone */
|
||||
}
|
||||
else {
|
||||
vgmstream->coding_type = coding_PCM16LE; /* Heroes of M&M */
|
||||
}
|
||||
vgmstream->layout_type = layout_interleave;
|
||||
vgmstream->interleave_block_size = (uint16_t)read_16bitLE(0x12,streamFile);
|
||||
if (vgmstream->interleave_block_size)
|
||||
vgmstream->interleave_last_block_size = (data_size % (vgmstream->interleave_block_size*vgmstream->channels)) / vgmstream->channels;
|
||||
|
||||
/* open the file for reading */
|
||||
{
|
||||
int i;
|
||||
STREAMFILE * file;
|
||||
file = streamFile->open(streamFile,filename,STREAMFILE_DEFAULT_BUFFER_SIZE);
|
||||
if (!file) goto fail;
|
||||
for (i=0;i<channel_count;i++) {
|
||||
vgmstream->ch[i].streamfile = file;
|
||||
vgmstream->ch[i].channel_start_offset=
|
||||
vgmstream->ch[i].offset=start_offset+
|
||||
vgmstream->interleave_block_size*i;
|
||||
|
||||
}
|
||||
}
|
||||
if (!vgmstream_open_stream(vgmstream,streamFile,start_offset))
|
||||
goto fail;
|
||||
return vgmstream;
|
||||
|
||||
return vgmstream;
|
||||
|
||||
/* clean up anything we may have opened */
|
||||
fail:
|
||||
if (vgmstream) close_vgmstream(vgmstream);
|
||||
return NULL;
|
||||
close_vgmstream(vgmstream);
|
||||
return NULL;
|
||||
}
|
||||
|
@ -1,85 +1,53 @@
|
||||
#include "meta.h"
|
||||
#include "../util.h"
|
||||
|
||||
/* SVAG
|
||||
|
||||
PS2 SVAG format is an interleaved format found in many konami Games
|
||||
The header start with a Svag id and have the sentence :
|
||||
"ALL RIGHTS RESERVED.KONAMITYO Sound Design Dept. "
|
||||
or "ALL RIGHTS RESERVED.KCE-Tokyo Sound Design Dept. "
|
||||
|
||||
2008-05-13 - Fastelbja : First version ...
|
||||
Thx to HCS for his awesome work on shortblock interleave
|
||||
*/
|
||||
#include "../coding/coding.h"
|
||||
|
||||
/* SVAG - from Konami Tokyo games [OZ (PS2), Neo Contra (PS2)]] */
|
||||
VGMSTREAM * init_vgmstream_ps2_svag(STREAMFILE *streamFile) {
|
||||
VGMSTREAM * vgmstream = NULL;
|
||||
char filename[PATH_LIMIT];
|
||||
off_t start_offset;
|
||||
size_t data_size;
|
||||
int loop_flag, channel_count;
|
||||
|
||||
int loop_flag=0;
|
||||
int channel_count;
|
||||
int i;
|
||||
|
||||
/* check extension, case insensitive */
|
||||
streamFile->get_name(streamFile,filename,sizeof(filename));
|
||||
if (strcasecmp("svag",filename_extension(filename))) goto fail;
|
||||
|
||||
/* check SVAG Header */
|
||||
if (read_32bitBE(0x00,streamFile) != 0x53766167)
|
||||
/* checks */
|
||||
if (!check_extensions(streamFile, "svag"))
|
||||
goto fail;
|
||||
|
||||
/* check loop */
|
||||
if (read_32bitBE(0x00,streamFile) != 0x53766167) /* "Svag" */
|
||||
goto fail;
|
||||
|
||||
channel_count = read_16bitLE(0x0C,streamFile); /* always 2? ("S"tereo vag?) */
|
||||
loop_flag = (read_32bitLE(0x14,streamFile)==1);
|
||||
|
||||
channel_count=read_16bitLE(0x0C,streamFile);
|
||||
start_offset = 0x800; /* header repeated at 0x400 too */
|
||||
data_size = read_32bitLE(0x04,streamFile);
|
||||
|
||||
|
||||
/* build the VGMSTREAM */
|
||||
vgmstream = allocate_vgmstream(channel_count,loop_flag);
|
||||
if (!vgmstream) goto fail;
|
||||
|
||||
/* fill in the vital statistics */
|
||||
vgmstream->channels = read_16bitLE(0x0C,streamFile);
|
||||
vgmstream->sample_rate = read_32bitLE(0x08,streamFile);
|
||||
|
||||
/* Compression Scheme */
|
||||
vgmstream->coding_type = coding_PSX;
|
||||
vgmstream->num_samples = read_32bitLE(0x04,streamFile)/16*28/vgmstream->channels;
|
||||
|
||||
/* Get loop point values */
|
||||
vgmstream->num_samples = ps_bytes_to_samples(read_32bitLE(0x04,streamFile), vgmstream->channels);
|
||||
if(vgmstream->loop_flag) {
|
||||
vgmstream->loop_start_sample = read_32bitLE(0x18,streamFile)/16*28;
|
||||
vgmstream->loop_end_sample = read_32bitLE(0x04,streamFile)/16*28/vgmstream->channels;
|
||||
vgmstream->loop_start_sample = ps_bytes_to_samples(read_32bitLE(0x18,streamFile)*vgmstream->channels, vgmstream->channels);
|
||||
vgmstream->loop_end_sample = vgmstream->num_samples;
|
||||
}
|
||||
|
||||
vgmstream->interleave_block_size = read_32bitLE(0x10,streamFile);
|
||||
if (channel_count > 1) {
|
||||
vgmstream->interleave_smallblock_size = (read_32bitLE(0x04,streamFile)%(vgmstream->channels*vgmstream->interleave_block_size))/vgmstream->channels;
|
||||
vgmstream->layout_type = layout_interleave_shortblock;
|
||||
} else {
|
||||
vgmstream->layout_type = layout_none;
|
||||
}
|
||||
vgmstream->meta_type = meta_PS2_SVAG;
|
||||
vgmstream->coding_type = coding_PSX;
|
||||
vgmstream->layout_type = layout_interleave;
|
||||
vgmstream->interleave_block_size = read_32bitLE(0x10,streamFile);
|
||||
if (vgmstream->interleave_block_size)
|
||||
vgmstream->interleave_last_block_size = (data_size % (vgmstream->interleave_block_size*vgmstream->channels)) / vgmstream->channels;
|
||||
|
||||
/* open the file for reading by each channel */
|
||||
{
|
||||
for (i=0;i<channel_count;i++) {
|
||||
if (channel_count > 1)
|
||||
vgmstream->ch[i].streamfile = streamFile->open(streamFile,filename,vgmstream->interleave_block_size);
|
||||
else
|
||||
vgmstream->ch[i].streamfile = streamFile->open(streamFile,filename,STREAMFILE_DEFAULT_BUFFER_SIZE);
|
||||
|
||||
if (!vgmstream->ch[i].streamfile) goto fail;
|
||||
|
||||
vgmstream->ch[i].channel_start_offset=
|
||||
vgmstream->ch[i].offset=
|
||||
(off_t)(0x800+vgmstream->interleave_block_size*i);
|
||||
}
|
||||
}
|
||||
|
||||
if (!vgmstream_open_stream(vgmstream,streamFile,start_offset))
|
||||
goto fail;
|
||||
return vgmstream;
|
||||
|
||||
/* clean up anything we may have opened */
|
||||
fail:
|
||||
if (vgmstream) close_vgmstream(vgmstream);
|
||||
close_vgmstream(vgmstream);
|
||||
return NULL;
|
||||
}
|
||||
|
@ -1,77 +1,56 @@
|
||||
#include "meta.h"
|
||||
#include "../util.h"
|
||||
#include "../coding/coding.h"
|
||||
|
||||
/* RKV (from Legacy of Kain - Blood Omen 2) */
|
||||
/* RKV - from Legacy of Kain - Blood Omen 2 (PS2) */
|
||||
VGMSTREAM * init_vgmstream_ps2_rkv(STREAMFILE *streamFile) {
|
||||
VGMSTREAM * vgmstream = NULL;
|
||||
char filename[PATH_LIMIT];
|
||||
off_t start_offset=0;
|
||||
int loop_flag;
|
||||
int channel_count;
|
||||
off_t start_offset, header_offset;
|
||||
size_t data_size;
|
||||
int loop_flag, channel_count;
|
||||
|
||||
/* check extension, case insensitive */
|
||||
streamFile->get_name(streamFile,filename,sizeof(filename));
|
||||
if (strcasecmp("rkv",filename_extension(filename))) goto fail;
|
||||
|
||||
// Some RKV got info @ offset 0
|
||||
// Some other @ offset 4
|
||||
if(read_32bitLE(0,streamFile)==0)
|
||||
start_offset=4;
|
||||
/* checks */
|
||||
if (!check_extensions(streamFile, "rkv"))
|
||||
goto fail;
|
||||
|
||||
loop_flag = (read_32bitLE(start_offset+4,streamFile)!=0xFFFFFFFF);
|
||||
channel_count = read_32bitLE(start_offset+0x0c,streamFile)+1;
|
||||
|
||||
/* build the VGMSTREAM */
|
||||
/* some RKV got info at offset 0x00, some other at 0x0 4 */
|
||||
if(read_32bitLE(0x00,streamFile)==0)
|
||||
header_offset = 0x04;
|
||||
else
|
||||
header_offset = 0x00;
|
||||
start_offset = 0x800;
|
||||
data_size = get_streamfile_size(streamFile) - 0x800;
|
||||
|
||||
loop_flag = (read_32bitLE(header_offset+0x04,streamFile)!=0xFFFFFFFF);
|
||||
channel_count = read_32bitLE(header_offset+0x0c,streamFile)+1;
|
||||
|
||||
|
||||
/* build the VGMSTREAM */
|
||||
vgmstream = allocate_vgmstream(channel_count,loop_flag);
|
||||
if (!vgmstream) goto fail;
|
||||
|
||||
/* fill in the vital statistics */
|
||||
vgmstream->channels = channel_count;
|
||||
vgmstream->sample_rate = read_32bitLE(start_offset,streamFile);
|
||||
vgmstream->sample_rate = read_32bitLE(header_offset,streamFile);
|
||||
vgmstream->coding_type = coding_PSX;
|
||||
|
||||
// sometimes sample count is not set on the header
|
||||
vgmstream->num_samples = (get_streamfile_size(streamFile)-0x800)/16*28/channel_count;
|
||||
|
||||
if (loop_flag) {
|
||||
vgmstream->loop_start_sample = read_32bitLE(start_offset+4,streamFile);
|
||||
vgmstream->loop_end_sample = read_32bitLE(start_offset+8,streamFile);
|
||||
/* sometimes sample count is not set on the header */
|
||||
vgmstream->num_samples = ps_bytes_to_samples(data_size, channel_count);
|
||||
if (loop_flag) {
|
||||
vgmstream->loop_start_sample = read_32bitLE(header_offset+0x04,streamFile);
|
||||
vgmstream->loop_end_sample = read_32bitLE(header_offset+0x08,streamFile);
|
||||
}
|
||||
|
||||
start_offset = 0x800;
|
||||
vgmstream->meta_type = meta_PS2_RKV;
|
||||
vgmstream->layout_type = layout_interleave;
|
||||
vgmstream->interleave_block_size = 0x400;
|
||||
if (vgmstream->interleave_block_size)
|
||||
vgmstream->interleave_last_block_size = (data_size % (vgmstream->interleave_block_size*vgmstream->channels)) / vgmstream->channels;
|
||||
|
||||
if((get_streamfile_size(streamFile)-0x800)%0x400)
|
||||
{
|
||||
vgmstream->layout_type = layout_interleave_shortblock;
|
||||
vgmstream->interleave_smallblock_size=((get_streamfile_size(streamFile)-0x800)%0x400)/channel_count;
|
||||
} else {
|
||||
vgmstream->layout_type = layout_interleave;
|
||||
}
|
||||
|
||||
vgmstream->interleave_block_size = 0x400;
|
||||
vgmstream->meta_type = meta_PS2_RKV;
|
||||
/* open the file for reading */
|
||||
{
|
||||
int i;
|
||||
STREAMFILE * file;
|
||||
file = streamFile->open(streamFile,filename,STREAMFILE_DEFAULT_BUFFER_SIZE);
|
||||
if (!file) goto fail;
|
||||
for (i=0;i<channel_count;i++) {
|
||||
vgmstream->ch[i].streamfile = file;
|
||||
|
||||
vgmstream->ch[i].channel_start_offset=
|
||||
vgmstream->ch[i].offset=start_offset+
|
||||
vgmstream->interleave_block_size*i;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if (!vgmstream_open_stream(vgmstream,streamFile,start_offset))
|
||||
goto fail;
|
||||
return vgmstream;
|
||||
|
||||
/* clean up anything we may have opened */
|
||||
fail:
|
||||
if (vgmstream) close_vgmstream(vgmstream);
|
||||
close_vgmstream(vgmstream);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,81 +1,54 @@
|
||||
#include "meta.h"
|
||||
#include "../coding/coding.h"
|
||||
#include "../util.h"
|
||||
|
||||
/* .dsp w/ RS03 header - from Metroid Prime 2 */
|
||||
|
||||
/* RS03 - from Metroid Prime 2 (GC) */
|
||||
VGMSTREAM * init_vgmstream_rs03(STREAMFILE *streamFile) {
|
||||
VGMSTREAM * vgmstream = NULL;
|
||||
char filename[PATH_LIMIT];
|
||||
|
||||
int channel_count;
|
||||
int loop_flag;
|
||||
off_t start_offset;
|
||||
int i;
|
||||
size_t data_size;
|
||||
int channel_count, loop_flag;
|
||||
|
||||
/* check extension, case insensitive */
|
||||
streamFile->get_name(streamFile,filename,sizeof(filename));
|
||||
if (strcasecmp("dsp",filename_extension(filename))) goto fail;
|
||||
|
||||
/* check header */
|
||||
if ((uint32_t)read_32bitBE(0,streamFile)!=0x52530003) /* "RS03" */
|
||||
/* checks */
|
||||
if (!check_extensions(streamFile, "dsp"))
|
||||
goto fail;
|
||||
if (read_32bitBE(0x00,streamFile) != 0x52530003) /* "RS03" */
|
||||
goto fail;
|
||||
|
||||
channel_count = read_32bitBE(4,streamFile);
|
||||
channel_count = read_32bitBE(0x04,streamFile);
|
||||
if (channel_count != 1 && channel_count != 2) goto fail;
|
||||
|
||||
/* build the VGMSTREAM */
|
||||
|
||||
loop_flag = read_16bitBE(0x14,streamFile);
|
||||
|
||||
start_offset = 0x60;
|
||||
data_size = (get_streamfile_size(streamFile) - start_offset);
|
||||
|
||||
|
||||
/* build the VGMSTREAM */
|
||||
vgmstream = allocate_vgmstream(channel_count,loop_flag);
|
||||
if (!vgmstream) goto fail;
|
||||
|
||||
/* fill in the vital statistics */
|
||||
vgmstream->num_samples = read_32bitBE(8,streamFile);
|
||||
vgmstream->sample_rate = read_32bitBE(0xc,streamFile);
|
||||
|
||||
vgmstream->num_samples = read_32bitBE(8,streamFile);
|
||||
if (loop_flag) {
|
||||
vgmstream->loop_start_sample = read_32bitBE(0x18,streamFile)/8*14;
|
||||
vgmstream->loop_end_sample = read_32bitBE(0x1c,streamFile)/8*14;
|
||||
}
|
||||
|
||||
start_offset = 0x60;
|
||||
|
||||
vgmstream->coding_type = coding_NGC_DSP;
|
||||
if (channel_count == 2) {
|
||||
vgmstream->layout_type = layout_interleave_shortblock;
|
||||
vgmstream->interleave_block_size = 0x8f00;
|
||||
vgmstream->interleave_smallblock_size = (((get_streamfile_size(streamFile)-start_offset)%(0x8f00*2))/2+7)/8*8;
|
||||
} else
|
||||
vgmstream->layout_type = layout_none;
|
||||
vgmstream->meta_type = meta_DSP_RS03;
|
||||
vgmstream->coding_type = coding_NGC_DSP;
|
||||
vgmstream->layout_type = layout_interleave;
|
||||
vgmstream->interleave_block_size = 0x8f00;
|
||||
if (vgmstream->interleave_block_size)
|
||||
vgmstream->interleave_last_block_size = ((data_size % (vgmstream->interleave_block_size*vgmstream->channels))/2+7)/8*8;
|
||||
|
||||
for (i=0;i<16;i++)
|
||||
vgmstream->ch[0].adpcm_coef[i]=read_16bitBE(0x20+i*2,streamFile);
|
||||
if (channel_count==2) {
|
||||
for (i=0;i<16;i++)
|
||||
vgmstream->ch[1].adpcm_coef[i]=read_16bitBE(0x40+i*2,streamFile);
|
||||
}
|
||||
dsp_read_coefs_be(vgmstream,streamFile,0x20,0x20);
|
||||
|
||||
/* open the file for reading by each channel */
|
||||
{
|
||||
int i;
|
||||
for (i=0;i<channel_count;i++) {
|
||||
vgmstream->ch[i].streamfile = streamFile->open(streamFile,filename,0x8f00);
|
||||
|
||||
if (!vgmstream->ch[i].streamfile) goto fail;
|
||||
|
||||
vgmstream->ch[i].channel_start_offset=
|
||||
vgmstream->ch[i].offset=
|
||||
start_offset+0x8f00*i;
|
||||
}
|
||||
}
|
||||
|
||||
if (!vgmstream_open_stream(vgmstream,streamFile,start_offset))
|
||||
goto fail;
|
||||
return vgmstream;
|
||||
|
||||
/* clean up anything we may have opened */
|
||||
fail:
|
||||
if (vgmstream) close_vgmstream(vgmstream);
|
||||
close_vgmstream(vgmstream);
|
||||
return NULL;
|
||||
}
|
||||
|
@ -36,9 +36,9 @@ VGMSTREAM * init_vgmstream_smv(STREAMFILE *streamFile) {
|
||||
|
||||
vgmstream->meta_type = meta_SMV;
|
||||
vgmstream->coding_type = coding_PSX;
|
||||
vgmstream->layout_type = layout_interleave_shortblock;
|
||||
vgmstream->layout_type = layout_interleave;
|
||||
vgmstream->interleave_block_size = read_32bitLE(0x04, streamFile);
|
||||
vgmstream->interleave_smallblock_size = read_32bitLE(0x0c, streamFile);
|
||||
vgmstream->interleave_last_block_size = read_32bitLE(0x0c, streamFile);
|
||||
|
||||
if (!vgmstream_open_stream(vgmstream,streamFile,start_offset))
|
||||
goto fail;
|
||||
|
@ -9,12 +9,10 @@ VGMSTREAM * init_vgmstream_wii_04sw(STREAMFILE *streamFile) {
|
||||
size_t file_size, data_size;
|
||||
|
||||
|
||||
/* check extension, case insensitive */
|
||||
/* checks */
|
||||
/* ".04sw" is just the ID, the real filename inside the file uses .XA */
|
||||
if (!check_extensions(streamFile,"xa,04sw"))
|
||||
goto fail;
|
||||
|
||||
/* check header */
|
||||
if (read_32bitBE(0x00,streamFile) != 0x30345357) /* "04SW" */
|
||||
goto fail;
|
||||
|
||||
@ -39,9 +37,9 @@ VGMSTREAM * init_vgmstream_wii_04sw(STREAMFILE *streamFile) {
|
||||
vgmstream->num_samples = read_32bitBE(0x04,streamFile);
|
||||
|
||||
vgmstream->coding_type = coding_NGC_DSP;
|
||||
vgmstream->layout_type = channel_count == 1 ? layout_none : layout_interleave_shortblock;
|
||||
vgmstream->layout_type = channel_count == 1 ? layout_none : layout_interleave;
|
||||
vgmstream->interleave_block_size = 0x8000;
|
||||
vgmstream->interleave_smallblock_size = (read_32bitBE(0x08,streamFile) / 2 % vgmstream->interleave_block_size + 7) / 8 * 8;
|
||||
vgmstream->interleave_last_block_size = (read_32bitBE(0x08,streamFile) / 2 % vgmstream->interleave_block_size + 7) / 8 * 8;
|
||||
|
||||
dsp_read_coefs_be(vgmstream,streamFile,0x20, 0x60);
|
||||
/* the initial history offset seems different thatn standard DSP and possibly always zero */
|
||||
@ -50,10 +48,8 @@ VGMSTREAM * init_vgmstream_wii_04sw(STREAMFILE *streamFile) {
|
||||
/* the rest of the header has unknown values (several repeats) and the filename */
|
||||
|
||||
|
||||
/* open the file for reading */
|
||||
if (!vgmstream_open_stream(vgmstream,streamFile,start_offset))
|
||||
goto fail;
|
||||
|
||||
return vgmstream;
|
||||
|
||||
fail:
|
||||
|
@ -1,20 +1,17 @@
|
||||
#include "meta.h"
|
||||
#include "../util.h"
|
||||
#include "../coding/coding.h"
|
||||
|
||||
/* RAS (from Donkey Kong Country Returns) */
|
||||
/* RAS_ - from Donkey Kong Country Returns (Wii) */
|
||||
VGMSTREAM * init_vgmstream_wii_ras(STREAMFILE *streamFile) {
|
||||
VGMSTREAM * vgmstream = NULL;
|
||||
char filename[PATH_LIMIT];
|
||||
off_t start_offset;
|
||||
|
||||
int loop_flag;
|
||||
int channel_count;
|
||||
int loop_flag, channel_count;
|
||||
|
||||
/* check extension, case insensitive */
|
||||
streamFile->get_name(streamFile,filename,sizeof(filename));
|
||||
if (strcasecmp("ras",filename_extension(filename))) goto fail;
|
||||
/* checks */
|
||||
if (!check_extensions(streamFile, "ras"))
|
||||
goto fail;
|
||||
|
||||
/* check header */
|
||||
if (read_32bitBE(0x00,streamFile) != 0x5241535F) /* "RAS_" */
|
||||
goto fail;
|
||||
|
||||
@ -26,63 +23,32 @@ VGMSTREAM * init_vgmstream_wii_ras(STREAMFILE *streamFile) {
|
||||
loop_flag = 1;
|
||||
}
|
||||
channel_count = 2;
|
||||
start_offset = read_32bitBE(0x18,streamFile);
|
||||
|
||||
/* build the VGMSTREAM */
|
||||
/* build the VGMSTREAM */
|
||||
vgmstream = allocate_vgmstream(channel_count,loop_flag);
|
||||
if (!vgmstream) goto fail;
|
||||
|
||||
/* fill in the vital statistics */
|
||||
start_offset = read_32bitBE(0x18,streamFile);
|
||||
vgmstream->channels = channel_count;
|
||||
vgmstream->sample_rate = read_32bitBE(0x14,streamFile);
|
||||
vgmstream->coding_type = coding_NGC_DSP;
|
||||
vgmstream->num_samples = read_32bitBE(0x1c,streamFile)/channel_count/8*14;
|
||||
vgmstream->layout_type = layout_interleave;
|
||||
vgmstream->interleave_block_size = read_32bitBE(0x20,streamFile);
|
||||
vgmstream->meta_type = meta_WII_RAS;
|
||||
|
||||
if (loop_flag) {
|
||||
// loop is block + samples into block
|
||||
vgmstream->loop_start_sample =
|
||||
read_32bitBE(0x30,streamFile)*vgmstream->interleave_block_size/8*14 +
|
||||
read_32bitBE(0x34,streamFile);
|
||||
vgmstream->loop_end_sample =
|
||||
read_32bitBE(0x38,streamFile)*vgmstream->interleave_block_size/8*14 +
|
||||
read_32bitBE(0x3C,streamFile);
|
||||
vgmstream->coding_type = coding_NGC_DSP;
|
||||
vgmstream->layout_type = layout_interleave;
|
||||
vgmstream->interleave_block_size = read_32bitBE(0x20,streamFile);
|
||||
|
||||
vgmstream->num_samples = read_32bitBE(0x1c,streamFile)/channel_count/8*14;
|
||||
if (loop_flag) { /* loop is block + samples into block */
|
||||
vgmstream->loop_start_sample = read_32bitBE(0x30,streamFile)*vgmstream->interleave_block_size/8*14 +
|
||||
read_32bitBE(0x34,streamFile);
|
||||
vgmstream->loop_end_sample = read_32bitBE(0x38,streamFile)*vgmstream->interleave_block_size/8*14 +
|
||||
read_32bitBE(0x3C,streamFile);
|
||||
}
|
||||
|
||||
if (vgmstream->coding_type == coding_NGC_DSP) {
|
||||
int i;
|
||||
for (i=0;i<16;i++) {
|
||||
vgmstream->ch[0].adpcm_coef[i] = read_16bitBE(0x40+i*2,streamFile);
|
||||
}
|
||||
if (channel_count == 2) {
|
||||
for (i=0;i<16;i++)
|
||||
vgmstream->ch[1].adpcm_coef[i] = read_16bitBE(0x70+i*2,streamFile);
|
||||
}
|
||||
} else {
|
||||
dsp_read_coefs_be(vgmstream,streamFile,0x40,0x30);
|
||||
|
||||
|
||||
if (!vgmstream_open_stream(vgmstream,streamFile,start_offset))
|
||||
goto fail;
|
||||
}
|
||||
|
||||
/* open the file for reading */
|
||||
{
|
||||
int i;
|
||||
for (i=0;i<channel_count;i++) {
|
||||
if (vgmstream->layout_type==layout_interleave_shortblock)
|
||||
vgmstream->ch[i].streamfile = streamFile->open(streamFile,filename,
|
||||
vgmstream->interleave_block_size);
|
||||
else
|
||||
vgmstream->ch[i].streamfile = streamFile->open(streamFile,filename,
|
||||
0x1000);
|
||||
|
||||
if (!vgmstream->ch[i].streamfile) goto fail;
|
||||
|
||||
vgmstream->ch[i].channel_start_offset=
|
||||
vgmstream->ch[i].offset=
|
||||
start_offset + i*vgmstream->interleave_block_size;
|
||||
}
|
||||
}
|
||||
|
||||
return vgmstream;
|
||||
|
||||
/* clean up anything we may have opened */
|
||||
|
@ -887,7 +887,6 @@ void vgmstream_force_loop(VGMSTREAM* vgmstream, int loop_flag, int loop_start_sa
|
||||
void render_vgmstream(sample * buffer, int32_t sample_count, VGMSTREAM * vgmstream) {
|
||||
switch (vgmstream->layout_type) {
|
||||
case layout_interleave:
|
||||
case layout_interleave_shortblock:
|
||||
render_vgmstream_interleave(buffer,sample_count,vgmstream);
|
||||
break;
|
||||
case layout_none:
|
||||
@ -1261,7 +1260,7 @@ int get_vgmstream_frame_size(VGMSTREAM * vgmstream) {
|
||||
int get_vgmstream_samples_per_shortframe(VGMSTREAM * vgmstream) {
|
||||
switch (vgmstream->coding_type) {
|
||||
case coding_NDS_IMA:
|
||||
return (vgmstream->interleave_smallblock_size-4)*2;
|
||||
return (vgmstream->interleave_last_block_size-4)*2;
|
||||
default:
|
||||
return get_vgmstream_samples_per_frame(vgmstream);
|
||||
}
|
||||
@ -1269,7 +1268,7 @@ int get_vgmstream_samples_per_shortframe(VGMSTREAM * vgmstream) {
|
||||
int get_vgmstream_shortframe_size(VGMSTREAM * vgmstream) {
|
||||
switch (vgmstream->coding_type) {
|
||||
case coding_NDS_IMA:
|
||||
return vgmstream->interleave_smallblock_size;
|
||||
return vgmstream->interleave_last_block_size;
|
||||
default:
|
||||
return get_vgmstream_frame_size(vgmstream);
|
||||
}
|
||||
@ -2140,17 +2139,16 @@ void describe_vgmstream(VGMSTREAM * vgmstream, char * desc, int length) {
|
||||
"\n");
|
||||
concatn(length,desc,temp);
|
||||
|
||||
if (vgmstream->layout_type == layout_interleave
|
||||
|| vgmstream->layout_type == layout_interleave_shortblock) {
|
||||
if (vgmstream->layout_type == layout_interleave) {
|
||||
snprintf(temp,TEMPSIZE,
|
||||
"interleave: %#x bytes\n",
|
||||
(int32_t)vgmstream->interleave_block_size);
|
||||
concatn(length,desc,temp);
|
||||
|
||||
if (vgmstream->layout_type == layout_interleave_shortblock) {
|
||||
if (vgmstream->interleave_last_block_size) {
|
||||
snprintf(temp,TEMPSIZE,
|
||||
"last block interleave: %#x bytes\n",
|
||||
(int32_t)vgmstream->interleave_smallblock_size);
|
||||
(int32_t)vgmstream->interleave_last_block_size);
|
||||
concatn(length,desc,temp);
|
||||
}
|
||||
}
|
||||
@ -2300,7 +2298,7 @@ static void try_dual_file_stereo(VGMSTREAM * opened_vgmstream, STREAMFILE *strea
|
||||
/* check even if the layout doesn't use them, because it is
|
||||
* difficult to determine when it does, and they should be zero otherwise, anyway */
|
||||
new_vgmstream->interleave_block_size == opened_vgmstream->interleave_block_size &&
|
||||
new_vgmstream->interleave_smallblock_size == opened_vgmstream->interleave_smallblock_size)) {
|
||||
new_vgmstream->interleave_last_block_size == opened_vgmstream->interleave_last_block_size)) {
|
||||
goto fail;
|
||||
}
|
||||
|
||||
|
@ -215,7 +215,6 @@ typedef enum {
|
||||
|
||||
/* interleave */
|
||||
layout_interleave, /* equal interleave throughout the stream */
|
||||
layout_interleave_shortblock, /* interleave with a short last block */
|
||||
|
||||
/* headered blocks */
|
||||
layout_ast_blocked,
|
||||
@ -748,7 +747,7 @@ typedef struct {
|
||||
|
||||
/* layouts/block */
|
||||
size_t interleave_block_size; /* interleave, or block/frame size (depending on the codec) */
|
||||
size_t interleave_smallblock_size; /* smaller interleave for last block */
|
||||
size_t interleave_last_block_size; /* smaller interleave for last block */
|
||||
|
||||
/* channel state */
|
||||
VGMSTREAMCHANNEL * ch; /* pointer to array of channels */
|
||||
|
Loading…
Reference in New Issue
Block a user