From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id 7DDD342458 for ; Sun, 19 Mar 2023 14:15:35 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 1200468C34C; Sun, 19 Mar 2023 16:15:25 +0200 (EET) Received: from relay9-d.mail.gandi.net (relay9-d.mail.gandi.net [217.70.183.199]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 055FE68C296 for ; Sun, 19 Mar 2023 16:15:16 +0200 (EET) Received: (Authenticated sender: michael@niedermayer.cc) by mail.gandi.net (Postfix) with ESMTPSA id 24012FF802 for ; Sun, 19 Mar 2023 14:15:15 +0000 (UTC) From: Michael Niedermayer To: FFmpeg development discussions and patches Date: Sun, 19 Mar 2023 15:15:14 +0100 Message-Id: <20230319141514.28134-2-michael@niedermayer.cc> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230319141514.28134-1-michael@niedermayer.cc> References: <20230319141514.28134-1-michael@niedermayer.cc> Subject: [FFmpeg-devel] [PATCH 2/2] avfilter/vf_uspp: add AV_CODEC_FLAG_RECON_FRAME support 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 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: about 50% faster (based on command line fps) Signed-off-by: Michael Niedermayer --- libavfilter/vf_uspp.c | 41 ++++++++++++++++++++++++++++------------- 1 file changed, 28 insertions(+), 13 deletions(-) diff --git a/libavfilter/vf_uspp.c b/libavfilter/vf_uspp.c index f60eb230a2..9318410089 100644 --- a/libavfilter/vf_uspp.c +++ b/libavfilter/vf_uspp.c @@ -231,16 +231,25 @@ static int filter_1phase(AVFilterContext *ctx, void *arg, int i, int nb_jobs) return ret; } - ret = avcodec_send_packet(p->avctx_dec[i], pkt); - av_packet_unref(pkt); - if (ret < 0) { - av_log(p->avctx_dec[i], AV_LOG_ERROR, "Error sending a packet for decoding\n"); - return ret; - } - ret = avcodec_receive_frame(p->avctx_dec[i], p->frame_dec[i]); - if (ret < 0) { - av_log(p->avctx_dec[i], AV_LOG_ERROR, "Error receiving a frame from decoding\n"); - return ret; + if (p->avctx_enc[i]->flags & AV_CODEC_FLAG_RECON_FRAME) { + av_packet_unref(pkt); + ret = avcodec_receive_frame(p->avctx_enc[i], p->frame_dec[i]); + if (ret < 0) { + av_log(p->avctx_dec[i], AV_LOG_ERROR, "Error receiving a frame from encoding\n"); + return ret; + } + } else { + ret = avcodec_send_packet(p->avctx_dec[i], pkt); + av_packet_unref(pkt); + if (ret < 0) { + av_log(p->avctx_dec[i], AV_LOG_ERROR, "Error sending a packet for decoding\n"); + return ret; + } + ret = avcodec_receive_frame(p->avctx_dec[i], p->frame_dec[i]); + if (ret < 0) { + av_log(p->avctx_dec[i], AV_LOG_ERROR, "Error receiving a frame from decoding\n"); + return ret; + } } offset = (BLOCK-x1) + (BLOCK-y1) * p->frame_dec[i]->linesize[0]; @@ -397,6 +406,10 @@ static int config_input(AVFilterLink *inlink) avctx_enc->max_b_frames = 0; avctx_enc->pix_fmt = inlink->format; avctx_enc->flags = AV_CODEC_FLAG_QSCALE | AV_CODEC_FLAG_LOW_DELAY; + if (enc->capabilities & AV_CODEC_CAP_ENCODER_RECON_FRAME) { + avctx_enc->flags |= AV_CODEC_FLAG_RECON_FRAME; + av_dict_set(&opts, "no_bitstream", "1", 0); + } avctx_enc->strict_std_compliance = FF_COMPLIANCE_EXPERIMENTAL; avctx_enc->global_quality = 123; avctx_dec->thread_count = @@ -408,9 +421,11 @@ static int config_input(AVFilterLink *inlink) av_assert0(avctx_enc->codec); - ret = avcodec_open2(avctx_dec, dec, NULL); - if (ret < 0) - return ret; + if (!(enc->capabilities & AV_CODEC_CAP_ENCODER_RECON_FRAME)) { + ret = avcodec_open2(avctx_dec, dec, NULL); + if (ret < 0) + return ret; + } if (!(uspp->frame[i] = av_frame_alloc())) return AVERROR(ENOMEM); -- 2.17.1 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".