From 93699123b46f7aac2f4b9fbf579e3214c56088eb Mon Sep 17 00:00:00 2001 From: "Jan Alexander Steffens (heftig)" Date: Tue, 30 May 2023 15:10:11 +0200 Subject: [PATCH] isomp4: Fix (E)AC-3 channel count handling The muxer used a fixed value of 2 channels because the TR 102 366 spec says they're to be ignored. However, the demuxer still trusted them, resulting in bad caps. Make the muxer fill in the correct channel count anyway (FFmpeg already does) and make the demuxer ignore the value. Part-of: --- subprojects/gst-plugins-good/gst/isomp4/gstqtmux.c | 6 +++--- subprojects/gst-plugins-good/gst/isomp4/qtdemux.c | 10 ++++++++++ 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/subprojects/gst-plugins-good/gst/isomp4/gstqtmux.c b/subprojects/gst-plugins-good/gst/isomp4/gstqtmux.c index 488d597ee2..517f1fd4de 100644 --- a/subprojects/gst-plugins-good/gst/isomp4/gstqtmux.c +++ b/subprojects/gst-plugins-good/gst/isomp4/gstqtmux.c @@ -6087,9 +6087,9 @@ gst_qt_mux_audio_sink_set_caps (GstQTMuxPad * qtpad, GstCaps * caps) } else if (strcmp (mimetype, "audio/x-ac3") == 0) { entry.fourcc = FOURCC_ac_3; - /* Fixed values according to TS 102 366 but it also mentions that - * they should be ignored */ - entry.channels = 2; + /* TS 102 366 mentions that these fields should be ignored, + * but be friendly and fill in the channel count like FFmpeg does */ + entry.channels = channels; entry.sample_size = 16; /* AC-3 needs an extension atom but its data can only be obtained from diff --git a/subprojects/gst-plugins-good/gst/isomp4/qtdemux.c b/subprojects/gst-plugins-good/gst/isomp4/qtdemux.c index c7543b6ef4..8da64c9c8c 100644 --- a/subprojects/gst-plugins-good/gst/isomp4/qtdemux.c +++ b/subprojects/gst-plugins-good/gst/isomp4/qtdemux.c @@ -13205,6 +13205,16 @@ qtdemux_parse_trak (GstQTDemux * qtdemux, GNode * trak) entry->bytes_per_packet = entry->bytes_per_sample; break; } + + /* According to TS 102 366, the channel count in + * a (E)AC3SampleEntry box is to be ignored */ + case 0x20736d: + case GST_MAKE_FOURCC ('e', 'c', '-', '3'): + case GST_MAKE_FOURCC ('s', 'a', 'c', '3'): // Nero Recode + case FOURCC_ac_3: + entry->n_channels = 0; + break; + default: break; }