From patchwork Sun Apr 14 18:30: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: 48052 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a21:670b:b0:1a9:af23:56c1 with SMTP id wh11csp1407242pzb; Sun, 14 Apr 2024 11:30:23 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWWKf9gzQoD8RjVvgJIUPH9153WxiGfINHsHZJfyTGFuGUvgQ7KVSex9VmjMxoswZzMGiGuLMNG5Ha5x96J7LSm9SwrzKR2LGoYNw== X-Google-Smtp-Source: AGHT+IHObjbN3TulSNobFK5iuA7v4XyLuNL5Ozg4sZ7K5tOrlHPlfbqBG4yNo1dUhjrtWx9HZ0iw X-Received: by 2002:a17:906:66d5:b0:a51:dc1f:a3b1 with SMTP id k21-20020a17090666d500b00a51dc1fa3b1mr4874661ejp.39.1713119423353; Sun, 14 Apr 2024 11:30:23 -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 h18-20020a17090619d200b00a51ddc6f9b7si3875685ejd.661.2024.04.14.11.30.22; Sun, 14 Apr 2024 11:30:23 -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=M859EnPb; 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 D846C68D35B; Sun, 14 Apr 2024 21:30:20 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR02-DB5-obe.outbound.protection.outlook.com (mail-db5eur02olkn2096.outbound.protection.outlook.com [40.92.50.96]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id DA30168D075 for ; Sun, 14 Apr 2024 21:30:13 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bJ+JRsCdKHqjHaLgH6h8IJwUE1CSX6Jzh0uodRb6OppdiQOFTk3vyuPYcwSSU7qCgznoCKSyd88A4baT8RifQxsaac/ujOSCEhWXXE4qBQ3w9i/Dp1dCyOBXJczKDnVkuJS9pGwmKS1epbfFGtBypYI3+R/mrgw7LfwDi+d2UOsxTQD9tbSOSWwhMUOoVd1m1TAhxDvwNmG7+RX7XYJP0onVmFHXON9L87n1z8tAeEKlUgQLQkgoY8DpPS0v4GdN6V0ygT2IUrYV6m5cegIjWWds45TEHM6TBcHtIwt/Qo/d2IsINclt8tk6Tw6MlToHw0RDiJ8qv1OYlNOD9vKWxw== 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=8P5j397Yj7aAXPReshifsxWpeCp/QeXiCl96ag5mNvg=; b=k+D2Dj/5IOh531ZMZLsm/drAlJe03QIzu/J9q9Y8qGX7/8kFkpMxsKEcBHGN7xO5+ssIcPg49Z2Trf+LYBLa4NsXQRjniOC7xPq36wwnRZduoaz/DNLZQ4iE+WZXcj9YZUvsdrXBfeJUTGgQRCQiauSUrhglshGMu63AFroiR514mQPWiQWbmlnd5reDztCD/TdX37ea4j/5OZP0JxxlLRdILzNDm9GxG/qZa7A3uf4IbEVEYdTWhAtAfr7b0PriHfhzMDUz6yW1w+dMrrObcJQlm0isgpfsvcyBy0JThex5h2D+LIgusZ7tn9nfPhyIbqmstMa9N2SrAfnzGUaAIA== 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=8P5j397Yj7aAXPReshifsxWpeCp/QeXiCl96ag5mNvg=; b=M859EnPbbclAikMOYQ906xRXnFZauNcRdITToQjuReGyJMwDr9OY5e9WF9fjiIrUfUGKTonbNu+FlOIXGrx3qTxToJjlO8jQJSJrPkNpW8LLn3EnbldoF4JmlX4WqC3ROirT4lM9gzaYGe54uW1TcBjnd6I830cnLv79nWNnGkWrcZ/pgM8SFhRSzQsmdT2CFns6q1GSRVoHw9M2DAJxWHvsoq7ipPFWyu7qRohHknHkcVGAzavnleP39qMQs8BsOBgT9zZ4obZpWLbJtSL5EfgOc++9+uEnJyL8V8ZQuJPduutu/SDuwLL/+Q8zxoa8h5syegShsAvpxJ7M11qDIw== Received: from AS8P250MB0744.EURP250.PROD.OUTLOOK.COM (2603:10a6:20b:541::14) by PR3P250MB0305.EURP250.PROD.OUTLOOK.COM (2603:10a6:102:17c::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7409.55; Sun, 14 Apr 2024 18:30:12 +0000 Received: from AS8P250MB0744.EURP250.PROD.OUTLOOK.COM ([fe80::1f29:8206:b8c3:45bb]) by AS8P250MB0744.EURP250.PROD.OUTLOOK.COM ([fe80::1f29:8206:b8c3:45bb%3]) with mapi id 15.20.7409.042; Sun, 14 Apr 2024 18:30:12 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Sun, 14 Apr 2024 20:30:01 +0200 Message-ID: X-Mailer: git-send-email 2.40.1 In-Reply-To: References: X-TMN: [VvpWTdzvQH82mB5VM4vxgpbv6lTRCmEKWWHQogbmtBU=] X-ClientProxiedBy: LO2P265CA0374.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:a3::26) To AS8P250MB0744.EURP250.PROD.OUTLOOK.COM (2603:10a6:20b:541::14) X-Microsoft-Original-Message-ID: <20240414183005.3201646-1-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS8P250MB0744:EE_|PR3P250MB0305:EE_ X-MS-Office365-Filtering-Correlation-Id: 24719f5f-2775-4d3b-2bf6-08dc5cb0ebb1 X-MS-Exchange-SLBlob-MailProps: Cq7lScuPrnqixlJpeDAFCj+njEnnU0KRIC1zvmsB30JiiNXooqee8ODwcaxoUYPNln/XQWkFkPPInP6/ru/te/C/Aa4eEmnZUxGP3jmV+O1BfFqWNaIqIP9dVr1XhkR1yGgSeGU5UQ/OquwLmJ3cFgGvQ19H/+fFbtkIEBuOfo63+SkEF53tLOOoYDTQKujSt35xx/ZfWacV+iRtppI1pKe6MRbBP2p9s0HmOxssv0nQwuirFEEAXGVDevySDJsezxA5T5a9OWejVMraKwZ3SsJZlQpbxkf6DtXfrU7YMTmylV5h7qJvHKDQuKmkdaX413awY35i48aIVZUyNclbYA7qRexb5KfhIttp7iDhw7Xw89F/bX/0rT/25mJx8L0JAt4I7i9mRgG77mRdRzEhLsr3bam08/Nz/0YyCWEIzgGa4pN5GBDPqQMCP5K58Aom/hNMbuB8gav1gows+MdzlKJV4Scz/5GYaFuKiURtDOb/9QhTNJVqmTRHQ8mJ9Nkp+bwEafyu1MDp068q2JhG2E2fsNjUVjjsRkuDjkceIv8xK/rgHf0tAXEE3ArQ2l8q4EPftvvemYaYn6QZCDbR+33hV5ckp1pbLMgovFm/Wg24ogsrOSy/oeegwExrm/WJ6bJ6n/qt+sh6DUAQjNiHaDcHKtU1oXWklJh+zrQmE1cfuS/XUwbHCP6YD4HbGrHUvEHdDV7uILRWpUEuT5nLOSsfQnA6hbNkBgHcbsk2hYj3CPu1g6IUbNOr5Sn2YS/VvFtgau2Zldg= X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: an2Mzt85KRdh60koUDBxIgbfIUS6/JTC7ABw6WALt45+2hE/c/U7zZnq0V6Ori0SFgGh1d1hOb1j0LNH/5ALiDWJ7De5gqXYl+WSO+5mH72hbfGHhQkbryvZQf0zYxqScHE4ZjYo7kRQGOKLKXHpCDNnpE2rGscsaU0gcsMXEQjZyaSZXurGmRsGuwM0feunB6K3c1tcL2kqXjN+ZZVhbS/3aTRKt6+VLSIvUfHpIDTFQWYVi8NQ0fVIJZPdzogBdM/Cf7FgFrHg/OVnYP5wfqKeC330pRdVz7Y68XWgnZMb0EHd7lL96//5hT7DUKz0ioj8aKzDFZxJ1HTg5PGHIJmJ9unJ+BZJcij7e37NalvonNtugF9ObnOdmRgsFWkAeaMKcnp4TMJZf6tDb/3+8wuUI578frei70MKKBRtv+jAv3uK0afo+EUP95guyiqHlr/ygM4bhPv11vDfcOgLQhuq/qTNdlQvzixezodjrjaCW/MvoC/SS3hQ6Yitzf4pNY0/nSQWoNSlnjZvRwnCO5nQV/7yKwqvl9Gbgn1Gtm2VBOGl7C0CBA2vqJNDiuUiF+amkDBTje3GVvoAGQqqYqcad/eEKMVheNJnyeaggoNGzo9fc1SigNpRem7Spm5J X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 2MvCP93N5jHA4k4jFA0E0QI09iCM+DAf6RZj0yX0HDOyEuhWL8zB/aVpjVogr65sP/3rODKap7hI6dZU2UqwPvYyyMMt9+c9sW0CbErfXKmzizsHZTbPDpGfQfki2wRSGCc6sUZvL8S/JQVpsBIJCRuR/EB+y6JNLPuq6276S5VhoTjDlNLDFYOIFrwHbvLxP3sPULGwin4rree9b4AZ4FlcsZ687FH/bjA+nL/Ylges724iLje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ossTenant-Network-Message-Id: 24719f5f-2775-4d3b-2bf6-08dc5cb0ebb1 X-MS-Exchange-CrossTenant-AuthSource: AS8P250MB0744.EURP250.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Apr 2024 18:30:12.0252 (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: PR3P250MB0305 Subject: [FFmpeg-devel] [PATCH 2/6] avcodec/ac3enc: Avoid allocation for mdct_window 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: QuC7rCB2reMR Signed-off-by: Andreas Rheinhardt --- libavcodec/ac3enc.c | 1 - libavcodec/ac3enc.h | 5 ++++- libavcodec/ac3enc_fixed.c | 7 +------ libavcodec/ac3enc_float.c | 7 +------ libavcodec/ac3enc_template.c | 4 ++-- 5 files changed, 8 insertions(+), 16 deletions(-) diff --git a/libavcodec/ac3enc.c b/libavcodec/ac3enc.c index a31b528597..a3a05b3ac8 100644 --- a/libavcodec/ac3enc.c +++ b/libavcodec/ac3enc.c @@ -2183,7 +2183,6 @@ av_cold int ff_ac3_encode_close(AVCodecContext *avctx) int blk, ch; AC3EncodeContext *s = avctx->priv_data; - av_freep(&s->mdct_window); if (s->planar_samples) for (ch = 0; ch < s->channels; ch++) av_freep(&s->planar_samples[ch]); diff --git a/libavcodec/ac3enc.h b/libavcodec/ac3enc.h index 618c952a18..41b9a3a20b 100644 --- a/libavcodec/ac3enc.h +++ b/libavcodec/ac3enc.h @@ -169,7 +169,6 @@ typedef struct AC3EncodeContext { AC3DSPContext ac3dsp; ///< AC-3 optimized functions AVTXContext *tx; ///< FFT context for MDCT calculation av_tx_fn tx_fn; - const SampleType *mdct_window; ///< MDCT window function array AC3Block blocks[AC3_MAX_BLOCKS]; ///< per-block info @@ -260,6 +259,10 @@ typedef struct AC3EncodeContext { /* AC-3 vs. E-AC-3 function pointers */ void (*output_frame_header)(struct AC3EncodeContext *s); + union { + DECLARE_ALIGNED(32, float, mdct_window_float)[AC3_BLOCK_SIZE]; + DECLARE_ALIGNED(32, int32_t, mdct_window_fixed)[AC3_BLOCK_SIZE]; + }; union { DECLARE_ALIGNED(32, float, windowed_samples_float)[AC3_WINDOW_SIZE]; DECLARE_ALIGNED(32, int32_t, windowed_samples_fixed)[AC3_WINDOW_SIZE]; diff --git a/libavcodec/ac3enc_fixed.c b/libavcodec/ac3enc_fixed.c index d2f4cecd72..869e1f27a2 100644 --- a/libavcodec/ac3enc_fixed.c +++ b/libavcodec/ac3enc_fixed.c @@ -27,7 +27,6 @@ */ #define AC3ENC_FLOAT 0 -#include "libavutil/mem.h" #include "audiodsp.h" #include "ac3enc.h" #include "codec_internal.h" @@ -79,16 +78,12 @@ static av_cold int ac3_fixed_mdct_init(AVCodecContext *avctx, AC3EncodeContext * float fwin[AC3_BLOCK_SIZE]; const float scale = -1.0f; - int32_t *iwin = av_malloc_array(AC3_BLOCK_SIZE, sizeof(*iwin)); - if (!iwin) - return AVERROR(ENOMEM); + int32_t *iwin = s->mdct_window_fixed; ff_kbd_window_init(fwin, 5.0, AC3_BLOCK_SIZE); for (int i = 0; i < AC3_BLOCK_SIZE; i++) iwin[i] = lrintf(fwin[i] * (1 << 22)); - s->mdct_window = iwin; - s->fdsp = avpriv_alloc_fixed_dsp(avctx->flags & AV_CODEC_FLAG_BITEXACT); if (!s->fdsp) return AVERROR(ENOMEM); diff --git a/libavcodec/ac3enc_float.c b/libavcodec/ac3enc_float.c index cfd233da09..94e8ebc42d 100644 --- a/libavcodec/ac3enc_float.c +++ b/libavcodec/ac3enc_float.c @@ -27,7 +27,6 @@ */ #define AC3ENC_FLOAT 1 -#include "libavutil/mem.h" #include "audiodsp.h" #include "ac3enc.h" #include "codec_internal.h" @@ -87,12 +86,8 @@ static void sum_square_butterfly(AC3EncodeContext *s, float sum[4], static av_cold int ac3_float_mdct_init(AC3EncodeContext *s) { const float scale = -2.0 / AC3_WINDOW_SIZE; - float *window = av_malloc_array(AC3_BLOCK_SIZE, sizeof(*window)); - if (!window) - return AVERROR(ENOMEM); - ff_kbd_window_init(window, 5.0, AC3_BLOCK_SIZE); - s->mdct_window = window; + ff_kbd_window_init(s->mdct_window_float, 5.0, AC3_BLOCK_SIZE); return av_tx_init(&s->tx, &s->tx_fn, AV_TX_FLOAT_MDCT, 0, AC3_BLOCK_SIZE, &scale, 0); diff --git a/libavcodec/ac3enc_template.c b/libavcodec/ac3enc_template.c index 6070e14961..698042ae5c 100644 --- a/libavcodec/ac3enc_template.c +++ b/libavcodec/ac3enc_template.c @@ -59,10 +59,10 @@ static void apply_mdct(AC3EncodeContext *s) SampleType *windowed_samples = s->RENAME(windowed_samples); s->fdsp->vector_fmul(windowed_samples, input_samples, - s->mdct_window, AC3_BLOCK_SIZE); + s->RENAME(mdct_window), AC3_BLOCK_SIZE); s->fdsp->vector_fmul_reverse(windowed_samples + AC3_BLOCK_SIZE, &input_samples[AC3_BLOCK_SIZE], - s->mdct_window, AC3_BLOCK_SIZE); + s->RENAME(mdct_window), AC3_BLOCK_SIZE); s->tx_fn(s->tx, block->mdct_coef[ch+1], windowed_samples, sizeof(*windowed_samples));