From a32c10afca94d8203c225ec9460643ce91a088d5 Mon Sep 17 00:00:00 2001 From: fastelbja Date: Sun, 10 Aug 2008 20:08:03 +0000 Subject: [PATCH] added meta ims from matrix convert coding_xbox from interleave to none git-svn-id: https://vgmstream.svn.sourceforge.net/svnroot/vgmstream@403 51a99a44-fe44-0410-b1ba-c3e57ba2b86b --- src/coding/ima_decoder.c | 4 +++ src/layout/blocked.c | 3 ++ src/layout/ims_block.c | 18 ++++++++++++ src/layout/layout.h | 2 ++ src/libvgmstream.vcproj | 8 ++++++ src/meta/fsb.c | 3 +- src/meta/genh.c | 3 +- src/meta/meta.h | 2 ++ src/meta/rsd.c | 2 +- src/meta/xbox_ims.c | 60 ++++++++++++++++++++++++++++++++++++++++ src/meta/xbox_wavm.c | 3 +- src/meta/xbox_wvs.c | 3 +- src/meta/xbox_xwav.c | 3 +- src/vgmstream.c | 8 ++++++ src/vgmstream.h | 2 ++ winamp/in_vgmstream.c | 1 + 16 files changed, 114 insertions(+), 11 deletions(-) create mode 100644 src/layout/ims_block.c create mode 100644 src/meta/xbox_ims.c diff --git a/src/coding/ima_decoder.c b/src/coding/ima_decoder.c index 7c9a65ab..a84d7c23 100644 --- a/src/coding/ima_decoder.c +++ b/src/coding/ima_decoder.c @@ -111,6 +111,10 @@ void decode_xbox_ima(VGMSTREAMCHANNEL * stream, sample * outbuf, int channelspac outbuf[sample_count]=(short)(hist1); } + // Only increment offset on complete frame + if(offset-stream->offset==(32*channelspacing)+(4*channel)+channelspacing+1) // ?? + stream->offset+=36*channelspacing; + stream->adpcm_history1_32=hist1; stream->adpcm_step_index=step_index; } diff --git a/src/layout/blocked.c b/src/layout/blocked.c index 598c7f1e..26ab299a 100644 --- a/src/layout/blocked.c +++ b/src/layout/blocked.c @@ -78,6 +78,9 @@ void render_vgmstream_blocked(sample * buffer, int32_t sample_count, VGMSTREAM * break; case layout_ws_aud_blocked: ws_aud_block_update(vgmstream->next_block_offset,vgmstream); + break; + case layout_matx_blocked: + matx_block_update(vgmstream->next_block_offset,vgmstream); break; default: break; diff --git a/src/layout/ims_block.c b/src/layout/ims_block.c new file mode 100644 index 00000000..c5df5948 --- /dev/null +++ b/src/layout/ims_block.c @@ -0,0 +1,18 @@ +#include "layout.h" +#include "../vgmstream.h" + +/* set up for the block at the given offset */ +void matx_block_update(off_t block_offset, VGMSTREAM * vgmstream) { + int i; + + vgmstream->current_block_offset = block_offset; + vgmstream->current_block_size = read_32bitLE( + vgmstream->current_block_offset, + vgmstream->ch[0].streamfile); + vgmstream->next_block_offset = vgmstream->current_block_offset + vgmstream->current_block_size + 8; + vgmstream->current_block_size/=vgmstream->channels; + + for (i=0;ichannels;i++) { + vgmstream->ch[i].offset = vgmstream->current_block_offset + 8; + } +} diff --git a/src/layout/layout.h b/src/layout/layout.h index 91e64713..b82bf2a9 100644 --- a/src/layout/layout.h +++ b/src/layout/layout.h @@ -24,6 +24,8 @@ void str_snds_block_update(off_t block_offset, VGMSTREAM * vgmstream); void ws_aud_block_update(off_t block_offset, VGMSTREAM * vgmstream); +void matx_block_update(off_t block_offset, VGMSTREAM * vgmstream); + void render_vgmstream_interleave(sample * buffer, int32_t sample_count, VGMSTREAM * vgmstream); void render_vgmstream_nolayout(sample * buffer, int32_t sample_count, VGMSTREAM * vgmstream); diff --git a/src/libvgmstream.vcproj b/src/libvgmstream.vcproj index 912f3484..00142a64 100644 --- a/src/libvgmstream.vcproj +++ b/src/libvgmstream.vcproj @@ -536,6 +536,10 @@ RelativePath=".\meta\ws_aud.c" > + + @@ -692,6 +696,10 @@ RelativePath=".\layout\halpst_blocked.c" > + + diff --git a/src/meta/fsb.c b/src/meta/fsb.c index 63f7616c..8e37696e 100644 --- a/src/meta/fsb.c +++ b/src/meta/fsb.c @@ -83,8 +83,7 @@ VGMSTREAM * init_vgmstream_fsb(STREAMFILE *streamFile) { case 0x41004800: /* XBOX (FlatOut, Rainbow Six - Lockdown) */ case 0x01004804: /* XBOX (Cold Fear) <- maybe IMA??? */ vgmstream->coding_type = coding_XBOX; - vgmstream->layout_type = layout_interleave; - vgmstream->interleave_block_size = 36; + vgmstream->layout_type = layout_none; vgmstream->num_samples = read_32bitLE(0x0C,streamFile)*64/36/channel_count; if (loop_flag) { vgmstream->loop_start_sample = read_32bitLE(0x40,streamFile); diff --git a/src/meta/genh.c b/src/meta/genh.c index 79a3a1c2..3b2d48d6 100644 --- a/src/meta/genh.c +++ b/src/meta/genh.c @@ -141,8 +141,7 @@ VGMSTREAM * init_vgmstream_genh(STREAMFILE *streamFile) { } break; case coding_XBOX: - vgmstream->layout_type = layout_interleave; - vgmstream->interleave_block_size = 36; + vgmstream->layout_type = layout_none; break; case coding_NGC_DTK: diff --git a/src/meta/meta.h b/src/meta/meta.h index c8ab728f..ea30b49b 100644 --- a/src/meta/meta.h +++ b/src/meta/meta.h @@ -199,4 +199,6 @@ VGMSTREAM * init_vgmstream_xbox_wvs(STREAMFILE *streamFile); VGMSTREAM * init_vgmstream_dc_str(STREAMFILE *streamFile); +VGMSTREAM * init_vgmstream_xbox_matx(STREAMFILE *streamFile); + #endif diff --git a/src/meta/rsd.c b/src/meta/rsd.c index c60f6a4e..6198ddc3 100644 --- a/src/meta/rsd.c +++ b/src/meta/rsd.c @@ -84,7 +84,6 @@ VGMSTREAM * init_vgmstream_rsd(STREAMFILE *streamFile) { case 0x58414450: /* RSD2XADP */ start_offset = 0x40; coding_type = coding_XBOX; - vgmstream->interleave_block_size = 0x24; vgmstream->num_samples = (get_streamfile_size(streamFile)-start_offset)*64/36/channel_count; @@ -124,6 +123,7 @@ VGMSTREAM * init_vgmstream_rsd(STREAMFILE *streamFile) { if (vgmstream->coding_type == coding_XBOX) { + vgmstream->layout_type=layout_none; vgmstream->ch[i].channel_start_offset=start_offset; } else { vgmstream->ch[i].channel_start_offset= diff --git a/src/meta/xbox_ims.c b/src/meta/xbox_ims.c new file mode 100644 index 00000000..0f0a570e --- /dev/null +++ b/src/meta/xbox_ims.c @@ -0,0 +1,60 @@ +#include "meta.h" +#include "../util.h" + +/* matx + + MATX (found in Matrix) +*/ + +VGMSTREAM * init_vgmstream_xbox_matx(STREAMFILE *streamFile) { + VGMSTREAM * vgmstream = NULL; + char filename[260]; + + int loop_flag=0; + int channel_count; + int i; + + /* check extension, case insensitive */ + streamFile->get_name(streamFile,filename,sizeof(filename)); + if (strcasecmp("matx",filename_extension(filename))) goto fail; + + loop_flag = 0; + channel_count=read_16bitLE(0x4,streamFile); + + /* 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_16bitLE(0x06,streamFile) & 0xffff; + vgmstream->coding_type = coding_XBOX; + + vgmstream->layout_type = layout_matx_blocked; + vgmstream->meta_type = meta_XBOX_MATX; + + /* open the file for reading by each channel */ + { + for (i=0;ich[i].streamfile = streamFile->open(streamFile,filename,36); + if (!vgmstream->ch[i].streamfile) goto fail; + } + } + + /* Calc num_samples */ + matx_block_update(0,vgmstream); + vgmstream->num_samples=0; + + do { + vgmstream->num_samples += vgmstream->current_block_size/36*64; + matx_block_update(vgmstream->next_block_offset,vgmstream); + } while (vgmstream->next_block_offsetcoding_type = coding_XBOX; vgmstream->num_samples = (int32_t)(get_streamfile_size(streamFile) / 36 * 64 / vgmstream->channels); - vgmstream->layout_type = layout_interleave; - vgmstream->interleave_block_size=36; + vgmstream->layout_type = layout_none; vgmstream->meta_type = meta_XBOX_WAVM; diff --git a/src/meta/xbox_wvs.c b/src/meta/xbox_wvs.c index c783184d..bba6ad1e 100644 --- a/src/meta/xbox_wvs.c +++ b/src/meta/xbox_wvs.c @@ -40,8 +40,7 @@ VGMSTREAM * init_vgmstream_xbox_wvs(STREAMFILE *streamFile) { vgmstream->coding_type = coding_XBOX; vgmstream->num_samples = read_32bitLE(0,streamFile) / 36 * 64 / vgmstream->channels; - vgmstream->layout_type = layout_interleave; - vgmstream->interleave_block_size=36; + vgmstream->layout_type = layout_none; vgmstream->meta_type = meta_XBOX_WVS; if(loop_flag) { diff --git a/src/meta/xbox_xwav.c b/src/meta/xbox_xwav.c index 46e04ea1..8c8ce1d4 100644 --- a/src/meta/xbox_xwav.c +++ b/src/meta/xbox_xwav.c @@ -60,8 +60,7 @@ VGMSTREAM * init_vgmstream_xbox_xwav(STREAMFILE *streamFile) { vgmstream->coding_type = coding_XBOX; vgmstream->num_samples = read_32bitLE(start_offset,streamFile) / 36 * 64 / vgmstream->channels; - vgmstream->layout_type = layout_interleave; - vgmstream->interleave_block_size=36; + vgmstream->layout_type = layout_none; vgmstream->meta_type = meta_XBOX_RIFF; diff --git a/src/vgmstream.c b/src/vgmstream.c index 7f7f2caf..5676eb46 100644 --- a/src/vgmstream.c +++ b/src/vgmstream.c @@ -113,6 +113,7 @@ VGMSTREAM * (*init_vgmstream_fcns[])(STREAMFILE *streamFile) = { init_vgmstream_ngc_vjdsp, init_vgmstream_xbox_wvs, init_vgmstream_xbox_stma, + init_vgmstream_xbox_matx, }; #define INIT_VGMSTREAM_FCNS (sizeof(init_vgmstream_fcns)/sizeof(init_vgmstream_fcns[0])) @@ -460,6 +461,7 @@ void render_vgmstream(sample * buffer, int32_t sample_count, VGMSTREAM * vgmstre case layout_wsi_blocked: case layout_str_snds_blocked: case layout_ws_aud_blocked: + case layout_matx_blocked: render_vgmstream_blocked(buffer,sample_count,vgmstream); break; case layout_interleave_byte: @@ -1215,6 +1217,9 @@ void describe_vgmstream(VGMSTREAM * vgmstream, char * desc, int length) { case layout_ws_aud_blocked: snprintf(temp,TEMPSIZE,"Westwood Studios .aud blocked"); break; + case layout_matx_blocked: + snprintf(temp,TEMPSIZE,"Matrix .matx blocked"); + break; #ifdef VGM_USE_MPEG case layout_fake_mpeg: snprintf(temp,TEMPSIZE,"MPEG Audio stream with incorrect frame headers"); @@ -1596,6 +1601,9 @@ void describe_vgmstream(VGMSTREAM * vgmstream, char * desc, int length) { case meta_XBOX_STMA: snprintf(temp,TEMPSIZE,"Midnight Club 2 STMA Header"); break; + case meta_XBOX_MATX: + snprintf(temp,TEMPSIZE,"assumed Matrix file by .matx extension"); + break; default: snprintf(temp,TEMPSIZE,"THEY SHOULD HAVE SENT A POET"); } diff --git a/src/vgmstream.h b/src/vgmstream.h index 8db34736..b4e0f4d3 100644 --- a/src/vgmstream.h +++ b/src/vgmstream.h @@ -109,6 +109,7 @@ typedef enum { layout_wsi_blocked, layout_str_snds_blocked, layout_ws_aud_blocked, + layout_matx_blocked, #if 0 layout_strm_blocked, /* */ #endif @@ -226,6 +227,7 @@ typedef enum { meta_XBOX_RIFF, /* XBOX RIFF/WAVE File */ meta_XBOX_WVS, /* XBOX WVS */ meta_XBOX_STMA, /* XBOX STMA */ + meta_XBOX_MATX, /* XBOX MATX */ meta_EAXA_R2, /* EA XA Release 2 */ meta_EAXA_R3, /* EA XA Release 3 */ diff --git a/winamp/in_vgmstream.c b/winamp/in_vgmstream.c index 4ef26ef1..8134343c 100644 --- a/winamp/in_vgmstream.c +++ b/winamp/in_vgmstream.c @@ -172,6 +172,7 @@ char * extension_list[] = { "vjdsp\0VJDSP Audio File (*.VJDSP)\0", "wvs\0WVS Audio File (*.WVS)\0", "stma\0STMA Audio File (*.STMA)\0", + "matx\0MATX Audio File (*.MATX)\0", }; void about(HWND hwndParent) {