mirror of
https://github.com/vgmstream/vgmstream.git
synced 2024-11-24 15:00:11 +01:00
Add Relic .wxd+wxh and .bnk [Homeworld (PC)]
This commit is contained in:
parent
adf3d3d3b0
commit
970139f992
@ -594,6 +594,7 @@ static const char* extension_list[] = {
|
||||
"wve",
|
||||
"wvs",
|
||||
"wvx",
|
||||
"wxd",
|
||||
|
||||
"x",
|
||||
"x360audio", //fake extension for Unreal Engine 3 XMA (real extension unknown)
|
||||
@ -1353,6 +1354,8 @@ static const meta_info meta_info_list[] = {
|
||||
{meta_DSP_KWA, "Kuju London .KWA header"},
|
||||
{meta_OGV_3RDEYE, "3rdEye .OGV header"},
|
||||
{meta_PIFF_TPCM, "Tantalus PIFF TPCM header"},
|
||||
{meta_WXD_WXH, "Relic WXD+WXH header"},
|
||||
{meta_BNK_RELIC, "Relic BNK header"},
|
||||
};
|
||||
|
||||
void get_vgmstream_coding_description(VGMSTREAM* vgmstream, char* out, size_t out_size) {
|
||||
|
@ -309,6 +309,7 @@
|
||||
<ClCompile Include="meta\bik.c" />
|
||||
<ClCompile Include="meta\bkhd.c" />
|
||||
<ClCompile Include="meta\bmp_konami.c" />
|
||||
<ClCompile Include="meta\bnk_relic.c" />
|
||||
<ClCompile Include="meta\bnk_sony.c" />
|
||||
<ClCompile Include="meta\bnsf.c" />
|
||||
<ClCompile Include="meta\brstm.c" />
|
||||
@ -570,6 +571,7 @@
|
||||
<ClCompile Include="meta\wsi.c" />
|
||||
<ClCompile Include="meta\wv6.c" />
|
||||
<ClCompile Include="meta\wvs.c" />
|
||||
<ClCompile Include="meta\wxd_wxh.c" />
|
||||
<ClCompile Include="meta\wwise.c" />
|
||||
<ClCompile Include="meta\xau.c" />
|
||||
<ClCompile Include="meta\xavs.c" />
|
||||
|
@ -1207,6 +1207,9 @@
|
||||
<ClCompile Include="meta\wvs.c">
|
||||
<Filter>meta\Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="meta\wxd_wxh.c">
|
||||
<Filter>meta\Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="meta\wwise.c">
|
||||
<Filter>meta\Source Files</Filter>
|
||||
</ClCompile>
|
||||
@ -1831,6 +1834,9 @@
|
||||
<ClCompile Include="meta\bmp_konami.c">
|
||||
<Filter>meta\Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="meta\bnk_relic.c">
|
||||
<Filter>meta\Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="meta\bnk_sony.c">
|
||||
<Filter>meta\Source Files</Filter>
|
||||
</ClCompile>
|
||||
|
80
src/meta/bnk_relic.c
Normal file
80
src/meta/bnk_relic.c
Normal file
@ -0,0 +1,80 @@
|
||||
#include "meta.h"
|
||||
#include "../coding/coding.h"
|
||||
|
||||
/* BNK - sfx container from Relic's earlier games [Homeworld (PC), Homeworld Cataclysm (PC)] */
|
||||
VGMSTREAM* init_vgmstream_bnk_relic(STREAMFILE* sf) {
|
||||
VGMSTREAM* vgmstream = NULL;
|
||||
uint32_t start_offset, offset, data_size, loop_start, loop_end;
|
||||
int loop_flag, channels, bitrate, internal_rate, sample_rate;
|
||||
int total_subsongs, target_subsong = sf->stream_index;
|
||||
|
||||
|
||||
/* checks */
|
||||
if (!check_extensions(sf, "bnk"))
|
||||
goto fail;
|
||||
if (!is_id32be(0x00,sf, "BNK0"))
|
||||
goto fail;
|
||||
/* 0x04: flags? */
|
||||
|
||||
total_subsongs = read_u32le(0x08,sf);
|
||||
if (target_subsong == 0) target_subsong = 1;
|
||||
if (target_subsong < 0 || target_subsong > total_subsongs || total_subsongs < 1) goto fail;
|
||||
|
||||
offset = 0x0c + (target_subsong-1) * 0x38;
|
||||
if (!is_id32be(offset + 0x00,sf, "PCH0"))
|
||||
goto fail;
|
||||
/* 0x04: null */
|
||||
/* 0x08: 0/+-number? */
|
||||
start_offset = read_u32le(offset + 0x0c,sf);
|
||||
data_size = read_u32le(offset + 0x10,sf);
|
||||
loop_start = read_u32le(offset + 0x14,sf); /* 0x14: 0/offset? */
|
||||
loop_end = read_u32le(offset + 0x18,sf); /* 0x18: 0/offset? */
|
||||
bitrate = read_u16le(offset + 0x1c,sf);
|
||||
loop_flag = read_u16le(offset + 0x1e,sf);
|
||||
/* 0x20: volume? */
|
||||
/* 0x22: -1 */
|
||||
/* 0x24: fmt pcm codec 1 */
|
||||
channels = read_u16le(offset + 0x26,sf);
|
||||
sample_rate = read_u32le(offset + 0x28,sf);
|
||||
/* 0x2c: bitrate */
|
||||
/* 0x30: pcm block size */
|
||||
/* 0x32: pcm bps */
|
||||
/* 0x34: 0 */
|
||||
/* 0x36: -1 */
|
||||
|
||||
internal_rate = 44100;
|
||||
|
||||
loop_flag = 0; //todo clicks on loop, wrong calcs?
|
||||
|
||||
/* stream info */
|
||||
if (!is_id32be(start_offset - 0x04,sf, "DATA"))
|
||||
goto fail;
|
||||
|
||||
|
||||
/* build the VGMSTREAM */
|
||||
vgmstream = allocate_vgmstream(channels, loop_flag);
|
||||
if (!vgmstream) goto fail;
|
||||
|
||||
vgmstream->meta_type = meta_BNK_RELIC;
|
||||
vgmstream->sample_rate = sample_rate;
|
||||
|
||||
vgmstream->num_samples = relic_bytes_to_samples(data_size, channels, bitrate);
|
||||
vgmstream->loop_start_sample = relic_bytes_to_samples(loop_start, channels, bitrate);
|
||||
vgmstream->loop_end_sample = relic_bytes_to_samples(loop_end, channels, bitrate);
|
||||
|
||||
vgmstream->num_streams = total_subsongs;
|
||||
vgmstream->stream_size = data_size;
|
||||
|
||||
vgmstream->codec_data = init_relic(channels, bitrate, internal_rate);
|
||||
if (!vgmstream->codec_data) goto fail;
|
||||
vgmstream->coding_type = coding_RELIC;
|
||||
vgmstream->layout_type = layout_none;
|
||||
|
||||
if (!vgmstream_open_stream(vgmstream, sf, start_offset))
|
||||
goto fail;
|
||||
return vgmstream;
|
||||
|
||||
fail:
|
||||
close_vgmstream(vgmstream);
|
||||
return NULL;
|
||||
}
|
@ -1,22 +1,19 @@
|
||||
#include "meta.h"
|
||||
#include "../coding/coding.h"
|
||||
|
||||
|
||||
/* FDA - from Relic Entertainment games [Warhammer 4000: Dawn of War (PC)] */
|
||||
VGMSTREAM * init_vgmstream_fda(STREAMFILE *sf) {
|
||||
VGMSTREAM * vgmstream = NULL;
|
||||
VGMSTREAM* init_vgmstream_fda(STREAMFILE* sf) {
|
||||
VGMSTREAM* vgmstream = NULL;
|
||||
off_t start_offset;
|
||||
int loop_flag, channel_count, bitrate, sample_rate, num_samples;
|
||||
int loop_flag, channels, bitrate, sample_rate, num_samples;
|
||||
|
||||
|
||||
/* checks */
|
||||
if (!check_extensions(sf, "fda"))
|
||||
goto fail;
|
||||
|
||||
if (read_u32be(0x00, sf) != 0x52656C69 || /* "Reli" */
|
||||
read_u32be(0x04, sf) != 0x63204368 || /* "c Ch" */
|
||||
read_u32be(0x08, sf) != 0x756E6B79 || /* "unky" */
|
||||
read_u32be(0x0c, sf) != 0x0D0A1A00) /* "\r\n\1a\00"*/
|
||||
if (!is_id64be(0x00, sf, "Relic Ch") ||
|
||||
!is_id64be(0x08, sf, "unky\r\n\x1a\x00"))
|
||||
goto fail;
|
||||
|
||||
/* version? (later .fda change this) */
|
||||
@ -38,18 +35,18 @@ VGMSTREAM * init_vgmstream_fda(STREAMFILE *sf) {
|
||||
offset += 0x14 + name_size + chunk_size;
|
||||
|
||||
/* FOLD-FDA (folder of chunks) */
|
||||
if (read_u32be(offset + 0x04, sf) != 0x46444120) /* "FDA " */
|
||||
if (!is_id32be(offset + 0x04, sf, "FDA "))
|
||||
goto fail;
|
||||
offset += 0x14;
|
||||
|
||||
/* DATA-INFO (header) */
|
||||
if (read_u32be(offset + 0x04, sf) != 0x494E464F) /* "INFO" */
|
||||
if (!is_id32be(offset + 0x04, sf, "INFO"))
|
||||
goto fail;
|
||||
chunk_size = read_u32le(offset + 0x0c, sf);
|
||||
name_size = read_u32le(offset + 0x10, sf);
|
||||
offset += 0x14 + name_size;
|
||||
|
||||
channel_count = read_s32le(offset + 0x00, sf);
|
||||
channels = read_s32le(offset + 0x00, sf);
|
||||
/* 0x04: bps */
|
||||
bitrate = read_s32le(offset + 0x08, sf);
|
||||
sample_rate = read_s32le(offset + 0x0c, sf);
|
||||
@ -60,28 +57,28 @@ VGMSTREAM * init_vgmstream_fda(STREAMFILE *sf) {
|
||||
offset += chunk_size;
|
||||
|
||||
/* DATA-DATA (data) */
|
||||
if (read_u32be(offset + 0x04, sf) != 0x44415441) /* "DATA" */
|
||||
if (!is_id32be(offset + 0x04, sf, "DATA"))
|
||||
goto fail;
|
||||
chunk_size = read_u32le(offset + 0x0c, sf);
|
||||
name_size = read_u32le(offset + 0x10, sf);
|
||||
offset += 0x14 + name_size;
|
||||
|
||||
data_size = read_s32le(offset + 0x00, sf);
|
||||
data_size = read_u32le(offset + 0x00, sf);
|
||||
|
||||
start_offset = offset + 0x04;
|
||||
num_samples = data_size / channel_count / (bitrate / 8) * 512;
|
||||
num_samples = relic_bytes_to_samples(data_size, channels, bitrate);
|
||||
}
|
||||
|
||||
|
||||
/* build the VGMSTREAM */
|
||||
vgmstream = allocate_vgmstream(channel_count, loop_flag);
|
||||
vgmstream = allocate_vgmstream(channels, loop_flag);
|
||||
if (!vgmstream) goto fail;
|
||||
|
||||
vgmstream->meta_type = meta_FDA;
|
||||
vgmstream->sample_rate = 44100; /* fixed output */
|
||||
vgmstream->num_samples = num_samples;
|
||||
|
||||
vgmstream->codec_data = init_relic(channel_count, bitrate, sample_rate);
|
||||
vgmstream->codec_data = init_relic(channels, bitrate, sample_rate);
|
||||
if (!vgmstream->codec_data) goto fail;
|
||||
vgmstream->coding_type = coding_RELIC;
|
||||
vgmstream->layout_type = layout_none;
|
||||
|
@ -955,4 +955,8 @@ VGMSTREAM* init_vgmstream_sspr(STREAMFILE* sf);
|
||||
|
||||
VGMSTREAM* init_vgmstream_piff_tpcm(STREAMFILE* sf);
|
||||
|
||||
VGMSTREAM* init_vgmstream_wxd_wxh(STREAMFILE* sf);
|
||||
|
||||
VGMSTREAM* init_vgmstream_bnk_relic(STREAMFILE* sf);
|
||||
|
||||
#endif /*_META_H*/
|
||||
|
76
src/meta/wxd_wxh.c
Normal file
76
src/meta/wxd_wxh.c
Normal file
@ -0,0 +1,76 @@
|
||||
#include "meta.h"
|
||||
#include "../coding/coding.h"
|
||||
|
||||
/* WXD+WXH - stream container from Relic's earlier games [Homeworld (PC), Homeworld Cataclysm (PC)] */
|
||||
VGMSTREAM* init_vgmstream_wxd_wxh(STREAMFILE* sf) {
|
||||
VGMSTREAM* vgmstream = NULL;
|
||||
STREAMFILE* sh = NULL;
|
||||
uint32_t start_offset, offset, data_size;
|
||||
int loop_flag, channels, bitrate, internal_rate;
|
||||
int total_subsongs, target_subsong = sf->stream_index;
|
||||
|
||||
|
||||
/* checks */
|
||||
if (!check_extensions(sf, "wxd"))
|
||||
goto fail;
|
||||
if (!is_id32be(0x00,sf, "WXD1"))
|
||||
goto fail;
|
||||
/* 0x04: crc? */
|
||||
|
||||
/* companion .wxh found in .big bigfiles, must extract and put together */
|
||||
sh = open_streamfile_by_ext(sf,"wxh");
|
||||
if (!sh) goto fail;
|
||||
|
||||
if (!is_id32be(0x00,sh, "WXH1"))
|
||||
goto fail;
|
||||
/* 0x04: crc? */
|
||||
|
||||
total_subsongs = read_u32le(0x08,sh);
|
||||
if (target_subsong == 0) target_subsong = 1;
|
||||
if (target_subsong < 0 || target_subsong > total_subsongs || total_subsongs < 1) goto fail;
|
||||
|
||||
offset = 0x0c + (target_subsong-1) * 0x0c;
|
||||
start_offset = read_u32le(offset + 0x00,sh);
|
||||
loop_flag = read_u16le(offset + 0x04,sh);
|
||||
bitrate = read_u16le(offset + 0x06,sh);
|
||||
/* 0x08: volume (255=max) */
|
||||
channels = read_u8 (offset + 0x09,sh);
|
||||
/* 0x0a: unused (-1) */
|
||||
internal_rate = 44100;
|
||||
|
||||
/* stream info */
|
||||
if (!is_id32be(start_offset + 0x00,sf, "DATA"))
|
||||
goto fail;
|
||||
data_size = read_u32le(start_offset + 0x04,sf);
|
||||
start_offset += 0x08;
|
||||
|
||||
|
||||
/* build the VGMSTREAM */
|
||||
vgmstream = allocate_vgmstream(channels, loop_flag);
|
||||
if (!vgmstream) goto fail;
|
||||
|
||||
vgmstream->meta_type = meta_WXD_WXH;
|
||||
vgmstream->sample_rate = 44100;
|
||||
|
||||
vgmstream->num_samples = relic_bytes_to_samples(data_size, channels, bitrate);
|
||||
vgmstream->loop_start_sample = 0;
|
||||
vgmstream->loop_end_sample = vgmstream->num_samples;
|
||||
|
||||
vgmstream->num_streams = total_subsongs;
|
||||
vgmstream->stream_size = data_size;
|
||||
|
||||
vgmstream->codec_data = init_relic(channels, bitrate, internal_rate);
|
||||
if (!vgmstream->codec_data) goto fail;
|
||||
vgmstream->coding_type = coding_RELIC;
|
||||
vgmstream->layout_type = layout_none;
|
||||
|
||||
if (!vgmstream_open_stream(vgmstream, sf, start_offset))
|
||||
goto fail;
|
||||
close_streamfile(sh);
|
||||
return vgmstream;
|
||||
|
||||
fail:
|
||||
close_streamfile(sh);
|
||||
close_vgmstream(vgmstream);
|
||||
return NULL;
|
||||
}
|
@ -526,6 +526,8 @@ VGMSTREAM* (*init_vgmstream_functions[])(STREAMFILE* sf) = {
|
||||
init_vgmstream_ogv_3rdeye,
|
||||
init_vgmstream_sspr,
|
||||
init_vgmstream_piff_tpcm,
|
||||
init_vgmstream_wxd_wxh,
|
||||
init_vgmstream_bnk_relic,
|
||||
|
||||
/* 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 */
|
||||
|
@ -741,6 +741,8 @@ typedef enum {
|
||||
meta_DSP_KWA,
|
||||
meta_OGV_3RDEYE,
|
||||
meta_PIFF_TPCM,
|
||||
meta_WXD_WXH,
|
||||
meta_BNK_RELIC,
|
||||
} meta_t;
|
||||
|
||||
/* standard WAVEFORMATEXTENSIBLE speaker positions */
|
||||
|
Loading…
Reference in New Issue
Block a user