From patchwork Thu Oct 27 18:26:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Almer X-Patchwork-Id: 39021 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:85a8:b0:a2:d5a7:ad9d with SMTP id s40csp337481pzd; Thu, 27 Oct 2022 11:27:30 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5AKc8S9GFznfOOcV0Qfkw5lI/w96ISaVK8wIdDtX32iokyLe4zjXfukksVhIUDp3yojzzr X-Received: by 2002:a17:906:eec9:b0:73d:c369:690f with SMTP id wu9-20020a170906eec900b0073dc369690fmr43754881ejb.767.1666895239739; Thu, 27 Oct 2022 11:27:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666895239; cv=none; d=google.com; s=arc-20160816; b=lXanhI4fadEPK8Y7MJF+tjiTKFLnYeWsEr1uPEv2X9qZKFHfUFFKNxVddRozXRpUdq V8ROWt1YaQ9vbbfz2pslgrVryygAavtotK36c5YKIJVt00CCHXIxqE9mW5gYBQ3balkw j6YdSd5tKgv2M2hPRGyrvghZqapN86IabTGd500iKxXJmfkf5SbX6rot6BG5XTN38UtE 8/QecM8PLA/cYzXbWvDujHNqXDYTDxfJ87yZv0BJ+9faOC5/sR/s/dfrJ90PSklAppXF KE1hl9LEzNhJoZZZuNYcUJX+lIL5WoG9GquZu2r2pjwtcrqk6lVC5Jfgkm0MC5+t4udN eQnQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:references:in-reply-to:message-id :date:to:from:dkim-signature:delivered-to; bh=+RvzB/00jCBNRVyT9eECE4bB9jvNq8cYTmo/aCuZ7pE=; b=n9cKnueRLzXMmuM5l+XgwS5jbU5eusBcwwMDra/Oonl0AVNyZXXYnoniwHS9rnO6R2 MWC56k8zj5dHrn2DDzx7GcFuOGZ6fAHSXtMcKFaGkIzQCJnr4rElkn5S+QE8v/KIXqO4 MiEKcIEpgoHcei3fgGA+KJTJ+sm/R/8nDfs0ZSX8vb3t7IHeDvosV9r9nCDeJ5VBOEWx eocwuwcVljF1IXuTNQVrgF6CHzMs6YPkjpmo67qonHry9CJllN9n1D6Qz9/rrxgW9aXD JzHH7Hk3+LLyZyZ4MW4uhZ6Enc2Ln1s/uWGUYBTrWMklEvIQ1n6T9PDUjzELGZpI9oxu RSSg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b=YFthoSQE; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id i15-20020a1709064fcf00b007a137bfaa8dsi2290340ejw.148.2022.10.27.11.27.19; Thu, 27 Oct 2022 11:27:19 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b=YFthoSQE; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 27A5168B554; Thu, 27 Oct 2022 21:27:03 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-oa1-f48.google.com (mail-oa1-f48.google.com [209.85.160.48]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id AEFFB68BB88 for ; Thu, 27 Oct 2022 21:26:55 +0300 (EEST) Received: by mail-oa1-f48.google.com with SMTP id 586e51a60fabf-13b23e29e36so3266182fac.8 for ; Thu, 27 Oct 2022 11:26:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=iJQsrM0yzbS3RQRXDAk038j/UFa0U41QYc88Sbjh7ks=; b=YFthoSQEbX5ubtpeEkQJnKRIc3zVyxYQBaAVHIGoN+zVh4pdNSNQuhAvXf67NqHLXN F3aDN4q8zrZEgE2nelH6+4leGTG3GaeNwngiv/Uph7JD/dWcfvhFCeW8OPW935qW9FIT yglzwYB7I061EeZJHm9X9p0l4mVkUm9tRK0nxAdIv5DhhJ9yiqygf5Br4Jv90nlI95Kj /DCfeQ6LuN9tc+PcXVT1ipwwAFpX7tiC+M60N497MRu62dztBUF1+W3i27VBzQkun4HX CxepFHqn83TfWtFO7J2Blqse2zY9DXlEhpr5OsJYovaM6URzyyDUYob5KqWHHbu2SaG6 qTLw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=iJQsrM0yzbS3RQRXDAk038j/UFa0U41QYc88Sbjh7ks=; b=O47BRhJIlbVnKm8sGbNjyYQLG+HweOynpDmQcM1B5xcbSM6XE82spjoKPBgu7NLNky X+iUTlfhRjZCaxypgE6txoJLkdkRi9MnrfAQFXtXPXiWlNhhE/a/imseZe8T3aC7o61z 18WEvRa5FJOnO4BZBMrp14xQAfJYAJjQS8xjj9AElIhoFY/hIgJLpI41o/2JjR+7bHCc CVuRmSksXep4xeTRe3Z+PLo7M69EOjF5+FK28ef+fxoH8slhr83+eOzDrquXhg37BRBC k6DHfVWnJ6z2bujpPpvN8+D1HhD7NSCKM8ssE4fRz+XlQYwCTppUkuWsdYBOpE/4GBRB 1ZBA== X-Gm-Message-State: ACrzQf1ZnlFje3ugbzi5sYvghqWEoZEYQROiZhqYA0wcOCDj3JqJNqWW LqvFf0S/oaZfXgBAH1DtzhOBQE/Y1CA= X-Received: by 2002:a05:6870:fba9:b0:13b:fe98:53fa with SMTP id kv41-20020a056870fba900b0013bfe9853famr6314780oab.271.1666895213907; Thu, 27 Oct 2022 11:26:53 -0700 (PDT) Received: from localhost.localdomain ([191.97.187.183]) by smtp.gmail.com with ESMTPSA id j126-20020aca3c84000000b0035770fc6ca9sm696008oia.16.2022.10.27.11.26.52 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Oct 2022 11:26:53 -0700 (PDT) From: James Almer To: ffmpeg-devel@ffmpeg.org Date: Thu, 27 Oct 2022 15:26:52 -0300 Message-Id: <20221027182652.46178-3-jamrial@gmail.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221027182652.46178-1-jamrial@gmail.com> References: <20221027182652.46178-1-jamrial@gmail.com> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 3/3] avcodec/aacdec: add support for channel configuration 14 X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: IIL1rp+FSLO0 It corresponds to the 7.1(top) layout. Signed-off-by: James Almer --- 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.