[FFmpeg-cvslog] avcodec/cuvid: don't overwrite deinterlace at progressive input

Miroslav Slugeň git at videolan.org
Sat Feb 18 14:26:41 EET 2017


ffmpeg | branch: master | Miroslav Slugeň <thunder.m at email.cz> | Sun Feb 12 18:47:07 2017 +0100| [4cb8872eb79a43b7acaa35bc92ffd1ab1a64eb75] | committer: Timo Rothenpieler

avcodec/cuvid: don't overwrite deinterlace at progressive input

If there is progressive input it will disable deinterlacing in cuvid for
all future frames even those interlaced.

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

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=4cb8872eb79a43b7acaa35bc92ffd1ab1a64eb75
---

 libavcodec/cuvid.c | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/libavcodec/cuvid.c b/libavcodec/cuvid.c
index f5a49ce..844e782 100644
--- a/libavcodec/cuvid.c
+++ b/libavcodec/cuvid.c
@@ -51,6 +51,7 @@ typedef struct CuvidContext
     AVFifoBuffer *frame_queue;
 
     int deint_mode;
+    int deint_mode_current;
     int64_t prev_pts;
 
     int internal_error;
@@ -164,7 +165,11 @@ static int CUDAAPI cuvid_handle_video_sequence(void *opaque, CUVIDEOFORMAT* form
         (AVRational){ format->display_aspect_ratio.x, format->display_aspect_ratio.y },
         (AVRational){ avctx->width, avctx->height }));
 
-    if (!format->progressive_sequence && ctx->deint_mode == cudaVideoDeinterlaceMode_Weave)
+    ctx->deint_mode_current = format->progressive_sequence
+                              ? cudaVideoDeinterlaceMode_Weave
+                              : ctx->deint_mode;
+
+    if (!format->progressive_sequence && ctx->deint_mode_current == cudaVideoDeinterlaceMode_Weave)
         avctx->flags |= AV_CODEC_FLAG_INTERLACED_DCT;
     else
         avctx->flags &= ~AV_CODEC_FLAG_INTERLACED_DCT;
@@ -260,14 +265,9 @@ static int CUDAAPI cuvid_handle_video_sequence(void *opaque, CUVIDEOFORMAT* form
     cuinfo.ulNumOutputSurfaces = 1;
     cuinfo.ulCreationFlags = cudaVideoCreate_PreferCUVID;
     cuinfo.bitDepthMinus8 = format->bit_depth_luma_minus8;
+    cuinfo.DeinterlaceMode = ctx->deint_mode_current;
 
-    if (format->progressive_sequence) {
-        ctx->deint_mode = cuinfo.DeinterlaceMode = cudaVideoDeinterlaceMode_Weave;
-    } else {
-        cuinfo.DeinterlaceMode = ctx->deint_mode;
-    }
-
-    if (ctx->deint_mode != cudaVideoDeinterlaceMode_Weave)
+    if (ctx->deint_mode_current != cudaVideoDeinterlaceMode_Weave)
         avctx->framerate = av_mul_q(avctx->framerate, (AVRational){2, 1});
 
     ctx->internal_error = CHECK_CU(ctx->cvdl->cuvidCreateDecoder(&ctx->cudecoder, &cuinfo));
@@ -312,7 +312,7 @@ static int CUDAAPI cuvid_handle_picture_display(void *opaque, CUVIDPARSERDISPINF
     parsed_frame.dispinfo = *dispinfo;
     ctx->internal_error = 0;
 
-    if (ctx->deint_mode == cudaVideoDeinterlaceMode_Weave) {
+    if (ctx->deint_mode_current == cudaVideoDeinterlaceMode_Weave) {
         av_fifo_generic_write(ctx->frame_queue, &parsed_frame, sizeof(CuvidParsedFrame), NULL);
     } else {
         parsed_frame.is_deinterlacing = 1;
@@ -583,7 +583,7 @@ static int cuvid_decode_frame(AVCodecContext *avctx, void *data, int *got_frame,
 
     av_log(avctx, AV_LOG_TRACE, "cuvid_decode_frame\n");
 
-    if (ctx->deint_mode != cudaVideoDeinterlaceMode_Weave) {
+    if (ctx->deint_mode_current != cudaVideoDeinterlaceMode_Weave) {
         av_log(avctx, AV_LOG_ERROR, "Deinterlacing is not supported via the old API\n");
         return AVERROR(EINVAL);
     }



More information about the ffmpeg-cvslog mailing list