diff --git a/src/Makefile b/src/Makefile index 715ab41e..5aeea80f 100644 --- a/src/Makefile +++ b/src/Makefile @@ -47,7 +47,8 @@ LAYOUT_OBJS=layout/ast_blocked.o \ layout/ivaud_layout.o \ layout/mxch_blocked.o \ layout/psx_mgav_blocked.o \ - layout/ps2_adm_blocked.o + layout/ps2_adm_blocked.o \ + layout/bdsp_blocked.o META_OBJS=meta/adx_header.o \ meta/afc_header.o \ @@ -243,7 +244,8 @@ META_OBJS=meta/adx_header.o \ meta/ps2_wad.o \ meta/ps2_voi.o \ meta/ps2_lpcm.o \ - meta/ps2_adm.o + meta/ps2_adm.o \ + meta/dsp_bdsp.o OBJECTS=vgmstream.o streamfile.o util.o $(CODING_OBJS) $(LAYOUT_OBJS) $(META_OBJS) diff --git a/src/layout/Makefile.unix.am b/src/layout/Makefile.unix.am index 841a78df..7b6c4075 100644 --- a/src/layout/Makefile.unix.am +++ b/src/layout/Makefile.unix.am @@ -32,5 +32,6 @@ liblayout_la_SOURCES += ivaud_layout.c liblayout_la_SOURCES += mxch_blocked.c liblayout_la_SOURCES += psx_mgav_blocked.c liblayout_la_SOURCES += ps2_adm_blocked.c +liblayout_la_SOURCES += bdsp_blocked.c EXTRA_DIST = layout.h diff --git a/src/layout/bdsp_blocked.c b/src/layout/bdsp_blocked.c new file mode 100644 index 00000000..88f640b6 --- /dev/null +++ b/src/layout/bdsp_blocked.c @@ -0,0 +1,18 @@ +#include "layout.h" +#include "../vgmstream.h" + +/* set up for the block at the given offset */ +void dsp_bdsp_block_update(off_t block_offset, VGMSTREAM * vgmstream) { + int i; + + vgmstream->current_block_offset = block_offset; + vgmstream->current_block_size = read_32bitBE(vgmstream->current_block_offset,vgmstream->ch[0].streamfile)/7*8; + vgmstream->next_block_offset = vgmstream->current_block_offset + vgmstream->current_block_size+0xC0; + + for (i=0;ichannels;i++) { + + vgmstream->ch[i].channel_start_offset= + vgmstream->ch[i].offset=vgmstream->current_block_offset*i; + + } +} diff --git a/src/libvgmstream.vcproj b/src/libvgmstream.vcproj index c8c05eec..598a4da3 100644 --- a/src/libvgmstream.vcproj +++ b/src/libvgmstream.vcproj @@ -296,6 +296,10 @@ RelativePath=".\meta\dmsg_segh.c" > + + diff --git a/src/meta/Makefile.unix.am b/src/meta/Makefile.unix.am index aa3e7ae5..8349d02a 100644 --- a/src/meta/Makefile.unix.am +++ b/src/meta/Makefile.unix.am @@ -197,5 +197,6 @@ libmeta_la_SOURCES += ps2_b1s.c libmeta_la_SOURCES += ps2_wad.c libmeta_la_SOURCES += ps2_lpcm.c libmeta_la_SOURCES += ps2_adm.c +libmeta_la_SOURCES += dsp_bdsp.c EXTRA_DIST = meta.h diff --git a/src/meta/dsp_bdsp.c b/src/meta/dsp_bdsp.c new file mode 100644 index 00000000..eef08788 --- /dev/null +++ b/src/meta/dsp_bdsp.c @@ -0,0 +1,88 @@ +#include "meta.h" +#include "../layout/layout.h" +#include "../util.h" + +VGMSTREAM * init_vgmstream_dsp_bdsp(STREAMFILE *streamFile) { + + VGMSTREAM * vgmstream = NULL; + STREAMFILE * streamFileGSP = NULL; + char filename[260]; + int channel_count; + int loop_flag; + int i; + off_t start_offset; + + /* check extension, case insensitive */ + streamFile->get_name(streamFile,filename,sizeof(filename)); + if (strcasecmp("bdsp",filename_extension(filename))) goto fail; + + channel_count = 2; + loop_flag = 0; + + /* 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(0x8,streamFile); + vgmstream->coding_type = coding_NGC_DSP; + +#if 0 + if(loop_flag) { + vgmstream->loop_start_sample = read_32bitBE(0x64,streamFile); + vgmstream->loop_end_sample = read_32bitBE(0x68,streamFile); + } +#endif + + + vgmstream->layout_type = layout_dsp_bdsp_blocked; + vgmstream->interleave_block_size = 0x8; + vgmstream->meta_type = meta_DSP_BDSP; + + /* open the file for reading by each channel */ + { + for (i=0;ich[i].streamfile = streamFile->open(streamFile,filename,vgmstream->interleave_block_size); + + if (!vgmstream->ch[i].streamfile) goto fail; + vgmstream->ch[i].channel_start_offset= + vgmstream->ch[i].offset=i*vgmstream->interleave_block_size; + } + } + + if (vgmstream->coding_type == coding_NGC_DSP) { + int i; + for (i=0;i<16;i++) { + vgmstream->ch[0].adpcm_coef[i] = read_16bitBE(0x1C+i*2,streamFile); + } + if (vgmstream->channels == 2) { + for (i=0;i<16;i++) { + vgmstream->ch[1].adpcm_coef[i] = read_16bitBE(0x7C+i*2,streamFile); + } + } + } + + /* Calc num_samples */ + start_offset = 0x0; + dsp_bdsp_block_update(start_offset,vgmstream); + vgmstream->num_samples=0; + + do + { + vgmstream->num_samples += vgmstream->current_block_size*14/8; + dsp_bdsp_block_update(vgmstream->next_block_offset,vgmstream); + } + while (vgmstream->next_block_offset