[FFmpeg-cvslog] lavfi/asrc_flite: convert to query_func2()
Anton Khirnov
git at videolan.org
Sat Sep 28 10:59:21 EEST 2024
ffmpeg | branch: master | Anton Khirnov <anton at khirnov.net> | Mon Sep 9 17:29:04 2024 +0200| [21d2be108834553511c3fa4395b813bbfafb8466] | committer: Anton Khirnov
lavfi/asrc_flite: convert to query_func2()
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=21d2be108834553511c3fa4395b813bbfafb8466
---
libavfilter/asrc_flite.c | 39 +++++++++++++++++++++++++--------------
1 file changed, 25 insertions(+), 14 deletions(-)
diff --git a/libavfilter/asrc_flite.c b/libavfilter/asrc_flite.c
index 5962bf55bb..1bbd329177 100644
--- a/libavfilter/asrc_flite.c
+++ b/libavfilter/asrc_flite.c
@@ -255,24 +255,35 @@ static av_cold void uninit(AVFilterContext *ctx)
av_audio_fifo_free(flite->fifo);
}
-static int query_formats(AVFilterContext *ctx)
+static int query_formats(const AVFilterContext *ctx,
+ AVFilterFormatsConfig **cfg_in,
+ AVFilterFormatsConfig **cfg_out)
{
- FliteContext *flite = ctx->priv;
+ const FliteContext *flite = ctx->priv;
+
+ static const enum AVSampleFormat formats[] = {
+ AV_SAMPLE_FMT_S16,
+ AV_SAMPLE_FMT_NONE,
+ };
+ int sample_rates[] = { flite->sample_rate, -1 };
+ AVChannelLayout layouts[2] = {
+ { .nb_channels = 0 },
+ };
+
int ret;
- AVFilterChannelLayouts *chlayouts = NULL;
- AVFilterFormats *sample_formats = NULL;
- AVFilterFormats *sample_rates = NULL;
- AVChannelLayout chlayout = { 0 };
+ av_channel_layout_default(&layouts[0], flite->nb_channels);
- av_channel_layout_default(&chlayout, flite->nb_channels);
+ ret = ff_set_common_channel_layouts_from_list2(ctx, cfg_in, cfg_out, layouts);
+ if (ret < 0)
+ return ret;
+
+ ret = ff_set_common_formats_from_list2(ctx, cfg_in, cfg_out, formats);
+ if (ret < 0)
+ return ret;
- if ((ret = ff_add_channel_layout (&chlayouts , &chlayout )) < 0 ||
- (ret = ff_set_common_channel_layouts (ctx , chlayouts )) < 0 ||
- (ret = ff_add_format (&sample_formats, AV_SAMPLE_FMT_S16 )) < 0 ||
- (ret = ff_set_common_formats (ctx , sample_formats )) < 0 ||
- (ret = ff_add_format (&sample_rates , flite->sample_rate )) < 0 ||
- (ret = ff_set_common_samplerates (ctx , sample_rates )) < 0)
+ ret = ff_set_common_samplerates_from_list2(ctx, cfg_in, cfg_out, sample_rates);
+ if (ret < 0)
return ret;
return 0;
@@ -348,6 +359,6 @@ const AVFilter ff_asrc_flite = {
.activate = activate,
.inputs = NULL,
FILTER_OUTPUTS(flite_outputs),
- FILTER_QUERY_FUNC(query_formats),
+ FILTER_QUERY_FUNC2(query_formats),
.priv_class = &flite_class,
};
More information about the ffmpeg-cvslog
mailing list