VGMStream: Updated libvgmstream code base
Some checks failed
Check if Cog buildable / Build Universal Cog.app (push) Has been cancelled

Updated VGMStream to r2023-66-g6eb1f65c

Signed-off-by: Christopher Snowhill <kode54@gmail.com>
This commit is contained in:
Christopher Snowhill 2025-07-17 03:43:02 -07:00
parent bfc0a540de
commit b9ced57d5f
28 changed files with 1319 additions and 1069 deletions

View file

@ -10,7 +10,6 @@ void decode_tantalus(VGMSTREAMCHANNEL* stream, sample_t* outbuf, int channelspac
size_t bytes_per_frame, samples_per_frame; size_t bytes_per_frame, samples_per_frame;
int32_t hist1 = stream->adpcm_history1_32; int32_t hist1 = stream->adpcm_history1_32;
int32_t hist2 = stream->adpcm_history2_32;
/* external interleave (fixed size), mono */ /* external interleave (fixed size), mono */

View file

@ -347,6 +347,7 @@ static const char* extension_list[] = {
"mds", "mds",
"mdsp", "mdsp",
"med", "med",
"mhwk",
"mjb", "mjb",
"mi4", //fake extension for .mib (renamed, to be removed) "mi4", //fake extension for .mib (renamed, to be removed)
"mib", "mib",
@ -536,7 +537,7 @@ static const char* extension_list[] = {
"skx", "skx",
"slb", //txth/reserved [THE Nekomura no Hitobito (PS2)] "slb", //txth/reserved [THE Nekomura no Hitobito (PS2)]
"sli", "sli",
"smc", "smh",
"smk", "smk",
"smp", "smp",
"smv", "smv",
@ -558,6 +559,7 @@ static const char* extension_list[] = {
"spsd", "spsd",
"spw", "spw",
"srsa", "srsa",
"srcd",
"ss2", "ss2",
"ssd", //txth/reserved [Zack & Wiki (Wii)] "ssd", //txth/reserved [Zack & Wiki (Wii)]
"ssf", "ssf",
@ -1253,7 +1255,7 @@ static const meta_info meta_info_list[] = {
{meta_LSF_N1NJ4N, "Gizmondo Studios Helsingborg LSF header"}, {meta_LSF_N1NJ4N, "Gizmondo Studios Helsingborg LSF header"},
{meta_XWAV, "feelplus XWAV header"}, {meta_XWAV, "feelplus XWAV header"},
{meta_RAW_SNDS, "PC .snds raw header"}, {meta_RAW_SNDS, "PC .snds raw header"},
{meta_HYPERSCAN_KVAG, "Mattel Hyperscan KVAG"}, {meta_KVAG, "Mattel KVAG header"},
{meta_PSND, "Polarbit PSND header"}, {meta_PSND, "Polarbit PSND header"},
{meta_ADP_WILDFIRE, "Wildfire ADP! header"}, {meta_ADP_WILDFIRE, "Wildfire ADP! header"},
{meta_QD_ADP, "Quantic Dream .ADP header"}, {meta_QD_ADP, "Quantic Dream .ADP header"},
@ -1479,6 +1481,8 @@ static const meta_info meta_info_list[] = {
{meta_AUDIOPKG, "Inevitable .AUDIOPKG header"}, {meta_AUDIOPKG, "Inevitable .AUDIOPKG header"},
{meta_SWAR, "Nintendo SWAR header"}, {meta_SWAR, "Nintendo SWAR header"},
{meta_IVB, "Metro IVB header"}, {meta_IVB, "Metro IVB header"},
{meta_SRCD, "Capcom SRCD header"},
{meta_MHWK, "Broderbund MHWK header"}
}; };
void get_vgmstream_coding_description(VGMSTREAM* vgmstream, char* out, size_t out_size) { void get_vgmstream_coding_description(VGMSTREAM* vgmstream, char* out, size_t out_size) {

View file

@ -3,9 +3,9 @@
//MxCh blocked layout as used by Lego Island //MxCh blocked layout as used by Lego Island
void block_update_mxch(off_t block_offset, VGMSTREAM * vgmstream) { void block_update_mxch(off_t block_offset, VGMSTREAM * vgmstream) {
vgmstream->current_block_offset = block_offset; vgmstream->current_block_offset = block_offset;
vgmstream->next_block_offset = block_offset + vgmstream->next_block_offset = block_offset +
read_32bitLE(vgmstream->current_block_offset+4,vgmstream->ch[0].streamfile)+8; read_32bitLE(vgmstream->current_block_offset+4,vgmstream->ch[0].streamfile)+8;
/* skip pad blocks */ /* skip pad blocks */
while ( while (
read_32bitBE(vgmstream->current_block_offset, read_32bitBE(vgmstream->current_block_offset,

View file

@ -25,13 +25,13 @@ VGMSTREAM* init_vgmstream_astl(STREAMFILE* sf) {
// 28: -1? // 28: -1?
// 2c: -1? // 2c: -1?
if (read_u16le(0x30,sf) != 0x0001) // PCM only // fmt-like
return NULL; int format = read_u16le(0x30 + 0x00, sf);
channels = read_u16le(0x32, sf); channels = read_u16le(0x30 + 0x02, sf);
int sample_rate = read_s32le(0x34,sf); int sample_rate = read_s32le(0x30 + 0x04, sf);
// 38: bitrate // 08: avg bitrate
// 3a: block size // 0a: block size
// 3c: bps // 0e: bps
loop_flag = 0; // unlike X360 no apparent loop info in the files loop_flag = 0; // unlike X360 no apparent loop info in the files
@ -42,11 +42,51 @@ VGMSTREAM* init_vgmstream_astl(STREAMFILE* sf) {
vgmstream->meta_type = meta_ASTL; vgmstream->meta_type = meta_ASTL;
vgmstream->sample_rate = sample_rate; vgmstream->sample_rate = sample_rate;
vgmstream->num_samples = pcm16_bytes_to_samples(data_size, channels);
vgmstream->coding_type = coding_PCM16LE; switch(format) {
vgmstream->layout_type = layout_interleave; case 0x0001:
vgmstream->interleave_block_size = 0x2; vgmstream->num_samples = pcm16_bytes_to_samples(data_size, channels);
vgmstream->coding_type = coding_PCM16LE;
vgmstream->layout_type = layout_interleave;
vgmstream->interleave_block_size = 0x2;
break;
#ifdef VGM_USE_FFMPEG
case 0xFFFE: { // WAVEFORMATEXTENSIBLE
uint32_t avg_bitrate = read_u32le(0x30 + 0x08, sf);
uint16_t block_size = read_u16le(0x30 + 0x0c, sf);
uint32_t channel_layout = read_u32le(0x30 + 0x14, sf);
// actually a GUID but first 32b matches fmt (0x0162 / STATIC_KSDATAFORMAT_SUBTYPE_WMAUDIO3 only?)
uint32_t xwma_format = read_u32le(0x30 + 0x18, sf);
uint32_t dpds_offset = 0x30 + 0x28;
uint32_t dpds_size;
uint32_t offset = dpds_offset;
// TODO channel layout
vgmstream->codec_data = init_ffmpeg_xwma(sf, start_offset, data_size, xwma_format, channels, sample_rate, avg_bitrate, block_size);
if (!vgmstream->codec_data) goto fail;
vgmstream->coding_type = coding_FFmpeg;
vgmstream->layout_type = layout_none;
vgmstream->channel_layout = channel_layout;
// somehow there is no dpds size, so find last value before null padding
while (offset < start_offset) {
uint32_t sample = read_u32le(offset, sf);
if (sample == 0)
break;
offset += 0x04;
}
dpds_size = offset - dpds_offset;
vgmstream->num_samples = xwma_dpds_get_samples(sf, dpds_offset, dpds_size, channels, false);
break;
}
#endif
default:
goto fail;
}
if (!vgmstream_open_stream(vgmstream, sf, start_offset)) if (!vgmstream_open_stream(vgmstream, sf, start_offset))
goto fail; goto fail;

View file

@ -9,7 +9,7 @@ VGMSTREAM * init_vgmstream_bar(STREAMFILE *streamFile) {
off_t start_offset; off_t start_offset;
off_t ch2_start_offset; off_t ch2_start_offset;
int loop_flag; int loop_flag;
int channel_count; int channel_count;
long file_size; long file_size;

View file

@ -175,10 +175,10 @@ VGMSTREAM* init_vgmstream_ea_swvr(STREAMFILE* sf) {
do { do {
block_update(vgmstream->next_block_offset,vgmstream); block_update(vgmstream->next_block_offset,vgmstream);
switch(vgmstream->coding_type) { switch(vgmstream->coding_type) {
case coding_PSX: num_samples = ps_bytes_to_samples(vgmstream->current_block_size,1); break; case coding_PSX: num_samples = ps_bytes_to_samples(vgmstream->current_block_size,1); break;
case coding_NGC_DSP: num_samples = dsp_bytes_to_samples(vgmstream->current_block_size,1); break; case coding_NGC_DSP: num_samples = dsp_bytes_to_samples(vgmstream->current_block_size,1); break;
case coding_PCM8_U_int: num_samples = pcm_bytes_to_samples(vgmstream->current_block_size,1,8); break; case coding_PCM8_U_int: num_samples = pcm_bytes_to_samples(vgmstream->current_block_size,1,8); break;
default: num_samples = 0; break; default: num_samples = 0; break;
} }
vgmstream->num_samples += num_samples; vgmstream->num_samples += num_samples;

View file

@ -50,11 +50,18 @@ VGMSTREAM* init_vgmstream_fsb5_fev_bank(STREAMFILE* sf) {
goto fail; goto fail;
switch(chunk_type) { switch(chunk_type) {
case 0x4C495354: /* "LIST" with "SNDH" (usually v0x28 but also in Fall Guys's BNK_Music_RoundReveal) */ case 0x4C495354: /* "LIST" */
if (read_u32be(offset + 0x04, sf) == 0x534E4448) { // "SNDH" (usually v0x28 but also in Fall Guys's BNK_Music_RoundReveal)
if (read_u32be(offset + 0x04, sf) == get_id32be("SNDH")) {
bank_offset = offset + 0x0c; bank_offset = offset + 0x0c;
bank_size = read_s32le(offset + 0x08,sf); bank_size = read_s32le(offset + 0x08,sf);
} }
// multiple CrankcaseAudio REV ADM3 [Rennsport (PC)]
if (read_u32be(offset + 0x00, sf) == get_id32be("PEFX")) {
bank_offset = offset;
bank_size = chunk_size;
}
break; break;
case 0x534E4448: /* "SNDH" */ case 0x534E4448: /* "SNDH" */

View file

@ -1572,6 +1572,9 @@ static const hcakey_info hcakey_list[] = {
// Sand Land (multi) // Sand Land (multi)
{910990237314908160}, // 0CA47CCB51010000 {910990237314908160}, // 0CA47CCB51010000
// Patapon 1 & 2 Reloaded (PC)
{3316332033470531258}, // 2E05FA69EC4286BA
}; };
#endif #endif

View file

@ -3,38 +3,39 @@
/* IDSP - from Inevitable Entertainment games [Defender (GC)] */ /* IDSP - from Inevitable Entertainment games [Defender (GC)] */
VGMSTREAM * init_vgmstream_idsp_ie(STREAMFILE *streamFile) { VGMSTREAM* init_vgmstream_idsp_ie(STREAMFILE* sf) {
VGMSTREAM * vgmstream = NULL; VGMSTREAM* vgmstream = NULL;
off_t start_offset; off_t start_offset;
int loop_flag, channel_count; int loop_flag, channels;
/* checks */ /* checks */
if ( !check_extensions(streamFile,"idsp") ) if (!is_id32be(0x00, sf, "IDSP"))
goto fail; return NULL;
if (read_32bitBE(0x00,streamFile) != 0x49445350) /* "IDSP" */ if (!check_extensions(sf,"idsp"))
goto fail; return NULL;
channels = read_s32be(0x0C,sf);
if (channels > 2) return NULL;
loop_flag = 0; loop_flag = 0;
channel_count = read_32bitBE(0x0C,streamFile);
if (channel_count > 2) goto fail;
start_offset = 0x70; start_offset = 0x70;
/* build the VGMSTREAM */ /* build the VGMSTREAM */
vgmstream = allocate_vgmstream(channel_count,loop_flag); vgmstream = allocate_vgmstream(channels,loop_flag);
if (!vgmstream) goto fail; if (!vgmstream) goto fail;
vgmstream->meta_type = meta_IDSP_IE; vgmstream->meta_type = meta_IDSP_IE;
vgmstream->sample_rate = read_32bitBE(0x08,streamFile); vgmstream->sample_rate = read_s32be(0x08,sf);
vgmstream->coding_type = coding_NGC_DSP; vgmstream->coding_type = coding_NGC_DSP;
vgmstream->num_samples = dsp_bytes_to_samples(read_32bitBE(0x04,streamFile), channel_count); vgmstream->num_samples = dsp_bytes_to_samples(read_u32be(0x04,sf), channels);
vgmstream->layout_type = layout_interleave; vgmstream->layout_type = layout_interleave;
vgmstream->interleave_block_size = read_32bitBE(0x10,streamFile); vgmstream->interleave_block_size = read_u32be(0x10,sf);
dsp_read_coefs_be(vgmstream,streamFile,0x14,0x2E); dsp_read_coefs_be(vgmstream, sf, 0x14, 0x2E);
if ( !vgmstream_open_stream(vgmstream, streamFile, start_offset) ) if (!vgmstream_open_stream(vgmstream, sf, start_offset))
goto fail; goto fail;
return vgmstream; return vgmstream;

View file

@ -1,54 +1,52 @@
#include "meta.h" #include "meta.h"
#include "../coding/coding.h" #include "../coding/coding.h"
/* .IMC - from iNiS Gitaroo Man (PS2) */ /* .IMC (subfile) - from iNiS Gitaroo Man (PS2) */
VGMSTREAM * init_vgmstream_imc(STREAMFILE *streamFile) { VGMSTREAM* init_vgmstream_imc(STREAMFILE* sf) {
VGMSTREAM * vgmstream = NULL; VGMSTREAM* vgmstream = NULL;
off_t start_offset;
int loop_flag, channel_count, sample_rate, interleave, blocks;
size_t file_size, data_size;
/* checks */ /* checks */
/* .imc: extension from the main container */ /* .imc: extension from the main container */
if (!check_extensions(streamFile, "imc")) if (!check_extensions(sf, "imc"))
goto fail; return NULL;
channel_count = read_32bitLE(0x00, streamFile); int channels = read_s32le(0x00, sf);
sample_rate = read_32bitLE(0x04, streamFile); int sample_rate = read_s32le(0x04, sf);
interleave = read_32bitLE(0x08, streamFile) * 0x10; /* number of frames in a block */ int interleave = read_s32le(0x08, sf) * 0x10; // number of frames in a block
blocks = read_32bitLE(0x0c, streamFile); /* number of interleave blocks (even in mono) */ int blocks = read_s32le(0x0c, sf); // number of interleave blocks (even in mono)
file_size = get_streamfile_size(streamFile); uint32_t start_offset = 0x10;
loop_flag = 0; uint32_t file_size = get_streamfile_size(sf);
start_offset = 0x10; bool loop_flag = false;
/* extra checks since the header is so simple */ // extra checks since the header is so simple
if (channel_count < 1 || channel_count > 8) if (channels < 1 || channels > 8)
goto fail; return NULL;
// Game can play 11025, 16000, 22050, 32000, 44100, 48000. Anything else will be
// silent in-game. ST10.IMC subsongs 42-47 use 22000, those are unused silent audio
if (sample_rate < 11025 || sample_rate > 48000) if (sample_rate < 11025 || sample_rate > 48000)
/* game can play 11025, 16000, 22050, 32000, 44100, 48000. Anything else will be return NULL;
silent in-game. ST10.IMC subsongs 42-47 use 22000, those are unused silent audio */
goto fail;
if (interleave*blocks + start_offset != file_size)
goto fail;
data_size = file_size - start_offset; if (interleave * blocks + start_offset != file_size)
data_size -= ps_find_padding(streamFile, start_offset, data_size, channel_count, interleave, 0); return NULL;
uint32_t data_size = file_size - start_offset;
data_size -= ps_find_padding(sf, start_offset, data_size, channels, interleave, 0);
/* build the VGMSTREAM */ /* build the VGMSTREAM */
vgmstream = allocate_vgmstream(channel_count, loop_flag); vgmstream = allocate_vgmstream(channels, loop_flag);
if (!vgmstream) goto fail; if (!vgmstream) goto fail;
vgmstream->meta_type = meta_IMC; vgmstream->meta_type = meta_IMC;
vgmstream->sample_rate = sample_rate; vgmstream->sample_rate = sample_rate;
vgmstream->num_samples = ps_bytes_to_samples(data_size, channel_count); vgmstream->num_samples = ps_bytes_to_samples(data_size, channels);
vgmstream->coding_type = coding_PSX; vgmstream->coding_type = coding_PSX;
vgmstream->layout_type = layout_interleave; vgmstream->layout_type = layout_interleave;
vgmstream->interleave_block_size = interleave; vgmstream->interleave_block_size = interleave;
if (!vgmstream_open_stream(vgmstream,streamFile,start_offset)) if (!vgmstream_open_stream(vgmstream, sf, start_offset))
goto fail; goto fail;
return vgmstream; return vgmstream;
@ -60,56 +58,56 @@ fail:
/* ****************************************************************************** */ /* ****************************************************************************** */
/* .IMC in containers */ /* .IMC in containers */
VGMSTREAM * init_vgmstream_imc_container(STREAMFILE *streamFile) { VGMSTREAM* init_vgmstream_imc_container(STREAMFILE* sf) {
VGMSTREAM *vgmstream = NULL; VGMSTREAM* vgmstream = NULL;
STREAMFILE *temp_streamFile = NULL; STREAMFILE* temp_sf = NULL;
off_t header_offset, subfile_offset, next_offset, name_offset; off_t header_offset, subfile_offset, next_offset, name_offset;
size_t subfile_size; size_t subfile_size;
int total_subsongs, target_subsong = streamFile->stream_index; int total_subsongs, target_subsong = sf->stream_index;
/* checks */ /* checks */
if (!check_extensions(streamFile, "imc")) if (!check_extensions(sf, "imc"))
goto fail; return NULL;
total_subsongs = read_32bitLE(0x00, streamFile); total_subsongs = read_s32le(0x00, sf);
if (target_subsong == 0) target_subsong = 1; if (target_subsong == 0) target_subsong = 1;
if (target_subsong < 0 || target_subsong > total_subsongs || total_subsongs < 1) goto fail; if (target_subsong < 0 || target_subsong > total_subsongs || total_subsongs < 1) goto fail;
header_offset = 0x04 + 0x20*(target_subsong-1); header_offset = 0x04 + 0x20 * (target_subsong - 1);
name_offset = header_offset + 0x00; name_offset = header_offset + 0x00;
/* 0x08: flags? (0x702ADE77|0x002ADE77|0x20000000|etc) */ /* 0x08: flags? (0x702ADE77|0x002ADE77|0x20000000|etc) */
/* 0x0c: same for all songs in single .imc but varies between .imc */ /* 0x0c: same for all songs in single .imc but varies between .imc */
subfile_offset = read_32bitLE(header_offset + 0x10,streamFile); subfile_offset = read_u32le(header_offset + 0x10,sf);
/* 0x14: flags/size? (0xF0950000|0x3CFA1200|etc) */ /* 0x14: flags/size? (0xF0950000|0x3CFA1200|etc) */
/* 0x18: same for all songs in single .imc but varies between .imc */ /* 0x18: same for all songs in single .imc but varies between .imc */
/* 0x1c: flags? (0 or 2) */ /* 0x1c: flags? (0 or 2) */
if (target_subsong == total_subsongs) { if (target_subsong == total_subsongs) {
next_offset = get_streamfile_size(streamFile); next_offset = get_streamfile_size(sf);
} }
else { else {
next_offset = read_32bitLE(header_offset + 0x20 + 0x10,streamFile); next_offset = read_u32le(header_offset + 0x20 + 0x10,sf);
} }
subfile_size = next_offset - subfile_offset; subfile_size = next_offset - subfile_offset;
temp_streamFile = setup_subfile_streamfile(streamFile, subfile_offset,subfile_size, NULL); temp_sf = setup_subfile_streamfile(sf, subfile_offset,subfile_size, NULL);
if (!temp_streamFile) goto fail; if (!temp_sf) goto fail;
vgmstream = init_vgmstream_imc(temp_streamFile); vgmstream = init_vgmstream_imc(temp_sf);
if (!vgmstream) goto fail; if (!vgmstream) goto fail;
close_streamfile(temp_streamFile);
vgmstream->num_streams = total_subsongs; vgmstream->num_streams = total_subsongs;
read_string(vgmstream->stream_name,0x08+1, name_offset,streamFile); read_string(vgmstream->stream_name,0x08+1, name_offset,sf);
close_streamfile(temp_sf);
return vgmstream; return vgmstream;
fail: fail:
close_streamfile(temp_streamFile); close_streamfile(temp_sf);
close_vgmstream(vgmstream); close_vgmstream(vgmstream);
return NULL; return NULL;
} }

View file

@ -0,0 +1,32 @@
#include "meta.h"
#include "../util/meta_utils.h"
/* KVAG - Mattel Hyperscan games [Marvel Heroes (Hyperscan), X-Men (Hyperscan)] */
VGMSTREAM* init_vgmstream_hyperscan_kvag(STREAMFILE* sf) {
/* checks */
if (!is_id32be(0x00,sf, "KVAG"))
return NULL;
if (!check_extensions(sf,"bvg"))
return NULL;
meta_header_t h = {0};
h.meta = meta_KVAG;
h.stream_size = read_u32le(0x04, sf);
h.sample_rate = read_s32le(0x08, sf);
h.channels = read_s16le(0x0c, sf) + 1;
h.stream_offset = 0x0e;
if (h.channels > 2) // 2ch is rare [Ben 10's Theme22ks]
return NULL;
h.num_samples = ima_bytes_to_samples(h.stream_size, h.channels);
h.coding = coding_DVI_IMA;
h.layout = layout_none;
h.open_stream = true;
h.sf = sf;
return alloc_metastream(&h);
}

View file

@ -1,66 +0,0 @@
#include "meta.h"
#include "../util.h"
/* Mattel Hyperscan,
- Place all metas for this console here (there are just 5 games) */
VGMSTREAM * init_vgmstream_hyperscan_kvag(STREAMFILE *streamFile) {
VGMSTREAM * vgmstream = NULL;
char filename[PATH_LIMIT];
off_t start_offset;
int loop_flag = 0;
int channel_count;
/* check extension, case insensitive */
streamFile->get_name(streamFile,filename,sizeof(filename));
if (strcasecmp("bvg",filename_extension(filename))) goto fail;
/* check header */
if (read_32bitBE(0x00,streamFile) != 0x4B564147) /* "KVAG" */
goto fail;
channel_count = 1;
/* build the VGMSTREAM */
vgmstream = allocate_vgmstream(channel_count,loop_flag);
if (!vgmstream) goto fail;
/* fill in the vital statistics */
start_offset = 0xE;
vgmstream->channels = channel_count;
vgmstream->sample_rate = read_32bitLE(0x8,streamFile);
vgmstream->coding_type = coding_DVI_IMA;
vgmstream->num_samples = read_32bitLE(0x4,streamFile)*2;
#if 0
if (loop_flag) {
vgmstream->loop_start_sample = (read_32bitLE(0x08,streamFile)-1)*28;
vgmstream->loop_end_sample = (read_32bitLE(0x0c,streamFile)-1)*28;
}
#endif
vgmstream->layout_type = layout_none;
vgmstream->meta_type = meta_HYPERSCAN_KVAG;
/* 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;i<channel_count;i++) {
vgmstream->ch[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;
}

View file

@ -2,53 +2,49 @@
#include "../util.h" #include "../util.h"
/* Maxis XA - found in Sim City 3000 (PC), The Sims 2 (PC) */ /* Maxis XA - found in Sim City 3000 (PC), The Sims 2 (PC) */
VGMSTREAM * init_vgmstream_maxis_xa(STREAMFILE *streamFile) { VGMSTREAM* init_vgmstream_maxis_xa(STREAMFILE* sf) {
VGMSTREAM * vgmstream = NULL; VGMSTREAM* vgmstream = NULL;
off_t start_offset;
int avg_byte_rate, channel_count, loop_flag, resolution, sample_align, sample_rate;
/* check extension, case insensitive */ /* checks */
if (!check_extensions(streamFile,"xa")) if ((read_u32be(0x00,sf) & 0xFFFF0000) != get_id32be("XA\0\0")) // 02: "I"/"J"/null (version?)
goto fail; return NULL;
/* check header */ uint32_t pcm_size = read_u32le(0x04,sf);
if ((read_16bitBE(0x00,streamFile) != 0x5841)) /* "XA" */ if (read_u16le(0x08,sf) != 0x0001)
goto fail; return NULL;
/* check format tag */ if (!check_extensions(sf,"xa"))
if ((read_16bitLE(0x08,streamFile) != 0x0001)) return NULL;
goto fail;
channel_count = read_16bitLE(0x0A,streamFile); int channels = read_s16le(0x0A,sf);
sample_rate = read_32bitLE(0x0C,streamFile); int sample_rate = read_s32le(0x0C,sf);
avg_byte_rate = read_32bitLE(0x10,streamFile); int avg_byte_rate = read_s32le(0x10,sf);
sample_align = read_16bitLE(0x14,streamFile); int sample_align = read_u16le(0x14,sf);
resolution = read_16bitLE(0x16,streamFile); int resolution = read_u16le(0x16,sf);
/* check alignment */ /* check alignment */
if (sample_align != (resolution/8)*channel_count) if (sample_align != (resolution / 8) * channels)
goto fail; return NULL;
/* check average byte rate */ /* check average byte rate */
if (avg_byte_rate != sample_rate*sample_align) if (avg_byte_rate != sample_rate * sample_align)
goto fail; return NULL;
loop_flag = 0; off_t start_offset = 0x18;
start_offset = 0x18;
/* build the VGMSTREAM */ /* build the VGMSTREAM */
vgmstream = allocate_vgmstream(channel_count,loop_flag); vgmstream = allocate_vgmstream(channels, false);
if (!vgmstream) goto fail; if (!vgmstream) goto fail;
vgmstream->sample_rate = sample_rate; vgmstream->sample_rate = sample_rate;
vgmstream->num_samples = read_32bitLE(0x04,streamFile)/2/channel_count; vgmstream->num_samples = pcm_size / sizeof(short) / channels;
vgmstream->meta_type = meta_MAXIS_XA; vgmstream->meta_type = meta_MAXIS_XA;
vgmstream->coding_type = coding_MAXIS_XA; vgmstream->coding_type = coding_MAXIS_XA;
vgmstream->layout_type = layout_none; vgmstream->layout_type = layout_none;
/* open streams */ /* open streams */
if (!vgmstream_open_stream(vgmstream,streamFile,start_offset)) if (!vgmstream_open_stream(vgmstream, sf, start_offset))
goto fail; goto fail;
return vgmstream; return vgmstream;

View file

@ -701,7 +701,7 @@ VGMSTREAM * init_vgmstream_msb_msh(STREAMFILE * streamFile);
VGMSTREAM * init_vgmstream_txtp(STREAMFILE * streamFile); VGMSTREAM * init_vgmstream_txtp(STREAMFILE * streamFile);
VGMSTREAM * init_vgmstream_smc_smh(STREAMFILE * streamFile); VGMSTREAM* init_vgmstream_smh_smc(STREAMFILE* sf);
VGMSTREAM * init_vgmstream_ppst(STREAMFILE *streamFile); VGMSTREAM * init_vgmstream_ppst(STREAMFILE *streamFile);
@ -1035,4 +1035,8 @@ VGMSTREAM* init_vgmstream_swar(STREAMFILE* sf);
VGMSTREAM* init_vgmstream_ivb(STREAMFILE* sf); VGMSTREAM* init_vgmstream_ivb(STREAMFILE* sf);
VGMSTREAM* init_vgmstream_mhwk(STREAMFILE* sf);
VGMSTREAM* init_vgmstream_srcd(STREAMFILE* sf);
#endif #endif

View file

@ -0,0 +1,104 @@
#include "meta.h"
#include "../coding/coding.h"
/* MHWK - Broderbund's Mohawk engine (.mhk) */
VGMSTREAM* init_vgmstream_mhwk(STREAMFILE* sf) {
VGMSTREAM* vgmstream = NULL;
off_t start_offset = 0;
int loop_flag = 0, channels = 0, sample_rate = 0, format = 0;
int32_t num_samples = 0, loop_start = 0, loop_end = 0;
off_t current_offset;
uint32_t chunk_id;
uint32_t chunk_size;
/* Check for MHWK magic word */
if (!is_id32be(0x00, sf, "MHWK"))
return NULL;
if (!check_extensions(sf, "mhk"))
return NULL;
/* Check for WAVE magic word, which follows the MHWK header */
if (!is_id32be(0x08, sf, "WAVE"))
goto fail;
current_offset = 0x0C;
while (current_offset < get_streamfile_size(sf)) {
chunk_id = read_u32be(current_offset, sf);
chunk_size = read_u32be(current_offset + 0x04, sf);
current_offset += 0x08;
if (chunk_id == get_id32be("Cue#")) {
current_offset += chunk_size;
continue;
}
else if (chunk_id == get_id32be("ADPC")) {
current_offset += chunk_size;
continue;
}
else if (chunk_id == get_id32be("Data")) {
break;
}
else {
goto fail;
}
}
/* Data chunk header */
/* Header size is consistently 20 bytes from analysis */
sample_rate = read_u16be(current_offset + 0x00, sf);
num_samples = read_u32be(current_offset + 0x02, sf);
/* 0x06: sample width (1 byte), 0x07: channels (1 byte) */
channels = read_u8(current_offset + 0x07, sf);
format = read_u16be(current_offset + 0x08, sf);
if (read_u16be(current_offset + 0x0A, sf) == 0xFFFF) {
loop_flag = 1;
loop_start = read_u32be(current_offset + 0x0C, sf);
loop_end = read_u32be(current_offset + 0x10, sf);
}
/* The actual audio data starts after the header's 20 bytes not 28 bytes */
start_offset = current_offset + 0x14;
vgmstream = allocate_vgmstream(channels, loop_flag);
if (!vgmstream)
goto fail;
vgmstream->meta_type = meta_MHWK;
vgmstream->sample_rate = sample_rate;
vgmstream->num_samples = num_samples;
vgmstream->loop_start_sample = loop_start;
vgmstream->loop_end_sample = loop_end;
/* Determine coding type based on format ID */
switch (format) {
//Myst 1993
case 0x0000: /* 8-bit unsigned PCM. Default */
vgmstream->coding_type = coding_PCM8_U;
vgmstream->layout_type = layout_interleave; // Usually mono.
vgmstream->interleave_block_size = 0x01;
break;
//Carmen Sandiego: Word Detective
case 0x0001: /* IMA ADPCM */
vgmstream->coding_type = coding_IMA;
vgmstream->layout_type = layout_none;
break;
default: /* Unknown format */
goto fail;
}
if (!vgmstream_open_stream(vgmstream, sf, start_offset))
goto fail;
return vgmstream;
fail:
close_vgmstream(vgmstream);
return NULL;
}

View file

@ -7,37 +7,37 @@
static VGMSTREAM* init_vgmstream_mp4_aac_offset(STREAMFILE* sf, uint64_t start, uint64_t size); static VGMSTREAM* init_vgmstream_mp4_aac_offset(STREAMFILE* sf, uint64_t start, uint64_t size);
VGMSTREAM* init_vgmstream_mp4_aac(STREAMFILE* sf) { VGMSTREAM* init_vgmstream_mp4_aac(STREAMFILE* sf) {
return init_vgmstream_mp4_aac_offset( sf, 0x00, get_streamfile_size(sf)); return init_vgmstream_mp4_aac_offset( sf, 0x00, get_streamfile_size(sf));
} }
static VGMSTREAM* init_vgmstream_mp4_aac_offset(STREAMFILE* sf, uint64_t start, uint64_t size) { static VGMSTREAM* init_vgmstream_mp4_aac_offset(STREAMFILE* sf, uint64_t start, uint64_t size) {
VGMSTREAM* vgmstream = NULL; VGMSTREAM* vgmstream = NULL;
mp4_aac_codec_data* data = NULL; mp4_aac_codec_data* data = NULL;
data = init_mp4_aac(sf); data = init_mp4_aac(sf);
if (!data) goto fail; if (!data) goto fail;
int channels = mp4_aac_get_channels(data); int channels = mp4_aac_get_channels(data);
vgmstream = allocate_vgmstream(channels, 0); vgmstream = allocate_vgmstream(channels, 0);
if (!vgmstream) goto fail; if (!vgmstream) goto fail;
vgmstream->sample_rate = mp4_aac_get_sample_rate(data); vgmstream->sample_rate = mp4_aac_get_sample_rate(data);
vgmstream->num_samples = mp4_aac_get_samples(data); vgmstream->num_samples = mp4_aac_get_samples(data);
vgmstream->codec_data = data; vgmstream->codec_data = data;
vgmstream->coding_type = coding_MP4_AAC; vgmstream->coding_type = coding_MP4_AAC;
vgmstream->layout_type = layout_none; vgmstream->layout_type = layout_none;
vgmstream->meta_type = meta_MP4; vgmstream->meta_type = meta_MP4;
return vgmstream; return vgmstream;
fail: fail:
free_mp4_aac(data); free_mp4_aac(data);
if (vgmstream) { if (vgmstream) {
vgmstream->codec_data = NULL; vgmstream->codec_data = NULL;
close_vgmstream(vgmstream); close_vgmstream(vgmstream);
} }
return NULL; return NULL;
} }
#endif #endif

View file

@ -8,8 +8,8 @@ VGMSTREAM * init_vgmstream_pc_mxst(STREAMFILE *streamFile) {
char filename[PATH_LIMIT]; char filename[PATH_LIMIT];
int loop_flag=0; int loop_flag=0;
int bits_per_sample; int bits_per_sample;
int channel_count; int channel_count;
int sample_rate,bytes_per_second; int sample_rate,bytes_per_second;
long sample_count; long sample_count;
int i; int i;
@ -22,7 +22,7 @@ VGMSTREAM * init_vgmstream_pc_mxst(STREAMFILE *streamFile) {
if (strcasecmp("mxst",filename_extension(filename))) goto fail; if (strcasecmp("mxst",filename_extension(filename))) goto fail;
/* looping info not found yet */ /* looping info not found yet */
//loop_flag = get_streamfile_size(streamFile) > 700000; //loop_flag = get_streamfile_size(streamFile) > 700000;
/* check MxSt header */ /* check MxSt header */
if (0x4d785374 != read_32bitBE(0, streamFile)) goto fail; if (0x4d785374 != read_32bitBE(0, streamFile)) goto fail;
@ -172,31 +172,31 @@ VGMSTREAM * init_vgmstream_pc_mxst(STREAMFILE *streamFile) {
start_offset = MxCh; start_offset = MxCh;
} }
/* build the VGMSTREAM */ /* build the VGMSTREAM */
vgmstream = allocate_vgmstream(channel_count,loop_flag); vgmstream = allocate_vgmstream(channel_count,loop_flag);
if (!vgmstream) goto fail; if (!vgmstream) goto fail;
/* fill in the vital statistics */ /* fill in the vital statistics */
vgmstream->channels = channel_count; vgmstream->channels = channel_count;
vgmstream->sample_rate = sample_rate; vgmstream->sample_rate = sample_rate;
vgmstream->layout_type = layout_blocked_mxch; vgmstream->layout_type = layout_blocked_mxch;
vgmstream->meta_type = meta_PC_MXST; vgmstream->meta_type = meta_PC_MXST;
if(bits_per_sample == 8) if(bits_per_sample == 8)
{ {
vgmstream->coding_type = coding_PCM8_U; vgmstream->coding_type = coding_PCM8_U;
} }
else if (bits_per_sample == 16) else if (bits_per_sample == 16)
{ {
vgmstream->coding_type = coding_PCM16LE; vgmstream->coding_type = coding_PCM16LE;
} }
else goto fail; else goto fail;
vgmstream->num_samples = sample_count; vgmstream->num_samples = sample_count;
if(loop_flag) if(loop_flag)
{ {
vgmstream->loop_start_sample = 0; vgmstream->loop_start_sample = 0;
vgmstream->loop_end_sample=vgmstream->num_samples; vgmstream->loop_end_sample=vgmstream->num_samples;
} }
/* open the file for reading by each channel */ /* open the file for reading by each channel */
{ {
for (i=0;i<channel_count;i++) { for (i=0;i<channel_count;i++) {

View file

@ -2,48 +2,49 @@
/* .seb - Game Arts games [Grandia (PS1), Grandia II/III/X (PS2)] */ /* .seb - Game Arts games [Grandia (PS1), Grandia II/III/X (PS2)] */
VGMSTREAM * init_vgmstream_seb(STREAMFILE *streamFile) { VGMSTREAM* init_vgmstream_seb(STREAMFILE* sf) {
VGMSTREAM * vgmstream = NULL; VGMSTREAM* vgmstream = NULL;
off_t start_offset; off_t start_offset;
int loop_flag, channel_count; int loop_flag, channels;
/* checks */ /* checks */
channels = read_32bitLE(0x00,sf);
if (channels > 2)
return NULL;
// 0x08/0c: unknown count, possibly related to looping
/* .seb: found in Grandia II (PS2) .idx */ /* .seb: found in Grandia II (PS2) .idx */
/* .gms: fake? (.stz+idx bigfile without names, except in Grandia II) */ /* .gms: fake? (.stz+idx bigfile without names, except in Grandia II) */
if (!check_extensions(streamFile, "seb,gms,")) if (!check_extensions(sf, "seb,gms,"))
goto fail; return NULL;
channel_count = read_32bitLE(0x00,streamFile);
if (channel_count > 2) goto fail; /* mono or stereo */
/* 0x08/0c: unknown count, possibly related to looping */
start_offset = 0x800; start_offset = 0x800;
if (read_32bitLE(0x10,streamFile) > get_streamfile_size(streamFile) || /* loop start offset */ if (read_u32le(0x10,sf) > get_streamfile_size(sf) || // loop start offset
read_32bitLE(0x18,streamFile) > get_streamfile_size(streamFile)) /* loop end offset */ read_u32le(0x18,sf) > get_streamfile_size(sf)) // loop end offset
goto fail; return NULL;
/* in Grandia III sometimes there is a value at 0x24/34 */ /* in Grandia III sometimes there is a value at 0x24/34 */
loop_flag = (read_32bitLE(0x20,streamFile) == 0); loop_flag = (read_s32le(0x20,sf) == 0);
/* build the VGMSTREAM */ /* build the VGMSTREAM */
vgmstream = allocate_vgmstream(channel_count,loop_flag); vgmstream = allocate_vgmstream(channels,loop_flag);
if (!vgmstream) goto fail; if (!vgmstream) goto fail;
vgmstream->meta_type = meta_SEB; vgmstream->meta_type = meta_SEB;
vgmstream->sample_rate = read_32bitLE(0x04,streamFile); vgmstream->sample_rate = read_s32le(0x04,sf);
vgmstream->num_samples = read_32bitLE(0x1c,streamFile); vgmstream->num_samples = read_s32le(0x1c,sf);
vgmstream->loop_start_sample = read_32bitLE(0x14,streamFile); vgmstream->loop_start_sample = read_s32le(0x14,sf);
vgmstream->loop_end_sample = read_32bitLE(0x1c,streamFile); vgmstream->loop_end_sample = read_s32le(0x1c,sf);
vgmstream->coding_type = coding_PSX; vgmstream->coding_type = coding_PSX;
vgmstream->layout_type = layout_interleave; vgmstream->layout_type = layout_interleave;
vgmstream->interleave_block_size = 0x800; vgmstream->interleave_block_size = 0x800;
if (!vgmstream_open_stream(vgmstream,streamFile,start_offset)) if (!vgmstream_open_stream(vgmstream, sf, start_offset))
goto fail; goto fail;
return vgmstream; return vgmstream;

View file

@ -1,65 +0,0 @@
#include "meta.h"
#include "../coding/coding.h"
/* SMC+SMH - from Wangan Midnight 1/R (System246) */
VGMSTREAM * init_vgmstream_smc_smh(STREAMFILE *streamFile) {
VGMSTREAM * vgmstream = NULL;
STREAMFILE * streamHeader = NULL;
off_t start_offset, header_offset = 0;
size_t stream_size;
int loop_flag = 0, channel_count, sample_rate;
int total_subsongs, target_subsong = streamFile->stream_index;
/* checks */
if (!check_extensions(streamFile, "smc"))
goto fail;
streamHeader = open_streamfile_by_ext(streamFile, "smh");
if (!streamHeader) goto fail;
total_subsongs = read_32bitLE(0x00,streamHeader);
if (target_subsong == 0) target_subsong = 1;
if (target_subsong < 0 || target_subsong > total_subsongs || total_subsongs < 1) goto fail;
if (total_subsongs*0x10 + 0x10 != get_streamfile_size(streamHeader))
goto fail;
header_offset = 0x10 + (target_subsong-1)*0x10;
start_offset = read_32bitLE(header_offset+0x00, streamHeader);
stream_size = read_32bitLE(header_offset+0x04, streamHeader);
sample_rate = read_32bitLE(header_offset+0x08, streamHeader);
/* 0x0c(2): always 0x10, frame size? */
channel_count = read_16bitLE(header_offset+0x0e, streamHeader);
loop_flag = 0;
/* build the VGMSTREAM */
vgmstream = allocate_vgmstream(channel_count,loop_flag);
if (!vgmstream) goto fail;
vgmstream->sample_rate = sample_rate;
vgmstream->num_samples = ps_bytes_to_samples(stream_size,channel_count);
vgmstream->num_streams = total_subsongs;
vgmstream->stream_size = stream_size;
vgmstream->meta_type = meta_SMC_SMH;
vgmstream->coding_type = coding_PSX;
vgmstream->layout_type = layout_interleave;
vgmstream->interleave_block_size = read_32bitLE(0x04, streamHeader);
if (!vgmstream_open_stream(vgmstream,streamFile,start_offset))
goto fail;
close_streamfile(streamHeader);
return vgmstream;
fail:
close_streamfile(streamHeader);
close_vgmstream(vgmstream);
return NULL;
}

View file

@ -0,0 +1,64 @@
#include "meta.h"
#include "../coding/coding.h"
/* SMH+SMC - from Wangan Midnight 1/R (System246) */
VGMSTREAM* init_vgmstream_smh_smc(STREAMFILE* sf) {
VGMSTREAM* vgmstream = NULL;
STREAMFILE* sb = NULL;
off_t start_offset, header_offset = 0;
size_t stream_size;
int loop_flag = 0, channels, sample_rate;
int total_subsongs, target_subsong = sf->stream_index;
/* checks */
if (!check_extensions(sf, "smh"))
return NULL;
total_subsongs = read_s32le(0x00,sf);
if (target_subsong == 0) target_subsong = 1;
if (target_subsong < 0 || target_subsong > total_subsongs || total_subsongs < 1) goto fail;
if (total_subsongs * 0x10 + 0x10 != get_streamfile_size(sf))
return NULL;
sb = open_streamfile_by_ext(sf, "smc");
if (!sb) goto fail;
header_offset = 0x10 + (target_subsong - 1) * 0x10;
start_offset = read_u32le(header_offset+0x00, sf);
stream_size = read_u32le(header_offset+0x04, sf);
sample_rate = read_u32le(header_offset+0x08, sf);
// 0x0c(2): always 0x10, frame size?
channels = read_u16le(header_offset+0x0e, sf);
loop_flag = 0;
/* build the VGMSTREAM */
vgmstream = allocate_vgmstream(channels, loop_flag);
if (!vgmstream) goto fail;
vgmstream->sample_rate = sample_rate;
vgmstream->num_samples = ps_bytes_to_samples(stream_size, channels);
vgmstream->num_streams = total_subsongs;
vgmstream->stream_size = stream_size;
vgmstream->meta_type = meta_SMC_SMH;
vgmstream->coding_type = coding_PSX;
vgmstream->layout_type = layout_interleave;
vgmstream->interleave_block_size = read_32bitLE(0x04, sf);
if (!vgmstream_open_stream(vgmstream, sb, start_offset))
goto fail;
close_streamfile(sb);
return vgmstream;
fail:
close_streamfile(sb);
close_vgmstream(vgmstream);
return NULL;
}

View file

@ -0,0 +1,124 @@
#include "meta.h"
#include "../coding/coding.h"
/* srcd - Capcom RE Engine */
VGMSTREAM* init_vgmstream_srcd(STREAMFILE* sf) {
VGMSTREAM* vgmstream = NULL;
STREAMFILE* subfile = NULL;
off_t start_offset = 0;
int loop_flag = 0;
int32_t loop_start_sample = 0, loop_end_sample = 0;
uint32_t container_type;
const char* extension = NULL;
VGMSTREAM* (*init_vgmstream_function)(STREAMFILE*) = NULL;
if (!is_id32be(0x00, sf, "srcd"))
return NULL;
if (!check_extensions(sf, "srcd,asrc,14,21,26,31"))
return NULL;
{
enum versions { VERSION_31, VERSION_21_26, VERSION_14, VERSION_UNKNOWN };
enum versions ver = VERSION_UNKNOWN;
//v31 - AJ_AAT
if (read_u32le(0x18, sf) > 0x02) {
ver = VERSION_31;
}
//v21 - CAS2
else if (read_u32le(0x41, sf) == 0x49) {
ver = VERSION_21_26;
}
//v26 - GTPD
else if (read_u32le(0x46, sf) == 0x4E) {
ver = VERSION_21_26;
}
//v14 - CAS
else if (read_u8(0x3A, sf) == 0x42) {
ver = VERSION_14;
}
switch (ver) {
case VERSION_31:
loop_flag = read_u8(0x34, sf);
loop_start_sample = read_u32le(0x35, sf);
loop_end_sample = read_u32le(0x39, sf);
break;
case VERSION_21_26:
loop_flag = read_u8(0x2C, sf);
loop_start_sample = read_u32le(0x2D, sf);
loop_end_sample = read_u32le(0x31, sf);
break;
case VERSION_14:
loop_flag = read_u8(0x28, sf);
loop_start_sample = read_u32le(0x29, sf);
loop_end_sample = read_u32le(0x2D, sf);
break;
default:
VGM_LOG("SRCD: Unknown version, disabling loop\n");
loop_flag = 0;
break;
}
}
container_type = read_u32be(0x0C, sf);
{
const off_t scan_start = 0x40;
const size_t scan_size = 0x100; //Should be small
off_t current_offset;
uint32_t magic_to_find = 0;
if (container_type == get_id32be("wav ")) {
magic_to_find = get_id32be("RIFF");
} else if (container_type == get_id32be("ogg ")) {
magic_to_find = get_id32be("OggS");
}
if (magic_to_find) {
for (current_offset = scan_start; current_offset < scan_start + scan_size; current_offset++) {
if (read_u32be(current_offset, sf) == magic_to_find) {
start_offset = current_offset;
break;
}
}
}
}
if (start_offset == 0)
goto fail;
/* Select the appropriate init function and extension based on container type */
if (container_type == get_id32be("wav ")) {
extension = "wav";
init_vgmstream_function = init_vgmstream_riff;
} else if (container_type == get_id32be("ogg ")) {
extension = "ogg";
init_vgmstream_function = init_vgmstream_ogg_vorbis;
} else {
VGM_LOG("SRCD: Codec not recognized");
goto fail;
}
subfile = setup_subfile_streamfile(sf, start_offset, get_streamfile_size(sf) - start_offset, extension);
if (!subfile) goto fail;
vgmstream = init_vgmstream_function(subfile);
if (!vgmstream) goto fail;
vgmstream->meta_type = meta_SRCD;
vgmstream_force_loop(vgmstream, loop_flag, loop_start_sample, loop_end_sample);
close_streamfile(subfile);
return vgmstream;
fail:
close_streamfile(subfile);
close_vgmstream(vgmstream);
return NULL;
}

View file

@ -2,50 +2,50 @@
#include "../coding/coding.h" #include "../coding/coding.h"
/* WV6 - Gorilla Systems PC games [Spy Kids: Mega Mission Zone (PC), Lilo & Stitch: Hawaiian Adventure (PC)] */ /* WV6 - Gorilla Systems PC games [Spy Kids: Mega Mission Zone (PC), Lilo & Stitch: Hawaiian Adventure (PC)] */
VGMSTREAM * init_vgmstream_wv6(STREAMFILE *streamFile) { VGMSTREAM* init_vgmstream_wv6(STREAMFILE* sf) {
VGMSTREAM * vgmstream = NULL; VGMSTREAM* vgmstream = NULL;
off_t start_offset; off_t start_offset;
int loop_flag, channel_count; int loop_flag, channels;
/* checks */ /* checks */
if (!check_extensions(streamFile, "wv6")) if (read_u32le(0x00,sf) != get_streamfile_size(sf))
goto fail; return NULL;
// 04: filename
if (!is_id32be(0x2c,sf, "WV6 ") || !is_id32be(0x30,sf, "IMA_")) // "WV6 IMA_ADPCM COMPRESSED 16 BIT AUDIO"
return NULL;
if (read_32bitLE(0x00,streamFile) != get_streamfile_size(streamFile)) if (!check_extensions(sf, "wv6"))
goto fail; return NULL;
if (read_32bitBE(0x2c,streamFile) != 0x57563620 || /* "WV6 " */
read_32bitBE(0x30,streamFile) != 0x494D415F) /* "IMA_" ("WV6 IMA_ADPCM COMPRESSED 16 BIT AUDIO") */
goto fail;
/* 0x54/58/5c/60/6c: unknown (reject to catch possible stereo files, but don't seem to exist) */ // 0x54/58/5c/60/6c: unknown (reject to catch possible stereo files, but don't seem to exist)
if (read_32bitLE(0x54,streamFile) != 0x01 || if (read_s32le(0x54,sf) != 0x01 ||
read_32bitLE(0x58,streamFile) != 0x01 || read_s32le(0x58,sf) != 0x01 ||
read_32bitLE(0x5c,streamFile) != 0x10 || read_s32le(0x5c,sf) != 0x10 ||
read_32bitLE(0x68,streamFile) != 0x01 || read_s32le(0x68,sf) != 0x01 ||
read_32bitLE(0x6c,streamFile) != 0x88) read_s32le(0x6c,sf) != 0x88)
goto fail; return NULL;
/* 0x64: PCM size (samples*channels*2) */ // 0x64: PCM size (samples * channels * 2)
channel_count = 1; channels = 1;
loop_flag = 0; loop_flag = 0;
start_offset = 0x8c; start_offset = 0x8c;
/* build the VGMSTREAM */ /* build the VGMSTREAM */
vgmstream = allocate_vgmstream(channel_count, loop_flag); vgmstream = allocate_vgmstream(channels, loop_flag);
if (!vgmstream) goto fail; if (!vgmstream) goto fail;
vgmstream->sample_rate = read_32bitLE(0x60, streamFile); vgmstream->sample_rate = read_s32le(0x60, sf);
vgmstream->num_samples = ima_bytes_to_samples(read_32bitLE(0x88,streamFile), channel_count); vgmstream->num_samples = ima_bytes_to_samples(read_u32le(0x88,sf), channels);
vgmstream->meta_type = meta_WV6; vgmstream->meta_type = meta_WV6;
vgmstream->coding_type = coding_WV6_IMA; vgmstream->coding_type = coding_WV6_IMA;
vgmstream->layout_type = layout_none; vgmstream->layout_type = layout_none;
read_string(vgmstream->stream_name,0x1c+1, 0x04,streamFile); read_string(vgmstream->stream_name, 0x1c + 1, 0x04,sf);
if (!vgmstream_open_stream(vgmstream,streamFile,start_offset)) if (!vgmstream_open_stream(vgmstream,sf,start_offset))
goto fail; goto fail;
return vgmstream; return vgmstream;

View file

@ -12,7 +12,7 @@ enum {
VGMSTREAM_MAX_CHANNELS = 64, /* +40ch multilayers */ VGMSTREAM_MAX_CHANNELS = 64, /* +40ch multilayers */
VGMSTREAM_MIN_SAMPLE_RATE = 300, /* 300 is Wwise min */ VGMSTREAM_MIN_SAMPLE_RATE = 300, /* 300 is Wwise min */
VGMSTREAM_MAX_SAMPLE_RATE = 192000, /* found in some FSB5 */ VGMSTREAM_MAX_SAMPLE_RATE = 192000, /* found in some FSB5 */
VGMSTREAM_MAX_SUBSONGS = 65535, /* +20000 isn't that uncommon */ VGMSTREAM_MAX_SUBSONGS = 90000, /* +20000 isn't that uncommon, known max is 89734 in EA NHL 14 sbs+sbr */
VGMSTREAM_MAX_NUM_SAMPLES = 1000000000, /* no ~5h vgm hopefully */ VGMSTREAM_MAX_NUM_SAMPLES = 1000000000, /* no ~5h vgm hopefully */
}; };

View file

@ -317,7 +317,6 @@ init_vgmstream_t init_vgmstream_functions[] = {
init_vgmstream_ubi_lyn_container, init_vgmstream_ubi_lyn_container,
init_vgmstream_msb_msh, init_vgmstream_msb_msh,
init_vgmstream_txtp, init_vgmstream_txtp,
init_vgmstream_smc_smh,
init_vgmstream_ppst, init_vgmstream_ppst,
init_vgmstream_sps_n1_segmented, init_vgmstream_sps_n1_segmented,
init_vgmstream_ubi_bao_pk, init_vgmstream_ubi_bao_pk,
@ -330,7 +329,6 @@ init_vgmstream_t init_vgmstream_functions[] = {
init_vgmstream_xmd, init_vgmstream_xmd,
init_vgmstream_cks, init_vgmstream_cks,
init_vgmstream_ckb, init_vgmstream_ckb,
init_vgmstream_wv6,
init_vgmstream_str_wav, init_vgmstream_str_wav,
init_vgmstream_wavebatch, init_vgmstream_wavebatch,
init_vgmstream_hd3_bd3, init_vgmstream_hd3_bd3,
@ -368,8 +366,6 @@ init_vgmstream_t init_vgmstream_functions[] = {
init_vgmstream_dsp_adpx, init_vgmstream_dsp_adpx,
init_vgmstream_ogg_opus, init_vgmstream_ogg_opus,
init_vgmstream_nus3audio, init_vgmstream_nus3audio,
init_vgmstream_imc,
init_vgmstream_imc_container,
init_vgmstream_smp, init_vgmstream_smp,
init_vgmstream_gin, init_vgmstream_gin,
init_vgmstream_dsf, init_vgmstream_dsf,
@ -512,6 +508,8 @@ init_vgmstream_t init_vgmstream_functions[] = {
init_vgmstream_audiopkg, init_vgmstream_audiopkg,
init_vgmstream_swar, init_vgmstream_swar,
init_vgmstream_ivb, init_vgmstream_ivb,
init_vgmstream_srcd,
init_vgmstream_mhwk,
/* lower priority metas (no clean header identity, somewhat ambiguous, or need extension/companion file to identify) */ /* lower priority metas (no clean header identity, somewhat ambiguous, or need extension/companion file to identify) */
init_vgmstream_agsc, init_vgmstream_agsc,
@ -539,6 +537,10 @@ init_vgmstream_t init_vgmstream_functions[] = {
init_vgmstream_vai, init_vgmstream_vai,
init_vgmstream_ezw, init_vgmstream_ezw,
init_vgmstream_vgs_old, init_vgmstream_vgs_old,
init_vgmstream_imc,
init_vgmstream_imc_container,
init_vgmstream_wv6,
init_vgmstream_smh_smc,
/* need companion files */ /* need companion files */
init_vgmstream_pos, init_vgmstream_pos,
init_vgmstream_sli_loops, init_vgmstream_sli_loops,

View file

@ -496,7 +496,7 @@ typedef enum {
meta_LSF_N1NJ4N, /* .lsf n1nj4n Fastlane Street Racing (iPhone) */ meta_LSF_N1NJ4N, /* .lsf n1nj4n Fastlane Street Racing (iPhone) */
meta_XWAV, meta_XWAV,
meta_RAW_SNDS, meta_RAW_SNDS,
meta_HYPERSCAN_KVAG, /* Hyperscan KVAG/BVG */ meta_KVAG,
meta_PSND, meta_PSND,
meta_ADP_WILDFIRE, meta_ADP_WILDFIRE,
meta_QD_ADP, meta_QD_ADP,
@ -721,6 +721,8 @@ typedef enum {
meta_AUDIOPKG, meta_AUDIOPKG,
meta_SWAR, meta_SWAR,
meta_IVB, meta_IVB,
meta_SRCD,
meta_MHWK
} meta_t; } meta_t;
#endif #endif