vgmstream/src/meta/ivag.c

51 lines
1.5 KiB
C
Raw Normal View History

2019-11-24 20:18:01 +01:00
#include "meta.h"
2019-11-24 20:38:16 +01:00
/* IVAG - Namco header (from NUS3) [THE iDOLM@STER 2 (PS3), THE iDOLM@STER: Gravure For You! (PS3)] */
VGMSTREAM * init_vgmstream_ivag(STREAMFILE *streamFile) {
2019-11-24 20:18:01 +01:00
VGMSTREAM * vgmstream = NULL;
off_t start_offset;
int loop_flag = 0;
int channel_count;
2019-11-24 20:38:16 +01:00
/* checks */
/* .ivag: header id (since format can't be found outside NUS3) */
if (!check_extensions(streamFile, "ivag"))
goto fail;
2019-11-24 20:18:01 +01:00
2019-11-24 20:38:16 +01:00
if (read_32bitBE(0x00,streamFile) != 0x49564147) /* "IVAG" */
2019-11-24 20:18:01 +01:00
goto fail;
2019-11-24 20:38:16 +01:00
/* 0x04: null */
2019-11-24 20:18:01 +01:00
channel_count = read_32bitBE(0x08, streamFile);
2019-11-24 20:38:16 +01:00
loop_flag = (read_32bitBE(0x18, streamFile) != 0);
2019-11-24 20:18:01 +01:00
2019-11-24 20:38:16 +01:00
/* skip VAGp headers per channel (size 0x40) */
2019-11-24 20:18:01 +01:00
start_offset = 0x40 + (0x40 * channel_count);
2019-11-24 20:38:16 +01:00
2019-11-24 20:18:01 +01:00
/* build the VGMSTREAM */
vgmstream = allocate_vgmstream(channel_count,loop_flag);
if (!vgmstream) goto fail;
2019-11-24 20:38:16 +01:00
vgmstream->meta_type = meta_IVAG;
2019-11-24 20:18:01 +01:00
vgmstream->sample_rate = read_32bitBE(0x0C,streamFile);
vgmstream->num_samples = read_32bitBE(0x10,streamFile);
2019-11-24 20:38:16 +01:00
vgmstream->loop_start_sample = read_32bitBE(0x14,streamFile);
vgmstream->loop_end_sample = read_32bitBE(0x18,streamFile);
2019-11-24 20:18:01 +01:00
2019-11-24 20:38:16 +01:00
vgmstream->coding_type = coding_PSX;
2019-11-24 20:18:01 +01:00
vgmstream->layout_type = layout_interleave;
vgmstream->interleave_block_size = read_32bitBE(0x1C,streamFile);
2019-11-24 20:38:16 +01:00
if (!vgmstream_open_stream(vgmstream,streamFile,start_offset))
goto fail;
2019-11-24 20:18:01 +01:00
return vgmstream;
fail:
2019-11-24 20:38:16 +01:00
close_vgmstream(vgmstream);
2019-11-24 20:18:01 +01:00
return NULL;
}