From patchwork Fri Jun 16 09:29:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Niklas Haas X-Patchwork-Id: 42140 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:c526:b0:117:ac03:c9de with SMTP id gm38csp1391307pzb; Fri, 16 Jun 2023 02:31:48 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7a5zSiUKS6lmqXf0XQFxN2T4qcSBpfZjToOU1VDWbeix8+r3qSaBvgCwbVldeNSwXJZzzQ X-Received: by 2002:a17:907:3ea2:b0:978:9b09:ccaf with SMTP id hs34-20020a1709073ea200b009789b09ccafmr1573102ejc.14.1686907907984; Fri, 16 Jun 2023 02:31:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686907907; cv=none; d=google.com; s=arc-20160816; b=XkZIQNAyI0UD1ROB3fB6l2nET8sLnkuTDNNrkaaLYV/gXKBW+P2az3fCgcRbWpoVwL 3t0mUvyWwJkuzufhZZc2/EEQTA2JPWTrNi6lsxHtHE/2iigDUVBjJFOFci9ZHiXvEvCZ OSbPZs0daf7P5ul3sZyU43jhnfrq6xp84zvp148+XSV5iNxku8fr9NskGdAJmsobW3Sh WYUEdMQGvzu3G7vynwwLdzyx0RkMRq/dosVZ899KdYGJPyOoTcfi+NxurS4cVUibPNqs Zx6O/TzA35UFvP5tkErr40+lCPQixtfMu3Ll8iLFI2vqEFt2RX+zElUjXmwGzP2Yrj9m 3dIw== 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=dkkp/PhBSRW7xuux1T7afSIJNMRYXMgwYSjcmh+f/MQ=; b=TRL3268nG2mVfg3UJfBuIi4+83g2ZSvRhC6CDL6ffKtE9n4pEopFnhm1vGCId660K+ CxDfjtITHRremQQ9v9UrYAkYkKXehTEo7EA8fbzjGjodpdRWQbmBxGaDO6ei0pLBBi9c 7Jp+kxN4wAGbfrNIu/p4iknAbDBbJjXy7qlaElrxt8krqrzdNeLg95m0W0LbIkbKDnW0 TH6Ov9j/LUmnLKGWrlPvVENEEIFF/9kYztgQRM3Ved9A/6xsLl56LWWKI6CfopXSlcgN 4YsvnmK2hG/elG9ksZlFAH/3EEWSgkha0NZPBXm0ZFeO0WxA0ULadIH1D4k1RQOsE7N9 M3IA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@haasn.xyz header.s=mail header.b=QA+OyPRU; 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 a23-20020a17090640d700b009827a0ca95dsi3015293ejk.136.2023.06.16.02.31.47; Fri, 16 Jun 2023 02:31:47 -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=QA+OyPRU; 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 5614A68C5D6; Fri, 16 Jun 2023 12:30:35 +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 4325668C5B8 for ; Fri, 16 Jun 2023 12:30:29 +0300 (EEST) Received: from localhost (217-74-0-168.hsi.r-kom.net [217.74.0.168]) by haasn.dev (Postfix) with ESMTPSA id 0904D424F2; Fri, 16 Jun 2023 11:30:29 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=haasn.xyz; s=mail; t=1686907829; bh=1oh4G4Ds7q0J7DTduOpRx2H5qxG/LUfZcHKxCRHx57I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QA+OyPRUAXBHMYSI4vb84u2L0IqMsXrjciVZsOJoYOmJS+r+iEBQbdEWKkX+CCSQ+ bBcAIgCYvrSK6sCerFUt5astrhYKSw4H8+uVxTn7xjumjJi+/Zd8nLhZZzqrjVvnTo smZZGZWtyvEOIAZK+QLy5Y3R0Bp9dHXh+nf0Q85w= From: Niklas Haas To: ffmpeg-devel@ffmpeg.org Date: Fri, 16 Jun 2023 11:29:54 +0200 Message-ID: <20230616092959.5247-17-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 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: vkXL49r0/C4E 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 a46357bfd8..2ea4083c3e 100644 --- a/doc/filters.texi +++ b/doc/filters.texi @@ -16197,6 +16197,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 f86493f4e2..427a15dc47 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: @@ -739,6 +743,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;