mirror of
https://github.com/vgmstream/vgmstream.git
synced 2025-01-31 04:13:47 +01:00
cleanup
This commit is contained in:
parent
f87c75299b
commit
84a1053fd3
@ -1,48 +1,48 @@
|
||||
#include "meta.h"
|
||||
#include "../coding/coding.h"
|
||||
|
||||
/* APC - from Cryo games [MegaRace 3 (PC)] */
|
||||
VGMSTREAM * init_vgmstream_apc(STREAMFILE *streamFile) {
|
||||
VGMSTREAM * vgmstream = NULL;
|
||||
off_t start_offset;
|
||||
size_t data_size;
|
||||
int loop_flag, channel_count;
|
||||
|
||||
|
||||
/* checks */
|
||||
if ( !check_extensions(streamFile,"apc") )
|
||||
goto fail;
|
||||
if (read_32bitBE(0x00,streamFile) != 0x4352594F) /* "CRYO" */
|
||||
goto fail;
|
||||
if (read_32bitBE(0x04,streamFile) != 0x5F415043) /* "_APC" */
|
||||
goto fail;
|
||||
//if (read_32bitBE(0x08,streamFile) != 0x312E3230) /* "1.20" */
|
||||
// goto fail;
|
||||
|
||||
/* 0x14/18: L/R hist sample? */
|
||||
|
||||
start_offset = 0x20;
|
||||
data_size = get_streamfile_size(streamFile) - start_offset;
|
||||
channel_count = read_32bitLE(0x1c,streamFile) == 0 ? 1 : 2;
|
||||
loop_flag = 0;
|
||||
|
||||
|
||||
/* build the VGMSTREAM */
|
||||
vgmstream = allocate_vgmstream(channel_count,loop_flag);
|
||||
if (!vgmstream) goto fail;
|
||||
|
||||
vgmstream->meta_type = meta_APC;
|
||||
vgmstream->sample_rate = read_32bitLE(0x10,streamFile);
|
||||
vgmstream->num_samples = ima_bytes_to_samples(data_size,channel_count);
|
||||
|
||||
vgmstream->coding_type = coding_IMA;
|
||||
vgmstream->layout_type = layout_none;
|
||||
|
||||
if ( !vgmstream_open_stream(vgmstream, streamFile, start_offset) )
|
||||
goto fail;
|
||||
return vgmstream;
|
||||
|
||||
fail:
|
||||
close_vgmstream(vgmstream);
|
||||
return NULL;
|
||||
}
|
||||
#include "meta.h"
|
||||
#include "../coding/coding.h"
|
||||
|
||||
/* APC - from Cryo games [MegaRace 3 (PC)] */
|
||||
VGMSTREAM* init_vgmstream_apc(STREAMFILE* sf) {
|
||||
VGMSTREAM* vgmstream = NULL;
|
||||
uint32_t start_offset, data_size;
|
||||
int loop_flag, channels, sample_rate;
|
||||
|
||||
|
||||
/* checks */
|
||||
if (!is_id32be(0x00,sf, "CRYO"))
|
||||
goto fail;
|
||||
if (!is_id32be(0x04,sf, "_APC"))
|
||||
goto fail;
|
||||
//if (!is_id32be(0x04,sf, "1.20"))
|
||||
// goto fail;
|
||||
|
||||
if (!check_extensions(sf,"apc"))
|
||||
goto fail;
|
||||
|
||||
sample_rate = read_s32le(0x10,sf);
|
||||
/* 0x14/18: L/R hist sample? */
|
||||
channels = read_s32le(0x1c,sf) == 0 ? 1 : 2;
|
||||
loop_flag = 0;
|
||||
start_offset = 0x20;
|
||||
data_size = get_streamfile_size(sf) - start_offset;
|
||||
|
||||
|
||||
/* build the VGMSTREAM */
|
||||
vgmstream = allocate_vgmstream(channels, loop_flag);
|
||||
if (!vgmstream) goto fail;
|
||||
|
||||
vgmstream->meta_type = meta_APC;
|
||||
vgmstream->sample_rate = sample_rate;
|
||||
vgmstream->num_samples = ima_bytes_to_samples(data_size, channels);
|
||||
|
||||
vgmstream->coding_type = coding_IMA;
|
||||
vgmstream->layout_type = layout_none;
|
||||
|
||||
if (!vgmstream_open_stream(vgmstream, sf, start_offset))
|
||||
goto fail;
|
||||
return vgmstream;
|
||||
|
||||
fail:
|
||||
close_vgmstream(vgmstream);
|
||||
return NULL;
|
||||
}
|
||||
|
121
src/meta/asf.c
121
src/meta/asf.c
@ -1,58 +1,63 @@
|
||||
#include "meta.h"
|
||||
#include "../coding/coding.h"
|
||||
|
||||
/* ASF - Argonaut PC games [Croc 2 (PC), Aladdin: Nasira's Revenge (PC)] */
|
||||
VGMSTREAM * init_vgmstream_asf(STREAMFILE *streamFile) {
|
||||
VGMSTREAM * vgmstream = NULL;
|
||||
off_t start_offset;
|
||||
int loop_flag, channel_count, version;
|
||||
|
||||
|
||||
/* checks */
|
||||
/* .asf: original
|
||||
* .lasf: fake for plugins */
|
||||
if (!check_extensions(streamFile, "asf,lasf"))
|
||||
goto fail;
|
||||
|
||||
if (read_32bitBE(0x00,streamFile) != 0x41534600) /* "ASF\0" */
|
||||
goto fail;
|
||||
if (read_32bitBE(0x04,streamFile) != 0x02000100)
|
||||
goto fail;
|
||||
if (read_32bitLE(0x08,streamFile) != 0x01 &&
|
||||
read_32bitLE(0x0c,streamFile) != 0x18 &&
|
||||
read_32bitLE(0x1c,streamFile) != 0x20)
|
||||
goto fail;
|
||||
|
||||
version = read_32bitLE(0x28,streamFile); /* assumed? */
|
||||
switch(version){
|
||||
case 0x0d: channel_count = 1; break; /* Aladdin: Nasira's Revenge (PC) */
|
||||
case 0x0f: channel_count = 2; break; /* Croc 2 (PC), The Emperor's New Groove (PC) */
|
||||
default: goto fail;
|
||||
}
|
||||
|
||||
loop_flag = 0;
|
||||
start_offset = 0x2c;
|
||||
|
||||
/* build the VGMSTREAM */
|
||||
vgmstream = allocate_vgmstream(channel_count, loop_flag);
|
||||
if (!vgmstream) goto fail;
|
||||
|
||||
vgmstream->sample_rate = (uint16_t)read_16bitLE(0x24, streamFile);
|
||||
vgmstream->meta_type = meta_ASF;
|
||||
vgmstream->coding_type = coding_ASF;
|
||||
vgmstream->layout_type = layout_interleave;
|
||||
vgmstream->interleave_block_size = 0x11;
|
||||
vgmstream->num_samples = (get_streamfile_size(streamFile)-start_offset)/(0x11*channel_count)*32; /* bytes_to_samples */
|
||||
//vgmstream->num_samples = read_32bitLE(0x18,streamFile) * (0x20<<channel_count); /* something like this? */
|
||||
|
||||
read_string(vgmstream->stream_name,0x10, 0x08+1,streamFile);
|
||||
|
||||
|
||||
if (!vgmstream_open_stream(vgmstream,streamFile,start_offset))
|
||||
goto fail;
|
||||
return vgmstream;
|
||||
|
||||
fail:
|
||||
close_vgmstream(vgmstream);
|
||||
return NULL;
|
||||
}
|
||||
#include "meta.h"
|
||||
#include "../coding/coding.h"
|
||||
|
||||
/* ASF - Argonaut PC games [Croc 2 (PC), Aladdin: Nasira's Revenge (PC)] */
|
||||
VGMSTREAM* init_vgmstream_asf(STREAMFILE* sf) {
|
||||
VGMSTREAM* vgmstream = NULL;
|
||||
uint32_t start_offset;
|
||||
int loop_flag, channels, type, sample_rate;
|
||||
|
||||
|
||||
/* checks */
|
||||
if (!is_id32be(0x00,sf, "ASF\0"))
|
||||
goto fail;
|
||||
|
||||
/* .asf: original
|
||||
* .lasf: fake for plugins */
|
||||
if (!check_extensions(sf, "asf,lasf"))
|
||||
goto fail;
|
||||
|
||||
if (read_u32le(0x04,sf) != 0x00010002) /* v1.002? */
|
||||
goto fail;
|
||||
if (read_u32le(0x08,sf) != 0x01 &&
|
||||
read_u32le(0x0c,sf) != 0x18)
|
||||
goto fail;
|
||||
/* 0x10~18: stream name (same as filename) */
|
||||
/* 0x18: non-full size? */
|
||||
if (read_u32le(0x1c,sf) != 0x20) /* samples per frame? */
|
||||
goto fail;
|
||||
sample_rate = read_u16le(0x24, sf);
|
||||
|
||||
type = read_u32le(0x28,sf); /* assumed? */
|
||||
switch(type){
|
||||
case 0x0d: channels = 1; break; /* Aladdin: Nasira's Revenge (PC) */
|
||||
case 0x0f: channels = 2; break; /* Croc 2 (PC), The Emperor's New Groove (PC) */
|
||||
default: goto fail;
|
||||
}
|
||||
|
||||
loop_flag = 0;
|
||||
start_offset = 0x2c;
|
||||
|
||||
/* build the VGMSTREAM */
|
||||
vgmstream = allocate_vgmstream(channels, loop_flag);
|
||||
if (!vgmstream) goto fail;
|
||||
|
||||
vgmstream->sample_rate = sample_rate;
|
||||
vgmstream->meta_type = meta_ASF;
|
||||
vgmstream->coding_type = coding_ASF;
|
||||
vgmstream->layout_type = layout_interleave;
|
||||
vgmstream->interleave_block_size = 0x11;
|
||||
vgmstream->num_samples = (get_streamfile_size(sf) - start_offset) / (0x11 * channels) * 32; /* bytes_to_samples */
|
||||
//vgmstream->num_samples = read_32bitLE(0x18,sf) * (32 << channels); /* something like this? */
|
||||
|
||||
read_string(vgmstream->stream_name,0x10, 0x08+1,sf);
|
||||
|
||||
|
||||
if (!vgmstream_open_stream(vgmstream, sf, start_offset))
|
||||
goto fail;
|
||||
return vgmstream;
|
||||
|
||||
fail:
|
||||
close_vgmstream(vgmstream);
|
||||
return NULL;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user