This is an automated email from the git hooks/post-receive script.

Git pushed a commit to branch master
in repository ffmpeg.

commit c591ddd453c77e2387d1c67d640d9e9b96ed70f8
Author:     Tim Walker <[email protected]>
AuthorDate: Thu May 21 17:44:31 2026 +0200
Commit:     James Almer <[email protected]>
CommitDate: Thu May 28 03:22:29 2026 +0000

    avformat/movenc: don't write a 'chan' atom with an incorrect channel bitmap 
or description.
---
 libavformat/mov_chan.c | 23 ++++++++++++++++++-----
 libavformat/movenc.c   |  5 +++++
 2 files changed, 23 insertions(+), 5 deletions(-)

diff --git a/libavformat/mov_chan.c b/libavformat/mov_chan.c
index 767665d356..e45b58af24 100644
--- a/libavformat/mov_chan.c
+++ b/libavformat/mov_chan.c
@@ -499,11 +499,24 @@ int ff_mov_get_channel_layout_tag(const AVCodecParameters 
*par,
     /* if no tag was found, use channel bitmap or description as a backup if 
possible */
     if (tag == 0) {
         uint32_t *channel_desc;
-        if (par->ch_layout.order == AV_CHANNEL_ORDER_NATIVE &&
-            par->ch_layout.u.mask < 0x40000) {
-            *layout = MOV_CH_LAYOUT_USE_BITMAP;
-            *bitmap = (uint32_t)par->ch_layout.u.mask;
-            return 0;
+
+        if (par->ch_layout.order == AV_CHANNEL_ORDER_NATIVE) {
+            /* Parsers and encoders (e.g. AC3, AAC, ALAC) indicate/propagate 
the bitstream's
+             * channel configuration using "standard" layouts in 
AV_CHANNEL_ORDER_NATIVE but
+             * the encoded bitstream's channels are not actually in that 
order. Don't return
+             * a channel layout bitmap or description using a conflicting 
channel order, as
+             * some software will incorrectly override the bitstream-provided 
information
+             * using the chan atom's data instead (e.g. afinfo/afplay for AAC 
in MOV) */
+            if (layouts != mov_ch_layouts_wav) {
+                *layout = MOV_CH_LAYOUT_UNKNOWN;
+                return 0;
+            }
+
+            if (par->ch_layout.u.mask < 0x40000) {
+                *layout = MOV_CH_LAYOUT_USE_BITMAP;
+                *bitmap = (uint32_t)par->ch_layout.u.mask;
+                return 0;
+            }
         } else if (par->ch_layout.order == AV_CHANNEL_ORDER_UNSPEC)
             return AVERROR(ENOSYS);
 
diff --git a/libavformat/movenc.c b/libavformat/movenc.c
index 46d24bb967..7aa3f508c7 100644
--- a/libavformat/movenc.c
+++ b/libavformat/movenc.c
@@ -1017,6 +1017,11 @@ static int mov_write_chan_tag(AVFormatContext *s, 
AVIOContext *pb, MOVTrack *tra
         return ret;
     }
 
+    /* no predefined tag found + ch_layout in AV_CHANNEL_ORDER_NATIVE
+     * but bitstream channels not actually in native order */
+    if (layout_tag == MOV_CH_LAYOUT_UNKNOWN)
+        return 0;
+
     if (layout_tag == MOV_CH_LAYOUT_MONO && track->mono_as_fc > 0) {
         av_assert0(!channel_desc);
         channel_desc = av_malloc(sizeof(*channel_desc));

_______________________________________________
ffmpeg-cvslog mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to