[FFmpeg-devel] [PATCH] dcaenc: switch to encode2()

Paul B Mahol onemda at gmail.com
Thu Mar 22 20:14:26 CET 2012


Signed-off-by: Paul B Mahol <onemda at gmail.com>
---
 libavcodec/dcaenc.c |   20 +++++++++++++-------
 1 files changed, 13 insertions(+), 7 deletions(-)

diff --git a/libavcodec/dcaenc.c b/libavcodec/dcaenc.c
index 72ea16f..b0e4037 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,10 @@ 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;
+    *got_packet_ptr = 1;
+    return 0;
 }
 
 static int encode_init(AVCodecContext *avctx)
@@ -580,7 +586,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)"),
-- 
1.7.7



More information about the ffmpeg-devel mailing list