From patchwork Thu Apr 4 05:02:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 47790 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:24a8:b0:1a3:b6bb:3029 with SMTP id m40csp100481pzd; Wed, 3 Apr 2024 22:03:11 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUOtm4BeoNJM1U/TvB1e/TVpt8gkm68YxxIxXz9in5LYxrn9FxYr2vPR+CNlljwzLw3uqUvuXY+szqlrqe52gNznNtMlzBc/zFsTw== X-Google-Smtp-Source: AGHT+IEW3F/bA9u7crxyi/re48okgowX/ASQZBEfKrzibWQRPo/M4MIb46gSjduMQpQ4anTerYbd X-Received: by 2002:a17:906:2509:b0:a51:8250:2b52 with SMTP id i9-20020a170906250900b00a5182502b52mr740626ejb.61.1712206991157; Wed, 03 Apr 2024 22:03:11 -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 p23-20020a170906141700b00a46cbbf3b89si7304299ejc.340.2024.04.03.22.03.10; Wed, 03 Apr 2024 22:03:11 -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=qTwo42iI; 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 24F2C68D0EE; Thu, 4 Apr 2024 08:03:07 +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 5364568B43D for ; Thu, 4 Apr 2024 08:03:00 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=PlCdz14bfuPxgzYy1omJ7pw7QZ4ZCHGTbRbqEI7vhcwxLNW/Mapp482270P2nlnuMdm42CGfnSyuqpzUaSqsvMksSngkkZIgkl2kj0E8pEok7I3lC3D37GZKGQtpSWKZf+3Rs3wLFZiGfuDyXzhW+HfrTtxlUKHHlhQB6H3qUKiPlb9VaX9tt5X46kh/dvQRA6WYqVsOHfuxrFip8N+8dvNKGhIDCf0mT1g/8BDc/ljC4oWChu+ycldG2LkGguY5joktoiZoZ2y4MuwT68fS+cMqCf9rpoMu8rXy2tIDWC0IU23OhiZypBXyoLo0i9eW+uvdYxIdz/AjbV9EYW++NQ== 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=RxBBfu/a5xk9nPxH4GRLNO+e8U2aN0YVMk2OnvcVyXY=; b=fZzoi/wL/U8rLYStMxmodSrxyONTEB/taMsq/sNneDfhQCZpkzMAZ4GsUKTQfUjgZYqgGAjkuor/Q+FTNBfNEJw2boC++IMoaV42b+RlKHm/UO2U+ISdWNUSoxDkps+l8n8dKEuEP5buH63twvhkerf70JBoi9PMakA6e0QPYBiesaOCxh/wn1kkkqwGzXelcylAlDXehjJTH2ecpQnD1ex0MQCu3QQc58aR0RUBaxIh4FzNjUQiPLHnFHjPQZEWKwiYOM2S8uAWw6Ua2BRF5aV8iiz3QqxMaaobRpwCSFcaT5NsXruPUs38hJqyGoPTYRnzbvUc7jZ64Z/i9+YGJQ== 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=RxBBfu/a5xk9nPxH4GRLNO+e8U2aN0YVMk2OnvcVyXY=; b=qTwo42iIOWfAYsVFQjfYVqW1BXaUX10cBijKgBZTlI7+eR/TrTjm8nmTy4RPf2kckWmHnWZ/XQmz/HEA4AqVixs5eqo85cqhBc3dN6sj868iqp5KvsQelYsPeu09RDBxuD1cVHtAXohGuwamEJ5WiLcdQ3TsJfu8eR1+Im2HAvcMean8sz3X6x753QDCQwZbI1fNB+B7yF3JPdqZmiMJlHWd8I6IGRVpzfRpJ8nBAQ18U5r2qKAyI29SknDbaDMLf3sIBzOgMcL0rKLzeA0ddDe+RG5MsO/YJrAkDg2UmmJPWswXXSy6u4dhGoO1ZpXjxA8WY1B3OFbFEhlo4YvSUA== 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:02:58 +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:02:58 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Thu, 4 Apr 2024 07:02:46 +0200 Message-ID: X-Mailer: git-send-email 2.40.1 In-Reply-To: References: X-TMN: [jCva7FWw0ANqDAvbWnsPThXJoSqoDPcgPSe1s2J4LxA=] 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-1-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: 83cf868d-572f-4d09-e00d-08dc54647edc X-MS-Exchange-SLBlob-MailProps: Cq7lScuPrnqTbNMns+cyPHOFLLd8aUrTEaejK/nR+CgHV6nbY9rcq8pvoIpwJwMdOHMztwbf6ODp/bKYHMV8N1Lqe3rsC7jTZFoz6GRmF5/ycw3+MOeuHkf8zu4Fg9oifzuad9Jytn4J2vSn55ONh+/QLk5PmUCs0cCn4Wo07YjPE8B9TFj1TLMkV9it3zfdsY/aLUO3pYgZoR2irO1tz42aNgv+kK52XBTvqaJOC2ce0DlwKhYnRaA7dUihy16CwhjboD/oWry30X5XxDXpjn7jAAiKcXfD977SJpEwpXxfXuGWm1S9bqDalmV+NcIZtvaBoGoz8H4IF89s12LIwM9U44oLkAGAeHaWGzb3I6ZLVsIgm79bT4duv/z+wxS9xCHr84PQ1BZ996+3XnabDjVxZfX+g4TLa0o0nIYrnajYG11J7TM+cdeCZBQnum/uYZyDXc1kVU6zPZSnFZPJKVWw803tRjk7xzbqqCI5RJvsZkqe61KSRvE6nfZp504RAq1JFbmD4xDXjJ5U60JOINO5ojvUeK/nMK04HqPwzGWASzA7XbQDkTpdSvCiNEEJGmWm5wLuSCNJaqCgpfT9AXBj0D2CMAOmt5MCZnfqasgb0/8gQd/JOToozJ8nNIxz++PogCR62geiGTKqb04xCioxmhuKS08dAmplEwudFOkoPH3CeSeHu1id/78MuC4zPbEfFtNFKfA3WLU3mxB/BK5cDTg0IRkNTmjXKYHAF+bfnU+aIHau5yiS/UV50U+xPVSVcd/lJ1s= X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: es8bfSX2qlvPFn7iXZviUWVck54hs3YylVOKg3DbTHNbk/gkTg7fgS8EJfOey4JFgnMLZs0MjmrROFvylHCzKPPqkG+LO3OJuEzG48DHzE/AFK7mcLKj4XkErdm/8+EuU60z1U02rJA1F0eFPYzRLLVEJlusjwXfy/Uofun6yQ8mPaDK5f4jBBCHyMwB/EJ2Tg6nW7IF4PeBmUdG792i1N1EGac5XVSByFhNTj4VCwLR3sauu3eJ6xxf7avqWNG9Npfb7tbh8piE5jjAgMs3ACUfHSxJbkWva5v9iXynSicWRnJnxhjAYUmpxluehfhaqZ5f4EKuxdNiX0zxyx+UASM2IYWE909D4NAh8xn3QRVimbzub/WuyU6d8e0v3IhZtvQXHMjwVcf6J+ycf4uwUvnmhFtHalRT0qlwJypYezS1uWCcAFJXcqL/a7F+KBFz+VeV8+De7Cff2igFgXXc73duB6+wndlxPfBZxt7fHg4oP+nyC0ejqmGodRLAbqlzndryyf3K2y5j64ayOfIj5XIGMum/ZNUZlxpYRAlQq0kgSXx0lqao+++GVImefYHJZDE3t53+NwbvueafLe3p1jO04IVEEn1U/JngGdDLsLeHqXcSELxIuHG5rvRd2oVd X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: OQQoHdAOiW4orEbba4pohUSBk4pSUOlyUcyQ9182Q6RL8Ui1qynextL/+j/qbqvCU7t8sdRfz+RcE0kOpED7+aFDxX29ap0ZniVlsk8q9iPC/X6HtM68ZVx4Jua+rNZou2WDHBDOVu/qFtaMeql2pCgMOcMuUYj/R+diPrWa3Metbl3xcxyBELX1ZkVzoF6Hi41vjAY7/Hz4lAm2FBAcmCj6cSiFS9JPH2xMVrZFfJLcwyHh24jqnNYavVMCYEjQnAaJO5v7pkF3wC82TI18SlMtoBQ3znoO1X06ZH9ZgiT7FKyInCUb8bjvf0bjeTTbjPnFLDecxAgehKCKS596mrMO2Rm632uN9iDSJRggXPfuVIznGjn3RrGKIlY/Sc6qiW0i6qYa/M+e5+5z1gFUocCKy1zbUS2cWymyLwA/jOQy3cYupFCMCknS24TtwZbhWYonUQthHE7D46hbYHMeBxQVxanv7lc8WgWHB6LHgtw5DoRRLKr2bSENPQATB0QDiKRWoJ4TaW9g7dxw3veDTqR1XCydFirDf+zkeBXEoBD3IwqBJyze/OAK67VIwLcU7rV/84XcNpcicOWqxXgjY6jkpLojLnrOSUtZnRjsFFU5o9GO53F6YOu4VAnvyjyWahuj9yY7QQdDa7/JgBRFj38+dGyu387dkHIcEYu+epmRcRksoM0RCS2dBLZl57rvSOZX3SHv8//IgjpklKI1oLYhODxy5CnAez8n/pDc8+5oNdJsNx1Som16i9j7WnRtjheNvrmfqifFpfBGNl31+nCynzaSYZOpuGM0n5tdUftK+cjoWwilppI17eeMSjp3h/GtTihpcxdE26xwLdgoUmRf7ydSpqCspFL8YQuL/38HRcrlgCdxGrgw4Y1W/OX8+C2+q0nbUeI9mIVVAKacXe7/wwj/FZGcWHaUqAZ3tdSLBhcpC+5r4AvRIfhbLHHtFDzxrBgqPy6oLsHBuxecC9Smbyam9aqlYkJ6A74yCnRpofpKSKC4hIZsZqvIqnFvznAHn5WltMGKgxh10kXx1AdoN5LrJbOn8LiqTrtuJ3ezXmxvF48ASxC2T3EuFu0B6117C9GO8S24YJMjtWlowqJSGf2/BE8pqFnbRgmMXCihFewzZP9xeh8gVsw4auRYPLhLmY6rqOqUExLYDPMT5ZIm26TALIT69qbVfsW931cCL+GKBfgpekISLrB3w0uCeNsSWP4YMrvnn9l67q4Uwzfmspa+zLo92gqn2xZtrbM8hwYSPt4pcNwIM6YKTyi/eP0R/w9fjYbk/npVl15R9w== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 83cf868d-572f-4d09-e00d-08dc54647edc 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:02:58.3986 (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 2/6] avcodec/huffyuv: Inline common alloc/free functions in their callers 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: E/XBIXc3jh+D Signed-off-by: Andreas Rheinhardt --- libavcodec/huffyuv.c | 28 ++-------------------------- libavcodec/huffyuv.h | 2 -- libavcodec/huffyuvdec.c | 14 +++++++++++--- libavcodec/huffyuvenc.c | 18 ++++++++++++------ 4 files changed, 25 insertions(+), 37 deletions(-) diff --git a/libavcodec/huffyuv.c b/libavcodec/huffyuv.c index aaba313bf1..723ab6b92b 100644 --- a/libavcodec/huffyuv.c +++ b/libavcodec/huffyuv.c @@ -28,12 +28,11 @@ * huffyuv codec for libavcodec. */ +#include #include -#include "libavutil/attributes.h" -#include "libavutil/error.h" #include "libavutil/log.h" -#include "libavutil/mem.h" +#include "libavutil/macros.h" #include "huffyuv.h" @@ -59,26 +58,3 @@ int ff_huffyuv_generate_bits_table(uint32_t *dst, const uint8_t *len_table, int } return 0; } - -av_cold int ff_huffyuv_alloc_temp(uint8_t *temp[3], uint16_t *temp16[3], int width) -{ - int i; - - for (i=0; i<3; i++) { - temp[i] = av_malloc(4 * width + 16); - if (!temp[i]) - return AVERROR(ENOMEM); - temp16[i] = (uint16_t*)temp[i]; - } - return 0; -} - -av_cold void ff_huffyuv_common_end(uint8_t *temp[3], uint16_t *temp16[3]) -{ - int i; - - for(i = 0; i < 3; i++) { - av_freep(&temp[i]); - temp16[i] = NULL; - } -} diff --git a/libavcodec/huffyuv.h b/libavcodec/huffyuv.h index 22a766611e..62866b7a48 100644 --- a/libavcodec/huffyuv.h +++ b/libavcodec/huffyuv.h @@ -55,8 +55,6 @@ typedef enum Predictor { MEDIAN, } Predictor; -void ff_huffyuv_common_end(uint8_t *temp[3], uint16_t *temp16[3]); -int ff_huffyuv_alloc_temp(uint8_t *temp[3], uint16_t *temp16[3], int width); int ff_huffyuv_generate_bits_table(uint32_t *dst, const uint8_t *len_table, int n); #endif /* AVCODEC_HUFFYUV_H */ diff --git a/libavcodec/huffyuvdec.c b/libavcodec/huffyuvdec.c index 29e5419d91..e390380867 100644 --- a/libavcodec/huffyuvdec.c +++ b/libavcodec/huffyuvdec.c @@ -323,7 +323,11 @@ static av_cold int decode_end(AVCodecContext *avctx) HYuvDecContext *s = avctx->priv_data; int i; - ff_huffyuv_common_end(s->temp, s->temp16); + for (int i = 0; i < 3; i++) { + av_freep(&s->temp[i]); + s->temp16[i] = NULL; + } + av_freep(&s->bitstream_buffer); for (i = 0; i < 8; i++) @@ -599,8 +603,12 @@ static av_cold int decode_init(AVCodecContext *avctx) return AVERROR_INVALIDDATA; } - if ((ret = ff_huffyuv_alloc_temp(s->temp, s->temp16, avctx->width)) < 0) - return ret; + for (int i = 0; i < 3; i++) { + 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 0222565245..8329666fc0 100644 --- a/libavcodec/huffyuvenc.c +++ b/libavcodec/huffyuvenc.c @@ -430,12 +430,15 @@ static av_cold int encode_init(AVCodecContext *avctx) s->stats[i][j]= 0; } - ret = ff_huffyuv_alloc_temp(s->temp, s->temp16, avctx->width); - if (ret < 0) - return ret; - s->picture_number=0; + for (int i = 0; i < 3; i++) { + 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; } static int encode_422_bitstream(HYuvEncContext *s, int offset, int count) @@ -1035,10 +1038,13 @@ static av_cold int encode_end(AVCodecContext *avctx) { HYuvEncContext *s = avctx->priv_data; - ff_huffyuv_common_end(s->temp, s->temp16); - av_freep(&avctx->stats_out); + for (int i = 0; i < 3; i++) { + av_freep(&s->temp[i]); + s->temp16[i] = NULL; + } + return 0; }