From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id 4598345248 for ; Fri, 16 Jun 2023 09:32:49 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id CEAC768C60C; Fri, 16 Jun 2023 12:30:41 +0300 (EEST) Received: from haasn.dev (haasn.dev [78.46.187.166]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id ACDB668C5C1 for ; Fri, 16 Jun 2023 12:30:26 +0300 (EEST) Received: from localhost (217-74-0-168.hsi.r-kom.net [217.74.0.168]) by haasn.dev (Postfix) with ESMTPSA id 93B01401C9; Fri, 16 Jun 2023 11:30:25 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=haasn.xyz; s=mail; t=1686907825; bh=2tTB0IMGtozgW9u82SARVZ//nWaM1y+3xxPJ1k1hf0w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rRmYna41lghluao6risBgqsGAvQiwPp5hIOyMXdd51w51LsU4HN0r6qzTeuAChiP3 rVCvJp7R1MFIIU3ZFRUXfYfSEMqSraJCflalVz0TXcwcJRn/KrY8wHkIcvLGHwR6AO bTI1PWs0M9l69ygcN0JQoPyJc/mfdCS/ep2xrh50= From: Niklas Haas To: ffmpeg-devel@ffmpeg.org Date: Fri, 16 Jun 2023 11:29:48 +0200 Message-ID: <20230616092959.5247-11-ffmpeg@haasn.xyz> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230616092959.5247-1-ffmpeg@haasn.xyz> References: <20230616092959.5247-1-ffmpeg@haasn.xyz> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 11/22] lavfi/vf_libplacebo: support blending multiple inputs X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: Niklas Haas Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: From: Niklas Haas Subsequent inputs required frame blending to be enable, in order to not overwrite the existing frame contents. For output metadata, we implicitly copy the metadata of the *first* available stream (falling back to the second stream if the first has already reached EOF, and so on). This is done to resolve any conflicts between inputs with differing metadata. So when e.g. input 1 is HDR and output 2 is SDR, the output will be HDR, and vice versa. This logic could probablly be improved by dynamically determining some "superior" set of metadata, but I don't want to handle that complexity in this series. --- libavfilter/vf_libplacebo.c | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/libavfilter/vf_libplacebo.c b/libavfilter/vf_libplacebo.c index d6f19f166d..3d812569f1 100644 --- a/libavfilter/vf_libplacebo.c +++ b/libavfilter/vf_libplacebo.c @@ -784,12 +784,18 @@ static int output_frame(AVFilterContext *ctx, int64_t pts) { int err = 0, ok, changed_csp; LibplaceboContext *s = ctx->priv; - LibplaceboInput *in = &s->inputs[0]; AVFilterLink *outlink = ctx->outputs[0]; const AVPixFmtDescriptor *outdesc = av_pix_fmt_desc_get(outlink->format); - const AVFrame *ref = ref_frame(&in->mix); struct pl_frame target; + const AVFrame *ref = NULL; AVFrame *out; + + /* 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; @@ -860,8 +866,18 @@ static int output_frame(AVFilterContext *ctx, int64_t pts) goto fail; } - update_crops(ctx, in, &target, out->pts * av_q2d(outlink->time_base)); - pl_render_image_mix(in->renderer, &in->mix, &target, &s->params); + /* Draw first frame opaque, others with blending */ + s->params.skip_target_clearing = false; + s->params.blend_params = NULL; + for (int i = 0; i < s->nb_inputs; i++) { + LibplaceboInput *in = &s->inputs[i]; + if (in->qstatus != PL_QUEUE_OK) + continue; + update_crops(ctx, in, &target, out->pts * av_q2d(outlink->time_base)); + pl_render_image_mix(in->renderer, &in->mix, &target, &s->params); + s->params.skip_target_clearing = true; + s->params.blend_params = &pl_alpha_overlay; + } if (outdesc->flags & AV_PIX_FMT_FLAG_HWACCEL) { pl_unmap_avframe(s->gpu, &target); -- 2.41.0 _______________________________________________ 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".