From patchwork Sun Jun 18 11:17:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Niklas Haas X-Patchwork-Id: 42199 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:be15:b0:121:b37c:e101 with SMTP id ge21csp57234pzb; Sun, 18 Jun 2023 04:22:46 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6KN0GnW/bI4z1yfpC70rVn8phOXYv5TASfo+lTLo8LPVZ7gKEJLe6EY00AMe2tVoLVNyJm X-Received: by 2002:a17:907:7287:b0:973:93e3:bc9a with SMTP id dt7-20020a170907728700b0097393e3bc9amr7343138ejc.6.1687087366622; Sun, 18 Jun 2023 04:22:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687087366; cv=none; d=google.com; s=arc-20160816; b=LvO9J6W+OERaBSSriLfXmOzt5CWunQvbHMTPaX6mRHC49ql4qAykMmhKl2MFx3Qe9/ lr8fMGDXyXGsFBw+m9ySpHf+ngZVn9O0rb5IgyAqKWKhBGjcnnlJb64F7Gv9pG3HzogV mcaAhm3PzpRZAQ0vkekIb/9pX9MXgFTkFFdKO0x1J8lLv4oa3Lc33CrmYrVt4owLWNHG tzVcgDiqqIbS510UbIsroiEb8pttbuEGrfYsUVuZgdJ5daKQO7WWpW19+whpIugh+T5C CsUNoS23UExQPGvp4yQbjA6W3h9BXO3w4ZxGLqmKUpQrii/K/ZTSvwPWlkTiXt7qT0zO ksug== 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=AWQBYRCqutHqmx5PBdZQbMONSW4Q6gzsJkNLscLWpM8=; b=DNxDuBwabPIn7dWuZsJ0Ri9xVH2Xy5PBELe0dUBfn6mP7W+NfLncT2lGvblTgV8B2b sq5Y9+vFcWG+Kk622UR8Ww6MDcntbF7Twj/hORbPBpWoL905DXJW7UNs7ksfgVVPVTUi 48pecli9ueeh4MbVNqLBwABjb3GAWXBbqPeEYRXAlEQWbkqol65Sh3DdPoFtefAGAhzf eJrdFhvgMuXbDc1wJ74T4M46wnDa1SmZyCPTgjK1oC+yEyrIyU1vrzS7ro2WoKByyGgV nX6ZmoaOiX4Etsmvi48LF+gAt7gx+Edyl5enQscx2gGYn5T2iPsBfX4Pb1TB1WhwMyKL twcQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@haasn.xyz header.s=mail header.b=mSxTywBI; 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 w24-20020aa7d298000000b0051a590aa5c5si235986edq.587.2023.06.18.04.22.46; Sun, 18 Jun 2023 04:22:46 -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=mSxTywBI; 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 12CD868C1E6; Sun, 18 Jun 2023 14:20:30 +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 2F28B68C05A for ; Sun, 18 Jun 2023 14:20:14 +0300 (EEST) Received: from haasn.dev (unknown [10.30.0.2]) by haasn.dev (Postfix) with ESMTP id 89A3D4A698; Sun, 18 Jun 2023 13:20:10 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=haasn.xyz; s=mail; t=1687087210; bh=qS1j5vQ1G7B3CmSoznddbC3KKy549JU0/UjIauslt6U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mSxTywBIo1HtXFGkpbQ4pv4bMlBHTmd1107ZWAICye04ukS0Ke1EVSLd9xvfKs2C6 o49NbNQLpQ4d6WYq7+qlxb2dxf42dKu0FA40DLvsrpBcYe9leXgLoDyLnLZqLSVWP5 X9m9f6gixuoXWLLQF8Yb8IydqEjEjCo4QcjwOAc4= From: Niklas Haas To: ffmpeg-devel@ffmpeg.org Date: Sun, 18 Jun 2023 13:17:01 +0200 Message-ID: <20230618111955.40994-11-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 09/22] lavfi/vf_libplacebo: replace s->input by dynamic array 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: WlppufhDwipr From: Niklas Haas For now, hard-coded to 1 element. --- libavfilter/vf_libplacebo.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/libavfilter/vf_libplacebo.c b/libavfilter/vf_libplacebo.c index 408fb3918aa..ee8780036cf 100644 --- a/libavfilter/vf_libplacebo.c +++ b/libavfilter/vf_libplacebo.c @@ -136,7 +136,8 @@ typedef struct LibplaceboContext { pl_tex tex[4]; /* input state */ - LibplaceboInput input; + LibplaceboInput *inputs; + int nb_inputs; /* settings */ char *out_format_string; @@ -660,7 +661,12 @@ static int init_vulkan(AVFilterContext *avctx, const AVVulkanDeviceContext *hwct } /* Initialize inputs */ - RET(input_init(avctx, avctx->inputs[0], &s->input)); + s->nb_inputs = 1; + s->inputs = av_calloc(s->nb_inputs, sizeof(*s->inputs)); + 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])); /* fall through */ fail: @@ -677,7 +683,11 @@ static void libplacebo_uninit(AVFilterContext *avctx) pl_tex_destroy(s->gpu, &s->tex[i]); for (int i = 0; i < s->num_hooks; i++) pl_mpv_user_shader_destroy(&s->hooks[i]); - input_uninit(&s->input); + if (s->inputs) { + for (int i = 0; i < s->nb_inputs; i++) + input_uninit(&s->inputs[i]); + av_freep(&s->inputs); + } pl_vulkan_destroy(&s->vulkan); pl_log_destroy(&s->log); ff_vk_uninit(&s->vkctx); @@ -774,7 +784,7 @@ static int output_frame(AVFilterContext *ctx, int64_t pts) { int err = 0, ok, changed_csp; LibplaceboContext *s = ctx->priv; - LibplaceboInput *in = &s->input; + 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); @@ -942,7 +952,7 @@ static int libplacebo_activate(AVFilterContext *ctx) { int ret; LibplaceboContext *s = ctx->priv; - LibplaceboInput *in = &s->input; + LibplaceboInput *in = &s->inputs[0]; AVFilterLink *outlink = ctx->outputs[0]; int64_t pts;