From: Michael Niedermayer <michael@niedermayer.cc> To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org> Subject: [FFmpeg-devel] [PATCH v2 3/3] avfilter/vf_mcdeint: update to new API Date: Sun, 19 Mar 2023 20:42:40 +0100 Message-ID: <20230319194240.15001-3-michael@niedermayer.cc> (raw) In-Reply-To: <20230319194240.15001-1-michael@niedermayer.cc> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc> --- 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; -- 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".
next prev parent reply other threads:[~2023-03-19 19:43 UTC|newest] Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top 2023-03-19 19:42 [FFmpeg-devel] [PATCH v2 1/3] avcodec/snowenc: AV_CODEC_CAP_ENCODER_RECON_FRAME support Michael Niedermayer 2023-03-19 19:42 ` [FFmpeg-devel] [PATCH v2 2/3] avfilter/vf_uspp: add AV_CODEC_FLAG_RECON_FRAME support Michael Niedermayer 2023-03-19 19:42 ` Michael Niedermayer [this message] 2023-03-20 22:07 ` [FFmpeg-devel] [PATCH v2 1/3] avcodec/snowenc: AV_CODEC_CAP_ENCODER_RECON_FRAME support James Almer 2023-03-23 9:50 ` Michael Niedermayer 2023-03-23 11:32 ` James Almer 2023-03-24 0:08 ` Michael Niedermayer 2023-03-25 20:56 ` Michael Niedermayer
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20230319194240.15001-3-michael@niedermayer.cc \ --to=michael@niedermayer.cc \ --cc=ffmpeg-devel@ffmpeg.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel This inbox may be cloned and mirrored by anyone: git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git # If you have public-inbox 1.1+ installed, you may # initialize and index your mirror using the following commands: public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \ ffmpegdev@gitmailbox.com public-inbox-index ffmpegdev Example config snippet for mirrors. AGPL code for this site: git clone https://public-inbox.org/public-inbox.git