From patchwork Tue Apr 12 19:25:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 35293 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:671c:b0:7c:62c8:b2d1 with SMTP id q28csp1750537pzh; Tue, 12 Apr 2022 12:25:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx48YsykCGakUyx8FDvolhhdqvuMop0bsRvI7SpOD7+I0zTbrsAM3B9N6YftvIauFihhf3o X-Received: by 2002:a17:906:c092:b0:6cd:f3a1:a11e with SMTP id f18-20020a170906c09200b006cdf3a1a11emr35170547ejz.185.1649791539704; Tue, 12 Apr 2022 12:25:39 -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 d18-20020a170906305200b006e8782b11a5si7306414ejd.418.2022.04.12.12.25.38; Tue, 12 Apr 2022 12:25:39 -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=QHZk5QdQ; 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 1AA7868B3C4; Tue, 12 Apr 2022 22:25:37 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR03-AM5-obe.outbound.protection.outlook.com (mail-oln040092070030.outbound.protection.outlook.com [40.92.70.30]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 98B6568B39E for ; Tue, 12 Apr 2022 22:25:30 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=S76lf2rXknQGDP18BJ8rg1znGc6vGe5x4dgQeMh+mTJyZ5pUr8QzkbWRxqPTeb0+jmcbLyqvmriRV/Ql1J4vU3fQZPZDR8JtYhDjcWNH4btCvHIjx3V8dadbwqOO2F2r+szGEPmKwKNXP1dakdnGOZUglZbJX8Wo80o1xQZpeVqiS/2KvHdceZPjoqdUAlkDP8Gt5mhOcotAfv2B6ChwB9RbQsz1P9nwmC2aRJHGgpR8HJmMmGZ19TbWe8yVClqDFkQ7j0Nm50Tma/S6u0elo0aaujjNptIB1v1qA3TEaJ9JEF+LTJuOIp5RvunFExUTTj7HQmFK5KmIhxt9aTr0kA== 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=Uj2XqZ/VHXsK1qQK6pRIhNQ8IXIJLQC8Uawzh8d7UtM=; b=Z/xMHNtne+TqDgvNyO2RpTSnC9j7QJRVoDFCHenHM82/BrvzUN/xVlAQWidFakfFgsoMojIgdpsmYCe/VInh8njhi78Fk6p/sNaKFNG+xxDCiwkMbPXAJTvGI6XJ6Ng8nkWPCT62YQzzwhY81YhGyPcJ7Myo6uxPiNIfaaow10MNk9CX5QRSIeFgjcbmwtA0QU1NjOpFnBZCKAPHYE/UdSpJd0r4nzz0qpFXB7N93nv3GgVIX9ml76HhjNqds6R5t0sx/wNWQN+PXwzU6SDRy4XHS3D+Ko89VQM+9a+RpyYfA5pBCd97rOAyVDUl/D1WQ0wLJ5w6Ked2fjK3JoGNcA== 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=Uj2XqZ/VHXsK1qQK6pRIhNQ8IXIJLQC8Uawzh8d7UtM=; b=QHZk5QdQ/UvWd4bSP1cvIPI1E2LekNtZglI6sZw2ogid9GgtNl9jz2niixtqxWQLzQfWJe5oBG4sl2vtwGOb6IyfOhPiXp5RJ/HJQojvOc3GkjEqU5ZzH1GuMETMPHKz0SASNcpfRqUbyU6DQNlKrLeR5jJhQ6WNt+ZY/K6zMxG8ZuAnMpwt4t8tpehfUZjiz2ouKMPJgCCmMhufCAk4pgzdWabpbcJ6esjmHkHlub7Rxx0f1PPeByqjbFS7qSxHYZiOag2U14CUxRPV90/lZ2QAo4JPT1HhfcVO39AoVCIbL9AC5ttQ5B2dAQFqlTbuw2Nqv0ACHihXRfd+MpBDcw== Received: from AS8PR01MB7944.eurprd01.prod.exchangelabs.com (2603:10a6:20b:373::5) by DB6PR0101MB2230.eurprd01.prod.exchangelabs.com (2603:10a6:4:44::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5144.30; Tue, 12 Apr 2022 19:25:29 +0000 Received: from AS8PR01MB7944.eurprd01.prod.exchangelabs.com ([fe80::fcc3:1285:374c:9b2]) by AS8PR01MB7944.eurprd01.prod.exchangelabs.com ([fe80::fcc3:1285:374c:9b2%5]) with mapi id 15.20.5164.020; Tue, 12 Apr 2022 19:25:29 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Tue, 12 Apr 2022 21:25:18 +0200 Message-ID: X-Mailer: git-send-email 2.32.0 In-Reply-To: References: X-TMN: [Dbvjr8F7R323+eSFXTywgL8On9BnTtL8] X-ClientProxiedBy: ZR0P278CA0174.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:45::20) To AS8PR01MB7944.eurprd01.prod.exchangelabs.com (2603:10a6:20b:373::5) X-Microsoft-Original-Message-ID: <20220412192521.750751-1-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 897cd5d9-9218-4d84-6e84-08da1cba342a X-MS-Exchange-SLBlob-MailProps: S/btQ8cKWiTONvFbsB6nRbYK9Q9ndC83oBeJ4vrzQ+jvw2PlXBIAzzZw1Ifl8llSz8Bci56u9hlmgXnPA5k5tlee+ORl3LcmDAUu+VufMCRACxoju2TPCVIF4QFLLncEvrEg+V269Mr5XCiZUeSAH0mGULPMDfwWFAlbbb5NM0EzDYvlpCpUkjfxjfNHuNEC8kUMKgmdIqnIij4enAlOuVW1xFrfUtdEQD5NvMwifJce4rFooYT8m7NR5BFdzaCEwbtX6ylxDu9GPGoVAg/A4Iyn61ArClEQaOLQ2su2j5ObD0wxSt774E/fA69zeR/AQCc0t182k+qPthN2Pt55yQmUSlDs6zAO1081O1EO3aZt3BQuzgwZa9wVPMZRmMZkCWrgWX7vp7wiKAoJ8SwbFCd8loBxmjqa2HP4nIpbeNdnaSvk/kRv90T7VI0FTY14Rp2AShBzmODFwwGR/6rn9jxJkWPvLJWJTvYYPoUf+LuO8FEgoWeAVLoHSz+P0txMKhN01YQItos41fbkiwZ0RnxLVBqFEd/OzqSHw+WAm8PXc4+Ikn4KTqUBLoPouDn+9sbz4q/BCdn4F5zY2sg7+dYZQ6dKFA4/V6NXHyRAPnqw6LzL1p3d9SIsrF1Mq079MQVc9F3ygAdMRG5wWrWiRBoKKbgoPFiPuTZe2i3VWc7BNTioydiMewYLhIV1C8arqatdJJ4Q40d01RxShYuuRdqfIFuqgpWsWDjxonvvNUteaxg0eVyZHP5Mbawz2kUmUzIK294nvDo= X-MS-TrafficTypeDiagnostic: DB6PR0101MB2230:EE_ X-Microsoft-Antispam: BCL:0; X-Microsoft-Antisp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ook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 897cd5d9-9218-4d84-6e84-08da1cba342a X-MS-Exchange-CrossTenant-AuthSource: AS8PR01MB7944.eurprd01.prod.exchangelabs.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Apr 2022 19:25:29.3068 (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: DB6PR0101MB2230 Subject: [FFmpeg-devel] [PATCH 2/5] avcodec/vbn(dec|enc): Avoid leaving stale pointers in context 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: mvMuHETLT3m6 Therefore move the (Get|Put)ByteContext from the context to the stack. It is transient anyway. Signed-off-by: Andreas Rheinhardt --- libavcodec/vbndec.c | 11 ++++------- libavcodec/vbnenc.c | 3 +-- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/libavcodec/vbndec.c b/libavcodec/vbndec.c index 916421925d..56bfb1d544 100644 --- a/libavcodec/vbndec.c +++ b/libavcodec/vbndec.c @@ -34,7 +34,6 @@ typedef struct VBNContext { TextureDSPContext texdsp; TextureDSPThreadContext dec; - GetByteContext gb; } VBNContext; static av_cold int vbn_init(AVCodecContext *avctx) @@ -44,11 +43,9 @@ static av_cold int vbn_init(AVCodecContext *avctx) return 0; } -static int decompress(AVCodecContext *avctx, int compression, uint8_t **outbuf) +static int decompress(AVCodecContext *avctx, GetByteContext *gb, + int compression, uint8_t **outbuf) { - VBNContext *ctx = avctx->priv_data; - GetByteContext *gb = &ctx->gb; - if (compression == VBN_COMPRESSION_NONE) // outbuf is left NULL because gb->buf can be used directly return bytestream2_get_bytes_left(gb); @@ -61,7 +58,7 @@ static int vbn_decode_frame(AVCodecContext *avctx, AVPacket *avpkt) { VBNContext *ctx = avctx->priv_data; - GetByteContext *gb = &ctx->gb; + GetByteContext gb0, *const gb = &gb0; uint8_t *image_buf = NULL; int image_len; int width, height, components, format, compression, pix_fmt, linesize, data_size; @@ -139,7 +136,7 @@ static int vbn_decode_frame(AVCodecContext *avctx, return AVERROR_PATCHWELCOME; } - image_len = decompress(avctx, compression, &image_buf); + image_len = decompress(avctx, gb, compression, &image_buf); if (image_len < 0) return image_len; diff --git a/libavcodec/vbnenc.c b/libavcodec/vbnenc.c index 0b2c4dced2..03d36ccc86 100644 --- a/libavcodec/vbnenc.c +++ b/libavcodec/vbnenc.c @@ -37,7 +37,6 @@ typedef struct VBNContext { AVClass *class; TextureDSPContext dxtc; - PutByteContext pb; int format; TextureDSPThreadContext enc; } VBNContext; @@ -46,7 +45,7 @@ static int vbn_encode(AVCodecContext *avctx, AVPacket *pkt, const AVFrame *frame, int *got_packet) { VBNContext *ctx = avctx->priv_data; - PutByteContext *pb = &ctx->pb; + PutByteContext pb0, *const pb = &pb0; int ret; ptrdiff_t linesize; int64_t pkt_size;