From b1a0d694ea973c4de91fbb1fb46858cff6f6e91b Mon Sep 17 00:00:00 2001 From: Paul B Mahol Date: Thu, 22 Mar 2012 19:27:19 +0000 Subject: dcaenc: switch to encode2() Signed-off-by: Paul B Mahol Signed-off-by: Michael Niedermayer --- libavcodec/dcaenc.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) (limited to 'libavcodec') diff --git a/libavcodec/dcaenc.c b/libavcodec/dcaenc.c index 72ea16f6d5..71106d7e36 100644 --- a/libavcodec/dcaenc.c +++ b/libavcodec/dcaenc.c @@ -26,6 +26,7 @@ #include "libavutil/audioconvert.h" #include "avcodec.h" #include "get_bits.h" +#include "internal.h" #include "put_bits.h" #include "dcaenc.h" #include "dcadata.h" @@ -488,14 +489,18 @@ static void put_frame(DCAContext *c, flush_put_bits(&c->pb); } -static int encode_frame(AVCodecContext *avctx, uint8_t *frame, - int buf_size, void *data) +static int encode_frame(AVCodecContext *avctx, AVPacket *avpkt, + const AVFrame *frame, int *got_packet_ptr) { int i, k, channel; DCAContext *c = avctx->priv_data; - int16_t *samples = data; - int real_channel = 0; + const int16_t *samples; + int ret, real_channel = 0; + if ((ret = ff_alloc_packet2(avctx, avpkt, DCA_MAX_FRAME_SIZE + DCA_HEADER_SIZE))) + return ret; + + samples = (const int16_t *)frame->data[0]; for (i = 0; i < PCM_SAMPLES; i ++) { /* i is the decimated sample number */ for (channel = 0; channel < c->prim_channels + 1; channel++) { /* Get 32 PCM samples */ @@ -518,9 +523,11 @@ static int encode_frame(AVCodecContext *avctx, uint8_t *frame, } } - put_frame(c, c->subband, frame); + put_frame(c, c->subband, avpkt->data); - return c->frame_size; + avpkt->size = c->frame_size; + *got_packet_ptr = 1; + return 0; } static int encode_init(AVCodecContext *avctx) @@ -580,7 +587,7 @@ AVCodec ff_dca_encoder = { .id = CODEC_ID_DTS, .priv_data_size = sizeof(DCAContext), .init = encode_init, - .encode = encode_frame, + .encode2 = encode_frame, .capabilities = CODEC_CAP_EXPERIMENTAL, .sample_fmts = (const enum AVSampleFormat[]){AV_SAMPLE_FMT_S16,AV_SAMPLE_FMT_NONE}, .long_name = NULL_IF_CONFIG_SMALL("DCA (DTS Coherent Acoustics)"), -- cgit v1.2.3