ffmpeg | branch: master | Simon Thelen <ffmpeg-...@c-14.de> | Sat Jun 20 18:52:50 2015 +0200| [7cbb52ecab90206eccb8cb629019d3a7816769f0] | committer: Michael Niedermayer
libavfilter/formats: Fix parsing of channel specifications with a trailing 'c'. Signed-off-by: Michael Niedermayer <michae...@gmx.at> > http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=7cbb52ecab90206eccb8cb629019d3a7816769f0 --- libavfilter/formats.c | 17 +++++++---------- tests/ref/fate/filter-formats | 10 +++++----- 2 files changed, 12 insertions(+), 15 deletions(-) diff --git a/libavfilter/formats.c b/libavfilter/formats.c index 2451bf7..8758b3d 100644 --- a/libavfilter/formats.c +++ b/libavfilter/formats.c @@ -637,23 +637,20 @@ int ff_parse_channel_layout(int64_t *ret, int *nret, const char *arg, void *log_ctx) { char *tail; - int64_t chlayout, count; + int64_t chlayout; - if (nret) { - count = strtol(arg, &tail, 10); - if (*tail == 'c' && !tail[1] && count > 0 && count < 63) { - *nret = count; - *ret = 0; - return 0; - } - } chlayout = av_get_channel_layout(arg); if (chlayout == 0) { chlayout = strtol(arg, &tail, 10); - if (*tail || chlayout == 0) { + if (!(*tail == '\0' || *tail == 'c' && *(tail + 1) == '\0') || chlayout <= 0 || chlayout > 63) { av_log(log_ctx, AV_LOG_ERROR, "Invalid channel layout '%s'\n", arg); return AVERROR(EINVAL); } + if (nret) { + *nret = chlayout; + *ret = 0; + return 0; + } } *ret = chlayout; if (nret) diff --git a/tests/ref/fate/filter-formats b/tests/ref/fate/filter-formats index 0e21416..b0377e0 100644 --- a/tests/ref/fate/filter-formats +++ b/tests/ref/fate/filter-formats @@ -69,11 +69,11 @@ quad(side) -1 = ff_parse_channel_layout(FFFFFFFFFFFFFFFF, -1, blah); 0 = ff_parse_channel_layout(0000000000000004, 1, 1); 0 = ff_parse_channel_layout(0000000000000003, 2, 2); -0 = ff_parse_channel_layout(FFFFFFFFFFFFFFFF, 64, -1); -0 = ff_parse_channel_layout(000000000000003C, 4, 60); -0 = ff_parse_channel_layout(0000000000000041, 2, 65); -0 = ff_parse_channel_layout(0000000000000000, 1, 1c); -0 = ff_parse_channel_layout(0000000000000000, 2, 2c); +-1 = ff_parse_channel_layout(FFFFFFFFFFFFFFFF, -1, -1); +0 = ff_parse_channel_layout(0000000000000000, 60, 60); +-1 = ff_parse_channel_layout(FFFFFFFFFFFFFFFF, -1, 65); +0 = ff_parse_channel_layout(0000000000000004, 1, 1c); +0 = ff_parse_channel_layout(0000000000000003, 2, 2c); -1 = ff_parse_channel_layout(FFFFFFFFFFFFFFFF, -1, -1c); 0 = ff_parse_channel_layout(0000000000000000, 60, 60c); -1 = ff_parse_channel_layout(FFFFFFFFFFFFFFFF, -1, 65c); _______________________________________________ ffmpeg-cvslog mailing list ffmpeg-cvslog@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog