2021-07-29 23:41:27 +02:00
|
|
|
#include "meta.h"
|
|
|
|
#include "../coding/coding.h"
|
|
|
|
|
|
|
|
/* .AIF - from Asobo Studio games [Ratatouille (PC), WALL-E (PC), Up (PC)] */
|
|
|
|
VGMSTREAM* init_vgmstream_aif_asobo(STREAMFILE* sf) {
|
|
|
|
VGMSTREAM* vgmstream = NULL;
|
|
|
|
off_t start_offset;
|
|
|
|
size_t data_size;
|
2021-10-23 13:14:54 +02:00
|
|
|
int loop_flag, channels, sample_rate;
|
2021-07-29 23:41:27 +02:00
|
|
|
|
|
|
|
|
|
|
|
/* checks */
|
2021-10-23 13:14:54 +02:00
|
|
|
if (read_u16le(0x00,sf) != 0x69) /* fmt chunk with Xbox codec */
|
2021-07-29 23:41:27 +02:00
|
|
|
goto fail;
|
2021-10-23 13:14:54 +02:00
|
|
|
/* aif: standard, .laif: for plugins */
|
|
|
|
if ( !check_extensions(sf,"aif,laif") )
|
2021-07-29 23:41:27 +02:00
|
|
|
goto fail;
|
|
|
|
|
2021-10-23 13:14:54 +02:00
|
|
|
channels = read_u16le(0x02,sf); /* assumed, only stereo is known */
|
|
|
|
if (channels != 2) goto fail;
|
2021-07-29 23:41:27 +02:00
|
|
|
|
2021-10-23 13:14:54 +02:00
|
|
|
sample_rate = read_u32le(0x04,sf);
|
|
|
|
/* 0x08: bitrate */
|
|
|
|
if (read_u16le(0x0c,sf) != 0x24 * channels) /* Xbox block */
|
2021-07-29 23:41:27 +02:00
|
|
|
goto fail;
|
2021-10-23 13:14:54 +02:00
|
|
|
if (read_u16le(0x0e,sf) != 0x04) /* Xbox bps */
|
2021-07-29 23:41:27 +02:00
|
|
|
goto fail;
|
|
|
|
loop_flag = 0;
|
|
|
|
|
|
|
|
start_offset = 0x14;
|
|
|
|
data_size = get_streamfile_size(sf) - start_offset;
|
|
|
|
|
|
|
|
|
|
|
|
/* build the VGMSTREAM */
|
2021-10-23 13:14:54 +02:00
|
|
|
vgmstream = allocate_vgmstream(channels, loop_flag);
|
2021-07-29 23:41:27 +02:00
|
|
|
if (!vgmstream) goto fail;
|
|
|
|
|
|
|
|
vgmstream->meta_type = meta_AIF_ASOBO;
|
2021-10-23 13:14:54 +02:00
|
|
|
vgmstream->sample_rate = sample_rate;
|
|
|
|
vgmstream->num_samples = xbox_ima_bytes_to_samples(data_size, channels);
|
2021-07-29 23:41:27 +02:00
|
|
|
|
|
|
|
vgmstream->coding_type = coding_XBOX_IMA;
|
|
|
|
vgmstream->layout_type = layout_none;
|
|
|
|
|
2021-10-23 13:14:54 +02:00
|
|
|
if (!vgmstream_open_stream(vgmstream, sf, start_offset))
|
2021-07-29 23:41:27 +02:00
|
|
|
goto fail;
|
|
|
|
return vgmstream;
|
|
|
|
|
|
|
|
fail:
|
|
|
|
close_vgmstream(vgmstream);
|
|
|
|
return NULL;
|
|
|
|
}
|