From patchwork Fri Mar 11 15:44:23 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 34703 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6838:3486:0:0:0:0 with SMTP id ek6csp1806887nkb; Fri, 11 Mar 2022 07:44:45 -0800 (PST) X-Google-Smtp-Source: ABdhPJxoF2dQWeVH3odMstAxBlP4J26f0TFHuS9Lz2untUcojKxgfTj9VC7UZbCp8zH0yfz66HfB X-Received: by 2002:a17:907:168f:b0:6da:b548:4f9f with SMTP id hc15-20020a170907168f00b006dab5484f9fmr8876437ejc.666.1647013485217; Fri, 11 Mar 2022 07:44:45 -0800 (PST) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id j7-20020a05640211c700b00416799b824dsi6600633edw.183.2022.03.11.07.44.44; Fri, 11 Mar 2022 07:44:45 -0800 (PST) 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=ryDP1txH; 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 B87A668B0E7; Fri, 11 Mar 2022 17:44:40 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR02-HE1-obe.outbound.protection.outlook.com (mail-oln040092068108.outbound.protection.outlook.com [40.92.68.108]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 0214C68A8BE for ; Fri, 11 Mar 2022 17:44:33 +0200 (EET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BIs+3/KVXvTgqzGQbvg7TGuWypcbZ4d8pd0aiaUsnzViEanjAUVs91DuNsVCZYLlU1sQHPqX+d/PuXKUgtICtbapenQLLLxnxIC+XhFrFURN4RN7Mdg/UMZAZA2ciTRdHxW5+2U4HWkNssEVdHfSVZ5u5lnF7OAYkyXmp3MwaF7HZGyNjk4kzEP5Mg9d3UkP53qLCXoWWN5Uvjp7WvdWBeYFlqWYcZ/pYzoKJNt+GooYcnOvzkdlc83wxD25nklVLg4KppuyKhQloWRZyKEKFpFrU41YHLiQ0i/xmDLxAlUsPmmHEujhMwM07dKFdtank9QC65ETBm075JpilfUjTg== 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=9Tt5sM9tPGX5fr5otbiwydnvfbiYhwz34j+elmlF51s=; b=K5VyoIIz6kswhh43OnqeKHUKm+x1PXlHrcCaZdJGPCRMSrx9LWftoeFf+qPsy/Rtq16gGNxM2iN11ukM9L2cEm/PuCztWDomIvr8ln0dfDozk1/txGP0eznyu3eQMSNsIvpRrkaLSqgWqLahFkFrCdcB8LbJ8qCRdIW+jkVRfZx7zhhnkDnHVzMQZKtQogLR/CFY4JJ9Anqf7C+IoPkkkZnaDdo1cw7vqMeTTNpqSMARw5knJJmAzsjq/4p0kX5aiYN5+LYWX1AGqnNSttgxnh3rQ28HXw8dEy+LAHAlIN8Pg12xlja0VgycKXoMRm+PsAWiNVVpzQwk0SELIq+yog== 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=9Tt5sM9tPGX5fr5otbiwydnvfbiYhwz34j+elmlF51s=; b=ryDP1txHefVo8oVVkDpu0X1MeG+nLnnbUn5WCmXkWEK6mezLcDtfwpyn6GAcP8A+6LlZ40klQ3075dKFHvTh+TEdgvoUI6wK8mpFYN23gyNGXBVYX/KOFYfVeieSR88I7oqUZQE06bYPEmVFlpytKUjwp22z5FNNU8hCxynAwk3Q6o0ABZR1YaolsNORnIMANRZPToQDNXfoEaZ+uNsI+oFQM0/jTwQw4hUrU4fSVx23igeeRN9y/4kViiafdhpXrtdOcQcXGgvAo0nAcyzcX9YfDdIB0SrNiKU9wo++5OCLkgNq3aC5zBOFHRH9+7EnPygfWSOEm4zlGsoTPwfi2A== Received: from AM7PR03MB6660.eurprd03.prod.outlook.com (2603:10a6:20b:1c1::22) by DB6PR0302MB2614.eurprd03.prod.outlook.com (2603:10a6:4:ab::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5061.22; Fri, 11 Mar 2022 15:44:32 +0000 Received: from AM7PR03MB6660.eurprd03.prod.outlook.com ([fe80::bc6c:af66:7adb:7a3d]) by AM7PR03MB6660.eurprd03.prod.outlook.com ([fe80::bc6c:af66:7adb:7a3d%7]) with mapi id 15.20.5061.022; Fri, 11 Mar 2022 15:44:32 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Fri, 11 Mar 2022 16:44:23 +0100 Message-ID: X-Mailer: git-send-email 2.32.0 X-TMN: [odMzls2Q6qdJ2eYtxp/wzL8M2OMEXFpC] X-ClientProxiedBy: AS8P250CA0009.EURP250.PROD.OUTLOOK.COM (2603:10a6:20b:330::14) To AM7PR03MB6660.eurprd03.prod.outlook.com (2603:10a6:20b:1c1::22) X-Microsoft-Original-Message-ID: <20220311154424.220157-1-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 87a6bba8-74a8-4065-96a8-08da037608df X-MS-Exchange-SLBlob-MailProps: gjx25WM8ZNW55cP4YTouUlFWMuNNcdTJvmxZEzf0IhPEv/+22v1IB9MuBiDGLtdLRoGdT2ooCwPECtcSCOYRRGR8W/ziUbahzSr7byaxrU638onkxru0qg9kJxyIuI11ad7jEEHOPkET/9Bo3AYawKmWDSahmoDhhLL4fsoU+e+ddiO0NoGSR+NYerYFfREksXmn4VOowB4AXrqnyENfD2MB68nPOrgLgRqONxi9kQAPStk8H3vg4TcfrpALodmb7dHf5rnBG43wyU/5tbgF6SZb+9Q6+MnYq+Bi7YTa607bBZAxXd5TwKywG8dIXx94BNuhnXHrIsiH6+OUFagpYBx0XJYSY4eUyPLxV6S0O/oDwUGYo/wFLoV0dtmlbQwu9zS3CAQeoWbm8yFRTO1xWLOq+FC6v06sML9+Ts6rdU7Hte2bc29sPThUzza6qahWbhCQMAEBWTOecqn2zZelklCORCR/wIljRIRKyjCK5XqOJP/5Rhe/V+Wf+nN7Yu126hhd24hkjZ8hK3byKcy4tWhAgJ7TQd1+Kf8yhvOW5dE45OlOleFmW6VE0bTE1PzODC7mNDxIBJ3/vqHKo0H7q6T2UmOheCoP/YbNdUUXmw4QTmLty31qhhGGLj6H49AhFjXEPEnF0qu4s6/50IX0teL9uLjCzhC+KPZLXOUCS4067SHjQa6iSuqVdm9GHNfBLdGM51WbSl8/PvkpHRALvXv43envtZ/Sr3UIgfYnJ1U= X-MS-TrafficTypeDiagnostic: DB6PR0302MB2614:EE_ X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: OTdSGchGA8F7CRYfgD5npd4jWsEJKjS2SG57NmVEtxdl0Cgub/c2UOHsAdeG7HtE90dvXz4jlfz4QCeWXbm8Qik/MRZAqRjhrDYMVPIQnCX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PlaVdm8R3oYN3+zXq3f2KzVGsL1QlCR22Rp1UJQ3tgGNVW2AwiedbvsrbiHRC8MHIbxterO+Jy9FY2Kc8/6LsEDq/bIsjDLJymlGGEIFJ0kyM889Ei3/iTVzzKBW4zPQr9sTBKQDg5fDwU5eZRHnN3IuWg/Et1JuoFeASxpkLZPTXF3pmI1kXfMBXC4ERuAy40RVcckYwhN46ZFjONCbgic87vZxMcox7LYdQzUedohekoi4e4yhrpiVfLGqkZqNY8u5X24HnYkJHpsXINjbiy2TSKnyLqebfAtDrtRhCWuhQAvEPC/jpFcAe4GEOfJpIwtEojPEswkgWDD0156yIf/HmVO+JFmf2ZOahVk1S3j8kuNPQhYVBJYrYqBkrOQ+JMdeBtEBqAAZurmvhx/qMRlIXFjFgHmnTFZMzuJGPWy+yP3NvfhSoBbaGuTbSopbPuiOXMJYvJZGzxcLV+VdDU7F7LgR/9JRh24DLALYxhTJK5MQhFfP+jxDA3j3/tXxSNH1y9R2iOkrjHpERQFSKqIe34igfpElcrUXpACm2+Y8Y72XI0OMKd1AqIlbNsjl8XhcxVErK0cuaEC24EIhhyEqqOR038Ynr3rt08XOFKT34dbqOEGfZ3iS9p5TBk0dPMcCT+mS1j+Jldp7oXJ0L5ImvE= X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 87a6bba8-74a8-4065-96a8-08da037608df X-MS-Exchange-CrossTenant-AuthSource: AM7PR03MB6660.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Mar 2022 15:44:32.0160 (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: DB6PR0302MB2614 Subject: [FFmpeg-devel] [PATCH 1/2] avcodec/flashsv: Avoid copying packet 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: Qe3Ho8qAGL80 Signed-off-by: Andreas Rheinhardt --- libavcodec/flashsv.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/libavcodec/flashsv.c b/libavcodec/flashsv.c index 00f77f4902..5f0bc0c6df 100644 --- a/libavcodec/flashsv.c +++ b/libavcodec/flashsv.c @@ -44,7 +44,7 @@ #include "internal.h" typedef struct BlockInfo { - uint8_t *pos; + const uint8_t *pos; int size; } BlockInfo; @@ -59,7 +59,8 @@ typedef struct FlashSVContext { int ver; const uint32_t *pal; int is_keyframe; - uint8_t *keyframedata; + const uint8_t *keyframedata; + AVBufferRef *keyframedata_buf; uint8_t *keyframe; BlockInfo *blocks; uint8_t *deflate_block; @@ -138,7 +139,7 @@ static av_cold int flashsv_decode_init(AVCodecContext *avctx) return 0; } -static int flashsv2_prime(FlashSVContext *s, uint8_t *src, int size) +static int flashsv2_prime(FlashSVContext *s, const uint8_t *src, int size) { z_stream zs; int zret; // Zlib return code @@ -355,10 +356,10 @@ static int flashsv_decode_frame(AVCodecContext *avctx, void *data, /* we care for keyframes only in Screen Video v2 */ s->is_keyframe = (avpkt->flags & AV_PKT_FLAG_KEY) && (s->ver == 2); if (s->is_keyframe) { - int err; - if ((err = av_reallocp(&s->keyframedata, avpkt->size)) < 0) + int err = av_buffer_replace(&s->keyframedata_buf, avpkt->buf); + if (err < 0) return err; - memcpy(s->keyframedata, avpkt->data, avpkt->size); + s->keyframedata = avpkt->data; } if(s->ver == 2 && !s->blocks) s->blocks = av_mallocz((v_blocks + !!v_part) * (h_blocks + !!h_part) * @@ -566,7 +567,7 @@ static av_cold int flashsv2_decode_end(AVCodecContext *avctx) { FlashSVContext *s = avctx->priv_data; - av_freep(&s->keyframedata); + av_buffer_unref(&s->keyframedata_buf); av_freep(&s->blocks); av_freep(&s->keyframe); av_freep(&s->deflate_block);