aboutsummaryrefslogtreecommitdiffstats
path: root/libswresample
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2015-04-12 21:08:09 +0200
committerMichael Niedermayer <michaelni@gmx.at>2015-04-25 15:06:54 +0200
commit115961acc15c5d11b4b4b58a906580dd176da2f0 (patch)
treeb48d61dcd9dbe61f463e4d26f6c8d1f02fbdbcbd /libswresample
parent6a87a152e8340778a1320603e88566ea5be54ee3 (diff)
downloadffmpeg-115961acc15c5d11b4b4b58a906580dd176da2f0.tar.gz
swresample: Check channel layouts and channels against each other and print human readable error messages
Signed-off-by: Michael Niedermayer <michaelni@gmx.at> (cherry picked from commit 3c77bb5f23b2e149495c814759beab7eedeede6c) Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libswresample')
-rw-r--r--libswresample/swresample.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/libswresample/swresample.c b/libswresample/swresample.c
index 17082f1352..4685a8909d 100644
--- a/libswresample/swresample.c
+++ b/libswresample/swresample.c
@@ -152,6 +152,7 @@ av_cold void swr_close(SwrContext *s){
av_cold int swr_init(struct SwrContext *s){
int ret;
+ char l1[1024], l2[1024];
clear_context(s);
@@ -278,10 +279,18 @@ av_cold int swr_init(struct SwrContext *s){
return -1;
}
+ av_get_channel_layout_string(l1, sizeof(l1), s-> in.ch_count, s-> in_ch_layout);
+ av_get_channel_layout_string(l2, sizeof(l2), s->out.ch_count, s->out_ch_layout);
+ if (s->out_ch_layout && s->out.ch_count != av_get_channel_layout_nb_channels(s->out_ch_layout)) {
+ av_log(s, AV_LOG_ERROR, "Output channel layout %s mismatches specified channel count %d\n", l2, s->out.ch_count);
+ return AVERROR(EINVAL);
+ }
+ if (s->in_ch_layout && s->used_ch_count != av_get_channel_layout_nb_channels(s->in_ch_layout)) {
+ av_log(s, AV_LOG_ERROR, "Input channel layout %s mismatches specified channel count %d\n", l1, s->used_ch_count);
+ return AVERROR(EINVAL);
+ }
+
if ((!s->out_ch_layout || !s->in_ch_layout) && s->used_ch_count != s->out.ch_count && !s->rematrix_custom) {
- char l1[1024], l2[1024];
- av_get_channel_layout_string(l1, sizeof(l1), s-> in.ch_count, s-> in_ch_layout);
- av_get_channel_layout_string(l2, sizeof(l2), s->out.ch_count, s->out_ch_layout);
av_log(s, AV_LOG_ERROR, "Rematrix is needed between %s and %s "
"but there is not enough information to do it\n", l1, l2);
return -1;