cleanup: iivb, etc

This commit is contained in:
bnnm 2024-07-18 23:51:38 +02:00
parent b0962ea354
commit 135279b483
7 changed files with 36 additions and 57 deletions

View File

@ -1053,7 +1053,7 @@ static const meta_info meta_info_list[] = {
{meta_AIFF, "Apple AIFF header"},
{meta_STR_SNDS, "3DO SNDS header"},
{meta_WS_AUD, "Westwood Studios .AUD header"},
{meta_PS2_IVB, "IVB/BVII header"},
{meta_IIVB, "Vingt-et-un IIVB header"},
{meta_SVS, "Square SVS header"},
{meta_RIFF_WAVE, "RIFF WAVE header"},
{meta_RIFF_WAVE_POS, "RIFF WAVE header (.pos looping)"},

View File

@ -2,7 +2,7 @@
#include "../coding/coding.h"
/* Ongakukan RIFF with "ADP" extension [Train Simulator: Midousuji-sen (PS2), Mobile Train Simulator (PSP)] */
VGMSTREAM* init_vgmstream_ongakukan_adp(STREAMFILE* sf) {
VGMSTREAM* init_vgmstream_adp_ongakukan(STREAMFILE* sf) {
VGMSTREAM* vgmstream = NULL;
off_t start_offset;
int loop_flag = 0;

View File

@ -1,60 +1,35 @@
#include "meta.h"
#include "../util.h"
#include "../util/meta_utils.h"
/* a simple PS2 ADPCM format seen in Langrisser 3 */
VGMSTREAM * init_vgmstream_ivb(STREAMFILE *streamFile) {
VGMSTREAM * vgmstream = NULL;
char filename[PATH_LIMIT];
off_t start_offset;
off_t stream_length;
int loop_flag = 0;
int channel_count;
/* IIVB - from Vingt-et-un Systems games [Langrisser III (PS2), Ururun Quest: Koiyuuki (PS2)] */
VGMSTREAM* init_vgmstream_iivb(STREAMFILE* sf) {
/* check extension, case insensitive */
streamFile->get_name(streamFile,filename,sizeof(filename));
if (strcasecmp("ivb",filename_extension(filename))) goto fail;
/* checks */
if (!is_id32be(0x00, sf, "BVII")) /* IIVB LE, given extension */
return NULL;
if (!check_extensions(sf,"ivb"))
return NULL;
/* check header */
if (read_32bitBE(0x00,streamFile) != 0x42564949) /* "BVII", probably */
goto fail; /* supposed to be "IIVB"*/
loop_flag = 0;
channel_count = 2;
meta_header_t h = {
.meta = meta_IIVB,
};
h.chan_size = read_u32le(0x04,sf);
h.sample_rate = read_s32be(0x08,sf); /* big endian? */
// 0c: empty
/* build the VGMSTREAM */
vgmstream = allocate_vgmstream(channel_count,loop_flag);
if (!vgmstream) goto fail;
h.channels = 2;
h.stream_offset = 0x10;
h.num_samples = ps_bytes_to_samples(h.chan_size, 1);
/* fill in the vital statistics */
vgmstream->channels = channel_count;
vgmstream->sample_rate = read_32bitBE(0x8,streamFile); /* big endian? */
vgmstream->coding_type = coding_PSX;
stream_length = read_32bitLE(0x04,streamFile);
start_offset = 0x10;
vgmstream->num_samples = stream_length*28/16;
h.coding = coding_PSX;
h.layout = layout_interleave;
h.interleave = h.chan_size;
vgmstream->layout_type = layout_none;
vgmstream->meta_type = meta_PS2_IVB;
h.sf = sf;
h.open_stream = true;
/* open the file for reading */
{
int i;
for (i=0;i<channel_count;i++) {
vgmstream->ch[i].streamfile = streamFile->open(streamFile,filename,STREAMFILE_DEFAULT_BUFFER_SIZE);
if (!vgmstream->ch[i].streamfile) goto fail;
vgmstream->ch[i].channel_start_offset=
vgmstream->ch[i].offset=start_offset+stream_length*i;
}
}
return vgmstream;
/* clean up anything we may have opened */
fail:
if (vgmstream) close_vgmstream(vgmstream);
return NULL;
return alloc_metastream(&h);
}

View File

@ -182,7 +182,7 @@ VGMSTREAM * init_vgmstream_ws_aud(STREAMFILE * streamFile);
VGMSTREAM * init_vgmstream_ahx(STREAMFILE * streamFile);
VGMSTREAM * init_vgmstream_ivb(STREAMFILE * streamFile);
VGMSTREAM* init_vgmstream_iivb(STREAMFILE* sf);
VGMSTREAM * init_vgmstream_svs(STREAMFILE * streamFile);
@ -1018,6 +1018,6 @@ VGMSTREAM* init_vgmstream_ea_sbk(STREAMFILE* sf);
VGMSTREAM* init_vgmstream_dsp_asura_sfx(STREAMFILE* sf);
VGMSTREAM* init_vgmstream_ongakukan_adp(STREAMFILE* sf);
VGMSTREAM* init_vgmstream_adp_ongakukan(STREAMFILE* sf);
#endif /*_META_H*/

View File

@ -5,10 +5,14 @@
/* Allocate memory and setup a VGMSTREAM */
VGMSTREAM* alloc_metastream(meta_header_t* h) {
if (h->sample_rate <= 0 || h->sample_rate > VGMSTREAM_MAX_SAMPLE_RATE)
if (h->sample_rate <= 0 || h->sample_rate > VGMSTREAM_MAX_SAMPLE_RATE) {
VGM_LOG("meta: wrong sample rate %i\n", h->sample_rate);
return NULL;
if (h->num_samples <= 0 || h->num_samples > VGMSTREAM_MAX_NUM_SAMPLES)
}
if (h->num_samples <= 0 || h->num_samples > VGMSTREAM_MAX_NUM_SAMPLES) {
VGM_LOG("meta: wrong samples %i\n", h->sample_rate);
return NULL;
}
VGMSTREAM* vgmstream = allocate_vgmstream(h->channels, h->loop_flag);
if (!vgmstream) return NULL;

View File

@ -66,7 +66,7 @@ init_vgmstream_t init_vgmstream_functions[] = {
init_vgmstream_str_snds,
init_vgmstream_ws_aud,
init_vgmstream_ahx,
init_vgmstream_ivb,
init_vgmstream_iivb,
init_vgmstream_svs,
init_vgmstream_riff,
init_vgmstream_rifx,
@ -533,7 +533,7 @@ init_vgmstream_t init_vgmstream_functions[] = {
init_vgmstream_dsp_asura_ds2,
init_vgmstream_dsp_asura_ttss,
init_vgmstream_dsp_asura_sfx,
init_vgmstream_ongakukan_adp,
init_vgmstream_adp_ongakukan,
/* lower priority metas (no clean header identity, somewhat ambiguous, or need extension/companion file to identify) */
init_vgmstream_agsc,

View File

@ -318,7 +318,7 @@ typedef enum {
meta_PWB,
meta_VPK, /* VPK Audio File */
meta_PS2_BMDX, /* Beatmania thing */
meta_PS2_IVB, /* Langrisser 3 IVB */
meta_IIVB,
meta_PS2_SND, /* some Might & Magics SSND header */
meta_SVS, /* Square SVS */
meta_XSS, /* Dino Crisis 3 */