mirror of
https://github.com/vgmstream/vgmstream.git
synced 2025-01-17 23:36:41 +01:00
Add PC/X360/Wii .seg and fixes [The Spiderwick Chronicles (multi)]
This commit is contained in:
parent
7259bcc0f2
commit
1380faf5bb
@ -853,8 +853,7 @@ static const meta_info meta_info_list[] = {
|
||||
{meta_IDSP_NL, "Next Level IDSP header"},
|
||||
{meta_IDSP_IE, "Inevitable Entertainment IDSP Header"},
|
||||
{meta_UBI_JADE, "Ubisoft Jade RIFF header"},
|
||||
{meta_PS2_SEG, "SEG (PS2) Header"},
|
||||
{meta_XBOX_SEG, "SEG (XBOX) Header"},
|
||||
{meta_SEG, "Stormfront SEG header"},
|
||||
{meta_NDS_STRM_FFTA2, "Final Fantasy Tactics A2 RIFF Header"},
|
||||
{meta_STR_ASR, "Donkey Kong Jet Race KNON/WII Header"},
|
||||
{meta_ZWDSP, "Zack and Wiki custom DSP Header"},
|
||||
|
144
src/meta/seg.c
144
src/meta/seg.c
@ -1,94 +1,110 @@
|
||||
#include "meta.h"
|
||||
#include "../coding/coding.h"
|
||||
|
||||
|
||||
/* SEG - found in Eragon */
|
||||
/* SEG - from Stormfront games [Eragon (multi), Forgotten Realms: Demon Stone (multi) */
|
||||
VGMSTREAM * init_vgmstream_seg(STREAMFILE *streamFile) {
|
||||
VGMSTREAM * vgmstream = NULL;
|
||||
char filename[PATH_LIMIT];
|
||||
off_t start_offset;
|
||||
int loop_flag;
|
||||
int channel_count;
|
||||
coding_t coding;
|
||||
|
||||
/* check extension, case insensitive */
|
||||
streamFile->get_name(streamFile,filename,sizeof(filename));
|
||||
if (strcasecmp("seg",filename_extension(filename))) goto fail;
|
||||
int loop_flag, channel_count;
|
||||
size_t data_size;
|
||||
uint32_t codec;
|
||||
int32_t (*read_32bit)(off_t,STREAMFILE*) = NULL;
|
||||
|
||||
|
||||
/* check header */
|
||||
if (read_32bitBE(0x00,streamFile) != 0x73656700) /* "seg\0" */
|
||||
/* checks */
|
||||
if (!check_extensions(streamFile, "seg"))
|
||||
goto fail;
|
||||
if (read_32bitBE(0x00,streamFile) != 0x73656700) /* "seg\0" */
|
||||
goto fail;
|
||||
if (read_32bitBE(0x04,streamFile) == 0x70733200) /* "ps2\0" */
|
||||
{
|
||||
coding = coding_PSX;
|
||||
}
|
||||
else if (read_32bitBE(0x04,streamFile) == 0x78627800) /* "xbx\0" */
|
||||
{
|
||||
coding = coding_XBOX_IMA;
|
||||
}
|
||||
else goto fail;
|
||||
|
||||
loop_flag = 0;
|
||||
channel_count = read_32bitLE(0x24,streamFile);
|
||||
|
||||
/* build the VGMSTREAM */
|
||||
codec = read_32bitBE(0x04,streamFile);
|
||||
/* 0x08: version? (2: Eragon, Spiderwick Chronicles Wii / 3: Spiderwick Chronicles X360 / 4: Spiderwick Chronicles PC) */
|
||||
if (guess_endianness32bit(0x08,streamFile)) {
|
||||
read_32bit = read_32bitBE;
|
||||
} else {
|
||||
read_32bit = read_32bitLE;
|
||||
}
|
||||
/* 0x0c: file size */
|
||||
data_size = read_32bit(0x10, streamFile); /* including interleave padding */
|
||||
/* 0x14: null */
|
||||
|
||||
loop_flag = read_32bit(0x20,streamFile); /* rare */
|
||||
channel_count = read_32bit(0x24,streamFile);
|
||||
/* 0x28: extradata 1 entries (0x08 per entry, unknown) */
|
||||
/* 0x2c: extradata 1 offset */
|
||||
/* 0x30: extradata 2 entries (0x10 or 0x14 per entry, seek/hist table?) */
|
||||
/* 0x34: extradata 2 offset */
|
||||
|
||||
start_offset = 0x4000;
|
||||
|
||||
|
||||
/* build the VGMSTREAM */
|
||||
vgmstream = allocate_vgmstream(channel_count,loop_flag);
|
||||
if (!vgmstream) goto fail;
|
||||
|
||||
/* fill in the vital statistics */
|
||||
start_offset = 0x4000;
|
||||
vgmstream->channels = channel_count;
|
||||
vgmstream->sample_rate = read_32bitLE(0x18,streamFile);
|
||||
vgmstream->coding_type = coding;
|
||||
|
||||
vgmstream->meta_type = meta_SEG;
|
||||
vgmstream->sample_rate = read_32bit(0x18,streamFile);
|
||||
vgmstream->num_samples = read_32bit(0x1c,streamFile);
|
||||
if (loop_flag) {
|
||||
vgmstream->loop_start_sample = 0;
|
||||
vgmstream->loop_end_sample = read_32bitLE(0x1C,streamFile);
|
||||
vgmstream->loop_end_sample = vgmstream->num_samples;
|
||||
}
|
||||
read_string(vgmstream->stream_name,0x20+1, 0x38,streamFile);
|
||||
|
||||
vgmstream->interleave_block_size = 0;
|
||||
switch(codec) {
|
||||
case 0x70733200: /* "ps2\0" */
|
||||
vgmstream->coding_type = coding_PSX;
|
||||
vgmstream->layout_type = layout_interleave;
|
||||
vgmstream->interleave_block_size = 0x2000;
|
||||
break;
|
||||
|
||||
if (coding_PSX == coding)
|
||||
{
|
||||
vgmstream->num_samples = (read_32bitLE(0x0C,streamFile)-start_offset)*28/16/channel_count;
|
||||
vgmstream->meta_type = meta_PS2_SEG;
|
||||
case 0x78627800: /* "xbx\0" */
|
||||
vgmstream->coding_type = coding_XBOX_IMA;
|
||||
vgmstream->layout_type = layout_none;
|
||||
break;
|
||||
|
||||
if (channel_count == 1) {
|
||||
vgmstream->layout_type = layout_none;
|
||||
} else if (channel_count == 2) {
|
||||
vgmstream->layout_type = layout_interleave;
|
||||
vgmstream->interleave_block_size = 0x2000;
|
||||
}
|
||||
}
|
||||
else if (coding_XBOX_IMA == coding)
|
||||
{
|
||||
vgmstream->num_samples = xbox_ima_bytes_to_samples(read_32bitLE(0x0C,streamFile)-start_offset, channel_count);
|
||||
vgmstream->meta_type = meta_XBOX_SEG;
|
||||
vgmstream->layout_type = layout_none;
|
||||
}
|
||||
else goto fail;
|
||||
case 0x77696900: /* "wii\0" */
|
||||
vgmstream->coding_type = coding_NGC_DSP;
|
||||
vgmstream->layout_type = layout_interleave;
|
||||
vgmstream->interleave_block_size = 0x2000;
|
||||
|
||||
/* 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;
|
||||
/* standard dsp header at start_offset */
|
||||
dsp_read_coefs_be(vgmstream, streamFile, start_offset+0x1c, vgmstream->interleave_block_size);
|
||||
dsp_read_hist_be(vgmstream, streamFile, start_offset+0x40, vgmstream->interleave_block_size);
|
||||
//todo first_interleave: 0x2000 - 60
|
||||
break;
|
||||
|
||||
vgmstream->ch[i].channel_start_offset=
|
||||
vgmstream->ch[i].offset=start_offset+
|
||||
vgmstream->interleave_block_size*i;
|
||||
case 0x70635F00: /* "pc_\0" */
|
||||
vgmstream->coding_type = coding_IMA;
|
||||
vgmstream->layout_type = layout_none;
|
||||
break;
|
||||
|
||||
#ifdef VGM_USE_FFMPEG
|
||||
case 0x78623300: { /* "xb3\0" */
|
||||
uint8_t buf[0x100];
|
||||
int bytes, block_size, block_count;
|
||||
|
||||
block_size = 0x4000;
|
||||
block_count = data_size / block_size + (data_size % block_size ? 1 : 0);
|
||||
|
||||
bytes = ffmpeg_make_riff_xma2(buf,0x100, vgmstream->num_samples, data_size, vgmstream->channels, vgmstream->sample_rate, block_count, block_size);
|
||||
vgmstream->codec_data = init_ffmpeg_header_offset(streamFile, buf,bytes, start_offset,data_size);
|
||||
if (!vgmstream->codec_data) goto fail;
|
||||
vgmstream->coding_type = coding_FFmpeg;
|
||||
vgmstream->layout_type = layout_none;
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
|
||||
default:
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if (!vgmstream_open_stream(vgmstream,streamFile,start_offset))
|
||||
goto fail;
|
||||
return vgmstream;
|
||||
|
||||
/* clean up anything we may have opened */
|
||||
fail:
|
||||
if (vgmstream) close_vgmstream(vgmstream);
|
||||
close_vgmstream(vgmstream);
|
||||
return NULL;
|
||||
}
|
||||
|
@ -432,8 +432,7 @@ typedef enum {
|
||||
meta_RSD6WMA, /* RSD6WMA */
|
||||
|
||||
meta_PS2_ASS, /* ASS */
|
||||
meta_PS2_SEG, /* Eragon */
|
||||
meta_XBOX_SEG, /* Eragon */
|
||||
meta_SEG, /* Eragon */
|
||||
meta_NDS_STRM_FFTA2, /* Final Fantasy Tactics A2 */
|
||||
meta_STR_ASR, /* Donkey Kong Jet Race */
|
||||
meta_ZWDSP, /* Zack and Wiki */
|
||||
|
Loading…
x
Reference in New Issue
Block a user