PR #24875 opened by James Almer (jamrial)
URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/24875
Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/24875.patch


>From fe73e7cce40f756a3d301de1c05a4c147f31d1e1 Mon Sep 17 00:00:00 2001
From: James Almer <[email protected]>
Date: Sun, 4 Oct 2026 01:09:24 -0300
Subject: [PATCH] avcodec/aacenc: add support for 5.1.6 and 7.1.6 layouts using
 PCE

Signed-off-by: James Almer <[email protected]>
---
 libavcodec/aacenc.c             | 32 ++++++++++++++++++++++++++++++++
 tests/fate/aac.mak              | 16 ++++++++++++++++
 tests/ref/fate/aac-encode-5_1_6 |  4 ++++
 tests/ref/fate/aac-encode-7_1_6 |  4 ++++
 4 files changed, 56 insertions(+)
 create mode 100644 tests/ref/fate/aac-encode-5_1_6
 create mode 100644 tests/ref/fate/aac-encode-7_1_6

diff --git a/libavcodec/aacenc.c b/libavcodec/aacenc.c
index 3b7dce27f6..c8b8e1e265 100644
--- a/libavcodec/aacenc.c
+++ b/libavcodec/aacenc.c
@@ -356,6 +356,29 @@ static const AACPCEInfo aac_pce_configs[] = {
         .config_map = { 7, TYPE_SCE, TYPE_CPE, TYPE_CPE, TYPE_LFE, TYPE_CPE, 
TYPE_CPE, TYPE_SCE },
         .reorder_map = { 2, 0, 1, 4, 5, 3, 6, 7, 8, 9, 10 },
     },
