PR #23424 opened by Rodeo
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/23424
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/23424.patch
Before the patch (sample uses channel configuration 0 and a PCE):
```bash
ffprobe -i AV_CHANNEL_LAYOUT_7POINT1_WIDE_BACK_WITH_PCE.AAC
ffprobe version N-124924-g6bfc7214d1 Copyright (c) 2007-2026 the FFmpeg
developers
built with Apple clang version 21.0.0 (clang-2100.1.1.101)
configuration: --enable-nonfree --enable-libfdk_aac
libavutil 60. 33.100 / 60. 33.100
libavcodec 62. 36.101 / 62. 36.101
libavformat 62. 19.101 / 62. 19.101
libavdevice 62. 4.100 / 62. 4.100
libavfilter 11. 17.100 / 11. 17.100
libswscale 9. 8.100 / 9. 8.100
libswresample 6. 4.100 / 6. 4.100
[aac @ 0x78d014000] Estimating duration from bitrate, this may be inaccurate
Input #0, aac, from 'AV_CHANNEL_LAYOUT_7POINT1_WIDE_BACK_WITH_PCE.AAC':
Duration: 00:00:17.13, bitrate: 89 kb/s
Stream #0:0: Audio: aac (LC), 48000 Hz, 7.1(wide), fltp, 89 kb/s
[aac @ 0x78cc68000] Assuming an incorrectly encoded 7.1 channel layout instead
of a spec-compliant 7.1(wide) layout, use -strict 1 to decode according to the
specification instead.
```
This is because:
- in ff_aac_decode_init, if there is no extradata, the initial channel
configuration is
determined purely based on the channel count (avctx->ch_layout.nb_channels)
- ff_aac_set_default_channel_config gets called, printing the warning
for any extradata-less input with 8-channels (chan_config always 7)
This is later corrected by parse_adts_frame_header, but the (incorrect) warning
has already been shown.
As far as I can tell, initializing the layout here appears optional, as
suggested by:
```C
if (ac->oc[1].m4ac.chan_config) {
```
…skipping the code:
- when nothing is found in ff_mpeg4audio_channels matching
avctx->ch_layout.nb_channels (anything
w/between 9 and 23 or between 25 and MAX_CHANNELS channels, assuming such an
AAC file exists)
My patch just removes that branch entirely; getting rid of the warning along
with it.
Warning remains for files where the actual channel configuration is 7, see e.g.
AAC-kAudioChannelLayoutTag_AAC_7_1-in-adts.aac
Tested on a bunch of AAC samples (ADTS, CAF and MP4) with `ffmpeg -v error -i
"$i" -f framecrc -` and output seems unchanged; I hope I am not missing
anything obvious (or not obvious).
From 2923e160c0ae01bc7969bfd9a04b70abf92f0654 Mon Sep 17 00:00:00 2001
From: Tim Walker <[email protected]>
Date: Wed, 10 Jun 2026 00:45:26 +0200
Subject: [PATCH] avcodec_aacdec: don't set dummy chan_config in
ff_aac_decode_init When the context has no extradata (e.g. ADTS input),
ff_aac_decode_init attempts to automatically determine m4ac.chan_config from
avctx->ch_layout.nb_channels, before parse_adts_frame_header is ever called.
As a result, 8-channel streams get chan_config == 7 regardless of
whether they actually have the corresponding layout; triggering
the wraning about "incorrectly encoded 7.1 channel layout" in
ff_aac_set_default_channel_config, before the actual channel
configuration can be determined from the ADTS header.
---
libavcodec/aac/aacdec.c | 23 +----------------------
1 file changed, 1 insertion(+), 22 deletions(-)
diff --git a/libavcodec/aac/aacdec.c b/libavcodec/aac/aacdec.c
index 7c7151362e..d36f5d085b 100644
--- a/libavcodec/aac/aacdec.c
+++ b/libavcodec/aac/aacdec.c
@@ -1315,34 +1315,13 @@ av_cold int ff_aac_decode_init(AVCodecContext *avctx)
1)) < 0)
return ret;
} else {
- int sr, i;
- uint8_t layout_map[MAX_ELEM_ID*4][3];
- int layout_map_tags;
+ int sr;
sr = ff_aac_sample_rate_idx(avctx->sample_rate);
ac->oc[1].m4ac.sampling_index = sr;
ac->oc[1].m4ac.channels = avctx->ch_layout.nb_channels;
ac->oc[1].m4ac.sbr = -1;
ac->oc[1].m4ac.ps = -1;
-
- for (i = 0; i < FF_ARRAY_ELEMS(ff_mpeg4audio_channels); i++)
- if (ff_mpeg4audio_channels[i] == avctx->ch_layout.nb_channels)
- break;
- if (i == FF_ARRAY_ELEMS(ff_mpeg4audio_channels)) {
- i = 0;
- }
- ac->oc[1].m4ac.chan_config = i;
-
- if (ac->oc[1].m4ac.chan_config) {
- ret = ff_aac_set_default_channel_config(ac, avctx, layout_map,
- &layout_map_tags,
-
ac->oc[1].m4ac.chan_config);
- if (!ret)
- ff_aac_output_configure(ac, layout_map, layout_map_tags,
- OC_GLOBAL_HDR, 0);
- else if (avctx->err_recognition & AV_EF_EXPLODE)
- return AVERROR_INVALIDDATA;
- }
}
if (avctx->ch_layout.nb_channels > MAX_CHANNELS) {
--
2.52.0
_______________________________________________
ffmpeg-devel mailing list -- [email protected]
To unsubscribe send an email to [email protected]