From patchwork Sun Feb 12 17:47:07 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Miroslav_Sluge=C5=88?= X-Patchwork-Id: 2520 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.89.21 with SMTP id n21csp562952vsb; Sun, 12 Feb 2017 09:47:21 -0800 (PST) X-Received: by 10.223.172.17 with SMTP id v17mr15823473wrc.115.1486921641100; Sun, 12 Feb 2017 09:47:21 -0800 (PST) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id 75si2226472wmh.36.2017.02.12.09.47.20; Sun, 12 Feb 2017 09:47:21 -0800 (PST) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@email.cz; dkim=neutral (body hash did not verify) header.i=@email.cz; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=email.cz Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 626B5680A68; Sun, 12 Feb 2017 19:47:12 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mxf1.seznam.cz (mxf1.seznam.cz [77.75.78.123]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 931736808B8 for ; Sun, 12 Feb 2017 19:47:05 +0200 (EET) Received: from email.seznam.cz by email-smtpc6a.ko.seznam.cz (email-smtpc6a.ko.seznam.cz [10.53.10.165]) id 404c102e749b083240de3923; Sun, 12 Feb 2017 18:47:09 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=email.cz; s=beta; t=1486921629; bh=u0GFjqfrma3FC9ldgezF8ls4fn8VV0AfrpzGYLTVVag=; h=DKIM-Signature:Received:From:Subject:To:Message-ID:Date: User-Agent:MIME-Version:Content-Type; b=Bbj+FbGKNrm3xoxvrHcexI7NUR33qYY8EQCHStE1NmRQjXdcMU+owxoWl6xUR8B34 vq1/Kp4onvp6r36oGXFh2YNC+cdj4My23Elzi43FizXrZ3UkIXxD14bQ8TmHxyZeS4 ZtOp0DZ0lLS2zeK7UpLc2dEo10PsyCBy4AueWaN4= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=email.cz; s=beta; t=1486921629; bh=u0GFjqfrma3FC9ldgezF8ls4fn8VV0AfrpzGYLTVVag=; h=Received:From:Subject:To:Message-ID:Date:User-Agent:MIME-Version: Content-Type; b=gFomJrKujhJmiIkO8ubOEb3HfZPHo0Q2pW/2yQG5B1Pm/V0fmuV5QAuSk7y1q0i3j Sy6dM2ifbKl/jGFF5i2SumsDZw5jo0hW7NiPD0sHB72Fs0peWDTyTpwIJcbBW1HngL sfxGSAKHcjCrorRc5sIM34Owq9zJBv+/D6gbrTBs= Received: from [192.168.0.6] (ip-94-113-140-7.net.upcbroadband.cz [94.113.140.7]) by email-relay1.ko.seznam.cz (Seznam SMTPD 1.3.56) with ESMTP; Sun, 12 Feb 2017 18:47:08 +0100 (CET) From: =?UTF-8?Q?Miroslav_Sluge=c5=88?= To: ffmpeg-devel@ffmpeg.org Message-ID: <58A09F9B.5030401@email.cz> Date: Sun, 12 Feb 2017 18:47:07 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.0.1 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH] cuvid: don't overwrite deinterlace at progressive input X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" If there is progressive input it will disable deinterlacing in cuvid for all future frames even those interlaced. I suggest to backport this patch to stable, because deinterlacing of combined files (progressive+interlaced) is currently broken in cuvid. From af263ad83ae555baa9cdab2f8b7c5f73ef51ff4d Mon Sep 17 00:00:00 2001 From: Miroslav Slugen Date: Sun, 12 Feb 2017 18:44:10 +0100 Subject: [PATCH 1/1] cuvid: don't overwrite deinterlace at progressive input --- libavcodec/cuvid.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/libavcodec/cuvid.c b/libavcodec/cuvid.c index 9b35476..a99d7de 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; @@ -150,7 +151,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; @@ -241,14 +246,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)); @@ -293,7 +293,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; @@ -564,7 +564,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); } -- 2.1.4