From 0b3be50b284683ff9add627d43126f3627eaccf6 Mon Sep 17 00:00:00 2001 From: manakoAT Date: Fri, 28 Nov 2008 14:27:51 +0000 Subject: [PATCH] YSDP added SPT+SPD added ISH+ISD added git-svn-id: https://vgmstream.svn.sourceforge.net/svnroot/vgmstream@492 51a99a44-fe44-0410-b1ba-c3e57ba2b86b --- src/Makefile | 5 +- src/libvgmstream.vcproj | 12 +++++ src/meta/Makefile.unix.am | 3 ++ src/meta/ish_isd.c | 98 +++++++++++++++++++++++++++++++++++++++ src/meta/meta.h | 6 +++ src/meta/spt_spd.c | 96 ++++++++++++++++++++++++++++++++++++++ src/meta/ydsp.c | 83 +++++++++++++++++++++++++++++++++ src/vgmstream.c | 12 +++++ src/vgmstream.h | 3 ++ winamp/in_vgmstream.c | 3 ++ 10 files changed, 320 insertions(+), 1 deletion(-) create mode 100644 src/meta/ish_isd.c create mode 100644 src/meta/spt_spd.c create mode 100644 src/meta/ydsp.c diff --git a/src/Makefile b/src/Makefile index 3ac62e93..6511220f 100644 --- a/src/Makefile +++ b/src/Makefile @@ -149,7 +149,10 @@ META_OBJS=meta/adx_header.o \ meta/ps2_seg.o \ meta/str_asr.o \ meta/zwdsp.o \ - meta/gca.o + meta/gca.o \ + meta/ish_isd.o \ + meta/spt_spd.o \ + meta/ydsp.o OBJECTS=vgmstream.o streamfile.o util.o $(CODING_OBJS) $(LAYOUT_OBJS) $(META_OBJS) diff --git a/src/libvgmstream.vcproj b/src/libvgmstream.vcproj index c49b3a40..c9b8cbf2 100644 --- a/src/libvgmstream.vcproj +++ b/src/libvgmstream.vcproj @@ -291,6 +291,10 @@ RelativePath=".\meta\idsp.c" > + + @@ -609,6 +613,10 @@ RelativePath=".\meta\sli.c" > + + @@ -665,6 +673,10 @@ RelativePath=".\meta\xwb.c" > + + diff --git a/src/meta/Makefile.unix.am b/src/meta/Makefile.unix.am index bee83838..c5c48c68 100644 --- a/src/meta/Makefile.unix.am +++ b/src/meta/Makefile.unix.am @@ -118,4 +118,7 @@ libmeta_la_SOURCES += ps2_seg.c libmeta_la_SOURCES += str_asr.c libmeta_la_SOURCES += zwdsp.c libmeta_la_SOURCES += gca.c +libmeta_la_SOURCES += ish_isd.c +libmeta_la_SOURCES += spt_spd.c +libmeta_la_SOURCES += ydsp.c EXTRA_DIST = meta.h diff --git a/src/meta/ish_isd.c b/src/meta/ish_isd.c new file mode 100644 index 00000000..0ee46e0f --- /dev/null +++ b/src/meta/ish_isd.c @@ -0,0 +1,98 @@ +#include "meta.h" +#include "../util.h" + +/* SPT+SPT + + 2008-11-27 - manakoAT : First try for splitted files... +*/ + +VGMSTREAM * init_vgmstream_ish_isd(STREAMFILE *streamFile) { + + VGMSTREAM * vgmstream = NULL; + STREAMFILE * streamFileISH = NULL; + char filename[260]; + char filenameISH[260]; + + int i; + int channel_count; + int loop_flag; + + /* check extension, case insensitive */ + streamFile->get_name(streamFile,filename,sizeof(filename)); + if (strcasecmp("isd",filename_extension(filename))) goto fail; + + + strcpy(filenameISH,filename); + strcpy(filenameISH+strlen(filenameISH)-3,"ISH"); + + streamFileISH = streamFile->open(streamFile,filenameISH,STREAMFILE_DEFAULT_BUFFER_SIZE); + if (!streamFileISH) goto fail; + + /* check header */ + if (read_32bitBE(0x00,streamFileISH) != 0x495F5346) /* "I_SF" */ + goto fail; + + channel_count = read_32bitBE(0x14,streamFileISH); + loop_flag = read_32bitBE(0x20,streamFileISH); + + /* 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_32bitBE(0x08,streamFileISH); + vgmstream->num_samples=read_32bitBE(0x0C,streamFileISH); + vgmstream->coding_type = coding_NGC_DSP; + + if(loop_flag) { + vgmstream->loop_start_sample = read_32bitBE(0x20,streamFileISH)*14/8/channel_count; + vgmstream->loop_end_sample = read_32bitBE(0x24,streamFileISH)*14/8/channel_count; + } + + if (channel_count == 1) { + vgmstream->layout_type = layout_none; + } else if (channel_count == 2) { + vgmstream->layout_type = layout_interleave; + vgmstream->interleave_block_size = read_32bitBE(0x18,streamFileISH); + } + + + + vgmstream->meta_type = meta_ISH_ISD; + + /* open the file for reading */ + { + for (i=0;ich[i].streamfile = streamFile->open(streamFile,filename,vgmstream->interleave_block_size); + vgmstream->ch[i].offset = 0; + + if (!vgmstream->ch[i].streamfile) goto fail; + } + } + + + + 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,streamFileISH); + } + if (vgmstream->channels == 2) { + for (i=0;i<16;i++) { + vgmstream->ch[1].adpcm_coef[i] = read_16bitBE(0x80+i*2,streamFileISH); + } + } + } + + + close_streamfile(streamFileISH); streamFileISH=NULL; + + return vgmstream; + + /* clean up anything we may have opened */ +fail: + if (streamFileISH) close_streamfile(streamFileISH); + if (vgmstream) close_vgmstream(vgmstream); + return NULL; +} diff --git a/src/meta/meta.h b/src/meta/meta.h index e98cf256..d4d64485 100644 --- a/src/meta/meta.h +++ b/src/meta/meta.h @@ -287,4 +287,10 @@ VGMSTREAM * init_vgmstream_zwdsp(STREAMFILE * streamFile); VGMSTREAM * init_vgmstream_gca(STREAMFILE * streamFile); +VGMSTREAM * init_vgmstream_spt_spd(STREAMFILE * streamFile); + +VGMSTREAM * init_vgmstream_ish_isd(STREAMFILE * streamFile); + +VGMSTREAM * init_vgmstream_ydsp(STREAMFILE * streamFile); + #endif diff --git a/src/meta/spt_spd.c b/src/meta/spt_spd.c new file mode 100644 index 00000000..34772d0f --- /dev/null +++ b/src/meta/spt_spd.c @@ -0,0 +1,96 @@ +#include "meta.h" +#include "../util.h" + +/* SPT+SPT + + 2008-11-27 - manakoAT : First try for splitted files... +*/ + +VGMSTREAM * init_vgmstream_spt_spd(STREAMFILE *streamFile) { + + VGMSTREAM * vgmstream = NULL; + STREAMFILE * streamFileSPT = NULL; + char filename[260]; + char filenameSPT[260]; + + int i; + int channel_count; + int loop_flag; + + /* check extension, case insensitive */ + streamFile->get_name(streamFile,filename,sizeof(filename)); + if (strcasecmp("spd",filename_extension(filename))) goto fail; + + + strcpy(filenameSPT,filename); + strcpy(filenameSPT+strlen(filenameSPT)-3,"SPT"); + + streamFileSPT = streamFile->open(streamFile,filenameSPT,STREAMFILE_DEFAULT_BUFFER_SIZE); + + + if (!streamFileSPT) goto fail; + + channel_count = read_32bitBE(0x00,streamFileSPT); + loop_flag = read_32bitBE(0x04,streamFileSPT); + + /* 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_32bitBE(0x08,streamFileSPT); + vgmstream->num_samples=read_32bitBE(0x14,streamFileSPT)*14/16/channel_count; + vgmstream->coding_type = coding_NGC_DSP; + + if(loop_flag) { + vgmstream->loop_start_sample = 0; + vgmstream->loop_end_sample = read_32bitBE(0x14,streamFileSPT)*14/16/channel_count; + } + + if (channel_count == 1) { + 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->meta_type = meta_SPT_SPD; + + /* open the file for reading */ + { + for (i=0;ich[i].streamfile = streamFile->open(streamFile,filename,0x8000); + vgmstream->ch[i].offset = 0; + + if (!vgmstream->ch[i].streamfile) goto fail; + } + } + + + + if (vgmstream->coding_type == coding_NGC_DSP) { + int i; + for (i=0;i<16;i++) { + vgmstream->ch[0].adpcm_coef[i] = read_16bitBE(0x20+i*2,streamFileSPT); + } + if (vgmstream->channels == 2) { + for (i=0;i<16;i++) { + vgmstream->ch[1].adpcm_coef[i] = read_16bitBE(0x40+i*2,streamFileSPT); + } + } + } + + + close_streamfile(streamFileSPT); streamFileSPT=NULL; + return vgmstream; + + /* clean up anything we may have opened */ +fail: + if (streamFileSPT) close_streamfile(streamFileSPT); + if (vgmstream) close_vgmstream(vgmstream); + return NULL; +} diff --git a/src/meta/ydsp.c b/src/meta/ydsp.c new file mode 100644 index 00000000..007faa30 --- /dev/null +++ b/src/meta/ydsp.c @@ -0,0 +1,83 @@ +#include "meta.h" +#include "../util.h" + +/* YDSP (from WWE Day of Reckoning) */ +VGMSTREAM * init_vgmstream_ydsp(STREAMFILE *streamFile) { + VGMSTREAM * vgmstream = NULL; + char filename[260]; + off_t start_offset; + + int loop_flag; + int channel_count; + + /* check extension, case insensitive */ + streamFile->get_name(streamFile,filename,sizeof(filename)); + if (strcasecmp("ydsp",filename_extension(filename))) goto fail; + + /* check header */ + if (read_32bitBE(0x00,streamFile) != 0x59445350) /* "YDSP" */ + goto fail; + + loop_flag = (read_32bitBE(0xB0,streamFile)!=0); + channel_count = 2; /* (uint32_t)read_16bitBE(0x10,streamFile); */ + + /* build the VGMSTREAM */ + vgmstream = allocate_vgmstream(channel_count,loop_flag); + if (!vgmstream) goto fail; + + /* fill in the vital statistics */ + start_offset = 0x120; + vgmstream->channels = channel_count; + vgmstream->sample_rate = read_32bitBE(0x0C,streamFile); + vgmstream->coding_type = coding_NGC_DSP; + vgmstream->num_samples = (read_32bitBE(0x08,streamFile))*14/8/channel_count; + if (loop_flag) { + vgmstream->loop_start_sample = read_32bitBE(0xB0,streamFile); + vgmstream->loop_end_sample = read_32bitBE(0xB4,streamFile); + } + + if (channel_count == 1) { + vgmstream->layout_type = layout_none; + } else if (channel_count == 2) { + vgmstream->interleave_block_size = read_32bitBE(0x14,streamFile); + vgmstream->layout_type = layout_interleave; + } + + vgmstream->meta_type = meta_YDSP; + + /* open the file for reading */ + + if (vgmstream->coding_type == coding_NGC_DSP) { + int i; + for (i=0;i<16;i++) { + vgmstream->ch[0].adpcm_coef[i] = read_16bitBE(0x20+i*2,streamFile); + } + if (vgmstream->channels == 2) { + for (i=0;i<16;i++) { + vgmstream->ch[1].adpcm_coef[i] = read_16bitBE(0x44+i*2,streamFile); + } + } + } + + { + int i; + STREAMFILE * file; + file = streamFile->open(streamFile,filename,STREAMFILE_DEFAULT_BUFFER_SIZE); + if (!file) goto fail; + for (i=0;ich[i].streamfile = file; + + vgmstream->ch[i].channel_start_offset= + vgmstream->ch[i].offset=start_offset+ + vgmstream->interleave_block_size*i; + + } + } + + return vgmstream; + + /* clean up anything we may have opened */ +fail: + if (vgmstream) close_vgmstream(vgmstream); + return NULL; +} diff --git a/src/vgmstream.c b/src/vgmstream.c index d399b9fc..28f54620 100644 --- a/src/vgmstream.c +++ b/src/vgmstream.c @@ -160,6 +160,9 @@ VGMSTREAM * (*init_vgmstream_fcns[])(STREAMFILE *streamFile) = { init_vgmstream_str_asr, init_vgmstream_zwdsp, init_vgmstream_gca, + init_vgmstream_spt_spd, + init_vgmstream_ish_isd, + init_vgmstream_ydsp, }; #define INIT_VGMSTREAM_FCNS (sizeof(init_vgmstream_fcns)/sizeof(init_vgmstream_fcns[0])) @@ -1839,6 +1842,15 @@ void describe_vgmstream(VGMSTREAM * vgmstream, char * desc, int length) { break; case meta_GCA: snprintf(temp,TEMPSIZE,"GCA DSP Header"); + break; + case meta_SPT_SPD: + snprintf(temp,TEMPSIZE,"SPT+SPD DSP Header"); + break; + case meta_ISH_ISD: + snprintf(temp,TEMPSIZE,"ISH+ISD DSP Header"); + break; + case meta_YDSP: + snprintf(temp,TEMPSIZE,"YDSP Header"); break; default: snprintf(temp,TEMPSIZE,"THEY SHOULD HAVE SENT A POET"); diff --git a/src/vgmstream.h b/src/vgmstream.h index 02bb036d..1883c64d 100644 --- a/src/vgmstream.h +++ b/src/vgmstream.h @@ -243,6 +243,9 @@ typedef enum { meta_PS2_OMU, /* PS2 Int file with Header */ meta_PS2_XA2, /* XA2 XG3 file */ meta_IDSP, /* Chronicles of Narnia */ + meta_SPT_SPD, /* Variouis */ + meta_ISH_ISD, /* Various */ + meta_YDSP, /* WWE Day of Reckoning */ meta_IDSP2, /* Chronicles of Narnia */ meta_WAA_WAC_WAD_WAM, /* Beyond Good & Evil */ diff --git a/winamp/in_vgmstream.c b/winamp/in_vgmstream.c index c545cfe2..acb6439b 100644 --- a/winamp/in_vgmstream.c +++ b/winamp/in_vgmstream.c @@ -203,6 +203,9 @@ char * extension_list[] = { "asr\0ASR Audio File (*.ASR)\0", "zwdsp\0ZWDSP Audio File (*.ZWDSP)\0", "gca\0GCA Audio File (*.GCA)\0", + "spd\0SPD Audio File (*.SPD)\0", + "isd\0ISD Audio File (*.ISD)\0", + "ydsp\0YDSP Audio File (*.YDSP)\0", }; void about(HWND hwndParent) {