From patchwork Mon Sep 2 13:50:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 51309 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:612c:4027:b0:48e:c0f8:d0de with SMTP id ky39csp1835095vqb; Mon, 2 Sep 2024 06:51:14 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXOjfLdtkYIRaHgWFanvH7XQPsL1cwA1Uv3DcCEyroZw8c2wS7Ve7O0MnPujgiOT9DRROAW+a6mEUGmy1Hdd6kL@gmail.com X-Google-Smtp-Source: AGHT+IHuczU+qLdMdvWOgcoE/oBK+a0dG+mVX2TQXKRac56d+FPUynJXgp3ho+Ktn8OC6aofG4le X-Received: by 2002:a05:6512:3b99:b0:52c:e1cd:39be with SMTP id 2adb3069b0e04-53546af5268mr8018635e87.8.1725285074734; Mon, 02 Sep 2024 06:51:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1725285074; cv=none; d=google.com; s=arc-20240605; b=Bppaams8xGnjmOUPOoDgeEzXDIwN77ZSY8opmwrminRhNmqSFwMA2sHKeIv7+UQ3ms 69UaWIQcG5N4jEpzxdBTtlZaj4C1kfXvtt5UQUva5ceKOC3rOvOYPWWX2041xV3WFUvq 3Ptx0wHW3gPOSqB2nv9LT0aA2UChw9z7JVveb0dIEQ80C10eqVWyKgSK1qIZLzJQxUYF 2BHyhrKqPChaObCB9E5l/la1Z+N2IAoHsdpMwx8wpBvacFLKrCeMjn7LWrx+ZNFRqHxj 6wFzsBIUvjVjYaTOrW4HKdaQDGTRNyoLKDsy3CZsU27QrtgbAOAflX2FzrXZJH5dx67d CeBw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:content-transfer-encoding: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=+8QbHG953SU/TXEPu6UXp5QyDu0OebjKRI2wLx/xhec=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=DvgCOkQgVoG67SHBXQKT4Dup4FRj9W4JP6VAWn1CQmoq/+M7pT8Fo2TfhihbmsE9DD qPfjaB2q/+oX0EQMlIj1C/utsZ0i9DPVuq1SFblorAcIxvj5oJgTvpyH3nrSIBgclMX+ KBYitgNyngV/KHjwE4uBC3VyReY4SRxsPD3kypDJM5SuPqL++rVxlA9Zsq0/6Cqqsuil DDktgFrGjcybSlyKIt5s1fNV2UDRqm0x2PM1RBRoxrM2esmgEjA9XJiyJatAmj9H7sAj HGBxGQIIvb+gC1ka8AUATbkNYMvH4Llhef+s7X5frbUMyIXNXLWXfdPWYV8kNu9i0vkw YDnQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@khirnov.net header.s=mail header.b=hzU5z1AE; 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 a640c23a62f3a-a89be2aeecasi392154766b.388.2024.09.02.06.51.14; Mon, 02 Sep 2024 06:51:14 -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=@khirnov.net header.s=mail header.b=hzU5z1AE; 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 7C37068DF4C; Mon, 2 Sep 2024 16:50:48 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail1.khirnov.net (quelana.khirnov.net [94.230.150.81]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 97FBE68DF07 for ; Mon, 2 Sep 2024 16:50:40 +0300 (EEST) Authentication-Results: mail1.khirnov.net; dkim=pass (2048-bit key; unprotected) header.d=khirnov.net header.i=@khirnov.net header.a=rsa-sha256 header.s=mail header.b=hzU5z1AE; dkim-atps=neutral Received: from localhost (mail1.khirnov.net [IPv6:::1]) by mail1.khirnov.net (Postfix) with ESMTP id 237684DDE for ; Mon, 2 Sep 2024 15:50:40 +0200 (CEST) Received: from mail1.khirnov.net ([IPv6:::1]) by localhost (mail1.khirnov.net [IPv6:::1]) (amavis, port 10024) with ESMTP id AQtvOcYrGL5u for ; Mon, 2 Sep 2024 15:50:39 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=khirnov.net; s=mail; t=1725285038; bh=tHPVwwYMWdbQV47ihOBwrBGuRNnoLfkaXARUWZGKwkc=; h=From:To:Subject:Date:In-Reply-To:References:From; b=hzU5z1AEtN9QkWiOXYy4pz+k40SP6iX+oxhJTHSb0HIGKl7Z9CxgI1ITrdPqo39LU oC65rpbjFvAfyqrWD7FFRzSOCyQqxfluO2yV7ICN9eG0UE6trKixv6CSlczYibZP2t RHsvNXpa6fg1c30e/8RNM5OaLYcQjAR0ymG2W7fpxPS1RbUuqh9tTMkr3nX3wBmjeE p9Ywvk171LustaTA4NYEVlaGZFOdcTuK7NyI8p9yOu8J0qiqd9rSXOwMQ3PwhG2AXZ nc1+KzC+B8lWA4LTuPiTwVS8bV/quiMLm/91Er3+Rh5lilZQE+BkzD8BhHVosKF22+ KG8D7t5zvFQIg== Received: from libav.khirnov.net (libav.khirnov.net [IPv6:2a00:c500:561:201::7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "libav.khirnov.net", Issuer "smtp.khirnov.net SMTP CA" (verified OK)) by mail1.khirnov.net (Postfix) with ESMTPS id 180CA4DD0 for ; Mon, 2 Sep 2024 15:50:38 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id AF1043A181F for ; Mon, 02 Sep 2024 15:50:31 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Mon, 2 Sep 2024 15:50:03 +0200 Message-ID: <20240902135013.13803-3-anton@khirnov.net> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240902135013.13803-1-anton@khirnov.net> References: <20240902135013.13803-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 03/13] lavfi/af_anequalizer: convert to query_func2() 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: ljo19TQ1NKa8 Also, simplify code and drop redundant calls that also happen implicitly in generic code. --- libavfilter/af_anequalizer.c | 32 +++++++++----------------------- 1 file changed, 9 insertions(+), 23 deletions(-) diff --git a/libavfilter/af_anequalizer.c b/libavfilter/af_anequalizer.c index fdc9404857..26e9c3cdd7 100644 --- a/libavfilter/af_anequalizer.c +++ b/libavfilter/af_anequalizer.c @@ -217,13 +217,11 @@ static av_cold int init(AVFilterContext *ctx) return 0; } -static int query_formats(AVFilterContext *ctx) +static int query_formats(const AVFilterContext *ctx, + AVFilterFormatsConfig **cfg_in, + AVFilterFormatsConfig **cfg_out) { - AVFilterLink *inlink = ctx->inputs[0]; - AVFilterLink *outlink = ctx->outputs[0]; - AudioNEqualizerContext *s = ctx->priv; - AVFilterFormats *formats; - AVFilterChannelLayouts *layouts; + const AudioNEqualizerContext *s = ctx->priv; static const enum AVPixelFormat pix_fmts[] = { AV_PIX_FMT_RGBA, AV_PIX_FMT_NONE }; static const enum AVSampleFormat sample_fmts[] = { AV_SAMPLE_FMT_DBLP, @@ -232,25 +230,13 @@ static int query_formats(AVFilterContext *ctx) int ret; if (s->draw_curves) { - AVFilterLink *videolink = ctx->outputs[1]; - formats = ff_make_format_list(pix_fmts); - if ((ret = ff_formats_ref(formats, &videolink->incfg.formats)) < 0) + ret = ff_set_common_formats_from_list2(ctx, cfg_in, cfg_out, pix_fmts); + if (ret < 0) return ret; } - formats = ff_make_format_list(sample_fmts); - if ((ret = ff_formats_ref(formats, &inlink->outcfg.formats)) < 0 || - (ret = ff_formats_ref(formats, &outlink->incfg.formats)) < 0) - return ret; - - layouts = ff_all_channel_counts(); - if ((ret = ff_channel_layouts_ref(layouts, &inlink->outcfg.channel_layouts)) < 0 || - (ret = ff_channel_layouts_ref(layouts, &outlink->incfg.channel_layouts)) < 0) - return ret; - - formats = ff_all_samplerates(); - if ((ret = ff_formats_ref(formats, &inlink->outcfg.samplerates)) < 0 || - (ret = ff_formats_ref(formats, &outlink->incfg.samplerates)) < 0) + ret = ff_set_common_formats_from_list2(ctx, cfg_in, cfg_out, sample_fmts); + if (ret < 0) return ret; return 0; @@ -775,7 +761,7 @@ const AVFilter ff_af_anequalizer = { .uninit = uninit, FILTER_INPUTS(inputs), .outputs = NULL, - FILTER_QUERY_FUNC(query_formats), + FILTER_QUERY_FUNC2(query_formats), .process_command = process_command, .flags = AVFILTER_FLAG_DYNAMIC_OUTPUTS | AVFILTER_FLAG_SUPPORT_TIMELINE_INTERNAL |