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)); } } } 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/0YyCWE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YIhl2KmNrF2mzUmh6wr3xvWnJ8Jq2RpM+B0cImbczsPQleehIhNSZiV58MZFrkS7iO8sxuQnNHX9Yhlc2cJgd6tPUUjUq9WfJM4Pa0KiKlTb2aO7x08xkMSRmhnsyt3KMa8lULl1NzBv1IWYKOweS+71+ol5ooaXklrLsFLhKnEeMmO1Uyoqu2OwQ3kfX9wz7ZIzIwJtPgScuYUZU6QCx/HPmOeRLHNg== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-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)); From patchwork Sun Apr 14 18:30:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 48053 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a21:670b:b0:1a9:af23:56c1 with SMTP id wh11csp1407375pzb; Sun, 14 Apr 2024 11:30:41 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUe2ZxKmDFUH7CmmxWMZN+GqiPjAyQezsi7l8GLGjPbsXLIBaeFp6LHadLSPiRQWqVMtYkbcDFH6QFSLKo+Z8OcQRablVBeN9uiNg== X-Google-Smtp-Source: AGHT+IEvFDR+XaHZUg84WSxbXmYtSHPlQrUveDm5keVHFwth8QJ9Q46zSdbAB0ZtqiqeB/C/eBDD X-Received: by 2002:a50:cddc:0:b0:56d:c73f:98ab with SMTP id h28-20020a50cddc000000b0056dc73f98abmr7701239edj.19.1713119440637; Sun, 14 Apr 2024 11:30: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 w8-20020a056402268800b00570241f6321si552043edd.611.2024.04.14.11.30.40; Sun, 14 Apr 2024 11:30: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="T/7Aw42p"; 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 EA14168D3A4; Sun, 14 Apr 2024 21:30:37 +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-db5eur02olkn2085.outbound.protection.outlook.com [40.92.50.85]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id C467868D32E for ; Sun, 14 Apr 2024 21:30:30 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=TWX9NBeeuPz+b31tr/aEkHx0WZBBGnyaRjOgbXESdB+yQZKgf0G++zEvVW5yymGaMIS7bbikmLkcKeV+3iWSPZxwSr2l+iSGM+owVGNtDrgngagC0RX3jrpAb1a8Afj5Zxc2f17hrUEcB6yyPMfHN4Uqe9559a1ceS0jKQzTcX4JGxj7odyq55qKn8M/grOlgI8UAPPv7ECxJcq2UPv7ec4/jt9cTDvUGJ8a7Gev5VqPyrmduiiUBKzbcaY9gHw4FShXrCzzOunVKg0V6JNiCwtHU/mt1IW8Y2WAeMFz2aY9w8l355hTImAw3pk6nM7w2lyTH79k4zFJIz8W9CORsw== 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=S0k56OADrV72b3mMi9T5ltKZ+M/JV7o8ZUZutY8kbDs=; b=EGlUpqgl+XvX3fLv/ZdSNcVEdZ4JUC6dV5noQTuFjNrg6Z4kWFR0pThm1UveUHXbg48cuwXNMfWjU97HvZD5LS5ip4zWOcgEMFvHpx2bl7z4US0T0gq9rpXrpx0twl1zHvoueXbl9YTFxoRWC0M9cGynQMXwAy60rFzRoHSGhdg4XfYAG9Km2ucTZ/gjnIDwj3u0zXNjEkfxoamThyEoUH9odGqW3mwSeOCvEBSkgvshwxh8Cz48HhEpmuokc6fjVKG9f+mOLc7EM8c+lIXS2A2BYPV7NW35t8zYMOO9TIV7QgS19YdRJmu5zo7/OMxF5uHtxFSUw89NgqcfhJoNxw== 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=S0k56OADrV72b3mMi9T5ltKZ+M/JV7o8ZUZutY8kbDs=; b=T/7Aw42peuiTzIayJmcyxyj2aJcKhGHGtzZIvKP5qVQTv8IwZ9x7TrWg2mtpDjHjWhT9Pw94rJkIZU1pa0UzoqrbdcXJhvMzV7i+H8/oJPocHjcBTDt7OvZtBmkGcHmE5ij3uYDBt1u5/8i7xPK5PTv6lEXiQ57b8OQLEn6PjurlINdHqAKegJC0Et/J8UlGol+25qTjuwyMqwHycjK7ACUaqCugpvP7t95TPGexnLjpX5ZgoILCrXwrrdGxP7LdVlqTmik0dhgWFgk1lPPQOMW5QzdJM9q0XLfImqvg2263SzXxlEIcWWR/cC4ML4wevy5Nx4/EGAeYyaHyqdUf/g== 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:29 +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:29 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Sun, 14 Apr 2024 20:30:02 +0200 Message-ID: X-Mailer: git-send-email 2.40.1 In-Reply-To: References: X-TMN: [3VuscOpd++/3Pg/Klj5bJ7d7/C1nzVMPrD4/6SgZJlo=] 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-2-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: 6c067200-9934-4562-80aa-08dc5cb0f5ec X-MS-Exchange-SLBlob-MailProps: 9IecXKUgicBjqiCWzr+pRkDdXxvh1/bA1HHL1eIJ/Oc/gfEKX+MmRzYo/9Os0vQ1r+6DQQ5IRmBVixVuMgACvopFfk3oeTIWiHHuCv0Cb1PXMWJxDg4ptQlMUgONd8s6+PoUSCM4lZWTD0KpcAlAizVu9Mj07goVeLBFRKTzo30a1263jAV7zud07j41mrOCHmLeKZxif1WxcMrLb0k8w/VLfsjgMw9DwP1zG962HIIL8/X6LImDFxvE/4UT7fpJTNHKVSiEvywczCwV6fJCLooakWrde0EZTe8aWDqvz5zoJrx6iq8f9DPESALmuy7SSvEJmpEANT0je711nkJ1453C7ak2hGYxjztbG0XpG1mXKTpxbVx9czQOmUZoQZW0zwN/WpeToZsUn9kimcX+C/MUDH5dVxa2gzZ0m2ro0OYcMqv/Hks0c0ZF37Tcn9q4rxNDGDvHdbg5ca3ZIIxDFAl6hpk93BTzQ2ZHNGSGO227P4iCpt2cZbm9/yIfteaAMBNZU9yqjoYtgj09Q2sMCgkLlbup021mm6+ouFIXHWx3spnwyCo/32GAZYJ5en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JXQUJfag5V7CE/A9NRk7d1/iGe8t8Fu/f7A2WZltlMpYB71M0yYEFxuJYy0Gibd3FqtA== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6c067200-9934-4562-80aa-08dc5cb0f5ec 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:29.1521 (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 3/6] avcodec/ac3enc: Avoid indirections, allocations of small arrays 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: pm1X5lkoptnC Signed-off-by: Andreas Rheinhardt --- libavcodec/ac3enc.c | 44 ++++---------------------------------------- libavcodec/ac3enc.h | 22 +++++++++++----------- 2 files changed, 15 insertions(+), 51 deletions(-) diff --git a/libavcodec/ac3enc.c b/libavcodec/ac3enc.c index a3a05b3ac8..1ef670622a 100644 --- a/libavcodec/ac3enc.c +++ b/libavcodec/ac3enc.c @@ -2180,13 +2180,10 @@ static void dprint_options(AC3EncodeContext *s) */ av_cold int ff_ac3_encode_close(AVCodecContext *avctx) { - int blk, ch; AC3EncodeContext *s = avctx->priv_data; - if (s->planar_samples) - for (ch = 0; ch < s->channels; ch++) - av_freep(&s->planar_samples[ch]); - av_freep(&s->planar_samples); + for (int ch = 0; ch < s->channels; ch++) + av_freep(&s->planar_samples[ch]); av_freep(&s->bap_buffer); av_freep(&s->bap1_buffer); av_freep(&s->mdct_coef_buffer); @@ -2200,19 +2197,6 @@ av_cold int ff_ac3_encode_close(AVCodecContext *avctx) av_freep(&s->cpl_coord_exp_buffer); av_freep(&s->cpl_coord_mant_buffer); av_freep(&s->fdsp); - for (blk = 0; blk < s->num_blocks; blk++) { - AC3Block *block = &s->blocks[blk]; - av_freep(&block->mdct_coef); - av_freep(&block->fixed_coef); - av_freep(&block->exp); - av_freep(&block->grouped_exp); - av_freep(&block->psd); - av_freep(&block->band_psd); - av_freep(&block->mask); - av_freep(&block->qmant); - av_freep(&block->cpl_coord_exp); - av_freep(&block->cpl_coord_mant); - } av_tx_uninit(&s->tx); @@ -2457,9 +2441,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 (!FF_ALLOCZ_TYPED_ARRAY(s->planar_samples, s->channels)) - return AVERROR(ENOMEM); - for (int ch = 0; ch < s->channels; ch++) { s->planar_samples[ch] = av_mallocz((AC3_FRAME_SIZE + AC3_BLOCK_SIZE) * sampletype_size); @@ -2486,21 +2467,6 @@ static av_cold int allocate_buffers(AC3EncodeContext *s) for (blk = 0; blk < s->num_blocks; blk++) { AC3Block *block = &s->blocks[blk]; - if (!FF_ALLOCZ_TYPED_ARRAY(block->mdct_coef, channels) || - !FF_ALLOCZ_TYPED_ARRAY(block->exp, channels) || - !FF_ALLOCZ_TYPED_ARRAY(block->grouped_exp, channels) || - !FF_ALLOCZ_TYPED_ARRAY(block->psd, channels) || - !FF_ALLOCZ_TYPED_ARRAY(block->band_psd, channels) || - !FF_ALLOCZ_TYPED_ARRAY(block->mask, channels) || - !FF_ALLOCZ_TYPED_ARRAY(block->qmant, channels)) - return AVERROR(ENOMEM); - - if (s->cpl_enabled) { - if (!FF_ALLOCZ_TYPED_ARRAY(block->cpl_coord_exp, channels) || - !FF_ALLOCZ_TYPED_ARRAY(block->cpl_coord_mant, channels)) - return AVERROR(ENOMEM); - } - for (ch = 0; ch < channels; ch++) { /* arrangement: block, channel, coeff */ block->grouped_exp[ch] = &s->grouped_exp_buffer[128 * (blk * channels + ch)]; @@ -2524,16 +2490,14 @@ static av_cold int allocate_buffers(AC3EncodeContext *s) return AVERROR(ENOMEM); for (blk = 0; blk < s->num_blocks; blk++) { AC3Block *block = &s->blocks[blk]; - if (!FF_ALLOCZ_TYPED_ARRAY(block->fixed_coef, channels)) - return AVERROR(ENOMEM); + for (ch = 0; ch < channels; ch++) block->fixed_coef[ch] = &s->fixed_coef_buffer[AC3_MAX_COEFS * (s->num_blocks * ch + blk)]; } } else { for (blk = 0; blk < s->num_blocks; blk++) { AC3Block *block = &s->blocks[blk]; - if (!FF_ALLOCZ_TYPED_ARRAY(block->fixed_coef, channels)) - return AVERROR(ENOMEM); + for (ch = 0; ch < channels; ch++) block->fixed_coef[ch] = (int32_t *)block->mdct_coef[ch]; } diff --git a/libavcodec/ac3enc.h b/libavcodec/ac3enc.h index 41b9a3a20b..54e14d43d9 100644 --- a/libavcodec/ac3enc.h +++ b/libavcodec/ac3enc.h @@ -127,16 +127,16 @@ typedef struct AC3EncOptions { * Data for a single audio block. */ typedef struct AC3Block { - CoefType **mdct_coef; ///< MDCT coefficients - int32_t **fixed_coef; ///< fixed-point MDCT coefficients - uint8_t **exp; ///< original exponents - uint8_t **grouped_exp; ///< grouped exponents - int16_t **psd; ///< psd per frequency bin - int16_t **band_psd; ///< psd per critical band - int16_t **mask; ///< masking curve - uint16_t **qmant; ///< quantized mantissas - uint8_t **cpl_coord_exp; ///< coupling coord exponents (cplcoexp) - uint8_t **cpl_coord_mant; ///< coupling coord mantissas (cplcomant) + CoefType *mdct_coef[AC3_MAX_CHANNELS]; ///< MDCT coefficients + int32_t *fixed_coef[AC3_MAX_CHANNELS]; ///< fixed-point MDCT coefficients + uint8_t *exp[AC3_MAX_CHANNELS]; ///< original exponents + uint8_t *grouped_exp[AC3_MAX_CHANNELS]; ///< grouped exponents + int16_t *psd[AC3_MAX_CHANNELS]; ///< psd per frequency bin + int16_t *band_psd[AC3_MAX_CHANNELS]; ///< psd per critical band + int16_t *mask[AC3_MAX_CHANNELS]; ///< masking curve + uint16_t *qmant[AC3_MAX_CHANNELS]; ///< quantized mantissas + uint8_t *cpl_coord_exp[AC3_MAX_CHANNELS]; ///< coupling coord exponents (cplcoexp) + uint8_t *cpl_coord_mant[AC3_MAX_CHANNELS]; ///< coupling coord mantissas (cplcomant) uint8_t new_rematrixing_strategy; ///< send new rematrixing flags in this block int num_rematrixing_bands; ///< number of rematrixing bands uint8_t rematrixing_flags[4]; ///< rematrixing flags @@ -232,7 +232,7 @@ typedef struct AC3EncodeContext { int frame_bits; ///< all frame bits except exponents and mantissas int exponent_bits; ///< number of bits used for exponents - uint8_t **planar_samples; + uint8_t *planar_samples[AC3_MAX_CHANNELS - 1]; uint8_t *bap_buffer; uint8_t *bap1_buffer; CoefType *mdct_coef_buffer; From patchwork Sun Apr 14 18:30:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 48054 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a21:670b:b0:1a9:af23:56c1 with SMTP id wh11csp1407426pzb; Sun, 14 Apr 2024 11:30:49 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVz/g/jf/fErs5s8V8Itr8QH0iBih9q8JySgJpjQ+4crs4cOnlFKmAtN9NUzlKojRomNUbdx3ibwp71trbgxMYtOSz0CL49C9awtw== X-Google-Smtp-Source: AGHT+IFJgO1IU9mNoRPCkQ/9vqvht9kC/QPnAxXQfo8ejP0YSSJhPHgYXMSRfzHszfhVjAq7wwc2 X-Received: by 2002:a17:906:e06:b0:a52:6a9c:9ef5 with SMTP id l6-20020a1709060e0600b00a526a9c9ef5mr439253eji.64.1713119449291; Sun, 14 Apr 2024 11:30:49 -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 s1-20020a170906a18100b00a51ab69de4asi3957684ejy.998.2024.04.14.11.30.48; Sun, 14 Apr 2024 11:30:49 -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=Fqy06NKb; 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 EE2B568D3AF; Sun, 14 Apr 2024 21:30:42 +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-db5eur02olkn2085.outbound.protection.outlook.com [40.92.50.85]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id E8C8A68D3AF for ; Sun, 14 Apr 2024 21:30:35 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZVvLQG50+wN0bFYP+109g/lWyj2S/qHp25CyQqaL4iw/nkAS8wWY0g34MYW+FAEmfEK5zLu6tWrn4rPpr5zagwhGsNtY2PtP9ywzUj+rINxAljTNYS2SKn6XFoS0qCSpTosrf1LbvoH6YMaEnj+L1YVPURehUAXt6FpXH2tQW/SHEXCHX9vvzXqOGLDXpxDwr6z+WdHznsnkLC6Lg2v5ur8w2EBWeWDRebTz10rX2eR2i9q/ws+vtaGY11SMJXlyOFX2iaAlPOSZo2wUAOQJWyg4hqACNq6DC641feeJCzp6/nKrhQ3XHBCneO4DhH7tuREzH2iBsXAU/Mq52F0Spg== 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=mMI7ePbOq/VL/80qNoTixFWRT7XIr3AU9Qqygk/dJL0=; b=Otzx/Wub7Ch2opIbxgp9RfxFiuwZc4Pj3BDX6Vp1KGHfobLE49t0OxisM9ktiRHwrHmtL7jWOolKB7BKUZ0S+PBPUXcrXwUDT2tdT5sweeTmn8Yyrk45fIzzA23LkHId0uOTuZI4xhbw8w/6J47G31fyx8QYxIWU4CfnG87zw/pvA/qXUW4xNa4ouD41VKrVUv9Nad3fTbTIywjY+c42bX8/dcFtXFvhHvb5tp04xCrgEfsx+bKXeyNzNZEQHfbf/CU8WyV20AOLNbzN2gHN4vTCQCKi1HgxW/yV15bAabMmpqvt0tkN2FcoUouMfQ0rgx9SHzGqQIKkc5wSuRseTA== 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=mMI7ePbOq/VL/80qNoTixFWRT7XIr3AU9Qqygk/dJL0=; b=Fqy06NKbh/gCYXwS32T+QR/1s+stgOZQyj4RHwM6+3R5rGl1WlSQXMj8+svZggcjS9vi48W8Goj2ZUE9+GWDqmC3SSYwW3c9bpjMT6fOsWOlfupA/OQ/mP4hynLhU5uUOCgR3AktrsxGm89PP74hgh45kxc62yibsgNfjxK7mnXCCb3ghr93S1qGO9mV6V/IAbBkCAI/G6y6RJpNITKG0VbHNO9leHpGReXZNLZu29U9/Dj15PD4jvk8rxSmEKwnKgd/Zh3TwWj03lZJcq++L1uLIfrG+k6HJEu3/TQugaqMnt7/7h8fWhVmPyo0rdWHfdomdfXf6M/ael1eghJ81w== 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:31 +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:31 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Sun, 14 Apr 2024 20:30:03 +0200 Message-ID: X-Mailer: git-send-email 2.40.1 In-Reply-To: References: X-TMN: [34YHt3fKUdyynzq7jMJ5Nfuc8qsLQ1Vn] 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-3-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: ce7fcf70-32fe-410a-f85c-08dc5cb0f762 X-MS-Exchange-SLBlob-MailProps: quCBMN2EvO9EDxo7zA78wT486JQYApETTXqa9QlwrD364p/crh27hiq9v4IfAUvauE0YlN7AyqktVsfI9Sch1LtxH/31t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CSGaFC9hCMlGEypA09AoJwPIDG0rTwdMfHTo7wyQ3krw1CYHTAzEIHA51ccM1RlcpnZwOUCM8QGU4Uos5F6nwHjOdp8O0EKBgGByG18vXtzN3U3Gqq9d1YTOUbpTh3E9/TUTJ49IhEMlY7q6f/K2llVhAbp44yrWEA+RIv5XYxX+BwTkwJRPijL/C0zFwd+qJsISq8WvWwYWPsUmW6gCjALA+TdFfKcVkaeBTmsR5C3Zx4qdtbsjizW4EhcduYsLhP2CMD/5N1F9b7ZlFGTy/q6buXojfxHZLHAL7epYe1hYeQRZzZju/puE79Ynr+yZnTYtC+FYmmWdkz2fL6/NLLhxuTag4/2DB8vu30rHVuldsxQqAfEjNnrW7bxDtEOEUUhdAHT07+w9yB9WgL0usY84h+p3U7guXt/pWG5JOhTFjirsLF5WoVe50ebZa+1VO94IDNTHFSSNQYwUa3eaFglVZTL+RTi91RBaH3ZxoZpwmAVFu0sFoi+CgKaJbBJa6Ikrz0GiRAJKmxC6fD6BX0z1sBA== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: ce7fcf70-32fe-410a-f85c-08dc5cb0f762 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:31.6046 (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 4/6] avcodec/ac3enc: Combine loops 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: YmD4GOMTkkgt Signed-off-by: Andreas Rheinhardt --- libavcodec/ac3enc.c | 24 +++++++----------------- 1 file changed, 7 insertions(+), 17 deletions(-) diff --git a/libavcodec/ac3enc.c b/libavcodec/ac3enc.c index 1ef670622a..eb878afc7b 100644 --- a/libavcodec/ac3enc.c +++ b/libavcodec/ac3enc.c @@ -2459,6 +2459,10 @@ static av_cold int allocate_buffers(AC3EncodeContext *s) !FF_ALLOC_TYPED_ARRAY(s->qmant_buffer, total_coefs)) return AVERROR(ENOMEM); + if (!s->fixed_point) { + if (!FF_ALLOCZ_TYPED_ARRAY(s->fixed_coef_buffer, total_coefs)) + return AVERROR(ENOMEM); + } if (s->cpl_enabled) { if (!FF_ALLOC_TYPED_ARRAY(s->cpl_coord_exp_buffer, channel_blocks * 16) || !FF_ALLOC_TYPED_ARRAY(s->cpl_coord_mant_buffer, channel_blocks * 16)) @@ -2482,24 +2486,10 @@ static av_cold int allocate_buffers(AC3EncodeContext *s) /* arrangement: channel, block, coeff */ block->exp[ch] = &s->exp_buffer [AC3_MAX_COEFS * (s->num_blocks * ch + blk)]; block->mdct_coef[ch] = &s->mdct_coef_buffer [AC3_MAX_COEFS * (s->num_blocks * ch + blk)]; - } - } - - if (!s->fixed_point) { - if (!FF_ALLOCZ_TYPED_ARRAY(s->fixed_coef_buffer, total_coefs)) - return AVERROR(ENOMEM); - for (blk = 0; blk < s->num_blocks; blk++) { - AC3Block *block = &s->blocks[blk]; - - for (ch = 0; ch < channels; ch++) - block->fixed_coef[ch] = &s->fixed_coef_buffer[AC3_MAX_COEFS * (s->num_blocks * ch + blk)]; - } - } else { - for (blk = 0; blk < s->num_blocks; blk++) { - AC3Block *block = &s->blocks[blk]; - - for (ch = 0; ch < channels; ch++) + if (s->fixed_point) block->fixed_coef[ch] = (int32_t *)block->mdct_coef[ch]; + else + block->fixed_coef[ch] = &s->fixed_coef_buffer[AC3_MAX_COEFS * (s->num_blocks * ch + blk)]; } } From patchwork Sun Apr 14 18:30:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 48055 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a21:670b:b0:1a9:af23:56c1 with SMTP id wh11csp1407462pzb; Sun, 14 Apr 2024 11:30:57 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCX1Rmtu+o9M+rk0AXXza0y5dqoDkYDbv5BOnUxnLUP25ZRKEC46YKr6W/3Uev6vAnM4cT7lk+vX5O91ld64QiiI6JvT2i0aeFHfdA== X-Google-Smtp-Source: AGHT+IH6HuqWmbZ4SunwaAIGNfCqSwncJ9UMIjzXd/t2kCjR+1BjYrSAgs8zw/Kbb4O+9xzUISP3 X-Received: by 2002:ac2:410a:0:b0:515:bacd:adbf with SMTP id b10-20020ac2410a000000b00515bacdadbfmr4698497lfi.34.1713119457131; Sun, 14 Apr 2024 11:30:57 -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 sh16-20020a1709076e9000b00a51b83ce8aasi3738615ejc.493.2024.04.14.11.30.56; Sun, 14 Apr 2024 11:30:57 -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="UWUiQ/Ty"; 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 0490968D3D0; Sun, 14 Apr 2024 21:30:48 +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-db5eur02olkn2085.outbound.protection.outlook.com [40.92.50.85]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 1CF2068D3C2 for ; Sun, 14 Apr 2024 21:30:41 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=WNJB0KFnXbAVdoxdSSqDWpN+21VB1zYPP1yl/O2TwgaK65NT7E4FwsLLzn6FEvpZyeAUYmKs4pRDiq2KPCFBNNvwGrVoIenJ0nxs0kz/zoa/u/LBPLp9aFmruCajT09lZJEO292rlouPVY4P/yttTQ58hbOilvWTBrokFo4DBpNFAwkBlWerJRySoODiZpUJWb/qtLX1A9Anw5tMPHCa/+heTuJd1R4oEDEPBLY5SU9a5pzPFjcNb6gAmPfBhiT3vSYe11SHMH118qda6Vk7EqgJOHRIowDYcDaXrPi0n5OqkotvKrv7p5Klpwpc5hY9x947jmJS1Er2zHsWhfYc+A== 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=0kMaXPbn+ObfRMtZfrSD/HMwsS1rc8lf3ySIrFKvhHw=; b=BtNzPkOPkwioZU2vMjKKouP3/wmmLa0TM8jYW3Hs0ZuM/zBmlFzOX8vw0qxDlBG/VgQcyT7abIxIwVoz6cUL5Em9jZacwb+kse+m59/7mA5ga0ZqPeag81NlyTsT/L1uVqdKld6XJLeyHhkXniDGiKZcv5JwXTmCpJ2U1BuzIPZNfruB6IdAbgEUoR0ZYcPEhivS3dmV79LYzfz+6FdSK7qxB3tXQmtuvc8hFfN3eXhLoRqpjbIGWhmycsBWSjIfFeABQN0q1ec3NAOKXbttXyYzXYzc5NShgxPUtTyA7rK5oyvOveBPEfGUHSmAAEOGzwpcU7ZgjcAb1pWGLT1yQA== 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=0kMaXPbn+ObfRMtZfrSD/HMwsS1rc8lf3ySIrFKvhHw=; b=UWUiQ/TySDWUUN0AkHS3m7DmqcxDq1lg1k7CEkuW9PurGL7yXyixGumDnfE7mnzMjBY7VZjhtq2iQzMHT7t0WX4008xUI618e4t8mRhC4iC+Uc4OGIZDRG58OoQjCLXofcuVeBi/sBlzIlu6X/A91kq2qzTn8uBm+zlv8kdr5VyRFQRRoL/Nm1ltpXazA9PwjbKn/8ZVVbN6/I1/5gy00FWQfGooK7oVXavU+gT05xEvpyEpWJgXZXlNlBTaXWD0ynKnGwEbrTiiBe6QjokGwVg+v977xDLunRlec8oa3JWVlhRZ3gAoCo0StFN0mK25Vwh0AeGbswkBKCfnzfFjLw== 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:39 +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:39 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Sun, 14 Apr 2024 20:30:04 +0200 Message-ID: X-Mailer: git-send-email 2.40.1 In-Reply-To: References: X-TMN: [MyN7b7bhqT6ogGsme4Xx7vheVYTMWEN4] 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-4-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: 1f7606a2-c1b4-4490-58d4-08dc5cb0fc49 X-MS-Exchange-SLBlob-MailProps: 9IecXKUgicBjqiCWzr+pRkDdXxvh1/bAE5/S7jafgV8DMl4KAM/0PKweOBhdLi0cQnBqOyvuoB1BfmPnRpn8jX5BSp9W2PjK/gdUe+D7MqxEoLp6tgWInwneG5zFNoxIvZ2W2dnsHNGkJfz8ivhtQrzI7mdY1sFeuEoh/nigmEVIhOvxVCGxCkbdlkJfZyRHmlhXzQUYRcTUQcGEmnBzDsDskERp1sJbnBHDlqcd5I4I60OjWm64+Pu132f8elNRft4oaf4SJrjs0gPFS1qf4yVaGDaDP08kTqLhmyghnqEzRP2a/H0V8HL8NjHm1suQwlYNS78YcoEWNzZVFSui8l5DPHjQyvoqtwIv65vEMlD/gV8Q8P9pLjCe4F+bkpbgD2+nYuMLyvdD1drKnkMOzDROmfRfQeZSfmjNL+HSGNPUR7GG9DOHrh3WlyHk0cGKpjtsWHQRciDyypxpZTRtcC30sbQX1Td8eH8urvTNvRJdFW2/hiIoF2nsFkeOk7DUm7pSfxuQTikdmzYCft34/Xa9KhxMr9K4YLop4hhL/gKe5URCNo4312tPj0S/63KpcmPcuFvc8nkfrAaKNowjmQcZhVxYUQTAuTcNo6HIuvpzKs/ukHQk8CCzmqvCFHTTKUwiiZjcXry/80Vzyq+y+AdnXT7DKJHUfkObZpxUWLUKdGE/c7ExtlMbSsPZj4UtDnCX2Ad+671uhhMoSW/6BL+5aK9wfutBHfrVhv5LS6w22slctdj5KA== X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 5un6PSsop3KlmcgJk4pTgLOPe4oKthtlQAX2FRlVewQu9s4uvSQEEWQBWBrqjH8/EIRm+pFqTuNRGWsQgB4bTVc/aOzXgFtptck3xZ//IWq/Jve1tXvgLROVi4dniaao4jIzefqeQgUs3sO4XddB/eFZq0uRtDMLEIEwd2sbUsdZHrX4ujO3fia7NyyaiqSK2VgvHOi/fE0J5RFXwEumZ9j5EbDv2Do77h3eHj4Fwtqm/53b8MBoNswTdc3V/IKioTBWd7BzAhlN+hAOX7AUVGRN3zjZWLy2dCFaTBxntbEK3pVanCv25EZJK/An3Q4imM7PmgMLaINKg6c3M+LemG1dMsRYPgPIfE3c1ZoDc2Jw2ASM/hhVJULiSqcUZG+dfCQ1uf9E3Si59S+X3T6AOzTA0/UDcomBoRqtOztMgmbt504wKsYMxkPWWndsKFmZ3/SmYy28PUDMRlbTin+hg4F1drvxr5yy3X8UYdzt58pgCSZwy1CUg9F+TH3yztjSWy1IM7JG5EXV2U7SztXDfoJjT8wsF1PZlqpSCumigsGKjQ0ggSocqb7S4wMY0+3ZfQiQhLq9Bi26XOJX/0TcbZLiLppJfilssMnA7Z5ltZ6AGMlf8hFps7yxq9wIaVNh X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: WHfZjcLPxqCJ4Ent95g1KX7PPs9/cm+HH8cb3jua8EbUUCpOyLMW0BdVlWVvdOcrKD6VEYV1BXHasgachxOIUB9lVAXX4H1mKSukl9/QFQsQeXVyGRJ/MC62ELLTLC/cCKVuhlD8YIjMHugNZmBFtophwzhR+v6wH9hxU6lcBclYQn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VkuHUmUXl5BGB0qEIp9ZmVnJNhis6rGRUNOdvcK0JGw== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1f7606a2-c1b4-4490-58d4-08dc5cb0fc49 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:39.8661 (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 5/6] avcodec/ac3enc: Combine cpl_coord buffers 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: 6WflesZbmjY8 Signed-off-by: Andreas Rheinhardt --- libavcodec/ac3enc.c | 12 ++++++------ libavcodec/ac3enc.h | 3 +-- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/libavcodec/ac3enc.c b/libavcodec/ac3enc.c index eb878afc7b..71d3026d40 100644 --- a/libavcodec/ac3enc.c +++ b/libavcodec/ac3enc.c @@ -2194,8 +2194,7 @@ av_cold int ff_ac3_encode_close(AVCodecContext *avctx) av_freep(&s->band_psd_buffer); av_freep(&s->mask_buffer); av_freep(&s->qmant_buffer); - av_freep(&s->cpl_coord_exp_buffer); - av_freep(&s->cpl_coord_mant_buffer); + av_freep(&s->cpl_coord_buffer); av_freep(&s->fdsp); av_tx_uninit(&s->tx); @@ -2439,6 +2438,7 @@ static av_cold int allocate_buffers(AC3EncodeContext *s) int channels = s->channels + 1; /* includes coupling channel */ int channel_blocks = channels * s->num_blocks; int total_coefs = AC3_MAX_COEFS * channel_blocks; + uint8_t *cpl_coord_mant_buffer; const unsigned sampletype_size = SAMPLETYPE_SIZE(s); for (int ch = 0; ch < s->channels; ch++) { @@ -2464,9 +2464,9 @@ static av_cold int allocate_buffers(AC3EncodeContext *s) return AVERROR(ENOMEM); } if (s->cpl_enabled) { - if (!FF_ALLOC_TYPED_ARRAY(s->cpl_coord_exp_buffer, channel_blocks * 16) || - !FF_ALLOC_TYPED_ARRAY(s->cpl_coord_mant_buffer, channel_blocks * 16)) + if (!FF_ALLOC_TYPED_ARRAY(s->cpl_coord_buffer, channel_blocks * 32)) return AVERROR(ENOMEM); + cpl_coord_mant_buffer = s->cpl_coord_buffer + 16 * channel_blocks; } for (blk = 0; blk < s->num_blocks; blk++) { AC3Block *block = &s->blocks[blk]; @@ -2479,8 +2479,8 @@ static av_cold int allocate_buffers(AC3EncodeContext *s) block->mask[ch] = &s->mask_buffer [64 * (blk * channels + ch)]; block->qmant[ch] = &s->qmant_buffer [AC3_MAX_COEFS * (blk * channels + ch)]; if (s->cpl_enabled) { - block->cpl_coord_exp[ch] = &s->cpl_coord_exp_buffer [16 * (blk * channels + ch)]; - block->cpl_coord_mant[ch] = &s->cpl_coord_mant_buffer[16 * (blk * channels + ch)]; + block->cpl_coord_exp[ch] = &s->cpl_coord_buffer [16 * (blk * channels + ch)]; + block->cpl_coord_mant[ch] = &cpl_coord_mant_buffer[16 * (blk * channels + ch)]; } /* arrangement: channel, block, coeff */ diff --git a/libavcodec/ac3enc.h b/libavcodec/ac3enc.h index 54e14d43d9..4241a908a1 100644 --- a/libavcodec/ac3enc.h +++ b/libavcodec/ac3enc.h @@ -243,8 +243,7 @@ typedef struct AC3EncodeContext { int16_t *band_psd_buffer; int16_t *mask_buffer; int16_t *qmant_buffer; - uint8_t *cpl_coord_exp_buffer; - uint8_t *cpl_coord_mant_buffer; + uint8_t *cpl_coord_buffer; uint8_t exp_strategy[AC3_MAX_CHANNELS][AC3_MAX_BLOCKS]; ///< exponent strategies uint8_t frame_exp_strategy[AC3_MAX_CHANNELS]; ///< frame exp strategy index From patchwork Sun Apr 14 18:30:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 48056 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a21:670b:b0:1a9:af23:56c1 with SMTP id wh11csp1407516pzb; Sun, 14 Apr 2024 11:31:05 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUE5PaQbdWHY1i3kIxZBfmE5aV+QJCL+oqBK1MGvPBODNfEUk8ltwe80cbEfYZtMnc1jqjlaKmXm9PQEfsAn2fLC/sOjZtf8+i1Mw== X-Google-Smtp-Source: AGHT+IF80ud3c9rmCer9wEiOIK0qU9AG+1O5mkTW1YnopdD1cca/R/MyeG0f0S5UEsNX9eF6o2vN X-Received: by 2002:a17:907:970f:b0:a52:3451:8a18 with SMTP id jg15-20020a170907970f00b00a5234518a18mr6680395ejc.29.1713119465363; Sun, 14 Apr 2024 11:31:05 -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 ho40-20020a1709070ea800b00a51fc4903c7si3722353ejc.1054.2024.04.14.11.31.04; Sun, 14 Apr 2024 11:31:05 -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=lXJZm9pA; 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 0AEC468D23D; Sun, 14 Apr 2024 21:30:51 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR02-AM0-obe.outbound.protection.outlook.com (mail-am0eur02olkn2035.outbound.protection.outlook.com [40.92.49.35]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 8C6FF68D3D2 for ; Sun, 14 Apr 2024 21:30:49 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lp+ifYLYG0xcIkxF7p0pae2O1EXWCxO0GGX2hh/J2tJMEiEjA+nWNz8uF9z2TD9SsmSykD5cIH68hcWzmi3zcbSO1pglfnRA6ygaWC7g7HgIffcl9gvoviJ1I2nY2AMuCNLH8DaM1aojNS1q9CByoADUF76cQXRDn0c/8shn0zJWM97g8Cith3aSvWc8q0rc1nRTa6QBRgwo3xQJDhxGfdz8LJq3ebjKXpO1grR5ncQaDSaK0/ABOGScPsatV+a+eJWOILhgVNHW/nNoBQMe1MubGY6JBOUaqCtYRkadvO3yDniU3GdQjTiZyPNXUlTRNJkyK2KD5yC+cMtNxz7O/Q== 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=Q7RGcv4XSn09NcFoQ9ZZCM/KYM25C/btg3QnLgxR0w0=; b=jBuBMp7XVY5b9nsAfyYSmufn17h9h3VBBJ65b9vnha4aCXfm/KUlZWkhNLRRxtjwwPaK05x9tCFeyTT5SgPn7uCA4yYL7ewi3nzMGVGdq+iyue+uJpCU0E8ec84CKrCGotEG2S4yJt1IyNaHRsOassipsKdkdCibrMfsGXaPCcEvZk6AKXUccMdy8QTmLZipr1FQ6zM+OmXPGKPwsw9bT+6Lw9WFFsYWGDZiqTVvvQsegdgrjC+0nVXuakDZ4cajpvmtWweAPodCHva42wbTLfr+jIElJ3rhbi4dbkPxgfwFQTUl464biVXJabkr6BDTPX2dwNVULSjNPNwlB4kb3w== 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=Q7RGcv4XSn09NcFoQ9ZZCM/KYM25C/btg3QnLgxR0w0=; b=lXJZm9pAVM+z1vU7kwI8zINrrDmS9eeKf8UErYdhGmgtOp6tV3jHSOh6MYnK6caDUAZmrFStN3VMVb4nDy3hnWe1ugVWJ+VkrWqxf2bfHOa2bH+5L7d8a+nKCR4bv73fuYZMPnEXmgjfArKN6T6UFY4ieqYhA2hETselRkvoqZR6yHRToiqQjRUgmFnJ7km37CZQDAlH9nit3+RhLly7b8wrCtKHdWGMUXtG1La9kXmzxwrnPDH/SSArVwLahaL0TGU6vwHC3HeFigF/RBqgZzV+Wn9YD2m87aJViH/165JUn1kCS1KF8h6V+OEMwzCJ07PE4TXHo6lYjCz4p5MOHQ== Received: from AS8P250MB0744.EURP250.PROD.OUTLOOK.COM (2603:10a6:20b:541::14) by AS4P250MB0413.EURP250.PROD.OUTLOOK.COM (2603:10a6:20b:4c0::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7409.56; Sun, 14 Apr 2024 18:30:47 +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:47 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Sun, 14 Apr 2024 20:30:05 +0200 Message-ID: X-Mailer: git-send-email 2.40.1 In-Reply-To: References: X-TMN: [AITMXU51RlieWkc2jnZwfDOY5oKYHr7n] 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-5-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS8P250MB0744:EE_|AS4P250MB0413:EE_ X-MS-Office365-Filtering-Correlation-Id: acc15d10-7927-4706-675f-08dc5cb100cd X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 2AGlDnGnwnKVanmTXLdHeKH9eHZBiM3v1ZtUUMTvu+brmMz50mC/Saq0cHrSTgxaHlTTHyr/STf+REtLZaUiH9XWU1lJwoNdCq21wVX36TH6f4uVEwNnh2Z710VltQ96PVA6VX01w7oJd8tPhFaD471qwzWrlEnvb0s4mVCrAlzH37Pe3k+ZSU1qVpBgjdR5LVH8IbhVSc3F0zXuzizg2hihtpQmHOURlfdjLMSggBAQGRd32dbEg0oJxH+3piHyhkhkJyXQqxB7SoUyAno3LWTxF8EU4j9fYwIXZEtQRXZPG3Dgti/F4/zmG7CNFpijfTZmTcEwjIOCQ9cxRMhy+uUaE7XN+Gy3pId+7WDWM0N7cDdUbGm5UuoA6uCJ+TUg8/8APLGvpubGTPWDamGQlRJUGp0m8HpWVv4y3KWb2nQLi5IUBABizhrs9+6Mz8aF3bCMAmHMtUa8W1I5RuqZaYSWwPwG8KQlTLiuGwDljNlEXtRDe5+jBChxJDqcfIeg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T4LQCtOhdJmeUtxspehIbt6M9J+gWgYmWyYTPB/F7q0K1T9FWWykhIeG8g+iD0GjN8Juj6JMQPKVPEJ5mJuGFJtp7zSXjV+IJr6cYYky8TD7z8DrrLJcyT1v+OPHPqA2CCviVqoLExy5wI/M3jgWf+zSl1pUEGcswNM5FkT6tz56RqPSB9hFLM7lVtI/9pcgSZ8N5SOAy0FtcNqANKY2Zp7rqpEV/bGkFNC1O1hh4kiDTPrVnWT/z+yFPPdoOXAKDyv/o3x0XW1gqnPEgrcjkghm5E4r+gRk/BO2hRhb7K8Ml1+sVFzsdnruhKLQ3kh5Dsw/PfWmMYJ6D+OcGiLCoHZKKiofbEW2BGdFoQgvUpGbpve/LD943AjwML3dPlf3c6wSFotIlvMTH9RC235Qg4v09E9CLEedgA== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: acc15d10-7927-4706-675f-08dc5cb100cd 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:47.4403 (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: AS4P250MB0413 Subject: [FFmpeg-devel] [PATCH 6/6] avcodec/ac3enc: Avoid copying 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: ajht8OHzNdtj Only the last 256 samples of each frame are used; the encoder currently uses a buffer for 1536 + 256 samples whose first 256 samples contain are the last 256 samples from the last frame and the next 1536 are the samples of the current frame. Yet since 238b2d4155d9779d770fccb3594076bb32742c82 all the DSP functions only need 256 contiguous samples and this can be achieved by only retaining the last 256 samples of each frame. Doing so saves 6KiB per channel. Signed-off-by: Andreas Rheinhardt --- libavcodec/ac3enc.c | 29 ++--------------------------- libavcodec/ac3enc.h | 2 +- libavcodec/ac3enc_template.c | 20 ++++++++++++++------ 3 files changed, 17 insertions(+), 34 deletions(-) diff --git a/libavcodec/ac3enc.c b/libavcodec/ac3enc.c index 71d3026d40..1a869ab865 100644 --- a/libavcodec/ac3enc.c +++ b/libavcodec/ac3enc.c @@ -503,28 +503,6 @@ static void ac3_adjust_frame_size(AC3EncodeContext *s) s->samples_written += AC3_BLOCK_SIZE * s->num_blocks; } -/* - * Copy input samples. - * Channels are reordered from FFmpeg's default order to AC-3 order. - */ -static void copy_input_samples(AC3EncodeContext *s, uint8_t * const *samples) -{ - const unsigned sampletype_size = SAMPLETYPE_SIZE(s); - - /* copy and remap input samples */ - for (int ch = 0; ch < s->channels; ch++) { - /* copy last 256 samples of previous frame to the start of the current frame */ - memcpy(&s->planar_samples[ch][0], - s->planar_samples[ch] + AC3_BLOCK_SIZE * sampletype_size * s->num_blocks, - AC3_BLOCK_SIZE * sampletype_size); - - /* copy new samples for current frame */ - memcpy(s->planar_samples[ch] + AC3_BLOCK_SIZE * sampletype_size, - samples[s->channel_map[ch]], - sampletype_size * AC3_BLOCK_SIZE * s->num_blocks); - } -} - /** * Set the initial coupling strategy parameters prior to coupling analysis. * @@ -2018,9 +1996,7 @@ int ff_ac3_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, if (s->bit_alloc.sr_code == 1 || s->eac3) ac3_adjust_frame_size(s); - copy_input_samples(s, frame->extended_data); - - s->encode_frame(s); + s->encode_frame(s, frame->extended_data); ac3_apply_rematrixing(s); @@ -2442,8 +2418,7 @@ static av_cold int allocate_buffers(AC3EncodeContext *s) const unsigned sampletype_size = SAMPLETYPE_SIZE(s); for (int ch = 0; ch < s->channels; ch++) { - s->planar_samples[ch] = av_mallocz((AC3_FRAME_SIZE + AC3_BLOCK_SIZE) * - sampletype_size); + s->planar_samples[ch] = av_mallocz(AC3_BLOCK_SIZE * sampletype_size); if (!s->planar_samples[ch]) return AVERROR(ENOMEM); } diff --git a/libavcodec/ac3enc.h b/libavcodec/ac3enc.h index 4241a908a1..30812617cc 100644 --- a/libavcodec/ac3enc.h +++ b/libavcodec/ac3enc.h @@ -253,7 +253,7 @@ typedef struct AC3EncodeContext { int ref_bap_set; ///< indicates if ref_bap pointers have been set /** fixed vs. float function pointers */ - void (*encode_frame)(struct AC3EncodeContext *s); + void (*encode_frame)(struct AC3EncodeContext *s, uint8_t * const *samples); /* AC-3 vs. E-AC-3 function pointers */ void (*output_frame_header)(struct AC3EncodeContext *s); diff --git a/libavcodec/ac3enc_template.c b/libavcodec/ac3enc_template.c index 698042ae5c..49fc6d7f37 100644 --- a/libavcodec/ac3enc_template.c +++ b/libavcodec/ac3enc_template.c @@ -48,25 +48,33 @@ * This applies the KBD window and normalizes the input to reduce precision * loss due to fixed-point calculations. */ -static void apply_mdct(AC3EncodeContext *s) +static void apply_mdct(AC3EncodeContext *s, uint8_t * const *samples) { int blk, ch; for (ch = 0; ch < s->channels; ch++) { + const SampleType *input_samples0 = (const SampleType*)s->planar_samples[ch]; + /* Reorder channels from native order to AC-3 order. */ + const SampleType *input_samples1 = (const SampleType*)samples[s->channel_map[ch]]; + 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(windowed_samples, input_samples, + s->fdsp->vector_fmul(windowed_samples, input_samples0, s->RENAME(mdct_window), AC3_BLOCK_SIZE); s->fdsp->vector_fmul_reverse(windowed_samples + AC3_BLOCK_SIZE, - &input_samples[AC3_BLOCK_SIZE], + input_samples1, s->RENAME(mdct_window), AC3_BLOCK_SIZE); s->tx_fn(s->tx, block->mdct_coef[ch+1], windowed_samples, sizeof(*windowed_samples)); + input_samples0 = input_samples1; + input_samples1 += AC3_BLOCK_SIZE; } + /* Store last 256 samples of current frame */ + memcpy(s->planar_samples[ch], input_samples0, + AC3_BLOCK_SIZE * sizeof(*input_samples0)); } } @@ -336,9 +344,9 @@ static void compute_rematrixing_strategy(AC3EncodeContext *s) } -static void encode_frame(AC3EncodeContext *s) +static void encode_frame(AC3EncodeContext *s, uint8_t * const *samples) { - apply_mdct(s); + apply_mdct(s, samples); s->cpl_on = s->cpl_enabled; ff_ac3_compute_coupling_strategy(s);