+    {
+        .layout = AV_CHANNEL_LAYOUT_5POINT1POINT6,
+        .num_ele = { 4, 1, 2, 1 },
+        .pairing = { { 0, 1, 0, 1 }, { 0 }, { 1, 1 }, },
+        .index = { { 0, 0, 1, 2 }, { 2 }, { 1, 3 }, { 0 }, },
+        .height = { { 0, 0, 1, 1 }, { 1 }, { 0, 1 } },
+        .config_map = { 8, TYPE_SCE, TYPE_CPE, TYPE_CPE, TYPE_LFE, TYPE_SCE, 
TYPE_CPE, TYPE_SCE, TYPE_CPE },
+        .reorder_map = { 2, 0, 1, 4, 5, 3, 8, 7, 9, 6, 10, 11 },
+    },
+    {
+        .layout = {
+            .nb_channels = 12,
+            .order       = AV_CHANNEL_ORDER_NATIVE,
+            .u.mask      = AV_CH_LAYOUT_5POINT1POINT2_BACK | 
AV_CH_TOP_BACK_LEFT | AV_CH_TOP_BACK_RIGHT |
+                           AV_CH_TOP_CENTER | AV_CH_TOP_FRONT_CENTER,
+        },
+        .num_ele = { 4, 1, 2, 1 },
+        .pairing = { { 0, 1, 0, 1 }, { 0 }, { 1, 1 }, },
+        .index = { { 0, 0, 1, 2 }, { 2 }, { 1, 3 }, { 0 }, },
+        .height = { { 0, 0, 1, 1 }, { 1 }, { 0, 1 } },
+        .config_map = { 8, TYPE_SCE, TYPE_CPE, TYPE_CPE, TYPE_LFE, TYPE_SCE, 
TYPE_CPE, TYPE_SCE, TYPE_CPE },
+        .reorder_map = { 2, 0, 1, 4, 5, 3, 8, 7, 9, 6, 10, 11 },
+    },
     {
         .layout = AV_CHANNEL_LAYOUT_7POINT1POINT2,
         .num_ele = { 3, 0, 2, 1 },
@@ -385,6 +408,15 @@ static const AACPCEInfo aac_pce_configs[] = {
         .config_map = { 7, TYPE_SCE, TYPE_CPE, TYPE_CPE, TYPE_CPE, TYPE_LFE, 
TYPE_CPE, TYPE_CPE },
         .reorder_map = { 2, 0, 1, 4, 5, 6, 7, 3, 8, 9, 10, 11 },
     },
+    {
+        .layout = AV_CHANNEL_LAYOUT_7POINT1POINT6,
+        .num_ele = { 4, 1, 3, 1 },
+        .pairing = { { 0, 1, 0, 1 }, { 0 }, { 1, 1, 1 }, },
+        .index = { { 0, 0, 1, 3 }, { 2 }, { 2, 1, 4 }, { 0 } },
+        .height = { { 0, 0, 1, 1 }, { 1 }, { 0, 0, 1 } },
+        .config_map = { 9, TYPE_SCE, TYPE_CPE, TYPE_CPE, TYPE_CPE, TYPE_LFE, 
TYPE_SCE, TYPE_CPE, TYPE_SCE, TYPE_CPE },
+        .reorder_map = { 2, 0, 1, 4, 5, 6, 7, 3, 10, 9, 11, 8, 12, 13 },
+    },
     {
         // ITU-R BS.2051-3 Sound System G
         .layout = AV_CHANNEL_LAYOUT_9POINT1POINT4,
diff --git a/tests/fate/aac.mak b/tests/fate/aac.mak
index 071fc8ae17..7bfabfbbd5 100644
--- a/tests/fate/aac.mak
+++ b/tests/fate/aac.mak
@@ -284,6 +284,13 @@ tests/data/fate/aac-7_1_2.adts: ffmpeg$(PROGSSUF)$(EXESUF) 
| tests/data/fate
        -ch_layout "7.1.2" -i $(TARGET_PATH)/tests/data/asynth-44100-10.wav \
        -c:a aac -aac_pce 1 -aframes 5 -f adts -y $(TARGET_PATH)/$@ 2>/dev/null
 
+tests/data/fate/aac-5_1_6.adts: TAG = GEN
+tests/data/fate/aac-5_1_6.adts: tests/data/asynth-44100-12.wav
+tests/data/fate/aac-5_1_6.adts: ffmpeg$(PROGSSUF)$(EXESUF) | tests/data/fate
+       $(M)$(TARGET_EXEC) $(TARGET_PATH)/$< -nostdin \
+       -ch_layout "5.1.6" -i $(TARGET_PATH)/tests/data/asynth-44100-12.wav \
+       -c:a aac -aac_pce 1 -aframes 5 -f adts -y $(TARGET_PATH)/$@ 2>/dev/null
+
 tests/data/fate/aac-7_2_3.adts: TAG = GEN
 tests/data/fate/aac-7_2_3.adts: tests/data/asynth-44100-12.wav
 tests/data/fate/aac-7_2_3.adts: ffmpeg$(PROGSSUF)$(EXESUF) | tests/data/fate
@@ -298,6 +305,13 @@ tests/data/fate/aac-7_1_4.adts: ffmpeg$(PROGSSUF)$(EXESUF) 
| tests/data/fate
        -ch_layout "7.1.4" -i $(TARGET_PATH)/tests/data/asynth-44100-12.wav \
        -c:a aac -aac_pce 1 -aframes 5 -f adts -y $(TARGET_PATH)/$@ 2>/dev/null
 
+tests/data/fate/aac-7_1_6.adts: TAG = GEN
+tests/data/fate/aac-7_1_6.adts: tests/data/asynth-44100-14.wav
+tests/data/fate/aac-7_1_6.adts: ffmpeg$(PROGSSUF)$(EXESUF) | tests/data/fate
+       $(M)$(TARGET_EXEC) $(TARGET_PATH)/$< -nostdin \
+       -ch_layout "7.1.6" -i $(TARGET_PATH)/tests/data/asynth-44100-14.wav \
+       -c:a aac -aac_pce 1 -aframes 5 -f adts -y $(TARGET_PATH)/$@ 2>/dev/null
+
 tests/data/fate/aac-9_1_4.adts: TAG = GEN
 tests/data/fate/aac-9_1_4.adts: tests/data/asynth-44100-14.wav
 tests/data/fate/aac-9_1_4.adts: ffmpeg$(PROGSSUF)$(EXESUF) | tests/data/fate
@@ -320,8 +334,10 @@ endef
 
 $(eval $(call FATE_AAC_LAYOUT_TEST,5_1_2))
 $(eval $(call FATE_AAC_LAYOUT_TEST,5_1_4))
+$(eval $(call FATE_AAC_LAYOUT_TEST,5_1_6))
 $(eval $(call FATE_AAC_LAYOUT_TEST,7_1_2))
 $(eval $(call FATE_AAC_LAYOUT_TEST,7_1_4))
+$(eval $(call FATE_AAC_LAYOUT_TEST,7_1_6))
 $(eval $(call FATE_AAC_LAYOUT_TEST,7_2_3))
 $(eval $(call FATE_AAC_LAYOUT_TEST,9_1_4))
 $(eval $(call FATE_AAC_LAYOUT_TEST,9_1_6))
diff --git a/tests/ref/fate/aac-encode-5_1_6 b/tests/ref/fate/aac-encode-5_1_6
new file mode 100644
index 0000000000..57fc42733b
--- /dev/null
+++ b/tests/ref/fate/aac-encode-5_1_6
@@ -0,0 +1,4 @@
+[STREAM]
+codec_name=aac
+channel_layout=12 channels (FL+FR+FC+LFE+BL+BR+TC+TFL+TFC+TFR+TBL+TBR)
+[/STREAM]
diff --git a/tests/ref/fate/aac-encode-7_1_6 b/tests/ref/fate/aac-encode-7_1_6
new file mode 100644
index 0000000000..558f730094
--- /dev/null
+++ b/tests/ref/fate/aac-encode-7_1_6
@@ -0,0 +1,4 @@
+[STREAM]
+codec_name=aac
+channel_layout=7.1.6
+[/STREAM]
-- 
2.52.0

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

Reply via email to