summaryrefslogtreecommitdiff
path: root/libavfilter/af_aformat.c
diff options
context:
space:
mode:
Diffstat (limited to 'libavfilter/af_aformat.c')
-rw-r--r--libavfilter/af_aformat.c48
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;
}