From patchwork Sun Apr 7 21:09:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 47906 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:24a8:b0:1a3:b6bb:3029 with SMTP id m40csp2147335pzd; Sun, 7 Apr 2024 14:11:19 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVDbiMl3oNmfu34vGk0BPdK2ctvPddOLPWrg9Af8cj19kvp5/M6FvpRjP+dgfiInqel3oLkCT6e6FRe1MY6qdA26Yz9OR6k3rBveg== X-Google-Smtp-Source: AGHT+IEaIZ6OAxqA1xuQIu1ff/Bk72aw8cKrmOtwfnR9nQlMPcxX2IM9PuJ26e9P3cE3G4Ixr3lO X-Received: by 2002:a17:907:981:b0:a51:ab0f:57cb with SMTP id bf1-20020a170907098100b00a51ab0f57cbmr6699304ejc.11.1712524279219; Sun, 07 Apr 2024 14:11:19 -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 ka8-20020a170907990800b00a51d9d7ba8dsi119264ejc.865.2024.04.07.14.11.18; Sun, 07 Apr 2024 14:11: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=@outlook.com header.s=selector1 header.b=TQ4DrD8L; 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 D4ECC68D28B; Mon, 8 Apr 2024 00:10:00 +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-db5eur01olkn2083.outbound.protection.outlook.com [40.92.64.83]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id AF2F668D217 for ; Mon, 8 Apr 2024 00:09:50 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KK7znZe1NuBAhteeEZjhETSx36jxyhVhp6c81h1g7tALjNV38JulOyaWj+f9OhXe425a0StQ4iXtQuAyAlqSg4GPeffiYamMKj419cHirxCa9r4uVF0wrpfUIpk19mer0LknQHfAyw8MvS7rS50CJIlWEen2ejDAoNY0ePN2CaoG9YXDWo8ZfhJOzbQqy9Dw2YSX5jHiXSBJdrFJ1Bi8VBaWXB6Q8++XJNZlQ+JLI+JxOV5PrbnNAUhS7AeChXRuH1e/+60M8CEIBwmRTiHF9CUho2fX8QrPZBuyR+FVfhk2+9xW8GleTB7j+KTzJZAGhnIThlklM1hWR0/X4PixmA== 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=pl5NiK36Xoea/Ui1C5S9yM7W7BAnP7yd7oGLLl9cVOA=; b=jESUYZb4ZDw7m50czZmGqZu91kfMWx9UHaqiSjerVyn5wRQwVbWdu4wJJDLI0hzdCaXkLkwAgRYThLtEcov6G5TDEEjSP3Po0S1yB850OEyl08ykRsmjjCUWeeQbrXCClVW5G+OOJY244FLYa/bMsp3knD9ETkfVDHx9ehF4OmINAWFqHGgzGG+0OdiQbVXLJZH5CN0AEIHXbMLI9h7zu2CF+PNHDjn/NNURGn/rdNLCqOQavuWKem9pQbSlqQsveIvS/3G+DXirDxFw5oeGegYPRZc5qq8iQ5C9/Rn9iA2j+Qh2GGGKOBGnlG4jAemMcOvfK8HbD+o3ziFefOqWEQ== 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=pl5NiK36Xoea/Ui1C5S9yM7W7BAnP7yd7oGLLl9cVOA=; b=TQ4DrD8Lnh5mxiOtAS14xfbdSUjncOsYfnWB5/Z7KxbISKEttVOmQAcS5gbEzpz3IqfcOSUZ2R8CQgnhKjaD0Fl1zCbdURi+f9NS5BGEpvM54jhHwHVr2uzO++NJ2k4+aB431syKKD+BLi9EVlc3j0rnjOkcVXBkd9P5AqTnP4JJML/d3WywjBj0Grb3gSiUx/jB7lY5b6VLyx9xjY3rWN+6bvPt3sTit8GxT8j1bhnmlOH/tC2ZsPYj/nFnZffj1T4HpCYf9QW4pojl7M71v0ORbuWHHGzNa6c4P0ZBYAnUUx21zeTw15N8KhLK3MlbDtClrbqoD761EMYjG5YVmQ== 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:44 +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:44 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Sun, 7 Apr 2024 23:09:13 +0200 Message-ID: X-Mailer: git-send-email 2.40.1 In-Reply-To: References: X-TMN: [iPxG3PVjn+vAKObVh1TL8aOow0FufQVZjFOr2Lb3vJ0=] 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-14-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: 65815d69-2a94-4290-888b-08dc57470c9c X-MS-Exchange-SLBlob-MailProps: quCBMN2EvO+2u7sZ7OSLhMIkTSfckR5UDgfYLoq90h1Za5OCCXwtm9B/7WjNIlrvzyN8GUcooIYgsRun5vimHiY0Oy0YMIlA3zB+bIgdu6DRyIRgEELjIY/lI/NWJQuWqVqvoeh00yeuoCh91k+DjF5kTLg0LfprcPyHrwbxSQDSyNsjBXAqQbhYUsG74t7MULl9dXp5EliE8lMcLNOzsmMwQCVJsE6SgKS8vSNXN73WoGv4uCFyEv5oP6B3MmoryoNCwek2B1YCoWoEiRiAb31gh2p0SVe6IwnFgGn6i3GVFvXhiawsAUCuzNPHZPZf7GIUjzwcwZIwiyDTPjNIA2bhG1MKs/S+ln4eIbfqKGXcHZhuL47zteOhjGepPaFrEWhkbwzh6iftZL2D2YUlj7vB97adNq4GtqUi6dDHy3qthtNQGXR0W/ZWfppN0VI589c5vpLa6hvFRWZGu+ZRlHwN1lFhqXgfOvIMYCxTRxOpGREeIAtnamqpsyujXYNuadwP0slXU7n0w23xwX7h7LAWhE+SFFzpe7x8nWYhwYmvtiLtKXhNrtUjyrMeO+pkxPIzSs3bD9m1JdTIhzA3cYIWmBT8+BQ1woKrLMdQm03PJKWC/1RDcKg6tfP9mNjUntd+Joz8/wDLfazM+UgWgw2T0kvKNaT3XQJWnP3q6Je6CKCchtvF1tEZ10kslre13RUhE3QP3vA3/esU5Tyhgg== X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: nsZ1ti3Af/uQN01WuhixpPjN0aH0PvXQxsX8wQFyjlxNJEmzdI57HjVVowG2qk00P2jjhz7Da1G1B4+n2AJaf+7v/NMQmjc9m7U5w4XWWxkwHdADFRhlerVOFUJ4Hrml/mKzEfD2Oiw7rKzQY0K1pX1qmfj4Zgo3wfs8TquZXWkMftF6/OIFAbJBmsEoOsutSnaYs4+yRWmJQDcm016+jdVojwmJOiWN0SFjrEOA04rs3nrYTKhZQUGPkjMRXbOH6lo3b/L7OW2Y5GkVLyJ7Y9I4/K4MtkgujSUzVMpcENIb7mTz+dQ+2fhMCt39vvaOuaBbjPBKhl4SC0Jw+pxVHirIFoEExsfaMSSkfqEI/pEXdRH1HEZnYg6KT77N878g6EUSHVIxj7tKAdyM5+hh6ra207xW0RoB2C+oZvPqKit1RPjveFTPC5swrFJeccZVye6oBafgd+rnSJLm23EyzfiHKtMIgOrX2GEgQlyCWt9x5GUZhPKedMEAbrbLKKZ9qkj/b+g40twAHt7jX1wLtO1bMAefyojtj1XXDKOczl2JAtLweW9oqUkSgksjyCJH0afKVGXtR2cmO49bG+gAj9rXybIH5XvMMq2yo7tM11Daml/GQ3+4H+E/tHC5Va7d X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: jh6j+vsAjU6ucPXTBStZ4Ju/flT+5CJVltOsggJU+eDTyPAd0lEDyula6VRYcbbKbYwEd6dvgqXTTBdWxXUui4Q6K5oyXxVltA9uUPZfwboUfwKRqRBIlsI6ndYr0dleC4pkkiox1YO5tC49uTVbsobtAtQ8QhhgfjaPbeA7p1LUthEu5W0y0AZr74v+o/MdAbCcub8i+fF9HwUEqHfdThxO8aOKOH9+189lt7yyz/a1VA5VLI6NPZFPDrIU4coOprOjhDR+S5+QOlw0/VeBspSQAr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c57470c9c 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:44.7324 (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 15/17] avcodec/ac3enc: Move EAC-3 specific initialization to eac3enc.c 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: +pKlwgPeNAqf Signed-off-by: Andreas Rheinhardt --- libavcodec/ac3enc.c | 8 +------- libavcodec/eac3enc.c | 26 ++++++++++++++++++++++---- libavcodec/eac3enc.h | 10 ---------- 3 files changed, 23 insertions(+), 21 deletions(-) diff --git a/libavcodec/ac3enc.c b/libavcodec/ac3enc.c index 8ad89b6a84..f520e72fc0 100644 --- a/libavcodec/ac3enc.c +++ b/libavcodec/ac3enc.c @@ -2554,8 +2554,6 @@ av_cold int ff_ac3_encode_init(AVCodecContext *avctx) s->avctx = avctx; - s->eac3 = avctx->codec_id == AV_CODEC_ID_EAC3; - ret = validate_options(s); if (ret) return ret; @@ -2578,11 +2576,7 @@ av_cold int ff_ac3_encode_init(AVCodecContext *avctx) s->crc_inv[1] = pow_poly((CRC16_POLY >> 1), (8 * frame_size_58) - 16, CRC16_POLY); } - if (CONFIG_EAC3_ENCODER && s->eac3) { - static AVOnce init_static_once_eac3 = AV_ONCE_INIT; - ff_thread_once(&init_static_once_eac3, ff_eac3_exponent_init); - s->output_frame_header = ff_eac3_output_frame_header; - } else + if (!s->output_frame_header) s->output_frame_header = ac3_output_frame_header; set_bandwidth(s); diff --git a/libavcodec/eac3enc.c b/libavcodec/eac3enc.c index 1ee140f13a..c957174a70 100644 --- a/libavcodec/eac3enc.c +++ b/libavcodec/eac3enc.c @@ -27,6 +27,7 @@ #define AC3ENC_FLOAT 1 #include "libavutil/attributes.h" +#include "libavutil/thread.h" #include "ac3enc.h" #include "codec_internal.h" #include "eac3enc.h" @@ -47,7 +48,10 @@ static const AVClass eac3enc_class = { static int8_t eac3_frame_expstr_index_tab[3][4][4][4][4][4]; -av_cold void ff_eac3_exponent_init(void) +/** + * Initialize E-AC-3 exponent tables. + */ +static av_cold void eac3_exponent_init(void) { int i; @@ -122,8 +126,10 @@ void ff_eac3_set_cpl_states(AC3EncodeContext *s) } } - -void ff_eac3_output_frame_header(AC3EncodeContext *s) +/** + * Write the E-AC-3 frame header to the output bitstream. + */ +static void eac3_output_frame_header(AC3EncodeContext *s) { int blk, ch; AC3EncOptions *opt = &s->options; @@ -243,6 +249,18 @@ void ff_eac3_output_frame_header(AC3EncodeContext *s) put_bits(&s->pb, 1, 0); } +static av_cold int eac3_encode_init(AVCodecContext *avctx) +{ + static AVOnce init_static_once = AV_ONCE_INIT; + AC3EncodeContext *s = avctx->priv_data; + + s->eac3 = 1; + s->output_frame_header = eac3_output_frame_header; + + ff_thread_once(&init_static_once, eac3_exponent_init); + + return ff_ac3_float_encode_init(avctx); +} const FFCodec ff_eac3_encoder = { .p.name = "eac3", @@ -251,7 +269,7 @@ const FFCodec ff_eac3_encoder = { .p.id = AV_CODEC_ID_EAC3, .p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE, .priv_data_size = sizeof(AC3EncodeContext), - .init = ff_ac3_float_encode_init, + .init = eac3_encode_init, FF_CODEC_ENCODE_CB(ff_ac3_encode_frame), .close = ff_ac3_encode_close, .p.sample_fmts = (const enum AVSampleFormat[]){ AV_SAMPLE_FMT_FLTP, diff --git a/libavcodec/eac3enc.h b/libavcodec/eac3enc.h index 7d6155975d..0523de411b 100644 --- a/libavcodec/eac3enc.h +++ b/libavcodec/eac3enc.h @@ -29,11 +29,6 @@ #include "ac3enc.h" -/** - * Initialize E-AC-3 exponent tables. - */ -void ff_eac3_exponent_init(void); - /** * Determine frame exponent strategy use and indices. */ @@ -46,9 +41,4 @@ void ff_eac3_get_frame_exp_strategy(AC3EncodeContext *s); */ void ff_eac3_set_cpl_states(AC3EncodeContext *s); -/** - * Write the E-AC-3 frame header to the output bitstream. - */ -void ff_eac3_output_frame_header(AC3EncodeContext *s); - #endif /* AVCODEC_EAC3ENC_H */