From patchwork Thu Apr 29 23:25:09 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 27531 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a11:4023:0:0:0:0 with SMTP id ky35csp2058095pxb; Thu, 29 Apr 2021 17:58:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy2HIBHSmpRYuNP9LOGefAWMY+xM8JSlB+oRzggLpDhO9payVaJIG/8TPtCTB0D/unZG/6m X-Received: by 2002:a05:6402:138f:: with SMTP id b15mr2726468edv.121.1619744294042; Thu, 29 Apr 2021 17:58:14 -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 w13si162576edd.475.2021.04.29.17.58.08; Thu, 29 Apr 2021 17:58:14 -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=jJaZzR3z; 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 9482368A293; Fri, 30 Apr 2021 03:57:38 +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-oln040092070069.outbound.protection.outlook.com [40.92.70.69]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 2CA76680825 for ; Fri, 30 Apr 2021 03:57:32 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=esYY025SUVlSTBanxE5djB9pdkJKVNhYNwGtFXJdexEQsV1uNSW1pUs5D1kpT5lHIwwyOubGkBn9Rd7AJyFjjpJXH1d22H8qvcy+WeaNoWwVY6J6gVBtsaBOJGPtRLzI3jADetyETUv8bB6tewaTpfrWT0fkrv78BgxS3RfDIFlnz7ihXUCDF3XHJQFPKt38s7v5zpV1IiW6vbdWkYBpK08ODWtz6qeVbXy4qcGNd1oC6dbSCmY2l9zabz0Ha7FdOSPWBVfqgy5sebkc2LXJKH6uJ9WdY0P/zRnmw2Q2WLzuYUMVy3R2nLUfnmo1uLNuPFuMDpRgWZj8pSMKm5auFA== 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-SenderADCheck; bh=Yd7QiO1WFAiqBML464ES+rt/M/HAz8p3j2Cb79iUTV0=; b=W57vLCaEinaH/rqUQYCqetK8iy1E/3IC0f7OSyERGk+Q/BbJuNOJU8JV+kQ2xS0Gyqxn26tP5FofNp3P1OuA8QYkZjAo6jOBUImkTA/kXrfrE3EXAcXOkM/jRzdGAoKYDlL5jLNS23LqED6rymmhbMsZEZAiP+EFio0wsJX4qmfbr16ltKAz8If6VpQZQmiRVaEWUGzBRwV0pL6At5ctIJqAnBA+tyo3dhtFlJBX30Ri9+8ryzutF3JEJReTL1Zct92arZjT3bkOu5/lw6u0LQFvTOx6BvRzBUfth0Fp87Dj2pPXTbB4P1GXnWWKqa0/xnInqHnAcqxZ8Cl71EcliQ== 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=Yd7QiO1WFAiqBML464ES+rt/M/HAz8p3j2Cb79iUTV0=; b=jJaZzR3zFmuRUMuBRI7BtDdqUxsPQtkTX3RAayHNCsmB8i0N5gyPhX3vhW2PUp7fBOAsnWeoCo+O9u0Q/tR1k/1NhY9obmre4uiL3GbQtcl+6jJeO+Pz1tCItK6XEolV2koyxIw5TbJEr6iMJW4ec885CB+OUztsthJJvlCpfgKG+IWd+Fs/9ZSRDKnw2qHVpIjpx0bAaffgBIoHU1+mTyNDRrgMoFzFYDNyfMF0xo5iHr5YY+gBOa++isYvV52/qAgN88z5qWXtwhX0lveyOCxfpk4y3n786Dabxu4Ju9+F23QbUPTQ1UqeM0ON/NOMffXU3b9v3BsxN6mtI/QXBQ== Received: from VE1EUR03FT038.eop-EUR03.prod.protection.outlook.com (2a01:111:e400:7e09::46) by VE1EUR03HT042.eop-EUR03.prod.protection.outlook.com (2a01:111:e400:7e09::478) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4065.21; Thu, 29 Apr 2021 23:26:06 +0000 Received: from HE1PR0301MB2154.eurprd03.prod.outlook.com (2a01:111:e400:7e09::46) by VE1EUR03FT038.mail.protection.outlook.com (2a01:111:e400:7e09::368) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4087.27 via Frontend Transport; Thu, 29 Apr 2021 23:26:06 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:A5F6F421C65F0C85875258D6A3660A6BCAE6785846DA95868EC648DD717669B1; UpperCasedChecksum:4024678F56D5CEF2A8FA325334564D90A3701C7DE13A706034B28E4E71A1E46B; SizeAsReceived:7400; Count:46 Received: from HE1PR0301MB2154.eurprd03.prod.outlook.com ([fe80::45bb:c44f:2b75:23b7]) by HE1PR0301MB2154.eurprd03.prod.outlook.com ([fe80::45bb:c44f:2b75:23b7%5]) with mapi id 15.20.4065.027; Thu, 29 Apr 2021 23:26:06 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Fri, 30 Apr 2021 01:25:09 +0200 Message-ID: X-Mailer: git-send-email 2.27.0 X-TMN: [m56xMnDzgZfkPbN7BdqpnTTB2oymsQJp] X-ClientProxiedBy: ZR0P278CA0038.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:1d::7) To HE1PR0301MB2154.eurprd03.prod.outlook.com (2603:10a6:3:2a::22) X-Microsoft-Original-Message-ID: <20210429232554.2066739-1-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from sblaptop.fritz.box (188.193.248.86) by ZR0P278CA0038.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:1d::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4087.25 via Frontend Transport; Thu, 29 Apr 2021 23:26:05 +0000 X-MS-PublicTrafficType: Email X-IncomingHeaderCount: 46 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-Correlation-Id: 2028e26a-e6c5-4868-66f3-08d90b662927 X-MS-Exchange-SLBlob-MailProps: ISIDp/2nRg3KXokOksxCiagcE7D5FxNrj1UKnJ2l3Qsmeg8JZsgK0thCVUDTy8oLB6/1QP4NZYes9xMnzYBmHCq33f02H2AiP4H6dR1ormjpPeOwYXwqvZmEEUTmUPbHApMXJ2oILTc28GtYGDtsvlBmAEsZROmMNlVbEdu8ttIetULGBgnDLTTD0/UkDPhFzlWy/hCix5VXqkrIixBUZfeNfqEQESsS8xWoL/Y7lxSOux4rF7n8OOPw1xKa8tovVCOHH8jUFN6wPNYQSePqC0OYLgx6d+FZ/BoTQYHoBJDQCI9hT0513JvuatT6JWV4MJDZyXH3/Vwpv2clihh0IHZ1aeTGDYhSujnmLyH2Az1H7B+qIdgh9hzuFaurXuhZ67JIaYaJB5U5ul2FzDTPFHBRYY3sFao3tOI49cuOM1C1PRPH0Zc9S9rjJxYK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ZxCJeJZPDnLXvj6tubAuaEQwmRc8FcuVuecOqE+ZmA9LSK07/H5XubTXL1T+ynu0vmCW1kZvAeCB/NwCabNUR3/0TBYmnq9kD1iUpUBBHPOFSSn8+XKy+PwS2LqDPmEmw== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2028e26a-e6c5-4868-66f3-08d90b662927 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Apr 2021 23:26:06.5159 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-AuthSource: VE1EUR03FT038.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: Internet X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1EUR03HT042 Subject: [FFmpeg-devel] [PATCH 01/46] avcodec/a64multienc: Avoid intermediate buffer 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: 0xXZLHJon3BB Signed-off-by: Andreas Rheinhardt --- This patchset is the first batch of patches to implement support for user-supplied buffers in encoders; those who can't wait can already look here for the second part dealing with encoders with external libs: https://github.com/mkver/FFmpeg/commits/ff_alloc_packet2 This patchset supersedes https://ffmpeg.org/pipermail/ffmpeg-devel/2021-April/279571.html libavcodec/a64multienc.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/libavcodec/a64multienc.c b/libavcodec/a64multienc.c index 9dc859b271..1b52631193 100644 --- a/libavcodec/a64multienc.c +++ b/libavcodec/a64multienc.c @@ -50,7 +50,6 @@ typedef struct A64Context { int *mc_charmap; int *mc_best_cb; int mc_luma_vals[5]; - uint8_t *mc_charset; uint8_t *mc_colram; uint8_t *mc_palette; int mc_pal_size; @@ -197,7 +196,6 @@ static av_cold int a64multi_close_encoder(AVCodecContext *avctx) A64Context *c = avctx->priv_data; av_freep(&c->mc_meta_charset); av_freep(&c->mc_best_cb); - av_freep(&c->mc_charset); av_freep(&c->mc_charmap); av_freep(&c->mc_colram); return 0; @@ -231,8 +229,7 @@ static av_cold int a64multi_encode_init(AVCodecContext *avctx) if (!(c->mc_meta_charset = av_mallocz_array(c->mc_lifetime, 32000 * sizeof(int))) || !(c->mc_best_cb = av_malloc(CHARSET_CHARS * 32 * sizeof(int))) || !(c->mc_charmap = av_mallocz_array(c->mc_lifetime, 1000 * sizeof(int))) || - !(c->mc_colram = av_mallocz(CHARSET_CHARS * sizeof(uint8_t))) || - !(c->mc_charset = av_malloc(0x800 * (INTERLACED+1) * sizeof(uint8_t)))) { + !(c->mc_colram = av_mallocz(CHARSET_CHARS * sizeof(uint8_t)))) { av_log(avctx, AV_LOG_ERROR, "Failed to allocate buffer memory.\n"); return AVERROR(ENOMEM); } @@ -284,7 +281,6 @@ static int a64multi_encode_frame(AVCodecContext *avctx, AVPacket *pkt, int *charmap = c->mc_charmap; uint8_t *colram = c->mc_colram; - uint8_t *charset = c->mc_charset; int *meta = c->mc_meta_charset; int *best_cb = c->mc_best_cb; @@ -346,10 +342,7 @@ static int a64multi_encode_frame(AVCodecContext *avctx, AVPacket *pkt, return ret; /* create colorram map and a c64 readable charset */ - render_charset(avctx, charset, colram); - - /* copy charset to buf */ - memcpy(buf, charset, charset_size); + render_charset(avctx, buf, colram); /* advance pointers */ buf += charset_size;