From patchwork Sun Apr 14 18:28:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 48051 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a21:670b:b0:1a9:af23:56c1 with SMTP id wh11csp1406644pzb; Sun, 14 Apr 2024 11:28:40 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXlpMeI/pRPiN+2eySn5j4g6t0c5O7IIZ4dqvL+7DAeNYs5zTX2e8FY5HzpWxYnpBM3MPfVHqhOutwCk0f84vIC2rOrCjqRgk/tzw== X-Google-Smtp-Source: AGHT+IEVQO8+qTxPLFJJuLC17LojowC3+G5Qppdl434WzmDZLDCA4Q0zcufqJEgFj4wj4YY0kOMF X-Received: by 2002:a17:907:3607:b0:a52:54f2:6ae6 with SMTP id bk7-20020a170907360700b00a5254f26ae6mr2556520ejc.1.1713119320110; Sun, 14 Apr 2024 11:28:40 -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 bq24-20020a170906d0d800b00a4e7ebb78adsi3679492ejb.274.2024.04.14.11.28.39; Sun, 14 Apr 2024 11:28:40 -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=JEIIz69P; 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 7298B68D22E; Sun, 14 Apr 2024 21:28:35 +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-db5eur02olkn2064.outbound.protection.outlook.com [40.92.50.64]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 47A2D68004A for ; Sun, 14 Apr 2024 21:28:28 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=d/iho55i97d6pDUZ71q2diTvA38MU/CJvOxUWmcQd5Nj1TKZ0MdcLLzF6zryE0x9UtAeIolW8elUYBz9Ebu4BW82c3fyR7Hh3I4GicutYuZN4+0traEBVcMJ9mH28XcvnE8EHFMQHyPMBh2L/zV39ptysPJRpybsBO5MWjVoNAuUk8h9oO8GdZjc862dj+wRNYBYa4h4B4VAQ4pbhGKJy6Rn3AmyHlTFpRDNlz93BAGjOriHrAuFf3yQge9/hb+JuLRonAuAeN7OVJZBM8lkVPcXFB344wAxqcnYyMiGdyPANuUn42nYgw+7k4Ste+wlbt7bXFSHrb9TVJiPh1eQpA== 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=3sD/RsZ8k5fri4MD+zN7TvFBPlTGuI5VLAQlelJwDE0=; b=nujEa/vPg5+5prenikFPykC3a8+szXR+sl1AaKQNy5bgbFjdjQL5nH4jwSi3t7/kcefcfds6YuyoegHyuVre3/N+Os0Wts9iHQpZkm/uRJX7dac4weHMqu3b/bEftl4Xqw+wr9Tjv3z9chQgvvRFgsulAILkHW89V4Nlh7+PsBbEDt9Bp8wwyJoQNDH2fTEbCpMWBAdx7oJAkFlk/FKtTsSdTKVs8jp5PjiJmvnxWsUqI5oqMaPkGaPG9rf6Y5u0meBOwfiAwylwUomXE7PTsCm3rajfJRL/CNPG40PWxs5vCwuLHUJ9eE+dk/t0OHqoEYeqdZctjlmrzYQF1/XsQw== 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=3sD/RsZ8k5fri4MD+zN7TvFBPlTGuI5VLAQlelJwDE0=; b=JEIIz69PJgo5jBIvZb+s7NWu89NA6mcpy9m6apzMcTUM7XpqKuYa6KW1j0EfmorZL9x/Vr+mwoI8okFaIwcFJuhSTE2Wb8cETQJaJ/bGjYMM+h19FXyrSr3YXoh71/Ued3544BLT4r/5MLK193W6zEZSi/uunw2FgC9MWt0xDpvUs4IN66JINqv2OnO6IxdvKdvvlWQcW1tQVhbRKopKV6xl3geS4X52am/jFeSt6aHxy5lDYtINNFzaTE28iIgSJIY4Ikdq21By/ohgzIq7zAZWZTicge2T6s8sB8yKZASRpvPVBmCrkEPKlXE2vQNwz+JFdBHQwsrYoBslWoFijQ== 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:28:25 +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:28:25 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Sun, 14 Apr 2024 20:28:12 +0200 Message-ID: X-Mailer: git-send-email 2.40.1 X-TMN: [Or3kX1JMXmLISkZb8UFgWysYzTl5b6+MzYfV2wMR/CE=] X-ClientProxiedBy: ZR2P278CA0083.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:65::9) To AS8P250MB0744.EURP250.PROD.OUTLOOK.COM (2603:10a6:20b:541::14) X-Microsoft-Original-Message-ID: <20240414182817.3201228-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: 13e6a16e-22a2-4036-09ad-08dc5cb0abe0 X-MS-Exchange-SLBlob-MailProps: Cq7lScuPrnqixlJpeDAFCj+njEnnU0KRpUsco+yot7RV4Y9gcVtVlsKWLpLz+WQ5997O8RIesMmbSz94PGUX1fKfg0RAtFcDx7paOPhINu9YEELOJ0CMxUimJAb9bXLH48q0vWmZNjh5+1mQIIFNkT4DQiOBsk73CGbHWwjWrATTkMcGRCgAofYgkLXwu7XPU3kSjDmGievZEBQ/B7OiHDsIxoJL6R6zzwwurz5XGF4hR9QRNyWXlcikcFM3ApnKpVJ3SOpBsJjrpPHnSnoipk2+NjEXSJ6f8JLHI3zO5F0sXg+p/YT+KWSLJ83s+Ga7ZpY+fZTz2r6XBXFuA1kdNrtDNoS2CcE183WpqV0xR8imHQrlOugdWzJz+lPSWYbHDbmUoZBAP03oHvgxOpZahox343Cm2Vj1JBy4JA6zwGqyQ3iXxU2pNt9fIsITtMXangPDX42CBr8t7/HsQydu7pRKZ3ZcEukL5lQFcLeUjg6Pc3+IaXYhdIcWI05wtUJcBYsBf8CBLhLYS7TCA4zGwHMk58UBXiIr+wxFAemT+sWhQRysmWveOd/hX5CZMGkQuTgOkVJKlVFe3nt7UAxUSIYqsrPDXkYf6Y0M9aAh3rsXv33iAs87D9e4AI69ybifJ8lMdeRC9ZX4pWcn6pkCPWy/m+Edl3sh7qGx2BJMRRp3WzYHp9NZeOmlxRkPwgVTrjNcFVy/s20naUNt38+r7bk7Ij7Pcyvap4wBt+4lrcumeEtGugvr9yRl+T1GrSPljZDrsXc/s4E= X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: GckAUMV9ZCke4bYDN6RyaLeJvnJKuidATzjcX215N3app8xf6hIctg30y7mRLnfycDZ/fZpr/EDZaI95Z7HAvy2p4pxdkZQgeEC24yPRiv7Gg+QduoxBoXtidjNzpQnkdcxxEa1q0pZDW9UWtmbXBInLANY9PH/fYQ2lJe5ETrEhmABjwUzU7+Xuzu8xCbf/rikXt5Eejeokp73fXPfYg55jpi/HY2OqqM61YgZekkYTcW+41lIK2fetTNIgEg/GItD18vhQmoFjuEBQEyxDdfFPWVS2TPj0+sNEHVImHBQzGse1gy6jrY4U5UCk1I8+wuSVy6wzYpolIf0pwHWSXMW/v6ywEg5CqV+Nvez0Yd9vuf82535t7K7nhu3qlLfjz3qPsnc4Zqgfstjvg/5hFzR8spC2Np6+A+kJDB/Ce7hynyjX4ttl8ozeYKESNktUYRGzbBrGx3uECy75Nlf8HUjiQ3tz88GQEOxl327hVSMFNy89CcO7MlBj/QXlDQWumMdID+BdU4sO0TDIvZLdzyF7Ov4wFTkUGtEVhXJxxItSypfOrIwW4v/iojtK3PGgTH91FnRSG6UzPQoGm6bsLN4omf1uhCDOjIgH63kP42CQsoFYeC+E1cIvQDbE/HMO X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: iIcVucoWAhNPsEAMyPWyXL6CNO6/pZ1aeelUufod7gp3qjyXknhvYENVf4x2yNzdqHb3xrTBOrILtHv42BhCtmjxxmoRdsVsndvFqJZ150bgB1aKX7B/S/jAMf1MCD2Smmp0Tui6BW4Nawy3xTZZNgXxoj/GAphHZhpbjXn8XL5e7GtcSqub/sR8C6SA0i5hgpVVGseEhiTC3ZBVyXND2gpPqNj9pFy3ynDcLirL+ZgevHSZQG173AK0L8z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CrossTenant-Network-Message-Id: 13e6a16e-22a2-4036-09ad-08dc5cb0abe0 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:28:24.9706 (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 1/6] avcodec/ac3enc: Avoid allocation for windowed_samples 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: luWWz0HEKrEW Signed-off-by: Andreas Rheinhardt --- libavcodec/ac3enc.c | 4 ---- libavcodec/ac3enc.h | 7 ++++++- libavcodec/ac3enc_template.c | 12 +++++++++--- 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/libavcodec/ac3enc.c b/libavcodec/ac3enc.c index 1ba4ba549e..a31b528597 100644 --- a/libavcodec/ac3enc.c +++ b/libavcodec/ac3enc.c @@ -2184,7 +2184,6 @@ av_cold int ff_ac3_encode_close(AVCodecContext *avctx) AC3EncodeContext *s = avctx->priv_data; av_freep(&s->mdct_window); - av_freep(&s->windowed_samples); if (s->planar_samples) for (ch = 0; ch < s->channels; ch++) av_freep(&s->planar_samples[ch]); @@ -2459,9 +2458,6 @@ static av_cold int allocate_buffers(AC3EncodeContext *s) int total_coefs = AC3_MAX_COEFS * channel_blocks; const unsigned sampletype_size = SAMPLETYPE_SIZE(s); - if (!(s->windowed_samples = av_malloc(sampletype_size * AC3_WINDOW_SIZE))) - return AVERROR(ENOMEM); - if (!FF_ALLOCZ_TYPED_ARRAY(s->planar_samples, s->channels)) return AVERROR(ENOMEM); diff --git a/libavcodec/ac3enc.h b/libavcodec/ac3enc.h index 227744d27f..618c952a18 100644 --- a/libavcodec/ac3enc.h +++ b/libavcodec/ac3enc.h @@ -30,6 +30,7 @@ #include +#include "libavutil/mem_internal.h" #include "libavutil/opt.h" #include "libavutil/tx.h" @@ -232,7 +233,6 @@ typedef struct AC3EncodeContext { int frame_bits; ///< all frame bits except exponents and mantissas int exponent_bits; ///< number of bits used for exponents - void *windowed_samples; uint8_t **planar_samples; uint8_t *bap_buffer; uint8_t *bap1_buffer; @@ -259,6 +259,11 @@ typedef struct AC3EncodeContext { /* AC-3 vs. E-AC-3 function pointers */ void (*output_frame_header)(struct AC3EncodeContext *s); + + union { + DECLARE_ALIGNED(32, float, windowed_samples_float)[AC3_WINDOW_SIZE]; + DECLARE_ALIGNED(32, int32_t, windowed_samples_fixed)[AC3_WINDOW_SIZE]; + }; } AC3EncodeContext; extern const AVChannelLayout ff_ac3_ch_layouts[19]; diff --git a/libavcodec/ac3enc_template.c b/libavcodec/ac3enc_template.c index b0f9e69ee8..6070e14961 100644 --- a/libavcodec/ac3enc_template.c +++ b/libavcodec/ac3enc_template.c @@ -37,6 +37,11 @@ #include "ac3enc.h" #include "eac3enc.h" +#if AC3ENC_FLOAT +#define RENAME(element) element ## _float +#else +#define RENAME(element) element ## _fixed +#endif /* * Apply the MDCT to input samples to generate frequency coefficients. @@ -51,15 +56,16 @@ static void apply_mdct(AC3EncodeContext *s) for (blk = 0; blk < s->num_blocks; blk++) { AC3Block *block = &s->blocks[blk]; const SampleType *input_samples = (SampleType*)s->planar_samples[ch] + blk * AC3_BLOCK_SIZE; + SampleType *windowed_samples = s->RENAME(windowed_samples); - s->fdsp->vector_fmul(s->windowed_samples, input_samples, + s->fdsp->vector_fmul(windowed_samples, input_samples, s->mdct_window, AC3_BLOCK_SIZE); - s->fdsp->vector_fmul_reverse((SampleType*)s->windowed_samples + 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->tx_fn(s->tx, block->mdct_coef[ch+1], - s->windowed_samples, sizeof(float)); + windowed_samples, sizeof(*windowed_samples)); } } }