added bdsp block layout

git-svn-id: https://vgmstream.svn.sourceforge.net/svnroot/vgmstream@795 51a99a44-fe44-0410-b1ba-c3e57ba2b86b
This commit is contained in:
manakoAT 2010-05-12 09:54:01 +00:00
parent ad4276c7b7
commit ef3f28fe35
6 changed files with 116 additions and 2 deletions

View File

@ -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)

View File

@ -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

18
src/layout/bdsp_blocked.c Normal file
View File

@ -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;i<vgmstream->channels;i++) {
vgmstream->ch[i].channel_start_offset=
vgmstream->ch[i].offset=vgmstream->current_block_offset*i;
}
}

View File

@ -296,6 +296,10 @@
RelativePath=".\meta\dmsg_segh.c"
>
</File>
<File
RelativePath=".\meta\dsp_bdsp.c"
>
</File>
<File
RelativePath=".\meta\dsp_sth_str.c"
>

View File

@ -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

88
src/meta/dsp_bdsp.c Normal file
View File

@ -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;i<channel_count;i++) {
vgmstream->ch[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<get_streamfile_size(streamFile));
dsp_bdsp_block_update(start_offset,vgmstream);
return vgmstream;
/* clean up anything we may have opened */
fail:
if (vgmstream) close_vgmstream(vgmstream);
return NULL;
}