mirror of
https://github.com/vgmstream/vgmstream.git
synced 2024-11-29 08:44:32 +01:00
Fix some .XWC [The Darkness (X360)]
This commit is contained in:
parent
776d85fee0
commit
48c11e81ca
@ -4,26 +4,44 @@
|
||||
/* .XWC - Starbreeze games [Chronicles of Riddick: Assault on Dark Athena, Syndicate] */
|
||||
VGMSTREAM * init_vgmstream_xwc(STREAMFILE *streamFile) {
|
||||
VGMSTREAM * vgmstream = NULL;
|
||||
off_t start_offset;
|
||||
off_t start_offset, extra_offset;
|
||||
size_t data_size;
|
||||
int loop_flag, channel_count, codec;
|
||||
int loop_flag, channel_count, codec, num_samples;
|
||||
|
||||
/* check extensions (.xwc is the extension of the bigfile, individual files don't have one) */
|
||||
if ( !check_extensions(streamFile,"xwc"))
|
||||
goto fail;
|
||||
|
||||
if(read_32bitBE(0x00,streamFile) != 0x00040000 && /* version? */
|
||||
read_32bitBE(0x04,streamFile) != 0x00900000)
|
||||
goto fail;
|
||||
|
||||
/* version */
|
||||
if (read_32bitBE(0x00,streamFile) == 0x00030000 &&
|
||||
read_32bitBE(0x04,streamFile) == 0x00900000) { /* The Darkness */
|
||||
data_size = read_32bitLE(0x08, streamFile); /* including subheader */
|
||||
channel_count = read_32bitLE(0x0c, streamFile);
|
||||
/* 0x10: num_samples */
|
||||
/* 0x14: 0x8000? */
|
||||
/* 0x18: null */
|
||||
codec = read_32bitBE(0x1c, streamFile);
|
||||
num_samples = read_32bitLE(0x20, streamFile);
|
||||
/* 0x24: config data >> 2? (0x00(1): channels; 0x01(2): ?, 0x03(2): sample_rate) */
|
||||
extra_offset = 0x28;
|
||||
}
|
||||
else if (read_32bitBE(0x00,streamFile) == 0x00040000 &&
|
||||
read_32bitBE(0x04,streamFile) == 0x00900000) { /* Riddick, Syndicate */
|
||||
data_size = read_32bitLE(0x08, streamFile); /* including subheader */
|
||||
channel_count = read_32bitLE(0x0c, streamFile);
|
||||
/* 0x10: num_samples */
|
||||
/* 0x14: 0x8000? */
|
||||
codec = read_32bitBE(0x24, streamFile);
|
||||
/* 0x28: num_samples */
|
||||
/* 0x2c: config data? (first nibble: 0x4=mono, 0x8=stereo) */
|
||||
num_samples = read_32bitLE(0x28, streamFile);
|
||||
/* 0x2c: config data >> 2? (0x00(1): channels; 0x01(2): ?, 0x03(2): sample_rate) */
|
||||
/* 0x30+: codec dependant */
|
||||
extra_offset = 0x30;
|
||||
}
|
||||
else {
|
||||
goto fail;
|
||||
}
|
||||
|
||||
loop_flag = 0; /* seemingly not in the file */
|
||||
|
||||
|
||||
@ -31,7 +49,7 @@ VGMSTREAM * init_vgmstream_xwc(STREAMFILE *streamFile) {
|
||||
vgmstream = allocate_vgmstream(channel_count,loop_flag);
|
||||
if (!vgmstream) goto fail;
|
||||
|
||||
vgmstream->num_samples = read_32bitLE(0x28, streamFile);
|
||||
vgmstream->num_samples = num_samples;
|
||||
vgmstream->meta_type = meta_XWC;
|
||||
|
||||
switch(codec) {
|
||||
@ -40,8 +58,8 @@ VGMSTREAM * init_vgmstream_xwc(STREAMFILE *streamFile) {
|
||||
mpeg_custom_config cfg = {0};
|
||||
|
||||
start_offset = 0x800;
|
||||
vgmstream->num_samples = read_32bitLE(0x30, streamFile); /* with encoder delay */ //todo improve
|
||||
cfg.data_size = read_32bitLE(0x34, streamFile); //data_size - 0x28;
|
||||
vgmstream->num_samples = read_32bitLE(extra_offset+0x00, streamFile); /* with encoder delay */ //todo improve
|
||||
cfg.data_size = read_32bitLE(extra_offset+0x04, streamFile); //data_size - 0x28;
|
||||
|
||||
vgmstream->codec_data = init_mpeg_custom(streamFile, start_offset, &vgmstream->coding_type, vgmstream->channels, MPEG_STANDARD, &cfg);
|
||||
if (!vgmstream->codec_data) goto fail;
|
||||
@ -56,13 +74,13 @@ VGMSTREAM * init_vgmstream_xwc(STREAMFILE *streamFile) {
|
||||
uint8_t buf[0x100];
|
||||
int32_t bytes, seek_size, block_size, block_count, sample_rate;
|
||||
|
||||
seek_size = read_32bitLE(0x30, streamFile);
|
||||
start_offset = 0x34 + seek_size + read_32bitLE(0x34+seek_size, streamFile) + 0x08;
|
||||
seek_size = read_32bitLE(extra_offset+0x00, streamFile);
|
||||
start_offset = extra_offset+0x04 + seek_size + read_32bitLE(extra_offset+0x04+seek_size, streamFile) + 0x08;
|
||||
start_offset += (start_offset % 0x800) ? 0x800 - (start_offset % 0x800) : 0; /* padded */
|
||||
|
||||
sample_rate = read_32bitBE(0x34+seek_size+0x10, streamFile);
|
||||
block_size = read_32bitBE(0x34+seek_size+0x1c, streamFile);
|
||||
block_count = read_32bitBE(0x34+seek_size+0x28, streamFile);
|
||||
sample_rate = read_32bitBE(extra_offset+0x04+seek_size+0x10, streamFile);
|
||||
block_size = read_32bitBE(extra_offset+0x04+seek_size+0x1c, streamFile);
|
||||
block_count = read_32bitBE(extra_offset+0x04+seek_size+0x28, streamFile);
|
||||
/* others: scrambled RIFF fmt BE values */
|
||||
|
||||
bytes = ffmpeg_make_riff_xma2(buf,0x100, vgmstream->num_samples, data_size, vgmstream->channels, sample_rate, block_count, block_size);
|
||||
@ -93,10 +111,6 @@ VGMSTREAM * init_vgmstream_xwc(STREAMFILE *streamFile) {
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (vgmstream->sample_rate != 48000) { /* get from config data instead of codecs? */
|
||||
VGM_LOG("XWC: unexpected sample rate %i\n",vgmstream->sample_rate);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if ( !vgmstream_open_stream(vgmstream, streamFile, start_offset) )
|
||||
goto fail;
|
||||
|
Loading…
Reference in New Issue
Block a user