From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.ffmpeg.org (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTPS id AAE0E4C687 for ; Thu, 11 Sep 2025 00:06:24 +0000 (UTC) Authentication-Results: ffbox; dkim=fail (body hash mismatch (got b'DA3hJ4odQ6si11/c0CDIbHyX50l0XuZpxKe73niTZjQ=', expected b'N/KkfuaSkFOKdmMkiqxxPH+lEvtfzS+L32x0/7TgL9w=')) header.d=ffmpeg.org header.i=@ffmpeg.org header.a=rsa-sha256 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ffmpeg.org; i=@ffmpeg.org; q=dns/txt; s=mail; t=1757549158; h=mime-version : to : date : message-id : reply-to : subject : list-id : list-archive : list-archive : list-help : list-owner : list-post : list-subscribe : list-unsubscribe : from : cc : content-type : content-transfer-encoding : from; bh=DA3hJ4odQ6si11/c0CDIbHyX50l0XuZpxKe73niTZjQ=; b=Uz6z+9CY+X9KpOVHwc+g0iHZK/bYAKwDwfJt6V2l8K3u9rH247A2atFAjEJSHKav2LVKJ o3GImkCAt+z70e58Z2SlG9Qpwi3WLrzW8SCeU6E1Df33EZ5i+oGqKSvfSJeFvq4mjvKdh9G VkPK+W4iSAkMNJNqPvUUNxq/qzojyTJYKDb7qoLJYC1A2STG6Muke+vScW7evlJZniqpN8i 9vD94jzLQN9OzSQBKZ842t+9qErO1LGszhvh1N8cuPXJBjxyUIMOSSoU1jYydejtINZyz2i W6PiFRiIZ05UwKQbDl6O/o6EKQgAvkJcaXgZLoptbCnLCX61J4uiKxCZ6P/A== Received: from [172.19.0.4] (unknown [172.19.0.4]) by ffbox0-bg.ffmpeg.org (Postfix) with ESMTP id 8107668E79C; Thu, 11 Sep 2025 03:05:58 +0300 (EEST) ARC-Seal: i=1; cv=none; a=rsa-sha256; d=ffmpeg.org; s=arc; t=1757549155; b=fBloG/HuwWR/3ANIoV0RyRk0nfxs0vbG2CCIphl/xhwQbBxqEkhrqknpNwUGdM9P2mf66 DCj3Vbn0KdinbZtuaaPNOvZM+gr2EkgC9s+LnDLW70Bx+Qi49fS9/PP2F0wbe5iyRdhjiB+ Cf0LTEer67pElB7jg1chuvbJtW5HACvu9HWfjb0QKwZxcVqkOLGiQzhc41jxlP31CbjJhOY 1TQqbJiVJCjBCCxucL3LM45nJCZmdWuiNmHbjKErJPvN8Ij17IrEsXdPn1rE4DKTgkHMW2U xjGzDbvyaRtF0hG+0cu/LawU77ezoZn8IaTGwNhawH6BIDWKzcJ6sl5Dp7+g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=ffmpeg.org; s=arc; t=1757549155; h=from : sender : reply-to : subject : date : message-id : to : cc : mime-version : content-type : content-transfer-encoding : content-id : content-description : resent-date : resent-from : resent-sender : resent-to : resent-cc : resent-message-id : in-reply-to : references : list-id : list-help : list-unsubscribe : list-subscribe : list-post : list-owner : list-archive; bh=dh1GGt5tz0SiUafuUxzBUT8/ZADicNdUJQGB3V8Ng0g=; b=q9SZKBUC8kPNWNvEqhCsqIW/yeQq7cMIgepERiKZwzV78dsuc7DAx9aAzsPBbrn0hKKAU BA6aFr8WV3HOxylcQ0Mp8/sPo+RDslQevNT3SM3ahizdobIYW6H4l1N6t8GSE0TCsqwCJgK HcGjSquUCzC64o/5q3wyrGCrz4v02f+JsVioTVM0EdZ+Jq8vZD4lzwLq2s03wak8udECKkp IEVk2LXIUwEtrxbFd8E9GEOKx91CCk6x1YUzHeXKWoJI0u2HRFSwmH3yd74UdNRjretmgGy bzy1bhV9asQM3z32tFdspGPhf73D8BDlDERauyIfSZ4cOzoSLjAro1WYGI5A== ARC-Authentication-Results: i=1; ffmpeg.org; dkim=pass header.d=ffmpeg.org header.i=@ffmpeg.org; arc=none; dmarc=none Authentication-Results: ffmpeg.org; dkim=pass header.d=ffmpeg.org header.i=@ffmpeg.org; arc=none (Message is not ARC signed); dmarc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ffmpeg.org; i=@ffmpeg.org; q=dns/txt; s=mail; t=1757549140; h=content-type : mime-version : content-transfer-encoding : from : to : reply-to : subject : date : from; bh=N/KkfuaSkFOKdmMkiqxxPH+lEvtfzS+L32x0/7TgL9w=; b=OOQzPLo0LmcfHCJVoQZGXeyi7b+j/xokDHsUhlnZW3oSIFtEUvniDnVony1qxTpq0LNdp b5JjN4Bw5Mijqt5jE4gEHoKwXjccTAKxx7fANWyXMzESKxDR9i7hpCTPNL0am2V9dLZ5GiK JwVjQKTkKJQdlK7gbAVs5dQMIlcS/sYutJ+0mDWRjeyf+PFDN4Fetub/r0XO8UR5M1b3foN lPcl3MyRPFxEs+w8cwuYJ9x1AKrOcFtBimf857CPZgx7RqfIQ26g58HSEtUAT1oJRnNua6C wKgFAnoNrpGUGbwb/yfV/5OBAZ2A32H6jt9uVPI6ZM3a5/02IyIUn8HRkixw== Received: from 3f9d35a0eedc (code.ffmpeg.org [188.245.149.3]) by ffbox0-bg.ffmpeg.org (Postfix) with ESMTPS id 2EE8C68E6D0 for ; Thu, 11 Sep 2025 03:05:40 +0300 (EEST) MIME-Version: 1.0 To: ffmpeg-devel@ffmpeg.org Date: Thu, 11 Sep 2025 00:05:39 -0000 Message-ID: <175754914053.25.2176504532139457440@463a07221176> Message-ID-Hash: S3UJQSM56FSEH3EE7WELPZLWQBIDFDKN X-Message-ID-Hash: S3UJQSM56FSEH3EE7WELPZLWQBIDFDKN X-MailFrom: code@ffmpeg.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; header-match-ffmpeg-devel.ffmpeg.org-0; header-match-ffmpeg-devel.ffmpeg.org-1; header-match-ffmpeg-devel.ffmpeg.org-2; header-match-ffmpeg-devel.ffmpeg.org-3; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list Reply-To: FFmpeg development discussions and patches Subject: [FFmpeg-devel] [PATCH] avfilter/vf_libplacebo: two blending-related fixes (PR #20491) List-Id: FFmpeg development discussions and patches Archived-At: Archived-At: List-Archive: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Niklas Haas via ffmpeg-devel Cc: Niklas Haas Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Archived-At: List-Archive: List-Post: PR #20491 opened by Niklas Haas (haasn) URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20491 Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20491.patch >>From 71d4a88136e731bddf2673e13ed393efe9c2fdd5 Mon Sep 17 00:00:00 2001 From: Niklas Haas Date: Thu, 11 Sep 2025 01:39:46 +0200 Subject: [PATCH 1/2] avfilter/vf_libplacebo: use temporary params struct for per-pass params Instead of directly mutating `opts->params`. Avoids any possible leak of overriden params between invocations of this function, as well as the later `pl_render_image` during the linear output pass. --- libavfilter/vf_libplacebo.c | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/libavfilter/vf_libplacebo.c b/libavfilter/vf_libplacebo.c index 5e0a678ff2..8f30eb193b 100644 --- a/libavfilter/vf_libplacebo.c +++ b/libavfilter/vf_libplacebo.c @@ -1038,12 +1038,7 @@ props_done: } /* Draw first frame opaque, others with blending */ - opts->params.blend_params = NULL; -#if PL_API_VER >= 346 - opts->params.background = opts->params.border = PL_CLEAR_COLOR; -#else - opts->params.skip_target_clearing = false; -#endif + struct pl_render_params tmp_params = opts->params; for (int i = 0; i < s->nb_inputs; i++) { LibplaceboInput *in = &s->inputs[i]; FilterLink *il = ff_filter_link(ctx->inputs[i]); @@ -1053,17 +1048,17 @@ props_done: pl_renderer_flush_cache(in->renderer); continue; } - opts->params.skip_caching_single_frame = high_fps; + tmp_params.skip_caching_single_frame = high_fps; update_crops(ctx, in, &target, target_pts); - pl_render_image_mix(in->renderer, &in->mix, &target, &opts->params); + pl_render_image_mix(in->renderer, &in->mix, &target, &tmp_params); /* Force straight output and set correct blend mode */ target.repr.alpha = PL_ALPHA_INDEPENDENT; - opts->params.blend_params = &pl_alpha_overlay; + tmp_params.blend_params = &pl_alpha_overlay; #if PL_API_VER >= 346 - opts->params.background = opts->params.border = PL_CLEAR_SKIP; + tmp_params.background = tmp_params.border = PL_CLEAR_SKIP; #else - opts->params.skip_target_clearing = true; + tmp_params.skip_target_clearing = true; #endif } -- 2.49.1 >>From ba24b8bf6f6003901af92c83a442d49263cab9d3 Mon Sep 17 00:00:00 2001 From: Niklas Haas Date: Thu, 11 Sep 2025 01:48:32 +0200 Subject: [PATCH 2/2] avfilter/vf_libplacebo: force premultiplied blending for linear texture Blending onto independent alpha framebuffers is not possible under the constraints of the supported blend operators. While we could handle blending premul-onto-premul, this would break if the base layer is YUV, since premultiplied alpha does not survive the (nonlinear) YUV conversion. Fortunately, blending independent-onto-premul is just as easy, and works in all cases. So just force this mode when using a linear intermediate blend texture, which is always RGBA. --- libavfilter/vf_libplacebo.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libavfilter/vf_libplacebo.c b/libavfilter/vf_libplacebo.c index 8f30eb193b..80d3b273bb 100644 --- a/libavfilter/vf_libplacebo.c +++ b/libavfilter/vf_libplacebo.c @@ -1033,6 +1033,7 @@ props_done: .color = orig_target.color, .rotation = orig_target.rotation, }; + target.repr.alpha = PL_ALPHA_PREMULTIPLIED; target.color.transfer = PL_COLOR_TRC_LINEAR; use_linear_compositor = true; } @@ -1052,7 +1053,8 @@ props_done: update_crops(ctx, in, &target, target_pts); pl_render_image_mix(in->renderer, &in->mix, &target, &tmp_params); - /* Force straight output and set correct blend mode */ + /* Force straight output and set correct blend operator. This is + * required to get correct blending onto YUV target buffers. */ target.repr.alpha = PL_ALPHA_INDEPENDENT; tmp_params.blend_params = &pl_alpha_overlay; #if PL_API_VER >= 346 @@ -1065,6 +1067,7 @@ props_done: if (use_linear_compositor) { /* Blit the linear intermediate image to the output frame */ target.crop = orig_target.crop = (struct pl_rect2df) {0}; + target.repr.alpha = PL_ALPHA_PREMULTIPLIED; pl_render_image(s->linear_rr, &target, &orig_target, &opts->params); target = orig_target; } else if (!ref) { -- 2.49.1 _______________________________________________ ffmpeg-devel mailing list -- ffmpeg-devel@ffmpeg.org To unsubscribe send an email to ffmpeg-devel-leave@ffmpeg.org