mirror of
https://github.com/vgmstream/vgmstream.git
synced 2024-11-28 16:30:54 +01:00
Add .xsh+xsd/xss [KS's Pro Surfer (Xbox)]
This commit is contained in:
parent
02f2245c78
commit
c3e6afd7b6
@ -612,6 +612,7 @@ static const char* extension_list[] = {
|
|||||||
"xma2",
|
"xma2",
|
||||||
"xmu",
|
"xmu",
|
||||||
"xnb",
|
"xnb",
|
||||||
|
"xsh",
|
||||||
"xsf",
|
"xsf",
|
||||||
"xse",
|
"xse",
|
||||||
"xsew",
|
"xsew",
|
||||||
@ -1358,6 +1359,7 @@ static const meta_info meta_info_list[] = {
|
|||||||
{meta_PIFF_TPCM, "Tantalus PIFF TPCM header"},
|
{meta_PIFF_TPCM, "Tantalus PIFF TPCM header"},
|
||||||
{meta_WXD_WXH, "Relic WXD+WXH header"},
|
{meta_WXD_WXH, "Relic WXD+WXH header"},
|
||||||
{meta_BNK_RELIC, "Relic BNK header"},
|
{meta_BNK_RELIC, "Relic BNK header"},
|
||||||
|
{meta_XSH_XSD_XSS, "Treyarch XSH+XSD/XSS 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) {
|
||||||
|
@ -589,6 +589,7 @@
|
|||||||
<ClCompile Include="meta\xpcm.c" />
|
<ClCompile Include="meta\xpcm.c" />
|
||||||
<ClCompile Include="meta\xps.c" />
|
<ClCompile Include="meta\xps.c" />
|
||||||
<ClCompile Include="meta\xse.c" />
|
<ClCompile Include="meta\xse.c" />
|
||||||
|
<ClCompile Include="meta\xsh_xsd_xss.c" />
|
||||||
<ClCompile Include="meta\xss.c" />
|
<ClCompile Include="meta\xss.c" />
|
||||||
<ClCompile Include="meta\xssb.c" />
|
<ClCompile Include="meta\xssb.c" />
|
||||||
<ClCompile Include="meta\xvag.c" />
|
<ClCompile Include="meta\xvag.c" />
|
||||||
|
@ -1828,6 +1828,9 @@
|
|||||||
<ClCompile Include="meta\xse.c">
|
<ClCompile Include="meta\xse.c">
|
||||||
<Filter>meta\Source Files</Filter>
|
<Filter>meta\Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
<ClCompile Include="meta\xsh_xsd_xss.c">
|
||||||
|
<Filter>meta\Source Files</Filter>
|
||||||
|
</ClCompile>
|
||||||
<ClCompile Include="meta\x360_cxs.c">
|
<ClCompile Include="meta\x360_cxs.c">
|
||||||
<Filter>meta\Source Files</Filter>
|
<Filter>meta\Source Files</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
#include "../vgmstream.h"
|
#include "../vgmstream.h"
|
||||||
|
|
||||||
VGMSTREAM* init_vgmstream_silence(int channels, int sample_rate, int32_t num_samples);
|
VGMSTREAM* init_vgmstream_silence(int channels, int sample_rate, int32_t num_samples);
|
||||||
|
VGMSTREAM* init_vgmstream_silence_container(int total_subsongs);
|
||||||
|
|
||||||
|
|
||||||
VGMSTREAM* init_vgmstream_adx(STREAMFILE* sf);
|
VGMSTREAM* init_vgmstream_adx(STREAMFILE* sf);
|
||||||
@ -959,4 +960,6 @@ VGMSTREAM* init_vgmstream_wxd_wxh(STREAMFILE* sf);
|
|||||||
|
|
||||||
VGMSTREAM* init_vgmstream_bnk_relic(STREAMFILE* sf);
|
VGMSTREAM* init_vgmstream_bnk_relic(STREAMFILE* sf);
|
||||||
|
|
||||||
|
VGMSTREAM* init_vgmstream_xsh_xsd_xss(STREAMFILE* sf);
|
||||||
|
|
||||||
#endif /*_META_H*/
|
#endif /*_META_H*/
|
||||||
|
@ -27,3 +27,19 @@ fail:
|
|||||||
close_vgmstream(vgmstream);
|
close_vgmstream(vgmstream);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* silent stream - for containers that have dummy streams but it's a hassle to detect/filter out */
|
||||||
|
VGMSTREAM* init_vgmstream_silence_container(int total_subsongs) {
|
||||||
|
VGMSTREAM* vgmstream = NULL;
|
||||||
|
|
||||||
|
vgmstream = init_vgmstream_silence(0, 0, 0);
|
||||||
|
if (!vgmstream) goto fail;
|
||||||
|
|
||||||
|
vgmstream->num_streams = total_subsongs;
|
||||||
|
snprintf(vgmstream->stream_name, STREAM_NAME_SIZE, "%s", "dummy");
|
||||||
|
|
||||||
|
return vgmstream;
|
||||||
|
fail:
|
||||||
|
close_vgmstream(vgmstream);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
170
src/meta/xsh_xsd_xss.c
Normal file
170
src/meta/xsh_xsd_xss.c
Normal file
@ -0,0 +1,170 @@
|
|||||||
|
#include "meta.h"
|
||||||
|
#include "../coding/coding.h"
|
||||||
|
|
||||||
|
|
||||||
|
/* XSH+XSD/XSS - from Treyarch games [Spider-Man 2002 (Xbox), Kelly Slater's Pro Surfer (Xbox)] */
|
||||||
|
VGMSTREAM* init_vgmstream_xsh_xsd_xss(STREAMFILE* sf) {
|
||||||
|
VGMSTREAM* vgmstream = NULL;
|
||||||
|
STREAMFILE* sf_body = NULL;
|
||||||
|
uint32_t offset;
|
||||||
|
uint32_t stream_type, stream_offset, stream_size;
|
||||||
|
uint32_t name_offset, name_size;
|
||||||
|
uint32_t flags;
|
||||||
|
int32_t num_samples;
|
||||||
|
int version = 0;
|
||||||
|
int loop_flag, channels, codec, sample_rate;
|
||||||
|
int total_subsongs, target_subsong = sf->stream_index;
|
||||||
|
|
||||||
|
|
||||||
|
/* checks */
|
||||||
|
if (!check_extensions(sf, "xsh"))
|
||||||
|
goto fail;
|
||||||
|
|
||||||
|
version = read_u32le(0x00, sf);
|
||||||
|
|
||||||
|
if (read_u32le(0x04, sf) != 0)
|
||||||
|
goto fail;
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
|
switch(version) {
|
||||||
|
case 0x009D:
|
||||||
|
offset = 0x0c + (target_subsong-1) * 0x60;
|
||||||
|
|
||||||
|
name_offset = offset + 0x00;
|
||||||
|
name_size = 0x20;
|
||||||
|
stream_type = read_u32le(offset + 0x20,sf);
|
||||||
|
stream_offset = read_u32le(offset + 0x24,sf);
|
||||||
|
stream_size = read_u32le(offset + 0x28,sf);
|
||||||
|
flags = read_u32le(offset + 0x34,sf);
|
||||||
|
/* 0x38: flags? */
|
||||||
|
num_samples = 0;
|
||||||
|
|
||||||
|
offset = offset + 0x3c;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 0x0100:
|
||||||
|
offset = 0x0c + (target_subsong-1) * 0x64;
|
||||||
|
|
||||||
|
name_offset = offset + 0x00;
|
||||||
|
name_size = 0x20;
|
||||||
|
stream_type = read_u32le(offset + 0x20,sf);
|
||||||
|
stream_offset = read_u32le(offset + 0x24,sf);
|
||||||
|
stream_size = read_u32le(offset + 0x28,sf);
|
||||||
|
flags = read_u32le(offset + 0x34,sf);
|
||||||
|
num_samples = read_u32le(offset + 0x38,sf);
|
||||||
|
/* 0x3c: flags? */
|
||||||
|
|
||||||
|
offset = offset + 0x40;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
|
|
||||||
|
loop_flag = 0;
|
||||||
|
|
||||||
|
if (stream_type < 0 || stream_type > 2)
|
||||||
|
goto fail;
|
||||||
|
|
||||||
|
/* 0x00: floats x4 (volume/pan/etc? usually 1.0, 1.0, 10.0, 10.0) */
|
||||||
|
codec = read_u16le(offset + 0x10,sf);
|
||||||
|
channels = read_u16le(offset + 0x12,sf);
|
||||||
|
sample_rate = read_u32le(offset + 0x14,sf);
|
||||||
|
/* 0x18: avg bitrate */
|
||||||
|
/* 0x1c: block size */
|
||||||
|
/* 0x1e: bps */
|
||||||
|
/* 0x20: 2? */
|
||||||
|
|
||||||
|
if (stream_type == 0) {
|
||||||
|
vgmstream = init_vgmstream_silence_container(total_subsongs);
|
||||||
|
if (!vgmstream) goto fail;
|
||||||
|
|
||||||
|
close_streamfile(sf_body);
|
||||||
|
return vgmstream;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (flags & 0x04) {
|
||||||
|
char filename[255];
|
||||||
|
switch (version) {
|
||||||
|
case 0x009D:
|
||||||
|
/* stream is a named .xss, with stream_offset/size = 0 (Spider-Man) */
|
||||||
|
read_string(filename, name_size, name_offset,sf);
|
||||||
|
strcat(filename, ".xss");
|
||||||
|
|
||||||
|
sf_body = open_streamfile_by_filename(sf,filename);
|
||||||
|
if (!sf_body) {
|
||||||
|
VGM_LOG("XSH: can't find %s\n", filename);
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* xss is playable externally, so this is mostly for show */
|
||||||
|
vgmstream = init_vgmstream_riff(sf_body);
|
||||||
|
if (!vgmstream) goto fail;
|
||||||
|
|
||||||
|
vgmstream->num_streams = total_subsongs;
|
||||||
|
read_string(vgmstream->stream_name, name_size, name_offset,sf);
|
||||||
|
|
||||||
|
close_streamfile(sf_body);
|
||||||
|
return vgmstream;
|
||||||
|
//break;
|
||||||
|
|
||||||
|
case 0x0100:
|
||||||
|
/* bigfile with all streams (Kelly Slater) */
|
||||||
|
snprintf(filename, sizeof(filename), "%s", "STREAMS.XSS");
|
||||||
|
sf_body = open_streamfile_by_filename(sf,filename);
|
||||||
|
if (!sf_body) {
|
||||||
|
VGM_LOG("XSH: can't find %s\n", filename);
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
sf_body = open_streamfile_by_ext(sf,"xsd");
|
||||||
|
if (!sf_body) {
|
||||||
|
VGM_LOG("XSH: can't find XSD");
|
||||||
|
goto fail;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* build the VGMSTREAM */
|
||||||
|
vgmstream = allocate_vgmstream(channels, loop_flag);
|
||||||
|
if (!vgmstream) goto fail;
|
||||||
|
|
||||||
|
vgmstream->meta_type = meta_XSH_XSD_XSS;
|
||||||
|
vgmstream->sample_rate = sample_rate;
|
||||||
|
vgmstream->num_streams = total_subsongs;
|
||||||
|
vgmstream->stream_size = stream_size;
|
||||||
|
|
||||||
|
switch(codec) {
|
||||||
|
case 0x0069:
|
||||||
|
vgmstream->coding_type = coding_XBOX_IMA;
|
||||||
|
vgmstream->layout_type = layout_none;
|
||||||
|
|
||||||
|
if (!num_samples)
|
||||||
|
num_samples = xbox_ima_bytes_to_samples(stream_size, channels);
|
||||||
|
|
||||||
|
vgmstream->num_samples = num_samples;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
read_string(vgmstream->stream_name, name_size, name_offset,sf);
|
||||||
|
|
||||||
|
if (!vgmstream_open_stream(vgmstream, sf_body, stream_offset))
|
||||||
|
goto fail;
|
||||||
|
close_streamfile(sf_body);
|
||||||
|
return vgmstream;
|
||||||
|
|
||||||
|
fail:
|
||||||
|
close_streamfile(sf_body);
|
||||||
|
close_vgmstream(vgmstream);
|
||||||
|
return NULL;
|
||||||
|
}
|
@ -528,6 +528,7 @@ VGMSTREAM* (*init_vgmstream_functions[])(STREAMFILE* sf) = {
|
|||||||
init_vgmstream_piff_tpcm,
|
init_vgmstream_piff_tpcm,
|
||||||
init_vgmstream_wxd_wxh,
|
init_vgmstream_wxd_wxh,
|
||||||
init_vgmstream_bnk_relic,
|
init_vgmstream_bnk_relic,
|
||||||
|
init_vgmstream_xsh_xsd_xss,
|
||||||
|
|
||||||
/* 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 */
|
||||||
@ -819,7 +820,7 @@ void close_vgmstream(VGMSTREAM* vgmstream) {
|
|||||||
void vgmstream_force_loop(VGMSTREAM* vgmstream, int loop_flag, int loop_start_sample, int loop_end_sample) {
|
void vgmstream_force_loop(VGMSTREAM* vgmstream, int loop_flag, int loop_start_sample, int loop_end_sample) {
|
||||||
if (!vgmstream) return;
|
if (!vgmstream) return;
|
||||||
|
|
||||||
/* ignore bad values (may happen with layers + TXTP loop install) */
|
/* ignore bad values (may happen with layers + TXTP loop install) */
|
||||||
if (loop_flag && (loop_start_sample < 0 ||
|
if (loop_flag && (loop_start_sample < 0 ||
|
||||||
loop_start_sample > loop_end_sample ||
|
loop_start_sample > loop_end_sample ||
|
||||||
loop_end_sample > vgmstream->num_samples))
|
loop_end_sample > vgmstream->num_samples))
|
||||||
|
@ -743,6 +743,8 @@ typedef enum {
|
|||||||
meta_PIFF_TPCM,
|
meta_PIFF_TPCM,
|
||||||
meta_WXD_WXH,
|
meta_WXD_WXH,
|
||||||
meta_BNK_RELIC,
|
meta_BNK_RELIC,
|
||||||
|
meta_XSH_XSD_XSS,
|
||||||
|
|
||||||
} meta_t;
|
} meta_t;
|
||||||
|
|
||||||
/* standard WAVEFORMATEXTENSIBLE speaker positions */
|
/* standard WAVEFORMATEXTENSIBLE speaker positions */
|
||||||
|
Loading…
Reference in New Issue
Block a user