From patchwork Sun Apr 7 21:09:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 47895 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:24a8:b0:1a3:b6bb:3029 with SMTP id m40csp2146892pzd; Sun, 7 Apr 2024 14:09:46 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCU2Ii/IPMiiVmT2G9LdIssaLljRDNVLU1rW+jWKr6jJlp3lxBb4kVB74uVTc0wuA55VQadkW2tRi+qV6H2wkKiORCsMt/u9o9OiXg== X-Google-Smtp-Source: AGHT+IGTnpo9C2FO3KDNb/ZKoGFGf6FeVGKZFoq/5COzDboL4zhOWDcDlRNAn/ZKUKG748j/a8kg X-Received: by 2002:a17:906:412:b0:a4e:fe3:ceff with SMTP id d18-20020a170906041200b00a4e0fe3ceffmr4260087eja.57.1712524185826; Sun, 07 Apr 2024 14:09:45 -0700 (PDT) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id jg38-20020a170907972600b00a4e2d69e37esi3170012ejc.632.2024.04.07.14.09.45; Sun, 07 Apr 2024 14:09:45 -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=@outlook.com header.s=selector1 header.b=JkV9JPoY; arc=fail (body hash mismatch); 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=outlook.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 327E468D19E; Mon, 8 Apr 2024 00:09:42 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR01-DB5-obe.outbound.protection.outlook.com (mail-db5eur01olkn2043.outbound.protection.outlook.com [40.92.64.43]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 08C1668D18D for ; Mon, 8 Apr 2024 00:09:35 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jaDQTpmB0UZ1Q49YEM0ySyEnwCMOFjxju9u73tzIoBx8vuZP/IFMiPfhOEhFZcSLc3Z8XDRiyu+1HnPAsZQDPV1IrS+Cavup3ZUz6ZRtd0C1vReXgK6bChiBSFZAhwNonH68+8N+zvXGeobTmTBvcCYp3ipxyUCy8iUSkPdn2ZkmmfZQuWy08AeJfFmgHL5YnQyhZgAMgDvvgDkgZNr0kZzRMHlbStx/hAObGtXQ/uPr19Ogu/ErwR8CvlFQ5A6KTWiexEmafGZ0A522/emALrmZFl4Toj5mqYs4mqQyP8/U9mK8+l2FuGeVxV67IlCXOqz3Kb7KN5z7pBcJM6FpfA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=hhIbWEHvKINtmXPOlj/2CP46WigqNLmFS2U01juEK7Y=; b=SoCAvaKAbMSHS0lvdiMF19RPJRJz1M1HumvAl5yMaANZ81g0rLBeCES4Huo7nw0NkCackI49UBAc49nKuIyIBZaGoUIUDV6stVXrSJzAuehmBnm6I9i5TseWvCTRew813VOYiswd3y+kScqBHCMBYIYrPE/Qv5O2mGJfNGDsIn9UJg/xayYG067NgIMKPi+6SD3b3D7O2PJyssH+NzSrdn8Mr+dJytlNCZpMc1jNTfCUBuBD34YP8oYpaWe9fOw3AkOEGuIhE9miD/8LUfbz+6v99TzzvNsGS9amDjVOj5IJc3tO9qYuw967hS7VA2xARNDnOj/+D91vrOMRrjmh7w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outlook.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=hhIbWEHvKINtmXPOlj/2CP46WigqNLmFS2U01juEK7Y=; b=JkV9JPoYDGIpdAubh+GtVtzXBup5SZ3WK0j9k+S+OnOXqOgRrbwrZ5L+Q1aQHi9AQXpvjAA6/v++Du+kc0qRIKk19Oin69EJ73d17vOnDplrw+aJvMoNZ0lyDnHJ07+b4bgbgORq2HQBgpiTiG8Z5KCgimNcN0rNEHJU6MRcN+0AvyDW7MssoDMkL+/BdwxT1Q7YCf/UHw+z9dDmJsugEEwaF5TPheiNyXEWZTZMCamGDLADOxQCZWmQyq739f0Q6z8r8RpfVyrvrJDQen3wT2Z/cmBHN/35e5O2m/BGfGsqhun9nKwByNXDXDX2M87XJkslePTncGAWkX2rEWc4eg== Received: from GV1P250MB0737.EURP250.PROD.OUTLOOK.COM (2603:10a6:150:8e::17) by AS8P250MB0234.EURP250.PROD.OUTLOOK.COM (2603:10a6:20b:379::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7409.55; Sun, 7 Apr 2024 21:09:33 +0000 Received: from GV1P250MB0737.EURP250.PROD.OUTLOOK.COM ([fe80::4a3b:cf76:cddc:c68d]) by GV1P250MB0737.EURP250.PROD.OUTLOOK.COM ([fe80::4a3b:cf76:cddc:c68d%4]) with mapi id 15.20.7409.042; Sun, 7 Apr 2024 21:09:33 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Sun, 7 Apr 2024 23:09:01 +0200 Message-ID: X-Mailer: git-send-email 2.40.1 In-Reply-To: References: X-TMN: [BeXUCuzPHS8E931c5uYOBDafI2aWCrgc] X-ClientProxiedBy: ZR0P278CA0038.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:1d::7) To GV1P250MB0737.EURP250.PROD.OUTLOOK.COM (2603:10a6:150:8e::17) X-Microsoft-Original-Message-ID: <20240407210915.895619-2-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: GV1P250MB0737:EE_|AS8P250MB0234:EE_ X-MS-Office365-Filtering-Correlation-Id: 695110d3-918e-4ed2-995b-08dc574705c2 X-MS-Exchange-SLBlob-MailProps: 9IecXKUgicDNEbE0encsoirT0ZUrgC9mLJcKLLCfi9QrlR/Sf7HXAwFxOXsr7PhBobC+7ZE4hoQZfWdXa8XH3yJP5MTRRZopZ85M7qGDL6tM/SeoazXs6PtR5GHqQ0JfRdXOH9NTmcabSZdLrTfZmlNQwPpOTa+V/E1nb+WRsMOvbRF5FXflOpZrT5qOBvR+rtWHusOeYpxoILzLBNPJU1lnI1gAfhhvhTa+0vVmHjGI4GKDGoS6RqTXMTAexytVIdZ5obR1xtG6y91quhVskk/nwzva0kZGJLJGbd4IY5GLSZJNs2UWyjCF/s1snORe3KvM6XjqFr/SXigAo6pxQfIAUrhmeQE7NAkYkbARKUtPNLyyj9O5g/v4HMi0UNpLU585FMspS+e6iO68ERUhpwW6af0mGFIIVGr6nFj+pprGhjBQfG/JsXxQrW4+UTWOw9MAmuLv56AQyCx6wp9WXFze6RKYYMZBDt3qGGzLbseO6iyHFLhoLFBPBwazlJjh3VlJHmyTFIsie1ufx6ogG639+BmtQxlf0xOhE8x2NepVJFGcTrC5iqkGVazJOa3bKfGEUuuguOLOJDoIXtZJ1ISYxew8A4z1u/UZCoMC/MTotc4AMnrgKvcXDtkb1BUSM2CKuDbSzL/YH3iqj5tyKXdBXHfTRz9zuZgU2d8uIyqDPRvqwpfEuIyoOaNKk2HVoDl6D8NBOK8vRja0UUGqr6jDTWsFFc97Soq4u3NYz7d55dRA4G8Hzw== X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: pjFrmj4vg308opjCgeHc57VM7GJvvWUfKJlbnPeAu3uwaC/JHIQcCzTE1/V3uhxJt0e6b3uppzPYIUhL67cKmiKasdvTSeorv6FHQTiaXyY5siEiUhnfjFW1WKWGvrytTnpTGVUMTRNyEa/c3eivpoN19qAWh1l3a/LvvId8CjLDFtJZZWwb25e8jgbVnPyC0sYwqfz75+HsaojBTSBkH2Zi07h9b3STqmtVIqENJ95dlAom66STsDYLQPaanABWDPj17AvMKr7xq8yVzbW60xLlvs+bFHMAT9U/wuFjd8Bp9QG+vB5U7jrY7/P7QyOD07xHCXQKuKIN6jUFWZTaCWnZX5otu3R7NzzLxR9/rzjBLAYELXKeu1LNy9nhYRNNRYwtEtMG/5e99v9sILzK4vvHeCmnlkTkhjqj5CorBS4tBMpjEF73US/HmYGUnmHAU/2vvoSTAZ7utuXyFnXdhULR95TXTVVfXQeDXcwz7o18Qes1y/wxI2xf7JfxtRuBBCDQ7gjg+JjnB0ODvZh83SkLalIi/nh+A3aSP+RSA36cmFIUK2KR46H0vQGAMIhnaPHVZloS9o5g7d5QPk6bPBVdWUz0PslQp9534B5VCHnmkLbMnFbNzt2EMHAFEL5y X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 5qz9kNXp8ro9uE0WamCZ+ojLW69KdlQvdd7Me8YXRzfqdWxznqOOjbAGND/otmMx2Kua5jfnr8ejgSibdTSB/kd2CU4j8vyrnfPOrA+JNGDbZ7ewimPs7F+jm5dX9fug19JTddzQNvYB3HPszlqau29L+0dVX+CvBbrasSIwLAoGz2o6gRxCBwdHZPiymocAbToC2RbxKrgMH3rQlY2DYMx5DTGlpSMg8E5Ammk1nJjdnHR5uLjWBT+mA4Vc5TcyYB0ogDJB5K9xFqiEvAuo6BWTx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-4ed2-995b-08dc574705c2 X-MS-Exchange-CrossTenant-AuthSource: GV1P250MB0737.EURP250.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Apr 2024 21:09:33.2575 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8P250MB0234 Subject: [FFmpeg-devel] [PATCH 03/17] avcodec/ac3enc: Remove redundant channel layout checks 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: Andreas Rheinhardt Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: sH6CQA6ILfVD These are all checked generically via AVCodec.ch_layouts in encode_preinit_audio(). Signed-off-by: Andreas Rheinhardt --- libavcodec/ac3enc.c | 23 ++--------------------- 1 file changed, 2 insertions(+), 21 deletions(-) diff --git a/libavcodec/ac3enc.c b/libavcodec/ac3enc.c index f6456b2a22..1a65e35161 100644 --- a/libavcodec/ac3enc.c +++ b/libavcodec/ac3enc.c @@ -2189,17 +2189,12 @@ av_cold int ff_ac3_encode_close(AVCodecContext *avctx) /* * Set channel information during initialization. */ -static av_cold int set_channel_info(AVCodecContext *avctx) +static av_cold void set_channel_info(AVCodecContext *avctx) { AC3EncodeContext *s = avctx->priv_data; uint64_t mask = av_channel_layout_subset(&avctx->ch_layout, ~(uint64_t)0); int channels = avctx->ch_layout.nb_channels; - if (channels < 1 || channels > AC3_MAX_CHANNELS) - return AVERROR(EINVAL); - if (mask > 0x7FF) - return AVERROR(EINVAL); - s->lfe_on = !!(mask & AV_CH_LOW_FREQUENCY); s->channels = channels; s->fbw_channels = channels - s->lfe_on; @@ -2217,15 +2212,11 @@ static av_cold int set_channel_info(AVCodecContext *avctx) case AV_CH_LAYOUT_2_2: s->channel_mode = AC3_CHMODE_2F2R; break; case AV_CH_LAYOUT_5POINT0: case AV_CH_LAYOUT_5POINT0_BACK: s->channel_mode = AC3_CHMODE_3F2R; break; - default: - return AVERROR(EINVAL); } s->has_center = (s->channel_mode & 0x01) && s->channel_mode != AC3_CHMODE_MONO; s->has_surround = s->channel_mode & 0x04; s->channel_map = ac3_enc_channel_map[s->channel_mode][s->lfe_on]; - - return 0; } @@ -2234,17 +2225,7 @@ static av_cold int validate_options(AC3EncodeContext *s) AVCodecContext *avctx = s->avctx; int i, ret, max_sr; - /* validate channel layout */ - if (!avctx->ch_layout.nb_channels) { - av_log(avctx, AV_LOG_WARNING, "No channel layout specified. The " - "encoder will guess the layout, but it " - "might be incorrect.\n"); - } - ret = set_channel_info(avctx); - if (ret) { - av_log(avctx, AV_LOG_ERROR, "invalid channel layout\n"); - return ret; - } + set_channel_info(avctx); /* validate sample rate */ /* note: max_sr could be changed from 2 to 5 for E-AC-3 once we find a