From 6bcb8d200f28d69158792caa6a10c96fd8be4a5b Mon Sep 17 00:00:00 2001 From: wm4 Date: Mon, 4 May 2015 23:56:27 +0200 Subject: audio: chmap: explicitly drop channels not supported by lavc Basically as before, but avoid undefined behavior. (cherry picked from commit 937c8e513f7b948fff0746e80ecf3d27d7007abe) --- audio/chmap.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/audio/chmap.c b/audio/chmap.c index 10ae80bd1b..aec6a9aa05 100644 --- a/audio/chmap.c +++ b/audio/chmap.c @@ -268,6 +268,7 @@ void mp_chmap_remove_useless_channels(struct mp_chmap *map, } // Return the ffmpeg/libav channel layout as in . +// Speakers not representable by ffmpeg/libav are dropped. // Warning: this ignores the order of the channels, and will return a channel // mask even if the order is different from libavcodec's. uint64_t mp_chmap_to_lavc_unchecked(const struct mp_chmap *src) @@ -277,8 +278,10 @@ uint64_t mp_chmap_to_lavc_unchecked(const struct mp_chmap *src) if (mp_chmap_is_unknown(&t)) mp_chmap_from_channels(&t, t.num); uint64_t mask = 0; - for (int n = 0; n < t.num; n++) - mask |= 1ULL << t.speaker[n]; + for (int n = 0; n < t.num; n++) { + if (t.speaker[n] < 64) + mask |= 1ULL << t.speaker[n]; + } return mask; } -- cgit v1.2.3