summaryrefslogtreecommitdiffstats
path: root/audio
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2015-05-04 23:56:27 +0200
committerwm4 <wm4@nowhere>2015-05-04 23:56:27 +0200
commit937c8e513f7b948fff0746e80ecf3d27d7007abe (patch)
tree947a375e15585d4d5b950098611cf7d9e7db560c /audio
parent548cd826c24b7f56b597785f0b83a47cbf4a0465 (diff)
downloadmpv-937c8e513f7b948fff0746e80ecf3d27d7007abe.tar.bz2
mpv-937c8e513f7b948fff0746e80ecf3d27d7007abe.tar.xz
audio: chmap: explicitly drop channels not supported by lavc
Basically as before, but avoid undefined behavior.
Diffstat (limited to 'audio')
-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;
}