From 29819a79d4e12ed50360571c819e903e5fd5dfe2 Mon Sep 17 00:00:00 2001 From: manakoAT Date: Mon, 17 Nov 2008 18:28:14 +0000 Subject: [PATCH] genh dsp added git-svn-id: https://vgmstream.svn.sourceforge.net/svnroot/vgmstream@476 51a99a44-fe44-0410-b1ba-c3e57ba2b86b --- src/meta/genh.c | 35 +++++++++++++++++++++++++++++++++-- src/meta/ps2_seg.c | 15 ++++++++++----- 2 files changed, 43 insertions(+), 7 deletions(-) diff --git a/src/meta/genh.c b/src/meta/genh.c index ee8b7df8..2d47fd30 100644 --- a/src/meta/genh.c +++ b/src/meta/genh.c @@ -19,6 +19,9 @@ VGMSTREAM * init_vgmstream_genh(STREAMFILE *streamFile) { int32_t loop_end; int32_t start_offset; int32_t header_size; + int32_t coef1; + int32_t coef2; + char filename[260]; int coding; #ifdef VGM_USE_MPEG @@ -49,6 +52,7 @@ VGMSTREAM * init_vgmstream_genh(STREAMFILE *streamFile) { /* 9 = IMA */ /* 10 = AICA ADPCM */ /* 11 = MS ADPCM */ + /* 12 = NGC DSP */ /* ... others to come */ switch (read_32bitLE(0x18,streamFile)) { case 0: @@ -91,11 +95,14 @@ VGMSTREAM * init_vgmstream_genh(STREAMFILE *streamFile) { case 11: coding = coding_MSADPCM; break; + case 12: + coding = coding_NGC_DSP; + break; default: goto fail; } - start_offset = read_32bitLE(0x1c,streamFile); + start_offset = read_32bitLE(0x1C,streamFile); header_size = read_32bitLE(0x20,streamFile); /* HACK to support old genh */ @@ -111,7 +118,10 @@ VGMSTREAM * init_vgmstream_genh(STREAMFILE *streamFile) { sample_rate = read_32bitLE(0xc,streamFile); loop_start = read_32bitLE(0x10,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; /* build the VGMSTREAM */ @@ -161,6 +171,14 @@ VGMSTREAM * init_vgmstream_genh(STREAMFILE *streamFile) { case coding_NGC_DTK: vgmstream->layout_type = layout_dtk_interleave; 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 case coding_MPEG1_L3: vgmstream->layout_type = layout_mpeg; @@ -173,6 +191,8 @@ VGMSTREAM * init_vgmstream_genh(STREAMFILE *streamFile) { /* open the file for reading by each channel */ { int i; + int j; + STREAMFILE * chstreamfile = NULL; for (i=0;iopen(streamFile,filename,32*0x400); 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 case coding_MPEG1_L3: if (!chstreamfile) diff --git a/src/meta/ps2_seg.c b/src/meta/ps2_seg.c index 34096235..06ede8b2 100644 --- a/src/meta/ps2_seg.c +++ b/src/meta/ps2_seg.c @@ -7,7 +7,7 @@ VGMSTREAM * init_vgmstream_ps2_seg(STREAMFILE *streamFile) { char filename[260]; off_t start_offset; - int loop_flag; + int loop_flag; int channel_count; /* check extension, case insensitive */ @@ -16,12 +16,12 @@ VGMSTREAM * init_vgmstream_ps2_seg(STREAMFILE *streamFile) { /* 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" */ goto fail; loop_flag = 0; - channel_count = read_32bitLE(0x08,streamFile); + channel_count = read_32bitLE(0x24,streamFile); /* build the VGMSTREAM */ 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->layout_type = layout_interleave; - vgmstream->interleave_block_size = 0x2000; + if (channel_count == 1) { + 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; /* open the file for reading */