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

Git pushed a commit to branch master
in repository ffmpeg.

The following commit(s) were added to refs/heads/master by this push:
     new c65c8f1f49 avcodec/dcadec: output a custom channel layout when 
requesting coded channel ordering
c65c8f1f49 is described below

commit c65c8f1f49580bd352c7a191e295a1c94028a919
Author:     James Almer <[email protected]>
AuthorDate: Wed May 27 11:43:01 2026 -0300
Commit:     James Almer <[email protected]>
CommitDate: Sat May 30 22:37:09 2026 -0300

    avcodec/dcadec: output a custom channel layout when requesting coded 
channel ordering
    
    Outputting an UNSPEC layout will make most callers guess the speaker 
layout, and
    more likely than not get it wrong.
    Now that we can freely export custom order layouts, lets use them.
    
    Signed-off-by: James Almer <[email protected]>
---
 libavcodec/dcadec.c          | 24 ++++++++++++++++--------
 tests/fate/dca.mak           |  3 +++
 tests/ref/fate/dca-xll-coded |  1 +
 3 files changed, 20 insertions(+), 8 deletions(-)

diff --git a/libavcodec/dcadec.c b/libavcodec/dcadec.c
index 0d7bf1c53c..f47a694746 100644
--- a/libavcodec/dcadec.c
+++ b/libavcodec/dcadec.c
@@ -47,23 +47,31 @@ int ff_dca_set_channel_layout(AVCodecContext *avctx, int 
*ch_remap, int dca_mask
     DCAContext *s = avctx->priv_data;
 
     int dca_ch, wav_ch, nchannels = 0;
+    const uint8_t *dca2wav;
+
+    if (dca_mask == DCA_SPEAKER_LAYOUT_7POINT0_WIDE ||
+        dca_mask == DCA_SPEAKER_LAYOUT_7POINT1_WIDE)
+        dca2wav = dca2wav_wide;
+    else
+        dca2wav = dca2wav_norm;
 
     av_channel_layout_uninit(&avctx->ch_layout);
     if (s->output_channel_order == CHANNEL_ORDER_CODED) {
+        int ret;
         for (dca_ch = 0; dca_ch < DCA_SPEAKER_COUNT; dca_ch++)
             if (dca_mask & (1U << dca_ch))
                 ch_remap[nchannels++] = dca_ch;
-        avctx->ch_layout.order       = AV_CHANNEL_ORDER_UNSPEC;
-        avctx->ch_layout.nb_channels = nchannels;
+        ret = av_channel_layout_custom_init(&avctx->ch_layout, nchannels);
+        if (ret < 0)
+            return ret;
+
+        nchannels = 0;
+        for (dca_ch = 0; dca_ch < DCA_SPEAKER_COUNT; dca_ch++)
+            if (dca_mask & (1U << dca_ch))
+                avctx->ch_layout.u.map[nchannels++].id = dca2wav[dca_ch];
     } else {
         int wav_mask = 0;
         int wav_map[18];
-        const uint8_t *dca2wav;
-        if (dca_mask == DCA_SPEAKER_LAYOUT_7POINT0_WIDE ||
-            dca_mask == DCA_SPEAKER_LAYOUT_7POINT1_WIDE)
-            dca2wav = dca2wav_wide;
-        else
-            dca2wav = dca2wav_norm;
         for (dca_ch = 0; dca_ch < 28; dca_ch++) {
             if (dca_mask & (1 << dca_ch)) {
                 wav_ch = dca2wav[dca_ch];
diff --git a/tests/fate/dca.mak b/tests/fate/dca.mak
index c36f4fa918..609f924aa3 100644
--- a/tests/fate/dca.mak
+++ b/tests/fate/dca.mak
@@ -73,6 +73,9 @@ fate-dca-core: REF = $(SAMPLES)/dts/dts.pcm
 FATE_DCA-$(call DEMDEC, DTS, DCA, ARESAMPLE_FILTER PCM_S24LE_ENCODER 
PCM_S24LE_MUXER) += fate-dca-xll
 fate-dca-xll: CMD = md5 -i $(TARGET_SAMPLES)/dts/master_audio_7.1_24bit.dts -f 
s24le -af aresample
 
+FATE_DCA-$(call DEMDEC, DTS, DCA, ARESAMPLE_FILTER PCM_S24LE_ENCODER 
PCM_S24LE_MUXER) += fate-dca-xll-coded
+fate-dca-xll-coded: CMD = md5 -channel_order coded -i 
$(TARGET_SAMPLES)/dts/master_audio_7.1_24bit.dts -f s24le -af aresample
+
 FATE_DCA-$(call PCM, DTS, DCA, ARESAMPLE_FILTER) += fate-dts_es
 fate-dts_es: CMD = pcm -i $(TARGET_SAMPLES)/dts/dts_es.dts
 fate-dts_es: CMP = oneoff
diff --git a/tests/ref/fate/dca-xll-coded b/tests/ref/fate/dca-xll-coded
new file mode 100644
index 0000000000..42e17da0d7
--- /dev/null
+++ b/tests/ref/fate/dca-xll-coded
@@ -0,0 +1 @@
+0ae67d520a46776046ab5ab7d1c6a387

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

Reply via email to