PR #24885 opened by SidheshwarSarangal URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/24885 Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/24885.patch
Description: Reuse the alpha input frame's luma plane buffer for the output alpha plane instead of copying the plane for planar formats. The packed RGB path is unchanged. Tested with: make -j2 make TARGET_PATH=/tmp/ffmpeg-fate fate-filter-alphaextract_alphamerge_rgb fate-filter-alphaextract_alphamerge_yuv >From a9ad3baea482794dd0fea1a35c2ed100583f9516 Mon Sep 17 00:00:00 2001 From: Sidheshwar Sarangal <[email protected]> Date: Mon, 5 Oct 2026 15:14:42 +0530 Subject: [PATCH] avfilter/alphamerge: reuse alpha plane buffer Signed-off-by: Sidheshwar Sarangal <[email protected]> --- libavfilter/vf_alphamerge.c | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/libavfilter/vf_alphamerge.c b/libavfilter/vf_alphamerge.c index b5c7b3d9af..5555c960aa 100644 --- a/libavfilter/vf_alphamerge.c +++ b/libavfilter/vf_alphamerge.c @@ -25,6 +25,7 @@ #include <string.h> +#include "libavutil/frame.h" #include "libavutil/imgutils.h" #include "libavutil/opt.h" #include "libavutil/pixfmt.h" @@ -33,7 +34,6 @@ #include "formats.h" #include "filters.h" #include "framesync.h" -#include "video.h" enum { Y, U, V, A }; @@ -80,11 +80,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_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); -- 2.52.0 _______________________________________________ ffmpeg-devel mailing list -- [email protected] To unsubscribe send an email to [email protected]
