Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
From: James Almer <jamrial@gmail.com>
To: ffmpeg-devel@ffmpeg.org
Subject: [FFmpeg-devel] [PATCH 3/3] avcodec/aacdec: add support for channel configuration 14
Date: Thu, 27 Oct 2022 15:26:52 -0300
Message-ID: <20221027182652.46178-3-jamrial@gmail.com> (raw)
In-Reply-To: <20221027182652.46178-1-jamrial@gmail.com>

It corresponds to the 7.1(top) layout.

Signed-off-by: James Almer <jamrial@gmail.com>
---
 libavcodec/aacdec_template.c | 25 +++++++++++++++++++++++--
 libavcodec/aacdectab.h       |  6 +++---
 libavcodec/mpeg4audio.c      |  5 +++--
 libavcodec/mpeg4audio.h      |  2 +-
 4 files changed, 30 insertions(+), 8 deletions(-)

diff --git a/libavcodec/aacdec_template.c b/libavcodec/aacdec_template.c
index c10bc743b6..e5ac5bebca 100644
--- a/libavcodec/aacdec_template.c
+++ b/libavcodec/aacdec_template.c
@@ -404,6 +404,21 @@ static uint64_t sniff_channel_order(uint8_t (*layout_map)[3], int tags)
         i++;
     }
 
