From patchwork Thu Apr 4 04:59: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: 47789 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:24a8:b0:1a3:b6bb:3029 with SMTP id m40csp99036pzd; Wed, 3 Apr 2024 21:59:32 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWcnWpAjJ+UTGmZ69YHIqZ815l4Gha2Eq/29imbgmW5O2wgnV484vKZO5jjf2VTnz+/JuvaxJvifSjpGIRc2ugDcbvyTnbnUc5eQA== X-Google-Smtp-Source: AGHT+IFOATbdmxouwYGbOX5JEVYIr/VTZfcEGfTPmIJlBX3fJBxxVQGf5S7tHkEEQ3DTtV5lctZd X-Received: by 2002:a05:6512:158d:b0:516:c241:a912 with SMTP id bp13-20020a056512158d00b00516c241a912mr1110896lfb.1.1712206770963; Wed, 03 Apr 2024 21:59:30 -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 kf7-20020a17090776c700b00a4e223187fesi7433722ejc.681.2024.04.03.21.59.30; Wed, 03 Apr 2024 21:59:30 -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=VktvAhv0; 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 6B34768D15A; Thu, 4 Apr 2024 07:59:26 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-vi1eur04olkn2032.outbound.protection.outlook.com [40.92.75.32]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 56C1E68D13B for ; Thu, 4 Apr 2024 07:59:19 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=QVJ0Q58lJ/qEI1uazGbnNgevc1/zqfKR6izFXzo1eny30Mh6KYMKFIHg8M36Dt4bIVV7WzCBPDCSo7RGpiv5loyqdvFfw1I++m5D1Iy1MQRtfbdM+EbjY437CDN6E7pcoV0rBu9c3+98Ln2yCo11UllBtlVgbp6BNPxalU17RRx8P4aQFwMpDC9LTs9qEWk9bA+Y6/wrCF4m8Ows4e2AKRPS3lCaP6BAzYT77ti/mZx836hghSo4UoFC0gmDSf6jA2RFx/Ks9K3lCQNJLhLyRuqLgQ6IRqizejhARC3W+mjJeKjScb4owgFWHd635WYLArNAJDRvstpvsHzPx30I8w== 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=A5YnSNg3x+RdoHOxG9vbnk9v+1KlzG/Jd7q7YrpBSJg=; b=DNi72lKYUo89cqBE8qTUIMhQ+BYK+/iZ4uFmMvk/KysH4cv4eS76IRYLGZeHouIZmD1bFdisEX7keUK5OD+e7LJLXnF2/J447+Vx6YkaxvIOLD7MoqL5rVPU32V83JzNlGLT7M0/t0Udfu77RlEz8qBBbHsUnMJzAZJxhHbAnL3V+O6T3jEkS07arv4oqI6X2GFHulQzERM8ZTQGvFTIz+xvqKYnqsLQ8ioZ0bHKXZ0BhsusjXSUfdVspPGYpBoJuSgkYNTxR/c5i5vISOzbNYW/N/UANnoduzKXsJVl3Sonyb6+AKWYuomdMh+seous2kIywW+DEcoftEo/L9ohEw== 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=A5YnSNg3x+RdoHOxG9vbnk9v+1KlzG/Jd7q7YrpBSJg=; b=VktvAhv0Mzfp4ZlSt9Hv036NXOs1k5E4R0vFXpEJtKOObV2QXhoEBcQw0aYXl4dnqxTSiVN9IQ0SugiJqCbndZ05m1LAR6Toy0qZoDfn+ezFLkMLUVyGHU/B9eETyqZD/vqh/2U3meluqrpkHDAwXqibgklFBfSZ4zXwpO8lo7x5ZUL0cFoikrfF3FcQjuvQFLvvhqaTJvs5I3iuAn7H55YzXtVUIjO6P8gn5smGFEh26ECkKXD3AXVseR08nVpuxVLFf+18YQHyj/d+mWWdTL8zlttizFO9xGRWE2GkJrQ6uQkWr4FKWzCQFURAiXA0i+DA09B/9oi7Qz1x7lbRVw== 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 04:59:17 +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 04:59:17 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Thu, 4 Apr 2024 06:59:04 +0200 Message-ID: X-Mailer: git-send-email 2.40.1 X-TMN: [Epu5a3/wab0iJ7ODrmrXWUTsiVo5Duh1] X-ClientProxiedBy: ZR0P278CA0211.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:6a::24) To GV1P250MB0737.EURP250.PROD.OUTLOOK.COM (2603:10a6:150:8e::17) X-Microsoft-Original-Message-ID: <20240404045909.3450315-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: c7c78be9-312d-4aa7-ad7c-08dc5463fae5 X-MS-Exchange-SLBlob-MailProps: 9IecXKUgicCdj7HlD3lQLzAlIqBnD71IooEbHOyqfM7/RP8UhQ1abWVWlN4bIj+rxHyaxdZoca+Bo28vTQdmJ0HW50pxTBFaegUaRTfqP70pkiNm0yB+C1XCJLen1P3VM9eAp7FThXAzJS+FKZnX4TzjCsi3g9GDiG11x8lXdj1lMCxiQKNgbhYAUK0RmmNs2gJY9LUi6cBF0/VeC2MeBRFFQFnhXQMBGX+C+H6dHlnRdV4K+yVs5Bo6aeEpdwrH7p/qNkSqLE7S3LTfPV2H/gROAx3IrrWA5r4eIfcZBlfGLfzSmHlJRr3FpvDUrcS0H4Z3cJ7mMvl3Emg4SY7lODyNI7WYnS3+Wy4Xicv5hP+YISriuzpAG8Bqc+qw2rX2JESlQkiJZ5wql6iMA9tA4kg2O2uykWRGhjC8CqBs8GCQGCyvrDtPa1aHVIOecCOYmbIQ82YXTMcuJsDIJsNPHYRgEM+tAyF1u8WcimaKfvg3yvLTM3Ucidx6wy4TUFuHhIHZZgmIXO1fnaZr2XPN8BJ5/RfO7DPDudybzO+2iLCcUTu8YgO5hSNVIOSiWWRAmSnlUg/j8g/N2LpRPsvaFtnjhSKcgsSbaqm8nJHjiN5Y1v29HPYfYZ9wHU1eXGcAqB90ndS7tnLp/pOM3ulYsTWvcOhXXhSop+/yySEL4V8XLRaScvb1rk564ncImZba3ncPnGNpYLZILapv3Z/LaC+iF81GxXMnUQrkW0HSTzxVcQElTCrfUA== X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: bKeilnEv9y8qQ8xreltzXZCiefZ8EL1W2+wPfwXZWhLNq22XPfQxhdobqftpYpQI9y3zHO37r+cutiO/KNKMRUzo8zxciXadphd/DebhKyVDdXEJId0qUx1vgg5RG0xkwErIg3oCnoau+uHjV/2R+SWIuV4lf1zH42supd+wUa4ge6ANXkbPWiv9vG0mq2yXv4OI+PcL+RI/VV0DmcRT7IfiSkLURKuE+lDeNREcfsXzLTCz19WWOzbewBXNPwzDHRehWnROXW8yOU6Q1TcPkYtsQKFFo6NBWhqeHUFzDgY0PwsQ01eDnyx6sn3JaJRcjB+1VqedUyujjiMiD40WOc9Tf5sH+xfqdzNEDLLJfV8tH+1b+kSuQHem5elj03BCC+Q/7/2XpLH2NHvPdhHrjD7ovJe34a1v9ogiv/vvNKhTY8iojth4xt8UTfDXKZRnGng9jLF85tt3GQnRJ3Rh9vc0uju93fXD8v/QTfSidgec7xUXovGBL3fIjPPDs4gCLuOBhpXlz5NDkhkSTgyISCAEMUb0whGW6lEtHzbalIdDfFSVPX/SyXQMEb/TaudNR6FYId56L1DKZHsYrHGZofXKcUjerSNNbr/CY3n2+HkGv/RxHAzyueU0RupMkZjr X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: rMvSETiHrSiuwBRMxQaL6JgH3wlyZpMQPMYzB14bNx2PgpY/8O5i6Ah8WYTqLJAynGJvjVwEIM0dXxJjPpxmL22d8+LIIIl4JA4Lq8kra4D8lthPj07PpX/dakAp5ugQLqRJFGcg5FrB/gkXTK2+Ec1DzqeHcwANl18qJWrPHT2dLny4YXYgIlzrlmswfhlytc5LXjrAy2LwhSIFNu/5mlPSiaLgN7IoDrsrCicZdaY+lbGn7TRQto1RaIYLOZ9nfdX8GZ/S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c78be9-312d-4aa7-ad7c-08dc5463fae5 X-MS-Exchange-CrossTenant-AuthSource: GV1P250MB0737.EURP250.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Apr 2024 04:59:17.0554 (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 1/6] avcodec/huffyuvdec: Don't zero unnecessarily 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: tCK2h0AP2HaU A decoder's private data has already been zeroed (apart from options) before init is called. Signed-off-by: Andreas Rheinhardt --- libavcodec/huffyuvdec.c | 1 - 1 file changed, 1 deletion(-) diff --git a/libavcodec/huffyuvdec.c b/libavcodec/huffyuvdec.c index 3bed27be21..29e5419d91 100644 --- a/libavcodec/huffyuvdec.c +++ b/libavcodec/huffyuvdec.c @@ -346,7 +346,6 @@ static av_cold int decode_init(AVCodecContext *avctx) ff_bswapdsp_init(&s->bdsp); ff_huffyuvdsp_init(&s->hdsp, avctx->pix_fmt); ff_llviddsp_init(&s->llviddsp); - memset(s->vlc, 0, 4 * sizeof(VLC)); s->interlaced = avctx->height > 288; s->bgr32 = 1; 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; } 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/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K7quSToaFO8sRQ3A69s0k9x0zAy5OzCOYCFU7sFLr+qYYQHiVDO3qfoZ8YIPLLfyikTCL35CpOtJ7OHVwy3/1Vs6lp9yUn5SaQixo4h8MXBhE1gE254lLFdCbXx8X3lZiv6o068ruOQMte2Xo1n4nrckWuDq8rKG8EfPHOcjJi3TV6rESNXurdVB6HEC8CXbyJ8TFLIqKRLIrahrEJgzdcOrsPketuUYG1IsgZiM8tfx3NOP0o8RXfZ48GBYSJN5rU81sA04nQ41otynHql4jGItOeJxrgfhfNw6yPSUzPpqUjG0jUExwdN4Q== X-OriginatorOrg: outlook.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; } From patchwork Thu Apr 4 05:02:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 47792 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:24a8:b0:1a3:b6bb:3029 with SMTP id m40csp100615pzd; Wed, 3 Apr 2024 22:03:30 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCU6h+mHJC9/LfwjigcPrFvk1ZoEP23ZbaDNOSC4c4+WdVhCMVOie9d0x7QsFXzmciAhtGD/1zAcfISSw2sx+e21bANbroxTgP+aTg== X-Google-Smtp-Source: AGHT+IFLBWHfHMBFqkqaaLKW3iimu70EscgA/ZywGloaDEAL8QMz4OFKbwjdFjlltjKYEIhw5nXt X-Received: by 2002:a17:906:a290:b0:a47:134d:2fc8 with SMTP id i16-20020a170906a29000b00a47134d2fc8mr4010788ejz.10.1712207009758; Wed, 03 Apr 2024 22:03:29 -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 jj22-20020a170907985600b00a518fdbdcf1si14930ejc.521.2024.04.03.22.03.29; Wed, 03 Apr 2024 22:03:29 -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=fgOxzvCe; 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 330B468D16D; Thu, 4 Apr 2024 08:03:09 +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 C0DC268C068 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=FdrJkmoQ+wp9cAH6/kl0eaMrMJXgxaHLGa3B/sSI/CBxSz0jEJIBMw0TwM0WOS072jpXWHP41cWBkYKb0QoshjvmftIVWUMk0S9VbDZ3V3tZBOSYL8GNuNtscZlk6HoprwGQG41Dq1RYUg9vHl6J9HfW4dp5TdvKr6vFw2oIkYaYErliGiRzseCuNEoRIAT28KZyDhZ+g3LHs0IopKdWoR+MY3u8/psN7bT4CKczlrjimF9utnThNevfFqtyVW3w3rh+a0xHsUqfMz0FAGL7vZ5sVVOXHc9yfBySU523xSqEzqP9tzF3hYPlTveGwu4Sibbgny8aDEy4wD4i689rPg== 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=F5Qju5+OzPAs8MLX6PQ7j7XYj5yLQjjVL+I/Z3IW9vc=; b=LOjMTnpj95bEU09y5410sUrRx7oVL5kQ6lCyIi4XsSjUIKoDo/hRph1VCywL8s/VDecZ5Oc9s2ceWWRehGQ2ulL234i35MG4FvzH0bMzASxEIn66VQGhi8oda3RAbTw/DSeFvR0djt/Mw2nz3qHNVPSz/HE0WtelgZG3bpBjVMiVom6cCVRZGc/AVfWx1jWB6PAIVFnLXCiU9g5wOTzfadA8/cq9Uk7Gxza/x3akjdoJ3L6R+S0eifGOdVHeMqmPh9GOgZAiruGG8AfEFlw9u4OxgaNP4S3RoKMkt8O2DiKtvArasKHKFUVt+vSkSQdx+lxFjQVjIDznRiZAzIVuAw== 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=F5Qju5+OzPAs8MLX6PQ7j7XYj5yLQjjVL+I/Z3IW9vc=; b=fgOxzvCeJTHPcqqj4Tk8ksivvEhTgHqLg3qf2bdAHv8cMcS7hV8i9LeelYWT0wq1D3cxlbgZLeXjojCwFCO/KTuaOz91HORCwG9buG52kcicPjAmfSylloARko7TeEJMfs0LR43NjnzKOHk5lN5dVHtC8f8HcHhRM/9r9FJtDw2DaxAUxocybcNWrKkHtEhMSEn9jkvtIynFdnZ/ZRfxNZvlEW1lHnV2X1hI+U9jS652mvddX2ZrK/jFPDeMOB1JMOK2i7zTDHaLbOoN6cBBLpyRidNxrO6y0xcPbSwD5Tc+DYs1leWGBu04cOpZhC8eB5PsYjX0fCV8oSMXVWEzsQ== 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:01 +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:01 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Thu, 4 Apr 2024 07:02:48 +0200 Message-ID: X-Mailer: git-send-email 2.40.1 In-Reply-To: References: X-TMN: [d18RfRST68lCAOrNbX1hJQFniXDE3czJ/hXYcgn+Zxk=] 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-3-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: 4dea3817-b3a5-414c-aaf8-08dc546480b0 X-MS-Exchange-SLBlob-MailProps: quCBMN2EvO+/Tg02NQSOAqMNnTlnxFBGqTCoZdMLb9RDuH+Q/LQ+P6Nyb7fV9EvtaTTYefqybzndBBoXQvdDArX0ZAucVXjznamqTZhScutg69Q44RWVS2g5wICLpZX32hgG85XhUiH2+UJ9mqKaOc+R2bGzd0SaTkKXQfQ1nSg/1zogLII2fim7qqTLItWKSsYvlDf5QDfqr2upW5Qh3i9uVd3/yu2MjiXOeawCqbdcYQN25c1IYKG+RA3AwXtRzHvQqni2hNTy+XdJUk82Y1zYCXLNyk8zlJ59E0go4zz+NvQ8ObCOlAsGiboIC8XiPOWIRWq5JS+ZoHxvfK+UXZHYyrhSc1YzouyDWuyxkBDjlj/LQlWXyZeORrxMudbtqKCchdy7Ot/kALt57oYRNO1Zt9ziYrUmZFX7I9b6eudDXviUA+VmYixhqrQbzVp6FrWhNkhrFMJT1auBdp3riElfTNrH1PyME5LOXpaRxriQK186QQq5ukYOIjCkjtdYQu3NqKA+D9YfEUXXF629an9GOIwrUT8iEJZ2B4vfPU1EStSUSHyvshUF6YLaB04rCzEd0yzJ7SxsToDYyGkkzFfkLBAQGipi5CHpIr9vmNY3ilzbylJZwsRgBdUDYMFYX2peD6cAFITMlvz4GBLFkOt5p13//WBDcs1L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aaf8-08dc546480b0 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:01.4317 (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 4/6] avcodec/huffyuv: Return proper error code 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: nf7UYDjXUnlm Also forward said error code in the encoder. Signed-off-by: Andreas Rheinhardt --- libavcodec/huffyuv.c | 3 ++- libavcodec/huffyuvenc.c | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/libavcodec/huffyuv.c b/libavcodec/huffyuv.c index 723ab6b92b..f22c5ebc59 100644 --- a/libavcodec/huffyuv.c +++ b/libavcodec/huffyuv.c @@ -31,6 +31,7 @@ #include #include +#include "libavutil/error.h" #include "libavutil/log.h" #include "libavutil/macros.h" @@ -48,7 +49,7 @@ int ff_huffyuv_generate_bits_table(uint32_t *dst, const uint8_t *len_table, int for (int i = FF_ARRAY_ELEMS(lens) - 1; i > 0; i--) { if ((lens[i] + codes[i]) & 1) { av_log(NULL, AV_LOG_ERROR, "Error generating huffman table\n"); - return -1; + return AVERROR_INVALIDDATA; } codes[i - 1] = (lens[i] + codes[i]) >> 1; } diff --git a/libavcodec/huffyuvenc.c b/libavcodec/huffyuvenc.c index 4f709143a2..152f94cefb 100644 --- a/libavcodec/huffyuvenc.c +++ b/libavcodec/huffyuvenc.c @@ -232,9 +232,9 @@ static int store_huffman_tables(HYuvEncContext *s, uint8_t *buf) if ((ret = ff_huff_gen_len_table(s->len[i], s->stats[i], s->vlc_n, 0)) < 0) return ret; - if (ff_huffyuv_generate_bits_table(s->bits[i], s->len[i], s->vlc_n) < 0) { - return -1; - } + ret = ff_huffyuv_generate_bits_table(s->bits[i], s->len[i], s->vlc_n); + if (ret < 0) + return ret; size += store_table(s, s->len[i], buf + size); } From patchwork Thu Apr 4 05:02:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 47793 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:24a8:b0:1a3:b6bb:3029 with SMTP id m40csp100647pzd; Wed, 3 Apr 2024 22:03:38 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCX7O30OV9i8no78QCxqAQr1iWSH2Jat7Ukop2zKsba55ZWADAkxOyJn2zueaPOvdayexnBYD3zI8nU/lQgAO6qThd+Tbvr6PW0cqA== X-Google-Smtp-Source: AGHT+IG05P+2D/LV+diwTCa6bShZ5uOrp17tDK4EnYZrVa27kSmqJzlGMRIMBCjZAT9B3FPHlzx+ X-Received: by 2002:a17:906:a0cb:b0:a4e:a2b4:59c with SMTP id bh11-20020a170906a0cb00b00a4ea2b4059cmr648974ejb.6.1712207018084; Wed, 03 Apr 2024 22:03:38 -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 lb21-20020a170907785500b00a474107fbcasi7361998ejc.652.2024.04.03.22.03.37; Wed, 03 Apr 2024 22:03:38 -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=E5UzQ7u4; 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 44F9268D19E; Thu, 4 Apr 2024 08:03:10 +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 E2A7468B43D 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=ncP5FOfcLR6RMXF9/H5DlBVs22YRoB9dfSPpJuJaWshEttYj6P9YQ7ciul0PkS8hEdDs21kRTR5R4EJI6zotCFLvfTShTZ2P2pOlyQT88fjMs8QS2JKfPa8AjyBeaeTJqd9A7lw6tqFNpDJU54GnwHg/XUZIC9C5tv1h/Me8nWHR0tJJqzf8Z0X0XkPzgaZ6TTK4YEQwkHKBAXT8YL4ZH6Jh2vsdpB7iugm5J5hg6/tZauP7QOJfMxY8SSWVtAus2BJk48MRyH9kehcjT1ugsteSnTmEuDRk+vZ652AvjW+/MVFtuLdH1+BbFZ406UG/zdjSUZEsBA7+OjjrKygmhw== 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=KFr3Bb+tUnkgLZ3yiWv0b7gZKoa6xhOJo9XG0+6PeiY=; b=MQoZ+YDwqOYr72IC73xeplcW9p3sg95eUIzp+5ZNl1XKlSW9p0sYaa+7ejo2ttgRj2CpmpF4qZl6zWhycViri02c2eT9iIOod2CufQlEUOZNjtru7cO7qgJlcgGhQqnrpJSn8OrTlq8EYVJHfR3qjLBwartLGYe0KaaaM/nxmMPiOfuCrW3hhpRSW6OsOoFhNllrz4UrcXY8YZa64sUmx7z4BedbMv+pdDNnMfcEsM220HDQTKuGg2qJzHjuGzI2MdE30N3Gsg9X7oTJOQ5Gk892OIOpi5kPBex68Udx2waWei92ZCmjYf5ufRMi06MZA9I6f4hjtSPPriBzcah/Vg== 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=KFr3Bb+tUnkgLZ3yiWv0b7gZKoa6xhOJo9XG0+6PeiY=; b=E5UzQ7u4xCJXpu9CtYxe+kSCHV/aTDP3HQjtMhCBZvGw+GxABDDaUeUTdTtpe33eevVF/U8MMIopL5nPL3pAi33wcO9e8Vr/ZfbQtqJWAf5grsVOauZk58St6fXlAZ8Wh8jN8WEKiWOxTx/4ZTNmfCvebM7X34V881ZbxG3MNr3tQ25dRYzyiz39UOzakf0eBOEAuGLHL6PY2DIUMY3TSnDNaI06wDrWgnfBjpZmaK6yxkZhNrxsxJ+guDKFWrDeYzSkn+6femUp8T3fcnpCMEoDl+cIP8UJM3fhvYfqhasUj28BKhvbu9G6h4XaxRfZ6IgS84uMoGs0BKnmDUMa2w== 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:02 +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:02 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Thu, 4 Apr 2024 07:02:49 +0200 Message-ID: X-Mailer: git-send-email 2.40.1 In-Reply-To: References: X-TMN: [oAFHGw43d3cEVnBOGPk/sgKjnV4GYn2OqbM2m3Egx9A=] 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-4-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: 21ddd5e0-e00f-40d0-13fe-08dc54648162 X-MS-Exchange-SLBlob-MailProps: 9IecXKUgicCdj7HlD3lQLzAlIqBnD71In4YbHjWxTGOUx6B5BbSJPCbDnZwrqt49QhdVKdfMcLeJTS/eLkqXqocOQR7NfUmfb/CZWM/tVNpRQrL9bs6vpBultF8KkOh+Ndfwz9NJGS6R/BqoBUYjEQ3vkQHRiSmpgnvXJVQPqLEPEAggVIrYqvkW4CSM2WLjAbFi71nCborx244+9IbcEfleTRjPBnjdBJSzqV3A1YDuDWAt856IO8Uh5uY4mKlybvZC//3eByFMmqO63KfMVCzRXtXf8x5baejVuALyI3MDvjyrt9867cAdC9fWi/8Q0zV0VXc3Z5QCG+Ay0g7UJRS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Y0k5PmdvOfCUi3EIQsyenhWX5buoxjdC5UVxcAKvclhGv5RAPAfwf2qHIGWkK5h1GYqTJjOw+pxdW2pZ5Cnx7jSXZkiZLlTayt3FgT02XIhYMlwJDNEPmnDyHwPacg2BR3pn532j10u8t6ACbYtJxVpbfmolU1hssLDqbQPJTOslF9inijYHPp7F+pHZPUxBOF65SSjutQcoSHbw4iy6hg0wnKtxcmtB506s3br91+fQ4TuSd2Z9sKSt1OraKm6XOP/mBSuqea6vnR/FXOcxiNwS0dv2xltuVAJ5Zw== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 21ddd5e0-e00f-40d0-13fe-08dc54648162 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:02.5824 (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 5/6] avcodec/huffyuvenc: Avoid duplicate variables 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: 20ZP18zx0qF8 Also simplify assigningfake strides. Signed-off-by: Andreas Rheinhardt --- libavcodec/huffyuvenc.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/libavcodec/huffyuvenc.c b/libavcodec/huffyuvenc.c index 152f94cefb..fd6b01de81 100644 --- a/libavcodec/huffyuvenc.c +++ b/libavcodec/huffyuvenc.c @@ -755,16 +755,15 @@ static inline int encode_bgra_bitstream(HYuvEncContext *s, int count, int planes } static int encode_frame(AVCodecContext *avctx, AVPacket *pkt, - const AVFrame *pict, int *got_packet) + const AVFrame *p, int *got_packet) { HYuvEncContext *s = avctx->priv_data; const int width = avctx->width; const int width2 = avctx->width >> 1; const int height = avctx->height; - const int fake_ystride = s->interlaced ? pict->linesize[0]*2 : pict->linesize[0]; - const int fake_ustride = s->interlaced ? pict->linesize[1]*2 : pict->linesize[1]; - const int fake_vstride = s->interlaced ? pict->linesize[2]*2 : pict->linesize[2]; - const AVFrame * const p = pict; + const int fake_ystride = (1 + s->interlaced) * p->linesize[0]; + const int fake_ustride = (1 + s->interlaced) * p->linesize[1]; + const int fake_vstride = (1 + s->interlaced) * p->linesize[2]; int i, j, size = 0, ret; if ((ret = ff_alloc_packet(avctx, pkt, width * height * 3 * 4 + FF_INPUT_BUFFER_MIN_SIZE)) < 0) From patchwork Thu Apr 4 05:02:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 47794 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:24a8:b0:1a3:b6bb:3029 with SMTP id m40csp100698pzd; Wed, 3 Apr 2024 22:03:47 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXXLlgltjYO04NViZPkad5opNH8lrVFko0mc5k8HqQSmM/GZ+mRulQA9aDfySruSn55TcZj78NYBIIX+7fl+rkGeXXS3QHjUjjmmg== X-Google-Smtp-Source: AGHT+IHimt6HW84xDpWudX7RRceMpkU1qItW7xXMuzr/J67Qhjhfb9jA4fIS0KUEfefX87fXoiMg X-Received: by 2002:a50:d75e:0:b0:56b:986b:b4e7 with SMTP id i30-20020a50d75e000000b0056b986bb4e7mr1024103edj.27.1712207027056; Wed, 03 Apr 2024 22:03:47 -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 i21-20020a05640242d500b0056c465c3797si7814545edc.70.2024.04.03.22.03.46; Wed, 03 Apr 2024 22:03:47 -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=h6CWQN0z; 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 5E74768D1B3; Thu, 4 Apr 2024 08:03:11 +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 30C5768B43D for ; Thu, 4 Apr 2024 08:03:06 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cPD96m+ZS1/fEAz61mtdb3hYFlsJxvlR4Cshhi1S2H0jJgGWN2xg12V5rgOHXFjqiUQlsUuWVELwkpOTNcSDcCmTLcFV/lt+TnVN18XjuSRce1EvD0+hjSqyDOMXcUI2YIPAuusAFY0OKh7eItzYa+f1r18t7ko718t/0hg2kdNb9xsI0Y2Q2KnbVvBzxoWSU6puStVRiae0PiHSHDkMc4Vm0QUcPpMneWy5a6ZmIKVNV7+uWKnRATX1pVE/sP6nfvPOl3s4wnnFoZgcfqM/tfL6u9T4lVL3Ka9auPZdJz/vSlHbAXESml7YPrwnVDBaujqgl1EKS+lTPtxJD9bCeg== 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=2UpOj7iSh6A991FEnC78fHa/S0qw1Af105NBDWddq9Y=; b=i4Qpwg2QBiRpMVVMHWYGtgsXqdbUGWS4zPjG66oi8oukmW/PonqOtq0oF0MeasO4CS4Pd4Ic9HMQYiuMhkuV0XffFBLdo/iMmqgr05g5fonnfV4hcv9DeLD3ooRGs3DshcdUthT2JXbZdWOkYNgRbagiGwqTPo+672kRf3pRTTeSoK/N35y4LbbUuGDNcBDCGW7+92zwWWF30vSOOi7FVH9osTrNP9dN0x6X3tNcGvGm8sxxereLFCoiyp8Jy1hxBSL+gIJpfLAV0OqVFEnlRslwq5G11KcxzJs255TBby9td611zNfUq1Dit618JiJ7Jpd5Gw5lRTUftL3f35NIqQ== 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=2UpOj7iSh6A991FEnC78fHa/S0qw1Af105NBDWddq9Y=; b=h6CWQN0zDzwjm/iQf8oIiY2rr6BAF9VSzuDMBvWPT2Ghqf9EfId4IzjkEegKaEe/repPX7qZFvO18TO3UzgM/HYlnqIQUvbUMxjSRsLJblqTOJa67VKBVw9Ojitzvog9S6VPvQG5vKvR9eEr0j84ekszzyYh36fonjm1WmereKoa0Kj98OR2a/UltlBB8nakFQXusRC9pp0Cw6DKYxhpHyvZ7QhrSIwJMe86DyIcUnklsYWLJncqNXmI7yNd1M96fYyKrLQXPB/y7NVEbcrJi6w8qFBVOjcxm0iV7a3lDcF79JQ6extwaiUhrUZN+CwID4ruKFluou7cqkldrrLSNw== 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:03 +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:03 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Thu, 4 Apr 2024 07:02:50 +0200 Message-ID: X-Mailer: git-send-email 2.40.1 In-Reply-To: References: X-TMN: [pfU6HgoIaZoGWVnpenmVQqh+MuwmCM1gAXJ9ZPyHVG4=] 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-5-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: 76039cb9-980b-4b65-2f15-08dc54648221 X-MS-Exchange-SLBlob-MailProps: quCBMN2EvO+/Tg02NQSOAqMNnTlnxFBGee/+bcf8dxwG+xvell2aJ2jhJ8ubWD5PxO17Gz94vtAfsU1O/P7smXzM9/vwwOqI4LluYEgCFpT5ABMx5CMQE7KlMuy3+vIV7TJUkGOTeT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ZNs9cKl/Nwh4xRnyffggzG2c+2EOKYUt+FAoCjcDHv0lC0rUWO+LKbRQXkwZQdmRFVDMA56gnG3KSeWD/AAfYxX8Sb3Mg2t+Jk+jHMguetsZmb0+UjfSsnUeRxAUnGKt9dGRStBpix4gYPHI3hn0XouDghf4NixEeOZJ38uRk29wdaOtv2DZMx2mYZAYPr2ZV9NN47sB7jNDrX3lCpa9o/eKL9q3ryRag0ZRJamCewMU5ENGiWlNCJXrw3EDxWyq7fYSh2nKfxXmaY6bKocf3EhERfC9sKEDxfPOh9MTyipyFsxejEdxb1nGkGL+1KtiqmCjTpK3N1mJMacIDZTxpAg4kR7wj4hLAbbQTV8eucvXrAEKSrXd7fo5QAsUH9+V9kx6ajp4SByYnA1Hn2u3Z+1z2yLkfnAglJrrdG8vhAGRh0SIYQF9xRt6ZFMqubgSQK6V8FdK/4IQHqz7k3RhTnc4lc1KL69g== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 76039cb9-980b-4b65-2f15-08dc54648221 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:03.8833 (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 6/6] avcodec/huffyuvenc: Avoid code duplication 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: QZpXYrxXHq3t This also fixes misindentated code. Signed-off-by: Andreas Rheinhardt --- libavcodec/huffyuvenc.c | 146 ++++++++++++---------------------------- 1 file changed, 43 insertions(+), 103 deletions(-) diff --git a/libavcodec/huffyuvenc.c b/libavcodec/huffyuvenc.c index fd6b01de81..d822793406 100644 --- a/libavcodec/huffyuvenc.c +++ b/libavcodec/huffyuvenc.c @@ -499,7 +499,7 @@ static int encode_422_bitstream(HYuvEncContext *s, int offset, int count) static int encode_plane_bitstream(HYuvEncContext *s, int width, int plane) { - int i, count = width/2; + int count = width/2; if (put_bytes_left(&s->pb, 0) < count * s->bps / 2) { av_log(s->avctx, AV_LOG_ERROR, "encoded frame too large\n"); @@ -546,112 +546,52 @@ static int encode_plane_bitstream(HYuvEncContext *s, int width, int plane) put_bits(&s->pb, s->len[plane][y1>>2], s->bits[plane][y1>>2]);\ put_bits(&s->pb, 2, y1&3); - if (s->bps <= 8) { - if (s->flags & AV_CODEC_FLAG_PASS1) { - for (i = 0; i < count; i++) { - LOAD2; - STAT2; - } - if (width&1) { - LOADEND; - STATEND; - } - } - if (s->avctx->flags2 & AV_CODEC_FLAG2_NO_OUTPUT) - return 0; +#define ENCODE_PLANE(LOAD, LOADEND, WRITE, WRITEEND, STAT, STATEND) \ +do { \ + if (s->flags & AV_CODEC_FLAG_PASS1) { \ + for (int i = 0; i < count; i++) { \ + LOAD; \ + STAT; \ + } \ + if (width & 1) { \ + LOADEND; \ + STATEND; \ + } \ + } \ + if (s->avctx->flags2 & AV_CODEC_FLAG2_NO_OUTPUT) \ + return 0; \ + \ + if (s->context) { \ + for (int i = 0; i < count; i++) { \ + LOAD; \ + STAT; \ + WRITE; \ + } \ + if (width & 1) { \ + LOADEND; \ + STATEND; \ + WRITEEND; \ + } \ + } else { \ + for (int i = 0; i < count; i++) { \ + LOAD; \ + WRITE; \ + } \ + if (width & 1) { \ + LOADEND; \ + WRITEEND; \ + } \ + } \ +} while (0) - if (s->context) { - for (i = 0; i < count; i++) { - LOAD2; - STAT2; - WRITE2; - } - if (width&1) { - LOADEND; - STATEND; - WRITEEND; - } - } else { - for (i = 0; i < count; i++) { - LOAD2; - WRITE2; - } - if (width&1) { - LOADEND; - WRITEEND; - } - } + if (s->bps <= 8) { + ENCODE_PLANE(LOAD2, LOADEND, WRITE2, WRITEEND, STAT2, STATEND); } else if (s->bps <= 14) { int mask = s->n - 1; - if (s->flags & AV_CODEC_FLAG_PASS1) { - for (i = 0; i < count; i++) { - LOAD2_14; - STAT2; - } - if (width&1) { - LOADEND_14; - STATEND; - } - } - if (s->avctx->flags2 & AV_CODEC_FLAG2_NO_OUTPUT) - return 0; - - if (s->context) { - for (i = 0; i < count; i++) { - LOAD2_14; - STAT2; - WRITE2; - } - if (width&1) { - LOADEND_14; - STATEND; - WRITEEND; - } - } else { - for (i = 0; i < count; i++) { - LOAD2_14; - WRITE2; - } - if (width&1) { - LOADEND_14; - WRITEEND; - } - } + + ENCODE_PLANE(LOAD2_14, LOADEND_14, WRITE2, WRITEEND, STAT2, STATEND); } else { - if (s->flags & AV_CODEC_FLAG_PASS1) { - for (i = 0; i < count; i++) { - LOAD2_16; - STAT2_16; - } - if (width&1) { - LOADEND_16; - STATEND_16; - } - } - if (s->avctx->flags2 & AV_CODEC_FLAG2_NO_OUTPUT) - return 0; - - if (s->context) { - for (i = 0; i < count; i++) { - LOAD2_16; - STAT2_16; - WRITE2_16; - } - if (width&1) { - LOADEND_16; - STATEND_16; - WRITEEND_16; - } - } else { - for (i = 0; i < count; i++) { - LOAD2_16; - WRITE2_16; - } - if (width&1) { - LOADEND_16; - WRITEEND_16; - } - } + ENCODE_PLANE(LOAD2_16, LOADEND_16, WRITE2_16, WRITEEND_16, STAT2_16, STATEND_16); } #undef LOAD2 #undef STAT2 From patchwork Thu Apr 4 17:52:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 47802 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:24a8:b0:1a3:b6bb:3029 with SMTP id m40csp486020pzd; Thu, 4 Apr 2024 10:53:00 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCWsUewNYSFjKIKAUKXjw/eSgezHnBr9jYYpoAlInScMCdopkL9t2aAMkJWH7A5/HcH8uNkHADsWDG8JsOfjG8eBNQ2s0QuwOQJqsg== X-Google-Smtp-Source: AGHT+IHz3ROoNmdoQzuAmbenpaXZJVVdkBV1wRXInx+c1iuqbFH4/3t9aK6gALzGKRGaj1AlHJ/w X-Received: by 2002:a2e:804f:0:b0:2d6:b698:968 with SMTP id p15-20020a2e804f000000b002d6b6980968mr1888891ljg.1.1712253179778; Thu, 04 Apr 2024 10:52:59 -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 g7-20020a50d5c7000000b0056ba01693afsi8176289edj.510.2024.04.04.10.52.59; Thu, 04 Apr 2024 10:52:59 -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=JbQQyEm5; 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 43CDA68D0E0; Thu, 4 Apr 2024 20:52:56 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR03-DBA-obe.outbound.protection.outlook.com (mail-dbaeur03olkn2055.outbound.protection.outlook.com [40.92.58.55]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 492F768C1CD for ; Thu, 4 Apr 2024 20:52:49 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MkxQlpZgsDkzF1MIwfWe5vdWZM9eg163HGzSK6CoEDAQOzmZLwaNguJgTP/VXEbtcgnwJXNEwOvMKoA36SDI3+SZ/4wIVx1kWy1u7+6PCtfrtpghpHwi5NcqfrMqE850T0WO/SonVAM2IuP3GTifK0+VzvYzw3CxmKs1se6GLyNLcBqlczAdzGZmRVs36xAu1OrAJXzWm6EGTmpa9lFWewOzNEJkNwtqxDeqsa6j/fFMIP4PNPrnhKhui5QlroRZ2GhH1KBuOk7K9uPYyvurU8twFMZdHmGjrS+7IiOHR+LyU5t7g8IhHmhHXDMzJh/6D4drdcGCF73mJcnaG7vj7w== 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=1nW7nhfDET2RZ4MDf86xj2YyhZacL95+pkx2TrVrwoQ=; b=lIKpc8+G0FISH6zR7cUEXUjpPhqFBGJijfNW9+EVNwcnMKP3Kcb6fc79Zq24fwfUNhCzK7XwciswDGwHcrJsOU0V13ttg3kESQ/FtWNlbmsU6WanJ4zyzaHo/uYPNVqyvd8aozBQ/2WwyrBapXJt9LgpxU77ckgpiXwuynukUal25oLUvSPwCYwzGPTgzWZhi0q4/I9qv1ly1LyKM7pLHs/0WyYLG5/xemh6dod4fi7ZXcVGmCGibHVcJn5MANPJqIN6C2EHUZCGhi2hzsgSr5niIZDY+kmaKqOyb8NvOgHOyaWiwVoQOp7byWNrWoHQCPuvsc2nZpNXRLU0uQyBZg== 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=1nW7nhfDET2RZ4MDf86xj2YyhZacL95+pkx2TrVrwoQ=; b=JbQQyEm5WJAj0GG4FIqMwHQEgZ89vQUH/P/dBbCo2tNOBEkW1hJflllTctGM4YyPhxTrQPMc0M19Mg2krVZQXzmbyzGU2+NzdK3GZHfJVdF/moe/YTduGvwiFLlPgeV3KNOaHDEegP2BbhMMLgyvnRw7t4O0aExiIUNAf8FEloezS8t7UUICtnf92k/NAHzB33RUxS5MhgdAkPT3s08vCTuNwDr1jXGmrPVgo8I8ueio5xcVNWUEXM3PMX53hk2yU44v6bDVkkqHDTRzN56401Z5HFe1pIcr48aEMLXQKbe8gnrqhnXwO7DmANxh7VfT4W157fLrcg9kKC1IoiEnjg== Received: from GV1P250MB0737.EURP250.PROD.OUTLOOK.COM (2603:10a6:150:8e::17) by DU2P250MB0077.EURP250.PROD.OUTLOOK.COM (2603:10a6:10:23a::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7452.27; Thu, 4 Apr 2024 17:52:47 +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 17:52:47 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Thu, 4 Apr 2024 19:52:40 +0200 Message-ID: X-Mailer: git-send-email 2.40.1 In-Reply-To: References: X-TMN: [VAR0I1xLXTO0sk2yY8bPuPKSM79y6DceQtXvO+OgCqg=] X-ClientProxiedBy: ZR0P278CA0088.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:22::21) To GV1P250MB0737.EURP250.PROD.OUTLOOK.COM (2603:10a6:150:8e::17) X-Microsoft-Original-Message-ID: <20240404175240.3797192-1-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: GV1P250MB0737:EE_|DU2P250MB0077:EE_ X-MS-Office365-Filtering-Correlation-Id: d3d8ccde-90f7-4942-9201-08dc54d009cf X-MS-Exchange-SLBlob-MailProps: quCBMN2EvO9JfgqHH6vecaSGf4XO3W/nrSBC6WSizB5ZkFhhxy0tFiHOw/otve1ZkfPtLX9bcdZnPxnaQn9nbcQ2ZPIXVNcb18EsrlJfJ7sB+BO3hqQbfINfvh3T//0P3C0rItGQTOj0gZATyaeGXTQ4QqhxRXQuXjPka8B/q+jw507nod0nvC+s8DT0S32I+ZXbF97+7LTARdNFyHsYoAMpCr+jrUPMgWQaPpWtt8qukhlitDPO96Bf42Yj9JxAyWD3WtGrOHuluACkI81P5WiV48rBVZ1tnD9BOPRUQUIQrgG/ChBcQF39flPE9dx0GBp1TZNSVlNSm9ka2kh9nUTYJQTGlocqzCeESKF7xptbRK3DD3fe8c3ZAv3seu2GlgsGO59SmJlL5GK9jOp6ZbpvZzRAjC6A4fFyr07LcIbQWt3a9+2uuQCRogS212Qg5FR9SuX4wK8gfyQoK6pof65oGRcDwR+eKF/GImbVLD4+fXnFFnRmwFB5jsoR5g9achPzZ7k9rQRhjAtNNSl9vSMeQhchZBkJbqsCv1oeINRvixutne+bK3E0PtPZYOzxn8/ZGJovvYTGqirJiobsZ884HnvOH7Dxamf1YQjv4eUzH/bS9OBKwOMHNJkzvSlKBcasv7f8zFKwW6eNEk4VNZ5mCwVjcLxW5Hx/tEYfEisHANG4ZDUaGMyroDgl7g6HCWTYtC0UlWU8CM+CwXiF2g== X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message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nRjnLfZDX1Bp9nYnyd9fhF3MusqV5PpqMGLsuqDwggUKC0k+LssgJV3y1qEIzDtWYtfNTYQ/uMMaFt6Ws6uiDUTd3Pbi9EXmlhW3hSRHIlmWngM3KDlnxdZ2s9VfD479FPMwO9+uuUvueZvbZGhqhx3JTmxkxhF01yPmQPhiS3FJ9ffVZMMuQN+E9m1YeoRWC+/7SUYNr0YCfG2hBjWfAQ+sSJtHRp3H3Xc8wotvP+HaZwgq+gSRyKbDShJVNSnmmD7uLvjKeLu2n+OhHOt7UPKLX6uWQFb2ggOPvIYpio3Z8zScJDmPGF1+DGQrlgJF1FD0cpjz3fFWsMM9OzW7Vibfagmm53k6pdx8EdYMpp2CqMT6guyt66tml5cl51qy9gF17k0CXXRwYs/LQ1BBDWn+2y7ZPxuyS52Pp/aLzdMoftqVUQF9mS2XqDyc7QMDi+EJ+QIrddfXDi/XqTOYVKHU4UmNq4tsvrnwQ3cPicIjquFGJ+sVgYgorRWWE0gEh8SwejxxjldfenqIasPMETkdAXK07hOl04GkWxh3sdWuNx0Krxd5tfkd5SFf/X7nZE7Z+FNFeLS9n1kOXnwrETtKFQ3VBJZY35yNIc+0QI4RxaGHEXl9tkFymCC68EUmnNruyfvo4NYsjkbgru6twXybSIx2jEMsfKSVldRwc2PtiqUcp+8KfyU0l7bE5TGSy+vTKUyfirhRaKAdlpkn2xoAjRA17LRls0nOCq6HRJDFSXYgQ6L6ogRc/fLj2O8uHhQhB33+RlBu7bykCQJO1rbOSEA137REykMCpqW+0KioasE92SJxjXTEfGj+jUImuKE4FHCDgUV65kqKzu07JzWV+4OWwKySWqxkk55p7+3aO/OroiZw91GAWX+cytN/7+8cB2mljFgTMH/PEQlhA== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: d3d8ccde-90f7-4942-9201-08dc54d009cf X-MS-Exchange-CrossTenant-AuthSource: GV1P250MB0737.EURP250.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Apr 2024 17:52:47.6528 (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: DU2P250MB0077 Subject: [FFmpeg-devel] [PATCH 7/7] avcodec/huffyuvenc: Deduplicate options 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: jByDpovN+CMf Signed-off-by: Andreas Rheinhardt --- libavcodec/huffyuvenc.c | 42 ++++++++++++++++++----------------------- 1 file changed, 18 insertions(+), 24 deletions(-) diff --git a/libavcodec/huffyuvenc.c b/libavcodec/huffyuvenc.c index d822793406..294d6ad41c 100644 --- a/libavcodec/huffyuvenc.c +++ b/libavcodec/huffyuvenc.c @@ -989,37 +989,24 @@ static av_cold int encode_end(AVCodecContext *avctx) #define OFFSET(x) offsetof(HYuvEncContext, x) #define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM -#define COMMON_OPTIONS \ - { "non_deterministic", "Allow multithreading for e.g. context=1 at the expense of determinism", \ - OFFSET(non_determ), AV_OPT_TYPE_BOOL, { .i64 = 0 }, \ - 0, 1, VE }, \ - { "pred", "Prediction method", OFFSET(predictor), AV_OPT_TYPE_INT, { .i64 = LEFT }, LEFT, MEDIAN, VE, .unit = "pred" }, \ - { "left", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = LEFT }, INT_MIN, INT_MAX, VE, .unit = "pred" }, \ - { "plane", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = PLANE }, INT_MIN, INT_MAX, VE, .unit = "pred" }, \ - { "median", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = MEDIAN }, INT_MIN, INT_MAX, VE, .unit = "pred" }, \ - -static const AVOption normal_options[] = { - COMMON_OPTIONS - { NULL }, -}; - -static const AVOption ff_options[] = { - COMMON_OPTIONS +static const AVOption options[] = { + /* ffvhuff-only options */ { "context", "Set per-frame huffman tables", OFFSET(context), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, VE }, + /* Common options */ + { "non_deterministic", "Allow multithreading for e.g. context=1 at the expense of determinism", + OFFSET(non_determ), AV_OPT_TYPE_BOOL, { .i64 = 0 }, + 0, 1, VE }, + { "pred", "Prediction method", OFFSET(predictor), AV_OPT_TYPE_INT, { .i64 = LEFT }, LEFT, MEDIAN, VE, .unit = "pred" }, + { "left", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = LEFT }, INT_MIN, INT_MAX, VE, .unit = "pred" }, + { "plane", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = PLANE }, INT_MIN, INT_MAX, VE, .unit = "pred" }, + { "median", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = MEDIAN }, INT_MIN, INT_MAX, VE, .unit = "pred" }, { NULL }, }; static const AVClass normal_class = { .class_name = "huffyuv", .item_name = av_default_item_name, - .option = normal_options, - .version = LIBAVUTIL_VERSION_INT, -}; - -static const AVClass ff_class = { - .class_name = "ffvhuff", - .item_name = av_default_item_name, - .option = ff_options, + .option = options + 1, .version = LIBAVUTIL_VERSION_INT, }; @@ -1043,6 +1030,13 @@ const FFCodec ff_huffyuv_encoder = { }; #if CONFIG_FFVHUFF_ENCODER +static const AVClass ff_class = { + .class_name = "ffvhuff", + .item_name = av_default_item_name, + .option = options, + .version = LIBAVUTIL_VERSION_INT, +}; + const FFCodec ff_ffvhuff_encoder = { .p.name = "ffvhuff", CODEC_LONG_NAME("Huffyuv FFmpeg variant"), From patchwork Thu Apr 4 19:33:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 47804 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:24a8:b0:1a3:b6bb:3029 with SMTP id m40csp541163pzd; Thu, 4 Apr 2024 12:33:28 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUSqXK/ku4A5OxnqQfmpuN2+gehRrErwPiXP708ROcxspDEb7R8r9b26DHjtZScoiAJXw2LP8GMIGzQ6wDNBzMOvizuzjKQZorLxA== X-Google-Smtp-Source: AGHT+IF8ZVIy7kyLpXF38QNFOZwZq8ZJsqnRcCfqbqZkUEGR0u0Vli661hAJ08RlNBXf22Zi1noJ X-Received: by 2002:a17:906:3bd8:b0:a4a:850f:28fd with SMTP id v24-20020a1709063bd800b00a4a850f28fdmr500639ejf.29.1712259208496; Thu, 04 Apr 2024 12:33:28 -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 kh6-20020a170906f80600b00a4e90f52da9si2825530ejb.598.2024.04.04.12.33.28; Thu, 04 Apr 2024 12:33:28 -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=X2jmKtNv; 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 579C068D146; Thu, 4 Apr 2024 22:33:25 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-he1eur04olkn2059.outbound.protection.outlook.com [40.92.73.59]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id D3F9468CF79 for ; Thu, 4 Apr 2024 22:33:18 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KH9uxmY+fVPigF5gz51eg4Qj7Ko7Yf5Sv0AzchGxfAHRuSsiRrakXDMX87O0lejL0kP2PBKwP3vbZZyc2IkHS6ctyuQONbnyc0Sp1AqIjaeEmHoD8tq66gyP8ZYJeRw7XTizdVHReiD6ctMPHpAVNZoi+Jv5cJqgeYTLLbsw8xZzFhG5w+4TJAApWDVlb59GA7YO8dZRg+byv80QN97NbLxN1eZgDxveYT4xYd9/xHh6DfB4srFQWwnALQC+x/q7UqKGTN24HwLGwZTqG1JTf3w8BdlsWz1SjhBjIrtee/OW+5pToS6tdSMOa0LeKHJ9BDK356zPANf/jaDBS4xAqg== 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=Xl6BgfWwDpwbasSYVGbSP/sSQ0wayN1IG9w+H1YiWyY=; b=XOighCNrtDwhm6mCm6WPs2u79enVlsuxxrB1NpDtZNjXz8YFUrbU7ymzTbpjpN/4qoC9JhGWZNNcgSuu+xZX0jpWuDS12VwgE307xz9IoQzdWKr3aiECn7/lqj9orzvfkAL39znMC6xSKbCnasDHobShl4kn/JTPvOERNJ07fwhUZndXiN+3d8IQqHvQsnAadTh7zu+wPdqWO+Hqvr09xv4XE1v/5UGhXjndhW66cddoQox40erLnwZPiGyfNI/dSu6UQCvUaHMcWVZffc5/SpLkKnt2SsML+Up4QXdCEq3GwUafpPBtx7Fwczx09h+0/Kx1TkJ464iBpV2qpuCutQ== 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=Xl6BgfWwDpwbasSYVGbSP/sSQ0wayN1IG9w+H1YiWyY=; b=X2jmKtNv6aFnVgvYegDbAoyIHeVBqMnDd8HfvK8NdcYnRYUR4RslZCQmxebtVBARnDA/Chfg+0n87zQMHsQS5Xqdg+VRuOf2AlgIvithZ/pLr8gS7VHSnd7wFKML+vHzXY81OvDvnDgWgjDWcftQ3SAt9zaDh6uPWMdKdBR5KRUkg7wChlFSCF3VLVrdypZWuCstXn33qlUj/OXitTymwQ7uxbq7ewBQkixeOQ5zevh2QXPDObuRBKs4M6e85YY9BwKVKIWESAN/cL8xbxCBmLDoWQqlfeqWeM2EhXhNa9lcEms0xGT0gcsIRjJ5dywUnSEpB/YGSxaFmsXfLLsZ0w== Received: from GV1P250MB0737.EURP250.PROD.OUTLOOK.COM (2603:10a6:150:8e::17) by DU2P250MB0148.EURP250.PROD.OUTLOOK.COM (2603:10a6:10:275::15) 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 19:33:16 +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 19:33:16 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Thu, 4 Apr 2024 21:33:08 +0200 Message-ID: X-Mailer: git-send-email 2.40.1 In-Reply-To: References: X-TMN: [wjJULVmJDbP4/FydtKpn/tPSBE+vt94AvcSqQw9pLyQ=] X-ClientProxiedBy: FR0P281CA0181.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:ab::8) To GV1P250MB0737.EURP250.PROD.OUTLOOK.COM (2603:10a6:150:8e::17) X-Microsoft-Original-Message-ID: <20240404193309.3969296-1-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: GV1P250MB0737:EE_|DU2P250MB0148:EE_ X-MS-Office365-Filtering-Correlation-Id: 8e46b5fd-eddf-4e57-82f8-08dc54de136a X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: JO+af2lMIYU1WFGiTN42uSZNuEqdlrO/oK554FVQ/ZKF5AMYp/sC2F5VXrLK2OpNEI1YZBMmUjUUfDWw7WcDEBJJj0WCjdnSEw7ZcNNPIOqH+p0XeeQzgPfGSaja/fMgaBy9FQSv/6Whzf810DF01GoF+AX27d5QM7AYNsiwcTMEdKzvrfNo98O/XFc+h211mGsAMJTlVE2nLnrhNAk7TIVEA7essiBr6xHv0J2zlnO0j4csTFGXaGiJ5SrLRc/NEhxSkTgxkvPnWAW7d+Ex/+kBKuuHInsFquY7HUvDyrdCQdLs+DxtSvKJ7BL6pu1xGR0k608/b9X/SDISJDc2gaeK6JIOSmYTApdf+Z6GNTODFapTJZP8WWt94Jr9GeMU9eL5zna9lZ6hzA38yFKnEdMqFeoxzJbDEKhbT6b3zKv7mmEuTaHWlJ5/RuuhErsgf8AfUK77dbB9T+9XWnDDZ29zbPp4HBbMfZ/8uunTR8Gpc2bhxVlciNucoEL9/0QN6exj8jZtxposmjhgJg12a9XdrZJgv8x6eM9u1zaQFEOKvGCIp33goNohQTukZ4nkc++w2N/PumkNru2YdLLMxn3Jg55vZH/XM9XluSPOXTBR+QhPWJd1zKbRe8ZXaZun X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-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gXEkIqJUMx7nAFFQ8i+HDWgFrwaXIiAh8xl66Wy5qyoUxKN12MdS8mqrgn/LM0Bc+RFznDePQNlSfaSiGzBYwCPo90IaioIBtpJ/AQplU7kZ8TliNxza7hpf23ApUTvvuzZ4tKmXvUgjmQ2aMYOPC83+eRJqaMJIsVLbn8hC4Oqgyh8/1LalNr0RyW1zUrrLrcbI6yhjCwt9uFPkcAREVPjV83l8lr7LTo+wEDXTHoCyBL8vZqCX6GJgy8/2Te99m+dqg== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8e46b5fd-eddf-4e57-82f8-08dc54de136a X-MS-Exchange-CrossTenant-AuthSource: GV1P250MB0737.EURP250.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Apr 2024 19:33:16.6787 (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: DU2P250MB0148 Subject: [FFmpeg-devel] [PATCH v2 8/9] avcodec/huffyuvdec: Use bytestream API for byte-aligned reads 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: Pqlfj5umrRSO This also allows to remove the padding from these buffers. Signed-off-by: Andreas Rheinhardt --- libavcodec/huffyuvdec.c | 53 ++++++++++++++++++++++------------------- 1 file changed, 28 insertions(+), 25 deletions(-) diff --git a/libavcodec/huffyuvdec.c b/libavcodec/huffyuvdec.c index 12ecfcb933..e35d55c8ad 100644 --- a/libavcodec/huffyuvdec.c +++ b/libavcodec/huffyuvdec.c @@ -36,6 +36,7 @@ #include "avcodec.h" #include "bswapdsp.h" +#include "bytestream.h" #include "codec_internal.h" #include "get_bits.h" #include "huffyuv.h" @@ -86,21 +87,17 @@ typedef struct HYuvDecContext { } HYuvDecContext; -#define classic_shift_luma_table_size 42 -static const unsigned char classic_shift_luma[classic_shift_luma_table_size + AV_INPUT_BUFFER_PADDING_SIZE] = { +static const uint8_t classic_shift_luma[] = { 34, 36, 35, 69, 135, 232, 9, 16, 10, 24, 11, 23, 12, 16, 13, 10, 14, 8, 15, 8, 16, 8, 17, 20, 16, 10, 207, 206, 205, 236, 11, 8, - 10, 21, 9, 23, 8, 8, 199, 70, 69, 68, 0, - 0,0,0,0,0,0,0,0, + 10, 21, 9, 23, 8, 8, 199, 70, 69, 68, }; -#define classic_shift_chroma_table_size 59 -static const unsigned char classic_shift_chroma[classic_shift_chroma_table_size + AV_INPUT_BUFFER_PADDING_SIZE] = { +static const uint8_t classic_shift_chroma[] = { 66, 36, 37, 38, 39, 40, 41, 75, 76, 77, 110, 239, 144, 81, 82, 83, 84, 85, 118, 183, 56, 57, 88, 89, 56, 89, 154, 57, 58, 57, 26, 141, 57, 56, 58, 57, 58, 57, 184, 119, 214, 245, 116, 83, 82, 49, 80, 79, - 78, 77, 44, 75, 41, 40, 39, 38, 37, 36, 34, 0, - 0,0,0,0,0,0,0,0, + 78, 77, 44, 75, 41, 40, 39, 38, 37, 36, 34, }; static const unsigned char classic_add_luma[256] = { @@ -141,23 +138,30 @@ static const unsigned char classic_add_chroma[256] = { 6, 12, 8, 10, 7, 9, 6, 4, 6, 2, 2, 3, 3, 3, 3, 2, }; -static int read_len_table(uint8_t *dst, GetBitContext *gb, int n) +static int read_len_table(uint8_t *dst, GetByteContext *gb, int n) { int i, val, repeat; for (i = 0; i < n;) { - repeat = get_bits(gb, 3); - val = get_bits(gb, 5); - if (repeat == 0) - repeat = get_bits(gb, 8); - if (i + repeat > n || get_bits_left(gb) < 0) { - av_log(NULL, AV_LOG_ERROR, "Error reading huffman table\n"); - return AVERROR_INVALIDDATA; + if (bytestream2_get_bytes_left(gb) <= 0) + goto error; + repeat = bytestream2_peek_byteu(gb) >> 5; + val = bytestream2_get_byteu(gb) & 0x1F; + if (repeat == 0) { + if (bytestream2_get_bytes_left(gb) <= 0) + goto error; + repeat = bytestream2_get_byteu(gb); } + if (i + repeat > n) + goto error; while (repeat--) dst[i++] = val; } return 0; + +error: + av_log(NULL, AV_LOG_ERROR, "Error reading huffman table\n"); + return AVERROR_INVALIDDATA; } static int generate_joint_tables(HYuvDecContext *s) @@ -253,12 +257,11 @@ out: static int read_huffman_tables(HYuvDecContext *s, const uint8_t *src, int length) { - GetBitContext gb; + GetByteContext gb; int i, ret; int count = 3; - if ((ret = init_get_bits(&gb, src, length * 8)) < 0) - return ret; + bytestream2_init(&gb, src, length); if (s->version > 2) count = 1 + s->alpha + 2*s->chroma; @@ -277,21 +280,21 @@ static int read_huffman_tables(HYuvDecContext *s, const uint8_t *src, int length if ((ret = generate_joint_tables(s)) < 0) return ret; - return (get_bits_count(&gb) + 7) / 8; + return bytestream2_tell(&gb); } static int read_old_huffman_tables(HYuvDecContext *s) { - GetBitContext gb; + GetByteContext gb; int i, ret; - init_get_bits(&gb, classic_shift_luma, - classic_shift_luma_table_size * 8); + bytestream2_init(&gb, classic_shift_luma, + sizeof(classic_shift_luma)); if ((ret = read_len_table(s->len[0], &gb, 256)) < 0) return ret; - init_get_bits(&gb, classic_shift_chroma, - classic_shift_chroma_table_size * 8); + bytestream2_init(&gb, classic_shift_chroma, + sizeof(classic_shift_chroma)); if ((ret = read_len_table(s->len[1], &gb, 256)) < 0) return ret; From patchwork Thu Apr 4 19:33:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 47805 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:24a8:b0:1a3:b6bb:3029 with SMTP id m40csp541245pzd; Thu, 4 Apr 2024 12:33:36 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCW3tsbiU0UhBOrbJGnyNZLkvVUZk301i6lQC9fLLfR3+U4aGJbVh6Ce9dapsy/LtdzQCtd1vsdsjyIxIJCYDZaJt3hYqo9DGuAJtQ== X-Google-Smtp-Source: AGHT+IEpU5NEMbs1URWOVivzcOKQ4eFLb7OgvxGNjQIikQv6oc0PAnaoVeM+nBV+kGctf0TMwaVt X-Received: by 2002:a05:6402:786:b0:56c:5a49:731 with SMTP id d6-20020a056402078600b0056c5a490731mr2474550edy.1.1712259216315; Thu, 04 Apr 2024 12:33:36 -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 u18-20020a50c052000000b0056df3f73ae5si2683898edd.580.2024.04.04.12.33.35; Thu, 04 Apr 2024 12:33:36 -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=TMY3w98R; 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 8172268D14C; Thu, 4 Apr 2024 22:33:30 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-he1eur04olkn2059.outbound.protection.outlook.com [40.92.73.59]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 0EFA168D159 for ; Thu, 4 Apr 2024 22:33:24 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bc5IRinF+AMA7ODs4CygGBTAwM2k6hYiSdhAYLlIE7zmIosC5XOiyhQpFMhDDWJZnn0kCJzcc1G3ngNWSn9sFx9w1X2WwbQoc2zLBKuC3Pytp092x4q1e9dskfCDziMFOyMZKOVb6P3ES1GH3HcatfGLC0x0wQL8v6Ly9y2jsZnzRO3zUBOoPSQZYbm5nFxTYnoa4YJwI7Q0RHIAYmfDEn/syLRHkq+8tgRDcG3GXHtNO4C+qms0FtZq8IG00MLCAmeDaB4MeXYg9krOqhHyaNcmL9gBWaE6KJBzkGV1gLQ0b6o5ShLfYJBxO371oocY/JZBSnj5tzbZGpsewNzRhw== 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=gbuZthbQRWUE66CdAQQ8PbfyKhYaXQ3anVb4qt35cJ8=; b=ZU026Gl1SfKyapsHlZ/0w4T82ECaFaDwxgItiiqc3oZq90/DtCPyqtOZsOuqvcBKic4MCIs0Jv0s9XoPMz1rH7CuI4fxCkYI1/3ThS9knOO4IhUqKCBQB1JE6Vx2ec+jslIeSOPq6HIbHF4qCYMefYlClfk3/vS8F9vWVrN1Y1q+RuntTDEyYriVhR/Om5aAG7dJRKe5SDNdL7xIHlzzJYyJLMqzAHyy7j30pPSgBdNVoAZKffkWUOfEN5ZETxU5X6j4tSJJ+RnLoTULkvcPp02fFFPzGivwbTz0KvYoEvRCCAAvIV55AaqKgJQg2Y8Xmuiy0/VS2vLrjasONYnkvg== 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=gbuZthbQRWUE66CdAQQ8PbfyKhYaXQ3anVb4qt35cJ8=; b=TMY3w98Rd+t5JAjbSQ7rqErplIjAN0aOBTzWSPi7w3w0WKYgKpqmhN7zsOY5mgGJzMmIpsTKQmF8xTMhZZqTfZ9vDlkIa5ZxwDmcEzFDTH9g5DCEF3QhBShVupmEqzfO5Oz//N8ngmQAonAgSbTsW2QhE0RG7rjg5TAKllP8xEHVeuzkZJ6OECs/Arl0zqAEOEbz8F4bunt4c4CcQQmauMUZbK3B9sQ72acbF19i8zBOXK/n554kVllRieofMRCAIH7O0OFUe+yL9wPBJ5tPWopi2P6zXHLvlE7r7VFWttfeqrWBPGq4IbZSI5VjSq1IncC6we8/oc2Xow9I9xhiBA== Received: from GV1P250MB0737.EURP250.PROD.OUTLOOK.COM (2603:10a6:150:8e::17) by DU2P250MB0148.EURP250.PROD.OUTLOOK.COM (2603:10a6:10:275::15) 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 19:33:17 +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 19:33:17 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Thu, 4 Apr 2024 21:33:09 +0200 Message-ID: X-Mailer: git-send-email 2.40.1 In-Reply-To: References: X-TMN: [XliQaOpNGMITuZwYQR2kEUNUEvohExlzzwjUcqVQfUc=] X-ClientProxiedBy: FR0P281CA0181.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:ab::8) To GV1P250MB0737.EURP250.PROD.OUTLOOK.COM (2603:10a6:150:8e::17) X-Microsoft-Original-Message-ID: <20240404193309.3969296-2-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: GV1P250MB0737:EE_|DU2P250MB0148:EE_ X-MS-Office365-Filtering-Correlation-Id: 012f5176-1622-4de9-f13f-08dc54de140d X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: RdXB8pu7GCcxwA5ygUMGz4CyfnOMRER+t4xqEKGLSoQaYsR8bSJY9R7/zTJKYRhd+UhM/bmbt8E1ku0O+gZtUxh7p8UOg5uEuh0QXwt4KhGmkWEpsIv4jlwVkYQyo52FrLkdy5fpX7vhRM/pStMUZmoc4R2mMsMqkg/06R7SfpDwYfyZAY8lvtI80RDyfXbAqHXEPWIKsIisGqgaPyWUhVDftXYItW1F0sFURvBCCa/EwoK1bVCcwMdnxD0ZTRAZKMY5dubnd7TFcuJNCEurgwgh2d0pP6/kz79Wb2oz0tH8zdS4cIww/Z+CDwq0a17nNaJxlN2ro26BkgjV7hjz6FjsIgMm4st35r/64zkhLjGc8jdEyaRmWE1fMETA1BYNQnd7egV+yTV1y+iD5ZaoWRtY8NgCYPpfjKrhgbUxqkvQXZwxIv9b2Bixv9HyLTM4FTTkK9bWTxrX3VUjx2sDxcriF8cG6dlkZ3vZ+sGNkmLEs7pFHEYPMXc16S8XgtcGiw1ve5DvV3DTnrodCYy5Vh9a/eM1dJxlSxeZ5E+S601M/bc8Wc3OQdzyzvDAxBjcpzRE0Orlergg6pxxm3G6TVkZeMXDi1zhVJHwJ4QzCSRMlYvsnx6g/hYOJzC1Q87m X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: FaMZDomS+t7opS4bZTQAFbasZzQ/cqvlP9B5zlNSgGh+oUmkUCbfHJ43EYvaZfudx+7E7TxA/t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Z+IHV1Es//LVOCMGPltQ6DhHn6ggCET6IUx7rCEsqQfznjxnMeD6DeW0ss2ZM8woiOxOJce1Ig2QzU8JwbcVUQsF5fw6PiiU+DIpP2QWN2fPgCPEVSgWKvSaENRhsjJ0Jne/c+ErU6wQzzTHwIJgMxSBNT9Rg== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 012f5176-1622-4de9-f13f-08dc54de140d X-MS-Exchange-CrossTenant-AuthSource: GV1P250MB0737.EURP250.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Apr 2024 19:33:17.8364 (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: DU2P250MB0148 Subject: [FFmpeg-devel] [PATCH v2 9/9] avcodec/huffyuvdec: Use assert to check for things that can't fail 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: AFV5Bnf7CRJJ Signed-off-by: Andreas Rheinhardt --- libavcodec/huffyuvdec.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libavcodec/huffyuvdec.c b/libavcodec/huffyuvdec.c index e35d55c8ad..a8ccb724f5 100644 --- a/libavcodec/huffyuvdec.c +++ b/libavcodec/huffyuvdec.c @@ -290,13 +290,13 @@ static int read_old_huffman_tables(HYuvDecContext *s) bytestream2_init(&gb, classic_shift_luma, sizeof(classic_shift_luma)); - if ((ret = read_len_table(s->len[0], &gb, 256)) < 0) - return ret; + ret = read_len_table(s->len[0], &gb, 256); + av_assert1(ret >= 0); bytestream2_init(&gb, classic_shift_chroma, sizeof(classic_shift_chroma)); - if ((ret = read_len_table(s->len[1], &gb, 256)) < 0) - return ret; + ret = read_len_table(s->len[1], &gb, 256); + av_assert1(ret >= 0); for (i = 0; i < 256; i++) s->bits[0][i] = classic_add_luma[i];