From d69ccbfc18e7b3250e8edba4430c0232e2ff223e Mon Sep 17 00:00:00 2001 From: Niklas Haas Date: Thu, 7 Aug 2025 22:25:32 +0200 Subject: [PATCH] avfilter/vf_libplacebo: use the first visible input for metadata Instead of undconditionally using the first input. This covers the case of one layer fully obscuring another layer, in which case that should become the new "base" layer. --- libavfilter/vf_libplacebo.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/libavfilter/vf_libplacebo.c b/libavfilter/vf_libplacebo.c index d15c89b51e..bd5abb0b40 100644 --- a/libavfilter/vf_libplacebo.c +++ b/libavfilter/vf_libplacebo.c @@ -940,7 +940,11 @@ static int output_frame(AVFilterContext *ctx, int64_t pts) if (!cropped && cur->repr.alpha == PL_ALPHA_NONE) { idx_start = i; nb_visible = 0; + ref = NULL; } + /* Use first visible input as overall reference */ + if (!ref) + ref = ref_frame(&in->mix); nb_visible++; } @@ -948,15 +952,6 @@ static int output_frame(AVFilterContext *ctx, int64_t pts) * valid nonempty frame mix */ av_assert1(nb_visible > 0); - /* Use the first active input as metadata reference */ - for (int i = 0; i < s->nb_inputs; i++) { - const LibplaceboInput *in = &s->inputs[i]; - if (in->qstatus == PL_QUEUE_OK && (ref = ref_frame(&in->mix))) - break; - } - if (!ref) - return 0; - out = ff_get_video_buffer(outlink, outlink->w, outlink->h); if (!out) return AVERROR(ENOMEM);