Browse code

avcodec/cuvid: add drop_second_field as input option

Signed-off-by: Timo Rothenpieler <timo@rothenpieler.org>

Miroslav Slugeň authored on 2017/02/13 05:22:46
Showing 2 changed files
... ...
@@ -42,6 +42,7 @@ typedef struct CuvidContext
42 42
 
43 43
     char *cu_gpu;
44 44
     int nb_surfaces;
45
+    int drop_second_field;
45 46
 
46 47
     AVBufferRef *hwdevice;
47 48
     AVBufferRef *hwframe;
... ...
@@ -267,7 +268,7 @@ static int CUDAAPI cuvid_handle_video_sequence(void *opaque, CUVIDEOFORMAT* form
267 267
     cuinfo.bitDepthMinus8 = format->bit_depth_luma_minus8;
268 268
     cuinfo.DeinterlaceMode = ctx->deint_mode_current;
269 269
 
270
-    if (ctx->deint_mode_current != cudaVideoDeinterlaceMode_Weave)
270
+    if (ctx->deint_mode_current != cudaVideoDeinterlaceMode_Weave && !ctx->drop_second_field)
271 271
         avctx->framerate = av_mul_q(avctx->framerate, (AVRational){2, 1});
272 272
 
273 273
     ctx->internal_error = CHECK_CU(ctx->cvdl->cuvidCreateDecoder(&ctx->cudecoder, &cuinfo));
... ...
@@ -317,8 +318,10 @@ static int CUDAAPI cuvid_handle_picture_display(void *opaque, CUVIDPARSERDISPINF
317 317
     } else {
318 318
         parsed_frame.is_deinterlacing = 1;
319 319
         av_fifo_generic_write(ctx->frame_queue, &parsed_frame, sizeof(CuvidParsedFrame), NULL);
320
-        parsed_frame.second_field = 1;
321
-        av_fifo_generic_write(ctx->frame_queue, &parsed_frame, sizeof(CuvidParsedFrame), NULL);
320
+        if (!ctx->drop_second_field) {
321
+            parsed_frame.second_field = 1;
322
+            av_fifo_generic_write(ctx->frame_queue, &parsed_frame, sizeof(CuvidParsedFrame), NULL);
323
+        }
322 324
     }
323 325
 
324 326
     return 1;
... ...
@@ -949,6 +952,7 @@ static const AVOption options[] = {
949 949
     { "adaptive", "Adaptive deinterlacing",                  0, AV_OPT_TYPE_CONST, { .i64 = cudaVideoDeinterlaceMode_Adaptive }, 0, 0, VD, "deint" },
950 950
     { "gpu",      "GPU to be used for decoding", OFFSET(cu_gpu), AV_OPT_TYPE_STRING, { .str = NULL }, 0, 0, VD },
951 951
     { "surfaces", "Maximum surfaces to be used for decoding", OFFSET(nb_surfaces), AV_OPT_TYPE_INT, { .i64 = 25 }, 0, INT_MAX, VD },
952
+    { "drop_second_field", "Drop second field when deinterlacing", OFFSET(drop_second_field), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VD },
952 953
     { NULL }
953 954
 };
954 955
 
... ...
@@ -29,7 +29,7 @@
29 29
 
30 30
 #define LIBAVCODEC_VERSION_MAJOR  57
31 31
 #define LIBAVCODEC_VERSION_MINOR  80
32
-#define LIBAVCODEC_VERSION_MICRO 100
32
+#define LIBAVCODEC_VERSION_MICRO 101
33 33
 
34 34
 #define LIBAVCODEC_VERSION_INT  AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
35 35
                                                LIBAVCODEC_VERSION_MINOR, \