Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
From: Nicolas George <george@nsup.org>
To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org>
Subject: Re: [FFmpeg-devel] [PATCH] avfilter/vf_alphamerge: use refcounting for planar formats
Date: Sat, 9 Aug 2025 19:46:58 +0200
Message-ID: <aJeJkrKYK5CRJvt_@phare.normalesup.org> (raw)
In-Reply-To: <CAHPA9KRf-_3on1ru1KhP6+xX-rt7xxMJmEA1GKA66qBoaGeOGw@mail.gmail.com>

Jorge Estrada (HE12025-08-07):
> From b413b7f8a966c2cf77c8703b5f68e8ea492d930a Mon Sep 17 00:00:00 2001
> From: Jorge Estrada <jestrada.list@gmail.com>
> Date: Thu, 7 Aug 2025 12:55:19 -0700
> Subject: use av_buffer_replace
> 
> Addressed. Uses av_buffer_replace now
> 
> ---
>  libavfilter/vf_alphamerge.c | 24 +++++++++++++++++-------
>  1 file changed, 17 insertions(+), 7 deletions(-)
> 
> diff --git a/libavfilter/vf_alphamerge.c b/libavfilter/vf_alphamerge.c
> index f5779484a9..69c0dd04ea 100644
> --- a/libavfilter/vf_alphamerge.c
> +++ b/libavfilter/vf_alphamerge.c
> @@ -28,12 +28,12 @@
>  #include "libavutil/imgutils.h"
>  #include "libavutil/opt.h"
>  #include "libavutil/pixfmt.h"
> +#include "libavutil/frame.h"
>  #include "avfilter.h"
>  #include "drawutils.h"
>  #include "formats.h"
>  #include "filters.h"
>  #include "framesync.h"
> -#include "video.h"
>  
>  enum { Y, U, V, A };
>  
> @@ -78,11 +78,21 @@ static int do_alphamerge(FFFrameSync *fs)
>              }
>          }
>      } else {
> -        const int main_linesize = main_buf->linesize[A];
> -        const int alpha_linesize = alpha_buf->linesize[Y];
> -        av_image_copy_plane(main_buf->data[A], main_linesize,
> -                            alpha_buf->data[Y], alpha_linesize,
> -                            FFMIN(main_linesize, alpha_linesize), alpha_buf->height);
> +        AVBufferRef *alpha_plane_buf = av_frame_get_plane_buffer(alpha_buf, Y);
> +
> +        if (!alpha_plane_buf) {
> +            av_log(ctx, AV_LOG_ERROR, "Could not get buffer for alpha plane.\n");

> +            return AVERROR(EINVAL);

That should probably be AVERROR_BUG.

> +        }
> +
> +        ret = av_buffer_replace(&main_buf->buf[A], alpha_plane_buf);
> +        if (ret < 0) {
> +            av_log(ctx, AV_LOG_ERROR, "Failed to replace alpha plane buffer.\n");
> +            return ret;
> +        }
> +
> +        main_buf->data[A] = alpha_buf->data[Y];
> +        main_buf->linesize[A] = alpha_buf->linesize[Y];
>      }
>  
>      return ff_filter_frame(ctx->outputs[0], main_buf);
> @@ -212,4 +222,4 @@ const FFFilter ff_vf_alphamerge = {
>      FILTER_QUERY_FUNC2(query_formats),
>      .uninit         = uninit,
>      .activate       = activate,
> -};
> +};
> \ No newline at end of file

You really need to fix you editor to not have it remove the final
newline.

I am assuming that you of course tested it on a few cases and ran FATE.
If so, apart from the details above, LGTM. Thanks for your efforts.

Regards,

-- 
  Nicolas George
_______________________________________________
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".

  reply	other threads:[~2025-08-09 17:47 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-07 19:58 Jorge Estrada
2025-08-07 20:12 ` James Almer
2025-08-07 23:21   ` Jorge Estrada
2025-08-09 17:46     ` Nicolas George [this message]
2025-08-07 23:14 ` [FFmpeg-devel] use av_buffer_replace Jorge Estrada

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=aJeJkrKYK5CRJvt_@phare.normalesup.org \
    --to=george@nsup.org \
    --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