From patchwork Sun Mar 19 19:42:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Niedermayer X-Patchwork-Id: 40728 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:d046:b0:cd:afd7:272c with SMTP id hv6csp1275049pzb; Sun, 19 Mar 2023 12:43:08 -0700 (PDT) X-Google-Smtp-Source: AK7set/IlxFo2MNCCP776cQLuTqYEUilOio9E4lC8PmywGzDiPb1d+zo+CLvg4cq76NvyI4TrnKq X-Received: by 2002:a17:906:4c52:b0:931:6921:bdb7 with SMTP id d18-20020a1709064c5200b009316921bdb7mr6677019ejw.60.1679254988416; Sun, 19 Mar 2023 12:43:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1679254988; cv=none; d=google.com; s=arc-20160816; b=w2uMb1aE79hGqry2mfw4f2tHT+u0lmmFYH3PXyDToWplNAo4P4dyESchM3lTbUYz2Y OAVvkqn/CFdiQOUogdL4wa9CrYTodEbnsEeN4bCn7o1HdtM9d1/vgyng2UVSEpQGQGd5 Xmg1+cUC9Ma6dg70AMsaxbyTJ03XMahVt/Hxsja1cGhwOgdOWt0nbHaSzWnirseFvZtq usw6ExvfRxlFFWNKLqZOZEMDiyoJJijs1408kv/P9WLeOWPakprTt8Oi5FHnVFND2YB/ uB7M4K4Q9Undta0t+oRSqViyr+1niRXulCGbU7W8g8WDqLArwiJZF94qVZzSxkpa4Ukh w8Lg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:in-reply-to:message-id:date :to:from:delivered-to; bh=PL+BBBT/gGw0AYZtjmUYRgbE+qfbd1GEXNfZhiEf0EU=; b=dmOKf6QsGU9Kj1Idna1DXvVSFphojrYWCqzv29sS5wM+Bajx25UbL0Mdd/5ASnZMD9 DDJnoPk8F7pBuWSWdnwZF3JSgByn4CYMN51vMjg507BCHmdHFoOhMOYguloGRpKuEIwo PP9qsHm+zq7m9/xgE18z8YnfredsN8dgZvm04PA0eNAIe6xozP4n4NwLJd9aVi0au4i1 J9ergNDkUdcsXS2a0PIHtlzdFUNfluQgX+M//+UapH8Y8SmZSCpy/qP+CohGgXCE8VMH KuYG+a2dXCEcxt5o31U75rnasDHLnqJ9kZ9kIXwsBoOKJIw4J2tW6TM4ax0oLmINLHRt buiA== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id gt39-20020a1709072da700b0093337d30dadsi5936294ejc.522.2023.03.19.12.43.08; Sun, 19 Mar 2023 12:43:08 -0700 (PDT) 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; 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 Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 47AD568C3F5; Sun, 19 Mar 2023 21:42:59 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from relay8-d.mail.gandi.net (relay8-d.mail.gandi.net [217.70.183.201]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 73B8068C409 for ; Sun, 19 Mar 2023 21:42:52 +0200 (EET) Received: (Authenticated sender: michael@niedermayer.cc) by mail.gandi.net (Postfix) with ESMTPSA id 590961BF203 for ; Sun, 19 Mar 2023 19:42:50 +0000 (UTC) From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Sun, 19 Mar 2023 20:42:40 +0100 Message-Id: <20230319194240.15001-3-michael@niedermayer.cc> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230319194240.15001-1-michael@niedermayer.cc> References: <20230319194240.15001-1-michael@niedermayer.cc> Subject: [FFmpeg-devel] [PATCH v2 3/3] avfilter/vf_mcdeint: update to new API X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 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 MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: 8IbbZJ6lO8Tr Signed-off-by: Michael Niedermayer --- configure | 5 ----- doc/filters.texi | 2 -- libavfilter/vf_mcdeint.c | 30 +++++++++++++++++++++++------- 3 files changed, 23 insertions(+), 14 deletions(-) diff --git a/configure b/configure index 0370e25577..07b94e5e7c 100755 --- a/configure +++ b/configure @@ -7355,11 +7355,6 @@ esac enable frame_thread_encoder -# these filters depend on removed avcodec APIs -# they are kept disabled for now, but will be removed if -# nobody updates and re-enables them -disable mcdeint_filter - enabled asm || { arch=c; disable $ARCH_LIST $ARCH_EXT_LIST; } check_deps $CONFIG_LIST \ diff --git a/doc/filters.texi b/doc/filters.texi index d634924bfb..59c1faa0b4 100644 --- a/doc/filters.texi +++ b/doc/filters.texi @@ -16988,8 +16988,6 @@ Apply motion-compensation deinterlacing. It needs one field per frame as input and must thus be used together with yadif=1/3 or equivalent. -This filter is only available in ffmpeg version 4.4 or earlier. - This filter accepts the following options: @table @option @item mode diff --git a/libavfilter/vf_mcdeint.c b/libavfilter/vf_mcdeint.c index e747521c0a..a2c3e79b9e 100644 --- a/libavfilter/vf_mcdeint.c +++ b/libavfilter/vf_mcdeint.c @@ -75,6 +75,7 @@ typedef struct MCDeintContext { int parity; ///< MCDeintParity int qp; AVPacket *pkt; + AVFrame *frame_dec; AVCodecContext *enc_ctx; } MCDeintContext; @@ -116,6 +117,9 @@ static int config_props(AVFilterLink *inlink) mcdeint->pkt = av_packet_alloc(); if (!mcdeint->pkt) return AVERROR(ENOMEM); + mcdeint->frame_dec = av_frame_alloc(); + if (!mcdeint->frame_dec) + return AVERROR(ENOMEM); mcdeint->enc_ctx = avcodec_alloc_context3(enc); if (!mcdeint->enc_ctx) return AVERROR(ENOMEM); @@ -126,7 +130,7 @@ static int config_props(AVFilterLink *inlink) enc_ctx->gop_size = INT_MAX; enc_ctx->max_b_frames = 0; enc_ctx->pix_fmt = AV_PIX_FMT_YUV420P; - enc_ctx->flags = AV_CODEC_FLAG_QSCALE | AV_CODEC_FLAG_LOW_DELAY; + enc_ctx->flags = AV_CODEC_FLAG_QSCALE | AV_CODEC_FLAG_LOW_DELAY | AV_CODEC_FLAG_RECON_FRAME; enc_ctx->strict_std_compliance = FF_COMPLIANCE_EXPERIMENTAL; enc_ctx->global_quality = 1; enc_ctx->me_cmp = enc_ctx->me_sub_cmp = FF_CMP_SAD; @@ -160,15 +164,16 @@ static av_cold void uninit(AVFilterContext *ctx) av_packet_free(&mcdeint->pkt); avcodec_free_context(&mcdeint->enc_ctx); + av_frame_free(&mcdeint->frame_dec); } static int filter_frame(AVFilterLink *inlink, AVFrame *inpic) { MCDeintContext *mcdeint = inlink->dst->priv; AVFilterLink *outlink = inlink->dst->outputs[0]; - AVFrame *outpic, *frame_dec; + AVFrame *outpic, *frame_dec = mcdeint->frame_dec; AVPacket *pkt = mcdeint->pkt; - int x, y, i, ret, got_frame = 0; + int x, y, i, ret; outpic = ff_get_video_buffer(outlink, outlink->w, outlink->h); if (!outpic) { @@ -178,11 +183,22 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *inpic) av_frame_copy_props(outpic, inpic); inpic->quality = mcdeint->qp * FF_QP2LAMBDA; - ret = avcodec_encode_video2(mcdeint->enc_ctx, pkt, inpic, &got_frame); - if (ret < 0) + ret = avcodec_send_frame(mcdeint->enc_ctx, inpic); + if (ret < 0) { + av_log(mcdeint->enc_ctx, AV_LOG_ERROR, "Error sending a frame for encoding\n"); goto end; - - frame_dec = mcdeint->enc_ctx->coded_frame; + } + ret = avcodec_receive_packet(mcdeint->enc_ctx, pkt); + if (ret < 0) { + av_log(mcdeint->enc_ctx, AV_LOG_ERROR, "Error receiving a packet from encoding\n"); + goto end; + } + av_packet_unref(pkt); + ret = avcodec_receive_frame(mcdeint->enc_ctx, frame_dec); + if (ret < 0) { + av_log(mcdeint->enc_ctx, AV_LOG_ERROR, "Error receiving a frame from encoding\n"); + goto end; + } for (i = 0; i < 3; i++) { int is_chroma = !!i;