aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarton Balint <cus@passwd.hu>2024-01-29 20:15:28 +0100
committerMarton Balint <cus@passwd.hu>2024-02-09 23:47:24 +0100
commitdc9d64f7941f5b071283e16fa56e3af86e5c84d6 (patch)
tree6b30370c5486a68ad2b91d9d6bf8b5ce2eb8cfd7
parent3d3cad7483785191b99557c78d5a4a551088c549 (diff)
downloadffmpeg-dc9d64f7941f5b071283e16fa56e3af86e5c84d6.tar.gz
avformat/mov_chan: never override number of channels based on chan atom
The channel designation metadata should not override the number of channels. Let's warn the user if it is inconsistent, and keep the channel layout unspecified. Before the conversion to the channel layout API the code only set the mask, but never overridden the channel count, so this restores the old behaviour. Signed-off-by: Marton Balint <cus@passwd.hu>
-rw-r--r--libavformat/mov_chan.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/libavformat/mov_chan.c b/libavformat/mov_chan.c
index 5cb2de3820..6b206745b4 100644
--- a/libavformat/mov_chan.c
+++ b/libavformat/mov_chan.c
@@ -544,8 +544,13 @@ int ff_mov_read_chan(AVFormatContext *s, AVIOContext *pb, AVStream *st,
mask = mov_get_channel_layout(layout_tag, bitmap);
if (mask) {
- av_channel_layout_uninit(&st->codecpar->ch_layout);
- av_channel_layout_from_mask(&st->codecpar->ch_layout, mask);
+ if (!st->codecpar->ch_layout.nb_channels || av_popcount64(mask) == st->codecpar->ch_layout.nb_channels) {
+ av_channel_layout_uninit(&st->codecpar->ch_layout);
+ av_channel_layout_from_mask(&st->codecpar->ch_layout, mask);
+ } else {
+ av_log(s, AV_LOG_WARNING, "ignoring channel layout with %d channels because the real number of channels is %d\n",
+ av_popcount64(mask), st->codecpar->ch_layout.nb_channels);
+ }
}
avio_skip(pb, size - 12);