From patchwork Fri Aug 20 09:09:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas George X-Patchwork-Id: 29633 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6602:2a4a:0:0:0:0 with SMTP id k10csp1069829iov; Fri, 20 Aug 2021 02:09:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwrRSt/XfDvYD1JMHCMJjPW01OLyWCaOsJLnY3XWZ9TW71WWRvcXeQ+nTfhG9BUIXgHLQJF X-Received: by 2002:a17:906:7848:: with SMTP id p8mr20252179ejm.212.1629450562096; Fri, 20 Aug 2021 02:09:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629450562; cv=none; d=google.com; s=arc-20160816; b=u8kj1x6+oJkhpZIDmh9SkR1Ye/PmJWnTBN9PNQ1Z4OUiwg+MVCvNd1yohB77xc9ZxD sIrmYJRWqvw8vZKk59tJsy4dTWqiblPE5vzx8rWHaoUN1G0+VUPduCfBU4TWn+yY6+uB a9jYrVFQjpKabf+w52JZz/uhdBxfXQxMPFeA7WltklOHtZ3fjRhlsYu3GlAj9M8KnRtv 5jWuX8PFen9xpNzkzPAmRwnejdjMb9RB9mG+WyWUBZVX/QhClSRWUm77zTmeQvVA+qYq jkkWWqcU4YEdUSRLaoMRQ4bi8YLwLG9lELfAu+6zX8Pyv5JsrJ3qP2BQusmidatJIP34 JWDQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; 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 :delivered-to; bh=jrIT46B4cjwJ+vI1nGuUqTIaxFOFUev9cjCOi+LHbO8=; b=GWagR5SnoOAnaWjjXOAxJM7m09rQBxLSN6fz5pc0+KxvzOoSPtn/QARkzT3hLVjNdT EavtspUajHZevoXkYYnPZylzrJDKvPBsJ+Vj7ydkATPnBudc024zueTRB7xlvvuL0XFI OIZuoHy0ZiwC4d2BklBTLQxFkBL0yoz5mebzcMK/z5rFxHkoaZlcofT+Vtu6MCSF1spR X8Lvwa3GuqNZLjo2dq5Uk8or8+FM3OgZNCsfaytu8/CPPvFxYKejBor7dq7t/KBoJ7A7 DHKpnbBdxQwJI+Wzc7o26B4Icj7JUJCugPVcLmmw34GS0l65Neain+2gF6pobzgbKx/j q3Fg== ARC-Authentication-Results: i=1; mx.google.com; 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 w20si6654433edt.317.2021.08.20.02.09.21; Fri, 20 Aug 2021 02:09:22 -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; 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 81C2168A15D; Fri, 20 Aug 2021 12:09:17 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from nef.ens.fr (nef2.ens.fr [129.199.96.40]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 93A5468081B for ; Fri, 20 Aug 2021 12:09:10 +0300 (EEST) X-ENS-nef-client: 129.199.129.80 ( name = phare.normalesup.org ) Received: from phare.normalesup.org (phare.normalesup.org [129.199.129.80]) by nef.ens.fr (8.14.4/1.01.28121999) with ESMTP id 17K999ok026564 for ; Fri, 20 Aug 2021 11:09:10 +0200 Received: by phare.normalesup.org (Postfix, from userid 1001) id C7C2DEB5BD; Fri, 20 Aug 2021 11:09:09 +0200 (CEST) From: Nicolas George To: ffmpeg-devel@ffmpeg.org Date: Fri, 20 Aug 2021 11:09:06 +0200 Message-Id: <20210820090907.249707-1-george@nsup.org> X-Mailer: git-send-email 2.32.0 MIME-Version: 1.0 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.4.3 (nef.ens.fr [129.199.96.32]); Fri, 20 Aug 2021 11:09:10 +0200 (CEST) Subject: [FFmpeg-devel] [PATCH] lavfi: merge AVFilterChannelLayouts into AVFilterFormats. 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: cu6JwxYZdFBr Make AVFilterFormats.formats uint64_t. They are short-lived lists and usually quite short too. Signed-off-by: Nicolas George --- I think the simplification in formats.c is well worth the cost in memory: most of the lines removed are hard-to-maintain macro code. Furthermore, it will make easier to attach a score to the formats to replace the logic in swap_*() and pick_formats() without adding yet more macro code. This patch has the risk of causing many conflicts, I would like to avoir keeping it in the air too long. Please comment without taking too much time. libavfilter/aeval.c | 6 +- libavfilter/af_afir.c | 10 +- libavfilter/af_aformat.c | 4 +- libavfilter/af_agate.c | 10 +- libavfilter/af_amerge.c | 12 +-- libavfilter/af_anequalizer.c | 6 +- libavfilter/af_apulsator.c | 2 +- libavfilter/af_aresample.c | 6 +- libavfilter/af_asr.c | 2 +- libavfilter/af_bs2b.c | 2 +- libavfilter/af_channelmap.c | 10 +- libavfilter/af_channelsplit.c | 8 +- libavfilter/af_crossfeed.c | 2 +- libavfilter/af_earwax.c | 2 +- libavfilter/af_extrastereo.c | 2 +- libavfilter/af_haas.c | 2 +- libavfilter/af_hdcd.c | 2 +- libavfilter/af_headphone.c | 14 +-- libavfilter/af_join.c | 6 +- libavfilter/af_ladspa.c | 8 +- libavfilter/af_lv2.c | 8 +- libavfilter/af_pan.c | 6 +- libavfilter/af_replaygain.c | 2 +- libavfilter/af_sidechaincompress.c | 10 +- libavfilter/af_silencedetect.c | 2 +- libavfilter/af_sofalizer.c | 6 +- libavfilter/af_stereotools.c | 2 +- libavfilter/af_stereowiden.c | 2 +- libavfilter/af_surround.c | 6 +- libavfilter/asrc_flite.c | 2 +- libavfilter/avf_abitscope.c | 4 +- libavfilter/avf_ahistogram.c | 4 +- libavfilter/avf_aphasemeter.c | 6 +- libavfilter/avf_avectorscope.c | 4 +- libavfilter/avf_concat.c | 6 +- libavfilter/avf_showcqt.c | 4 +- libavfilter/avf_showfreqs.c | 4 +- libavfilter/avf_showspatial.c | 4 +- libavfilter/avf_showspectrum.c | 4 +- libavfilter/avf_showvolume.c | 4 +- libavfilter/avf_showwaves.c | 4 +- libavfilter/avfilter.c | 8 +- libavfilter/avfilter.h | 4 +- libavfilter/avfiltergraph.c | 44 ++++----- libavfilter/buffersink.c | 2 +- libavfilter/buffersrc.c | 2 +- libavfilter/f_ebur128.c | 6 +- libavfilter/formats.c | 152 ++++++++++++----------------- libavfilter/formats.h | 56 +++-------- libavfilter/src_movie.c | 2 +- libavfilter/tests/filtfmts.c | 6 +- libavfilter/vaf_spectrumsynth.c | 4 +- 52 files changed, 221 insertions(+), 275 deletions(-) diff --git a/libavfilter/aeval.c b/libavfilter/aeval.c index 7c891c5ad0..9e2abfff60 100644 --- a/libavfilter/aeval.c +++ b/libavfilter/aeval.c @@ -338,7 +338,7 @@ AVFILTER_DEFINE_CLASS(aeval); static int aeval_query_formats(AVFilterContext *ctx) { - AVFilterChannelLayouts *layouts; + AVFilterFormats *layouts; AVFilterLink *inlink = ctx->inputs[0]; AVFilterLink *outlink = ctx->outputs[0]; EvalContext *eval = ctx->priv; @@ -349,7 +349,7 @@ 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_formats_ref(layouts, &inlink->outcfg.channel_layouts)) < 0) return ret; if (eval->same_chlayout) { @@ -362,7 +362,7 @@ static int aeval_query_formats(AVFilterContext *ctx) eval->out_channel_layout ? eval->out_channel_layout : FF_COUNT2LAYOUT(eval->nb_channels))) < 0) return ret; - if ((ret = ff_channel_layouts_ref(layouts, &outlink->incfg.channel_layouts)) < 0) + if ((ret = ff_formats_ref(layouts, &outlink->incfg.channel_layouts)) < 0) return ret; } diff --git a/libavfilter/af_afir.c b/libavfilter/af_afir.c index d3868a7f2e..3086f91f47 100644 --- a/libavfilter/af_afir.c +++ b/libavfilter/af_afir.c @@ -737,19 +737,19 @@ static int query_formats(AVFilterContext *ctx) if (ret < 0) return ret; } else { - AVFilterChannelLayouts *mono = NULL; - AVFilterChannelLayouts *layouts = ff_all_channel_counts(); + AVFilterFormats *mono = NULL; + AVFilterFormats *layouts = ff_all_channel_counts(); - if ((ret = ff_channel_layouts_ref(layouts, &ctx->inputs[0]->outcfg.channel_layouts)) < 0) + if ((ret = ff_formats_ref(layouts, &ctx->inputs[0]->outcfg.channel_layouts)) < 0) return ret; - if ((ret = ff_channel_layouts_ref(layouts, &ctx->outputs[0]->incfg.channel_layouts)) < 0) + if ((ret = ff_formats_ref(layouts, &ctx->outputs[0]->incfg.channel_layouts)) < 0) return ret; ret = ff_add_channel_layout(&mono, AV_CH_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_formats_ref(mono, &ctx->inputs[i]->outcfg.channel_layouts)) < 0) return ret; } } diff --git a/libavfilter/af_aformat.c b/libavfilter/af_aformat.c index e9cc4738fd..d6c563671b 100644 --- a/libavfilter/af_aformat.c +++ b/libavfilter/af_aformat.c @@ -38,7 +38,7 @@ typedef struct AFormatContext { AVFilterFormats *formats; AVFilterFormats *sample_rates; - AVFilterChannelLayouts *channel_layouts; + AVFilterFormats *channel_layouts; char *formats_str; char *sample_rates_str; @@ -117,7 +117,7 @@ static av_cold void uninit(AVFilterContext *ctx) ff_formats_unref(&s->formats); ff_formats_unref(&s->sample_rates); - ff_channel_layouts_unref(&s->channel_layouts); + ff_formats_unref(&s->channel_layouts); } static int query_formats(AVFilterContext *ctx) diff --git a/libavfilter/af_agate.c b/libavfilter/af_agate.c index eb77dfbcc5..6d9c480fea 100644 --- a/libavfilter/af_agate.c +++ b/libavfilter/af_agate.c @@ -338,7 +338,7 @@ static int activate(AVFilterContext *ctx) static int scquery_formats(AVFilterContext *ctx) { - AVFilterChannelLayouts *layouts = NULL; + AVFilterFormats *layouts = NULL; static const enum AVSampleFormat sample_fmts[] = { AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_NONE @@ -346,19 +346,19 @@ static int scquery_formats(AVFilterContext *ctx) int ret, i; if (!ctx->inputs[0]->incfg.channel_layouts || - !ctx->inputs[0]->incfg.channel_layouts->nb_channel_layouts) { + !ctx->inputs[0]->incfg.channel_layouts->nb_formats) { av_log(ctx, AV_LOG_WARNING, "No channel layout for input 1\n"); return AVERROR(EAGAIN); } - if ((ret = ff_add_channel_layout(&layouts, ctx->inputs[0]->incfg.channel_layouts->channel_layouts[0])) < 0 || - (ret = ff_channel_layouts_ref(layouts, &ctx->outputs[0]->incfg.channel_layouts)) < 0) + if ((ret = ff_add_channel_layout(&layouts, ctx->inputs[0]->incfg.channel_layouts->formats[0])) < 0 || + (ret = ff_formats_ref(layouts, &ctx->outputs[0]->incfg.channel_layouts)) < 0) return ret; for (i = 0; i < 2; i++) { layouts = ff_all_channel_counts(); - if ((ret = ff_channel_layouts_ref(layouts, &ctx->inputs[i]->outcfg.channel_layouts)) < 0) + if ((ret = ff_formats_ref(layouts, &ctx->inputs[i]->outcfg.channel_layouts)) < 0) return ret; } diff --git a/libavfilter/af_amerge.c b/libavfilter/af_amerge.c index 37fb359c84..140deffbce 100644 --- a/libavfilter/af_amerge.c +++ b/libavfilter/af_amerge.c @@ -76,18 +76,18 @@ static int query_formats(AVFilterContext *ctx) }; AMergeContext *s = ctx->priv; int64_t inlayout[SWR_CH_MAX], outlayout = 0; - AVFilterChannelLayouts *layouts; + AVFilterFormats *layouts; int i, ret, overlap = 0, nb_ch = 0; for (i = 0; i < s->nb_inputs; i++) { if (!ctx->inputs[i]->incfg.channel_layouts || - !ctx->inputs[i]->incfg.channel_layouts->nb_channel_layouts) { + !ctx->inputs[i]->incfg.channel_layouts->nb_formats) { av_log(ctx, AV_LOG_WARNING, "No channel layout for input %d\n", i + 1); return AVERROR(EAGAIN); } - inlayout[i] = ctx->inputs[i]->incfg.channel_layouts->channel_layouts[0]; - if (ctx->inputs[i]->incfg.channel_layouts->nb_channel_layouts > 1) { + inlayout[i] = ctx->inputs[i]->incfg.channel_layouts->formats[0]; + if (ctx->inputs[i]->incfg.channel_layouts->nb_formats > 1) { char buf[256]; av_get_channel_layout_string(buf, sizeof(buf), 0, inlayout[i]); av_log(ctx, AV_LOG_INFO, "Using \"%s\" for input %d\n", buf, i + 1); @@ -134,13 +134,13 @@ static int query_formats(AVFilterContext *ctx) layouts = NULL; if ((ret = ff_add_channel_layout(&layouts, inlayout[i])) < 0) return ret; - if ((ret = ff_channel_layouts_ref(layouts, &ctx->inputs[i]->outcfg.channel_layouts)) < 0) + if ((ret = ff_formats_ref(layouts, &ctx->inputs[i]->outcfg.channel_layouts)) < 0) return ret; } layouts = NULL; if ((ret = ff_add_channel_layout(&layouts, outlayout)) < 0) return ret; - if ((ret = ff_channel_layouts_ref(layouts, &ctx->outputs[0]->incfg.channel_layouts)) < 0) + if ((ret = ff_formats_ref(layouts, &ctx->outputs[0]->incfg.channel_layouts)) < 0) return ret; return ff_set_common_all_samplerates(ctx); diff --git a/libavfilter/af_anequalizer.c b/libavfilter/af_anequalizer.c index 229e978278..4d1add3ff6 100644 --- a/libavfilter/af_anequalizer.c +++ b/libavfilter/af_anequalizer.c @@ -220,7 +220,7 @@ static int query_formats(AVFilterContext *ctx) AVFilterLink *outlink = ctx->outputs[0]; AudioNEqualizerContext *s = ctx->priv; AVFilterFormats *formats; - AVFilterChannelLayouts *layouts; + AVFilterFormats *layouts; static const enum AVPixelFormat pix_fmts[] = { AV_PIX_FMT_RGBA, AV_PIX_FMT_NONE }; static const enum AVSampleFormat sample_fmts[] = { AV_SAMPLE_FMT_DBLP, @@ -241,8 +241,8 @@ static int query_formats(AVFilterContext *ctx) 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) + if ((ret = ff_formats_ref(layouts, &inlink->outcfg.channel_layouts)) < 0 || + (ret = ff_formats_ref(layouts, &outlink->incfg.channel_layouts)) < 0) return ret; formats = ff_all_samplerates(); diff --git a/libavfilter/af_apulsator.c b/libavfilter/af_apulsator.c index cef49d891f..6f42123408 100644 --- a/libavfilter/af_apulsator.c +++ b/libavfilter/af_apulsator.c @@ -186,7 +186,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *in) static int query_formats(AVFilterContext *ctx) { - AVFilterChannelLayouts *layout = NULL; + AVFilterFormats *layout = NULL; AVFilterFormats *formats = NULL; int ret; diff --git a/libavfilter/af_aresample.c b/libavfilter/af_aresample.c index 1127ad2718..815469c4dc 100644 --- a/libavfilter/af_aresample.c +++ b/libavfilter/af_aresample.c @@ -87,7 +87,7 @@ static int query_formats(AVFilterContext *ctx) AVFilterFormats *in_formats, *out_formats; AVFilterFormats *in_samplerates, *out_samplerates; - AVFilterChannelLayouts *in_layouts, *out_layouts; + AVFilterFormats *in_layouts, *out_layouts; int ret; av_opt_get_sample_fmt(aresample->swr, "osf", 0, &out_format); @@ -103,7 +103,7 @@ static int query_formats(AVFilterContext *ctx) return ret; in_layouts = ff_all_channel_counts(); - if ((ret = ff_channel_layouts_ref(in_layouts, &inlink->outcfg.channel_layouts)) < 0) + if ((ret = ff_formats_ref(in_layouts, &inlink->outcfg.channel_layouts)) < 0) return ret; if(out_rate > 0) { @@ -130,7 +130,7 @@ static int query_formats(AVFilterContext *ctx) } else out_layouts = ff_all_channel_counts(); - return ff_channel_layouts_ref(out_layouts, &outlink->incfg.channel_layouts); + return ff_formats_ref(out_layouts, &outlink->incfg.channel_layouts); } diff --git a/libavfilter/af_asr.c b/libavfilter/af_asr.c index 8dbe67fa5b..22d001e26c 100644 --- a/libavfilter/af_asr.c +++ b/libavfilter/af_asr.c @@ -127,7 +127,7 @@ static int query_formats(AVFilterContext *ctx) int ret; AVFilterFormats *formats = NULL; - AVFilterChannelLayouts *layout = NULL; + AVFilterFormats *layout = NULL; if ((ret = ff_add_format (&formats, AV_SAMPLE_FMT_S16 )) < 0 || (ret = ff_set_common_formats (ctx , formats )) < 0 || diff --git a/libavfilter/af_bs2b.c b/libavfilter/af_bs2b.c index beb1d0f341..b9d2de2dd2 100644 --- a/libavfilter/af_bs2b.c +++ b/libavfilter/af_bs2b.c @@ -92,7 +92,7 @@ static av_cold void uninit(AVFilterContext *ctx) static int query_formats(AVFilterContext *ctx) { - AVFilterChannelLayouts *layouts = NULL; + AVFilterFormats *layouts = NULL; static const enum AVSampleFormat sample_fmts[] = { AV_SAMPLE_FMT_U8, diff --git a/libavfilter/af_channelmap.c b/libavfilter/af_channelmap.c index 82df3ace15..45c757156b 100644 --- a/libavfilter/af_channelmap.c +++ b/libavfilter/af_channelmap.c @@ -280,18 +280,18 @@ static av_cold int channelmap_init(AVFilterContext *ctx) static int channelmap_query_formats(AVFilterContext *ctx) { ChannelMapContext *s = ctx->priv; - AVFilterChannelLayouts *channel_layouts = NULL; + AVFilterFormats *channel_layouts = NULL; int ret; if ((ret = ff_set_common_formats (ctx, ff_planar_sample_fmts())) < 0 || (ret = ff_set_common_all_samplerates(ctx )) < 0 || (ret = ff_add_channel_layout(&channel_layouts, s->output_layout)) < 0 || - (ret = ff_channel_layouts_ref(channel_layouts, - &ctx->outputs[0]->incfg.channel_layouts)) < 0) + (ret = ff_formats_ref(channel_layouts, + &ctx->outputs[0]->incfg.channel_layouts)) < 0) return ret; - return ff_channel_layouts_ref(ff_all_channel_counts(), - &ctx->inputs[0]->outcfg.channel_layouts); + return ff_formats_ref(ff_all_channel_counts(), + &ctx->inputs[0]->outcfg.channel_layouts); } static int channelmap_filter_frame(AVFilterLink *inlink, AVFrame *buf) diff --git a/libavfilter/af_channelsplit.c b/libavfilter/af_channelsplit.c index 7857ce0343..2d138ca37d 100644 --- a/libavfilter/af_channelsplit.c +++ b/libavfilter/af_channelsplit.c @@ -108,7 +108,7 @@ fail: static int query_formats(AVFilterContext *ctx) { ChannelSplitContext *s = ctx->priv; - AVFilterChannelLayouts *in_layouts = NULL; + AVFilterFormats *in_layouts = NULL; int i, ret; if ((ret = ff_set_common_formats(ctx, ff_planar_sample_fmts())) < 0 || @@ -116,15 +116,15 @@ static int query_formats(AVFilterContext *ctx) return ret; if ((ret = ff_add_channel_layout(&in_layouts, s->channel_layout)) < 0 || - (ret = ff_channel_layouts_ref(in_layouts, &ctx->inputs[0]->outcfg.channel_layouts)) < 0) + (ret = ff_formats_ref(in_layouts, &ctx->inputs[0]->outcfg.channel_layouts)) < 0) return ret; for (i = 0; i < ctx->nb_outputs; i++) { - AVFilterChannelLayouts *out_layouts = NULL; + AVFilterFormats *out_layouts = NULL; uint64_t channel = av_channel_layout_extract_channel(s->channel_layout, s->map[i]); if ((ret = ff_add_channel_layout(&out_layouts, channel)) < 0 || - (ret = ff_channel_layouts_ref(out_layouts, &ctx->outputs[i]->incfg.channel_layouts)) < 0) + (ret = ff_formats_ref(out_layouts, &ctx->outputs[i]->incfg.channel_layouts)) < 0) return ret; } diff --git a/libavfilter/af_crossfeed.c b/libavfilter/af_crossfeed.c index 1d0f8a8149..70114b12d3 100644 --- a/libavfilter/af_crossfeed.c +++ b/libavfilter/af_crossfeed.c @@ -41,7 +41,7 @@ typedef struct CrossfeedContext { static int query_formats(AVFilterContext *ctx) { AVFilterFormats *formats = NULL; - AVFilterChannelLayouts *layout = NULL; + AVFilterFormats *layout = NULL; int ret; if ((ret = ff_add_format (&formats, AV_SAMPLE_FMT_DBL )) < 0 || diff --git a/libavfilter/af_earwax.c b/libavfilter/af_earwax.c index ddb85705ee..41ea07b507 100644 --- a/libavfilter/af_earwax.c +++ b/libavfilter/af_earwax.c @@ -84,7 +84,7 @@ static int query_formats(AVFilterContext *ctx) int ret; AVFilterFormats *formats = NULL; - AVFilterChannelLayouts *layout = NULL; + AVFilterFormats *layout = NULL; if ((ret = ff_add_format (&formats, AV_SAMPLE_FMT_S16P )) < 0 || (ret = ff_set_common_formats (ctx , formats )) < 0 || diff --git a/libavfilter/af_extrastereo.c b/libavfilter/af_extrastereo.c index 6d4f307384..3b2f21e475 100644 --- a/libavfilter/af_extrastereo.c +++ b/libavfilter/af_extrastereo.c @@ -44,7 +44,7 @@ AVFILTER_DEFINE_CLASS(extrastereo); static int query_formats(AVFilterContext *ctx) { AVFilterFormats *formats = NULL; - AVFilterChannelLayouts *layout = NULL; + AVFilterFormats *layout = NULL; int ret; if ((ret = ff_add_format (&formats, AV_SAMPLE_FMT_FLT )) < 0 || diff --git a/libavfilter/af_haas.c b/libavfilter/af_haas.c index b180d4c5b0..578801c319 100644 --- a/libavfilter/af_haas.c +++ b/libavfilter/af_haas.c @@ -82,7 +82,7 @@ AVFILTER_DEFINE_CLASS(haas); static int query_formats(AVFilterContext *ctx) { AVFilterFormats *formats = NULL; - AVFilterChannelLayouts *layout = NULL; + AVFilterFormats *layout = NULL; int ret; if ((ret = ff_add_format (&formats, AV_SAMPLE_FMT_DBL )) < 0 || diff --git a/libavfilter/af_hdcd.c b/libavfilter/af_hdcd.c index 3d180bbbda..1848a30f36 100644 --- a/libavfilter/af_hdcd.c +++ b/libavfilter/af_hdcd.c @@ -1610,7 +1610,7 @@ static int query_formats(AVFilterContext *ctx) }; AVFilterFormats *in_formats; AVFilterFormats *out_formats; - AVFilterChannelLayouts *layouts = NULL; + AVFilterFormats *layouts = NULL; AVFilterLink *inlink = ctx->inputs[0]; AVFilterLink *outlink = ctx->outputs[0]; diff --git a/libavfilter/af_headphone.c b/libavfilter/af_headphone.c index d5b0d84052..447d366fe7 100644 --- a/libavfilter/af_headphone.c +++ b/libavfilter/af_headphone.c @@ -582,9 +582,9 @@ static int query_formats(AVFilterContext *ctx) { struct HeadphoneContext *s = ctx->priv; AVFilterFormats *formats = NULL; - AVFilterChannelLayouts *layouts = NULL; - AVFilterChannelLayouts *stereo_layout = NULL; - AVFilterChannelLayouts *hrir_layouts = NULL; + AVFilterFormats *layouts = NULL; + AVFilterFormats *stereo_layout = NULL; + AVFilterFormats *hrir_layouts = NULL; int ret, i; ret = ff_add_format(&formats, AV_SAMPLE_FMT_FLT); @@ -598,14 +598,14 @@ static int query_formats(AVFilterContext *ctx) if (!layouts) return AVERROR(ENOMEM); - ret = ff_channel_layouts_ref(layouts, &ctx->inputs[0]->outcfg.channel_layouts); + ret = ff_formats_ref(layouts, &ctx->inputs[0]->outcfg.channel_layouts); if (ret) return ret; ret = ff_add_channel_layout(&stereo_layout, AV_CH_LAYOUT_STEREO); if (ret) return ret; - ret = ff_channel_layouts_ref(stereo_layout, &ctx->outputs[0]->incfg.channel_layouts); + ret = ff_formats_ref(stereo_layout, &ctx->outputs[0]->incfg.channel_layouts); if (ret) return ret; @@ -613,12 +613,12 @@ static int query_formats(AVFilterContext *ctx) hrir_layouts = ff_all_channel_counts(); if (!hrir_layouts) return AVERROR(ENOMEM); - ret = ff_channel_layouts_ref(hrir_layouts, &ctx->inputs[1]->outcfg.channel_layouts); + ret = ff_formats_ref(hrir_layouts, &ctx->inputs[1]->outcfg.channel_layouts); if (ret) return ret; } else { for (i = 1; i <= s->nb_hrir_inputs; i++) { - ret = ff_channel_layouts_ref(stereo_layout, &ctx->inputs[i]->outcfg.channel_layouts); + ret = ff_formats_ref(stereo_layout, &ctx->inputs[i]->outcfg.channel_layouts); if (ret) return ret; } diff --git a/libavfilter/af_join.c b/libavfilter/af_join.c index 939edc4fa6..05c57ea442 100644 --- a/libavfilter/af_join.c +++ b/libavfilter/af_join.c @@ -224,16 +224,16 @@ static av_cold void join_uninit(AVFilterContext *ctx) static int join_query_formats(AVFilterContext *ctx) { JoinContext *s = ctx->priv; - AVFilterChannelLayouts *layouts = NULL; + AVFilterFormats *layouts = NULL; int i, ret; if ((ret = ff_add_channel_layout(&layouts, s->channel_layout)) < 0 || - (ret = ff_channel_layouts_ref(layouts, &ctx->outputs[0]->incfg.channel_layouts)) < 0) + (ret = ff_formats_ref(layouts, &ctx->outputs[0]->incfg.channel_layouts)) < 0) return ret; for (i = 0; i < ctx->nb_inputs; i++) { layouts = ff_all_channel_layouts(); - if ((ret = ff_channel_layouts_ref(layouts, &ctx->inputs[i]->outcfg.channel_layouts)) < 0) + if ((ret = ff_formats_ref(layouts, &ctx->inputs[i]->outcfg.channel_layouts)) < 0) return ret; } diff --git a/libavfilter/af_ladspa.c b/libavfilter/af_ladspa.c index 3cf5f9f22b..15dd0f21cf 100644 --- a/libavfilter/af_ladspa.c +++ b/libavfilter/af_ladspa.c @@ -657,7 +657,7 @@ static av_cold int init(AVFilterContext *ctx) static int query_formats(AVFilterContext *ctx) { LADSPAContext *s = ctx->priv; - AVFilterChannelLayouts *layouts; + AVFilterFormats *layouts; static const enum AVSampleFormat sample_fmts[] = { AV_SAMPLE_FMT_FLTP, AV_SAMPLE_FMT_NONE }; int ret = ff_set_common_formats_from_list(ctx, sample_fmts); @@ -700,12 +700,12 @@ static int query_formats(AVFilterContext *ctx) ret = ff_add_channel_layout(&layouts, inlayout); if (ret < 0) return ret; - ret = ff_channel_layouts_ref(layouts, &inlink->outcfg.channel_layouts); + ret = ff_formats_ref(layouts, &inlink->outcfg.channel_layouts); if (ret < 0) return ret; if (!s->nb_outputs) { - ret = ff_channel_layouts_ref(layouts, &outlink->incfg.channel_layouts); + ret = ff_formats_ref(layouts, &outlink->incfg.channel_layouts); if (ret < 0) return ret; } @@ -718,7 +718,7 @@ static int query_formats(AVFilterContext *ctx) ret = ff_add_channel_layout(&layouts, outlayout); if (ret < 0) return ret; - ret = ff_channel_layouts_ref(layouts, &outlink->incfg.channel_layouts); + ret = ff_formats_ref(layouts, &outlink->incfg.channel_layouts); if (ret < 0) return ret; } diff --git a/libavfilter/af_lv2.c b/libavfilter/af_lv2.c index a7f069206d..ed443fe046 100644 --- a/libavfilter/af_lv2.c +++ b/libavfilter/af_lv2.c @@ -476,7 +476,7 @@ static av_cold int init(AVFilterContext *ctx) static int query_formats(AVFilterContext *ctx) { LV2Context *s = ctx->priv; - AVFilterChannelLayouts *layouts; + AVFilterFormats *layouts; AVFilterLink *outlink = ctx->outputs[0]; static const enum AVSampleFormat sample_fmts[] = { AV_SAMPLE_FMT_FLTP, AV_SAMPLE_FMT_NONE }; @@ -513,12 +513,12 @@ static int query_formats(AVFilterContext *ctx) ret = ff_add_channel_layout(&layouts, inlayout); if (ret < 0) return ret; - ret = ff_channel_layouts_ref(layouts, &inlink->outcfg.channel_layouts); + ret = ff_formats_ref(layouts, &inlink->outcfg.channel_layouts); if (ret < 0) return ret; if (!s->nb_outputs) { - ret = ff_channel_layouts_ref(layouts, &outlink->incfg.channel_layouts); + ret = ff_formats_ref(layouts, &outlink->incfg.channel_layouts); if (ret < 0) return ret; } @@ -531,7 +531,7 @@ static int query_formats(AVFilterContext *ctx) ret = ff_add_channel_layout(&layouts, outlayout); if (ret < 0) return ret; - ret = ff_channel_layouts_ref(layouts, &outlink->incfg.channel_layouts); + ret = ff_formats_ref(layouts, &outlink->incfg.channel_layouts); if (ret < 0) return ret; } diff --git a/libavfilter/af_pan.c b/libavfilter/af_pan.c index b699faf75b..fb2f253eaf 100644 --- a/libavfilter/af_pan.c +++ b/libavfilter/af_pan.c @@ -251,7 +251,7 @@ static int query_formats(AVFilterContext *ctx) PanContext *pan = ctx->priv; AVFilterLink *inlink = ctx->inputs[0]; AVFilterLink *outlink = ctx->outputs[0]; - AVFilterChannelLayouts *layouts; + AVFilterFormats *layouts; int ret; pan->pure_gains = are_gains_pure(pan); @@ -264,7 +264,7 @@ static int 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_formats_ref(layouts, &inlink->outcfg.channel_layouts)) < 0) return ret; // outlink supports only requested output channel layout @@ -273,7 +273,7 @@ static int query_formats(AVFilterContext *ctx) pan->out_channel_layout ? pan->out_channel_layout : FF_COUNT2LAYOUT(pan->nb_output_channels))) < 0) return ret; - return ff_channel_layouts_ref(layouts, &outlink->incfg.channel_layouts); + return ff_formats_ref(layouts, &outlink->incfg.channel_layouts); } static int config_props(AVFilterLink *link) diff --git a/libavfilter/af_replaygain.c b/libavfilter/af_replaygain.c index fd642297f8..0445ced798 100644 --- a/libavfilter/af_replaygain.c +++ b/libavfilter/af_replaygain.c @@ -322,7 +322,7 @@ typedef struct ReplayGainContext { static int query_formats(AVFilterContext *ctx) { AVFilterFormats *formats = NULL; - AVFilterChannelLayouts *layout = NULL; + AVFilterFormats *layout = NULL; int i, ret; if ((ret = ff_add_format (&formats, AV_SAMPLE_FMT_FLT )) < 0 || diff --git a/libavfilter/af_sidechaincompress.c b/libavfilter/af_sidechaincompress.c index 8e8547c3a4..80302bc491 100644 --- a/libavfilter/af_sidechaincompress.c +++ b/libavfilter/af_sidechaincompress.c @@ -297,7 +297,7 @@ static int activate(AVFilterContext *ctx) static int query_formats(AVFilterContext *ctx) { - AVFilterChannelLayouts *layouts = NULL; + AVFilterFormats *layouts = NULL; static const enum AVSampleFormat sample_fmts[] = { AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_NONE @@ -305,19 +305,19 @@ static int query_formats(AVFilterContext *ctx) int ret, i; if (!ctx->inputs[0]->incfg.channel_layouts || - !ctx->inputs[0]->incfg.channel_layouts->nb_channel_layouts) { + !ctx->inputs[0]->incfg.channel_layouts->nb_formats) { av_log(ctx, AV_LOG_WARNING, "No channel layout for input 1\n"); return AVERROR(EAGAIN); } - if ((ret = ff_add_channel_layout(&layouts, ctx->inputs[0]->incfg.channel_layouts->channel_layouts[0])) < 0 || - (ret = ff_channel_layouts_ref(layouts, &ctx->outputs[0]->incfg.channel_layouts)) < 0) + if ((ret = ff_add_channel_layout(&layouts, ctx->inputs[0]->incfg.channel_layouts->formats[0])) < 0 || + (ret = ff_formats_ref(layouts, &ctx->outputs[0]->incfg.channel_layouts)) < 0) return ret; for (i = 0; i < 2; i++) { layouts = ff_all_channel_counts(); - if ((ret = ff_channel_layouts_ref(layouts, &ctx->inputs[i]->outcfg.channel_layouts)) < 0) + if ((ret = ff_formats_ref(layouts, &ctx->inputs[i]->outcfg.channel_layouts)) < 0) return ret; } diff --git a/libavfilter/af_silencedetect.c b/libavfilter/af_silencedetect.c index 4342793216..3aaebcc7d6 100644 --- a/libavfilter/af_silencedetect.c +++ b/libavfilter/af_silencedetect.c @@ -197,7 +197,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *insamples) static int query_formats(AVFilterContext *ctx) { - AVFilterChannelLayouts *layouts = NULL; + AVFilterFormats *layouts = NULL; static const enum AVSampleFormat sample_fmts[] = { AV_SAMPLE_FMT_DBL, AV_SAMPLE_FMT_FLT, diff --git a/libavfilter/af_sofalizer.c b/libavfilter/af_sofalizer.c index 9708aab634..9c13ddcfc4 100644 --- a/libavfilter/af_sofalizer.c +++ b/libavfilter/af_sofalizer.c @@ -648,7 +648,7 @@ static int activate(AVFilterContext *ctx) static int query_formats(AVFilterContext *ctx) { struct SOFAlizerContext *s = ctx->priv; - AVFilterChannelLayouts *layouts = NULL; + AVFilterFormats *layouts = NULL; int ret, sample_rates[] = { 48000, -1 }; static const enum AVSampleFormat sample_fmts[] = { AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_FLTP, @@ -663,7 +663,7 @@ static int query_formats(AVFilterContext *ctx) if (!layouts) return AVERROR(ENOMEM); - ret = ff_channel_layouts_ref(layouts, &ctx->inputs[0]->outcfg.channel_layouts); + ret = ff_formats_ref(layouts, &ctx->inputs[0]->outcfg.channel_layouts); if (ret) return ret; @@ -672,7 +672,7 @@ static int query_formats(AVFilterContext *ctx) if (ret) return ret; - ret = ff_channel_layouts_ref(layouts, &ctx->outputs[0]->incfg.channel_layouts); + ret = ff_formats_ref(layouts, &ctx->outputs[0]->incfg.channel_layouts); if (ret) return ret; diff --git a/libavfilter/af_stereotools.c b/libavfilter/af_stereotools.c index 043265f22c..4bca66c7e0 100644 --- a/libavfilter/af_stereotools.c +++ b/libavfilter/af_stereotools.c @@ -102,7 +102,7 @@ AVFILTER_DEFINE_CLASS(stereotools); static int query_formats(AVFilterContext *ctx) { AVFilterFormats *formats = NULL; - AVFilterChannelLayouts *layout = NULL; + AVFilterFormats *layout = NULL; int ret; if ((ret = ff_add_format (&formats, AV_SAMPLE_FMT_DBL )) < 0 || diff --git a/libavfilter/af_stereowiden.c b/libavfilter/af_stereowiden.c index b004b24399..a7783c9fcb 100644 --- a/libavfilter/af_stereowiden.c +++ b/libavfilter/af_stereowiden.c @@ -55,7 +55,7 @@ AVFILTER_DEFINE_CLASS(stereowiden); static int query_formats(AVFilterContext *ctx) { AVFilterFormats *formats = NULL; - AVFilterChannelLayouts *layout = NULL; + AVFilterFormats *layout = NULL; int ret; if ((ret = ff_add_format (&formats, AV_SAMPLE_FMT_FLT )) < 0 || diff --git a/libavfilter/af_surround.c b/libavfilter/af_surround.c index 06e181c7ad..603c53c9b4 100644 --- a/libavfilter/af_surround.c +++ b/libavfilter/af_surround.c @@ -160,7 +160,7 @@ static int query_formats(AVFilterContext *ctx) { AudioSurroundContext *s = ctx->priv; AVFilterFormats *formats = NULL; - AVFilterChannelLayouts *layouts = NULL; + AVFilterFormats *layouts = NULL; int ret; ret = ff_add_format(&formats, AV_SAMPLE_FMT_FLTP); @@ -175,7 +175,7 @@ static int query_formats(AVFilterContext *ctx) if (ret) return ret; - ret = ff_channel_layouts_ref(layouts, &ctx->outputs[0]->incfg.channel_layouts); + ret = ff_formats_ref(layouts, &ctx->outputs[0]->incfg.channel_layouts); if (ret) return ret; @@ -184,7 +184,7 @@ static int query_formats(AVFilterContext *ctx) if (ret) return ret; - ret = ff_channel_layouts_ref(layouts, &ctx->inputs[0]->outcfg.channel_layouts); + ret = ff_formats_ref(layouts, &ctx->inputs[0]->outcfg.channel_layouts); if (ret) return ret; diff --git a/libavfilter/asrc_flite.c b/libavfilter/asrc_flite.c index 1478cc07fa..cd24b39b5c 100644 --- a/libavfilter/asrc_flite.c +++ b/libavfilter/asrc_flite.c @@ -209,7 +209,7 @@ static int query_formats(AVFilterContext *ctx) FliteContext *flite = ctx->priv; int ret; - AVFilterChannelLayouts *chlayouts = NULL; + AVFilterFormats *chlayouts = NULL; int64_t chlayout = av_get_default_channel_layout(flite->wave->num_channels); AVFilterFormats *sample_formats = NULL; AVFilterFormats *sample_rates = NULL; diff --git a/libavfilter/avf_abitscope.c b/libavfilter/avf_abitscope.c index 481a218e6e..c1c7685717 100644 --- a/libavfilter/avf_abitscope.c +++ b/libavfilter/avf_abitscope.c @@ -60,7 +60,7 @@ AVFILTER_DEFINE_CLASS(abitscope); static int query_formats(AVFilterContext *ctx) { AVFilterFormats *formats = NULL; - AVFilterChannelLayouts *layouts; + AVFilterFormats *layouts; AVFilterLink *inlink = ctx->inputs[0]; AVFilterLink *outlink = ctx->outputs[0]; static const enum AVSampleFormat sample_fmts[] = { AV_SAMPLE_FMT_S16P, AV_SAMPLE_FMT_S32P, AV_SAMPLE_FMT_NONE }; @@ -74,7 +74,7 @@ static int query_formats(AVFilterContext *ctx) layouts = ff_all_channel_counts(); if (!layouts) return AVERROR(ENOMEM); - if ((ret = ff_channel_layouts_ref(layouts, &inlink->outcfg.channel_layouts)) < 0) + if ((ret = ff_formats_ref(layouts, &inlink->outcfg.channel_layouts)) < 0) return ret; formats = ff_all_samplerates(); diff --git a/libavfilter/avf_ahistogram.c b/libavfilter/avf_ahistogram.c index 864c061c2f..92a3ca26e0 100644 --- a/libavfilter/avf_ahistogram.c +++ b/libavfilter/avf_ahistogram.c @@ -91,7 +91,7 @@ AVFILTER_DEFINE_CLASS(ahistogram); static int query_formats(AVFilterContext *ctx) { AVFilterFormats *formats = NULL; - AVFilterChannelLayouts *layouts = NULL; + AVFilterFormats *layouts = NULL; AVFilterLink *inlink = ctx->inputs[0]; AVFilterLink *outlink = ctx->outputs[0]; static const enum AVSampleFormat sample_fmts[] = { AV_SAMPLE_FMT_FLTP, AV_SAMPLE_FMT_NONE }; @@ -101,7 +101,7 @@ static int query_formats(AVFilterContext *ctx) formats = ff_make_format_list(sample_fmts); if ((ret = ff_formats_ref (formats, &inlink->outcfg.formats )) < 0 || (layouts = ff_all_channel_counts()) == NULL || - (ret = ff_channel_layouts_ref (layouts, &inlink->outcfg.channel_layouts)) < 0) + (ret = ff_formats_ref (layouts, &inlink->outcfg.channel_layouts)) < 0) return ret; formats = ff_all_samplerates(); diff --git a/libavfilter/avf_aphasemeter.c b/libavfilter/avf_aphasemeter.c index bd3ad1ac61..9b5aab7fa3 100644 --- a/libavfilter/avf_aphasemeter.c +++ b/libavfilter/avf_aphasemeter.c @@ -91,7 +91,7 @@ static int query_formats(AVFilterContext *ctx) { AudioPhaseMeterContext *s = ctx->priv; AVFilterFormats *formats = NULL; - AVFilterChannelLayouts *layout = NULL; + AVFilterFormats *layout = NULL; AVFilterLink *inlink = ctx->inputs[0]; AVFilterLink *outlink = ctx->outputs[0]; static const enum AVSampleFormat sample_fmts[] = { AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_NONE }; @@ -102,8 +102,8 @@ static int query_formats(AVFilterContext *ctx) if ((ret = ff_formats_ref (formats, &inlink->outcfg.formats )) < 0 || (ret = ff_formats_ref (formats, &outlink->incfg.formats )) < 0 || (ret = ff_add_channel_layout (&layout, AV_CH_LAYOUT_STEREO )) < 0 || - (ret = ff_channel_layouts_ref (layout , &inlink->outcfg.channel_layouts)) < 0 || - (ret = ff_channel_layouts_ref (layout , &outlink->incfg.channel_layouts)) < 0) + (ret = ff_formats_ref (layout , &inlink->outcfg.channel_layouts)) < 0 || + (ret = ff_formats_ref (layout , &outlink->incfg.channel_layouts)) < 0) return ret; formats = ff_all_samplerates(); diff --git a/libavfilter/avf_avectorscope.c b/libavfilter/avf_avectorscope.c index a0011fe33b..fc37f44af0 100644 --- a/libavfilter/avf_avectorscope.c +++ b/libavfilter/avf_avectorscope.c @@ -182,7 +182,7 @@ static void fade(AudioVectorScopeContext *s) static int query_formats(AVFilterContext *ctx) { AVFilterFormats *formats = NULL; - AVFilterChannelLayouts *layout = NULL; + AVFilterFormats *layout = NULL; AVFilterLink *inlink = ctx->inputs[0]; AVFilterLink *outlink = ctx->outputs[0]; static const enum AVSampleFormat sample_fmts[] = { AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_NONE }; @@ -192,7 +192,7 @@ static int query_formats(AVFilterContext *ctx) formats = ff_make_format_list(sample_fmts); if ((ret = ff_formats_ref (formats, &inlink->outcfg.formats )) < 0 || (ret = ff_add_channel_layout (&layout, AV_CH_LAYOUT_STEREO )) < 0 || - (ret = ff_channel_layouts_ref (layout , &inlink->outcfg.channel_layouts)) < 0) + (ret = ff_formats_ref (layout , &inlink->outcfg.channel_layouts)) < 0) return ret; formats = ff_all_samplerates(); diff --git a/libavfilter/avf_concat.c b/libavfilter/avf_concat.c index 10f21cecb7..ad5301ea59 100644 --- a/libavfilter/avf_concat.c +++ b/libavfilter/avf_concat.c @@ -76,7 +76,7 @@ static int query_formats(AVFilterContext *ctx) ConcatContext *cat = ctx->priv; unsigned type, nb_str, idx0 = 0, idx, str, seg; AVFilterFormats *formats, *rates = NULL; - AVFilterChannelLayouts *layouts = NULL; + AVFilterFormats *layouts = NULL; int ret; for (type = 0; type < TYPE_ALL; type++) { @@ -94,7 +94,7 @@ static int query_formats(AVFilterContext *ctx) if ((ret = ff_formats_ref(rates, &ctx->outputs[idx]->incfg.samplerates)) < 0) return ret; layouts = ff_all_channel_layouts(); - if ((ret = ff_channel_layouts_ref(layouts, &ctx->outputs[idx]->incfg.channel_layouts)) < 0) + if ((ret = ff_formats_ref(layouts, &ctx->outputs[idx]->incfg.channel_layouts)) < 0) return ret; } @@ -104,7 +104,7 @@ static int query_formats(AVFilterContext *ctx) return ret; if (type == AVMEDIA_TYPE_AUDIO) { if ((ret = ff_formats_ref(rates, &ctx->inputs[idx]->outcfg.samplerates)) < 0 || - (ret = ff_channel_layouts_ref(layouts, &ctx->inputs[idx]->outcfg.channel_layouts)) < 0) + (ret = ff_formats_ref(layouts, &ctx->inputs[idx]->outcfg.channel_layouts)) < 0) return ret; } idx += ctx->nb_outputs; diff --git a/libavfilter/avf_showcqt.c b/libavfilter/avf_showcqt.c index aa9900ebe0..9db70d95e2 100644 --- a/libavfilter/avf_showcqt.c +++ b/libavfilter/avf_showcqt.c @@ -1317,7 +1317,7 @@ static av_cold void uninit(AVFilterContext *ctx) static int query_formats(AVFilterContext *ctx) { AVFilterFormats *formats = NULL; - AVFilterChannelLayouts *layouts = NULL; + AVFilterFormats *layouts = NULL; AVFilterLink *inlink = ctx->inputs[0]; AVFilterLink *outlink = ctx->outputs[0]; static const enum AVSampleFormat sample_fmts[] = { AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_NONE }; @@ -1334,7 +1334,7 @@ static int query_formats(AVFilterContext *ctx) return ret; layouts = ff_make_format64_list(channel_layouts); - if ((ret = ff_channel_layouts_ref(layouts, &inlink->outcfg.channel_layouts)) < 0) + if ((ret = ff_formats_ref(layouts, &inlink->outcfg.channel_layouts)) < 0) return ret; formats = ff_all_samplerates(); diff --git a/libavfilter/avf_showfreqs.c b/libavfilter/avf_showfreqs.c index 5dee3445a8..a39c195232 100644 --- a/libavfilter/avf_showfreqs.c +++ b/libavfilter/avf_showfreqs.c @@ -130,7 +130,7 @@ AVFILTER_DEFINE_CLASS(showfreqs); static int query_formats(AVFilterContext *ctx) { AVFilterFormats *formats = NULL; - AVFilterChannelLayouts *layouts = NULL; + AVFilterFormats *layouts = NULL; AVFilterLink *inlink = ctx->inputs[0]; AVFilterLink *outlink = ctx->outputs[0]; static const enum AVSampleFormat sample_fmts[] = { AV_SAMPLE_FMT_FLTP, AV_SAMPLE_FMT_NONE }; @@ -143,7 +143,7 @@ static int query_formats(AVFilterContext *ctx) return ret; layouts = ff_all_channel_layouts(); - if ((ret = ff_channel_layouts_ref(layouts, &inlink->outcfg.channel_layouts)) < 0) + if ((ret = ff_formats_ref(layouts, &inlink->outcfg.channel_layouts)) < 0) return ret; formats = ff_all_samplerates(); diff --git a/libavfilter/avf_showspatial.c b/libavfilter/avf_showspatial.c index 3e1d4bd70e..12bfa94395 100644 --- a/libavfilter/avf_showspatial.c +++ b/libavfilter/avf_showspatial.c @@ -106,7 +106,7 @@ static av_cold void uninit(AVFilterContext *ctx) static int query_formats(AVFilterContext *ctx) { AVFilterFormats *formats = NULL; - AVFilterChannelLayouts *layout = NULL; + AVFilterFormats *layout = NULL; AVFilterLink *inlink = ctx->inputs[0]; AVFilterLink *outlink = ctx->outputs[0]; static const enum AVSampleFormat sample_fmts[] = { AV_SAMPLE_FMT_FLTP, AV_SAMPLE_FMT_NONE }; @@ -116,7 +116,7 @@ static int query_formats(AVFilterContext *ctx) formats = ff_make_format_list(sample_fmts); if ((ret = ff_formats_ref (formats, &inlink->outcfg.formats )) < 0 || (ret = ff_add_channel_layout (&layout, AV_CH_LAYOUT_STEREO )) < 0 || - (ret = ff_channel_layouts_ref (layout , &inlink->outcfg.channel_layouts)) < 0) + (ret = ff_formats_ref (layout , &inlink->outcfg.channel_layouts)) < 0) return ret; formats = ff_all_samplerates(); diff --git a/libavfilter/avf_showspectrum.c b/libavfilter/avf_showspectrum.c index 6ae4c89d77..cccb0eb06d 100644 --- a/libavfilter/avf_showspectrum.c +++ b/libavfilter/avf_showspectrum.c @@ -362,7 +362,7 @@ static av_cold void uninit(AVFilterContext *ctx) static int query_formats(AVFilterContext *ctx) { AVFilterFormats *formats = NULL; - AVFilterChannelLayouts *layouts = NULL; + AVFilterFormats *layouts = NULL; AVFilterLink *inlink = ctx->inputs[0]; AVFilterLink *outlink = ctx->outputs[0]; static const enum AVSampleFormat sample_fmts[] = { AV_SAMPLE_FMT_FLTP, AV_SAMPLE_FMT_NONE }; @@ -375,7 +375,7 @@ static int query_formats(AVFilterContext *ctx) return ret; layouts = ff_all_channel_layouts(); - if ((ret = ff_channel_layouts_ref(layouts, &inlink->outcfg.channel_layouts)) < 0) + if ((ret = ff_formats_ref(layouts, &inlink->outcfg.channel_layouts)) < 0) return ret; formats = ff_all_samplerates(); diff --git a/libavfilter/avf_showvolume.c b/libavfilter/avf_showvolume.c index d4b8c48297..576fca3b2f 100644 --- a/libavfilter/avf_showvolume.c +++ b/libavfilter/avf_showvolume.c @@ -117,7 +117,7 @@ static av_cold int init(AVFilterContext *ctx) static int query_formats(AVFilterContext *ctx) { AVFilterFormats *formats = NULL; - AVFilterChannelLayouts *layouts = NULL; + AVFilterFormats *layouts = NULL; AVFilterLink *inlink = ctx->inputs[0]; AVFilterLink *outlink = ctx->outputs[0]; static const enum AVSampleFormat sample_fmts[] = { AV_SAMPLE_FMT_FLTP, AV_SAMPLE_FMT_NONE }; @@ -129,7 +129,7 @@ static int query_formats(AVFilterContext *ctx) return ret; layouts = ff_all_channel_counts(); - if ((ret = ff_channel_layouts_ref(layouts, &inlink->outcfg.channel_layouts)) < 0) + if ((ret = ff_formats_ref(layouts, &inlink->outcfg.channel_layouts)) < 0) return ret; formats = ff_all_samplerates(); diff --git a/libavfilter/avf_showwaves.c b/libavfilter/avf_showwaves.c index b3639f46a5..43cade4d69 100644 --- a/libavfilter/avf_showwaves.c +++ b/libavfilter/avf_showwaves.c @@ -152,7 +152,7 @@ static av_cold void uninit(AVFilterContext *ctx) static int query_formats(AVFilterContext *ctx) { AVFilterFormats *formats = NULL; - AVFilterChannelLayouts *layouts = NULL; + AVFilterFormats *layouts = NULL; AVFilterLink *inlink = ctx->inputs[0]; AVFilterLink *outlink = ctx->outputs[0]; static const enum AVSampleFormat sample_fmts[] = { AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_NONE }; @@ -165,7 +165,7 @@ static int query_formats(AVFilterContext *ctx) return ret; layouts = ff_all_channel_layouts(); - if ((ret = ff_channel_layouts_ref(layouts, &inlink->outcfg.channel_layouts)) < 0) + if ((ret = ff_formats_ref(layouts, &inlink->outcfg.channel_layouts)) < 0) return ret; formats = ff_all_samplerates(); diff --git a/libavfilter/avfilter.c b/libavfilter/avfilter.c index ea22b247de..059439826e 100644 --- a/libavfilter/avfilter.c +++ b/libavfilter/avfilter.c @@ -249,8 +249,8 @@ int avfilter_insert_filter(AVFilterLink *link, AVFilterContext *filt, ff_formats_changeref(&link->outcfg.samplerates, &filt->outputs[filt_dstpad_idx]->outcfg.samplerates); if (link->outcfg.channel_layouts) - ff_channel_layouts_changeref(&link->outcfg.channel_layouts, - &filt->outputs[filt_dstpad_idx]->outcfg.channel_layouts); + ff_formats_changeref(&link->outcfg.channel_layouts, + &filt->outputs[filt_dstpad_idx]->outcfg.channel_layouts); return 0; } @@ -703,8 +703,8 @@ static void free_link(AVFilterLink *link) ff_formats_unref(&link->outcfg.formats); ff_formats_unref(&link->incfg.samplerates); ff_formats_unref(&link->outcfg.samplerates); - ff_channel_layouts_unref(&link->incfg.channel_layouts); - ff_channel_layouts_unref(&link->outcfg.channel_layouts); + ff_formats_unref(&link->incfg.channel_layouts); + ff_formats_unref(&link->outcfg.channel_layouts); avfilter_link_free(&link); } diff --git a/libavfilter/avfilter.h b/libavfilter/avfilter.h index 5a225ffc44..19d26d6561 100644 --- a/libavfilter/avfilter.h +++ b/libavfilter/avfilter.h @@ -68,7 +68,7 @@ typedef struct AVFilterContext AVFilterContext; typedef struct AVFilterLink AVFilterLink; typedef struct AVFilterPad AVFilterPad; typedef struct AVFilterFormats AVFilterFormats; -typedef struct AVFilterChannelLayouts AVFilterChannelLayouts; +typedef struct AVFilterFormats AVFilterChannelLayouts; /** * Get the number of elements in a NULL-terminated array of AVFilterPads (e.g. @@ -437,7 +437,7 @@ typedef struct AVFilterFormatsConfig { /** * Lists of supported channel layouts, only for audio. */ - AVFilterChannelLayouts *channel_layouts; + AVFilterFormats *channel_layouts; } AVFilterFormatsConfig; diff --git a/libavfilter/avfiltergraph.c b/libavfilter/avfiltergraph.c index 8c6d43a0c7..2b8bac2a4c 100644 --- a/libavfilter/avfiltergraph.c +++ b/libavfilter/avfiltergraph.c @@ -295,11 +295,11 @@ AVFilterContext *avfilter_graph_get_filter(AVFilterGraph *graph, const char *nam return NULL; } -static void sanitize_channel_layouts(void *log, AVFilterChannelLayouts *l) +static void sanitize_channel_layouts(void *log, AVFilterFormats *l) { if (!l) return; - if (l->nb_channel_layouts) { + if (l->nb_formats) { if (l->all_layouts || l->all_counts) av_log(log, AV_LOG_WARNING, "All layouts set on non-empty list\n"); l->all_layouts = l->all_counts = 0; @@ -361,7 +361,7 @@ static int filter_query_formats(AVFilterContext *ctx) { int ret, i; AVFilterFormats *formats; - AVFilterChannelLayouts *chlayouts; + AVFilterFormats *chlayouts; enum AVMediaType type = ctx->inputs && ctx->inputs [0] ? ctx->inputs [0]->type : ctx->outputs && ctx->outputs[0] ? ctx->outputs[0]->type : AVMEDIA_TYPE_VIDEO; @@ -681,8 +681,8 @@ static int pick_format(AVFilterLink *link, AVFilterLink *ref) "'aformat=channel_layouts=something'.\n"); return AVERROR(EINVAL); } - link->incfg.channel_layouts->nb_channel_layouts = 1; - link->channel_layout = link->incfg.channel_layouts->channel_layouts[0]; + link->incfg.channel_layouts->nb_formats = 1; + link->channel_layout = link->incfg.channel_layouts->formats[0]; if ((link->channels = FF_LAYOUT2COUNT(link->channel_layout))) link->channel_layout = 0; else @@ -693,8 +693,8 @@ static int pick_format(AVFilterLink *link, AVFilterLink *ref) ff_formats_unref(&link->outcfg.formats); ff_formats_unref(&link->incfg.samplerates); ff_formats_unref(&link->outcfg.samplerates); - ff_channel_layouts_unref(&link->incfg.channel_layouts); - ff_channel_layouts_unref(&link->outcfg.channel_layouts); + ff_formats_unref(&link->incfg.channel_layouts); + ff_formats_unref(&link->outcfg.channel_layouts); return 0; } @@ -751,16 +751,16 @@ static int reduce_formats_on_filter(AVFilterContext *filter) uint64_t fmt; if (!inlink->outcfg.channel_layouts || - inlink->outcfg.channel_layouts->nb_channel_layouts != 1) + inlink->outcfg.channel_layouts->nb_formats != 1) continue; - fmt = inlink->outcfg.channel_layouts->channel_layouts[0]; + fmt = inlink->outcfg.channel_layouts->formats[0]; for (j = 0; j < filter->nb_outputs; j++) { AVFilterLink *outlink = filter->outputs[j]; - AVFilterChannelLayouts *fmts; + AVFilterFormats *fmts; fmts = outlink->incfg.channel_layouts; - if (inlink->type != outlink->type || fmts->nb_channel_layouts == 1) + if (inlink->type != outlink->type || fmts->nb_formats == 1) continue; if (fmts->all_layouts && @@ -772,10 +772,10 @@ static int reduce_formats_on_filter(AVFilterContext *filter) break; } - for (k = 0; k < outlink->incfg.channel_layouts->nb_channel_layouts; k++) { - if (fmts->channel_layouts[k] == fmt) { - fmts->channel_layouts[0] = fmt; - fmts->nb_channel_layouts = 1; + for (k = 0; k < outlink->incfg.channel_layouts->nb_formats; k++) { + if (fmts->formats[k] == fmt) { + fmts->formats[0] = fmt; + fmts->nb_formats = 1; ret = 1; break; } @@ -895,7 +895,7 @@ static void swap_channel_layouts_on_filter(AVFilterContext *filter) link = filter->inputs[i]; if (link->type == AVMEDIA_TYPE_AUDIO && - link->outcfg.channel_layouts->nb_channel_layouts == 1) + link->outcfg.channel_layouts->nb_formats == 1) break; } if (i == filter->nb_inputs) @@ -906,12 +906,12 @@ static void swap_channel_layouts_on_filter(AVFilterContext *filter) int best_idx = -1, best_score = INT_MIN, best_count_diff = INT_MAX; if (outlink->type != AVMEDIA_TYPE_AUDIO || - outlink->incfg.channel_layouts->nb_channel_layouts < 2) + outlink->incfg.channel_layouts->nb_formats < 2) continue; - for (j = 0; j < outlink->incfg.channel_layouts->nb_channel_layouts; j++) { - uint64_t in_chlayout = link->outcfg.channel_layouts->channel_layouts[0]; - uint64_t out_chlayout = outlink->incfg.channel_layouts->channel_layouts[j]; + for (j = 0; j < outlink->incfg.channel_layouts->nb_formats; j++) { + uint64_t in_chlayout = link->outcfg.channel_layouts->formats[0]; + uint64_t out_chlayout = outlink->incfg.channel_layouts->formats[j]; int in_channels = av_get_channel_layout_nb_channels(in_chlayout); int out_channels = av_get_channel_layout_nb_channels(out_chlayout); int count_diff = out_channels - in_channels; @@ -969,8 +969,8 @@ static void swap_channel_layouts_on_filter(AVFilterContext *filter) } } av_assert0(best_idx >= 0); - FFSWAP(uint64_t, outlink->incfg.channel_layouts->channel_layouts[0], - outlink->incfg.channel_layouts->channel_layouts[best_idx]); + FFSWAP(uint64_t, outlink->incfg.channel_layouts->formats[0], + outlink->incfg.channel_layouts->formats[best_idx]); } } diff --git a/libavfilter/buffersink.c b/libavfilter/buffersink.c index 07c4812f29..54fc9a8f34 100644 --- a/libavfilter/buffersink.c +++ b/libavfilter/buffersink.c @@ -256,7 +256,7 @@ static int asink_query_formats(AVFilterContext *ctx) { BufferSinkContext *buf = ctx->priv; AVFilterFormats *formats = NULL; - AVFilterChannelLayouts *layouts = NULL; + AVFilterFormats *layouts = NULL; unsigned i; int ret; diff --git a/libavfilter/buffersrc.c b/libavfilter/buffersrc.c index 4d0bb4f91d..40db97fe2e 100644 --- a/libavfilter/buffersrc.c +++ b/libavfilter/buffersrc.c @@ -356,7 +356,7 @@ static av_cold void uninit(AVFilterContext *ctx) static int query_formats(AVFilterContext *ctx) { BufferSourceContext *c = ctx->priv; - AVFilterChannelLayouts *channel_layouts = NULL; + AVFilterFormats *channel_layouts = NULL; AVFilterFormats *formats = NULL; AVFilterFormats *samplerates = NULL; int ret; diff --git a/libavfilter/f_ebur128.c b/libavfilter/f_ebur128.c index 938ae60848..ed756c4682 100644 --- a/libavfilter/f_ebur128.c +++ b/libavfilter/f_ebur128.c @@ -912,7 +912,7 @@ static int query_formats(AVFilterContext *ctx) { EBUR128Context *ebur128 = ctx->priv; AVFilterFormats *formats; - AVFilterChannelLayouts *layouts; + AVFilterFormats *layouts; AVFilterLink *inlink = ctx->inputs[0]; AVFilterLink *outlink = ctx->outputs[0]; int ret; @@ -937,8 +937,8 @@ static int query_formats(AVFilterContext *ctx) return ret; layouts = ff_all_channel_layouts(); - if ((ret = ff_channel_layouts_ref(layouts, &inlink->outcfg.channel_layouts)) < 0 || - (ret = ff_channel_layouts_ref(layouts, &outlink->incfg.channel_layouts)) < 0) + if ((ret = ff_formats_ref(layouts, &inlink->outcfg.channel_layouts)) < 0 || + (ret = ff_formats_ref(layouts, &outlink->incfg.channel_layouts)) < 0) return ret; formats = ff_all_samplerates(); diff --git a/libavfilter/formats.c b/libavfilter/formats.c index ca85b4094b..7914748421 100644 --- a/libavfilter/formats.c +++ b/libavfilter/formats.c @@ -212,9 +212,9 @@ static int merge_samplerates(void *a, void *b) */ static int merge_channel_layouts(void *va, void *vb) { - AVFilterChannelLayouts *a = va; - AVFilterChannelLayouts *b = vb; - uint64_t *channel_layouts; + AVFilterFormats *a = va; + AVFilterFormats *b = vb; + uint64_t *formats; unsigned a_all = a->all_layouts + a->all_counts; unsigned b_all = b->all_layouts + b->all_counts; int ret_max, ret_nb = 0, i, j, round; @@ -225,37 +225,37 @@ static int merge_channel_layouts(void *va, void *vb) /* Put the most generic set in a, to avoid doing everything twice */ if (a_all < b_all) { - FFSWAP(AVFilterChannelLayouts *, a, b); + FFSWAP(AVFilterFormats *, a, b); FFSWAP(unsigned, a_all, b_all); } if (a_all) { if (a_all == 1 && !b_all) { /* keep only known layouts in b; works also for b_all = 1 */ - for (i = j = 0; i < b->nb_channel_layouts; i++) - if (KNOWN(b->channel_layouts[i])) - b->channel_layouts[j++] = b->channel_layouts[i]; + for (i = j = 0; i < b->nb_formats; i++) + if (KNOWN(b->formats[i])) + b->formats[j++] = b->formats[i]; /* Not optimal: the unknown layouts of b may become known after another merge. */ if (!j) return 0; - b->nb_channel_layouts = j; + b->nb_formats = j; } - MERGE_REF(b, a, channel_layouts, AVFilterChannelLayouts, return AVERROR(ENOMEM);); + MERGE_REF(b, a, formats, AVFilterFormats, return AVERROR(ENOMEM);); return 1; } - ret_max = a->nb_channel_layouts + b->nb_channel_layouts; - if (!(channel_layouts = av_malloc_array(ret_max, sizeof(*channel_layouts)))) + ret_max = a->nb_formats + b->nb_formats; + if (!(formats = av_malloc_array(ret_max, sizeof(*formats)))) return AVERROR(ENOMEM); /* a[known] intersect b[known] */ - for (i = 0; i < a->nb_channel_layouts; i++) { - if (!KNOWN(a->channel_layouts[i])) + for (i = 0; i < a->nb_formats; i++) { + if (!KNOWN(a->formats[i])) continue; - for (j = 0; j < b->nb_channel_layouts; j++) { - if (a->channel_layouts[i] == b->channel_layouts[j]) { - channel_layouts[ret_nb++] = a->channel_layouts[i]; - a->channel_layouts[i] = b->channel_layouts[j] = 0; + for (j = 0; j < b->nb_formats; j++) { + if (a->formats[i] == b->formats[j]) { + formats[ret_nb++] = a->formats[i]; + a->formats[i] = b->formats[j] = 0; break; } } @@ -263,40 +263,40 @@ static int merge_channel_layouts(void *va, void *vb) /* 1st round: a[known] intersect b[generic] 2nd round: a[generic] intersect b[known] */ for (round = 0; round < 2; round++) { - for (i = 0; i < a->nb_channel_layouts; i++) { - uint64_t fmt = a->channel_layouts[i], bfmt; + for (i = 0; i < a->nb_formats; i++) { + uint64_t fmt = a->formats[i], bfmt; if (!fmt || !KNOWN(fmt)) continue; bfmt = FF_COUNT2LAYOUT(av_get_channel_layout_nb_channels(fmt)); - for (j = 0; j < b->nb_channel_layouts; j++) - if (b->channel_layouts[j] == bfmt) - channel_layouts[ret_nb++] = a->channel_layouts[i]; + for (j = 0; j < b->nb_formats; j++) + if (b->formats[j] == bfmt) + formats[ret_nb++] = a->formats[i]; } /* 1st round: swap to prepare 2nd round; 2nd round: put it back */ - FFSWAP(AVFilterChannelLayouts *, a, b); + FFSWAP(AVFilterFormats *, a, b); } /* a[generic] intersect b[generic] */ - for (i = 0; i < a->nb_channel_layouts; i++) { - if (KNOWN(a->channel_layouts[i])) + for (i = 0; i < a->nb_formats; i++) { + if (KNOWN(a->formats[i])) continue; - for (j = 0; j < b->nb_channel_layouts; j++) - if (a->channel_layouts[i] == b->channel_layouts[j]) - channel_layouts[ret_nb++] = a->channel_layouts[i]; + for (j = 0; j < b->nb_formats; j++) + if (a->formats[i] == b->formats[j]) + formats[ret_nb++] = a->formats[i]; } if (!ret_nb) { - av_free(channel_layouts); + av_free(formats); return 0; } if (a->refcount > b->refcount) - FFSWAP(AVFilterChannelLayouts *, a, b); + FFSWAP(AVFilterFormats *, a, b); - MERGE_REF(b, a, channel_layouts, AVFilterChannelLayouts, - { av_free(channel_layouts); return AVERROR(ENOMEM); }); - av_freep(&b->channel_layouts); - b->channel_layouts = channel_layouts; - b->nb_channel_layouts = ret_nb; + MERGE_REF(b, a, formats, AVFilterFormats, + { av_free(formats); return AVERROR(ENOMEM); }); + av_freep(&b->formats); + b->formats = formats; + b->nb_formats = ret_nb; return 1; } @@ -387,13 +387,12 @@ AVFilterFormats *ff_make_format_list(const int *fmts) return formats; } -AVFilterChannelLayouts *ff_make_format64_list(const int64_t *fmts) +AVFilterFormats *ff_make_format64_list(const int64_t *fmts) { - MAKE_FORMAT_LIST(AVFilterChannelLayouts, - channel_layouts, nb_channel_layouts); + MAKE_FORMAT_LIST(AVFilterFormats, formats, nb_formats); if (count) - memcpy(formats->channel_layouts, fmts, - sizeof(*formats->channel_layouts) * count); + memcpy(formats->formats, fmts, + sizeof(*formats->formats) * count); return formats; } @@ -419,14 +418,14 @@ do { \ int ff_add_format(AVFilterFormats **avff, int64_t fmt) { - ADD_FORMAT(avff, fmt, ff_formats_unref, int, formats, nb_formats); + ADD_FORMAT(avff, fmt, ff_formats_unref, uint64_t, formats, nb_formats); return 0; } -int ff_add_channel_layout(AVFilterChannelLayouts **l, uint64_t channel_layout) +int ff_add_channel_layout(AVFilterFormats **l, uint64_t channel_layout) { av_assert1(!(*l && (*l)->all_layouts)); - ADD_FORMAT(l, channel_layout, ff_channel_layouts_unref, uint64_t, channel_layouts, nb_channel_layouts); + ADD_FORMAT(l, channel_layout, ff_formats_unref, uint64_t, formats, nb_formats); return 0; } @@ -512,25 +511,26 @@ AVFilterFormats *ff_all_samplerates(void) return ret; } -AVFilterChannelLayouts *ff_all_channel_layouts(void) +AVFilterFormats *ff_all_channel_layouts(void) { - AVFilterChannelLayouts *ret = av_mallocz(sizeof(*ret)); + AVFilterFormats *ret = av_mallocz(sizeof(*ret)); if (!ret) return NULL; ret->all_layouts = 1; return ret; } -AVFilterChannelLayouts *ff_all_channel_counts(void) +AVFilterFormats *ff_all_channel_counts(void) { - AVFilterChannelLayouts *ret = av_mallocz(sizeof(*ret)); + AVFilterFormats *ret = av_mallocz(sizeof(*ret)); if (!ret) return NULL; ret->all_layouts = ret->all_counts = 1; return ret; } -#define FORMATS_REF(f, ref, unref_fn) \ +int ff_formats_ref(AVFilterFormats *f, AVFilterFormats **ref) +{ void *tmp; \ \ if (!f) \ @@ -538,22 +538,13 @@ AVFilterChannelLayouts *ff_all_channel_counts(void) \ tmp = av_realloc_array(f->refs, sizeof(*f->refs), f->refcount + 1); \ if (!tmp) { \ - unref_fn(&f); \ + ff_formats_unref(&f); \ return AVERROR(ENOMEM); \ } \ f->refs = tmp; \ f->refs[f->refcount++] = ref; \ *ref = f; \ - return 0 - -int ff_channel_layouts_ref(AVFilterChannelLayouts *f, AVFilterChannelLayouts **ref) -{ - FORMATS_REF(f, ref, ff_channel_layouts_unref); -} - -int ff_formats_ref(AVFilterFormats *f, AVFilterFormats **ref) -{ - FORMATS_REF(f, ref, ff_formats_unref); + return 0; } #define FIND_REF_INDEX(ref, idx) \ @@ -566,8 +557,8 @@ do { \ } \ } while (0) -#define FORMATS_UNREF(ref, list) \ -do { \ +void ff_formats_unref(AVFilterFormats **ref) +{ int idx = -1; \ \ if (!*ref) \ @@ -581,25 +572,15 @@ do { \ --(*ref)->refcount; \ } \ if (!(*ref)->refcount) { \ - av_free((*ref)->list); \ + av_free((*ref)->formats); \ av_free((*ref)->refs); \ av_free(*ref); \ } \ *ref = NULL; \ -} while (0) - -void ff_formats_unref(AVFilterFormats **ref) -{ - FORMATS_UNREF(ref, formats); } -void ff_channel_layouts_unref(AVFilterChannelLayouts **ref) +void ff_formats_changeref(AVFilterFormats **oldref, AVFilterFormats **newref) { - FORMATS_UNREF(ref, channel_layouts); -} - -#define FORMATS_CHANGEREF(oldref, newref) \ -do { \ int idx = -1; \ \ FIND_REF_INDEX(oldref, idx); \ @@ -609,17 +590,6 @@ do { \ *newref = *oldref; \ *oldref = NULL; \ } \ -} while (0) - -void ff_channel_layouts_changeref(AVFilterChannelLayouts **oldref, - AVFilterChannelLayouts **newref) -{ - FORMATS_CHANGEREF(oldref, newref); -} - -void ff_formats_changeref(AVFilterFormats **oldref, AVFilterFormats **newref) -{ - FORMATS_CHANGEREF(oldref, newref); } #define SET_COMMON_FORMATS(ctx, fmts, ref_fn, unref_fn) \ @@ -654,10 +624,10 @@ void ff_formats_changeref(AVFilterFormats **oldref, AVFilterFormats **newref) return 0; int ff_set_common_channel_layouts(AVFilterContext *ctx, - AVFilterChannelLayouts *channel_layouts) + AVFilterFormats *channel_layouts) { SET_COMMON_FORMATS(ctx, channel_layouts, - ff_channel_layouts_ref, ff_channel_layouts_unref); + ff_formats_ref, ff_formats_unref); } int ff_set_common_channel_layouts_from_list(AVFilterContext *ctx, @@ -822,7 +792,7 @@ static int layouts_compatible(uint64_t a, uint64_t b) (KNOWN(b) && !KNOWN(a) && av_get_channel_layout_nb_channels(b) == FF_LAYOUT2COUNT(a)); } -int ff_formats_check_channel_layouts(void *log, const AVFilterChannelLayouts *fmts) +int ff_formats_check_channel_layouts(void *log, const AVFilterFormats *fmts) { unsigned i, j; @@ -832,13 +802,13 @@ int ff_formats_check_channel_layouts(void *log, const AVFilterChannelLayouts *fm av_log(log, AV_LOG_ERROR, "Inconsistent generic list\n"); return AVERROR(EINVAL); } - if (!fmts->all_layouts && !fmts->nb_channel_layouts) { + if (!fmts->all_layouts && !fmts->nb_formats) { av_log(log, AV_LOG_ERROR, "Empty channel layout list\n"); return AVERROR(EINVAL); } - for (i = 0; i < fmts->nb_channel_layouts; i++) { - for (j = i + 1; j < fmts->nb_channel_layouts; j++) { - if (layouts_compatible(fmts->channel_layouts[i], fmts->channel_layouts[j])) { + for (i = 0; i < fmts->nb_formats; i++) { + for (j = i + 1; j < fmts->nb_formats; j++) { + if (layouts_compatible(fmts->formats[i], fmts->formats[j])) { av_log(log, AV_LOG_ERROR, "Duplicated or redundant channel layout\n"); return AVERROR(EINVAL); } diff --git a/libavfilter/formats.h b/libavfilter/formats.h index 7c8258ed08..dafc40e915 100644 --- a/libavfilter/formats.h +++ b/libavfilter/formats.h @@ -60,20 +60,8 @@ * we must ensure that all links which reference either pre-merge format list * get updated as well. Therefore, we have the format list structure store a * pointer to each of the pointers to itself. - */ -struct AVFilterFormats { - unsigned nb_formats; ///< number of formats - int *formats; ///< list of media formats - - unsigned refcount; ///< number of references to this list - struct AVFilterFormats ***refs; ///< references to this list -}; - -/** - * A list of supported channel layouts. * - * The list works the same as AVFilterFormats, except for the following - * differences: + * For channel layouts: * - A list with all_layouts = 1 means all channel layouts with a known * disposition; nb_channel_layouts must then be 0. * - A list with all_counts = 1 means all channel counts, with a known or @@ -82,21 +70,21 @@ struct AVFilterFormats { * channel count with unknown disposition with the same number of channels * (e.g. AV_CH_LAYOUT_STEREO and FF_COUNT2LAYOUT(2). */ -struct AVFilterChannelLayouts { - uint64_t *channel_layouts; ///< list of channel layouts - int nb_channel_layouts; ///< number of channel layouts +struct AVFilterFormats { + unsigned nb_formats; ///< number of formats + uint64_t *formats; ///< list of media formats char all_layouts; ///< accept any known channel layout char all_counts; ///< accept any channel layout or count unsigned refcount; ///< number of references to this list - struct AVFilterChannelLayouts ***refs; ///< references to this list + struct AVFilterFormats ***refs; ///< references to this list }; /** * Encode a channel count as a channel layout. * FF_COUNT2LAYOUT(c) means any channel layout with c channels, with a known * or unknown disposition. - * The result is only valid inside AVFilterChannelLayouts and immediately + * The result is only valid inside AVFilterFormats and immediately * related functions. */ #define FF_COUNT2LAYOUT(c) (0x8000000000000000ULL | (c)) @@ -109,24 +97,24 @@ struct AVFilterChannelLayouts { (int)((l) & 0x7FFFFFFF) : 0) /** - * Construct an empty AVFilterChannelLayouts/AVFilterFormats struct -- + * Construct an empty AVFilterFormats struct -- * representing any channel layout (with known disposition)/sample rate. */ av_warn_unused_result -AVFilterChannelLayouts *ff_all_channel_layouts(void); +AVFilterFormats *ff_all_channel_layouts(void); av_warn_unused_result AVFilterFormats *ff_all_samplerates(void); /** - * Construct an AVFilterChannelLayouts coding for any channel layout, with + * Construct an AVFilterFormats coding for any channel layout, with * known or unknown disposition. */ av_warn_unused_result -AVFilterChannelLayouts *ff_all_channel_counts(void); +AVFilterFormats *ff_all_channel_counts(void); av_warn_unused_result -AVFilterChannelLayouts *ff_make_format64_list(const int64_t *fmts); +AVFilterFormats *ff_make_format64_list(const int64_t *fmts); /** * A helper for query_formats() which sets all links to the same list of channel @@ -135,7 +123,7 @@ AVFilterChannelLayouts *ff_make_format64_list(const int64_t *fmts); */ av_warn_unused_result int ff_set_common_channel_layouts(AVFilterContext *ctx, - AVFilterChannelLayouts *layouts); + AVFilterFormats *layouts); /** * Equivalent to ff_set_common_channel_layouts(ctx, ff_make_format64_list(fmts)) */ @@ -178,22 +166,10 @@ av_warn_unused_result int ff_set_common_formats_from_list(AVFilterContext *ctx, const int *fmts); av_warn_unused_result -int ff_add_channel_layout(AVFilterChannelLayouts **l, uint64_t channel_layout); - -/** - * Add *ref as a new reference to f. - */ -av_warn_unused_result -int ff_channel_layouts_ref(AVFilterChannelLayouts *f, - AVFilterChannelLayouts **ref); - -/** - * Remove a reference to a channel layouts list. - */ -void ff_channel_layouts_unref(AVFilterChannelLayouts **ref); +int ff_add_channel_layout(AVFilterFormats **l, uint64_t channel_layout); -void ff_channel_layouts_changeref(AVFilterChannelLayouts **oldref, - AVFilterChannelLayouts **newref); +void ff_channel_layouts_changeref(AVFilterFormats **oldref, + AVFilterFormats **newref); av_warn_unused_result int ff_default_query_formats(AVFilterContext *ctx); @@ -313,7 +289,7 @@ int ff_formats_check_sample_rates(void *log, const AVFilterFormats *fmts); * * In particular, check for duplicates. */ -int ff_formats_check_channel_layouts(void *log, const AVFilterChannelLayouts *fmts); +int ff_formats_check_channel_layouts(void *log, const AVFilterFormats *fmts); typedef struct AVFilterFormatMerger { unsigned offset; diff --git a/libavfilter/src_movie.c b/libavfilter/src_movie.c index ea5bb90255..541133880b 100644 --- a/libavfilter/src_movie.c +++ b/libavfilter/src_movie.c @@ -370,7 +370,7 @@ static int movie_query_formats(AVFilterContext *ctx) if ((ret = ff_formats_ref(ff_make_format_list(list), &outlink->incfg.samplerates)) < 0) return ret; list64[0] = c->channel_layout; - if ((ret = ff_channel_layouts_ref(ff_make_format64_list(list64), + if ((ret = ff_formats_ref(ff_make_format64_list(list64), &outlink->incfg.channel_layouts)) < 0) return ret; break; diff --git a/libavfilter/tests/filtfmts.c b/libavfilter/tests/filtfmts.c index 356f467331..57ace7a6c5 100644 --- a/libavfilter/tests/filtfmts.c +++ b/libavfilter/tests/filtfmts.c @@ -48,7 +48,7 @@ static void print_formats(AVFilterContext *filter_ctx) av_get_pix_fmt_name(fmts->formats[j])); \ } else if (filter_ctx->inout##puts[i]->type == AVMEDIA_TYPE_AUDIO) { \ AVFilterFormats *fmts; \ - AVFilterChannelLayouts *layouts; \ + AVFilterFormats *layouts; \ \ fmts = filter_ctx->inout##puts[i]->outin##cfg.formats; \ for (j = 0; j < fmts->nb_formats; j++) \ @@ -57,10 +57,10 @@ static void print_formats(AVFilterContext *filter_ctx) av_get_sample_fmt_name(fmts->formats[j])); \ \ layouts = filter_ctx->inout##puts[i]->outin##cfg.channel_layouts; \ - for (j = 0; j < layouts->nb_channel_layouts; j++) { \ + for (j = 0; j < layouts->nb_formats; j++) { \ char buf[256]; \ av_get_channel_layout_string(buf, sizeof(buf), -1, \ - layouts->channel_layouts[j]); \ + layouts->formats[j]); \ printf(#INOUT "PUT[%d] %s: chlayout:%s\n", \ i, avfilter_pad_get_name(filter_ctx->inout##put_pads, i), buf); \ } \ diff --git a/libavfilter/vaf_spectrumsynth.c b/libavfilter/vaf_spectrumsynth.c index d44d01cd33..96b0d37097 100644 --- a/libavfilter/vaf_spectrumsynth.c +++ b/libavfilter/vaf_spectrumsynth.c @@ -106,7 +106,7 @@ static int query_formats(AVFilterContext *ctx) { SpectrumSynthContext *s = ctx->priv; AVFilterFormats *formats = NULL; - AVFilterChannelLayouts *layout = NULL; + AVFilterFormats *layout = NULL; AVFilterLink *magnitude = ctx->inputs[0]; AVFilterLink *phase = ctx->inputs[1]; AVFilterLink *outlink = ctx->outputs[0]; @@ -119,7 +119,7 @@ static int query_formats(AVFilterContext *ctx) formats = ff_make_format_list(sample_fmts); if ((ret = ff_formats_ref (formats, &outlink->incfg.formats )) < 0 || (ret = ff_add_channel_layout (&layout, FF_COUNT2LAYOUT(s->channels))) < 0 || - (ret = ff_channel_layouts_ref (layout , &outlink->incfg.channel_layouts)) < 0) + (ret = ff_formats_ref (layout , &outlink->incfg.channel_layouts)) < 0) return ret; sample_rates[0] = s->sample_rate;