Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
From: Niklas Haas <ffmpeg@haasn.xyz>
To: ffmpeg-devel@ffmpeg.org
Cc: Niklas Haas <git@haasn.dev>
Subject: [FFmpeg-devel] [PATCH v2 22/22] lavfi/vf_libplacebo: add nb_inputs option
Date: Sun, 18 Jun 2023 13:17:14 +0200
Message-ID: <20230618111955.40994-24-ffmpeg@haasn.xyz> (raw)
In-Reply-To: <20230618111955.40994-2-ffmpeg@haasn.xyz>

From: Niklas Haas <git@haasn.dev>

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,
 };
-- 
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".

  parent reply	other threads:[~2023-06-18 11:22 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-18 11:16 [FFmpeg-devel] lavfi/vf_libplacebo: generalize to multiple inputs Niklas Haas
2023-06-18 11:16 ` [FFmpeg-devel] [PATCH v2 01/22] lavfi/vf_libplacebo: drop redundant case Niklas Haas
2023-06-18 11:16 ` [FFmpeg-devel] [PATCH v2 02/22] lavfi/vf_libplacebo: move input-specific state to struct Niklas Haas
2023-06-18 11:16 ` [FFmpeg-devel] [PATCH v2 03/22] lavfi/vf_libplacebo: move input handling to separate function Niklas Haas
2023-06-18 11:16 ` [FFmpeg-devel] [PATCH v2 04/22] lavfi/vf_libplacebo: cosmetic Niklas Haas
2023-06-18 11:16 ` [FFmpeg-devel] [PATCH v2 05/22] lavfi/vf_libplacebo: move temporary vars into per-input struct Niklas Haas
2023-06-18 11:16 ` [FFmpeg-devel] [PATCH v2 06/22] lavif/vf_libplacebo: remove pl_frame_mix from output_frame_mix Niklas Haas
2023-06-18 11:16 ` [FFmpeg-devel] [PATCH v2 07/22] lavfi/vf_libplacebo: factor out ref frame logic Niklas Haas
2023-06-18 11:17 ` [FFmpeg-devel] [PATCH v2 08/22] lavfi/vf_libplacebo: use correct link in update_crops() Niklas Haas
2023-06-18 11:17 ` [FFmpeg-devel] [PATCH v2 09/22] lavfi/vf_libplacebo: replace s->input by dynamic array Niklas Haas
2023-06-18 11:17 ` [FFmpeg-devel] [PATCH v2 10/22] lavfi/vf_libplacebo: keep track of latest status globally Niklas Haas
2023-06-18 11:17 ` [FFmpeg-devel] [PATCH v2 11/22] lavfi/vf_libplacebo: support blending multiple inputs Niklas Haas
2023-06-18 11:17 ` [FFmpeg-devel] [PATCH v2 12/22] lavfi/vf_libplacebo: handle " Niklas Haas
2023-06-18 11:17 ` [FFmpeg-devel] [PATCH v2 13/22] lavfi/vf_libplacebo: determine PTS of next frame from any input Niklas Haas
2023-06-18 11:17 ` [FFmpeg-devel] [PATCH v2 14/22] lavfi/vf_libplacebo: only drain actually used PTS Niklas Haas
2023-06-18 11:17 ` [FFmpeg-devel] [PATCH v2 15/22] lavfi/vf_libplacebo: generalize frame update to multiple inputs Niklas Haas
2023-06-18 11:17 ` [FFmpeg-devel] [PATCH v2 16/22] lavfi/vf_libplacebo: make input-dependent vars dynamic Niklas Haas
2023-06-18 11:17 ` [FFmpeg-devel] [PATCH v2 17/22] lavfi/vf_libplacebo: add in_idx variable Niklas Haas
2023-06-18 11:17 ` [FFmpeg-devel] [PATCH v2 18/22] lavfi/vf_libplacebo: set format list for all inputs Niklas Haas
2023-06-18 11:17 ` [FFmpeg-devel] [PATCH v2 19/22] lavfi/vf_libplacebo: skip cache selectively per-input Niklas Haas
2023-06-18 11:17 ` [FFmpeg-devel] [PATCH v2 20/22] lavfi/vf_libplacebo: also skip cache if in FPS == out FPS Niklas Haas
2023-06-18 11:17 ` [FFmpeg-devel] [PATCH v2 21/22] lavfi/vf_libplacebo: set time_base/frame_rate dynamically Niklas Haas
2023-06-18 11:17 ` Niklas Haas [this message]
2023-06-20 14:50 ` [FFmpeg-devel] lavfi/vf_libplacebo: generalize to multiple inputs Marvin Scholz
2023-06-20 15:12   ` Niklas Haas

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230618111955.40994-24-ffmpeg@haasn.xyz \
    --to=ffmpeg@haasn.xyz \
    --cc=ffmpeg-devel@ffmpeg.org \
    --cc=git@haasn.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
		ffmpegdev@gitmailbox.com
	public-inbox-index ffmpegdev

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git