Add .3do extension [Aqua World: Umimi Monogatari (3DO)]

This commit is contained in:
bnnm 2020-11-29 20:09:52 +01:00
parent 433c3ac56d
commit 07c1168a6a
2 changed files with 122 additions and 116 deletions

View File

@ -25,6 +25,7 @@ static const char* extension_list[] = {
"208",
"2dx9",
"2pfs",
"3do",
"4", //for Game.com audio
"8", //txth/reserved [Gungage (PS1)]
"800",
@ -943,7 +944,7 @@ static const meta_info meta_info_list[] = {
{meta_DSP_WSI, "Alone in the Dark .WSI header"},
{meta_AIFC, "Apple AIFF-C (Audio Interchange File Format) header"},
{meta_AIFF, "Apple AIFF (Audio Interchange File Format) header"},
{meta_STR_SNDS, "3DO .str header"},
{meta_STR_SNDS, "3DO SNDS header"},
{meta_WS_AUD, "Westwood Studios .aud header"},
{meta_WS_AUD_old, "Westwood Studios .aud (old) header"},
{meta_PS2_IVB, "IVB/BVII header"},

View File

@ -4,45 +4,49 @@
/* .str - 3DO format with CTRL/SNDS/SHDR blocks [Icebreaker (3DO), Battle Pinball (3DO)] */
VGMSTREAM * init_vgmstream_str_snds(STREAMFILE *streamFile) {
VGMSTREAM* init_vgmstream_str_snds(STREAMFILE* sf) {
VGMSTREAM* vgmstream = NULL;
off_t start_offset, shdr_offset = -1;
int loop_flag, channel_count, found_shdr = 0;
int loop_flag, channels, found_shdr = 0;
size_t file_size, ctrl_size = -1;
/* checks */
if (!check_extensions(streamFile, "str"))
/* .str: standard
* .3do: Aqua World - Umimi Monogatari (3DO) movies */
if (!check_extensions(sf, "str,3do"))
goto fail;
if (read_32bitBE(0x00,streamFile) != 0x4354524c && /* "CTRL" */
read_32bitBE(0x00,streamFile) != 0x534e4453 && /* "SNDS" */
read_32bitBE(0x00,streamFile) != 0x53484452) /* "SHDR" */
if (read_u32be(0x00,sf) != 0x4354524c && /* "CTRL" */
read_u32be(0x00,sf) != 0x534e4453 && /* "SNDS" */
read_u32be(0x00,sf) != 0x53484452) /* "SHDR" */
goto fail;
file_size = get_streamfile_size(streamFile);
file_size = get_streamfile_size(sf);
start_offset = 0x00;
/* scan chunks until we find a SNDS containing a SHDR */
{
off_t current_chunk = 0;
off_t offset = 0;
uint32_t size;
while (!found_shdr && current_chunk < file_size) {
if (current_chunk < 0) goto fail;
while (!found_shdr && offset < file_size) {
if (offset < 0) goto fail;
if (current_chunk+read_32bitBE(current_chunk+0x04,streamFile) >= file_size)
size = read_u32be(offset + 0x04,sf);
if (offset + size >= file_size)
goto fail;
switch (read_32bitBE(current_chunk,streamFile)) {
switch (read_u32be(offset + 0x00,sf)) {
case 0x4354524C: /* "CTRL" */
ctrl_size = read_32bitBE(current_chunk+4,streamFile);
ctrl_size = read_u32be(offset + 0x04,sf);
break;
case 0x534e4453: /* "SNDS" */
switch (read_32bitBE(current_chunk+16,streamFile)) {
switch (read_u32be(offset + 0x10,sf)) {
case 0x53484452: /* SHDR */
found_shdr = 1;
shdr_offset = current_chunk+16;
shdr_offset = offset + 0x10;
break;
default:
break;
@ -50,10 +54,10 @@ VGMSTREAM * init_vgmstream_str_snds(STREAMFILE *streamFile) {
break;
case 0x53484452: /* "SHDR" */
switch (read_32bitBE(current_chunk+0x7C, streamFile)) {
switch (read_u32be(offset + 0x7C, sf)) {
case 0x4354524C: /* "CTRL" */
/* to distinguish between styles */
ctrl_size = read_32bitBE(current_chunk + 0x80, streamFile);
ctrl_size = read_u32be(offset + 0x80, sf);
break;
default:
@ -61,50 +65,51 @@ VGMSTREAM * init_vgmstream_str_snds(STREAMFILE *streamFile) {
}
break;
default:
/* ignore others for now */
default: /* ignore others */
break;
}
current_chunk += read_32bitBE(current_chunk+0x04,streamFile);
offset += size;
}
}
if (!found_shdr) goto fail;
if (!found_shdr)
goto fail;
channel_count = read_32bitBE(shdr_offset+0x20,streamFile);
channels = read_u32be(shdr_offset+0x20,sf);
loop_flag = 0;
/* build the VGMSTREAM */
vgmstream = allocate_vgmstream(channel_count,loop_flag);
vgmstream = allocate_vgmstream(channels, loop_flag);
if (!vgmstream) goto fail;
vgmstream->meta_type = meta_STR_SNDS;
vgmstream->sample_rate = read_32bitBE(shdr_offset+0x1c,streamFile);
vgmstream->sample_rate = read_u32be(shdr_offset+0x1c,sf);
if (ctrl_size == 0x1C || ctrl_size == 0x0B || ctrl_size == -1) {
vgmstream->num_samples = read_32bitBE(shdr_offset+0x2c,streamFile) - 1; /* sample count? */
vgmstream->num_samples = read_u32be(shdr_offset+0x2c,sf) - 1; /* sample count? */
}
else {
vgmstream->num_samples = read_32bitBE(shdr_offset+0x2c,streamFile) * 0x10; /* frame count? */
vgmstream->num_samples = read_u32be(shdr_offset+0x2c,sf) * 0x10; /* frame count? */
}
vgmstream->num_samples /= vgmstream->channels;
switch (read_32bitBE(shdr_offset+0x24,streamFile)) {
switch (read_u32be(shdr_offset + 0x24,sf)) {
case 0x53445832: /* "SDX2" */
if (channel_count > 1) {
if (channels > 1) {
vgmstream->coding_type = coding_SDX2_int;
vgmstream->interleave_block_size = 1;
} else
} else {
vgmstream->coding_type = coding_SDX2;
}
break;
default:
goto fail;
}
vgmstream->layout_type = layout_blocked_str_snds;
if (!vgmstream_open_stream(vgmstream,streamFile,start_offset))
if (!vgmstream_open_stream(vgmstream, sf, start_offset))
goto fail;
return vgmstream;