SPD/SPT PCM coding added

git-svn-id: https://vgmstream.svn.sourceforge.net/svnroot/vgmstream@723 51a99a44-fe44-0410-b1ba-c3e57ba2b86b
This commit is contained in:
manakoAT 2010-01-10 17:29:19 +00:00
parent eef0ee10ad
commit 862b467615
2 changed files with 31 additions and 25 deletions

View File

@ -12,7 +12,6 @@ VGMSTREAM * init_vgmstream_spt_spd(STREAMFILE *streamFile) {
STREAMFILE * streamFileSPT = NULL;
char filename[260];
char filenameSPT[260];
int i;
int channel_count;
int loop_flag;
@ -41,8 +40,18 @@ VGMSTREAM * init_vgmstream_spt_spd(STREAMFILE *streamFile) {
vgmstream->channels = channel_count;
vgmstream->sample_rate = read_32bitBE(0x08,streamFileSPT);
vgmstream->num_samples=read_32bitBE(0x14,streamFileSPT)*14/16/channel_count;
vgmstream->coding_type = coding_NGC_DSP;
switch ((read_32bitBE(0x0,streamFileSPT))) {
case 1:
vgmstream->coding_type = coding_NGC_DSP;
break;
case 2:
vgmstream->coding_type = coding_PCM16BE;
break;
default:
goto fail;
}
if(loop_flag) {
vgmstream->loop_start_sample = 0;
vgmstream->loop_end_sample = read_32bitBE(0x14,streamFileSPT)*14/16/channel_count;
@ -52,7 +61,7 @@ VGMSTREAM * init_vgmstream_spt_spd(STREAMFILE *streamFile) {
vgmstream->layout_type = layout_none;
} else if (channel_count == 2) {
vgmstream->layout_type = layout_interleave;
vgmstream->interleave_block_size=0x4000; /* Unknown now, never seen 2ch files in psd+spt */
vgmstream->interleave_block_size=(read_32bitBE(0x34,streamFileSPT)*channel_count)/2;
}

View File

@ -1,6 +1,8 @@
#include "meta.h"
#include "../util.h"
/* XWB (found in King of Fighters 2003 (XBOX)) */
/* XWB - XACT Wave Bank (Main format on the XBOX console) */
VGMSTREAM * init_vgmstream_xwb(STREAMFILE *streamFile) {
VGMSTREAM * vgmstream = NULL;
char filename[260];
@ -10,28 +12,23 @@ VGMSTREAM * init_vgmstream_xwb(STREAMFILE *streamFile) {
int coding;
int coding_flag;
int num_samples;
int header_start;
/* check extension, case insensitive */
streamFile->get_name(streamFile,filename,sizeof(filename));
if (strcasecmp("xwb",filename_extension(filename))) goto fail;
/* check header */
if (read_32bitBE(0x00,streamFile) != 0x57424E44) /* WBND */
goto fail;
#if 0
if ((read_32bitBE(0x00,streamFile) != 0x57424E44) && /* WBND */
(read_32bitBE(0x00,streamFile) != 0x444E4257)) /* DNBW */
goto fail;
/* check if the file is been used as container */
if (read_32bitBE(0x2C,streamFile) != 0x01000000)
goto fail;
#endif
/* if it's looped it should be 2, didn't see anything else... */
loop_flag = (uint8_t)(read_8bit(0x50,streamFile));
if (loop_flag == 2) {
loop_flag = 1;
} else if (loop_flag < 2) {
loop_flag = 0;
}
header_start = read_32bitLE(0x10,streamFile);
loop_flag = (read_32bitLE(header_start+0x10,streamFile) != 0x0);
channel_count = 2;
/* build the VGMSTREAM */
@ -41,27 +38,27 @@ VGMSTREAM * init_vgmstream_xwb(STREAMFILE *streamFile) {
/* fill in the vital statistics */
start_offset = read_32bitLE(0x20,streamFile);
vgmstream->channels = channel_count;
vgmstream->sample_rate = 44100; /* read_32bitLE(0x08,streamFile); */
vgmstream->sample_rate = (((uint32_t)read_32bitLE(header_start+0x4, streamFile)) << 8 >> 12) / 2;
coding_flag = (uint8_t)(read_8bit(0x52,streamFile));
coding_flag = (uint16_t)(read_16bitLE(header_start+0x2,streamFile));
switch (coding_flag) {
case 0:
coding = coding_PCM16LE;
vgmstream->layout_type = layout_interleave;
vgmstream->interleave_block_size = 0x2;
num_samples = read_32bitLE(0x5C,streamFile)/2/channel_count;
num_samples = read_32bitLE(header_start+0xC,streamFile)/2/channel_count;
if (loop_flag) {
vgmstream->loop_start_sample = read_32bitLE(0x60,streamFile)/2/channel_count;
vgmstream->loop_end_sample = read_32bitLE(0x5C,streamFile)/2/channel_count;
vgmstream->loop_start_sample = read_32bitLE(header_start+10,streamFile)/2/channel_count;
vgmstream->loop_end_sample = read_32bitLE(header_start+0xC,streamFile)/2/channel_count;
}
break;
case 1:
coding = coding_XBOX;
vgmstream->layout_type = layout_none;
num_samples = read_32bitLE(0x5C,streamFile)/36/channel_count*64;
num_samples = read_32bitLE(header_start+0xC,streamFile)/36/channel_count*64;
if (loop_flag) {
vgmstream->loop_start_sample = read_32bitLE(0x60,streamFile)/36/channel_count*64;
vgmstream->loop_end_sample = read_32bitLE(0x5C,streamFile)/36/channel_count*64;
vgmstream->loop_start_sample = read_32bitLE(header_start+0x10,streamFile)/36/channel_count*64;
vgmstream->loop_end_sample = read_32bitLE(header_start+0xC,streamFile)/36/channel_count*64;
}
break;
default: