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 E2696467A5 for ; Sun, 18 Jun 2023 11:21:26 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 8F94268C09A; Sun, 18 Jun 2023 14:20:21 +0300 (EEST) Received: from haasn.dev (haasn.dev [78.46.187.166]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 050FA68BFA9 for ; Sun, 18 Jun 2023 14:20:15 +0300 (EEST) Received: from haasn.dev (unknown [10.30.0.2]) by haasn.dev (Postfix) with ESMTP id 82B4F4B7F4; Sun, 18 Jun 2023 13:20:12 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=haasn.xyz; s=mail; t=1687087212; bh=XalFZ7+GvOO4b3uNOj+yEIoEX+xPMdWhO1A69FiyWnA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Li0Ayw++i4Z7M8DklRWQ9QR766s40V/hKM8MNgcFqmUFim87p6/lELGW5HJq4Q/gm I2Wmqgm5JLu74kMWpAaYbrLfEThsoEVbDsCHorqJ9kRD18CJ3jmJkzC4uV9U3wxlUf fPkAiz1tlGrhFF5FmDlWY5MDl+O/pYu78frpGiqk= From: Niklas Haas To: ffmpeg-devel@ffmpeg.org Date: Sun, 18 Jun 2023 13:17:09 +0200 Message-ID: <20230618111955.40994-19-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 17/22] lavfi/vf_libplacebo: add in_idx variable 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 To allow placing an input dynamically, as a function of the input index. --- doc/filters.texi | 2 ++ libavfilter/vf_libplacebo.c | 9 +++++++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/doc/filters.texi b/doc/filters.texi index 5e25cf293e5..cf17930b014 100644 --- a/doc/filters.texi +++ b/doc/filters.texi @@ -16249,6 +16249,8 @@ the @option{crop_w}, @option{crop_h}, @option{crop_x}, @option{crop_y}, also contain the following constants: @table @option +@item in_idx, idx +The (0-based) numeric index of the currently active input stream. @item crop_w, cw @item crop_h, ch The computed values of @option{crop_w} and @option{crop_h}. diff --git a/libavfilter/vf_libplacebo.c b/libavfilter/vf_libplacebo.c index a3a034766e2..fcd3ad07e2c 100644 --- a/libavfilter/vf_libplacebo.c +++ b/libavfilter/vf_libplacebo.c @@ -70,6 +70,7 @@ enum { }; static const char *const var_names[] = { + "in_idx", "idx",///< index of input "in_w", "iw", ///< width of the input video frame "in_h", "ih", ///< height of the input video frame "out_w", "ow", ///< width of the output video frame @@ -92,6 +93,7 @@ static const char *const var_names[] = { }; enum var_name { + VAR_IN_IDX, VAR_IDX, VAR_IN_W, VAR_IW, VAR_IN_H, VAR_IH, VAR_OUT_W, VAR_OW, @@ -115,6 +117,7 @@ enum var_name { /* per-input dynamic filter state */ typedef struct LibplaceboInput { + int idx; pl_renderer renderer; pl_queue queue; enum pl_queue_status qstatus; @@ -574,7 +577,7 @@ static void unlock_queue(void *priv, uint32_t qf, uint32_t qidx) #endif static int input_init(AVFilterContext *avctx, AVFilterLink *link, - LibplaceboInput *input) + LibplaceboInput *input, int idx) { LibplaceboContext *s = avctx->priv; @@ -584,6 +587,7 @@ static int input_init(AVFilterContext *avctx, AVFilterLink *link, input->queue = pl_queue_create(s->gpu); input->renderer = pl_renderer_create(s->log, s->gpu); input->link = link; + input->idx = idx; return 0; } @@ -668,7 +672,7 @@ static int init_vulkan(AVFilterContext *avctx, const AVVulkanDeviceContext *hwct if (!s->inputs) return AVERROR(ENOMEM); for (int i = 0; i < s->nb_inputs; i++) - RET(input_init(avctx, avctx->inputs[i], &s->inputs[i])); + RET(input_init(avctx, avctx->inputs[i], &s->inputs[i], i)); /* fall through */ fail: @@ -741,6 +745,7 @@ static void update_crops(AVFilterContext *ctx, LibplaceboInput *in, double image_pts = src->pts * av_q2d(in->link->time_base); /* Update dynamic variables */ + s->var_values[VAR_IN_IDX] = s->var_values[VAR_IDX] = in->idx; s->var_values[VAR_IN_W] = s->var_values[VAR_IW] = in->link->w; s->var_values[VAR_IN_H] = s->var_values[VAR_IH] = in->link->h; s->var_values[VAR_A] = (double) in->link->w / in->link->h; -- 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".