+    // The previous checks would end up at 4 at this point for chan_config 14
+    if (layout == AV_CH_LAYOUT_5POINT1_BACK && tags == 5 && i == 4) {
+        const uint8_t (*reference_layout_map)[3] = aac_channel_layout_map[13];
+        for (int j = 0; j < tags; j++) {
+            if (layout_map[j][0] != reference_layout_map[j][0] ||
+                layout_map[j][2] != reference_layout_map[j][2])
+                goto end_of_layout_definition;
+        }
+
+        i += assign_pair(e2c_vec, layout_map, i,
+                         AV_CH_TOP_FRONT_LEFT,
+                         AV_CH_TOP_FRONT_RIGHT,
+                         AAC_CHANNEL_FRONT,
+                         &layout);
+    }
     // The previous checks would end up at 8 at this point for 22.2
     if (layout == PREFIX_FOR_22POINT2 && tags == 16 && i == 8) {
         const uint8_t (*reference_layout_map)[3] = aac_channel_layout_map[12];
@@ -633,7 +648,7 @@ static int set_default_channel_config(AACContext *ac, AVCodecContext *avctx,
                                       int channel_config)
 {
     if (channel_config < 1 || (channel_config > 7 && channel_config < 11) ||
-        channel_config > 13) {
+        channel_config > 14) {
         av_log(avctx, AV_LOG_ERROR,
                "invalid default channel configuration (%d)\n",
                channel_config);
@@ -717,6 +732,12 @@ static ChannelElement *get_che(AACContext *ac, int type, int elem_id)
     /* For indexed channel configurations map the channels solely based
      * on position. */
     switch (ac->oc[1].m4ac.chan_config) {
+    case 14:
+        if (ac->tags_mapped > 2 && ((type == TYPE_CPE && elem_id < 3) ||
+                                    (type == TYPE_LFE && elem_id < 1))) {
+            ac->tags_mapped++;
+            return ac->tag_che_map[type][elem_id] = ac->che[type][elem_id];
+        }
     case 13:
         if (ac->tags_mapped > 3 && ((type == TYPE_CPE && elem_id < 8) ||
                                     (type == TYPE_SCE && elem_id < 6) ||
@@ -3194,7 +3215,7 @@ static int aac_decode_er_frame(AVCodecContext *avctx, void *data,
 
     ac->tags_mapped = 0;
 
-    if (chan_config < 0 || (chan_config >= 8 && chan_config < 11) || chan_config >= 13) {
+    if (chan_config < 0 || (chan_config >= 8 && chan_config < 11) || chan_config > 14) {
         avpriv_request_sample(avctx, "Unknown ER channel configuration %d",
                               chan_config);
         return AVERROR_INVALIDDATA;
diff --git a/libavcodec/aacdectab.h b/libavcodec/aacdectab.h
index 327efbcde0..55a91cb4fe 100644
--- a/libavcodec/aacdectab.h
+++ b/libavcodec/aacdectab.h
@@ -68,8 +68,8 @@ static const uint8_t aac_channel_layout_map[16][16][3] = {
       { TYPE_SCE, 5, AAC_CHANNEL_FRONT }, // SCE6 = BtFC,
       { TYPE_CPE, 7, AAC_CHANNEL_FRONT }, // CPE8 = BtFL and BtFR
     },
+    { { TYPE_SCE, 0, AAC_CHANNEL_FRONT }, { TYPE_CPE, 0, AAC_CHANNEL_FRONT }, { TYPE_CPE, 1, AAC_CHANNEL_BACK }, { TYPE_LFE, 0, AAC_CHANNEL_LFE }, { TYPE_CPE, 2, AAC_CHANNEL_FRONT  }, },
     { { 0, } },
-    /* TODO: Add 7+1 TOP configuration */
 };
 
 #if FF_API_OLD_CHANNEL_LAYOUT
@@ -84,8 +84,8 @@ static const uint64_t aac_channel_layout[] = {
     AV_CH_LAYOUT_6POINT1_BACK,
     AV_CH_LAYOUT_7POINT1,
     AV_CH_LAYOUT_22POINT2,
+    AV_CH_LAYOUT_7POINT1_TOP,
     0,
-    /* AV_CH_LAYOUT_7POINT1_TOP, */
 };
 #endif
 
@@ -100,8 +100,8 @@ static const AVChannelLayout aac_ch_layout[] = {
     AV_CHANNEL_LAYOUT_6POINT1_BACK,
     AV_CHANNEL_LAYOUT_7POINT1,
     AV_CHANNEL_LAYOUT_22POINT2,
+    AV_CHANNEL_LAYOUT_7POINT1_TOP,
     { 0 },
-    /* AV_CHANNEL_LAYOUT_7POINT1_TOP, */
 };
 
 #endif /* AVCODEC_AACDECTAB_H */
diff --git a/libavcodec/mpeg4audio.c b/libavcodec/mpeg4audio.c
index e38a8c0852..4a996411d1 100644
--- a/libavcodec/mpeg4audio.c
+++ b/libavcodec/mpeg4audio.c
@@ -56,7 +56,7 @@ static int parse_config_ALS(GetBitContext *gb, MPEG4AudioConfig *c, void *logctx
     return 0;
 }
 
-const uint8_t ff_mpeg4audio_channels[14] = {
+const uint8_t ff_mpeg4audio_channels[15] = {
     0,
     1, // mono (1/0)
     2, // stereo (2/0)
@@ -70,7 +70,8 @@ const uint8_t ff_mpeg4audio_channels[14] = {
     0,
     7, // 3/3.1
     8, // 3/2/2.1
-    24 // 3/3/3 - 5/2/3 - 3/0/0.2
+    24, // 3/3/3 - 5/2/3 - 3/0/0.2
+    8 // 3/2.1 - 2/0
 };
 
 static inline int get_object_type(GetBitContext *gb)
diff --git a/libavcodec/mpeg4audio.h b/libavcodec/mpeg4audio.h
index a6f71cff58..56615ef321 100644
--- a/libavcodec/mpeg4audio.h
+++ b/libavcodec/mpeg4audio.h
@@ -42,7 +42,7 @@ typedef struct MPEG4AudioConfig {
 } MPEG4AudioConfig;
 
 extern const int     ff_mpeg4audio_sample_rates[16];
-extern const uint8_t ff_mpeg4audio_channels[14];
+extern const uint8_t ff_mpeg4audio_channels[15];
 
 /**
  * Parse MPEG-4 systems extradata from a potentially unaligned GetBitContext to retrieve audio configuration.
-- 
2.38.1

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

      parent reply	other threads:[~2022-10-27 18:27 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-27 18:26 [FFmpeg-devel] [PATCH 1/3] avcodec/aacdec: fix parsing streams with channel configuration 11 James Almer
2022-10-27 18:26 ` [FFmpeg-devel] [PATCH 2/3] avutil/channel_layout: add a 7.1(top) channel layout James Almer
2022-10-27 18:26 ` James Almer [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221027182652.46178-3-jamrial@gmail.com \
    --to=jamrial@gmail.com \
    --cc=ffmpeg-devel@ffmpeg.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
		ffmpegdev@gitmailbox.com
	public-inbox-index ffmpegdev

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git