From patchwork Sun Jun 18 11:17:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Niklas Haas X-Patchwork-Id: 42196 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:be15:b0:121:b37c:e101 with SMTP id ge21csp57086pzb; Sun, 18 Jun 2023 04:22:21 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4bgsYBMN8rKrhTXG/kFw57jKaV45zbq7m3W7PpxbdU4fKRbkSAWHslNPGH9ogbj9W6POtl X-Received: by 2002:a05:6402:1150:b0:518:6a99:cac3 with SMTP id g16-20020a056402115000b005186a99cac3mr4236808edw.31.1687087341183; Sun, 18 Jun 2023 04:22:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687087341; cv=none; d=google.com; s=arc-20160816; b=H8xmadtPX8UPwm1ThutRBXxM90EuZp5lxVNYpY+qLzXsxAHzhrMI/wmIeRHfKdom9X q2dn3h/yUJJaXbZrRBRdBjk70juWNx8k5EozRX/xhtcBz7pRcmjP62/DA+03W0hmXh/4 8AK8tW0kf+Bx+4OCPWChCmWEfAvyKhJTmRmb0ErbxsRKe/TT/l05IeRFtbxk/Jk7jh+M iaMOIChsVqR3xZb0KJ523DoVelcxulBo9eJC1+8zSetvgM9stSOJmEOQuj/FHYYw7WIl 7aaF1UfpgHtfFblsbIwS3peMpd7ybTuW/3nl3FigeSY1RpCS6l6j5hTDA2Q+7zEuWVNq mUyg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature:delivered-to; bh=CiRzXHS/c3fzvyW0LrD7RoybeJPnv3T+Q3rzUKKa1aY=; b=1JPrXQ2G9QfJ0XX5/qpQH0221d+AptHzV8NQS9FtJELa5D3a+Dy/bMH3xEWeRJe9l2 LntrX4jZ0yaamTznJmSYJwhT84fiU9MDkpnfOTV2yNrINTyfCzkOXiCUmuqgAqVTFQim JXUzh9v/bAoWGvzp3wSJnxK+qj5iv2LFGTAcqrtkYGD02Dduhylj/tEUilWwB0TP10R7 S4J0TE0kFWZtOd44z+lgaUy3zfw1Lzd2DntfgsroV1H8/mmJ9s5vsphv9ucI7otoY6VM kzVBZBIVyV3jShhrc8nsNMPyx4gBarlq1DKxErxxsfcYE65xHhJfq4QuUECzU+sj+CwA Ruew== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@haasn.xyz header.s=mail header.b=rz27yykA; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id z20-20020aa7cf94000000b005169f6f7f6bsi13067750edx.56.2023.06.18.04.22.20; Sun, 18 Jun 2023 04:22:21 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@haasn.xyz header.s=mail header.b=rz27yykA; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 77D9A68C1A3; Sun, 18 Jun 2023 14:20:27 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from haasn.dev (haasn.dev [78.46.187.166]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 3629868BFCD for ; Sun, 18 Jun 2023 14:20:16 +0300 (EEST) Received: from haasn.dev (unknown [10.30.0.2]) by haasn.dev (Postfix) with ESMTP id CDDC042350; Sun, 18 Jun 2023 13:20:13 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=haasn.xyz; s=mail; t=1687087213; bh=EZ1q2zHJyuCM6EoSFE54qJ16jycEZfgBtEXyX+Wh4XM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rz27yykA/HEXlE52mbWrXSXnZvqV0X4Zj/EPt1RZDDPKX4TZznxqoP4Hdw9Z1/scC +uR6rvWjgNAIz/mv6i+9dkPhL6TTThAs72QPrTIw+QCqXd2Q24R997ZAMc/jztZvdt I2qEO2925I0NBzzLHwY4//fyFuaPA9GzMWy/v1Y8= From: Niklas Haas To: ffmpeg-devel@ffmpeg.org Date: Sun, 18 Jun 2023 13:17:14 +0200 Message-ID: <20230618111955.40994-24-ffmpeg@haasn.xyz> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230618111955.40994-2-ffmpeg@haasn.xyz> References: <20230618111955.40994-2-ffmpeg@haasn.xyz> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v2 22/22] lavfi/vf_libplacebo: add nb_inputs option 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: 81sGzYHUzMEo From: Niklas Haas To control the number of inputs. --- doc/filters.texi | 5 +++++ libavfilter/vf_libplacebo.c | 25 ++++++++++++++----------- 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/doc/filters.texi b/doc/filters.texi index cf17930b014..c3d3f004b19 100644 --- a/doc/filters.texi +++ b/doc/filters.texi @@ -16153,6 +16153,11 @@ to preserve the source colorimetry and size as best as it can, but it will apply any embedded film grain, dolby vision metadata or anamorphic SAR present in source frames. @table @option +@item inputs +Set the number of inputs. This can be used, alongside the @code{idx} variable, +to allow placing/blending multiple inputs inside the output frame. This +effectively enables functionality similar to @ref{hstack}, @ref{overlay}, etc. + @item w @item h Set the output video dimension expression. Default values are @code{iw} and diff --git a/libavfilter/vf_libplacebo.c b/libavfilter/vf_libplacebo.c index 09a24e7c291..056041d2131 100644 --- a/libavfilter/vf_libplacebo.c +++ b/libavfilter/vf_libplacebo.c @@ -502,6 +502,7 @@ static int parse_shader(AVFilterContext *avctx, const void *shader, size_t len) } static void libplacebo_uninit(AVFilterContext *avctx); +static int libplacebo_config_input(AVFilterLink *inlink); static int libplacebo_init(AVFilterContext *avctx) { @@ -530,6 +531,17 @@ static int libplacebo_init(AVFilterContext *avctx) s->out_format = AV_PIX_FMT_NONE; } + for (int i = 0; i < s->nb_inputs; i++) { + AVFilterPad pad = { + .name = av_asprintf("input%d", i), + .type = AVMEDIA_TYPE_VIDEO, + .config_props = &libplacebo_config_input, + }; + if (!pad.name) + return AVERROR(ENOMEM); + RET(ff_append_inpad_free_name(avctx, &pad)); + } + RET(update_settings(avctx)); RET(av_expr_parse(&s->crop_x_pexpr, s->crop_x_expr, var_names, NULL, NULL, NULL, NULL, 0, s)); @@ -665,7 +677,6 @@ static int init_vulkan(AVFilterContext *avctx, const AVVulkanDeviceContext *hwct } /* Initialize inputs */ - s->nb_inputs = 1; s->inputs = av_calloc(s->nb_inputs, sizeof(*s->inputs)); if (!s->inputs) return AVERROR(ENOMEM); @@ -1252,6 +1263,7 @@ fail: #define DYNAMIC (STATIC | AV_OPT_FLAG_RUNTIME_PARAM) static const AVOption libplacebo_options[] = { + { "inputs", "Number of inputs", OFFSET(nb_inputs), AV_OPT_TYPE_INT, {.i64 = 1}, 1, INT_MAX, .flags = STATIC }, { "w", "Output video frame width", OFFSET(w_expr), AV_OPT_TYPE_STRING, {.str = "iw"}, .flags = STATIC }, { "h", "Output video frame height", OFFSET(h_expr), AV_OPT_TYPE_STRING, {.str = "ih"}, .flags = STATIC }, { "fps", "Output video frame rate", OFFSET(fps_string), AV_OPT_TYPE_STRING, {.str = "none"}, .flags = STATIC }, @@ -1443,14 +1455,6 @@ static const AVOption libplacebo_options[] = { AVFILTER_DEFINE_CLASS(libplacebo); -static const AVFilterPad libplacebo_inputs[] = { - { - .name = "default", - .type = AVMEDIA_TYPE_VIDEO, - .config_props = &libplacebo_config_input, - }, -}; - static const AVFilterPad libplacebo_outputs[] = { { .name = "default", @@ -1467,10 +1471,9 @@ const AVFilter ff_vf_libplacebo = { .uninit = &libplacebo_uninit, .activate = &libplacebo_activate, .process_command = &libplacebo_process_command, - FILTER_INPUTS(libplacebo_inputs), FILTER_OUTPUTS(libplacebo_outputs), FILTER_QUERY_FUNC(libplacebo_query_format), .priv_class = &libplacebo_class, .flags_internal = FF_FILTER_FLAG_HWFRAME_AWARE, - .flags = AVFILTER_FLAG_HWDEVICE, + .flags = AVFILTER_FLAG_HWDEVICE | AVFILTER_FLAG_DYNAMIC_INPUTS, };