summaryrefslogtreecommitdiff
path: root/libavfilter/formats.c
diff options
context:
space:
mode:
authorMarton Balint <cus@passwd.hu>2016-12-26 02:03:37 +0100
committerMarton Balint <cus@passwd.hu>2017-01-24 23:51:36 +0100
commit977fd8841921f0109bee220e1f99dd662c166ae1 (patch)
treea16f626ad67336bb9437f4d581f8658b894382f9 /libavfilter/formats.c
parentc4618f842a2de85097627763f02931afc3fde6d9 (diff)
downloadffmpeg-977fd8841921f0109bee220e1f99dd662c166ae1.tar.gz
avfilter/formats: do not allow unknown layouts in ff_parse_channel_layout if nret is not set
Current code returned the number of channels as channel layout in that case, and if nret is not set then unknown layouts are typically not supported. Also use the common parsing code. Use a temporary workaround to parse an unknown channel layout such as '13c', after a 1 year grace period only '13C' will work. Signed-off-by: Marton Balint <cus@passwd.hu>
Diffstat (limited to 'libavfilter/formats.c')
-rw-r--r--libavfilter/formats.c26
1 files changed, 15 insertions, 11 deletions
diff --git a/libavfilter/formats.c b/libavfilter/formats.c
index 840780d562..d4de862237 100644
--- a/libavfilter/formats.c
+++ b/libavfilter/formats.c
@@ -664,22 +664,26 @@ int ff_parse_channel_layout(int64_t *ret, int *nret, const char *arg,
{
char *tail;
int64_t chlayout;
-
- chlayout = av_get_channel_layout(arg);
- if (chlayout == 0) {
- chlayout = strtol(arg, &tail, 10);
- if (!(*tail == '\0' || *tail == 'c' && *(tail + 1) == '\0') || chlayout <= 0 || chlayout > 63) {
+ int nb_channels;
+
+ if (av_get_extended_channel_layout(arg, &chlayout, &nb_channels) < 0) {
+ /* [TEMPORARY 2016-12 -> 2017-12]*/
+ nb_channels = strtol(arg, &tail, 10);
+ if (!errno && *tail == 'c' && *(tail + 1) == '\0' && nb_channels > 0 && nb_channels < 64) {
+ chlayout = 0;
+ av_log(log_ctx, AV_LOG_WARNING, "Deprecated channel count specification '%s'. This will stop working in releases made in 2018 and after.\n", arg);
+ } else {
av_log(log_ctx, AV_LOG_ERROR, "Invalid channel layout '%s'\n", arg);
return AVERROR(EINVAL);
}
- if (nret) {
- *nret = chlayout;
- *ret = 0;
- return 0;
- }
+ }
+ if (!chlayout && !nret) {
+ av_log(log_ctx, AV_LOG_ERROR, "Unknown channel layout '%s' is not supported.\n", arg);
+ return AVERROR(EINVAL);
}
*ret = chlayout;
if (nret)
- *nret = av_get_channel_layout_nb_channels(chlayout);
+ *nret = nb_channels;
+
return 0;
}