From patchwork Sun Apr 25 22:34:42 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 27404 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:5014:0:0:0:0:0 with SMTP id e20csp3459599iob; Sun, 25 Apr 2021 15:39:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy260rH9Um+Y5Wr8VX60mY9uXFliFScHwutvf5E0N2t+pT5ADm+1a0prHfmAjKirCk3eyx1 X-Received: by 2002:a17:906:60d6:: with SMTP id f22mr15317575ejk.177.1619390352748; Sun, 25 Apr 2021 15:39:12 -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 r26si11332704ejc.505.2021.04.25.15.39.12; Sun, 25 Apr 2021 15:39:12 -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=Jbz9RCQD; 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 6FF126881C8; Mon, 26 Apr 2021 01:36:15 +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-oln040092065100.outbound.protection.outlook.com [40.92.65.100]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 238BF6881BB for ; Mon, 26 Apr 2021 01:36:12 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Y+X/Vl7ylTa4+FQ9yEn7xg4w+FkfHGm+rU/FnfPK9n206naVVf1mI96Z/U95DK8wR02PwxlSuriNIvK8bLvLN62FoNG3HxcTzkuTNrud93lmD3pln0uiO1bytDnNwpMZTiADJNHsvaQEIjcxrGqsF+3+rgifuYGwxzT7xnCrL7/+h/RLeq4Qh7soID3oja4qCeS0g+1Q1Fmf6qLaVq5fTxIHXYoP/B6RNuMrKgVhsqg3V7O9aIbN0CsWO7P+EOFjzsPdOV6YEQ3uSIHr1GCEvr6pDNorHHeoFnq8UMzVzvtr36MygEpmg8Kt4tHJzE7dWderWL8CTlKlGQfEXcP3dQ== 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=zNjFSlCFKBrcqFdxSeoTTjOdEJkkYabY5ANGse0dRpI=; b=hDMOD2VfqpU7E9ZZC5pG4idHlO1MdRcB2QbPfA88rTiTxlR10ym0QpG+p90PUyzjJ3DoTsLXlcltMQgI1avaRgmkRMTXz8/NSRSY4NlQtFvT8cc/lZNpVT75dmU5jH0suglr8wbQXIBLP/x3qE1Gy94RJq03OCxfrIhKobdpuvPgfWaYqRFpFMpnEiOOkLSit6dQ1MYMQuT/rgJSbxamU9J2zzjzuoXweeQyTBkspN9bd+XknTiEhhuqTDEQV7Hm1mbvrEfNmmJ/gNUQjaaM7tUOsDSNufYXL05wZLjDpOJBnkVB/avv2zLJ7TMQf0mfuKwE39TdgXdb7UjRX9NpGg== 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=zNjFSlCFKBrcqFdxSeoTTjOdEJkkYabY5ANGse0dRpI=; b=Jbz9RCQD6JUP5DnwON1JkKJJEYYAKAt4s08IPX8v2dO00TF2tQZ2inIGlEsRHtBpXlsAJBirZoyeJoqVt3y0zpEdPprRvf/4bfySwJHSkY1tAmCeZWcdG78S7mm9n0OMg4cr7NGcmRR/y0hed8X/g7s5Nq0n/hW5JWY9+4/2g4FQC5ThNp3/YzbxhSSe3kVhRcZCWsht7KUVhsLSOoOrLv+icIGncuvzDKuBgggWU++1g+DndR6RU04IuXiNggzMp286maya9MCph0vhqOCEucODojLBdVhIUYfAvpxLF8yC2InFgqBp6bUiFym+c9plbGHxU12PqyL4rZaTOyL4Ew== Received: from HE1EUR01FT054.eop-EUR01.prod.protection.outlook.com (2a01:111:e400:7e18::4f) by HE1EUR01HT161.eop-EUR01.prod.protection.outlook.com (2a01:111:e400:7e18::141) 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:36:11 +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:36:11 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:4E8B6C3E0B91451C53ED9B2A7FCEBC09906562F78BF9F543B0C104A8C4BDF54E; UpperCasedChecksum:34A5D78BDF3BC42F5F475BCF366361A312A43738DCFB760BEE16F3718B5A019D; SizeAsReceived:7586; 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:36:11 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Mon, 26 Apr 2021 00:34:42 +0200 Message-ID: X-Mailer: git-send-email 2.27.0 In-Reply-To: References: X-TMN: [QvJiL3hS739caAZmpdRSqhfRYakJFpXj] 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-27-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:36:10 +0000 X-MS-PublicTrafficType: Email X-IncomingHeaderCount: 48 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-Correlation-Id: 5fa03a20-4653-4989-5f4a-08d9083a86c1 X-MS-Exchange-SLBlob-MailProps: gjx25WM8ZNWJWQ5lR/nEnbarXZJSK/i4i6upxEzFgJTg0emeJ12tbCH5m6GX5Wbrtt9lUTspB4tlCOlcUcYtrmUyCQHV0P/WWYJcJNntSPPz7Q38uxGUKnlIeT60mHanH05fhLDGr3KI9/sKF4VsVaLrZT89hbQ41CnPKU9zhlpwfqh8R7rZEq5qHpD7XfQdzuidChRTAFTXPDFckp9sp21FiSt5KbYCzfGMs+FMKU+N80fWtK/IX3LF0Q0OBU1mqOVV87XEC94I1iau1czv7OQR1XreSb0n1h2L/rGRzv2cO6ppEUhi7UOz0osR8wqC8XOsWOkf5PZEIJ6Tnn/ZqQYp6mRz05eH9cw1j57itGfOiPG4dDsL+bs0Excac01MRokA58zxNMS4k42uRzG344mCz+N08QUy73pni+bbcNgfRcovDUNkGzNtzxExDGyaGW/+PQetEFMbPAK+3uL/E80Nf/Qv+VdrdYtV3fYHHBNr1iiE7Q7fdrr74hgM5dNNIE+pKK2sOHzfz5swF5aMowB7trPFyRQRQK1cz2hwY3IQHy52JzJDdggCKopMq+hwR0cH5m1A9vPI2MRPuNzLkAa/pQpOpcPBuwOwfBxqsDMAX1IFuu6xAONqLmNkrRYInvsaqtkNNhOFyKPD2G9sCVCqPdX09MOEevEUnf7RAi8g+pcI8vkjlL6kn490PjWBGxhGHQaNy/TrUf22+r7dfrmgiqUY2rYW6Sdk4y5sdT0= X-MS-TrafficTypeDiagnostic: HE1EUR01HT161: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: hE/VWPZE9DB8kOyUye+5KL0xNH4o3gRpPXU0niB3Vi1qbF6QjLNw2FSp4HaLR69kKd1WqSlQ4cFJYq8PS4S6mt73sbatfX5/qzEwkXSUZpXH6QHHPJ3Hn99u5MiCfeFWfjfyfHxrNvKkKJ8cabQNbLwP6iku0eKShLxxrNqGNx3nZxSgttkAS55TNCSeyOKYVzWuoPqP1bVU6/dhDWM0jxVpdD+g9FMHngg89r9ut98to96nfNEdnWe3ws8rOwz0Z8ESJpXryHLtOzJ/V4kETHBHQud7GeqFhxc6T/GzsRZu/Dgcd8oj8PNv9kLcP6XCqbMv8+WMtFcPQkiitX6apMl/MuGggEKlHJqSS+HPhSW3IXkKjt9U19ia42M4FYBc X-MS-Exchange-AntiSpam-MessageData: t+7ab1Swv/Coxihrgxa2YgwpPNVE2D+/QgsBTuFZhDjJLfPCiID0C1Ed2zZLUc8BzIT8nlvypccACvoZo2v7pYVu8JeVNU2EjWgcMgHUBMPUOJ4smQ41FJiGzFvCRE7b8Suax6BGL7aPM38TcNqlpA== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5fa03a20-4653-4989-5f4a-08d9083a86c1 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Apr 2021 22:36:11.3790 (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: HE1EUR01HT161 Subject: [FFmpeg-devel] [PATCH 28/34] avcodec/libmp3lame: 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: icUhZm9R1xr1 The libmp3lame encoder already uses an internal buffer, so that the packet size is already known before allocating the packet; therefore one can avoid another (implicit) intermediate buffer by setting the min_size parameter in ff_alloc_packet2(). Signed-off-by: Andreas Rheinhardt --- libavcodec/libmp3lame.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/libavcodec/libmp3lame.c b/libavcodec/libmp3lame.c index 2beb28e569..bdb69424ee 100644 --- a/libavcodec/libmp3lame.c +++ b/libavcodec/libmp3lame.c @@ -264,7 +264,7 @@ static int mp3lame_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, ff_dlog(avctx, "in:%d packet-len:%d index:%d\n", avctx->frame_size, len, s->buffer_index); if (len <= s->buffer_index) { - if ((ret = ff_alloc_packet2(avctx, avpkt, len, 0)) < 0) + if ((ret = ff_alloc_packet2(avctx, avpkt, len, len)) < 0) return ret; memcpy(avpkt->data, s->buffer, len); s->buffer_index -= len; @@ -296,7 +296,6 @@ static int mp3lame_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, AV_WL32(side_data + 4, discard_padding); } - avpkt->size = len; *got_packet_ptr = 1; } return 0;