vgmstream/src/meta/xbox_xmu.c
bnnm 9cf9416665 Add/use xbox_ima_bytes_to_samples, rename coding_XBOX to XBOX_IMA
Currently same as ms_ima_bytes_to_samples, but this will change; renamed
for consistency with all other IMA variations. Also clean a bit some
metas since I was testing anyway.
2018-02-17 12:30:14 +01:00

45 lines
1.4 KiB
C

#include "meta.h"
#include "../coding/coding.h"
/* XMU- found in Alter Echo (Xbox) */
VGMSTREAM * init_vgmstream_xbox_xmu(STREAMFILE *streamFile) {
VGMSTREAM * vgmstream = NULL;
size_t start_offset;
int loop_flag, channel_count;
size_t data_size;
/* check extension */
if (!check_extensions(streamFile,"xmu"))
goto fail;
if (read_32bitBE(0x00,streamFile) != 0x584D5520 && /* "XMU " */
read_32bitBE(0x08,streamFile) != 0x46524D54) /* "FRMT" */
goto fail;
start_offset = 0x800;
channel_count=read_8bit(0x14,streamFile); /* always stereo files */
loop_flag = read_8bit(0x16,streamFile); /* no Loop found atm */
data_size = read_32bitLE(0x7FC,streamFile); /* next to "DATA" */
/* build the VGMSTREAM */
vgmstream = allocate_vgmstream(channel_count,loop_flag);
if (!vgmstream) goto fail;
vgmstream->sample_rate = read_32bitLE(0x10,streamFile);
vgmstream->num_samples = xbox_ima_bytes_to_samples(data_size, vgmstream->channels);
vgmstream->loop_start_sample = 0;
vgmstream->loop_end_sample = vgmstream->num_samples;
vgmstream->coding_type = coding_XBOX_IMA;
vgmstream->layout_type = layout_none;
vgmstream->meta_type = meta_XBOX_XMU;
if (!vgmstream_open_stream(vgmstream, streamFile, start_offset))
goto fail;
return vgmstream;
fail:
close_vgmstream(vgmstream);
return NULL;
}