From patchwork Thu Aug 29 08:50:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 51224 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:612c:402a:b0:48e:c0f8:d0de with SMTP id ky42csp216340vqb; Thu, 29 Aug 2024 02:10:11 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWLRw00sEnsy7e6/m8juFIwUVQ5t8BY8WXpOLUNjN3xqob9uyRp7grWdL02RrdaD9AnSU7KtBfs8UEIpd8z0Z29@gmail.com X-Google-Smtp-Source: AGHT+IHjM9sL4/0Nk8fYn83yhK5lEWdfMQoKditORata8hdEg1iWZwXz0T7uzA0m0UEcyAW9pPg+ X-Received: by 2002:a05:6512:31cd:b0:533:483f:9563 with SMTP id 2adb3069b0e04-5353e5b8203mr1262458e87.45.1724922611088; Thu, 29 Aug 2024 02:10:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1724922611; cv=none; d=google.com; s=arc-20240605; b=FqRe1zlPSR/x38GbpucSTBBaqo7J3x5Ex1L7xmR772Ynu99nAHk+mGa68k6uQ7uKXQ W2Lxbc9OCQ4tFFzwXE+H6rqfjfIePKiApFRcpaMwlvkkXl5/2+PM0c7+uawLJOyf/vCw dd5Cdk/FNCvF0eMsxmiZ+6WmPr7LdBODsV6kHYUj/d58dD1KgcYWUcs+kOUloimHxrU0 +sQH1PuSRjWo5fnGduL/+nT9e6QAmHgMAUztbKylDEuI09/GDbGUtHBUViKyiR4RO34k 1YOjdrmEI2jkeNozbv81D4CC1NzWJcMsdS+LzyNGr7+phHMdxEZXoX3nflNE3FESPNoj cpew== 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:message-id:date:to:from :dkim-signature:delivered-to; bh=YAYQuLyo4MLXA2WYZ76JGMC2/CFYqGeClf3LgbSnyps=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=LgVTzBkBYqjjAeKqD+mbf/JY/9/AhV60q5bvTkFaMO/2vkusHtIgsjfasBIpw5Iuqb c+BuzHB/O6rcGUVMtvStMAltNAdRmYhyuJ7bryFc2jCWK2TLSHcpkjrkbtZiL2+bYKVM FudT3aYRhtFeylCDVdphEi8lW9TgxxLutmykZJ1v3Y6xMj/w+gdCiDKm82WLaiVKY+Mj bwCD7Wb2AuqYPh0DhID3kuB5ZKom/wat254railC6yJWTvYIb/uzk7KI+70xgucDyP56 Sb9iOvIP1m4ZkEAupqnCzbrj13U9EmTbzkWZ+c2UHJ2psEIJyNwOegYGShP2MV6wCb2/ qYYA==; 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=fuSUj2rC; 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-a89891fcb5fsi89249166b.1055.2024.08.29.02.10.10; Thu, 29 Aug 2024 02:10:11 -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=fuSUj2rC; 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 F413768DD25; Thu, 29 Aug 2024 11:52:08 +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 B253568DCC6 for ; Thu, 29 Aug 2024 11:52:01 +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=fuSUj2rC; dkim-atps=neutral Received: from localhost (mail1.khirnov.net [IPv6:::1]) by mail1.khirnov.net (Postfix) with ESMTP id 2A22B4DFA for ; Thu, 29 Aug 2024 10:51:57 +0200 (CEST) Received: from mail1.khirnov.net ([IPv6:::1]) by localhost (mail1.khirnov.net [IPv6:::1]) (amavis, port 10024) with ESMTP id sLa7_caVe4XD for ; Thu, 29 Aug 2024 10:51:56 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=khirnov.net; s=mail; t=1724921514; bh=oIaKtPcXNNqDhhP06irkc6EcxKK4WyfTiMcB3sDS3Ks=; h=From:To:Subject:Date:From; b=fuSUj2rCS8iD7xgujhX+3eq9DII9tsfvbLJFLiT/hYu8yDubaKqPFrTdka66IyIZf 2TYYRCzBNVjuwnFDQ8EAyU1zctNwZhnBtt3JQKE/fLi7OoEH89VoayklZDg7UfgqI3 xpotWeyknDg4eYar3QvHzVPWTO4iK5g+acafCcRDOvaD9pE2kf9R6wSh3M4VVLJwST 8sF5SJrI87U7Qs2Mk4ug0HGpHbmBVKH+45/iZ5QqtoDSOwdn1ChMai1RXkDqQAPaw/ 4mShvrD27BjnWAiNMTs6WgG0FkVMb4vWl6/zmLCgTv6l52DJMLxNVWef0lv0WvCeZh hDrbJS3G9XHzQ== 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 726C24DF6 for ; Thu, 29 Aug 2024 10:51:54 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 1CB573A02CA for ; Thu, 29 Aug 2024 10:51:48 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Thu, 29 Aug 2024 10:50:45 +0200 Message-ID: <20240829085052.533-1-anton@khirnov.net> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 1/8] lavfi: add 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: xl51+lJBLKKP It differs from query_func() in accepting arrays of input/output format configurations to be filled as callback parameters. This allows to mark the filter context as const, ensuring it is not modified by this function, as it is not supposed to have any side effects beyond returning the supported formats. --- libavfilter/avfilter.h | 85 +++++++++++--------- libavfilter/avfiltergraph.c | 43 ++++++++++ libavfilter/filters.h | 4 + libavfilter/formats.c | 147 +++++++++++++++++++++++++++++++++++ libavfilter/formats.h | 84 ++++++++++++++++++++ libavfilter/tests/filtfmts.c | 19 ++++- 6 files changed, 346 insertions(+), 36 deletions(-) diff --git a/libavfilter/avfilter.h b/libavfilter/avfilter.h index 549fe6ce3a..1401577c50 100644 --- a/libavfilter/avfilter.h +++ b/libavfilter/avfilter.h @@ -98,6 +98,41 @@ const char *avfilter_pad_get_name(const AVFilterPad *pads, int pad_idx); */ enum AVMediaType avfilter_pad_get_type(const AVFilterPad *pads, int pad_idx); +/** + * Lists of formats / etc. supported by an end of a link. + * + * This structure is directly part of AVFilterLink, in two copies: + * one for the source filter, one for the destination filter. + + * These lists are used for negotiating the format to actually be used, + * which will be loaded into the format and channel_layout members of + * AVFilterLink, when chosen. + */ +typedef struct AVFilterFormatsConfig { + + /** + * List of supported formats (pixel or sample). + */ + AVFilterFormats *formats; + + /** + * Lists of supported sample rates, only for audio. + */ + AVFilterFormats *samplerates; + + /** + * Lists of supported channel layouts, only for audio. + */ + AVFilterChannelLayouts *channel_layouts; + + /** + * Lists of supported YUV color metadata, only for YUV video. + */ + AVFilterFormats *color_spaces; ///< AVColorSpace + AVFilterFormats *color_ranges; ///< AVColorRange + +} AVFilterFormatsConfig; + /** * The number of the filter inputs is not determined just by AVFilter.inputs. * The filter might add additional inputs during initialization depending on the @@ -324,6 +359,21 @@ typedef struct AVFilter { * AVERROR code otherwise */ int (*query_func)(AVFilterContext *); + + /** + * Same as query_func(), except this function writes the results into + * provided arrays. + * + * @param cfg_in array of input format configurations with as many + * members as the filters has inputs (NULL when there are + * no inputs); + * @param cfg_out array of output format configurations with as many + * members as the filters has outputs (NULL when there + * are no outputs); + */ + int (*query_func2)(const AVFilterContext *, + struct AVFilterFormatsConfig **cfg_in, + struct AVFilterFormatsConfig **cfg_out); /** * A pointer to an array of admissible pixel formats delimited * by AV_PIX_FMT_NONE. The generic code will use this list @@ -492,41 +542,6 @@ struct AVFilterContext { int extra_hw_frames; }; -/** - * Lists of formats / etc. supported by an end of a link. - * - * This structure is directly part of AVFilterLink, in two copies: - * one for the source filter, one for the destination filter. - - * These lists are used for negotiating the format to actually be used, - * which will be loaded into the format and channel_layout members of - * AVFilterLink, when chosen. - */ -typedef struct AVFilterFormatsConfig { - - /** - * List of supported formats (pixel or sample). - */ - AVFilterFormats *formats; - - /** - * Lists of supported sample rates, only for audio. - */ - AVFilterFormats *samplerates; - - /** - * Lists of supported channel layouts, only for audio. - */ - AVFilterChannelLayouts *channel_layouts; - - /** - * Lists of supported YUV color metadata, only for YUV video. - */ - AVFilterFormats *color_spaces; ///< AVColorSpace - AVFilterFormats *color_ranges; ///< AVColorRange - -} AVFilterFormatsConfig; - /** * A link between two filters. This contains pointers to the source and * destination filters between which this link exists, and the indexes of diff --git a/libavfilter/avfiltergraph.c b/libavfilter/avfiltergraph.c index 68e392b826..215e2e7d6e 100644 --- a/libavfilter/avfiltergraph.c +++ b/libavfilter/avfiltergraph.c @@ -352,6 +352,49 @@ static int filter_query_formats(AVFilterContext *ctx) ctx->name, av_err2str(ret)); return ret; } + } else if (ctx->filter->formats_state == FF_FILTER_FORMATS_QUERY_FUNC2) { + AVFilterFormatsConfig *cfg_in_stack[64], *cfg_out_stack[64]; + AVFilterFormatsConfig **cfg_in_dyn = NULL, **cfg_out_dyn = NULL; + AVFilterFormatsConfig **cfg_in, **cfg_out; + + if (ctx->nb_inputs > FF_ARRAY_ELEMS(cfg_in_stack)) { + cfg_in_dyn = av_malloc_array(ctx->nb_inputs, sizeof(*cfg_in_dyn)); + if (!cfg_in_dyn) + return AVERROR(ENOMEM); + cfg_in = cfg_in_dyn; + } else + cfg_in = ctx->nb_inputs ? cfg_in_stack : NULL; + + for (unsigned i = 0; i < ctx->nb_inputs; i++) { + AVFilterLink *l = ctx->inputs[i]; + cfg_in[i] = &l->outcfg; + } + + if (ctx->nb_outputs > FF_ARRAY_ELEMS(cfg_out_stack)) { + cfg_out_dyn = av_malloc_array(ctx->nb_outputs, sizeof(*cfg_out_dyn)); + if (!cfg_out_dyn) + return AVERROR(ENOMEM); + cfg_out = cfg_out_dyn; + } else + cfg_out = ctx->nb_outputs ? cfg_out_stack : NULL; + + for (unsigned i = 0; i < ctx->nb_outputs; i++) { + AVFilterLink *l = ctx->outputs[i]; + cfg_out[i] = &l->incfg; + } + + ret = ctx->filter->formats.query_func2(ctx, cfg_in, cfg_out); + av_freep(&cfg_in_dyn); + av_freep(&cfg_out_dyn); + if (ret < 0) { + if (ret != AVERROR(EAGAIN)) + av_log(ctx, AV_LOG_ERROR, "Query format failed for '%s': %s\n", + ctx->name, av_err2str(ret)); + return ret; + } + } + + if (ctx->filter->formats_state == FF_FILTER_FORMATS_QUERY_FUNC) { ret = filter_check_formats(ctx); if (ret < 0) diff --git a/libavfilter/filters.h b/libavfilter/filters.h index 0053ad4303..fdc7a95cee 100644 --- a/libavfilter/filters.h +++ b/libavfilter/filters.h @@ -226,6 +226,7 @@ enum FilterFormatsState { */ FF_FILTER_FORMATS_PASSTHROUGH = 0, FF_FILTER_FORMATS_QUERY_FUNC, ///< formats.query active. + FF_FILTER_FORMATS_QUERY_FUNC2, ///< formats.query_func2 active. FF_FILTER_FORMATS_PIXFMT_LIST, ///< formats.pixels_list active. FF_FILTER_FORMATS_SAMPLEFMTS_LIST, ///< formats.samples_list active. FF_FILTER_FORMATS_SINGLE_PIXFMT, ///< formats.pix_fmt active @@ -235,6 +236,9 @@ enum FilterFormatsState { #define FILTER_QUERY_FUNC(func) \ .formats.query_func = func, \ .formats_state = FF_FILTER_FORMATS_QUERY_FUNC +#define FILTER_QUERY_FUNC2(func) \ + .formats.query_func2 = func, \ + .formats_state = FF_FILTER_FORMATS_QUERY_FUNC2 #define FILTER_PIXFMTS_ARRAY(array) \ .formats.pixels_list = array, \ .formats_state = FF_FILTER_FORMATS_PIXFMT_LIST diff --git a/libavfilter/formats.c b/libavfilter/formats.c index eabc3ec946..82473cab7b 100644 --- a/libavfilter/formats.c +++ b/libavfilter/formats.c @@ -876,6 +876,153 @@ int ff_set_common_formats_from_list(AVFilterContext *ctx, const int *fmts) return ff_set_common_formats(ctx, ff_make_format_list(fmts)); } +#define SET_COMMON_FORMATS2(ctx, cfg_in, cfg_out, fmts, media_type, \ + ref_fn, unref_fn) \ + if (!fmts) \ + return AVERROR(ENOMEM); \ + \ + for (unsigned i = 0; i < ctx->nb_inputs; i++) { \ + AVFilterLink *const link = ctx->inputs[i]; \ + if (!cfg_in[i]->fmts && \ + (media_type == AVMEDIA_TYPE_UNKNOWN || \ + link->type == media_type)) { \ + int ret = ref_fn(fmts, &cfg_in[i]->fmts); \ + if (ret < 0) { \ + return ret; \ + } \ + } \ + } \ + for (unsigned i = 0; i < ctx->nb_outputs; i++) { \ + AVFilterLink *const link = ctx->outputs[i]; \ + if (!cfg_out[i]->fmts && \ + (media_type == AVMEDIA_TYPE_UNKNOWN || \ + link->type == media_type)) { \ + int ret = ref_fn(fmts, &cfg_out[i]->fmts); \ + if (ret < 0) { \ + return ret; \ + } \ + } \ + } \ + \ + if (!fmts->refcount) \ + unref_fn(&fmts); \ + \ + return 0; + +int ff_set_common_channel_layouts2(const AVFilterContext *ctx, + AVFilterFormatsConfig **cfg_in, + AVFilterFormatsConfig **cfg_out, + AVFilterChannelLayouts *channel_layouts) +{ + SET_COMMON_FORMATS2(ctx, cfg_in, cfg_out, channel_layouts, AVMEDIA_TYPE_AUDIO, + ff_channel_layouts_ref, ff_channel_layouts_unref); +} + +int ff_set_common_channel_layouts_from_list2(const AVFilterContext *ctx, + AVFilterFormatsConfig **cfg_in, + AVFilterFormatsConfig **cfg_out, + const AVChannelLayout *fmts) +{ + return ff_set_common_channel_layouts2(ctx, cfg_in, cfg_out, ff_make_channel_layout_list(fmts)); +} + +int ff_set_common_all_channel_counts2(const AVFilterContext *ctx, + AVFilterFormatsConfig **cfg_in, + AVFilterFormatsConfig **cfg_out) +{ + return ff_set_common_channel_layouts2(ctx, cfg_in, cfg_out, ff_all_channel_counts()); +} + +int ff_set_common_samplerates2(const AVFilterContext *ctx, + AVFilterFormatsConfig **cfg_in, + AVFilterFormatsConfig **cfg_out, + AVFilterFormats *samplerates) +{ + SET_COMMON_FORMATS2(ctx, cfg_in, cfg_out, samplerates, AVMEDIA_TYPE_AUDIO, + ff_formats_ref, ff_formats_unref); +} + +int ff_set_common_samplerates_from_list2(const AVFilterContext *ctx, + AVFilterFormatsConfig **cfg_in, + AVFilterFormatsConfig **cfg_out, + const int *samplerates) +{ + return ff_set_common_samplerates2(ctx, cfg_in, cfg_out, ff_make_format_list(samplerates)); +} + +int ff_set_common_all_samplerates2(const AVFilterContext *ctx, + AVFilterFormatsConfig **cfg_in, + AVFilterFormatsConfig **cfg_out) +{ + return ff_set_common_samplerates2(ctx, cfg_in, cfg_out, ff_all_samplerates()); +} + +int ff_set_common_color_spaces2(const AVFilterContext *ctx, + AVFilterFormatsConfig **cfg_in, + AVFilterFormatsConfig **cfg_out, + AVFilterFormats *color_spaces) +{ + SET_COMMON_FORMATS2(ctx, cfg_in, cfg_out, color_spaces, AVMEDIA_TYPE_VIDEO, + ff_formats_ref, ff_formats_unref); +} + +int ff_set_common_color_spaces_from_list2(const AVFilterContext *ctx, + AVFilterFormatsConfig **cfg_in, + AVFilterFormatsConfig **cfg_out, + const int *color_ranges) +{ + return ff_set_common_color_spaces2(ctx, cfg_in, cfg_out, ff_make_format_list(color_ranges)); +} + +int ff_set_common_all_color_spaces2(const AVFilterContext *ctx, + AVFilterFormatsConfig **cfg_in, + AVFilterFormatsConfig **cfg_out) +{ + return ff_set_common_color_spaces2(ctx, cfg_in, cfg_out, ff_all_color_spaces()); +} + +int ff_set_common_color_ranges2(const AVFilterContext *ctx, + AVFilterFormatsConfig **cfg_in, + AVFilterFormatsConfig **cfg_out, + AVFilterFormats *color_ranges) +{ + SET_COMMON_FORMATS2(ctx, cfg_in, cfg_out, color_ranges, AVMEDIA_TYPE_VIDEO, + ff_formats_ref, ff_formats_unref); +} + +int ff_set_common_color_ranges_from_list2(const AVFilterContext *ctx, + AVFilterFormatsConfig **cfg_in, + AVFilterFormatsConfig **cfg_out, + const int *color_ranges) +{ + return ff_set_common_color_ranges2(ctx, cfg_in, cfg_out, ff_make_format_list(color_ranges)); +} + +int ff_set_common_all_color_ranges2(const AVFilterContext *ctx, + AVFilterFormatsConfig **cfg_in, + AVFilterFormatsConfig **cfg_out) +{ + return ff_set_common_color_ranges2(ctx, cfg_in, cfg_out, ff_all_color_ranges()); +} + +int ff_set_common_formats2(const AVFilterContext *ctx, + AVFilterFormatsConfig **cfg_in, + AVFilterFormatsConfig **cfg_out, + AVFilterFormats *formats) +{ + SET_COMMON_FORMATS2(ctx, cfg_in, cfg_out, formats, AVMEDIA_TYPE_UNKNOWN, + ff_formats_ref, ff_formats_unref); +} + +int ff_set_common_formats_from_list2(const AVFilterContext *ctx, + AVFilterFormatsConfig **cfg_in, + AVFilterFormatsConfig **cfg_out, + const int *fmts) +{ + return ff_set_common_formats2(ctx, cfg_in, cfg_out, ff_make_format_list(fmts)); +} + + int ff_default_query_formats(AVFilterContext *ctx) { const AVFilter *const f = ctx->filter; diff --git a/libavfilter/formats.h b/libavfilter/formats.h index 82b3af4be1..380e9dfd00 100644 --- a/libavfilter/formats.h +++ b/libavfilter/formats.h @@ -225,6 +225,90 @@ int ff_set_common_formats(AVFilterContext *ctx, AVFilterFormats *formats); av_warn_unused_result int ff_set_common_formats_from_list(AVFilterContext *ctx, const int *fmts); +/** + * Helpers for query_formats2() which set all free audio links to the same list + * of channel layouts/sample rates. If there are no links hooked to this list, + * the list is freed. + */ +av_warn_unused_result +int ff_set_common_channel_layouts2(const AVFilterContext *ctx, + AVFilterFormatsConfig **cfg_in, + AVFilterFormatsConfig **cfg_out, + AVFilterChannelLayouts *channel_layouts); + +av_warn_unused_result +int ff_set_common_channel_layouts_from_list2(const AVFilterContext *ctx, + AVFilterFormatsConfig **cfg_in, + AVFilterFormatsConfig **cfg_out, + const AVChannelLayout *fmts); +av_warn_unused_result +int ff_set_common_all_channel_counts2(const AVFilterContext *ctx, + AVFilterFormatsConfig **cfg_in, + AVFilterFormatsConfig **cfg_out); + +av_warn_unused_result +int ff_set_common_samplerates2(const AVFilterContext *ctx, + AVFilterFormatsConfig **cfg_in, + AVFilterFormatsConfig **cfg_out, + AVFilterFormats *samplerates); + +av_warn_unused_result +int ff_set_common_samplerates_from_list2(const AVFilterContext *ctx, + AVFilterFormatsConfig **cfg_in, + AVFilterFormatsConfig **cfg_out, + const int *samplerates); + +av_warn_unused_result +int ff_set_common_all_samplerates2(const AVFilterContext *ctx, + AVFilterFormatsConfig **cfg_in, + AVFilterFormatsConfig **cfg_out); + +av_warn_unused_result +int ff_set_common_color_spaces2(const AVFilterContext *ctx, + AVFilterFormatsConfig **cfg_in, + AVFilterFormatsConfig **cfg_out, + AVFilterFormats *color_spaces); + +av_warn_unused_result +int ff_set_common_color_spaces_from_list2(const AVFilterContext *ctx, + AVFilterFormatsConfig **cfg_in, + AVFilterFormatsConfig **cfg_out, + const int *color_ranges); + +av_warn_unused_result +int ff_set_common_all_color_spaces2(const AVFilterContext *ctx, + AVFilterFormatsConfig **cfg_in, + AVFilterFormatsConfig **cfg_out); + +av_warn_unused_result +int ff_set_common_color_ranges2(const AVFilterContext *ctx, + AVFilterFormatsConfig **cfg_in, + AVFilterFormatsConfig **cfg_out, + AVFilterFormats *color_ranges); + +av_warn_unused_result +int ff_set_common_color_ranges_from_list2(const AVFilterContext *ctx, + AVFilterFormatsConfig **cfg_in, + AVFilterFormatsConfig **cfg_out, + const int *color_ranges); + +av_warn_unused_result +int ff_set_common_all_color_ranges2(const AVFilterContext *ctx, + AVFilterFormatsConfig **cfg_in, + AVFilterFormatsConfig **cfg_out); + +av_warn_unused_result +int ff_set_common_formats2(const AVFilterContext *ctx, + AVFilterFormatsConfig **cfg_in, + AVFilterFormatsConfig **cfg_out, + AVFilterFormats *formats); + +av_warn_unused_result +int ff_set_common_formats_from_list2(const AVFilterContext *ctx, + AVFilterFormatsConfig **cfg_in, + AVFilterFormatsConfig **cfg_out, + const int *fmts); + av_warn_unused_result int ff_add_channel_layout(AVFilterChannelLayouts **l, const AVChannelLayout *channel_layout); diff --git a/libavfilter/tests/filtfmts.c b/libavfilter/tests/filtfmts.c index bc8c65c0ad..4ef6968826 100644 --- a/libavfilter/tests/filtfmts.c +++ b/libavfilter/tests/filtfmts.c @@ -143,7 +143,24 @@ int main(int argc, char **argv) if (filter->formats_state == FF_FILTER_FORMATS_QUERY_FUNC) ret = filter->formats.query_func(filter_ctx); - else + else if (filter->formats_state == FF_FILTER_FORMATS_QUERY_FUNC2) { + AVFilterFormatsConfig **cfg_in = NULL, **cfg_out = NULL; + + if (filter_ctx->nb_inputs) { + cfg_in = av_malloc_array(filter_ctx->nb_inputs, sizeof(*cfg_in)); + for (unsigned i = 0; i < filter_ctx->nb_inputs; i++) + cfg_in[i] = &filter_ctx->inputs[i]->outcfg; + } + if (filter_ctx->nb_outputs) { + cfg_out = av_malloc_array(filter_ctx->nb_outputs, sizeof(*cfg_out)); + for (unsigned i = 0; i < filter_ctx->nb_outputs; i++) + cfg_out[i] = &filter_ctx->outputs[i]->incfg; + } + + ret = filter->formats.query_func2(filter_ctx, cfg_in, cfg_out); + av_freep(&cfg_in); + av_freep(&cfg_out); + } else ret = ff_default_query_formats(filter_ctx); print_formats(filter_ctx); From patchwork Thu Aug 29 08:50:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 51219 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:612c:402a:b0:48e:c0f8:d0de with SMTP id ky42csp208275vqb; Thu, 29 Aug 2024 01:52:07 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXd9jPrgg6SXoQ6eB4GIJLFbjOq5ZXCcSonBizJpd/jYfjJZa8PfP3TzroWiEQ1GTBuueslmc/lSlEnTTt3KvNS@gmail.com X-Google-Smtp-Source: AGHT+IE45qkoSYxSbw9O5eoq6CzigXc8D120V4/eFBjGM22GgnyEOqV6Cy8/GkMEzhI3gy379Ad3 X-Received: by 2002:a05:6402:5ce:b0:5c0:ba23:a55e with SMTP id 4fb4d7f45d1cf-5c21eda0c36mr1747458a12.38.1724921527054; Thu, 29 Aug 2024 01:52:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1724921527; cv=none; d=google.com; s=arc-20240605; b=ZhMzobh0v58nYpnzi098E+MBICj7t0XHH4K/5ucHsZGmhv/FdL3W597ZB8H8I8ICj8 c36qQ0U0yRxOD86JoyKcXhRhAfuj6LVjwVw+2qeRq9Vk2ThxpblAojE9LMuwlI2ZEpKI oTESbBsdl3YrfizkcWokFbpfdQeEHPZBXk9YarBfhmKo190pyUs7wccBeQeidJ7/L9ln AXnMrQ0IuqN1qynPDeIknMsrpJdftRAbxADO6KtLWqM4MKcKpRCPmufp84Lu6wH91+h/ ctFE5br9eF15sKjIMjC6uXCPW1QkSJJTVZmTHCF8/NCFU052q+a1lhJosQ8XUpO45VUk EThw== 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=1FAqglIrZWm9jRmZwl28mmR/8HMM76qWLWR70dn9oY0=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=OBFSBRLicYneSxMzg5yPRcyGwIjH8ACvd/j3nFu337r0gBWtba/J1EOgmdB5Ure6JK Ag8Jq4RMeswx2h5sxpbygTn1b98EvrK8lWr+1qMOODN3jp35GITsf3LnMyZUsJMaSjKv LvIwmgz2uMm5asF1KCx70wuy4gz2MclLmT4fUSurYQ1VnZyO05hElYEYlhzvTcLeDMba FfOnNGzCMsKPFhp+K2zPjxYTiUfYcQ+VDUHmk9AzPGhwcoGoqXOTtpFyTVvOod9NwMJN cXhazAk7K8MFQbjsqh994brg1oVxQY4St4YzIBqGtNAuqatwTaPWctqgyXrULzFzQHMl aMjA==; 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=W62Kpnze; 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 4fb4d7f45d1cf-5c226d2f2d1si828851a12.535.2024.08.29.01.52.06; Thu, 29 Aug 2024 01:52:07 -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=W62Kpnze; 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 DFADF68DC93; Thu, 29 Aug 2024 11:52:02 +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 4E59568DC73 for ; Thu, 29 Aug 2024 11:51:56 +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=W62Kpnze; dkim-atps=neutral Received: from localhost (mail1.khirnov.net [IPv6:::1]) by mail1.khirnov.net (Postfix) with ESMTP id 8D8B24E08 for ; Thu, 29 Aug 2024 10:51:55 +0200 (CEST) Received: from mail1.khirnov.net ([IPv6:::1]) by localhost (mail1.khirnov.net [IPv6:::1]) (amavis, port 10024) with ESMTP id dSuMx19Tv5pd for ; Thu, 29 Aug 2024 10:51:54 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=khirnov.net; s=mail; t=1724921514; bh=3Zrj7sPD9iyYSxrfvFu7XvxcMiA9NE6CYEirVdX5J/k=; h=From:To:Subject:Date:In-Reply-To:References:From; b=W62Kpnzel6JbR0iDBzTcDkcr7TyuOLo+BmbXVGfLIVqMPqpdo4u/vhs19vQOh2frx 6p/dm1smYa9K/ltMQQecMgR6H6dZHgSJIqVxS4gspZZwUwfq0pIGvkItR9smqPPMnS Ny3bxpnOex2aqWdHWd/Jp/UaxB6KtvK6yNsmsch0zVjtpkpfzWU/2OQfoIDIj1tws0 KdnABiFGoRSMF9UJZ/X3dX2Iiiy3WanY79530THQjarYV5AJ8Wb+Jfz3FBDQg6qy2O TOSQXxtUBgmL4Lemdjfee2W9IeB98bV9z1Wry0/eGGX8cw+7CIxLR8yST0+2nNHnqx YlvNIxEWXA2hQ== 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 702874DF5 for ; Thu, 29 Aug 2024 10:51:54 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 2AD153A1676 for ; Thu, 29 Aug 2024 10:51:48 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Thu, 29 Aug 2024 10:50:46 +0200 Message-ID: <20240829085052.533-2-anton@khirnov.net> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240829085052.533-1-anton@khirnov.net> References: <20240829085052.533-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 2/8] lavfi/aeval: 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: GFiG/pd/fwYP Drop redundant ff_set_common_all_channel_counts() / ff_set_common_all_samplerates() calls, since those happen implicitly in generic code. --- libavfilter/aeval.c | 37 ++++++++++++++++++------------------- 1 file changed, 18 insertions(+), 19 deletions(-) diff --git a/libavfilter/aeval.c b/libavfilter/aeval.c index 9fb6354ed3..0e7ba8df80 100644 --- a/libavfilter/aeval.c +++ b/libavfilter/aeval.c @@ -242,23 +242,25 @@ static int config_props(AVFilterLink *outlink) return 0; } -static int query_formats(AVFilterContext *ctx) +static int query_formats(const AVFilterContext *ctx, + AVFilterFormatsConfig **cfg_in, + AVFilterFormatsConfig **cfg_out) { - EvalContext *eval = ctx->priv; + const EvalContext *eval = ctx->priv; static const enum AVSampleFormat sample_fmts[] = { AV_SAMPLE_FMT_DBLP, AV_SAMPLE_FMT_NONE }; AVChannelLayout chlayouts[] = { eval->chlayout.nb_channels ? eval->chlayout : FF_COUNT2LAYOUT(eval->nb_channels), { 0 } }; int sample_rates[] = { eval->sample_rate, -1 }; int ret; - ret = ff_set_common_formats_from_list(ctx, sample_fmts); + ret = ff_set_common_formats_from_list2(ctx, cfg_in, cfg_out, sample_fmts); if (ret < 0) return ret; - ret = ff_set_common_channel_layouts_from_list(ctx, chlayouts); + ret = ff_set_common_channel_layouts_from_list2(ctx, cfg_in, cfg_out, chlayouts); if (ret < 0) return ret; - return ff_set_common_samplerates_from_list(ctx, sample_rates); + return ff_set_common_samplerates_from_list2(ctx, cfg_in, cfg_out, sample_rates); } static int activate(AVFilterContext *ctx) @@ -327,7 +329,7 @@ const AVFilter ff_asrc_aevalsrc = { .priv_size = sizeof(EvalContext), .inputs = NULL, FILTER_OUTPUTS(aevalsrc_outputs), - FILTER_QUERY_FUNC(query_formats), + FILTER_QUERY_FUNC2(query_formats), .priv_class = &aevalsrc_class, }; @@ -345,12 +347,12 @@ static const AVOption aeval_options[]= { AVFILTER_DEFINE_CLASS(aeval); -static int aeval_query_formats(AVFilterContext *ctx) +static int aeval_query_formats(const AVFilterContext *ctx, + AVFilterFormatsConfig **cfg_in, + AVFilterFormatsConfig **cfg_out) { AVFilterChannelLayouts *layouts; - AVFilterLink *inlink = ctx->inputs[0]; - AVFilterLink *outlink = ctx->outputs[0]; - EvalContext *eval = ctx->priv; + const EvalContext *eval = ctx->priv; static const enum AVSampleFormat sample_fmts[] = { AV_SAMPLE_FMT_DBLP, AV_SAMPLE_FMT_NONE }; @@ -358,25 +360,22 @@ static int aeval_query_formats(AVFilterContext *ctx) // inlink supports any channel layout layouts = ff_all_channel_counts(); - if ((ret = ff_channel_layouts_ref(layouts, &inlink->outcfg.channel_layouts)) < 0) + if ((ret = ff_channel_layouts_ref(layouts, &cfg_in[0]->channel_layouts)) < 0) return ret; - if (eval->same_chlayout) { - if ((ret = ff_set_common_all_channel_counts(ctx)) < 0) - return ret; - } else { + if (!eval->same_chlayout) { // outlink supports only requested output channel layout layouts = NULL; if ((ret = ff_add_channel_layout(&layouts, &FF_COUNT2LAYOUT(eval->nb_channels))) < 0) return ret; - if ((ret = ff_channel_layouts_ref(layouts, &outlink->incfg.channel_layouts)) < 0) + if ((ret = ff_channel_layouts_ref(layouts, &cfg_out[0]->channel_layouts)) < 0) return ret; } - if ((ret = ff_set_common_formats_from_list(ctx, sample_fmts)) < 0) + if ((ret = ff_set_common_formats_from_list2(ctx, cfg_in, cfg_out, sample_fmts)) < 0) return ret; - return ff_set_common_all_samplerates(ctx); + return 0; } static int aeval_config_output(AVFilterLink *outlink) @@ -471,7 +470,7 @@ const AVFilter ff_af_aeval = { .priv_size = sizeof(EvalContext), FILTER_INPUTS(aeval_inputs), FILTER_OUTPUTS(aeval_outputs), - FILTER_QUERY_FUNC(aeval_query_formats), + FILTER_QUERY_FUNC2(aeval_query_formats), .priv_class = &aeval_class, .flags = AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC, }; From patchwork Thu Aug 29 08:50:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 51220 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:612c:402a:b0:48e:c0f8:d0de with SMTP id ky42csp208352vqb; Thu, 29 Aug 2024 01:52:20 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUZDWw0R1IIR6H/kpcqGuQ+ELraNvS3UdLQlOnMRMDgCWw9rhHw+z7NJYg6rKkQmUCBR+kBOnun8A0JqV+dJlz9@gmail.com X-Google-Smtp-Source: AGHT+IF9RH4W+ZoIJWnXUgZMlhDSu4KiCWoKrdJ3AhAzEuUWkBU8cJk/QlmMEpkD7Oy1BVifDWnu X-Received: by 2002:a05:6512:1047:b0:530:e0fd:4a92 with SMTP id 2adb3069b0e04-5353e2f9401mr807212e87.0.1724921539913; Thu, 29 Aug 2024 01:52:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1724921539; cv=none; d=google.com; s=arc-20240605; b=iHkgXXIPH3ahz9K31qWi8EPSgHbU4wDZuId/RW9+ss73BHlWRNHjqa3C/EkH3gNhU+ BPSpThhWaPeiclNI0jO4Innp63UyO6LDNHoAQFsN0dVEjNYNVDB5JnRuoZKv150Kofzt 2inq68unpZ+dS3KJI1GxmfWjYiEAFNnWi+5sG7Lo0q1vXJp3NVFyXWUE066B4m1sLdFj MEs5rj/Vm5CORiRgeNbegszhuLbdWGXc0pli5XUYYPTUb+A1Eq9SQBTrnOj3OSZD/hye F0ooiC85KgAxECFl7na7pWFz8PZougWSd6MAZZER2dwMn650HUZVGVj4quSy6M8hxpGn E/dQ== 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=EDKEuDknOxEy4lfpNlGvSyvCsRPrtqewJkLkbA/d0s0=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=Nwk1sb+wWqDHjlBqZPxC4Xjkk7iXwvKHgpavoeHv+OkKtxPCKY9Lik6yi2JLNEYsYJ 4C/kj0/intHHqmeDtghKJ3gMAk2p9dxLG/DcPwDgJpug2l8foSwAVu5yUpR1KNM+h6Wr fAGBnvlJYdpmDbhC6iGHIq+W5/QRl4VuVG5joyWjNAXYKKI+me5Bk4dxE6xPmiLW9aOo IrPA3PyczQGnUoTsCQlUbEsihnnEFXRhHagz4nm3i/QZOvb9wdnQ4of3dbyTiaihTGmk cwdRFBpRVCjoR2CsahSpL68BZYqzLhd4amdZa64ENRT+IMnXpXUecFJFMvwkSjKGDlNs yIYQ==; 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=gsUXOr9H; 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 2adb3069b0e04-5354077cf22si354518e87.28.2024.08.29.01.52.19; Thu, 29 Aug 2024 01:52:19 -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=gsUXOr9H; 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 1F14568DCA3; Thu, 29 Aug 2024 11:52:04 +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 6186668DC7D for ; Thu, 29 Aug 2024 11:51:56 +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=gsUXOr9H; dkim-atps=neutral Received: from localhost (mail1.khirnov.net [IPv6:::1]) by mail1.khirnov.net (Postfix) with ESMTP id E49414DF5 for ; Thu, 29 Aug 2024 10:51:55 +0200 (CEST) Received: from mail1.khirnov.net ([IPv6:::1]) by localhost (mail1.khirnov.net [IPv6:::1]) (amavis, port 10024) with ESMTP id S01rnx96Rnj9 for ; Thu, 29 Aug 2024 10:51:55 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=khirnov.net; s=mail; t=1724921514; bh=aIEygFaQKDs8a7PYIkY/yCONWQ+s0YOuAZ+NyGedrXM=; h=From:To:Subject:Date:In-Reply-To:References:From; b=gsUXOr9HLJI/BneXAFGaR8avWOBODxILQqNpeyH7BlWjAfHVV6r5QmQm4MyMyQ7EX no71SnBqRoDIAlB0D8fd2UUMrQqkPtjmBiXWdBptWOczCksgIMKOAK8yc2u8Zu2JNw OhUM405CIJEIqy77hV6iwvRs/iMzTG1s7esC+Gy+nT5JC/kvoJmaYTCg8BiU9TOMQk UVJbbtljBiWOFE9X8WuIOuSYk+2ypTfD44/KF/+B6N0B3bELy51ce9qL90aeT+DlCp 6wQKJtswiE2MREl0mZP/v+y89pmKSkU+lNdlQtV90vONsL2O9HcNamEGv9jnlg1Da+ +CocKAb6FmySw== 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 744854DF8 for ; Thu, 29 Aug 2024 10:51:54 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 3606D3A170F for ; Thu, 29 Aug 2024 10:51:48 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Thu, 29 Aug 2024 10:50:47 +0200 Message-ID: <20240829085052.533-3-anton@khirnov.net> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240829085052.533-1-anton@khirnov.net> References: <20240829085052.533-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 3/8] lavfi/af_aap: 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: CxvReHCHOuFu Drop redundant ff_set_common_all_channel_counts() / ff_set_common_all_samplerates() calls, since those happen implicitly in generic code. --- libavfilter/af_aap.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/libavfilter/af_aap.c b/libavfilter/af_aap.c index 352f10cd8c..05608d7fbb 100644 --- a/libavfilter/af_aap.c +++ b/libavfilter/af_aap.c @@ -95,9 +95,11 @@ static const AVOption aap_options[] = { AVFILTER_DEFINE_CLASS(aap); -static int query_formats(AVFilterContext *ctx) +static int query_formats(const AVFilterContext *ctx, + AVFilterFormatsConfig **cfg_in, + AVFilterFormatsConfig **cfg_out) { - AudioAPContext *s = ctx->priv; + const AudioAPContext *s = ctx->priv; static const enum AVSampleFormat sample_fmts[3][3] = { { AV_SAMPLE_FMT_FLTP, AV_SAMPLE_FMT_DBLP, AV_SAMPLE_FMT_NONE }, { AV_SAMPLE_FMT_FLTP, AV_SAMPLE_FMT_NONE }, @@ -105,13 +107,11 @@ static int query_formats(AVFilterContext *ctx) }; int ret; - if ((ret = ff_set_common_all_channel_counts(ctx)) < 0) + if ((ret = ff_set_common_formats_from_list2(ctx, cfg_in, cfg_out, + sample_fmts[s->precision])) < 0) return ret; - if ((ret = ff_set_common_formats_from_list(ctx, sample_fmts[s->precision])) < 0) - return ret; - - return ff_set_common_all_samplerates(ctx); + return 0; } static int activate(AVFilterContext *ctx) @@ -325,7 +325,7 @@ const AVFilter ff_af_aap = { .activate = activate, FILTER_INPUTS(inputs), FILTER_OUTPUTS(outputs), - FILTER_QUERY_FUNC(query_formats), + FILTER_QUERY_FUNC2(query_formats), .flags = AVFILTER_FLAG_SUPPORT_TIMELINE_INTERNAL | AVFILTER_FLAG_SLICE_THREADS, .process_command = ff_filter_process_command, From patchwork Thu Aug 29 08:50:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 51221 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:612c:402a:b0:48e:c0f8:d0de with SMTP id ky42csp208428vqb; Thu, 29 Aug 2024 01:52:31 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUUHfejqL5IAHQJ9QR645FizarJuPYfLSvCzKeTYPmXfU+M6lChIVnN/XC3ABKVu+phAR3Hf2O8MvJy3aCtTWtq@gmail.com X-Google-Smtp-Source: AGHT+IENVDpFaFS/ph4TlwwkTGH1qmohuHnKtC255a34hR2ww2bxBVHGs008uMIkIKAAFIpC3lKe X-Received: by 2002:a2e:4e11:0:b0:2f4:3de7:ac48 with SMTP id 38308e7fff4ca-2f616895d57mr3552621fa.19.1724921551330; Thu, 29 Aug 2024 01:52:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1724921551; cv=none; d=google.com; s=arc-20240605; b=JuspSKpgvu+X5KBzXyjuESYCzZLXASLkfkOxp6q5pmkovNV0Thv7Le2CEzrywq/D+K IhOxFNeWOEbPqlsjuML1neykitrW79nkyABTLME2NIWE3U+MlBTZ3bANz5lCREj9ViJx oS40KoL65hldCsRQOhnFFEaappaMHZSCWANvxKMA1xVpYYSvbN1LvUEF4N2frX6WqtXE 3aTg7wPHkYrVyDu5RPSeDVkRStMMo4DLZ0qJWCeXMyY/rHVNnjWxrmQ0eaBLtAa7aJhX 64I9lpdceVEJKBZh+qJIMEFP7hs4Nvv8bEipTMsi3wHYSVPmtkhoU2+GhVHX93pfCJf8 aUiQ== 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=F9sKLst+oU+TlAaOTeN0oJyJNwpDPwMlvhnzRCJv4cs=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=VcOJGi5eRDpKKspBIzgsohGKcKaCvAMGfEK7KtIY9d+iOPiu9dBPFUItfCRzX+Un62 3UUvB7Gal5Pb8Ib9ubkMfyNhiiD024aU0mDzaGSVVXdA51XD59k7HzX2JuLMkZqhwuYQ 13xiWohPt5oeuRULO4Uk/dAQFU3cOEUN5sCM7c7EjIVvJBi7odeNxaevReFiChbKad+z bXUzkKxB3D0/3qbqViCrlAdxWNl8WKHNhiMhEvRHFEIpbKoCyHmEsqhwNXyoHFNtD5nv VVLFIQFnHG5MTqPSZchOHZzSIVKfINh0dKUMfThFOvx5qsEhrMw4Da1tOgMgHo08QISc SUtg==; 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=Yy8dq5JL; 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 38308e7fff4ca-2f6151881bdsi3494921fa.568.2024.08.29.01.52.30; Thu, 29 Aug 2024 01:52:31 -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=Yy8dq5JL; 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 6591868DCC1; Thu, 29 Aug 2024 11:52:05 +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 BF64968DC81 for ; Thu, 29 Aug 2024 11:51:56 +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=Yy8dq5JL; dkim-atps=neutral Received: from localhost (mail1.khirnov.net [IPv6:::1]) by mail1.khirnov.net (Postfix) with ESMTP id 52F954DF8 for ; Thu, 29 Aug 2024 10:51:56 +0200 (CEST) Received: from mail1.khirnov.net ([IPv6:::1]) by localhost (mail1.khirnov.net [IPv6:::1]) (amavis, port 10024) with ESMTP id qKEaDe1JwV8q for ; Thu, 29 Aug 2024 10:51:56 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=khirnov.net; s=mail; t=1724921514; bh=vqxfiiJvKhcOOKwH7lJNHKSfdt6spzGTdxSyIWS53f0=; h=From:To:Subject:Date:In-Reply-To:References:From; b=Yy8dq5JLdybt4SdAVyCmoszYPM0kPsDfN5TuV2PwulbkR3/EQwxq/jU6B2Hn+g+2M cp/J+gNsIP8u7TLeuRJjRMKGhz/Q4UBuQUEQh4+Tb05GT+u06XiGLwc43aEf1kuNnD lp9P4hmKCVLLID7+DA2/9jS3FzqkLBwPKTgc7nkaJaG0pXsuABHAFvTKQvemqiDmpK 6C82s9ZiVdtUA99AXG5ha697k9NpmJbCMjxMr8tphQP5blJuzuTqkWI8Aru14V+6Hm UYJ5zeYEPvGlQWiOwFJLwj66KXMuu7MpcbnSXCyvsQUJ/GZ7zCzG6uQiJseDqjmV4+ PLQzKmSPkoH4g== 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 75BCC4DFA for ; Thu, 29 Aug 2024 10:51:54 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 411B83A17C2 for ; Thu, 29 Aug 2024 10:51:48 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Thu, 29 Aug 2024 10:50:48 +0200 Message-ID: <20240829085052.533-4-anton@khirnov.net> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240829085052.533-1-anton@khirnov.net> References: <20240829085052.533-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 4/8] lavfi/af_acrossover: 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: URSKAQhvDS21 Drop redundant ff_set_common_all_channel_counts() / ff_set_common_all_samplerates() calls, since those happen implicitly in generic code. --- libavfilter/af_acrossover.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/libavfilter/af_acrossover.c b/libavfilter/af_acrossover.c index 48ff002006..3fd5c1d246 100644 --- a/libavfilter/af_acrossover.c +++ b/libavfilter/af_acrossover.c @@ -108,9 +108,11 @@ static const AVOption acrossover_options[] = { AVFILTER_DEFINE_CLASS(acrossover); -static int query_formats(AVFilterContext *ctx) +static int query_formats(const AVFilterContext *ctx, + AVFilterFormatsConfig **cfg_in, + AVFilterFormatsConfig **cfg_out) { - AudioCrossoverContext *s = ctx->priv; + const AudioCrossoverContext *s = ctx->priv; static const enum AVSampleFormat auto_sample_fmts[] = { AV_SAMPLE_FMT_FLTP, AV_SAMPLE_FMT_DBLP, @@ -121,9 +123,7 @@ static int query_formats(AVFilterContext *ctx) AV_SAMPLE_FMT_NONE }; const enum AVSampleFormat *sample_fmts_list = sample_fmts; - int ret = ff_set_common_all_channel_counts(ctx); - if (ret < 0) - return ret; + int ret; switch (s->precision) { case 0: @@ -138,11 +138,11 @@ static int query_formats(AVFilterContext *ctx) default: break; } - ret = ff_set_common_formats_from_list(ctx, sample_fmts_list); + ret = ff_set_common_formats_from_list2(ctx, cfg_in, cfg_out, sample_fmts_list); if (ret < 0) return ret; - return ff_set_common_all_samplerates(ctx); + return 0; } static int parse_gains(AVFilterContext *ctx) @@ -627,7 +627,7 @@ const AVFilter ff_af_acrossover = { .uninit = uninit, FILTER_INPUTS(inputs), .outputs = NULL, - FILTER_QUERY_FUNC(query_formats), + FILTER_QUERY_FUNC2(query_formats), .flags = AVFILTER_FLAG_DYNAMIC_OUTPUTS | AVFILTER_FLAG_SLICE_THREADS, }; From patchwork Thu Aug 29 08:50:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 51226 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:612c:402a:b0:48e:c0f8:d0de with SMTP id ky42csp224511vqb; Thu, 29 Aug 2024 02:30:12 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXpAMD7W6tpqJNR+43lhdAtx/i8FVatFBMJSYKR/Q1V122LT1v4qvF1z7cuuGz6xiJlfZGJCSfiPltJLczR0qXv@gmail.com X-Google-Smtp-Source: AGHT+IF45aF2G5uAmiU32sjXwcXhH7By0IGVXrwa9na0WsdEg06HQV1iQbf6uzs4yUbTtlXq2DFv X-Received: by 2002:a17:907:3189:b0:a80:b63b:eba0 with SMTP id a640c23a62f3a-a897f84d693mr93685966b.4.1724923811871; Thu, 29 Aug 2024 02:30:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1724923811; cv=none; d=google.com; s=arc-20240605; b=MTalOD/U6syzRk5Yxjn01aodBAwhKM6Gy10swsk9GAevRs2x9cdy9X/A28VmdEr7ti EI7fgPCOdiMV+GXOhXOo5zv9bgkVL02gSIVpIasZeXpPdL/o65vH1SxoOyz5JW2g8X4p 3uskvdqkSYWW9xqSsDcBwr6nSuktEjfCZGEBL/tuZU6dJ+Hj6wGKqll1JvA8JQq2wyls objme0MNJ0/7nHDwXTpNCL+0ZzmcDidENi0kGgaxTPEZRX2F+NMRqj0BuKiLmm7Q7ITV 9ckWE8Km6C0dAne89hVMM4xGxtFd5aPa6oEIqMhvn44VGJR+jVXVF+BDW6Q2k/T1M5ID 7pdw== 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=9KsOFEzC3OwsNhXLqgWFVWa5oAasmR3nA164+LRRcso=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=R3n+Nwsg94FZpWwPOKdfej/7ExpfC0PtE3ev9sbqG5epG/LnOSveHJV2Kx9Yr2Uww/ w6yvZZn/a2hxfThln0UlmetitrOpGaGZrpo7yiz/e4hf32hlkjfSxjngRHOeWVEg6Hdj U3u8VhPzJ/eN00YNm5vSYMGra9FAiKvbJCK0ULM2a2qH8QuOy6eKgS4AP5FK1iBpoM87 xJE/0gwrXEfUePLBwARBf2w2g6jut1uPYQ2Fuwmtt9BfUUaTBuhyAxY0kuTgIrOZW/dG njTEqiRaqyqd6cXt3oVeKFjOU90xn4NVAuBSttI1aR5kRZMfAXMITbXodSSeZV/rsfSi fgCg==; 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=I8k11paN; 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-a898912d681si88216866b.304.2024.08.29.02.30.11; Thu, 29 Aug 2024 02:30:11 -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=I8k11paN; 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 8521168DCD3; Thu, 29 Aug 2024 11:52:06 +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 F0D1268DC73 for ; Thu, 29 Aug 2024 11:51:56 +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=I8k11paN; dkim-atps=neutral Received: from localhost (mail1.khirnov.net [IPv6:::1]) by mail1.khirnov.net (Postfix) with ESMTP id 9896C4E05 for ; Thu, 29 Aug 2024 10:51:56 +0200 (CEST) Received: from mail1.khirnov.net ([IPv6:::1]) by localhost (mail1.khirnov.net [IPv6:::1]) (amavis, port 10024) with ESMTP id n33JLZnZJvwf for ; Thu, 29 Aug 2024 10:51:54 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=khirnov.net; s=mail; t=1724921514; bh=bixniXNVObngXgzNVcziULN0mthzZuFv2GldNcfiiFI=; h=From:To:Subject:Date:In-Reply-To:References:From; b=I8k11paN2nHVge6CQ8ilVhYALWXJ6CuUhtCAgs6Y3JYeQ7sghixrcyBc4z8gca4Nz 6JDtkBWmXOM4BTXLKDoGRNc5OSc0pXIWEJg5LMbn4zemnacE8XrLce9QnwNxFbOQ75 704nBaNjVfodA1bqapd77tG9TroDSfdkluX+DqyJWrKfF4A+vwwPWpIaFFDB8/z57M Tb4Q30pTLOPe7Gq3faHvycS7ljMOwr0qjoxLJFZ1zC5vjIAVlewTPsd8ZVrJS6dMnw Qj+OZeE2uAdbbTHkXMa6K/HdbJzE6XDf1OepUhLaf+4ZKhFZoW2Oitp0h7Y2GEeRG0 eybUXzVsxnDpg== 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 784E74DFC for ; Thu, 29 Aug 2024 10:51:54 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 4C89A3A181F for ; Thu, 29 Aug 2024 10:51:48 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Thu, 29 Aug 2024 10:50:49 +0200 Message-ID: <20240829085052.533-5-anton@khirnov.net> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240829085052.533-1-anton@khirnov.net> References: <20240829085052.533-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 5/8] lavfi/af_adynamicequalizer: 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: itrWnBpGUQVy Drop redundant ff_set_common_all_channel_counts() / ff_set_common_all_samplerates() calls, since those happen implicitly in generic code. --- libavfilter/af_adynamicequalizer.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/libavfilter/af_adynamicequalizer.c b/libavfilter/af_adynamicequalizer.c index 7a102cad22..ba03faff60 100644 --- a/libavfilter/af_adynamicequalizer.c +++ b/libavfilter/af_adynamicequalizer.c @@ -110,9 +110,11 @@ typedef struct AudioDynamicEqualizerContext { ChannelContext *cc; } AudioDynamicEqualizerContext; -static int query_formats(AVFilterContext *ctx) +static int query_formats(const AVFilterContext *ctx, + AVFilterFormatsConfig **cfg_in, + AVFilterFormatsConfig **cfg_out) { - AudioDynamicEqualizerContext *s = ctx->priv; + const AudioDynamicEqualizerContext *s = ctx->priv; static const enum AVSampleFormat sample_fmts[3][3] = { { AV_SAMPLE_FMT_FLTP, AV_SAMPLE_FMT_DBLP, AV_SAMPLE_FMT_NONE }, { AV_SAMPLE_FMT_FLTP, AV_SAMPLE_FMT_NONE }, @@ -120,13 +122,11 @@ static int query_formats(AVFilterContext *ctx) }; int ret; - if ((ret = ff_set_common_all_channel_counts(ctx)) < 0) + if ((ret = ff_set_common_formats_from_list2(ctx, cfg_in, cfg_out, + sample_fmts[s->precision])) < 0) return ret; - if ((ret = ff_set_common_formats_from_list(ctx, sample_fmts[s->precision])) < 0) - return ret; - - return ff_set_common_all_samplerates(ctx); + return 0; } static double get_coef(double x, double sr) @@ -281,7 +281,7 @@ const AVFilter ff_af_adynamicequalizer = { .uninit = uninit, FILTER_INPUTS(inputs), FILTER_OUTPUTS(ff_audio_default_filterpad), - FILTER_QUERY_FUNC(query_formats), + FILTER_QUERY_FUNC2(query_formats), .flags = AVFILTER_FLAG_SUPPORT_TIMELINE_INTERNAL | AVFILTER_FLAG_SLICE_THREADS, .process_command = ff_filter_process_command, From patchwork Thu Aug 29 08:50:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 51222 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:612c:402a:b0:48e:c0f8:d0de with SMTP id ky42csp211280vqb; Thu, 29 Aug 2024 02:00:14 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXg2lCLW4Op2pcqx4EQTJLSt9pyuHrDQT+lnzwcL05WMbuYNCH/SPAIoEjM6mcmJCcvoEzEn9qUJKTU7Ws0t5pp@gmail.com X-Google-Smtp-Source: AGHT+IG0k9anf4IADHraYdvB9ndL+rEEaMUYiP4o/Y/ZkmCLKp7tCQCpBBOjbfeJ98DIBvasAfCg X-Received: by 2002:a05:651c:19a3:b0:2ef:c8a1:ff4 with SMTP id 38308e7fff4ca-2f6105c49a9mr18204261fa.7.1724922014630; Thu, 29 Aug 2024 02:00:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1724922014; cv=none; d=google.com; s=arc-20240605; b=U4KySBT73B5Rs8EzOmxIrnbhDSfLrFwx0m7cDvzeXa//4bctaDhvaOXie63FMm/sW7 OHRuUt0luTmiEhtOlnTlMTAWQfP6U7vn4aezU1dSh0DMfgqGj/sLp7J6SJSJKRXkeR1d 1KO/3P9yF63PW+x3NMcRd+2GQDjsB7cxU+19tFJVHD8mzCcPCKDe1GK+VdpfOGpMmTK9 6uuULxTwQu8CE0m06lMcg368tummOoHArq/PRBDeYeWYQZu6aKQUF99q3KHDSILuczrV JDR9ImKd761SZa9jK/4xqdq5XxC+cqo9XAJ41lbOrnBEFg2G+ikEVgL/s3AaC85MNzXu JHuQ== 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=bXsRmWMjeNhrEHUSVj78tqVJmokeiNfdfuzbbrWl3PM=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=X/dYNB06D9oTd5/msmQP5VpESsHbw7J+FLJSDHoon0YdODMlRqmbFivI0YB5SMbcam PnujQDzGV6suUrXxar6U3+AMnVrUwcq2ekWc5CJncOM1n59bUNOE2T678VjD/WJcQd70 K+SovS4n6X/U2HKjnRF5ogjtfw34UsnnTcfHzLjclnDZnZrTBOkDUfL28IfwswRI5W92 dyRj+iPwvd18GgbgB8A+Pa9lK195UybyTQwnt1NE58GmbjflCOHQ86KAuapKxqirKCOL U11JknSVhagGsWimijTpDF/m76c3He74gAllrblKDZzaXLj9sV0eEbT8LQLS+MQZhJyd hQIA==; 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=kAMvIQgr; 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-a89891f63c7si79987266b.949.2024.08.29.02.00.13; Thu, 29 Aug 2024 02:00: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=kAMvIQgr; 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 DA9C668DCE7; Thu, 29 Aug 2024 11:52:07 +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 6087468DC73 for ; Thu, 29 Aug 2024 11:51:57 +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=kAMvIQgr; dkim-atps=neutral Received: from localhost (mail1.khirnov.net [IPv6:::1]) by mail1.khirnov.net (Postfix) with ESMTP id E7CDC4DFC for ; Thu, 29 Aug 2024 10:51:56 +0200 (CEST) Received: from mail1.khirnov.net ([IPv6:::1]) by localhost (mail1.khirnov.net [IPv6:::1]) (amavis, port 10024) with ESMTP id IRlhz-NEwD-J for ; Thu, 29 Aug 2024 10:51:56 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=khirnov.net; s=mail; t=1724921514; bh=w3DaWd7ZU2pGb11sBhIrvF7osxTGhuxP1267Pe4y+dI=; h=From:To:Subject:Date:In-Reply-To:References:From; b=kAMvIQgrXDPLoNtZhRMUUTXZnEMcucCK2GoNYz5240KgjFnWtuKyyQzri/VmgzXbe 8OIzZMyJjQnbOylyq/mlxZ8QFEAS0xf/X8MYZ6Bsf216pE2YHI4nP5Ck+xyx07hDFa 1ch+QpJbFVBlnzzP7HUKE6SuZLdbX4wErQHlbkgkzop9cm/ZL0tRffMZC3wxwiCVnm rz0p2L5cGpGBFrF6JzSb+5EgN7vCIgwCxtzmFjuOyhTSuAgzPXWLMUfW0xB/bNm8rm Afa1jmbci/FKAIS7RFNFgxCdjhQCo8oexHRZzZhjgfRMWMNSc9AZQj1xH9JZPBiZfo gUbWxMKvzBnYg== 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 94A064DFE for ; Thu, 29 Aug 2024 10:51:54 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 588F33A27C7 for ; Thu, 29 Aug 2024 10:51:48 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Thu, 29 Aug 2024 10:50:50 +0200 Message-ID: <20240829085052.533-6-anton@khirnov.net> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240829085052.533-1-anton@khirnov.net> References: <20240829085052.533-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 6/8] lavfi/af_afir: 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: TlpwgdBqMFG1 Drop redundant ff_set_common_all_channel_counts() / ff_set_common_all_samplerates() calls, since those happen implicitly in generic code. --- libavfilter/af_afir.c | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/libavfilter/af_afir.c b/libavfilter/af_afir.c index 8ab4d544a8..c641893d4a 100644 --- a/libavfilter/af_afir.c +++ b/libavfilter/af_afir.c @@ -539,9 +539,11 @@ static int activate(AVFilterContext *ctx) return FFERROR_NOT_READY; } -static int query_formats(AVFilterContext *ctx) +static int query_formats(const AVFilterContext *ctx, + AVFilterFormatsConfig **cfg_in, + AVFilterFormatsConfig **cfg_out) { - AudioFIRContext *s = ctx->priv; + const AudioFIRContext *s = ctx->priv; static const enum AVSampleFormat sample_fmts[3][3] = { { AV_SAMPLE_FMT_FLTP, AV_SAMPLE_FMT_DBLP, AV_SAMPLE_FMT_NONE }, { AV_SAMPLE_FMT_FLTP, AV_SAMPLE_FMT_NONE }, @@ -549,32 +551,29 @@ static int query_formats(AVFilterContext *ctx) }; int ret; - if (s->ir_format) { - ret = ff_set_common_all_channel_counts(ctx); - if (ret < 0) - return ret; - } else { + if (!s->ir_format) { AVFilterChannelLayouts *mono = NULL; AVFilterChannelLayouts *layouts = ff_all_channel_counts(); - if ((ret = ff_channel_layouts_ref(layouts, &ctx->inputs[0]->outcfg.channel_layouts)) < 0) + if ((ret = ff_channel_layouts_ref(layouts, &cfg_in[0]->channel_layouts)) < 0) return ret; - if ((ret = ff_channel_layouts_ref(layouts, &ctx->outputs[0]->incfg.channel_layouts)) < 0) + if ((ret = ff_channel_layouts_ref(layouts, &cfg_out[0]->channel_layouts)) < 0) return ret; ret = ff_add_channel_layout(&mono, &(AVChannelLayout)AV_CHANNEL_LAYOUT_MONO); if (ret) return ret; for (int i = 1; i < ctx->nb_inputs; i++) { - if ((ret = ff_channel_layouts_ref(mono, &ctx->inputs[i]->outcfg.channel_layouts)) < 0) + if ((ret = ff_channel_layouts_ref(mono, &cfg_in[i]->channel_layouts)) < 0) return ret; } } - if ((ret = ff_set_common_formats_from_list(ctx, sample_fmts[s->precision])) < 0) + if ((ret = ff_set_common_formats_from_list2(ctx, cfg_in, cfg_out, + sample_fmts[s->precision])) < 0) return ret; - return ff_set_common_all_samplerates(ctx); + return 0; } static int config_output(AVFilterLink *outlink) @@ -783,7 +782,7 @@ const AVFilter ff_af_afir = { .description = NULL_IF_CONFIG_SMALL("Apply Finite Impulse Response filter with supplied coefficients in additional stream(s)."), .priv_size = sizeof(AudioFIRContext), .priv_class = &afir_class, - FILTER_QUERY_FUNC(query_formats), + FILTER_QUERY_FUNC2(query_formats), FILTER_OUTPUTS(outputs), .init = init, .activate = activate, From patchwork Thu Aug 29 08:50:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 51225 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:612c:402a:b0:48e:c0f8:d0de with SMTP id ky42csp224503vqb; Thu, 29 Aug 2024 02:30:11 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWy55eItOsBTy5JFklf/BZZuEk9gE/D27xCJINYHM09p/eOCbL3R+N5ti/yxB2g17da0quvodCXdnaq7yKXhQkl@gmail.com X-Google-Smtp-Source: AGHT+IHJjA950I2bn/e0FLjdi4EmuwbILm0xQ6yzvCMdAYPqL4WnumoCabd+G9Mq+rzoT3F7VceX X-Received: by 2002:a17:906:f586:b0:a86:8097:fdf2 with SMTP id a640c23a62f3a-a897fad29bbmr166586166b.60.1724923810922; Thu, 29 Aug 2024 02:30:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1724923810; cv=none; d=google.com; s=arc-20240605; b=fwD/r5+vwGrEE72RMLWdNc4lmN7cWNBblFYL63F2w8YGQhjtAh3zZv+vtPqYQUsk5o z5b1XMOP+D+fu9hL7KZ9XHm6qguYtkjjmuUEch9qDE0TU3Z6MBZJ5NyPdea+qExfM+2O 8fbsqYPpoLl3p1C7xS5Ls5TfS42Jue9ZQgIQPtMOilKcAZUXpgnSVVD6eK6mWxtj94/M 8MwGZsnotg3TD+roAQ5mVXRIYGNwL4zUVz67YD6Bg0m+3ThaMzECJZwDW49t8B12qRwE oLeS/j72TgLLlt8ZZHtgaLFtWIZuiKXOAzbJLHdKmDX2hvhKGH0tEka2lFN1f1s3oZ/8 FYcg== 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=IcoDEB0ukr3eWfzdWCU+TA0fnKL3qkL35jaJJoUuTjY=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=eKWSn58eu17/KV5kX4s++5nhilLGOpIXPjyvMV77Hl7rsdZk+UORKDs9VPpjEd2YlM aZleQikclPLsDwglLraaKqMWoTvwOyk762gxlK6FXj/dxrgwL7sWNmD6XdCIvoulQ3xQ aQ0VvXmT0tR5Q6MYb/F+tpXT48a9MGwJgPas4jjTOYKh7Ah0oUBKENAeHEQG9HiQItO2 bwmE9u9ZpMC2oASYudB5APahceKOJ4WfFT/lwcTpNZBavxgt2hPRNvYsQP1oofr98njU 8lz70el7KOQihe8/PWgmeaIyPSbHkvtY5DFrXmMSQFKQK5rprT6erzVvjgdf7MJFSBQX zjGQ==; 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=LoShcFQF; 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-a89891d3b09si87989766b.886.2024.08.29.02.30.10; Thu, 29 Aug 2024 02:30:10 -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=LoShcFQF; 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 11E2968DD53; Thu, 29 Aug 2024 11:52:11 +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 C35F368DCE9 for ; Thu, 29 Aug 2024 11:52:01 +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=LoShcFQF; dkim-atps=neutral Received: from localhost (mail1.khirnov.net [IPv6:::1]) by mail1.khirnov.net (Postfix) with ESMTP id 7C0554DFE for ; Thu, 29 Aug 2024 10:51:57 +0200 (CEST) Received: from mail1.khirnov.net ([IPv6:::1]) by localhost (mail1.khirnov.net [IPv6:::1]) (amavis, port 10024) with ESMTP id lCyS53mraIOL for ; Thu, 29 Aug 2024 10:51:57 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=khirnov.net; s=mail; t=1724921514; bh=BQfYBHqOho1lzoiGmkTH7oNTpf+TTGznFUxHOrojJmg=; h=From:To:Subject:Date:In-Reply-To:References:From; b=LoShcFQFfXGCABZ9/JuR571TCKRfahgXEzrd7LMw+Qh4XTo7cgKKff3jGSl+kDcP+ gHOcHqjonWO3+AWXBJ0XH595GUGy+8L0O2KNRH2uLpC59JjC79+lW6DdQfRqIXqcjx fQkXRJkt7D33MNZZtb4NpTbeTSWD3eX2Re3xsmcb/Dk8jHS+M9+GVnplmjbQ8dmGei ObG7THK/SQnKnReSCryyYmVPuy+T+dOTKgqsK/kY5TCzK7h2b7PT+ek1oXl5Ko/0Ba uymTO1jXZFksV96kC+Lj8wLV4xCvkiHSI7saJY3UCqExQvdRTcZ7pHfPOy7gHvrYNh ncKEA0mXuvczg== 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 94A334E02 for ; Thu, 29 Aug 2024 10:51:54 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 640273A293C for ; Thu, 29 Aug 2024 10:51:48 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Thu, 29 Aug 2024 10:50:51 +0200 Message-ID: <20240829085052.533-7-anton@khirnov.net> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240829085052.533-1-anton@khirnov.net> References: <20240829085052.533-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 7/8] lavfi/af_aformat: change options from strings to arrays 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: 2ZqfG0J9lJu3 Allows to drop custom parsing code, and also the assumption that query_formats() is not called more than once. --- libavfilter/af_aformat.c | 168 ++++++++++++++++----------------------- 1 file changed, 67 insertions(+), 101 deletions(-) diff --git a/libavfilter/af_aformat.c b/libavfilter/af_aformat.c index b4cf5f1426..dcedff7b70 100644 --- a/libavfilter/af_aformat.c +++ b/libavfilter/af_aformat.c @@ -26,6 +26,7 @@ #include "libavutil/avstring.h" #include "libavutil/channel_layout.h" #include "libavutil/common.h" +#include "libavutil/mem.h" #include "libavutil/opt.h" #include "audio.h" @@ -36,138 +37,103 @@ typedef struct AFormatContext { const AVClass *class; - AVFilterFormats *formats; - AVFilterFormats *sample_rates; - AVFilterChannelLayouts *channel_layouts; + enum AVSampleFormat *formats; + unsigned nb_formats; - char *formats_str; - char *sample_rates_str; - char *channel_layouts_str; + int *sample_rates; + unsigned nb_sample_rates; + + AVChannelLayout *channel_layouts; + unsigned nb_channel_layouts; } AFormatContext; +static const AVOptionArrayDef array_def = { .sep = '|' }; + #define OFFSET(x) offsetof(AFormatContext, x) #define A AV_OPT_FLAG_AUDIO_PARAM #define F AV_OPT_FLAG_FILTERING_PARAM static const AVOption aformat_options[] = { - { "sample_fmts", "A '|'-separated list of sample formats.", OFFSET(formats_str), AV_OPT_TYPE_STRING, .flags = A|F }, - { "f", "A '|'-separated list of sample formats.", OFFSET(formats_str), AV_OPT_TYPE_STRING, .flags = A|F }, - { "sample_rates", "A '|'-separated list of sample rates.", OFFSET(sample_rates_str), AV_OPT_TYPE_STRING, .flags = A|F }, - { "r", "A '|'-separated list of sample rates.", OFFSET(sample_rates_str), AV_OPT_TYPE_STRING, .flags = A|F }, - { "channel_layouts", "A '|'-separated list of channel layouts.", OFFSET(channel_layouts_str), AV_OPT_TYPE_STRING, .flags = A|F }, - { "cl", "A '|'-separated list of channel layouts.", OFFSET(channel_layouts_str), AV_OPT_TYPE_STRING, .flags = A|F }, + { "sample_fmts", "A '|'-separated list of sample formats.", OFFSET(formats), + AV_OPT_TYPE_SAMPLE_FMT | AV_OPT_TYPE_FLAG_ARRAY, .default_val.arr = &array_def, .flags = A|F }, + { "f", "A '|'-separated list of sample formats.", OFFSET(formats), + AV_OPT_TYPE_SAMPLE_FMT | AV_OPT_TYPE_FLAG_ARRAY, .default_val.arr = &array_def, .flags = A|F }, + { "sample_rates", "A '|'-separated list of sample rates.", OFFSET(sample_rates), + AV_OPT_TYPE_INT | AV_OPT_TYPE_FLAG_ARRAY, .default_val.arr = &array_def, .min = 1, .max = INT_MAX, .flags = A|F }, + { "r", "A '|'-separated list of sample rates.", OFFSET(sample_rates), + AV_OPT_TYPE_INT | AV_OPT_TYPE_FLAG_ARRAY, .default_val.arr = &array_def, .min = 1, .max = INT_MAX, .flags = A|F }, + { "channel_layouts", "A '|'-separated list of channel layouts.", OFFSET(channel_layouts), + AV_OPT_TYPE_CHLAYOUT | AV_OPT_TYPE_FLAG_ARRAY, .default_val.arr = &array_def, .flags = A|F }, + { "cl", "A '|'-separated list of channel layouts.", OFFSET(channel_layouts), + AV_OPT_TYPE_CHLAYOUT | AV_OPT_TYPE_FLAG_ARRAY, .default_val.arr = &array_def, .flags = A|F }, { NULL } }; AVFILTER_DEFINE_CLASS(aformat); -#define PARSE_FORMATS(str, type, list, add_to_list, get_fmt, none, desc) \ -do { \ - char *next, *cur = str; \ - int ret; \ - \ - while (cur) { \ - type fmt; \ - next = strchr(cur, '|'); \ - if (next) \ - *next++ = 0; \ - \ - if ((fmt = get_fmt(cur)) == none) { \ - av_log(ctx, AV_LOG_ERROR, "Error parsing " desc ": %s.\n", cur);\ - return AVERROR(EINVAL); \ - } \ - if ((ret = add_to_list(&list, fmt)) < 0) { \ - return ret; \ - } \ - \ - cur = next; \ - } \ -} while (0) - -static int get_sample_rate(const char *samplerate) -{ - int ret = strtol(samplerate, NULL, 0); - return FFMAX(ret, 0); -} - -static int parse_channel_layouts(AVFilterContext *ctx) -{ - AFormatContext *s = ctx->priv; - char *next, *cur = s->channel_layouts_str; - AVChannelLayout fmt = { 0 }; - int ret; - - while (cur) { - next = strchr(cur, '|'); - if (next) - *next++ = 0; - - ret = av_channel_layout_from_string(&fmt, cur); - if (ret < 0) { - av_log(ctx, AV_LOG_ERROR, "Error parsing channel layout: %s.\n", cur); - return AVERROR(EINVAL); - } - ret = ff_add_channel_layout(&s->channel_layouts, &fmt); - av_channel_layout_uninit(&fmt); - if (ret < 0) - return ret; - - cur = next; - } - - return 0; -} - static av_cold int init(AVFilterContext *ctx) { AFormatContext *s = ctx->priv; - int ret; - PARSE_FORMATS(s->formats_str, enum AVSampleFormat, s->formats, - ff_add_format, av_get_sample_fmt, AV_SAMPLE_FMT_NONE, "sample format"); - PARSE_FORMATS(s->sample_rates_str, int, s->sample_rates, ff_add_format, - get_sample_rate, 0, "sample rate"); - ret = parse_channel_layouts(ctx); - if (ret < 0) - return ret; + // terminate format lists for ff_set*_from_list() + if (s->nb_formats) { + void *tmp = av_realloc_array(s->formats, s->nb_formats + 1, + sizeof(*s->formats)); + if (!tmp) + return AVERROR(ENOMEM); + s->formats = tmp; + s->formats[s->nb_formats] = AV_SAMPLE_FMT_NONE; + + } + if (s->nb_sample_rates) { + void *tmp = av_realloc_array(s->sample_rates, s->nb_sample_rates + 1, + sizeof(*s->sample_rates)); + if (!tmp) + return AVERROR(ENOMEM); + s->sample_rates = tmp; + s->sample_rates[s->nb_sample_rates] = -1; + } + if (s->nb_channel_layouts) { + void *tmp = av_realloc_array(s->channel_layouts, s->nb_channel_layouts + 1, + sizeof(*s->channel_layouts)); + if (!tmp) + return AVERROR(ENOMEM); + s->channel_layouts = tmp; + s->channel_layouts[s->nb_channel_layouts] = (AVChannelLayout){ .nb_channels = 0 }; + } return 0; } -static av_cold void uninit(AVFilterContext *ctx) -{ - AFormatContext *s = ctx->priv; - - ff_formats_unref(&s->formats); - ff_formats_unref(&s->sample_rates); - ff_channel_layouts_unref(&s->channel_layouts); -} - static int query_formats(AVFilterContext *ctx) { AFormatContext *s = ctx->priv; int ret; - ret = ff_set_common_formats(ctx, s->formats ? s->formats : - ff_all_formats(AVMEDIA_TYPE_AUDIO)); - s->formats = NULL; - if (ret < 0) - return ret; - ret = ff_set_common_samplerates(ctx, s->sample_rates ? s->sample_rates : - ff_all_samplerates()); - s->sample_rates = NULL; - if (ret < 0) - return ret; - ret = ff_set_common_channel_layouts(ctx, s->channel_layouts ? s->channel_layouts : - ff_all_channel_counts()); - s->channel_layouts = NULL; - return ret; + if (s->nb_formats) { + ret = ff_set_common_formats_from_list(ctx, s->formats); + if (ret < 0) + return ret; + } + + if (s->nb_sample_rates) { + ret = ff_set_common_samplerates_from_list(ctx, s->sample_rates); + if (ret < 0) + return ret; + } + + if (s->nb_channel_layouts) { + ret = ff_set_common_channel_layouts_from_list(ctx, s->channel_layouts); + if (ret < 0) + return ret; + } + + return 0; } const AVFilter ff_af_aformat = { .name = "aformat", .description = NULL_IF_CONFIG_SMALL("Convert the input audio to one of the specified formats."), .init = init, - .uninit = uninit, .priv_size = sizeof(AFormatContext), .priv_class = &aformat_class, .flags = AVFILTER_FLAG_METADATA_ONLY, From patchwork Thu Aug 29 08:50:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Khirnov X-Patchwork-Id: 51223 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:612c:402a:b0:48e:c0f8:d0de with SMTP id ky42csp211317vqb; Thu, 29 Aug 2024 02:00:17 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWvL98mqNaxXUqYVBEWBJXW3K7e9yftPcM0+vVhzzmbLFjuuOInDxQdcQo6UL6sner3QLf5GTx2NL0re8Nk9SaE@gmail.com X-Google-Smtp-Source: AGHT+IF4yMTNGEa/D8jsSXcYLrYRLRpnFGG011qh/z5wJUmhl48x392Qt+ZydnoRV7pmekCTXOos X-Received: by 2002:a2e:be2b:0:b0:2ef:17df:62f9 with SMTP id 38308e7fff4ca-2f610581e14mr9097251fa.7.1724922017117; Thu, 29 Aug 2024 02:00:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1724922017; cv=none; d=google.com; s=arc-20240605; b=NJH8Ukoh79z09Pd1rXIgGfvgkfi2YKuRhPyiOnYYoznFVDiJb06x924I4Az+QLroQ3 dcA3EC9U3z4pdbjxNvar23Wr24d6Uu7N2Fu39zavYkEAcxe2kKGVV0jnMf96AFRzhVGA skyDhSA5U3Fr6re4SX+o8O86/oKwXbn8SmRZxdyH1vS6OqcWmJ1vjmNfSAT9q4ZkrxoF ZXaqWm1R5661ukLNQ2SJRsw9To9wtnpAelyoFDeXeDbJXAJTQwQD9jk/35qestWzxyZW nQ1udscqRsVP4ZaWhH4a8F7y4HIHuGZHKlFrXJd4+BcJm+h9bE/i53JEBvM5AHcLXwBD TyLw== 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=Rev5AdDQvdivANP1tHEQh2UFD6lsvT3VMKDX1u9r620=; fh=YOA8vD9MJZuwZ71F/05pj6KdCjf6jQRmzLS+CATXUQk=; b=Dj6Ns8AWiWxByqqHEzyCjGPrFJlntVPczs7fOo4Rxy/3R/Oef/074wUi1GZ8k/jb7B DjC+knDIzN9WsnzBzONrfJex+UU2g0uVaNm59IxwlDnYd0juokUDj864G4GWtCyWE5rH Ci9TtoPeu/3m0RyAnbSwwiMB724ORVq0+ZFQP9mlMrr/KM/sIDAirt6oHkPvrulG3WtI 1KdRdnhB7JZVPfN2L0kqkGVVDuv0pk+i72M8NBpRWFtZidCmXGjffGzEShQ6uHtEhycI mNqKKiZAeFfMVvO8q7VTRKf23X77dZK+CLwQwDNb6ZfTnJSFqhqBId7X7w7XjAvt47UF Sitw==; 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=BVDN7j9R; 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 38308e7fff4ca-2f614e957eesi3027611fa.17.2024.08.29.02.00.16; Thu, 29 Aug 2024 02:00:17 -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=BVDN7j9R; 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 E6EBB68DD3A; Thu, 29 Aug 2024 11:52:09 +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 B87C068DCE7 for ; Thu, 29 Aug 2024 11:52:01 +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=BVDN7j9R; dkim-atps=neutral Received: from localhost (mail1.khirnov.net [IPv6:::1]) by mail1.khirnov.net (Postfix) with ESMTP id 75EBE4DF6 for ; Thu, 29 Aug 2024 10:51:57 +0200 (CEST) Received: from mail1.khirnov.net ([IPv6:::1]) by localhost (mail1.khirnov.net [IPv6:::1]) (amavis, port 10024) with ESMTP id ojVqjwMv5j5X for ; Thu, 29 Aug 2024 10:51:57 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=khirnov.net; s=mail; t=1724921514; bh=PcnxlII5mBj4W2+ihyz3A7rOFKmtcghsr28rAWscqRQ=; h=From:To:Subject:Date:In-Reply-To:References:From; b=BVDN7j9RUP1ah23maICQwVkAWjvZuErdxQgl4FiuBec1MxzO+WmQLd2v5n6UPzPXm ciLIMXFr7J5Lou3NoDzvSL0KbensUWg4qYoEseq4WdCVK3Mb5TsavJys9t5HCjZ243 VoWT1DEGzoavzurbXrObOKT52wSLCekU3m/QKyp1Ih2NbWgRT0F0Y+ln50j6fU1K+E UYPjxbt6ispGr7a1XlASYzk9tf1bJxIxLPrOTCU0P5ZCuE94PVWuLS2OeEjuKamy47 WQuBRt+c5pGY0LJtUZWgsZStJxtYU3rVvqUcKBLzF4Td5AiMLUmokB7L776DsI5KN4 s8IbQ3pKZ/eNA== 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 9C1DE4E04 for ; Thu, 29 Aug 2024 10:51:54 +0200 (CEST) Received: from libav.khirnov.net (libav.khirnov.net [IPv6:::1]) by libav.khirnov.net (Postfix) with ESMTP id 6FE913A299F for ; Thu, 29 Aug 2024 10:51:48 +0200 (CEST) From: Anton Khirnov To: ffmpeg-devel@ffmpeg.org Date: Thu, 29 Aug 2024 10:50:52 +0200 Message-ID: <20240829085052.533-8-anton@khirnov.net> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240829085052.533-1-anton@khirnov.net> References: <20240829085052.533-1-anton@khirnov.net> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 8/8] lavfi/af_aformat: 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: 5PF6dyTrASWh --- libavfilter/af_aformat.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/libavfilter/af_aformat.c b/libavfilter/af_aformat.c index dcedff7b70..a7d05a9ce8 100644 --- a/libavfilter/af_aformat.c +++ b/libavfilter/af_aformat.c @@ -104,25 +104,27 @@ 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) { - AFormatContext *s = ctx->priv; + const AFormatContext *s = ctx->priv; int ret; if (s->nb_formats) { - ret = ff_set_common_formats_from_list(ctx, s->formats); + ret = ff_set_common_formats_from_list2(ctx, cfg_in, cfg_out, s->formats); if (ret < 0) return ret; } if (s->nb_sample_rates) { - ret = ff_set_common_samplerates_from_list(ctx, s->sample_rates); + ret = ff_set_common_samplerates_from_list2(ctx, cfg_in, cfg_out, s->sample_rates); if (ret < 0) return ret; } if (s->nb_channel_layouts) { - ret = ff_set_common_channel_layouts_from_list(ctx, s->channel_layouts); + ret = ff_set_common_channel_layouts_from_list2(ctx, cfg_in, cfg_out, s->channel_layouts); if (ret < 0) return ret; } @@ -139,5 +141,5 @@ const AVFilter ff_af_aformat = { .flags = AVFILTER_FLAG_METADATA_ONLY, FILTER_INPUTS(ff_audio_default_filterpad), FILTER_OUTPUTS(ff_audio_default_filterpad), - FILTER_QUERY_FUNC(query_formats), + FILTER_QUERY_FUNC2(query_formats), };