vgmstream/src/meta/ymf.c

52 lines
1.4 KiB
C
Raw Normal View History

#include "meta.h"
2023-06-24 17:56:09 +02:00
#include "../coding/coding.h"
2023-06-24 17:56:09 +02:00
/* YMF - from Yuke's games [WWE WrestleMania X8 (GC)] */
VGMSTREAM* init_vgmstream_ymf(STREAMFILE* sf) {
VGMSTREAM* vgmstream = NULL;
uint32_t start_offset;
int channels, loop_flag;
2023-06-24 17:56:09 +02:00
/* checks */
if (read_u32be(0x00,sf) != 0x00000180 ||
read_u32be(0x08,sf) != 0x00000003 ||
read_u32be(0x0c,sf) != 0xCCCCCCCC)
return NULL;
/* 0x04: used data size? */
/* .ymf: actual extension */
if (!check_extensions(sf, "ymf"))
return NULL;
/* .ymf can contain audio or video, but not both (videos start with 0x100 and change minor values),
* though it's are found in ./movie/*.* and probably are considered so */
loop_flag = 0;
2023-06-24 17:56:09 +02:00
channels = 2;
start_offset = read_u32be(0x00,sf);
2023-06-24 17:56:09 +02:00
/* build the VGMSTREAM */
vgmstream = allocate_vgmstream(channels, loop_flag);
if (!vgmstream) goto fail;
2023-06-24 17:56:09 +02:00
vgmstream->meta_type = meta_YMF;
vgmstream->sample_rate = read_32bitBE(0xA8,sf);
vgmstream->num_samples = read_32bitBE(0xDC,sf);
2023-06-24 17:56:09 +02:00
vgmstream->coding_type = coding_NGC_DSP;
vgmstream->layout_type = layout_interleave;
vgmstream->interleave_block_size = 0x20000;
2023-06-24 17:56:09 +02:00
dsp_read_coefs_be(vgmstream, sf, 0xAE, 0x60);
//dsp_read_hist_be(vgmstream, sf, 0xAE + 0x20, 0x60);
2023-06-24 17:56:09 +02:00
if (!vgmstream_open_stream(vgmstream, sf, start_offset))
goto fail;
return vgmstream;
fail:
2023-06-24 17:56:09 +02:00
close_vgmstream(vgmstream);
return NULL;
}