genh dsp added

git-svn-id: https://vgmstream.svn.sourceforge.net/svnroot/vgmstream@476 51a99a44-fe44-0410-b1ba-c3e57ba2b86b
This commit is contained in:
manakoAT 2008-11-17 18:28:14 +00:00
parent 5aca380054
commit 29819a79d4
2 changed files with 43 additions and 7 deletions

View File

@ -19,6 +19,9 @@ VGMSTREAM * init_vgmstream_genh(STREAMFILE *streamFile) {
int32_t loop_end; int32_t loop_end;
int32_t start_offset; int32_t start_offset;
int32_t header_size; int32_t header_size;
int32_t coef1;
int32_t coef2;
char filename[260]; char filename[260];
int coding; int coding;
#ifdef VGM_USE_MPEG #ifdef VGM_USE_MPEG
@ -49,6 +52,7 @@ VGMSTREAM * init_vgmstream_genh(STREAMFILE *streamFile) {
/* 9 = IMA */ /* 9 = IMA */
/* 10 = AICA ADPCM */ /* 10 = AICA ADPCM */
/* 11 = MS ADPCM */ /* 11 = MS ADPCM */
/* 12 = NGC DSP */
/* ... others to come */ /* ... others to come */
switch (read_32bitLE(0x18,streamFile)) { switch (read_32bitLE(0x18,streamFile)) {
case 0: case 0:
@ -91,11 +95,14 @@ VGMSTREAM * init_vgmstream_genh(STREAMFILE *streamFile) {
case 11: case 11:
coding = coding_MSADPCM; coding = coding_MSADPCM;
break; break;
case 12:
coding = coding_NGC_DSP;
break;
default: default:
goto fail; goto fail;
} }
start_offset = read_32bitLE(0x1c,streamFile); start_offset = read_32bitLE(0x1C,streamFile);
header_size = read_32bitLE(0x20,streamFile); header_size = read_32bitLE(0x20,streamFile);
/* HACK to support old genh */ /* HACK to support old genh */
@ -111,7 +118,10 @@ VGMSTREAM * init_vgmstream_genh(STREAMFILE *streamFile) {
sample_rate = read_32bitLE(0xc,streamFile); sample_rate = read_32bitLE(0xc,streamFile);
loop_start = read_32bitLE(0x10,streamFile); loop_start = read_32bitLE(0x10,streamFile);
loop_end = read_32bitLE(0x14,streamFile); loop_end = read_32bitLE(0x14,streamFile);
coef1 = read_32bitLE(0x24,streamFile);
coef2 = read_32bitLE(0x28,streamFile);
if (coding == coding_XBOX && channel_count != 2) goto fail; if (coding == coding_XBOX && channel_count != 2) goto fail;
/* build the VGMSTREAM */ /* build the VGMSTREAM */
@ -161,6 +171,14 @@ VGMSTREAM * init_vgmstream_genh(STREAMFILE *streamFile) {
case coding_NGC_DTK: case coding_NGC_DTK:
vgmstream->layout_type = layout_dtk_interleave; vgmstream->layout_type = layout_dtk_interleave;
break; break;
case coding_NGC_DSP:
if (channel_count > 1) {
vgmstream->layout_type = layout_interleave;
} else {
vgmstream->layout_type = layout_none;
}
break;
#ifdef VGM_USE_MPEG #ifdef VGM_USE_MPEG
case coding_MPEG1_L3: case coding_MPEG1_L3:
vgmstream->layout_type = layout_mpeg; vgmstream->layout_type = layout_mpeg;
@ -173,6 +191,8 @@ VGMSTREAM * init_vgmstream_genh(STREAMFILE *streamFile) {
/* open the file for reading by each channel */ /* open the file for reading by each channel */
{ {
int i; int i;
int j;
STREAMFILE * chstreamfile = NULL; STREAMFILE * chstreamfile = NULL;
for (i=0;i<channel_count;i++) { for (i=0;i<channel_count;i++) {
@ -218,6 +238,17 @@ VGMSTREAM * init_vgmstream_genh(STREAMFILE *streamFile) {
chstreamfile = chstreamfile =
streamFile->open(streamFile,filename,32*0x400); streamFile->open(streamFile,filename,32*0x400);
break; break;
case coding_NGC_DSP:
for (j=0;j<16;j++) {
vgmstream->ch[0].adpcm_coef[j] = read_16bitBE(coef1+j*2,streamFile);
}
if (vgmstream->channels == 2) {
for (j=0;j<16;j++) {
vgmstream->ch[1].adpcm_coef[j] = read_16bitBE(coef2+j*2,streamFile);
}
}
break;
#ifdef VGM_USE_MPEG #ifdef VGM_USE_MPEG
case coding_MPEG1_L3: case coding_MPEG1_L3:
if (!chstreamfile) if (!chstreamfile)

View File

@ -7,7 +7,7 @@ VGMSTREAM * init_vgmstream_ps2_seg(STREAMFILE *streamFile) {
char filename[260]; char filename[260];
off_t start_offset; off_t start_offset;
int loop_flag; int loop_flag;
int channel_count; int channel_count;
/* check extension, case insensitive */ /* check extension, case insensitive */
@ -16,12 +16,12 @@ VGMSTREAM * init_vgmstream_ps2_seg(STREAMFILE *streamFile) {
/* check header */ /* check header */
if (read_32bitBE(0x00,streamFile) != 0x73656700 && /* "sea\0" */ if (read_32bitBE(0x00,streamFile) != 0x73656700 && /* "seg\0" */
read_32bitBE(0x04,streamFile) != 0x70733200) /* "ps2\0" */ read_32bitBE(0x04,streamFile) != 0x70733200) /* "ps2\0" */
goto fail; goto fail;
loop_flag = 0; loop_flag = 0;
channel_count = read_32bitLE(0x08,streamFile); channel_count = read_32bitLE(0x24,streamFile);
/* build the VGMSTREAM */ /* build the VGMSTREAM */
vgmstream = allocate_vgmstream(channel_count,loop_flag); vgmstream = allocate_vgmstream(channel_count,loop_flag);
@ -38,8 +38,13 @@ VGMSTREAM * init_vgmstream_ps2_seg(STREAMFILE *streamFile) {
vgmstream->loop_end_sample = read_32bitLE(0x1C,streamFile); vgmstream->loop_end_sample = read_32bitLE(0x1C,streamFile);
} }
vgmstream->layout_type = layout_interleave; if (channel_count == 1) {
vgmstream->interleave_block_size = 0x2000; vgmstream->layout_type = layout_none;
} else if (channel_count == 2) {
vgmstream->layout_type = layout_interleave;
vgmstream->interleave_block_size = 0x2000;
}
vgmstream->meta_type = meta_PS2_SEG; vgmstream->meta_type = meta_PS2_SEG;
/* open the file for reading */ /* open the file for reading */