mirror of
https://github.com/vgmstream/vgmstream.git
synced 2024-11-14 18:47:39 +01:00
Add frame_size for MSADPCM
This commit is contained in:
parent
e35bbf59cf
commit
7593da7422
@ -1,21 +1,19 @@
|
||||
#include "meta.h"
|
||||
#include "../util.h"
|
||||
|
||||
/* 2DX9 (found in beatmaniaIIDX16 - EMPRESS (Arcade) */
|
||||
/* 2DX9 - from Konami arcade games [beatmaniaIIDX16: EMPRESS (AC), BeatStream (AC), REFLEC BEAT (AC)] */
|
||||
VGMSTREAM * init_vgmstream_2dx9(STREAMFILE *streamFile) {
|
||||
VGMSTREAM * vgmstream = NULL;
|
||||
char filename[PATH_LIMIT];
|
||||
off_t start_offset;
|
||||
int channel_count, loop_flag;
|
||||
|
||||
int loop_flag;
|
||||
int channel_count;
|
||||
|
||||
/* check extension, case insensitive */
|
||||
streamFile->get_name(streamFile,filename,sizeof(filename));
|
||||
if (strcasecmp("2dx9",filename_extension(filename))) goto fail;
|
||||
/* checks */
|
||||
if (!check_extensions(streamFile, "2dx9"))
|
||||
goto fail;
|
||||
|
||||
/* check header */
|
||||
if (read_32bitBE(0x0,streamFile) != 0x32445839) /* 2DX9 */
|
||||
if (read_32bitBE(0x00,streamFile) != 0x32445839) /* 2DX9 */
|
||||
goto fail;
|
||||
if (read_32bitBE(0x18,streamFile) != 0x52494646) /* RIFF */
|
||||
goto fail;
|
||||
@ -28,42 +26,24 @@ VGMSTREAM * init_vgmstream_2dx9(STREAMFILE *streamFile) {
|
||||
|
||||
loop_flag = 0;
|
||||
channel_count = read_16bitLE(0x2e,streamFile);
|
||||
start_offset = 0x72;
|
||||
|
||||
/* build the VGMSTREAM */
|
||||
vgmstream = allocate_vgmstream(channel_count,loop_flag);
|
||||
if (!vgmstream) goto fail;
|
||||
|
||||
/* fill in the vital statistics */
|
||||
start_offset = 0x72;
|
||||
vgmstream->channels = channel_count;
|
||||
vgmstream->sample_rate = read_32bitLE(0x30,streamFile);
|
||||
vgmstream->coding_type = coding_MSADPCM;
|
||||
vgmstream->num_samples = read_32bitLE(0x66,streamFile);
|
||||
vgmstream->layout_type = layout_none;
|
||||
vgmstream->interleave_block_size = read_16bitLE(0x38,streamFile);
|
||||
vgmstream->meta_type = meta_2DX9;
|
||||
vgmstream->sample_rate = read_32bitLE(0x30,streamFile);
|
||||
vgmstream->num_samples = read_32bitLE(0x66,streamFile);
|
||||
vgmstream->coding_type = coding_MSADPCM;
|
||||
vgmstream->layout_type = layout_none;
|
||||
vgmstream->frame_size = read_16bitLE(0x38,streamFile);
|
||||
|
||||
/* open the file for reading */
|
||||
{
|
||||
int i;
|
||||
STREAMFILE * file;
|
||||
file = streamFile->open(streamFile,filename,STREAMFILE_DEFAULT_BUFFER_SIZE);
|
||||
if (!file) goto fail;
|
||||
for (i=0;i<channel_count;i++) {
|
||||
vgmstream->ch[i].streamfile = file;
|
||||
|
||||
vgmstream->ch[i].channel_start_offset=
|
||||
vgmstream->ch[i].offset=start_offset+
|
||||
vgmstream->interleave_block_size*i;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!vgmstream_open_stream(vgmstream, streamFile, start_offset))
|
||||
goto fail;
|
||||
return vgmstream;
|
||||
|
||||
fail:
|
||||
/* clean up anything we may have opened */
|
||||
if (vgmstream) close_vgmstream(vgmstream);
|
||||
close_vgmstream(vgmstream);
|
||||
return NULL;
|
||||
}
|
||||
|
@ -1215,10 +1215,10 @@ int get_vgmstream_samples_per_frame(VGMSTREAM * vgmstream) {
|
||||
return 128;
|
||||
|
||||
case coding_MSADPCM:
|
||||
return (vgmstream->interleave_block_size - 0x07*vgmstream->channels)*2 / vgmstream->channels + 2;
|
||||
return (vgmstream->frame_size - 0x07*vgmstream->channels)*2 / vgmstream->channels + 2;
|
||||
case coding_MSADPCM_int:
|
||||
case coding_MSADPCM_ck:
|
||||
return (vgmstream->interleave_block_size - 0x07)*2 + 2;
|
||||
return (vgmstream->frame_size - 0x07)*2 + 2;
|
||||
case coding_WS: /* only works if output sample size is 8 bit, which always is for WS ADPCM */
|
||||
return vgmstream->ws_output_size;
|
||||
case coding_AICA:
|
||||
@ -1407,7 +1407,7 @@ int get_vgmstream_frame_size(VGMSTREAM * vgmstream) {
|
||||
case coding_MSADPCM:
|
||||
case coding_MSADPCM_int:
|
||||
case coding_MSADPCM_ck:
|
||||
return vgmstream->interleave_block_size;
|
||||
return vgmstream->frame_size;
|
||||
case coding_WS:
|
||||
return vgmstream->current_block_size;
|
||||
case coding_AICA:
|
||||
@ -2393,7 +2393,8 @@ void describe_vgmstream(VGMSTREAM * vgmstream, char * desc, int length) {
|
||||
}
|
||||
|
||||
/* codecs with configurable frame size */
|
||||
if (vgmstream->interleave_block_size > 0) {
|
||||
if (vgmstream->frame_size > 0 || vgmstream->interleave_block_size > 0) {
|
||||
int32_t frame_size = vgmstream->frame_size > 0 ? vgmstream->frame_size : vgmstream->interleave_block_size;
|
||||
switch (vgmstream->coding_type) {
|
||||
case coding_MSADPCM:
|
||||
case coding_MSADPCM_int:
|
||||
@ -2403,7 +2404,7 @@ void describe_vgmstream(VGMSTREAM * vgmstream, char * desc, int length) {
|
||||
case coding_WWISE_IMA:
|
||||
case coding_REF_IMA:
|
||||
case coding_PSX_cfg:
|
||||
snprintf(temp,TEMPSIZE, "frame size: %#x bytes\n", (int32_t)vgmstream->interleave_block_size);
|
||||
snprintf(temp,TEMPSIZE, "frame size: %#x bytes\n", frame_size);
|
||||
concatn(length,desc,temp);
|
||||
break;
|
||||
default:
|
||||
@ -2792,7 +2793,7 @@ int vgmstream_open_stream(VGMSTREAM * vgmstream, STREAMFILE *streamFile, off_t s
|
||||
vgmstream->coding_type == coding_PSX_pivotal) &&
|
||||
(vgmstream->interleave_block_size == 0 || vgmstream->interleave_block_size > 0x50)) {
|
||||
VGM_LOG("VGMSTREAM: PSX-cfg decoder with wrong frame size %x\n", vgmstream->interleave_block_size);
|
||||
return 0;
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if ((vgmstream->coding_type == coding_CRI_ADX ||
|
||||
@ -2802,7 +2803,14 @@ int vgmstream_open_stream(VGMSTREAM * vgmstream, STREAMFILE *streamFile, off_t s
|
||||
vgmstream->coding_type == coding_CRI_ADX_fixed) &&
|
||||
(vgmstream->interleave_block_size == 0 || vgmstream->interleave_block_size > 0x12)) {
|
||||
VGM_LOG("VGMSTREAM: ADX decoder with wrong frame size %x\n", vgmstream->interleave_block_size);
|
||||
return 0;
|
||||
goto fail;
|
||||
}
|
||||
|
||||
if ((vgmstream->coding_type == coding_MSADPCM ||
|
||||
vgmstream->coding_type == coding_MSADPCM_ck ||
|
||||
vgmstream->coding_type == coding_MSADPCM_int) &&
|
||||
vgmstream->frame_size == 0) {
|
||||
vgmstream->frame_size = vgmstream->interleave_block_size;
|
||||
}
|
||||
|
||||
/* if interleave is big enough keep a buffer per channel */
|
||||
|
@ -828,6 +828,7 @@ typedef struct {
|
||||
size_t interleave_first_block_size; /* different interleave for first block */
|
||||
size_t interleave_first_skip; /* data skipped before interleave first (needed to skip other channels) */
|
||||
size_t interleave_last_block_size; /* smaller interleave for last block */
|
||||
size_t frame_size; /* for codecs with configurable size */
|
||||
|
||||
/* subsong config */
|
||||
int num_streams; /* for multi-stream formats (0=not set/one stream, 1=one stream) */
|
||||
|
Loading…
Reference in New Issue
Block a user