mirror of
https://github.com/vgmstream/vgmstream.git
synced 2024-11-24 15:00:11 +01:00
Add AKB MSADPCM [various SFX]; improve AKB header parsing
This commit is contained in:
parent
6389493992
commit
d364cf5a8d
@ -36,11 +36,12 @@ fail:
|
||||
/* AKB - found in SQEX iOS games */
|
||||
VGMSTREAM * init_vgmstream_akb_multi(STREAMFILE *streamFile) {
|
||||
VGMSTREAM * vgmstream = NULL;
|
||||
off_t start_offset;
|
||||
size_t filesize;
|
||||
off_t start_offset, extra_data_offset = 0;
|
||||
size_t file_size, header_size, extra_header_size = 0, extra_data_size = 0;
|
||||
int loop_flag = 0, channel_count, codec;
|
||||
|
||||
/* check extensions */
|
||||
/* .akb.bytes is the usual extension in later games */
|
||||
if ( !check_extensions(streamFile, "akb") )
|
||||
goto fail;
|
||||
|
||||
@ -55,35 +56,47 @@ VGMSTREAM * init_vgmstream_akb_multi(STREAMFILE *streamFile) {
|
||||
vgmstream = allocate_vgmstream(channel_count,loop_flag);
|
||||
if (!vgmstream) goto fail;
|
||||
|
||||
/* 0x04: version? (iPad/IPhone?) 0x24: file_id? */
|
||||
filesize = read_32bitLE(0x08,streamFile);
|
||||
/* 0x04 (2): version (iPad/IPhone?) */
|
||||
header_size = read_16bitLE(0x06,streamFile);
|
||||
file_size = read_32bitLE(0x08,streamFile);
|
||||
codec = read_8bit(0x0c,streamFile);
|
||||
vgmstream->sample_rate = (uint16_t)read_16bitLE(0x0e,streamFile);
|
||||
vgmstream->num_samples = read_32bitLE(0x10,streamFile);
|
||||
vgmstream->loop_start_sample = read_32bitLE(0x14,streamFile);
|
||||
vgmstream->loop_end_sample = read_32bitLE(0x18,streamFile);
|
||||
/* 0x0c: some size based on codec 0x10+: unk stuff? 0xc0+: data stuff? */
|
||||
vgmstream->loop_end_sample = read_32bitLE(0x18,streamFile);
|
||||
vgmstream->meta_type = meta_AKB;
|
||||
|
||||
/* should be ok but not exact (probably more complex, see AKB2) */
|
||||
if ( header_size >= 0x44) { /* v2 */
|
||||
/* 0x10+: config? (pan, volume), 0x24: file_id? */
|
||||
extra_data_size = read_16bitLE(0x1c,streamFile);
|
||||
extra_header_size = read_16bitLE(0x28,streamFile);
|
||||
extra_data_offset = header_size + extra_header_size;
|
||||
start_offset = extra_data_offset + extra_data_size;
|
||||
/* ~num_samples at extra_data_offset + 0x04/0x0c? */
|
||||
}
|
||||
else { /* v0 */
|
||||
start_offset = header_size;
|
||||
}
|
||||
|
||||
|
||||
switch (codec) {
|
||||
#if 0
|
||||
case 0x02: { /* some kind of ADPCM or PCM [various SFX] */
|
||||
start_offset = 0xC4;
|
||||
vgmstream->coding_type = coding_APPLE_IMA4;
|
||||
vgmstream->layout_type = channel_count==1 ? layout_none : layout_interleave;
|
||||
vgmstream->interleave_block_size = 0x100;
|
||||
case 0x02: { /* MSAPDCM [various SFX] */
|
||||
vgmstream->coding_type = coding_MSADPCM;
|
||||
vgmstream->layout_type = layout_none;
|
||||
vgmstream->interleave_block_size = read_16bitLE(extra_data_offset + 0x02,streamFile);
|
||||
|
||||
vgmstream->num_samples = read_32bitLE(extra_data_offset + 0x04, streamFile); /* lower than header num_samples */
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef VGM_USE_FFMPEG
|
||||
case 0x05: { /* ogg vorbis [Final Fantasy VI, Dragon Quest II-VI] */
|
||||
/* Starting from an offset in the current libvorbis code is a bit hard so just use FFmpeg.
|
||||
* Decoding seems to produce the same output with (inaudible) +-1 lower byte differences here and there. */
|
||||
* Decoding seems to produce the same output with (inaudible) +-1 lower byte differences due to rounding. */
|
||||
ffmpeg_codec_data *ffmpeg_data;
|
||||
|
||||
start_offset = 0xCC;
|
||||
ffmpeg_data = init_ffmpeg_offset(streamFile, start_offset,filesize-start_offset);
|
||||
ffmpeg_data = init_ffmpeg_offset(streamFile, start_offset,file_size-start_offset);
|
||||
if ( !ffmpeg_data ) goto fail;
|
||||
|
||||
vgmstream->codec_data = ffmpeg_data;
|
||||
@ -98,8 +111,7 @@ VGMSTREAM * init_vgmstream_akb_multi(STREAMFILE *streamFile) {
|
||||
/* init_vgmstream_akb above has priority, but this works fine too */
|
||||
ffmpeg_codec_data *ffmpeg_data;
|
||||
|
||||
start_offset = 0x20;
|
||||
ffmpeg_data = init_ffmpeg_offset(streamFile, start_offset,filesize-start_offset);
|
||||
ffmpeg_data = init_ffmpeg_offset(streamFile, start_offset,file_size-start_offset);
|
||||
if ( !ffmpeg_data ) goto fail;
|
||||
|
||||
vgmstream->codec_data = ffmpeg_data;
|
||||
@ -115,7 +127,6 @@ VGMSTREAM * init_vgmstream_akb_multi(STREAMFILE *streamFile) {
|
||||
}
|
||||
#endif
|
||||
|
||||
/* AAC @20 in some cases? (see above) */
|
||||
default:
|
||||
goto fail;
|
||||
}
|
||||
@ -141,6 +152,7 @@ VGMSTREAM * init_vgmstream_akb2_multi(STREAMFILE *streamFile) {
|
||||
int akb_header_size, sound_index = 0, sound_offset_data, sound, sound_header_size, material_offset_data, material_index = 0, material, extradata, encryption_flag;
|
||||
|
||||
/* check extensions */
|
||||
/* .akb.bytes is the usual extension in later games */
|
||||
if ( !check_extensions(streamFile, "akb") )
|
||||
goto fail;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user