PR #24532 opened by StaZhu
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/24532
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/24532.patch

## Summary of changes

The MOV demuxer currently reads only the mandatory five bytes of the
`dec3` atom in `mov_read_dec3()`. Any remaining bytes, including optional
E-AC-3 JOC signaling, are skipped by the MOV atom parser and are not
exposed to callers.

This change:

- preserves the complete `EC3SpecificBox` payload in
  `AVCodecParameters.extradata`;
- keeps the existing parsing of `bsmod`, `acmod`, and `lfeon` for channel
  layout and audio service metadata;
- allows callers to pass the complete `dec3` configuration to platform
  decoders without parsing E-AC-3 packets in the caller.

This is required by Chromium's AVFoundation passthrough path, which forwards
the codec extradata to the platform decoder for E-AC-3 JOC / Dolby Atmos
playback.

This patch does not implement an E-AC-3 or JOC decoder itself; it preserves
the signaling required by platform decoders.

The existing channel layout and audio service metadata behavior is
unchanged.

## Testing

- Built FFmpeg successfully on macOS.
- Verified with a local E-AC-3 JOC MP4 that the complete `dec3` payload is
  exported as codec extradata.


>From 6773573f6598c0cebf11d4a6a621510d476a3daa Mon Sep 17 00:00:00 2001
From: Sida Zhu <[email protected]>
Date: Wed, 16 Sep 2026 14:35:55 +0800
Subject: [PATCH] avformat/mov: export dec3 payload as extradata

The optional EC3SpecificBox extensions carry E-AC-3 JOC signaling.
Preserve the complete dec3 payload in codec extradata so callers can
pass it to platform decoders without parsing E-AC-3 packets.

Keep parsing the mandatory fields for channel layout and audio service
metadata.

Signed-off-by: Sida Zhu <[email protected]>
---
 libavformat/mov.c | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/libavformat/mov.c b/libavformat/mov.c
index 59361cd30d..8d2a1206e5 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -1131,11 +1131,20 @@ static int mov_read_dec3(MOVContext *c, AVIOContext 
*pb, MOVAtom atom)
     enum AVAudioServiceType *ast;
     int eac3info, acmod, lfeon, bsmod;
     uint64_t mask;
+    int ret;
 
     if (c->fc->nb_streams < 1)
         return 0;
     st = c->fc->streams[c->fc->nb_streams-1];
 
+    /* Preserve the complete EC3SpecificBox payload, including optional
+     * extensions such as E-AC-3 JOC signaling. */
+    if (atom.size < 5 || (uint64_t)atom.size > (1 << 30))
+        return AVERROR_INVALIDDATA;
+    ret = ff_get_extradata(c->fc, st->codecpar, pb, atom.size);
+    if (ret < 0)
+        return ret;
+
     sd = av_packet_side_data_new(&st->codecpar->coded_side_data,
                                  &st->codecpar->nb_coded_side_data,
                                  AV_PKT_DATA_AUDIO_SERVICE_TYPE,
@@ -1145,11 +1154,7 @@ static int mov_read_dec3(MOVContext *c, AVIOContext *pb, 
MOVAtom atom)
 
     ast = (enum AVAudioServiceType*)sd->data;
 
-    /* No need to parse fields for additional independent substreams and its
-     * associated dependent substreams since libavcodec's E-AC-3 decoder
-     * does not support them yet. */
-    avio_rb16(pb); /* data_rate and num_ind_sub */
-    eac3info = avio_rb24(pb);
+    eac3info = AV_RB24(st->codecpar->extradata + 2);
     bsmod = (eac3info >> 12) & 0x1f;
     acmod = (eac3info >>  9) & 0x7;
     lfeon = (eac3info >>  8) & 0x1;
-- 
2.52.0

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

Reply via email to