diff options
author | James Almer <jamrial@gmail.com> | 2021-08-31 11:03:14 -0300 |
---|---|---|
committer | James Almer <jamrial@gmail.com> | 2022-03-15 09:42:46 -0300 |
commit | 1f96db959c1235bb7079d354e09914a0a2608f62 (patch) | |
tree | 21ac480d5b148c0524761853e6badb3a90a7ca3f /libavfilter/af_aformat.c | |
parent | 8a5896ec1f635ccf0d726f7ba7a06649ebeebf25 (diff) |
avfilter: convert to new channel layout API
Signed-off-by: James Almer <jamrial@gmail.com>
Diffstat (limited to 'libavfilter/af_aformat.c')
-rw-r--r-- | libavfilter/af_aformat.c | 48 |
1 files changed, 45 insertions, 3 deletions
diff --git a/libavfilter/af_aformat.c b/libavfilter/af_aformat.c index d2599431dc..a14e4c1240 100644 --- a/libavfilter/af_aformat.c +++ b/libavfilter/af_aformat.c @@ -89,17 +89,59 @@ static int get_sample_rate(const char *samplerate) 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) { +#if FF_API_OLD_CHANNEL_LAYOUT + uint64_t mask; +FF_DISABLE_DEPRECATION_WARNINGS + mask = av_get_channel_layout(cur); + if (!mask) { +#endif + av_log(ctx, AV_LOG_ERROR, "Error parsing channel layout: %s.\n", cur); + return AVERROR(EINVAL); +#if FF_API_OLD_CHANNEL_LAYOUT + } +FF_ENABLE_DEPRECATION_WARNINGS + av_log(ctx, AV_LOG_WARNING, "Channel layout '%s' uses a deprecated syntax.\n", + cur); + av_channel_layout_from_mask(&fmt, mask); +#endif + } + 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"); - PARSE_FORMATS(s->channel_layouts_str, uint64_t, s->channel_layouts, - ff_add_channel_layout, av_get_channel_layout, 0, - "channel layout"); + ret = parse_channel_layouts(ctx); + if (ret < 0) + return ret; return 0; } |