From 96c3b5cc43cbcc8d29b82c24f84d3d7dbdc1c84b Mon Sep 17 00:00:00 2001 From: manakoAT Date: Wed, 24 Sep 2008 16:36:19 +0000 Subject: [PATCH] .MIHB added -> Merged MIH+MIB git-svn-id: https://vgmstream.svn.sourceforge.net/svnroot/vgmstream@441 51a99a44-fe44-0410-b1ba-c3e57ba2b86b --- src/Makefile | 3 +- src/libvgmstream.vcproj | 4 +++ src/meta/Makefile.unix.am | 1 + src/meta/meta.h | 2 ++ src/meta/ps2_mihb.c | 67 +++++++++++++++++++++++++++++++++++++++ src/vgmstream.c | 4 +++ src/vgmstream.h | 1 + winamp/in_vgmstream.c | 1 + 8 files changed, 82 insertions(+), 1 deletion(-) create mode 100644 src/meta/ps2_mihb.c diff --git a/src/Makefile b/src/Makefile index be6831aa..d5e771c9 100644 --- a/src/Makefile +++ b/src/Makefile @@ -137,7 +137,8 @@ META_OBJS=meta/adx_header.o \ meta/ngc_ymf.o \ meta/nds_sad.o \ meta/ps2_ccc.o \ - meta/psx_fag.o + meta/psx_fag.o \ + meta/ps2_mihb.o OBJECTS=vgmstream.o streamfile.o util.o $(CODING_OBJS) $(LAYOUT_OBJS) $(META_OBJS) diff --git a/src/libvgmstream.vcproj b/src/libvgmstream.vcproj index e85db88c..8c0fc5e5 100644 --- a/src/libvgmstream.vcproj +++ b/src/libvgmstream.vcproj @@ -437,6 +437,10 @@ RelativePath=".\meta\ps2_mic.c" > + + diff --git a/src/meta/Makefile.unix.am b/src/meta/Makefile.unix.am index 9b3ee96c..153f475d 100644 --- a/src/meta/Makefile.unix.am +++ b/src/meta/Makefile.unix.am @@ -106,4 +106,5 @@ libmeta_la_SOURCES += ngc_ymf.c libmeta_la_SOURCES += nds_sad.c libmeta_la_SOURCES += ps2_ccc.c libmeta_la_SOURCES += psx_fag.c +libmeta_la_SOURCES += ps2_mihb.c EXTRA_DIST = meta.h diff --git a/src/meta/meta.h b/src/meta/meta.h index f572ae21..ecf2c6ca 100644 --- a/src/meta/meta.h +++ b/src/meta/meta.h @@ -233,4 +233,6 @@ VGMSTREAM * init_vgmstream_ps2_ccc(STREAMFILE * streamFile); VGMSTREAM * init_vgmstream_psx_fag(STREAMFILE * streamFile); +VGMSTREAM * init_vgmstream_ps2_mihb(STREAMFILE * streamFile); + #endif diff --git a/src/meta/ps2_mihb.c b/src/meta/ps2_mihb.c new file mode 100644 index 00000000..57a80f09 --- /dev/null +++ b/src/meta/ps2_mihb.c @@ -0,0 +1,67 @@ +#include "meta.h" +#include "../util.h" + +/* MIHB (Merged MIH+MIB) */ +VGMSTREAM * init_vgmstream_ps2_mihb(STREAMFILE *streamFile) { + VGMSTREAM * vgmstream = NULL; + char filename[260]; + off_t start_offset; + + int mib_blocks; + int loop_flag = 0; + int channel_count; + + /* check extension, case insensitive */ + streamFile->get_name(streamFile,filename,sizeof(filename)); + if (strcasecmp("mihb",filename_extension(filename))) goto fail; + + /* check header */ + if (read_32bitBE(0x00,streamFile) != 0x40000000) + goto fail; + + mib_blocks = read_32bitLE(0x14,streamFile); + loop_flag = 0; + channel_count = read_32bitLE(0x08,streamFile); + + /* build the VGMSTREAM */ + vgmstream = allocate_vgmstream(channel_count,loop_flag); + if (!vgmstream) goto fail; + + /* fill in the vital statistics */ + start_offset = 0x40; + vgmstream->channels = channel_count; + vgmstream->sample_rate = read_32bitLE(0x0C,streamFile); + vgmstream->coding_type = coding_PSX; + vgmstream->num_samples = (read_32bitLE(0x10,streamFile))*mib_blocks*channel_count/32*28; + if (loop_flag) { + vgmstream->loop_start_sample = 0; + vgmstream->loop_end_sample = (read_32bitLE(0x10,streamFile))*mib_blocks*channel_count/32*28; + } + + vgmstream->layout_type = layout_interleave; + vgmstream->interleave_block_size = read_32bitLE(0x10,streamFile); + vgmstream->meta_type = meta_PS2_MIHB; + + /* open the file for reading */ + { + int i; + STREAMFILE * file; + file = streamFile->open(streamFile,filename,STREAMFILE_DEFAULT_BUFFER_SIZE); + if (!file) goto fail; + for (i=0;ich[i].streamfile = file; + + vgmstream->ch[i].channel_start_offset= + vgmstream->ch[i].offset=start_offset+ + vgmstream->interleave_block_size*i; + + } + } + + return vgmstream; + + /* clean up anything we may have opened */ +fail: + if (vgmstream) close_vgmstream(vgmstream); + return NULL; +} diff --git a/src/vgmstream.c b/src/vgmstream.c index 9ac6f773..beefbbb3 100644 --- a/src/vgmstream.c +++ b/src/vgmstream.c @@ -132,6 +132,7 @@ VGMSTREAM * (*init_vgmstream_fcns[])(STREAMFILE *streamFile) = { init_vgmstream_sadl, init_vgmstream_ps2_ccc, init_vgmstream_psx_fag, + init_vgmstream_ps2_mihb, }; #define INIT_VGMSTREAM_FCNS (sizeof(init_vgmstream_fcns)/sizeof(init_vgmstream_fcns[0])) @@ -1703,6 +1704,9 @@ void describe_vgmstream(VGMSTREAM * vgmstream, char * desc, int length) { break; case meta_PSX_FAG: snprintf(temp,TEMPSIZE,"FAG Header"); + break; + case meta_PS2_MIHB: + snprintf(temp,TEMPSIZE,"Merged MIH+MIB"); break; default: snprintf(temp,TEMPSIZE,"THEY SHOULD HAVE SENT A POET"); diff --git a/src/vgmstream.h b/src/vgmstream.h index 91e4b9f4..53bcb56d 100644 --- a/src/vgmstream.h +++ b/src/vgmstream.h @@ -239,6 +239,7 @@ typedef enum { meta_SADL, /* .sad */ meta_PS2_CCC, /* Tokyo Xtreme Racer DRIFT 2 */ meta_PSX_FAG, /* Jackie Chan - Stuntmaster */ + meta_PS2_MIHB, /* Merged MIH+MIB */ meta_XBOX_WAVM, /* XBOX WAVM File */ meta_XBOX_RIFF, /* XBOX RIFF/WAVE File */ diff --git a/winamp/in_vgmstream.c b/winamp/in_vgmstream.c index 7c466f50..edbfe2c3 100644 --- a/winamp/in_vgmstream.c +++ b/winamp/in_vgmstream.c @@ -188,6 +188,7 @@ char * extension_list[] = { "ymf\0YMF Audio File (*.YMF)\0", "ccc\0CCC Audio File (*.CCC)\0", "fag\0FAG Audio File (*.FAG)\0", + "mihb\0MIHB Audio File (*.MIHB)\0", }; void about(HWND hwndParent) {