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 486f03997c avcodec/aacenc: add option to allow encoding non-PCE 
7.1(wide)
486f03997c is described below

commit 486f03997ce4b4ecf61aba0ec14b3aa61f39fc02
Author:     Niklas Haas <[email protected]>
AuthorDate: Tue Jun 9 17:13:27 2026 +0200
Commit:     Niklas Haas <[email protected]>
CommitDate: Mon Aug 31 19:22:59 2026 +0200

    avcodec/aacenc: add option to allow encoding non-PCE 7.1(wide)
    
    PCE is not compatible with all downstream sources. Some browsers, for 
example,
    will refuse to play an AAC file with a PCE channel layout. So there is a
    legitimate use case for encoding non-PCE files if required.
    
    However, due to the historical work-around where FFmpeg produced out-of-spec
    files that mislabelled 7.1 as 7.1(wide), we should gate this behind a new
    option.
    
    I considered tying it to -strict 1 (which also disables the equivalent
    work-around in aacdec), but this may lead to users unknowingly opting into
    this behavior due to enabling -strict 1 out of habit (or for other reasons).
    
    This way, a user who really knows what they're doing can use
    -af aformat=channel_layouts=7.1(wide) -aac_allow_71wide yes to force
    producing a spec-compliant non-PCE AAC file.
    
    I decided to keep the option undocumented for now, matching the existing
    `aac_pce` option (also undocumented).
    
    The channel IDs were taken by comparing the AAC bitstream channel order:
     FC, FLC, FRC, FL, FR, BL, BR, LFE
    
    Aginst the FFmpeg channel order for 7POINT1_WIDE_BACK:
     0=FL 1=FR 2=FC 3=LFE 4=BL 5=BR 6=FLC 7=FRC
    
    This gives us {2, 6, 7, 0, 1, 4, 5, 3}.
    
    Sponsored-by: nxtedition AB
    Signed-off-by: Niklas Haas <[email protected]>
---
 libavcodec/aacenc.c    | 15 +++++++++++++++
 libavcodec/aacenc.h    |  1 +
 libavcodec/aacenctab.h |  6 +++---
 3 files changed, 19 insertions(+), 3 deletions(-)

diff --git a/libavcodec/aacenc.c b/libavcodec/aacenc.c
index df54149631..33a16cd92a 100644
--- a/libavcodec/aacenc.c
+++ b/libavcodec/aacenc.c
@@ -1750,6 +1750,20 @@ static av_cold int aac_encode_init(AVCodecContext *avctx)
         }
     }
 
+    if (!s->needs_pce && chcfg == 7 /* 7.1(wide) */ && 
!s->options.allow_71wide) {
+        /**
+         * FFmpeg used to produce out-of-spec AAC files that mistagged 7.1
+         * as 7.1(wide), and this wark-around is still enabled by default in
+         * aacdec.c, so avoid producing such files in the rare case that the
+         * user correctly passed 7.1(wide) channel layout content.
+         */
+        av_log(avctx, AV_LOG_INFO, "Forcing the use of PCE to encode 7.1(wide) 
"
+               "channel layout to avoid ambiguity. Set -aac_allow_71wide 1 to "
+               "override this behavior and force the use of spec-compliant "
+               "channel configuration ID.\n");
+        s->needs_pce = 1;
+    }
+
     if (s->needs_pce) {
         char buf[64];
         for (i = 0; i < FF_ARRAY_ELEMS(aac_pce_configs); i++)
@@ -1896,6 +1910,7 @@ static const AVOption aacenc_options[] = {
     {"aac_tns", "Temporal noise shaping", offsetof(AACEncContext, 
options.tns), AV_OPT_TYPE_BOOL, {.i64 = 1}, -1, 1, AACENC_FLAGS},
     {"aac_pce", "Forces the use of PCEs", offsetof(AACEncContext, 
options.pce), AV_OPT_TYPE_BOOL, {.i64 = 0}, -1, 1, AACENC_FLAGS},
     {"aac_nmr_speed", "NMR coder speed level: 0 = slowest/best, higher trades 
quality for speed", offsetof(AACEncContext, options.nmr_speed), 
AV_OPT_TYPE_INT, {.i64 = 0}, 0, 4, AACENC_FLAGS},
+    {"aac_allow_71wide", "Allow non-PCE use of 7.1(wide) channel layout", 
offsetof(AACEncContext, options.allow_71wide), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 
1, AACENC_FLAGS},
     FF_AAC_PROFILE_OPTS
     {NULL}
 };
diff --git a/libavcodec/aacenc.h b/libavcodec/aacenc.h
index 1ad2b7bc96..a59c9458eb 100644
--- a/libavcodec/aacenc.h
+++ b/libavcodec/aacenc.h
@@ -71,6 +71,7 @@ typedef struct AACEncOptions {
     int mid_side;
     int intensity_stereo;
     int nmr_speed;          ///< NMR coder speed level: 0 = slowest/best, 
higher is faster
+    int allow_71wide;
 } AACEncOptions;
 
 /**
diff --git a/libavcodec/aacenctab.h b/libavcodec/aacenctab.h
index addab63885..12e646ad08 100644
--- a/libavcodec/aacenctab.h
+++ b/libavcodec/aacenctab.h
@@ -52,7 +52,7 @@ static const AVChannelLayout aac_normal_chan_layouts[15] = {
     AV_CHANNEL_LAYOUT_4POINT0,
     AV_CHANNEL_LAYOUT_5POINT0_BACK,
     AV_CHANNEL_LAYOUT_5POINT1_BACK,
-    { 0 }, // AV_CHANNEL_LAYOUT_7POINT1_WIDE_BACK, disabled in favor or PCE 
configuration
+    AV_CHANNEL_LAYOUT_7POINT1_WIDE_BACK,
     { 0 },
     { 0 },
     { 0 },
@@ -70,7 +70,7 @@ static const uint8_t aac_chan_configs[14][6] = {
     {3, TYPE_SCE, TYPE_CPE, TYPE_SCE},                     // 4 channels - 
front center + stereo + back center
     {3, TYPE_SCE, TYPE_CPE, TYPE_CPE},                     // 5 channels - 
front center + stereo + back stereo
     {4, TYPE_SCE, TYPE_CPE, TYPE_CPE, TYPE_LFE},           // 6 channels - 
front center + stereo + back stereo + LFE
-    {0},
+    {5, TYPE_SCE, TYPE_CPE, TYPE_CPE, TYPE_CPE, TYPE_LFE}, // 8 channels - 
front center + front center stereo + front stereo + back stereo + LFE
     {0},
     {0},
     {0},
@@ -90,7 +90,7 @@ static const uint8_t aac_chan_maps[14][AAC_MAX_CHANNELS] = {
     { 2, 0, 1, 3 },
     { 2, 0, 1, 3, 4 },
     { 2, 0, 1, 4, 5, 3 },
-    { 0 },
+    { 2, 6, 7, 0, 1, 4, 5, 3 },
     { 0 },
     { 0 },
     { 0 },

-- 
To stop receiving notification emails like this one, please contact
[email protected].
_______________________________________________
ffmpeg-cvslog mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to