diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2011-12-03 02:26:01 +0100 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2011-12-03 03:00:44 +0100 |
commit | 7db5ff79966a7c278a121f502f1f4bbdea1c7c16 (patch) | |
tree | a6bcc6b35c1ca9b9dfbc98154e662eff075fda4b /libavcodec/g729dec.c | |
parent | e4de71677f3adeac0f74b89ac8df5d417364df2c (diff) | |
download | ffmpeg-7db5ff79966a7c278a121f502f1f4bbdea1c7c16.tar.gz |
g729dec: update to the new API
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec/g729dec.c')
-rw-r--r-- | libavcodec/g729dec.c | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/libavcodec/g729dec.c b/libavcodec/g729dec.c index d76567974f..4714f19554 100644 --- a/libavcodec/g729dec.c +++ b/libavcodec/g729dec.c @@ -99,6 +99,7 @@ typedef struct { typedef struct { DSPContext dsp; + AVFrame frame; /// past excitation signal buffer int16_t exc_base[2*SUBFRAME_SIZE+PITCH_DELAY_MAX+INTERPOL_LEN]; @@ -380,15 +381,18 @@ static av_cold int decoder_init(AVCodecContext * avctx) dsputil_init(&ctx->dsp, avctx); ctx->dsp.scalarproduct_int16 = scalarproduct_int16_c; + avcodec_get_frame_defaults(&ctx->frame); + avctx->coded_frame = &ctx->frame; + return 0; } -static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, +static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame_ptr, AVPacket *avpkt) { const uint8_t *buf = avpkt->data; int buf_size = avpkt->size; - int16_t *out_frame = data; + int16_t *out_frame; GetBitContext gb; const G729FormatDescription *format; int frame_erasure = 0; ///< frame erasure detected during decoding @@ -407,14 +411,16 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, int pitch_delay_3x; // pitch delay, multiplied by 3 int16_t fc[SUBFRAME_SIZE]; // fixed-codebook vector int16_t synth[SUBFRAME_SIZE+10]; // fixed-codebook vector - int j; + int j, ret; int gain_before, gain_after; int is_periodic = 0; // whether one of the subframes is declared as periodic or not - if (*data_size < SUBFRAME_SIZE << 2) { - av_log(avctx, AV_LOG_ERROR, "Error processing packet: output buffer too small\n"); - return AVERROR(EIO); + ctx->frame.nb_samples = SUBFRAME_SIZE<<1; + if ((ret = avctx->get_buffer(avctx, &ctx->frame)) < 0) { + av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); + return ret; } + out_frame= ctx->frame.data[0]; if (buf_size == 10) { packet_type = FORMAT_G729_8K; @@ -701,7 +707,8 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, /* Save signal for use in next frame. */ memmove(ctx->exc_base, ctx->exc_base + 2 * SUBFRAME_SIZE, (PITCH_DELAY_MAX+INTERPOL_LEN)*sizeof(int16_t)); - *data_size = SUBFRAME_SIZE << 2; + *got_frame_ptr = 1; + *(AVFrame*)data = ctx->frame; return buf_size; } @@ -715,5 +722,6 @@ AVCodec ff_g729_decoder = NULL, NULL, decode_frame, + .capabilities = CODEC_CAP_DR1, .long_name = NULL_IF_CONFIG_SMALL("G.729"), }; |