Added soneek's experimental CSTM meta for BCSTM support (3DS)

This commit is contained in:
Chris Moeller 2014-02-25 22:31:28 -08:00
parent 43866fd9ed
commit 1ab759bd19
10 changed files with 144 additions and 1 deletions

View File

@ -295,6 +295,7 @@ bool input_vgmstream::g_is_our_path(const char * p_path,const char * p_extension
if(!stricmp_utf8(p_extension,"baka")) return 1;
if(!stricmp_utf8(p_extension,"baf")) return 1;
if(!stricmp_utf8(p_extension,"bar")) return 1;
if(!stricmp_utf8(p_extension,"bcstm")) return 1;
if(!stricmp_utf8(p_extension,"bcwav")) return 1;
if(!stricmp_utf8(p_extension,"bg00")) return 1;
if(!stricmp_utf8(p_extension,"bgw")) return 1;
@ -618,6 +619,7 @@ DECLARE_MULTIPLE_FILE_TYPE("AUS Audio File (*.AUS)", aus);
DECLARE_MULTIPLE_FILE_TYPE("BAKA Audio File (*.BAKA)", baka);
DECLARE_MULTIPLE_FILE_TYPE("BAF Audio File (*.BAF)", baf);
DECLARE_MULTIPLE_FILE_TYPE("BAR Audio File (*.BAR)", bar);
DECLARE_MULTIPLE_FILE_TYPE("BCSTM Audio File (*.BCSTM)", bcstm);
DECLARE_MULTIPLE_FILE_TYPE("BCWAV Audio File (*.BCWAV)", bcwav);
DECLARE_MULTIPLE_FILE_TYPE("BG00 Audio File (*.BG00)", bg00);
DECLARE_MULTIPLE_FILE_TYPE("BGW Audio File (*.BGW)", bgw);

View File

@ -291,7 +291,8 @@ META_OBJS=meta/adx_header.o \
meta/ps2_2pfs.o \
meta/ubi_ckd.o \
meta/ps2_vbk.o \
meta/otm.o
meta/otm.o \
meta/bcstm.o
OBJECTS=vgmstream.o streamfile.o util.o $(CODING_OBJS) $(LAYOUT_OBJS) $(META_OBJS)

View File

@ -248,6 +248,10 @@
RelativePath=".\meta\baf.c"
>
</File>
<File
RelativePath=“.\meta\bcstm.c”
>
</File>
<File
RelativePath=".\meta\bgw.c"
>

View File

@ -236,5 +236,6 @@ libmeta_la_SOURCES += ps3_ivag.c
libmeta_la_SOURCES += ps2_2pfs.c
libmeta_la_SOURCES += ubi_ckd.c
libmeta_la_SOURCES += otm.c
libmeta_la_SOURCES += bcstm.c
EXTRA_DIST = meta.h

126
src/meta/bcstm.c Normal file
View File

@ -0,0 +1,126 @@
#include "meta.h"
#include "../util.h"
VGMSTREAM * init_vgmstream_bcstm(STREAMFILE *streamFile) {
VGMSTREAM * vgmstream = NULL;
char filename[PATH_LIMIT];
coding_t coding_type;
off_t head_offset;
int codec_number;
int channel_count;
int loop_flag;
off_t start_offset;
/* check extension, case insensitive */
streamFile->get_name(streamFile, filename, sizeof(filename));
if (strcasecmp("bcstm", filename_extension(filename)))
goto fail;
/* check header */
if ((uint32_t)read_32bitBE(0, streamFile) != 0x4353544D) /* "CSTM" */
goto fail;
if ((uint32_t)read_32bitBE(4, streamFile) != 0xFFFE4000)
goto fail;
/* get head offset, check */
head_offset = read_32bitLE(0x18, streamFile);
if ((uint32_t)read_32bitBE(head_offset, streamFile) != 0x494E464F) /* "INFO" */
goto fail;
/* check type details */
codec_number = read_8bit(head_offset + 0x20, streamFile);
loop_flag = read_8bit(head_offset + 0x21, streamFile);
channel_count = read_8bit(head_offset + 0x22, streamFile);
switch (codec_number) {
case 0:
coding_type = coding_PCM8;
break;
case 1:
coding_type = coding_PCM16BE;
break;
case 2:
coding_type = coding_NGC_DSP;
break;
default:
goto fail;
}
if (channel_count < 1) goto fail;
/* build the VGMSTREAM */
vgmstream = allocate_vgmstream(channel_count, loop_flag);
if (!vgmstream) goto fail;
/* fill in the vital statistics */
vgmstream->num_samples = read_32bitLE(head_offset + 0x2c, streamFile);
vgmstream->sample_rate = (uint16_t)read_16bitLE(head_offset + 0x24, streamFile);
/* channels and loop flag are set by allocate_vgmstream */
vgmstream->loop_start_sample = read_32bitLE(head_offset + 0x28, streamFile);
vgmstream->loop_end_sample = vgmstream->num_samples;
vgmstream->coding_type = coding_type;
if (channel_count == 1)
vgmstream->layout_type = layout_none;
else
vgmstream->layout_type = layout_interleave_shortblock;
vgmstream->meta_type = meta_CSTM;
vgmstream->interleave_block_size = read_32bitLE(head_offset + 0x34, streamFile);
vgmstream->interleave_smallblock_size = read_32bitLE(head_offset + 0x44, streamFile);
if (vgmstream->coding_type == coding_NGC_DSP) {
off_t coef_offset;
off_t coef_offset1;
off_t coef_offset2;
int i, j;
int coef_spacing = 0x2E;
coef_offset1 = read_32bitLE(head_offset + 0x1c, streamFile);
coef_offset = coef_offset1 + 0x40;
for (j = 0; j<vgmstream->channels; j++) {
for (i = 0; i<16; i++) {
vgmstream->ch[j].adpcm_coef[i] = read_16bitLE(head_offset + coef_offset + j*coef_spacing + i * 2, streamFile);
}
}
}
start_offset = read_32bitLE(0x30, streamFile) + 0x20;
/* open the file for reading by each channel */
{
int i;
for (i = 0; i<channel_count; i++) {
if (vgmstream->layout_type == layout_interleave_shortblock)
vgmstream->ch[i].streamfile = streamFile->open(streamFile, filename,
vgmstream->interleave_block_size);
else
vgmstream->ch[i].streamfile = streamFile->open(streamFile, filename,
0x1000);
if (!vgmstream->ch[i].streamfile) goto fail;
vgmstream->ch[i].channel_start_offset =
vgmstream->ch[i].offset =
start_offset + i*vgmstream->interleave_block_size;
}
}
return vgmstream;
/* clean up anything we may have opened */
fail:
if (vgmstream) close_vgmstream(vgmstream);
return NULL;
}

View File

@ -628,4 +628,6 @@ VGMSTREAM * init_vgmstream_ps2_vbk(STREAMFILE* streamFile);
VGMSTREAM * init_vgmstream_otm(STREAMFILE* streamFile);
VGMSTREAM * init_vgmstream_bcstm(STREAMFILE* streamFile);
#endif

View File

@ -329,6 +329,7 @@ VGMSTREAM * (*init_vgmstream_fcns[])(STREAMFILE *streamFile) = {
init_vgmstream_ubi_ckd,
init_vgmstream_ps2_vbk,
init_vgmstream_otm,
init_vgmstream_bcstm,
};
#define INIT_VGMSTREAM_FCNS (sizeof(init_vgmstream_fcns)/sizeof(init_vgmstream_fcns[0]))
@ -3057,6 +3058,9 @@ void describe_vgmstream(VGMSTREAM * vgmstream, char * desc, int length) {
break;
case meta_OTM:
snprintf(temp,TEMPSIZE,"Otomedius OTM Header");
break;
case meta_CSTM:
snprintf(temp,TEMPSIZE,"Nintendo 3DS CSTM Header");
break;
default:
snprintf(temp,TEMPSIZE,"THEY SHOULD HAVE SENT A POET");

View File

@ -564,6 +564,7 @@ typedef enum {
meta_PS2_2PFS, // Mahoromatic: Moetto - KiraKira Maid-San (PS2)
meta_PS2_VBK,
meta_OTM, // Otomedius (Arcade)
meta_CSTM, // Nintendo 3DS CSTM
#ifdef VGM_USE_MP4V2
meta_MP4,
#endif

View File

@ -42,6 +42,7 @@ gchar *vgmstream_exts [] = {
"baka",
"baf",
"bar",
"bcstm",
"bcwav",
"bg00",
"bgw",

View File

@ -106,6 +106,7 @@ char * extension_list[] = {
"baka\0BAKA Audio File (*.BAKA)\0",
"baf\0BAF Audio File (*.BAF)\0",
"bar\0BAR Audio File (*.BAR)\0",
"bcstm\0BCSTM Audio File (*.BCSTM)\0",
"bcwav\0BCWAV (*.BCWAV)\0",
"bdsp\0BDSP Audio File (*.BDSP)\0",
"bg00\0BG00 Audio File (*.BG00)\0",