From patchwork Sat Feb 18 17:24:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marth64 X-Patchwork-Id: 40442 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:5494:b0:bf:7b3a:fd32 with SMTP id i20csp707129pzk; Sat, 18 Feb 2023 09:25:40 -0800 (PST) X-Google-Smtp-Source: AK7set9M7yzeewxdf/KEXE5kwNc6q73KpE2YbH+I2wuHU1tQlmuUTJ3Q+6luw+lvaIDavSPYYbbq X-Received: by 2002:a05:6402:1101:b0:4ab:2423:e310 with SMTP id u1-20020a056402110100b004ab2423e310mr1053738edv.28.1676741140496; Sat, 18 Feb 2023 09:25:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676741140; cv=none; d=google.com; s=arc-20160816; b=c64A65ejge9e8yDF5qkdn3rDTQ7/gXoMlck8IoBToYCoIqTVgCFP1YPd7AgU/o8HGX BwMYLphmjoj3dErPEyE0jQp4UoKFhsl6bCPkSvBTetnyrbXa52mMefr955oFLorBjU0q W7dbqP9JxuGpvURlfX1JiQdlpNXFMs4kf5Pk6QNyEoA3v8kUv851EVg441BVU/dHwWnu lWIyUDvpAkl9FCDfGfht9rTTP51nMAvB+AuFbCPegz18WICo6zynk9deD2DVw9oshJMe pIvyo1jBnQ06EX8ISjHBFwQhunxHuDkakH1zPfv0fcaqobEux6kuq0udW/jTcp1EN6Fs 1sYg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc: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:delivered-to; bh=3HLe5WWzKKKtEWMLM1LMw217LDrtMNdkYPHl2hs6nwY=; b=0HPfFkl6C/rnJudjycyMpZj286AYjoycPB8yFd+HWcAKAVkrqP5z3Q37mpS3G5L2kK 1Q3YuNjxmLKlGZILG7cIAFEWqtDe9Gm/x4Inihla9I3nNGvZ5mND2dzBggi92g8rGtHx 1C6IKdpYZoN3QSK0p5gOmifKHiIbj4rPoO8GFMM7J3T535GViRbqild+C+ScRBh/MKR6 N1thU3K+oX9KUvEspzGQGPW3s3O9e+0BzdDhOWBCgJdVCzYExvHh9l4Ii6r64vy4+cAc oyxmV0Ueb2pJbRerZ+YZMp323sUYZL+ki7xXxrGLZehR3Ifu1ekUtrPDnPcoSxCHMjqO uGSA== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id l3-20020aa7d943000000b004acb59a6f43si8856994eds.217.2023.02.18.09.25.40; Sat, 18 Feb 2023 09:25:40 -0800 (PST) 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; 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 Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id B145868BEBA; Sat, 18 Feb 2023 19:25:37 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-qt1-f169.google.com (mail-qt1-f169.google.com [209.85.160.169]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 889066801A9 for ; Sat, 18 Feb 2023 19:25:30 +0200 (EET) Received: by mail-qt1-f169.google.com with SMTP id o8so806835qtr.6 for ; Sat, 18 Feb 2023 09:25:30 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1676741129; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=8/T+98qoltonisODiABeT5iK3nind15bgas6A0w/8Xc=; b=PwifhKlLRpfFErhPqxHb8d2s0LfnsQzjhw1rihvsKk7ylm8tCd8pfCInYdLyptLVtg +Igfl4lFsXCCrc+czSamv0CJVbfcTiko+g+eNAvVB9ds4/XSV9wUEnkcaH6E4E/6zJYo q2ECazVRiK9XTQ8IY6HoB82LPDDVC5ssjT0hyyUib+/+Qb6jx2QvWCSQSL+bsSZ2Rzmo 4EWlObAo5nuygOnz52809mI7MlHKuIlRwFLhSATRXsh6hN3VwkrETw8MQToQmmijPcdu gbUa4V/WVqXlWPRtJeP5sGeuF06tkfm3V2Xo+CVdwrAc5YWXHCEfDU/Ee4PftPpIZeAb 7DKA== X-Gm-Message-State: AO0yUKUliYlhzOXYJ54oeiXYYYfK3BedkSMVCYBJ4lr9FfBD8GJGK3NA ByE87ox8YRbwrwrhXZAmRIVa+Xb1uFytMeaWjI/kpulciVHI02eTNdnm+Zsq0H2ZzJtHxGL94eq JviF93xqe+KwnADzJuisdRxASca6ChLfScFD5VjWO+UAPbbZmdVdAAPe/usIpCDjNbApGGQ== X-Received: by 2002:a05:622a:201:b0:3b8:6bef:61df with SMTP id b1-20020a05622a020100b003b86bef61dfmr10194109qtx.6.1676741128820; Sat, 18 Feb 2023 09:25:28 -0800 (PST) Received: from localhost.localdomain ([76.141.0.17]) by smtp.gmail.com with ESMTPSA id g6-20020a37b606000000b00739f84a6c23sm5539198qkf.113.2023.02.18.09.25.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 18 Feb 2023 09:25:28 -0800 (PST) From: Marth64 To: ffmpeg-devel@ffmpeg.org Date: Sat, 18 Feb 2023 11:24:38 -0600 Message-Id: <20230218172436.367169-1-marth64@proxyid.net> X-Mailer: git-send-email 2.25.1 In-Reply-To: <306724> References: <306724> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v2 2/4] avcodec/mlpdec: add detection of Atmos spatial extension profile in TrueHD 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 Cc: Marth64 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: 6u+B+VHL0Uy4 Signed-off-by: Marth64 --- Tidied up formatting in mlpdec.c libavcodec/avcodec.h | 2 ++ libavcodec/codec_desc.c | 1 + libavcodec/mlpdec.c | 10 ++++++++++ libavcodec/profiles.c | 5 +++++ libavcodec/profiles.h | 1 + 5 files changed, 19 insertions(+) diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index 0e85dd50a4..3feab75741 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -1593,6 +1593,8 @@ typedef struct AVCodecContext { #define FF_PROFILE_EAC3_DDP_ATMOS 30 +#define FF_PROFILE_TRUEHD_ATMOS 30 + #define FF_PROFILE_MPEG2_422 0 #define FF_PROFILE_MPEG2_HIGH 1 #define FF_PROFILE_MPEG2_SS 2 diff --git a/libavcodec/codec_desc.c b/libavcodec/codec_desc.c index 4098d4f5a5..e80ac07700 100644 --- a/libavcodec/codec_desc.c +++ b/libavcodec/codec_desc.c @@ -2960,6 +2960,7 @@ static const AVCodecDescriptor codec_descriptors[] = { .name = "truehd", .long_name = NULL_IF_CONFIG_SMALL("TrueHD"), .props = AV_CODEC_PROP_LOSSLESS, + .profiles = NULL_IF_CONFIG_SMALL(ff_truehd_profiles), }, { .id = AV_CODEC_ID_MP4ALS, diff --git a/libavcodec/mlpdec.c b/libavcodec/mlpdec.c index 0ee1f0982c..966ee0f0a2 100644 --- a/libavcodec/mlpdec.c +++ b/libavcodec/mlpdec.c @@ -42,6 +42,7 @@ #include "mlpdsp.h" #include "mlp.h" #include "config.h" +#include "profiles.h" /** number of bits used for VLC lookup - longest Huffman code is 9 */ #if ARCH_ARM @@ -392,6 +393,14 @@ static int read_major_sync(MLPDecodeContext *m, GetBitContext *gb) m->num_substreams = mh.num_substreams; m->substream_info = mh.substream_info; + /* If there is a 4th substream and the MSB of substream_info is set, + * there is a 16-channel spatial presentation (Atmos in TrueHD). + */ + if (m->avctx->codec_id == AV_CODEC_ID_TRUEHD + && m->num_substreams == 4 && m->substream_info >> 7 == 1) { + m->avctx->profile = FF_PROFILE_TRUEHD_ATMOS; + } + /* limit to decoding 3 substreams, as the 4th is used by Dolby Atmos for non-audio data */ m->max_decoded_substream = FFMIN(m->num_substreams - 1, 2); @@ -1452,5 +1461,6 @@ const FFCodec ff_truehd_decoder = { FF_CODEC_DECODE_CB(read_access_unit), .flush = mlp_decode_flush, .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_CHANNEL_CONF, + .p.profiles = NULL_IF_CONFIG_SMALL(ff_truehd_profiles), }; #endif /* CONFIG_TRUEHD_DECODER */ diff --git a/libavcodec/profiles.c b/libavcodec/profiles.c index 343b08f363..5bd91d9c5c 100644 --- a/libavcodec/profiles.c +++ b/libavcodec/profiles.c @@ -50,6 +50,11 @@ const AVProfile ff_eac3_profiles[] = { { FF_PROFILE_UNKNOWN }, }; +const AVProfile ff_truehd_profiles[] = { + { FF_PROFILE_TRUEHD_ATMOS, "Dolby TrueHD + Dolby Atmos"}, + { FF_PROFILE_UNKNOWN }, +}; + const AVProfile ff_dnxhd_profiles[] = { { FF_PROFILE_DNXHD, "DNXHD"}, { FF_PROFILE_DNXHR_LB, "DNXHR LB"}, diff --git a/libavcodec/profiles.h b/libavcodec/profiles.h index 6ebedbd03f..1d523992fc 100644 --- a/libavcodec/profiles.h +++ b/libavcodec/profiles.h @@ -59,6 +59,7 @@ extern const AVProfile ff_aac_profiles[]; extern const AVProfile ff_dca_profiles[]; extern const AVProfile ff_eac3_profiles[]; +extern const AVProfile ff_truehd_profiles[]; extern const AVProfile ff_dnxhd_profiles[]; extern const AVProfile ff_h264_profiles[]; extern const AVProfile ff_hevc_profiles[];