summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2015-05-04 23:56:27 +0200
committerDiogo Franco (Kovensky) <diogomfranco@gmail.com>2015-05-07 10:46:48 +0900
commit6bcb8d200f28d69158792caa6a10c96fd8be4a5b (patch)
tree1fa73f8d8b78ec4023cc4023ede1ca8b0bba4125
parentd9c42ff9ff01dd1100db816412d5df044bc38a6c (diff)
downloadmpv-6bcb8d200f28d69158792caa6a10c96fd8be4a5b.tar.bz2
mpv-6bcb8d200f28d69158792caa6a10c96fd8be4a5b.tar.xz
audio: chmap: explicitly drop channels not supported by lavc
Basically as before, but avoid undefined behavior. (cherry picked from commit 937c8e513f7b948fff0746e80ecf3d27d7007abe)
-rw-r--r--audio/chmap.c7
1 files 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 <libavutil/channel_layout.h>.
+// 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;
}