Restore G719 max frame size as 2560 bits (0x140) is decoder max

This commit is contained in:
bnnm 2018-09-27 23:56:44 +02:00
parent c0d484a715
commit 2a5516fe7c
2 changed files with 6 additions and 10 deletions

View File

@ -2,14 +2,14 @@
#include <g719.h>
#ifdef VGM_USE_G719
#define G719_MAX_FRAME_SIZE 0x1000 /* arbitrary max (samples per frame seems to always be 960) */
#define G719_MAX_CODES ((1280/8)) /* in int16, so max frame size is (value/8)*2 (0xF0=common, 0x140=decoder max 2560b, rare) */
g719_codec_data *init_g719(int channel_count, int frame_size) {
int i;
g719_codec_data *data = NULL;
if (frame_size / sizeof(int16_t) > G719_MAX_FRAME_SIZE)
if (frame_size / sizeof(int16_t) > G719_MAX_CODES)
goto fail;
data = calloc(channel_count, sizeof(g719_codec_data)); /* one decoder per channel */
@ -18,10 +18,6 @@ g719_codec_data *init_g719(int channel_count, int frame_size) {
for (i = 0; i < channel_count; i++) {
data[i].handle = g719_init(frame_size); /* Siren 22 == 22khz bandwidth */
if (!data[i].handle) goto fail;
/* known values: 0xF0=common (sizeof(int16) * 960/8), 0x140=rare (sizeof(int16) * 1280/8) */
data[i].code_buffer = malloc(sizeof(int16_t) * frame_size);
if (!data[i].code_buffer) goto fail;
}
return data;
@ -45,8 +41,10 @@ void decode_g719(VGMSTREAM * vgmstream, sample * outbuf, int channelspacing, int
int i;
if (0 == vgmstream->samples_into_block) {
read_streamfile((uint8_t*)ch_data->code_buffer, ch->offset, vgmstream->interleave_block_size, ch->streamfile);
g719_decode_frame(ch_data->handle, ch_data->code_buffer, ch_data->buffer);
int16_t code_buffer[G719_MAX_CODES];
read_streamfile((uint8_t*)code_buffer, ch->offset, vgmstream->interleave_block_size, ch->streamfile);
g719_decode_frame(ch_data->handle, code_buffer, ch_data->buffer);
}
for (i = 0; i < samples_to_do; i++) {
@ -70,7 +68,6 @@ void free_g719(g719_codec_data * data, int channels) {
for (i = 0; i < channels; i++) {
g719_free(data[i].handle);
free(data[i].code_buffer);
}
free(data);
}

View File

@ -1032,7 +1032,6 @@ typedef struct {
typedef struct {
sample buffer[960];
void *handle;
int16_t *code_buffer;
} g719_codec_data;
#endif