Added support for Xenoblade Chronicles 3D adx

This commit is contained in:
Joseph Gibbs 2015-05-16 15:30:15 -07:00
parent 4aec20fe21
commit 51dfc3339a
6 changed files with 194 additions and 152 deletions

View File

@ -16,7 +16,7 @@ VGMSTREAM * init_vgmstream_adx(STREAMFILE *streamFile) {
off_t stream_offset;
uint16_t version_signature;
int loop_flag=0;
int channel_count;
int channel_count, i, j, channel_header_spacing;
int32_t loop_start_sample=0;
int32_t loop_end_sample=0;
meta_t header_type;
@ -25,14 +25,27 @@ VGMSTREAM * init_vgmstream_adx(STREAMFILE *streamFile) {
char filename[PATH_LIMIT];
int coding_type = coding_CRI_ADX;
uint16_t xor_start=0,xor_mult=0,xor_add=0;
/* Xenoblade Chronicles 3D uses an adx extension as with
the Wii version, but it's actually DSP ADPCM. Adding
this flag to account for it. */
int xb3d_flag = 0;
/* check extension, case insensitive */
streamFile->get_name(streamFile,filename,sizeof(filename));
if (strcasecmp("adx",filename_extension(filename))) goto fail;
/* check first 2 bytes */
if ((uint16_t)read_16bitBE(0,streamFile)!=0x8000) goto fail;
if ((uint16_t)read_16bitBE(0,streamFile)!=0x8000) {
if (read_8bit(0,streamFile)!=2)goto fail;
else {xb3d_flag = 1; coding_type = coding_NGC_DSP;}
}
if (xb3d_flag) {
channel_count = read_32bitLE(0, streamFile);
loop_flag = read_16bitLE(0x6e, streamFile);
channel_header_spacing = 0x34;
}
else {
/* get stream offset, check for CRI signature just before */
stream_offset = (uint16_t)read_16bitBE(2,streamFile) + 4;
if ((uint16_t)read_16bitBE(stream_offset-6,streamFile)!=0x2863 ||/* "(c" */
@ -111,10 +124,35 @@ VGMSTREAM * init_vgmstream_adx(STREAMFILE *streamFile) {
}
channel_count = read_8bit(7,streamFile);
}
vgmstream = allocate_vgmstream(channel_count,loop_flag);
if (!vgmstream) goto fail;
/* fill in the vital statistics */
if (xb3d_flag) {
for (j=0;j<vgmstream->channels;j++) {
for (i=0;i<16;i++) {
vgmstream->ch[j].adpcm_coef[i]=read_16bitLE(4+j*channel_header_spacing+i*2,streamFile);
}
}
vgmstream->layout_type = layout_none;
vgmstream->coding_type = coding_type;
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);
for (i = 0; i<channel_count; i++) {
vgmstream->ch[i].streamfile = streamFile->open(streamFile, filename, 0x1000);
vgmstream->ch[i].channel_start_offset = vgmstream->ch[i].offset
= read_32bitLE(0x34+i*channel_header_spacing, streamFile);
if (!vgmstream->ch[i].streamfile) goto fail;
}
}
else {
vgmstream->num_samples = read_32bitBE(0xc,streamFile);
vgmstream->sample_rate = read_32bitBE(8,streamFile);
/* channels and loop flag are set by allocate_vgmstream */
@ -129,7 +167,6 @@ VGMSTREAM * init_vgmstream_adx(STREAMFILE *streamFile) {
vgmstream->meta_type = header_type;
vgmstream->interleave_block_size=18;
/* calculate filter coefficients */
{
double x,y,z,a,b,c;
@ -178,7 +215,7 @@ VGMSTREAM * init_vgmstream_adx(STREAMFILE *streamFile) {
}
}
}
}
return vgmstream;
/* clean up anything we may have opened */

View File

@ -3148,6 +3148,9 @@ void describe_vgmstream(VGMSTREAM * vgmstream, char * desc, int length) {
case meta_MCA:
snprintf(temp,TEMPSIZE,"Capcom MCA Header");
break;
case meta_XB3D_ADX:
snprintf(temp, TEMPSIZE,"Xenoblade 3D ADX Header");
break;
default:
snprintf(temp,TEMPSIZE,"THEY SHOULD HAVE SENT A POET");
}

View File

@ -580,6 +580,7 @@ typedef enum {
meta_3DS_IDSP, // Nintendo 3DS IDSP
meta_G1L, // Tecmo Koei G1L
meta_MCA, // Capcom MCA "MADP"
meta_XB3D_ADX, // Xenoblade Chronicles 3D ADX
#ifdef VGM_USE_MP4V2
meta_MP4,
#endif

View File

@ -1,6 +1,8 @@
export SHELL = /bin/sh
export CFLAGS=-Wall -O3 -I../ext_includes
export LDFLAGS=-L../src -L ../ext_libs -lvgmstream -lvorbisfile -lmpg123-0 -lm
export CFLAGS=-Wall -O3 -I../ext_includes -DUSE_ALLOCA -DVGM_USE_MAIATRAC3PLUS
# -DVGM_USE_G7221 -DVGM_USE_G719
export LDFLAGS=-L../src -L ../ext_libs -lvgmstream -lvorbisfile -lmpg123 -lat3plusdecoder -lpthread -lm
#-lg719_decode -lg7221_decode -lsiren_decode
export CC=gcc
export AR=ar
export STRIP=strip
@ -8,8 +10,8 @@ export STRIP=strip
.PHONY: libvgmstream.a
test.exe: libvgmstream.a
$(CC) $(CFLAGS) $(LDFLAGS) "-DVERSION=\"`../version.sh`\"" test.c $(LDFLAGS) -o test
$(STRIP) test
$(CC) $(CFLAGS) $(LDFLAGS) "-DVERSION=\"`../version.sh`\"" test.c $(LDFLAGS) -o vgmstream
$(STRIP) vgmstream
libvgmstream.a:
$(MAKE) -C ../src $@

View File

@ -35,7 +35,6 @@ void usage(const char * name) {
" -r outfile2.wav: output a second time after resetting\n"
" -2 N: only output the Nth (first is 0) set of stereo channels\n"
,name);
}
int main(int argc, char ** argv) {

View File

@ -35,7 +35,7 @@ libg7221_decode.a:
libg719_decode.a:
$(MAKE) -C ../ext_libs -f Makefile.mingw $@
at3plusdecoder.a:
libat3plusdecoder.a:
$(MAKE) -C ../ext_libs -f Makefile.mingw $@
clean: