mirror of
https://github.com/vgmstream/vgmstream.git
synced 2025-01-19 00:04:04 +01:00
Added WBK format [Spider-Man 2, Ultimate Spider-Man]
This commit is contained in:
parent
1355279f2a
commit
385a105426
@ -592,6 +592,7 @@ static const char* extension_list[] = {
|
|||||||
"wb",
|
"wb",
|
||||||
"wb2",
|
"wb2",
|
||||||
"wbd",
|
"wbd",
|
||||||
|
"wbk",
|
||||||
"wd",
|
"wd",
|
||||||
"wem",
|
"wem",
|
||||||
"wii",
|
"wii",
|
||||||
@ -1381,6 +1382,7 @@ static const meta_info meta_info_list[] = {
|
|||||||
{meta_PSB, "M2 PSB header"},
|
{meta_PSB, "M2 PSB header"},
|
||||||
{meta_LOPU_FB, "French-Bread LOPU header"},
|
{meta_LOPU_FB, "French-Bread LOPU header"},
|
||||||
{meta_LPCM_FB, "French-Bread LPCM header"},
|
{meta_LPCM_FB, "French-Bread LPCM header"},
|
||||||
|
{meta_WBK, "Treyarch WBK 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) {
|
||||||
|
@ -254,6 +254,7 @@
|
|||||||
<ClCompile Include="meta\sgxd.c" />
|
<ClCompile Include="meta\sgxd.c" />
|
||||||
<ClCompile Include="meta\silence.c" />
|
<ClCompile Include="meta\silence.c" />
|
||||||
<ClCompile Include="meta\sk_aud.c" />
|
<ClCompile Include="meta\sk_aud.c" />
|
||||||
|
<ClCompile Include="meta\wbk.c" />
|
||||||
<ClCompile Include="meta\xwav.c" />
|
<ClCompile Include="meta\xwav.c" />
|
||||||
<ClCompile Include="meta\seg.c" />
|
<ClCompile Include="meta\seg.c" />
|
||||||
<ClCompile Include="meta\sfh.c" />
|
<ClCompile Include="meta\sfh.c" />
|
||||||
|
@ -1946,13 +1946,16 @@
|
|||||||
<Filter>meta\Source Files</Filter>
|
<Filter>meta\Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="util\chunks.c">
|
<ClCompile Include="util\chunks.c">
|
||||||
<Filter>util\Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="util\log.c">
|
<ClCompile Include="util\log.c">
|
||||||
<Filter>util\Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="util\m2_psb.c">
|
<ClCompile Include="util\m2_psb.c">
|
||||||
<Filter>util\Source Files</Filter>
|
<Filter>Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
|
<ClCompile Include="meta\wbk.c">
|
||||||
|
<Filter>meta\Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
@ -969,4 +969,6 @@ VGMSTREAM* init_vgmstream_lopu_fb(STREAMFILE* sf);
|
|||||||
|
|
||||||
VGMSTREAM* init_vgmstream_lpcm_fb(STREAMFILE* sf);
|
VGMSTREAM* init_vgmstream_lpcm_fb(STREAMFILE* sf);
|
||||||
|
|
||||||
|
VGMSTREAM* init_vgmstream_wbk(STREAMFILE* sf);
|
||||||
|
|
||||||
#endif /*_META_H*/
|
#endif /*_META_H*/
|
||||||
|
155
src/meta/wbk.c
Normal file
155
src/meta/wbk.c
Normal file
@ -0,0 +1,155 @@
|
|||||||
|
#include "meta.h"
|
||||||
|
#include "../coding/coding.h"
|
||||||
|
|
||||||
|
/* .WBK - seen in some Treyarch games [Spider-Man 2, Ultimate Spider-Man, Call of Duty 2: Big Red One] */
|
||||||
|
VGMSTREAM* init_vgmstream_wbk(STREAMFILE* sf) {
|
||||||
|
VGMSTREAM* vgmstream = NULL;
|
||||||
|
uint32_t table_offset, entry_offset, data_offset, streams_offset, strings_offset, strings_size, coefsec_offset,
|
||||||
|
name_offset, codec, flags, channels, sound_offset, sound_size, num_samples, sample_rate;
|
||||||
|
int target_subsong = sf->stream_index, total_subsongs, loop_flag, has_names, i;
|
||||||
|
|
||||||
|
/* checks */
|
||||||
|
if (!is_id32be(0x00, sf, "WAVE") ||
|
||||||
|
!is_id32be(0x04, sf, "BK11"))
|
||||||
|
goto fail;
|
||||||
|
|
||||||
|
/* checks */
|
||||||
|
if (!check_extensions(sf, "wbk"))
|
||||||
|
goto fail;
|
||||||
|
|
||||||
|
/* always little endian, even on GC */
|
||||||
|
data_offset = read_u32le(0x10, sf);
|
||||||
|
//data_size = read_u32le(0x14, sf);
|
||||||
|
streams_offset = read_u32le(0x18, sf);
|
||||||
|
//streams_size = read_u32le(0x1c, sf);
|
||||||
|
|
||||||
|
total_subsongs = read_u32le(0x40, sf);
|
||||||
|
table_offset = read_u32le(0x44, sf);
|
||||||
|
|
||||||
|
if (target_subsong == 0) target_subsong = 1;
|
||||||
|
if (target_subsong < 0 || target_subsong > total_subsongs || total_subsongs < 1)
|
||||||
|
goto fail;
|
||||||
|
|
||||||
|
//paramsec_size = read_u32le(0x50, sf);
|
||||||
|
//paramsec_offset = read_u32le(0x54, sf);
|
||||||
|
//coefsec_size = read_u32le(0x58, sf);
|
||||||
|
coefsec_offset = read_u32le(0x5c, sf);
|
||||||
|
strings_size = read_u32le(0x60, sf);
|
||||||
|
strings_offset = read_u32le(0x64, sf);
|
||||||
|
|
||||||
|
/* Ultimate Spider-Man has no names, only name hashes */
|
||||||
|
{
|
||||||
|
size_t len;
|
||||||
|
|
||||||
|
/* check if the first sound points at the first or the second string */
|
||||||
|
len = read_string(NULL, STREAM_NAME_SIZE, strings_offset, sf);
|
||||||
|
name_offset = read_u32le(table_offset + 0x00, sf);
|
||||||
|
has_names = (name_offset == 0x00 || name_offset == len + 0x01);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 0x00: name offset/name hash
|
||||||
|
* 0x04: codec
|
||||||
|
* 0x05: flags
|
||||||
|
* 0x06: channel mask (can actually only be mono or stereo)
|
||||||
|
* 0x07: padding
|
||||||
|
* 0x08: sound size
|
||||||
|
* 0x0c: number of samples
|
||||||
|
* 0x10: group name offset
|
||||||
|
* 0x14: parameters offset
|
||||||
|
* 0x18: DSP coefs offset, usually not set (-1)
|
||||||
|
* 0x1c: sound offset
|
||||||
|
* 0x20: sample rate
|
||||||
|
* 0x24: always 0?
|
||||||
|
*
|
||||||
|
* struct slightly changed in Call of Duty 2 but still compatible
|
||||||
|
*/
|
||||||
|
entry_offset = table_offset + (target_subsong - 1) * 0x28;
|
||||||
|
name_offset = read_u32le(entry_offset + 0x00, sf);
|
||||||
|
codec = read_u8(entry_offset + 0x04, sf);
|
||||||
|
flags = read_u8(entry_offset + 0x05, sf);
|
||||||
|
channels = read_u8(entry_offset + 0x06, sf) == 0x03 ? 2 : 1;
|
||||||
|
sound_size = read_u32le(entry_offset + 0x08, sf);
|
||||||
|
num_samples = read_u32le(entry_offset + 0x0c, sf);
|
||||||
|
sound_offset = read_u32le(entry_offset + 0x1c, sf);
|
||||||
|
sample_rate = read_u16le(entry_offset + 0x20, sf);
|
||||||
|
|
||||||
|
if (!(flags & 0x02)) /* streamed sounds have absolute offset */
|
||||||
|
sound_offset += data_offset;
|
||||||
|
|
||||||
|
loop_flag = (flags & 0x08);
|
||||||
|
|
||||||
|
/* build the VGMSTREAM */
|
||||||
|
vgmstream = allocate_vgmstream(channels, loop_flag);
|
||||||
|
if (!vgmstream) goto fail;
|
||||||
|
|
||||||
|
/* fill in the vital statistics */
|
||||||
|
vgmstream->meta_type = meta_WBK;
|
||||||
|
vgmstream->sample_rate = sample_rate;
|
||||||
|
vgmstream->stream_size = sound_size;
|
||||||
|
vgmstream->num_samples = num_samples;
|
||||||
|
vgmstream->loop_start_sample = 0;
|
||||||
|
vgmstream->loop_end_sample = num_samples; /* full loops only */
|
||||||
|
vgmstream->num_streams = total_subsongs;
|
||||||
|
|
||||||
|
switch (codec) {
|
||||||
|
case 0x03: { /* DSP */
|
||||||
|
uint32_t coef_offset;
|
||||||
|
uint16_t coef_table[16] = {
|
||||||
|
0x0216,0xfc9f,0x026c,0x04b4,0x065e,0xfdec,0x0a11,0xfd1e,
|
||||||
|
0x0588,0xfc38,0x05ad,0x01da,0x083b,0xfdbc,0x08c3,0xff18
|
||||||
|
};
|
||||||
|
|
||||||
|
vgmstream->coding_type = coding_NGC_DSP;
|
||||||
|
vgmstream->layout_type = layout_interleave;
|
||||||
|
vgmstream->interleave_block_size = 0x8000;
|
||||||
|
|
||||||
|
coef_offset = read_u32le(entry_offset + 0x18, sf);
|
||||||
|
if (coef_offset == UINT32_MAX || coefsec_offset == 0x00) {
|
||||||
|
/* hardcoded coef table */
|
||||||
|
for (i = 0; i < vgmstream->channels; i++)
|
||||||
|
memcpy(vgmstream->ch[i].adpcm_coef, coef_table, sizeof(coef_table));
|
||||||
|
} else {
|
||||||
|
if (coefsec_offset == UINT32_MAX)
|
||||||
|
goto fail;
|
||||||
|
|
||||||
|
dsp_read_coefs_be(vgmstream, sf, coefsec_offset + coef_offset, 0x28);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case 0x04: /* PSX */
|
||||||
|
vgmstream->coding_type = coding_PSX;
|
||||||
|
vgmstream->layout_type = layout_interleave;
|
||||||
|
vgmstream->interleave_block_size = 0x800;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 0x05: /* XBOX */
|
||||||
|
vgmstream->coding_type = coding_XBOX_IMA;
|
||||||
|
vgmstream->layout_type = layout_none;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 0x07: /* IMA */
|
||||||
|
vgmstream->coding_type = coding_IMA;
|
||||||
|
vgmstream->layout_type = layout_none;
|
||||||
|
|
||||||
|
/* for some reason, number of samples is off for IMA */
|
||||||
|
vgmstream->num_samples = ima_bytes_to_samples(sound_size, channels);
|
||||||
|
vgmstream->loop_end_sample = vgmstream->num_samples;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (has_names)
|
||||||
|
read_string(vgmstream->stream_name, STREAM_NAME_SIZE, strings_offset + name_offset, sf);
|
||||||
|
else
|
||||||
|
snprintf(vgmstream->stream_name, STREAM_NAME_SIZE, "%08x", name_offset);
|
||||||
|
|
||||||
|
if (!vgmstream_open_stream(vgmstream, sf, sound_offset))
|
||||||
|
goto fail;
|
||||||
|
return vgmstream;
|
||||||
|
|
||||||
|
fail:
|
||||||
|
close_vgmstream(vgmstream);
|
||||||
|
return NULL;
|
||||||
|
}
|
@ -525,6 +525,7 @@ VGMSTREAM* (*init_vgmstream_functions[])(STREAMFILE* sf) = {
|
|||||||
init_vgmstream_psb,
|
init_vgmstream_psb,
|
||||||
init_vgmstream_lopu_fb,
|
init_vgmstream_lopu_fb,
|
||||||
init_vgmstream_lpcm_fb,
|
init_vgmstream_lpcm_fb,
|
||||||
|
init_vgmstream_wbk,
|
||||||
|
|
||||||
/* lowest priority metas (should go after all metas, and TXTH should go before raw formats) */
|
/* lowest priority metas (should go after all metas, and TXTH should go before raw formats) */
|
||||||
init_vgmstream_txth, /* proper parsers should supersede TXTH, once added */
|
init_vgmstream_txth, /* proper parsers should supersede TXTH, once added */
|
||||||
|
@ -752,6 +752,7 @@ typedef enum {
|
|||||||
meta_PSB,
|
meta_PSB,
|
||||||
meta_LOPU_FB,
|
meta_LOPU_FB,
|
||||||
meta_LPCM_FB,
|
meta_LPCM_FB,
|
||||||
|
meta_WBK,
|
||||||
|
|
||||||
} meta_t;
|
} meta_t;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user