Make decoder init functions for G722.1/G719

This commit is contained in:
bnnm 2017-10-14 12:41:59 +02:00
parent 4d0c8b54fd
commit 229783f5f0
3 changed files with 53 additions and 0 deletions

View File

@ -172,6 +172,7 @@ void mpeg_set_error_logging(mpeg_codec_data * data, int enable);
#ifdef VGM_USE_G7221 #ifdef VGM_USE_G7221
/* g7221_decoder */ /* g7221_decoder */
g7221_codec_data *init_g7221(int channel_count, int frame_size);
void decode_g7221(VGMSTREAM *vgmstream, sample * outbuf, int channelspacing, int32_t samples_to_do, int channel); void decode_g7221(VGMSTREAM *vgmstream, sample * outbuf, int channelspacing, int32_t samples_to_do, int channel);
void reset_g7221(VGMSTREAM *vgmstream); void reset_g7221(VGMSTREAM *vgmstream);
void free_g7221(VGMSTREAM *vgmstream); void free_g7221(VGMSTREAM *vgmstream);
@ -179,6 +180,7 @@ void free_g7221(VGMSTREAM *vgmstream);
#ifdef VGM_USE_G719 #ifdef VGM_USE_G719
/* g719_decoder */ /* g719_decoder */
g719_codec_data *init_g719(int channel_count, int frame_size);
void decode_g719(VGMSTREAM *vgmstream, sample * outbuf, int channelspacing, int32_t samples_to_do, int channel); void decode_g719(VGMSTREAM *vgmstream, sample * outbuf, int channelspacing, int32_t samples_to_do, int channel);
void reset_g719(VGMSTREAM *vgmstream); void reset_g719(VGMSTREAM *vgmstream);
void free_g719(VGMSTREAM *vgmstream); void free_g719(VGMSTREAM *vgmstream);

View File

@ -4,6 +4,31 @@
#ifdef VGM_USE_G719 #ifdef VGM_USE_G719
#include "../stack_alloc.h" #include "../stack_alloc.h"
g719_codec_data *init_g719(int channel_count, int frame_size) {
int i;
g719_codec_data *data = NULL;
data = calloc(channel_count, sizeof(g719_codec_data)); /* one decoder per channel */
if (!data) goto fail;
for (i = 0; i < channel_count; i++) {
data[i].handle = g719_init(frame_size); /* Siren 22 == 22khz bandwidth */
if (!data[i].handle) goto fail;
}
return data;
fail:
if (data) {
for (i = 0; i < channel_count; i++) {
g719_free(data[i].handle);
}
}
free(data);
return NULL;
}
void decode_g719(VGMSTREAM * vgmstream, sample * outbuf, int channelspacing, int32_t samples_to_do, int channel) { void decode_g719(VGMSTREAM * vgmstream, sample * outbuf, int channelspacing, int32_t samples_to_do, int channel) {
VGMSTREAMCHANNEL *ch = &vgmstream->ch[channel]; VGMSTREAMCHANNEL *ch = &vgmstream->ch[channel];
g719_codec_data *data = vgmstream->codec_data; g719_codec_data *data = vgmstream->codec_data;

View File

@ -3,6 +3,32 @@
#ifdef VGM_USE_G7221 #ifdef VGM_USE_G7221
g7221_codec_data * init_g7221(int channel_count, int frame_size) {
int i;
g7221_codec_data *data = NULL;
data = calloc(channel_count, sizeof(g7221_codec_data)); /* one decoder per channel */
if (!data) goto fail;
for (i = 0; i < channel_count; i++) {
data[i].handle = g7221_init(frame_size, 14000); /* Siren 14 == 14khz bandwidth */
if (!data[i].handle) goto fail;
}
return data;
fail:
if (data) {
for (i = 0; i < channel_count; i++) {
g7221_free(data[i].handle);
}
}
free(data);
return NULL;
}
void decode_g7221(VGMSTREAM * vgmstream, sample * outbuf, int channelspacing, int32_t samples_to_do, int channel) { void decode_g7221(VGMSTREAM * vgmstream, sample * outbuf, int channelspacing, int32_t samples_to_do, int channel) {
VGMSTREAMCHANNEL *ch = &vgmstream->ch[channel]; VGMSTREAMCHANNEL *ch = &vgmstream->ch[channel];
g7221_codec_data *data = vgmstream->codec_data; g7221_codec_data *data = vgmstream->codec_data;