Browse code

dnxhdenc: switch to encode2.

Anton Khirnov authored on 2012/02/12 04:03:42
Showing 1 changed files
... ...
@@ -29,6 +29,7 @@
29 29
 #include "libavutil/opt.h"
30 30
 #include "avcodec.h"
31 31
 #include "dsputil.h"
32
+#include "internal.h"
32 33
 #include "mpegvideo.h"
33 34
 #include "mpegvideo_common.h"
34 35
 #include "dnxhdenc.h"
... ...
@@ -903,18 +904,21 @@ static void dnxhd_load_picture(DNXHDEncContext *ctx, const AVFrame *frame)
903 903
     ctx->cur_field = frame->interlaced_frame && !frame->top_field_first;
904 904
 }
905 905
 
906
-static int dnxhd_encode_picture(AVCodecContext *avctx, unsigned char *buf, int buf_size, void *data)
906
+static int dnxhd_encode_picture(AVCodecContext *avctx, AVPacket *pkt,
907
+                                const AVFrame *frame, int *got_packet)
907 908
 {
908 909
     DNXHDEncContext *ctx = avctx->priv_data;
909 910
     int first_field = 1;
910 911
     int offset, i, ret;
912
+    uint8_t *buf;
911 913
 
912
-    if (buf_size < ctx->cid_table->frame_size) {
914
+    if ((ret = ff_alloc_packet(pkt, ctx->cid_table->frame_size)) < 0) {
913 915
         av_log(avctx, AV_LOG_ERROR, "output buffer is too small to compress picture\n");
914
-        return -1;
916
+        return ret;
915 917
     }
918
+    buf = pkt->data;
916 919
 
917
-    dnxhd_load_picture(ctx, data);
920
+    dnxhd_load_picture(ctx, frame);
918 921
 
919 922
  encode_coding_unit:
920 923
     for (i = 0; i < 3; i++) {
... ...
@@ -955,13 +959,14 @@ static int dnxhd_encode_picture(AVCodecContext *avctx, unsigned char *buf, int b
955 955
         first_field     = 0;
956 956
         ctx->cur_field ^= 1;
957 957
         buf      += ctx->cid_table->coding_unit_size;
958
-        buf_size -= ctx->cid_table->coding_unit_size;
959 958
         goto encode_coding_unit;
960 959
     }
961 960
 
962 961
     ctx->frame.quality = ctx->qscale*FF_QP2LAMBDA;
963 962
 
964
-    return ctx->cid_table->frame_size;
963
+    pkt->flags |= AV_PKT_FLAG_KEY;
964
+    *got_packet = 1;
965
+    return 0;
965 966
 }
966 967
 
967 968
 static int dnxhd_encode_end(AVCodecContext *avctx)
... ...
@@ -999,7 +1004,7 @@ AVCodec ff_dnxhd_encoder = {
999 999
     .id             = CODEC_ID_DNXHD,
1000 1000
     .priv_data_size = sizeof(DNXHDEncContext),
1001 1001
     .init           = dnxhd_encode_init,
1002
-    .encode         = dnxhd_encode_picture,
1002
+    .encode2        = dnxhd_encode_picture,
1003 1003
     .close          = dnxhd_encode_end,
1004 1004
     .capabilities = CODEC_CAP_SLICE_THREADS,
1005 1005
     .pix_fmts = (const enum PixelFormat[]){PIX_FMT_YUV422P, PIX_FMT_YUV422P10, PIX_FMT_NONE},