From patchwork Thu Apr 4 05:02:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 47791 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:24a8:b0:1a3:b6bb:3029 with SMTP id m40csp100550pzd; Wed, 3 Apr 2024 22:03:20 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCW7YUvim1YrZToFZ0J8EGkTOgrvY42/P9F2AMuFrweTJI3jdIeEfej/xSA+bq9rHvGzlzx8u1p3VLzdln8PuwhiUwKxTfEk+5+S8g== X-Google-Smtp-Source: AGHT+IF8P2/zCcuaznSIQUW3A/XousKJmm43SJI10mY/tbQDGX0P/xHmvH3FNU563IpiNEmiI4GG X-Received: by 2002:a17:906:a51:b0:a4a:aaa9:8b3b with SMTP id x17-20020a1709060a5100b00a4aaaa98b3bmr629831ejf.77.1712207000657; Wed, 03 Apr 2024 22:03:20 -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 y16-20020a170906559000b00a4ea1be2096si1306967ejp.445.2024.04.03.22.03.20; Wed, 03 Apr 2024 22:03:20 -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=KTNOKawB; 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 1DF2B68C4BA; Thu, 4 Apr 2024 08:03:08 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05olkn2054.outbound.protection.outlook.com [40.92.90.54]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 9F4A968B43D for ; Thu, 4 Apr 2024 08:03:05 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=N8EdDBEzDFjIjUFtSmS3ak5e9sNUSmaURZBrCt752OzAO3/Whp7c2s2BTNk2iuDwDosxwgwjlzq63D1dN45qYch7aojhFo0CbesTzdQ4f1clMSPGAAAcsyh3sRXdS+nR48pUEp5a9nJ0l1B6qZkDcIs3kTtFCyYd8xpTLPcQ6H/9mEhzQHM73T/GZAvnhwOQPjRaeLlS11Ap8pTSquaN6VzNX2TXfxLkWKJK+PSaCRS9QyWgYI7OLZWRC3577/lvkdK+2Ah2Qo/DFWO36OTCde9h2Jq4WSwFn06VHMU26n3gQzFSH6Ck6q1hB9bLPgsOWOe8YVy2lD7xIWSBTUYltg== 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=Jnf5P51cP52Kh5s1GZcXYAuz/wzzvk981j3z4qh/MsE=; b=FPz7pkHJ28zwvnpmWYRPuRnOxV0yw2D9IWkdKq1HtroNNWewpeBwX3DZQs/kyZSej9zFflc13EzI85QCTFIVpcYQzdPd2oTxd2uj/iPu/xIBuZpIt+jQg/99ed9hHx9219s+oUroaNTLEHlTysWPqiIPJ2JqWsSJ9F1lhy6pzX1V7xoGdWz5yYCWR5FDQGXq2zOsCRHPVZ+5fksQAAqODv83QhsXNuYf45T5edT2DmsWug2ACO85YMhGzJbqqb7UucTqt0tKQd15qJ2ZjrWYXq7ciddTfjKnK1iXhri0TCj+3qgwG13UTZrAmrHG43YrnAfp9xfmO8LN0avuuB1Dvw== 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=Jnf5P51cP52Kh5s1GZcXYAuz/wzzvk981j3z4qh/MsE=; b=KTNOKawBEY4a/zADPPbJwyxV53R27un5LqHyRojMqRfKCvt8s24DDJyIaicvwHzutAslSmewNIxFt3RCfnAE/3A/365QUmHFXLi5AoqoEVBeakfJUSIHdpgcm0+LWYuWeqqTmtlCz6riDXD9pxg6Eh+uvsxSc2f7jxn7Rt10lA0FxuEPbL+yxRJA+sOuaGYSYsefNinRRTDYhwbzfcclkApdNDUlSHu3+gt3+ltBJh26uQ0FPe8oNs+vQsWiTqfnyIZVYbEfzjKEo8NjuUgpl9nbFXBsF9hG3q8kh7P4xHFgRLVebJzeIjVJDsefhp8DhYRKokIoAUNoS31TzCRGAQ== Received: from GV1P250MB0737.EURP250.PROD.OUTLOOK.COM (2603:10a6:150:8e::17) by DU0P250MB0436.EURP250.PROD.OUTLOOK.COM (2603:10a6:10:348::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7409.46; Thu, 4 Apr 2024 05:03:00 +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; Thu, 4 Apr 2024 05:03:00 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Thu, 4 Apr 2024 07:02:47 +0200 Message-ID: X-Mailer: git-send-email 2.40.1 In-Reply-To: References: X-TMN: [wClWgKXba+8aWoTV0LwDRd5QJlAJ/PNPh9U6Vw6Yg84=] X-ClientProxiedBy: ZR2P278CA0028.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:46::8) To GV1P250MB0737.EURP250.PROD.OUTLOOK.COM (2603:10a6:150:8e::17) X-Microsoft-Original-Message-ID: <20240404050250.3450360-2-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: GV1P250MB0737:EE_|DU0P250MB0436:EE_ X-MS-Office365-Filtering-Correlation-Id: 439be639-c16a-4731-f2fe-08dc54647ff5 X-MS-Exchange-SLBlob-MailProps: Cq7lScuPrnqTbNMns+cyPHOFLLd8aUrTGq7av8R7a1xUWWx9MwbhX1oHDUyDoUxBgufGQu4f+ySoz6/ObSWyJQhlhoUEi2EVRx3wvVgpcrE5JuVVNGIQFnEkKsF3QStCuuUPJm+AzAK7c+yJkku4s//Fx9Phs57eBal9JCbNv4g3W7cE/VjKPBPUK9k8T4PwiXhPXTOWUpdi2p9zW8q8udxAUbLAZm8S1coCVk+fbNxGnSPmcwcGVET7aCm6qYGeUN9sHRPEUOp9M4R5vfXwgfa5esMU8MHvA22YJBLReQKV1v479DgeV/mQ7VmtklpleHoH1ek2KMi23AjUzp7/piQ6/ooFe6UemsMQS0LZ3lD+WNKqSS4NONbakhKoFUGGdVx+qF9Va99JB9Zaj0iZrG4BHrCefh80MUbTOuGx9wc6Cv8ZSzkdN6z4X+tfBV6dZSbdbfO92VqqZUsSn5z/csW3DQRlRoe758oc95+tHLIc08bCQ2YO0TudmeyLEQTjDEU4a70huBQywrJ399L1sQSHVW9SmnCVWBfRSdBaQeiFGTRsCyT+nxFkj0fjD5RpCZfu9zG6aJ90ujaI8Nakv+r15zYhy6tcppWPyd92xExfmHNvbvZCNt5Um2EsgbCAmsLMv66WVIktmUf3k8kMvnb2cFruNlSXfQp7djq/GhD/+5yvUgtkU0erPoD3HdLYVAc471QLTdRQ2p35030tdOi8c8uwMsUeRA8h/xvOPPdhG5EEUUJ2YDS4XLRtnGJgU4nS3NBN8zo= X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: xyYOpEFCR8V2pQNw6kYI5Wl2DX9nVN3uYPE3HiB9/jh7gvMxsIYbneSTFiVg3lzgOMR5QrKIuEUcYaLLDxEKRW2Ea8pwCQ7SEqOLktZcAdxPCTpABv8IsRht/9O5RutYE8jjURDzztyud59V37G53rzZlnOTWtukvDlS/59qLlXsis5v2s1F5b1Xuwt60cNh2yBox+qUezzK+HUkBFZKrjZVeARRBXgSzPmZu8FzNoIP9m80Ube7BICT3RXMwr+tQASOGhqL15gLkfcVC9d1jfafkW/4SEV4yFXt6izOxhTIyTx1HY+RFwwS/S5H7pGy/2WyhNVIk4vFj7SN1sZ3wB/hh/p3IiAXG2Tr1B+0EKyJVIrfRgxpSylcbPzQKnd9btQZlAbrTWH+xnb4Lolwx1Mu+NX4ksBSnFDRFHx3bQzby8N6UbxPtgs3OXYBS4/ZamzVpY4mifiHIMNcocchIMbQB2lkPvT/qEFu5WcMvCpXttpTAoYXfk/b/76F3KjQm6eQzeJktjWTNmnwJ5x4xedlaV0KOhEgcaXO6vpObUwIDfGKEvZ8xuAJ3jJwww3gVs4zXMIIzCfnMZfoWACDYFOgScj4z0u0qHzQp3Vq3bjKxGX5jztAS20SxkjBM1SF X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: D1uPtBrL0/PhGspd+HSBK7LCsz780RL+GGAvPLxVNgvZoewCSvC1vJ8qHgARD0cWQUvXg+/WIrzrCuq7cHM3VXUA9m6su+kU3JMGqOBfY0S263yeu6pFGDFtCaYdWxPP5seOnNb09TMSE+viSA7SioDERsP2MK2tkwnLMRMMV7fQ0CnfmgNi0Z1VArFIYFffy8IvEmtYfIMv+VETWbzROzf2tQSKiXTZJfluhstFkw2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.com X-MS-Exchange-CrossTenant-Network-Message-Id: 439be639-c16a-4731-f2fe-08dc54647ff5 X-MS-Exchange-CrossTenant-AuthSource: GV1P250MB0737.EURP250.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Apr 2024 05:03:00.2118 (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: DU0P250MB0436 Subject: [FFmpeg-devel] [PATCH 3/6] avcodec/huffyuv(dec|enc): Use union for temp/temp16 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: AJ5UmEpRnBHp These pointers already point to the same buffers, so using a union is possible and avoids the overhead of syncing the pointers (and saves some memory). Signed-off-by: Andreas Rheinhardt --- libavcodec/huffyuvdec.c | 11 +++++------ libavcodec/huffyuvenc.c | 11 +++++------ 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/libavcodec/huffyuvdec.c b/libavcodec/huffyuvdec.c index e390380867..12ecfcb933 100644 --- a/libavcodec/huffyuvdec.c +++ b/libavcodec/huffyuvdec.c @@ -70,8 +70,10 @@ typedef struct HYuvDecContext { int context; int last_slice_end; - uint8_t *temp[3]; - uint16_t *temp16[3]; ///< identical to temp but 16bit type + union { + uint8_t *temp[3]; + uint16_t *temp16[3]; + }; uint8_t len[4][MAX_VLC_N]; uint32_t bits[4][MAX_VLC_N]; uint32_t pix_bgr_map[1<priv_data; int i; - for (int i = 0; i < 3; i++) { + for (int i = 0; i < 3; i++) av_freep(&s->temp[i]); - s->temp16[i] = NULL; - } av_freep(&s->bitstream_buffer); @@ -607,7 +607,6 @@ static av_cold int decode_init(AVCodecContext *avctx) s->temp[i] = av_malloc(4 * avctx->width + 16); if (!s->temp[i]) return AVERROR(ENOMEM); - s->temp16[i] = (uint16_t*)s->temp[i]; } return 0; diff --git a/libavcodec/huffyuvenc.c b/libavcodec/huffyuvenc.c index 8329666fc0..4f709143a2 100644 --- a/libavcodec/huffyuvenc.c +++ b/libavcodec/huffyuvenc.c @@ -65,8 +65,10 @@ typedef struct HYuvEncContext { int context; int picture_number; - uint8_t *temp[3]; - uint16_t *temp16[3]; ///< identical to temp but 16bit type + union { + uint8_t *temp[3]; + uint16_t *temp16[3]; + }; uint64_t stats[4][MAX_VLC_N]; uint8_t len[4][MAX_VLC_N]; uint32_t bits[4][MAX_VLC_N]; @@ -436,7 +438,6 @@ static av_cold int encode_init(AVCodecContext *avctx) s->temp[i] = av_malloc(4 * avctx->width + 16); if (!s->temp[i]) return AVERROR(ENOMEM); - s->temp16[i] = (uint16_t*)s->temp[i]; } return 0; @@ -1040,10 +1041,8 @@ static av_cold int encode_end(AVCodecContext *avctx) av_freep(&avctx->stats_out); - for (int i = 0; i < 3; i++) { + for (int i = 0; i < 3; i++) av_freep(&s->temp[i]); - s->temp16[i] = NULL; - } return 0; }