mirror of
https://github.com/vgmstream/vgmstream.git
synced 2024-11-28 08:20:54 +01:00
cleanup
This commit is contained in:
parent
edaac2c289
commit
b947f9b9e1
@ -3,21 +3,21 @@
|
||||
|
||||
|
||||
/* .PCM - from Lunar: Eternal Blue (Sega CD) */
|
||||
VGMSTREAM * init_vgmstream_scd_pcm(STREAMFILE *streamFile) {
|
||||
VGMSTREAM * vgmstream = NULL;
|
||||
VGMSTREAM* init_vgmstream_scd_pcm(STREAMFILE* sf) {
|
||||
VGMSTREAM* vgmstream = NULL;
|
||||
off_t start_offset;
|
||||
int loop_flag, channel_count;
|
||||
int loop_flag, channels;
|
||||
|
||||
|
||||
/* checks */
|
||||
if (!check_extensions(streamFile, "pcm"))
|
||||
if (!check_extensions(sf, "pcm"))
|
||||
goto fail;
|
||||
|
||||
if (read_16bitBE(0x00,streamFile) == 0x0002) {
|
||||
channel_count = 1;
|
||||
if (read_u16be(0x00,sf) == 0x0002) {
|
||||
channels = 1;
|
||||
}
|
||||
else if (read_16bitBE(0x00,streamFile) == 0x0001) {
|
||||
channel_count = 2; /* RP025.PCM, RP039.PCM */
|
||||
else if (read_u16be(0x00,sf) == 0x0001) {
|
||||
channels = 2; /* RP025.PCM, RP039.PCM */
|
||||
}
|
||||
else {
|
||||
goto fail;
|
||||
@ -31,31 +31,31 @@ VGMSTREAM * init_vgmstream_scd_pcm(STREAMFILE *streamFile) {
|
||||
off_t i;
|
||||
/* should be empty up to start (~0x0a/~0x10 sometimes has unknown values) */
|
||||
for (i = 0x20; i < start_offset; i++) {
|
||||
if (read_8bit(i, streamFile) != 0)
|
||||
if (read_u8(i, sf) != 0)
|
||||
goto fail;
|
||||
}
|
||||
}
|
||||
|
||||
/* loops start 0 is possible, plus all? files loops
|
||||
* (even sfx/voices loop, but those set loop start in silence near the end) */
|
||||
loop_flag = (read_32bitBE(0x06,streamFile) != 0);
|
||||
loop_flag = (read_u32be(0x06,sf) != 0);
|
||||
|
||||
|
||||
/* build the VGMSTREAM */
|
||||
vgmstream = allocate_vgmstream(channel_count,loop_flag);
|
||||
vgmstream = allocate_vgmstream(channels,loop_flag);
|
||||
if (!vgmstream) goto fail;
|
||||
|
||||
vgmstream->meta_type = meta_SCD_PCM;
|
||||
vgmstream->sample_rate = 32500; /* looks correct compared to emu/recordings */
|
||||
vgmstream->num_samples = pcm_bytes_to_samples(get_streamfile_size(streamFile) - start_offset, channel_count, 8);
|
||||
vgmstream->loop_start_sample = read_32bitBE(0x02,streamFile)*0x400*2;
|
||||
vgmstream->loop_end_sample = read_32bitBE(0x06,streamFile)*2;
|
||||
vgmstream->num_samples = pcm_bytes_to_samples(get_streamfile_size(sf) - start_offset, channels, 8);
|
||||
vgmstream->loop_start_sample = read_s32be(0x02,sf)*0x400*2;
|
||||
vgmstream->loop_end_sample = read_s32be(0x06,sf)*2;
|
||||
|
||||
vgmstream->coding_type = coding_PCM8_SB;
|
||||
vgmstream->layout_type = layout_interleave;
|
||||
vgmstream->interleave_block_size = 0x800;
|
||||
|
||||
if (!vgmstream_open_stream(vgmstream,streamFile,start_offset))
|
||||
if (!vgmstream_open_stream(vgmstream,sf,start_offset))
|
||||
goto fail;
|
||||
return vgmstream;
|
||||
|
||||
|
@ -2,22 +2,21 @@
|
||||
#include "../coding/coding.h"
|
||||
|
||||
/* SSCF - Square-Enix games, older version of .scd [Crisis Core -Final Fantasy VII- (PSP), Dissidia 012 (PSP)] */
|
||||
VGMSTREAM * init_vgmstream_scd_sscf(STREAMFILE *streamFile) {
|
||||
VGMSTREAM * vgmstream = NULL;
|
||||
off_t start_offset, meta_offset, stream_offset;
|
||||
size_t stream_size;
|
||||
int loop_flag, channel_count, sample_rate;
|
||||
int total_subsongs, target_subsong = streamFile->stream_index;
|
||||
VGMSTREAM* init_vgmstream_scd_sscf(STREAMFILE* sf) {
|
||||
VGMSTREAM* vgmstream = NULL;
|
||||
uint32_t start_offset, meta_offset, stream_offset, stream_size;
|
||||
int loop_flag, channels, sample_rate;
|
||||
int total_subsongs, target_subsong = sf->stream_index;
|
||||
|
||||
|
||||
/* checks */
|
||||
if (!check_extensions(streamFile, "scd"))
|
||||
if (!is_id32be(0x00,sf, "SSCF"))
|
||||
goto fail;
|
||||
if (!check_extensions(sf, "scd"))
|
||||
goto fail;
|
||||
|
||||
if (read_32bitBE(0x00,streamFile) != 0x53534346) /* "SSCF" "*/
|
||||
goto fail;
|
||||
if (!(read_32bitBE(0x04,streamFile) == 0x002070210 || /* version? [Crisis Core (PSP)] */
|
||||
read_32bitBE(0x04,streamFile) == 0x10020702)) /* inverted version? [Dissidia (PSP)] */
|
||||
if (!(read_u32be(0x04,sf) == 0x02070210 || /* version? [Crisis Core (PSP)] */
|
||||
read_u32be(0x04,sf) == 0x10020702)) /* inverted version? [Dissidia (PSP)] */
|
||||
goto fail;
|
||||
/* 0x08: file size, except for a few files that with a weird value */
|
||||
/* 0x10: file id? */
|
||||
@ -26,8 +25,8 @@ VGMSTREAM * init_vgmstream_scd_sscf(STREAMFILE *streamFile) {
|
||||
/* find total subsongs (entries can be dummy) and target subsong */
|
||||
{
|
||||
int i,j, is_dupe;
|
||||
int entries = read_32bitLE(0x0c,streamFile);
|
||||
off_t stream_offsets[0x800];
|
||||
int entries = read_s32le(0x0c,sf);
|
||||
uint32_t stream_offsets[0x800];
|
||||
|
||||
if (entries > 0x800) /* meh */
|
||||
goto fail;
|
||||
@ -38,18 +37,18 @@ VGMSTREAM * init_vgmstream_scd_sscf(STREAMFILE *streamFile) {
|
||||
meta_offset = 0;
|
||||
total_subsongs = 0;
|
||||
for (i = 0; i < entries; i++) {
|
||||
off_t entry_offset = 0x20 + (0x20*i);
|
||||
off_t entry_stream_offset;
|
||||
uint32_t entry_offset = 0x20 + (0x20*i);
|
||||
uint32_t entry_stream_offset;
|
||||
|
||||
/* skip dummies */
|
||||
if (read_32bitLE(entry_offset+0x08,streamFile) == 0) /* size 0 */
|
||||
if (read_u32le(entry_offset+0x08,sf) == 0) /* size 0 */
|
||||
continue;
|
||||
if (read_16bitLE(entry_offset+0x0c,streamFile) == 0) /* no sample rate */
|
||||
if (read_u16le(entry_offset+0x0c,sf) == 0) /* no sample rate */
|
||||
continue;
|
||||
|
||||
/* skip repeated sounds */
|
||||
is_dupe = 0;
|
||||
entry_stream_offset = read_32bitLE(entry_offset+0x04,streamFile);
|
||||
entry_stream_offset = read_u32le(entry_offset+0x04,sf);
|
||||
for (j = 0; j < total_subsongs; j++) {
|
||||
if (entry_stream_offset == stream_offsets[j]) {
|
||||
is_dupe = 1;
|
||||
@ -74,9 +73,9 @@ VGMSTREAM * init_vgmstream_scd_sscf(STREAMFILE *streamFile) {
|
||||
|
||||
/* 0x00(2): config? usually 0x00/0x01 */
|
||||
/* 0x02(2): loop config */ //todo when 1 uses PS-ADPCM uses SPU loop flags to set start/end
|
||||
stream_offset = read_32bitLE(meta_offset+0x04,streamFile); /* absolute */
|
||||
stream_size = read_32bitLE(meta_offset+0x08,streamFile);
|
||||
sample_rate = (uint16_t)read_16bitLE(meta_offset+0x0c,streamFile);
|
||||
stream_offset = read_u32le(meta_offset+0x04,sf); /* absolute */
|
||||
stream_size = read_u32le(meta_offset+0x08,sf);
|
||||
sample_rate = read_u16le(meta_offset+0x0c,sf);
|
||||
/* 0x0e: config? */
|
||||
/* 0x10: config? */
|
||||
/* 0x14: 0xCA5F or 0x5FCA */
|
||||
@ -84,18 +83,18 @@ VGMSTREAM * init_vgmstream_scd_sscf(STREAMFILE *streamFile) {
|
||||
/* 0x1c: null / some id? */
|
||||
|
||||
loop_flag = 0;
|
||||
channel_count = 1;
|
||||
channels = 1;
|
||||
start_offset = stream_offset;
|
||||
|
||||
|
||||
/* build the VGMSTREAM */
|
||||
vgmstream = allocate_vgmstream(channel_count, loop_flag);
|
||||
vgmstream = allocate_vgmstream(channels, loop_flag);
|
||||
if (!vgmstream) goto fail;
|
||||
|
||||
vgmstream->sample_rate = sample_rate;
|
||||
vgmstream->num_streams = total_subsongs;
|
||||
vgmstream->stream_size = stream_size;
|
||||
vgmstream->num_samples = ps_bytes_to_samples(stream_size, channel_count);
|
||||
vgmstream->num_samples = ps_bytes_to_samples(stream_size, channels);
|
||||
if (loop_flag) {
|
||||
vgmstream->loop_start_sample = 0;
|
||||
vgmstream->loop_end_sample = vgmstream->num_samples;
|
||||
@ -105,7 +104,7 @@ VGMSTREAM * init_vgmstream_scd_sscf(STREAMFILE *streamFile) {
|
||||
vgmstream->coding_type = coding_PSX;
|
||||
vgmstream->layout_type = layout_none;
|
||||
|
||||
if (!vgmstream_open_stream(vgmstream,streamFile,start_offset))
|
||||
if (!vgmstream_open_stream(vgmstream,sf,start_offset))
|
||||
goto fail;
|
||||
return vgmstream;
|
||||
|
||||
|
@ -97,7 +97,6 @@ VGMSTREAM* (*init_vgmstream_functions[])(STREAMFILE* sf) = {
|
||||
init_vgmstream_ps2_kces,
|
||||
init_vgmstream_hxd,
|
||||
init_vgmstream_vsv,
|
||||
init_vgmstream_scd_pcm,
|
||||
init_vgmstream_ps2_pcm,
|
||||
init_vgmstream_ps2_rkv,
|
||||
init_vgmstream_ps2_vas,
|
||||
@ -528,6 +527,7 @@ VGMSTREAM* (*init_vgmstream_functions[])(STREAMFILE* sf) = {
|
||||
init_vgmstream_bigrp,
|
||||
|
||||
/* lower priority metas (no clean header identity, somewhat ambiguous, or need extension/companion file to identify) */
|
||||
init_vgmstream_scd_pcm,
|
||||
init_vgmstream_agsc,
|
||||
init_vgmstream_rsf,
|
||||
init_vgmstream_ps2_wmus,
|
||||
|
Loading…
Reference in New Issue
Block a user