From patchwork Sat Feb 18 17:49:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marth64 X-Patchwork-Id: 40443 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:5494:b0:bf:7b3a:fd32 with SMTP id i20csp719130pzk; Sat, 18 Feb 2023 09:50:32 -0800 (PST) X-Google-Smtp-Source: AK7set8HLbqohA5JT+H1wC/XwpFhMmwVseNMgCTeOgln4pLOwQ14X1FEkrykQZVRx0cnPUDDC2Fz X-Received: by 2002:a17:906:9692:b0:8b1:3c99:76c0 with SMTP id w18-20020a170906969200b008b13c9976c0mr1602326ejx.64.1676742632439; Sat, 18 Feb 2023 09:50:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676742632; cv=none; d=google.com; s=arc-20160816; b=ND2bO/YNhJJzyQcFw3qfGRjvp5gnu3+vNxW8Y4GDA0WbIBC1DG7XosQRTtKRVtKCaE KUyDFa6TkGpVvDj1DTxZYjtJiVjJ39m4x7esifNYuUWausOiTTlf3fQsVfdHiHbiDa82 qpQVI/EpAwg1FVgg6AFAF89oVhOnQ4VdmAQYrisPsSnOrhKH+WX0ocIM4Q4optUtbeOd x9I1kahMt/nwszuelT7CijVhbyYQRhChdWtzFyqGgcwplkOtaa0vXvLC5BaLeeY5W+xg ttBRb4q8+XdxLJea4QQNlFR0Nxi8QLJfhmZeMWA98A8bnJTFsfhSujaYB6z1WFarBSci VPiA== 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=Iq5wggWwAvSJsqFnCeccmS654txSaHHadVXjiyS1b5c=; b=ZbPcxamimwy7DJSLUKTdH1u46OHz1XWQomDoz4hnBwlAtD/pfZXBczLMzAIk8VMMxb RSMFVKIXA8/YiQlOXisgBGg/fj0o73DZKvQMXj/M9A36qeltJI46cLJcv5dG13vHEB4K qhMD733sMUV4rURGia1EdTudvu6UQ7cXqIwm+5ompqsdw92HGgU5PAlY/5wsxqkdTOE6 QO2So2hLxgK5ivE7fQUI2ml+WxDDhKT0qYJuUhSTWEMEM9pJuoqr4GwLzsjR7727phPE Td0SNFryRXmHPe4mRRta9Cn0LfQtSip1TvUwdncf1OFUjAguuFuoxcX71s/pzxmQAtAA P2EQ== 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 mr40-20020a17090782a800b008b17f6bf67asi6023196ejc.283.2023.02.18.09.50.31; Sat, 18 Feb 2023 09:50:32 -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 A7CAE68BEC3; Sat, 18 Feb 2023 19:50:28 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-qv1-f49.google.com (mail-qv1-f49.google.com [209.85.219.49]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id BA0ED68BD8B for ; Sat, 18 Feb 2023 19:50:21 +0200 (EET) Received: by mail-qv1-f49.google.com with SMTP id oh3so916040qvb.1 for ; Sat, 18 Feb 2023 09:50:21 -0800 (PST) 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:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=LjQETdyX8ixI2dpcHcc9sPh+/70U8LTChixdpbeq30Y=; b=GrzNumttCxhKg4BUxSvhWgVrSUnMa0w8bq/YIcxvmReKePwRS2QHA/VKPETt1ZeXnC cLIJdm1RyiS1W/DHUe/h0kWQd+1T9bHieoslvBqNe1TgrJX2mHPvF9YR1vVk8Yv8Oxya YjtUIfHOWXPaB06NO3pyRONVEb1hbH4h8b8tNGc7l9gh8gfVWQ8B9d8HRLlvUZCCAEsM vCqJydz3bBqiFY7gDAs1a/E3dhXXEhrb9hQ+QAkgmF/mRuy35rIKdlWNhDHIvAcNU9NN b5yNhLy5RQ6jBCoMnAxNkdOIJUrAL7SH6aTac997hE4j4hf5ezXmAd7G5+2M3y/18y4U u5ig== X-Gm-Message-State: AO0yUKWJe/mW7JHbiuxUPkyZEtE9rEdQoyPV9Q940nc8McS6ETcP8yX3 v3uAuMCy68FMMLk4c81PvMB3uuwegSK3x6mRjnaMdOCYpqpBlpxrQuMDFrjdG35CLMagPPqNRXP 7ZJiz6b7rUOiixVTCtbA3o6OmtxQJPnQ+CIIyhw/s0U2w+KPRmnGcgp613wWsbeZPerIONA== X-Received: by 2002:a0c:b448:0:b0:539:aae2:8dc4 with SMTP id e8-20020a0cb448000000b00539aae28dc4mr2764918qvf.4.1676742619735; Sat, 18 Feb 2023 09:50:19 -0800 (PST) Received: from localhost.localdomain ([76.141.0.17]) by smtp.gmail.com with ESMTPSA id q205-20020a3743d6000000b0073b75718428sm5661176qka.134.2023.02.18.09.50.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 18 Feb 2023 09:50:19 -0800 (PST) From: Marth64 To: ffmpeg-devel@ffmpeg.org Date: Sat, 18 Feb 2023 11:49:56 -0600 Message-Id: <20230218174955.372237-1-marth64@proxyid.net> X-Mailer: git-send-email 2.25.1 In-Reply-To: <306722> References: <306722> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH v2 1/4] avcodec/eac3dec: add detection of Atmos spatial extension profile 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: 4s659yReqxYx Signed-off-by: Marth64 --- - Missed adding the profiles to actual codec descriptor in ac3dec_float - Formatting tidyness libavcodec/ac3dec.c | 3 +++ libavcodec/ac3dec.h | 1 + libavcodec/ac3dec_float.c | 2 ++ libavcodec/avcodec.h | 2 ++ libavcodec/codec_desc.c | 1 + libavcodec/eac3dec.c | 11 ++++++++++- libavcodec/profiles.c | 5 +++++ libavcodec/profiles.h | 1 + 8 files changed, 25 insertions(+), 1 deletion(-) diff --git a/libavcodec/ac3dec.c b/libavcodec/ac3dec.c index 0b120e6140..b5f4b166d3 100644 --- a/libavcodec/ac3dec.c +++ b/libavcodec/ac3dec.c @@ -1714,6 +1714,9 @@ skip: if (!err) { avctx->sample_rate = s->sample_rate; avctx->bit_rate = s->bit_rate + s->prev_bit_rate; + + if (s->eac3_extension_type_a == 1) + avctx->profile = s->eac3_extension_type_a == 1 ? FF_PROFILE_EAC3_DDP_ATMOS : FF_PROFILE_UNKNOWN; } if (!avctx->sample_rate) { diff --git a/libavcodec/ac3dec.h b/libavcodec/ac3dec.h index 138b462abb..0829f4b40d 100644 --- a/libavcodec/ac3dec.h +++ b/libavcodec/ac3dec.h @@ -102,6 +102,7 @@ typedef struct AC3DecodeContext { int eac3; ///< indicates if current frame is E-AC-3 int eac3_frame_dependent_found; ///< bitstream has E-AC-3 dependent frame(s) int eac3_subsbtreamid_found; ///< bitstream has E-AC-3 additional substream(s) + int eac3_extension_type_a; ///< bitstream has E-AC-3 extension type A enabled frame(s) int dolby_surround_mode; ///< dolby surround mode (dsurmod) int dolby_surround_ex_mode; ///< dolby surround ex mode (dsurexmod) int dolby_headphone_mode; ///< dolby headphone mode (dheadphonmod) diff --git a/libavcodec/ac3dec_float.c b/libavcodec/ac3dec_float.c index b8868d8ee1..39d3cbd282 100644 --- a/libavcodec/ac3dec_float.c +++ b/libavcodec/ac3dec_float.c @@ -33,6 +33,7 @@ #include "ac3dec.h" #include "codec_internal.h" +#include "profiles.h" #include "eac3dec.c" #include "ac3dec.c" @@ -92,6 +93,7 @@ const FFCodec ff_eac3_decoder = { .p.sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_FLTP, AV_SAMPLE_FMT_NONE }, .p.priv_class = &ac3_eac3_decoder_class, + .p.profiles = NULL_IF_CONFIG_SMALL(ff_eac3_profiles), .caps_internal = FF_CODEC_CAP_INIT_CLEANUP, }; #endif diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h index 39881a1d2b..0e85dd50a4 100644 --- a/libavcodec/avcodec.h +++ b/libavcodec/avcodec.h @@ -1591,6 +1591,8 @@ typedef struct AVCodecContext { #define FF_PROFILE_DTS_HD_MA 60 #define FF_PROFILE_DTS_EXPRESS 70 +#define FF_PROFILE_EAC3_DDP_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 199f62df15..4098d4f5a5 100644 --- a/libavcodec/codec_desc.c +++ b/libavcodec/codec_desc.c @@ -2931,6 +2931,7 @@ static const AVCodecDescriptor codec_descriptors[] = { .name = "eac3", .long_name = NULL_IF_CONFIG_SMALL("ATSC A/52B (AC-3, E-AC-3)"), .props = AV_CODEC_PROP_INTRA_ONLY | AV_CODEC_PROP_LOSSY, + .profiles = NULL_IF_CONFIG_SMALL(ff_eac3_profiles), }, { .id = AV_CODEC_ID_SIPR, diff --git a/libavcodec/eac3dec.c b/libavcodec/eac3dec.c index deca51dd3d..5c71751a0c 100644 --- a/libavcodec/eac3dec.c +++ b/libavcodec/eac3dec.c @@ -464,7 +464,16 @@ static int ff_eac3_parse_header(AC3DecodeContext *s) if (get_bits1(gbc)) { int addbsil = get_bits(gbc, 6); for (i = 0; i < addbsil + 1; i++) { - skip_bits(gbc, 8); // skip additional bit stream info + if (i == 0) { + /* In this 8 bit chunk, the LSB is equal to flag_ec3_extension_type_a + which can be used to detect Atmos presence */ + skip_bits(gbc, 7); + if (get_bits1(gbc)) { + s->eac3_extension_type_a = 1; + } + } else { + skip_bits(gbc, 8); // skip additional bit stream info + } } } diff --git a/libavcodec/profiles.c b/libavcodec/profiles.c index 7af7fbeb13..343b08f363 100644 --- a/libavcodec/profiles.c +++ b/libavcodec/profiles.c @@ -45,6 +45,11 @@ const AVProfile ff_dca_profiles[] = { { FF_PROFILE_UNKNOWN }, }; +const AVProfile ff_eac3_profiles[] = { + { FF_PROFILE_EAC3_DDP_ATMOS, "Dolby Digital Plus + 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 41a19aa9ad..6ebedbd03f 100644 --- a/libavcodec/profiles.h +++ b/libavcodec/profiles.h @@ -58,6 +58,7 @@ extern const AVProfile ff_aac_profiles[]; extern const AVProfile ff_dca_profiles[]; +extern const AVProfile ff_eac3_profiles[]; extern const AVProfile ff_dnxhd_profiles[]; extern const AVProfile ff_h264_profiles[]; extern const AVProfile ff_hevc_profiles[];