PR #23252 opened by James Almer (jamrial) URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/23252 Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/23252.patch
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. >From 897a6eed0dd2f044d9a62953c968c853b529b5a2 Mon Sep 17 00:00:00 2001 From: James Almer <[email protected]> Date: Wed, 27 May 2026 11:43:01 -0300 Subject: [PATCH] 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 ++++++++++++++++-------- 1 file changed, 16 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]; -- 2.52.0 _______________________________________________ ffmpeg-devel mailing list -- [email protected] To unsubscribe send an email to [email protected]
