The branch, master has been updated via 899e497122f793c3d97f5aac7bee62567f23fe29 (commit) via 6f08ab6c4c2e5eeef3e0704b21c338c512cf97f6 (commit) from 5c9b2027bc48ae5d39b0d82696895f0834788242 (commit)
- Log ----------------------------------------------------------------- commit 899e497122f793c3d97f5aac7bee62567f23fe29 Author: Niklas Haas <g...@haasn.dev> AuthorDate: Thu Sep 11 01:48:32 2025 +0200 Commit: Niklas Haas <ffm...@haasn.dev> CommitDate: Tue Sep 23 18:50:03 2025 +0000 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. 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) { commit 6f08ab6c4c2e5eeef3e0704b21c338c512cf97f6 Author: Niklas Haas <g...@haasn.dev> AuthorDate: Thu Sep 11 01:39:46 2025 +0200 Commit: Niklas Haas <ffm...@haasn.dev> CommitDate: Tue Sep 23 18:50:03 2025 +0000 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. 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 } ----------------------------------------------------------------------- Summary of changes: libavfilter/vf_libplacebo.c | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) hooks/post-receive -- _______________________________________________ ffmpeg-cvslog mailing list -- ffmpeg-cvslog@ffmpeg.org To unsubscribe send an email to ffmpeg-cvslog-le...@ffmpeg.org