2008-11-11 11:02:52 +01:00
|
|
|
#include "meta.h"
|
2018-08-22 19:19:31 +02:00
|
|
|
#include "../coding/coding.h"
|
2008-11-11 11:02:52 +01:00
|
|
|
|
|
|
|
|
2018-08-22 19:19:31 +02:00
|
|
|
/* .ASS - from Dai Senryaku VII: Exceed (PS2) */
|
2008-11-11 11:02:52 +01:00
|
|
|
VGMSTREAM * init_vgmstream_ps2_ass(STREAMFILE *streamFile) {
|
|
|
|
VGMSTREAM * vgmstream = NULL;
|
2018-08-22 19:19:31 +02:00
|
|
|
off_t start_offset;
|
|
|
|
size_t channel_size, interleave;
|
|
|
|
int loop_flag, channel_count, sample_rate;
|
|
|
|
int32_t num_samples, loop_start = 0, loop_end = 0;
|
2008-11-11 11:02:52 +01:00
|
|
|
|
|
|
|
|
2018-08-22 19:19:31 +02:00
|
|
|
/* checks */
|
|
|
|
if (!check_extensions(streamFile, "ass"))
|
2008-11-11 11:02:52 +01:00
|
|
|
goto fail;
|
|
|
|
|
|
|
|
start_offset = 0x800;
|
2018-08-22 19:19:31 +02:00
|
|
|
channel_count = read_32bitLE(0x00,streamFile); /* assumed */
|
|
|
|
if (channel_count != 2) goto fail;
|
|
|
|
sample_rate = read_32bitLE(0x04,streamFile);
|
|
|
|
channel_size = read_32bitLE(0x08,streamFile);
|
|
|
|
interleave = read_32bitLE(0x0c,streamFile);
|
|
|
|
num_samples = ps_bytes_to_samples(channel_size,1);
|
2008-12-03 21:30:18 +01:00
|
|
|
|
2018-08-22 19:19:31 +02:00
|
|
|
loop_flag = ps_find_loop_offsets(streamFile, start_offset, channel_size*channel_count, channel_count, interleave, &loop_start, &loop_end);
|
|
|
|
loop_flag = loop_flag && (num_samples > 10*sample_rate); /* disable looping for smaller files (in seconds) */
|
2008-11-11 11:02:52 +01:00
|
|
|
|
|
|
|
|
2018-08-22 19:19:31 +02:00
|
|
|
/* build the VGMSTREAM */
|
|
|
|
vgmstream = allocate_vgmstream(channel_count,loop_flag);
|
|
|
|
if (!vgmstream) goto fail;
|
|
|
|
|
|
|
|
vgmstream->meta_type = meta_PS2_ASS;
|
|
|
|
vgmstream->sample_rate = sample_rate;
|
|
|
|
vgmstream->num_samples = num_samples;
|
|
|
|
vgmstream->loop_start_sample = loop_start;
|
|
|
|
vgmstream->loop_end_sample = loop_end;
|
2008-11-11 11:02:52 +01:00
|
|
|
|
2018-08-22 19:19:31 +02:00
|
|
|
vgmstream->coding_type = coding_PSX;
|
|
|
|
vgmstream->layout_type = layout_interleave;
|
|
|
|
vgmstream->interleave_block_size = interleave;
|
2008-11-11 11:02:52 +01:00
|
|
|
|
2018-08-22 19:19:31 +02:00
|
|
|
if (!vgmstream_open_stream(vgmstream,streamFile,start_offset))
|
|
|
|
goto fail;
|
2008-11-11 11:02:52 +01:00
|
|
|
return vgmstream;
|
|
|
|
|
|
|
|
fail:
|
2018-08-22 19:19:31 +02:00
|
|
|
close_vgmstream(vgmstream);
|
2008-11-11 11:02:52 +01:00
|
|
|
return NULL;
|
|
|
|
}
|