From patchwork Sun Apr 25 22:34:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 27381 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:5014:0:0:0:0:0 with SMTP id e20csp3459459iob; Sun, 25 Apr 2021 15:38:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwH9BTx+AJoF0dPF8RR4BxIdX5F5rQ9GdrX45IZ/mwpQ1PAcQZzDzojHyHxJpPXAXf1vMgQ X-Received: by 2002:aa7:d9d9:: with SMTP id v25mr17444228eds.83.1619390328268; Sun, 25 Apr 2021 15:38:48 -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 p20si5617299ejb.124.2021.04.25.15.38.48; Sun, 25 Apr 2021 15:38:48 -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=gfhVf4Wf; 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 7E89868834B; Mon, 26 Apr 2021 01:35:53 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR01-HE1-obe.outbound.protection.outlook.com (mail-oln040092065054.outbound.protection.outlook.com [40.92.65.54]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id B8890689CDB for ; Mon, 26 Apr 2021 01:35:48 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=iio3D+5nsZ6a8qIoN1K1N/C0huPedgGOkxSWWLG0wKK5W5HhXSA8fZLlRyGxzd86v9x7Lnry+yix1cuJm37aS+XvqeMblM4aWWXoOqy5o+kYJVmu7UnsST/6DVQY+u2VrAYAqa/p8lcWmC2Nk02ZOLjOFalxJxE+kbGSP0Ik0OP0a0rQ0twjZ7j2+CNBodDgzQNHyQYjQmyoO0IguZ4Guw6sRlNzaZUH+dw1mvRiR3OQkPkMb8Ku494O/s8anaZ5M+y+cxYkKHPfER5/jncmv1O1fpHdSZQB/UFyzodDLOmCroSfGp8DxwHJT30l9r2nm5N2xh0G71R2NsCDMhQscA== 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=rnMA7BK4qim0npUhpGz2xJmWFhfDFPbxXRTy3kkwGL4=; b=D0R9Jtx90Cg8WJA79kjS/nRioZAC3BN4pQxU0gIEI3dsKmAqhd8Zbbu8/CdRk2RzVzpVur445XyJcIvWaHlrexQZ6/IG25Mo6pAf84HZugaxi/Myxgxb3GPLGBTQ/73s3+uNOp5Gm/pkjjEZzdK/beubxhnmZWICAdG8e8M/yRJnFPR4FSWbenb4KZNqUwtk3SH357Tqmz80P4AO+n0yDemMwsi4xhPGKDIInlIKxUmsNJbH+9Z4Qbmw7a12BuU4IMzIeTlUd2+FVsgTjRmwmLF2ZFdVvknbB+GQM7TNwR28Dyvx8q23RSZhnW4yOWxmCy6m0ZO7uRMIUTIrmbAdnQ== 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=rnMA7BK4qim0npUhpGz2xJmWFhfDFPbxXRTy3kkwGL4=; b=gfhVf4WfFShXutaUXjPORb+HxcCILMy+7KTO8Vz9xtnBgaho5uj3wnxzX0BvY1/1iE+sXglJFPm5DQtDBF0Rt2wX7t53R/6cR5mB0A6O0W5BIREQYqjT7UJZX8w4qpZNOpcsGOmTBWJV6B4KJe4JP6/2v8uQXELsrobEeGmu4pGvqf2CELjjb1Obb7hp7YsjsM34SGKd+SqexPDp+KRlB65VYUAM+gAhSbNleu0RX99jVP3QwgB4Ln5N60snVS3d7K/NUcNLy0chSEankRglAk5he/DoAeVTM9BR8YqDctRJi7cdkjnpva2xh3KgOh0qSTjVcmv7J+OJNXvZ8jJrqQ== Received: from HE1EUR01FT054.eop-EUR01.prod.protection.outlook.com (2a01:111:e400:7e18::50) by HE1EUR01HT233.eop-EUR01.prod.protection.outlook.com (2a01:111:e400:7e18::369) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4065.21; Sun, 25 Apr 2021 22:35:47 +0000 Received: from HE1PR0301MB2154.eurprd03.prod.outlook.com (2a01:111:e400:7e18::4b) by HE1EUR01FT054.mail.protection.outlook.com (2a01:111:e400:7e18::317) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4065.21 via Frontend Transport; Sun, 25 Apr 2021 22:35:47 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:A7E24582EA26D4B2D4B8352AE96AD7D72D6E0E58D8EAD5BA644CCE61C6257F76; UpperCasedChecksum:657E978D676BF6A2A849B76A81610FC1D7199214E1986083FC0690E8A5F2F553; SizeAsReceived:7582; Count:48 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.026; Sun, 25 Apr 2021 22:35:47 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Mon, 26 Apr 2021 00:34:39 +0200 Message-ID: X-Mailer: git-send-email 2.27.0 In-Reply-To: References: X-TMN: [bM4qLoNfVP9HokLPQdoTVWHX80AiwUEu] X-ClientProxiedBy: ZR0P278CA0100.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:23::15) To HE1PR0301MB2154.eurprd03.prod.outlook.com (2603:10a6:3:2a::22) X-Microsoft-Original-Message-ID: <20210425223448.130684-24-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from sblaptop.fritz.box (188.193.248.86) by ZR0P278CA0100.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:23::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4065.22 via Frontend Transport; Sun, 25 Apr 2021 22:35:46 +0000 X-MS-PublicTrafficType: Email X-IncomingHeaderCount: 48 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-Correlation-Id: a77d1b71-e4c9-4ae8-c884-08d9083a786e X-MS-Exchange-SLBlob-MailProps: gjx25WM8ZNWJWQ5lR/nEnbarXZJSK/i4ioRHOXMcivXi6OtyeFFCb0LcTLjv2Tg34ZKk+AvQU5mLAIbrVVpKz4dvzBH5fwgB/qj93wJLFwb5DyqbvAnY8GX6QbY5ROZcUWoYq52ds77yQlcHEPg+hZ3h6P/qbSvTSTd1HlLBzk+oZnSYJGaQ8EJ2/R6Knn+Am8dUDOrLqbIhEmrPykqSHRHPTysIdEd6KMaxILRS9ap0gVzULXuKuP0l3m3SrkEL5fuoEOhxULvW1atMBnl10jr5QFlYD6Hb5/vE6OSHLHVKUl/dglw6qs0zsIRWkGZU2wcbZ6bZOcC/61vvS29m/Wai8WRkqUAM2BM8Q0so5nvUsJTaTk2p+S6gTb1ofEdq2D60EIKGbIyIGCWFY4EbYAaCkEFl9eOv7QC4pkw+JVU0kSCiM7xFNreumMaSW+90DqzhqEpGbQ+e41yAefh/NAUvKSOx7ITqd5zPvhFLjawDPS9LVdiedFHylnWeKrULh3AHEUI8xLhxvlsFeEQvB+FNRcFWCyp+YDGvo1MtBDNvx8kdWNPDQ6LuEG8anZ+/m+EbwS0W016NPtwfT+jxtuSQh6M7SB+RZ9iB7qxvdJN7gR37/Ab6eKtBZzTijJd3bGi/jyPqmDH2ytKj1czUfwvYprXNA/SfTSSK4x/QCCeaJ6Rv/3rSRg5Vke6k6DJziTRA163dJBenaq5nKxHIP6Sr80g8S4qdthV9v8NLtJo= X-MS-TrafficTypeDiagnostic: HE1EUR01HT233: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 2HNXZrkS+T9fEqOhwoxb+l2Bch+lwxJKjklMRud2iBUVBropI7H8mdUsc8/8+lVi0b8SV0wDMPO84ef6k4weLVelxQzecfyFlMu4zSEipbKPR13YoXg9FDT2V4+V4ZcOkJGVz5t0kTT8iODxqjDJQT3CuHvJmKjlWzQfGVtNSzHGtOmenmQQm00hY3CtR0QUmcehTXSw3AjE26kgnMFJW2ZmUHNAmnISboWwk6wbMd3iBWuQgiUXMYZOKn+O+p8341vHVz39COkuZDbzRlmygvy3YvFV7bXl7Ur7yDQ/NenKT6wx4ZE6HRqprJOGtRCgM/yWAguB3VcJMFvCW/WGcOixQblE065zZ1t9ssj8wUsGFsLGOL0+5aKMr7OmXtzvbYxYbpStEYAuCCdS61Q7tQ== X-MS-Exchange-AntiSpam-MessageData: Tnw/FJUibCm6pvExVP1iwybkhthlmE3anFOpT003yGgzjJ7EnO9fK0qbA2l9aoDRSYrGkbkRuR48H5Vom+MiecE7xjUXU+Xw+iMwl/eG78INLLFNWUHv6iGwTTtwS1MzTelaCQoneRhOSWuK2Fzvvg== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: a77d1b71-e4c9-4ae8-c884-08d9083a786e X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Apr 2021 22:35:47.3706 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-AuthSource: HE1EUR01FT054.eop-EUR01.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: HE1EUR01HT233 Subject: [FFmpeg-devel] [PATCH 25/34] avcodec/libx264: Avoid copying packet data 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: iSAzxBUEbF5n Here the packet size is known before allocating the packet because the encoder provides said information (and works with internal buffers itself), so one can pass this information to ff_alloc_packet2() to avoid the implicit use of another intermediate buffer for the packet data. Signed-off-by: Andreas Rheinhardt --- libavcodec/libx264.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/libx264.c b/libavcodec/libx264.c index 4ddc4973a4..b23471a809 100644 --- a/libavcodec/libx264.c +++ b/libavcodec/libx264.c @@ -144,7 +144,7 @@ static int encode_nals(AVCodecContext *ctx, AVPacket *pkt, for (i = 0; i < nnal; i++) size += nals[i].i_payload; - if ((ret = ff_alloc_packet2(ctx, pkt, size, 0)) < 0) + if ((ret = ff_alloc_packet2(ctx, pkt, size, size)) < 0) return ret; p = pkt->data;