From patchwork Fri May 21 09:17:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 27858 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:b214:0:0:0:0:0 with SMTP id b20csp339585iof; Fri, 21 May 2021 02:18:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwmCOEU2upVhnBPR+EbGD/6DGpkqL190ix8eWpjp/ONFNPrTBpnWYTETckboyqNCc7RsAe0 X-Received: by 2002:a05:6402:5211:: with SMTP id s17mr10383638edd.352.1621588683218; Fri, 21 May 2021 02:18:03 -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 f16si5313486edy.382.2021.05.21.02.18.02; Fri, 21 May 2021 02:18:03 -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="n/qLDZ4c"; 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 BED57689888; Fri, 21 May 2021 12:17:59 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR01-DB5-obe.outbound.protection.outlook.com (mail-oln040092064041.outbound.protection.outlook.com [40.92.64.41]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id BE4B8680BFE for ; Fri, 21 May 2021 12:17:52 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=S/yQQd/n5TvZoQ6K7gsFQ1z21DM+evY3dCAe9zFV0dpg947HcakWNl23B+he3fHm2Qfc5C+YoWR/7kQAPCkD0+U9FPVLBbWRgfLYClmxK2u8JLreMJqqSSeNTH72WIJQLGROcNs8oL+UIUf7Iib0s2FpVw22foq4JGl8eCEcEzmYc9XuXZ1E2AIKi7i40jBG3m8zHJYoHQ7QqFd4b1jsms2BV0JeBmGXLJCLSGYvd6RvbUJddiv+QrLsL0Y75VUTeYKBYHX1zlcV9LYSRlBs6OdAQh5rBaLPS8od4gQfdCXA1iFsceSYYIXkikn41Vjz1FARSQCzGYDJyCrNBrJ5Sw== 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=J+bBkPsgRapg3sB5Kj0oy8sFMKMHfcnFtmmGYbV2DQU=; b=Bw9WYrpMH2AYHtkch6QOWqCXeqiUd2HyRpB0Ccqxz/aMLkNH03gWgxjJgsz1RhDQLdKYbTCwawiN9JxfVeE44qXnLal5KXg8FYQ9KgIf66zvRA2KVsE5mvPO8puLW1o25Lkvz1asDbFaYCwKDmmXCXxFbCrXy5LM8jiNuC8hQUUovTHrlJ2SqZr5n8tvBwJZjjUOnWEA/vSWsVfUymKq4YhFKZJVzjYdv0+AcWvi9a0Uk0axnTN9n25qEJ6lCKjaxmV3mIpw6lh6A5VCvDzsHFB7mQlH7ce5G71+Idi4/PoyfzT2pCjsJrPLyjZCSV8jzAb17Pg3P0rdCG+0rA/Mmw== 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=J+bBkPsgRapg3sB5Kj0oy8sFMKMHfcnFtmmGYbV2DQU=; b=n/qLDZ4cHGA/YB6lWl9NUobjUJZTCzb9UMJ7w5SXyfZ/F/riDRe/XD8RfDN1p2TOW/9ZPlAYoknHHC0HaygE5D+kxDVZ16hcXgm65mf/bvDBOu6dTJevzc2Bq6sab7aKNuUNUcmbg0lKKXA2ysMSbfzN94PsKBsySbeDds6CWYWzO59fwZW8eF8Tz+bSPNEE7OMaCX+kx9hYjecPCbzfQL1mNHIHavd75cXemWQLRR1r6qUw653imgXVKOQ3RHme/j2jI5Nd8GgN5Py1p9OyETu7aRybyLht8oNr4F/W/tssE54iTH3VG8jMB/f2UQXOkTCtexZbvI+Wyq3/rI3+fw== Received: from VE1EUR01FT010.eop-EUR01.prod.protection.outlook.com (2a01:111:e400:7e19::52) by VE1EUR01HT006.eop-EUR01.prod.protection.outlook.com (2a01:111:e400:7e19::115) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4129.25; Fri, 21 May 2021 09:17:50 +0000 Received: from HE1PR0301MB2154.eurprd03.prod.outlook.com (2a01:111:e400:7e19::41) by VE1EUR01FT010.mail.protection.outlook.com (2a01:111:e400:7e19::83) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4129.25 via Frontend Transport; Fri, 21 May 2021 09:17:50 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:7930BA08133140220B58ECDFD09627D53EFB0FB01E927E1C3A3AD74D9244A209; UpperCasedChecksum:42F220E52BC4AFA622DC7695FFE1A4DEA600AB3F17A47EDCB7C3E768F6B9E9C6; SizeAsReceived:7603; Count:48 Received: from HE1PR0301MB2154.eurprd03.prod.outlook.com ([fe80::f4cc:63fc:9cef:37fb]) by HE1PR0301MB2154.eurprd03.prod.outlook.com ([fe80::f4cc:63fc:9cef:37fb%6]) with mapi id 15.20.4150.025; Fri, 21 May 2021 09:17:50 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Fri, 21 May 2021 11:17:05 +0200 Message-ID: X-Mailer: git-send-email 2.27.0 In-Reply-To: References: X-TMN: [mT/bKC0PYyn00y0MtquRPXNDlA/udIP2] X-ClientProxiedBy: PR0P264CA0070.FRAP264.PROD.OUTLOOK.COM (2603:10a6:100:1d::34) To HE1PR0301MB2154.eurprd03.prod.outlook.com (2603:10a6:3:2a::22) X-Microsoft-Original-Message-ID: <20210521091742.184902-1-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from sblaptop.fritz.box (188.192.95.27) by PR0P264CA0070.FRAP264.PROD.OUTLOOK.COM (2603:10a6:100:1d::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4150.23 via Frontend Transport; Fri, 21 May 2021 09:17:50 +0000 X-MS-PublicTrafficType: Email X-IncomingHeaderCount: 48 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-Correlation-Id: 565545f8-1d72-42a3-a3b9-08d91c394e77 X-MS-Exchange-SLBlob-MailProps: S/btQ8cKWiSiYaxVAPXjtBLAGaAm06UegjoLookccLr58AFc0KkxebYtgP8LL/3+DC82RFQLu5dd3iG4K9fz5Khx3lAXfcq3eZmgJ/BU/Knid5nYpjtoOMAg9/GsI5CLZa2QOKmLFO7LEAEUvNWvZvZo7M/HslDcVgXIs6y8m4sKpjHW1gykymxpNe62UWLScwU1Q9rUlIKE0YelG5Jm0PxplJ7fD51dwvv+BfjLH3wj/FbX2WMWmWCsa10R8drUi/VRDoor5cY5GQu2Cc2CYPMYMXW8w2q7G4osTt2qP24Ic3Bj4Dt1N5KiCy8IjQfFnE8NuDUBD33y2ETvSQSv5A1fVSQJSI1ylCwwK37cuvNKrpcvYIPtXtZiUwAjKT85j8403KJZmVBESklbv3vD1sU3WpxmO7D+VIuCR5VYhRXiXSFVyJih8Ury/hNPLXn8Tjv/THyE1Ty2tI2uva+a/PXS34e/jrYARrHNPeLoBzxG8x4Jlg7ZZSgXzCkZaKCD3j7gG4SuZgF6ttV+JPvIm5LaV22tcQl7riK0LBeaLZEvBtRG8m5XhzE+sU5nUh8Chit6yCnXuaSKj4SfPuS9iHG45bnqqqEO3XwUWby1hH6Zmnq/D6bI7+DKWqW99axyPFH5ecDxIZLi5GkO+d/gL9RNJDVYwq24hzDzBip7xz07GXnWTYs5Ni+jnHIM2OKNiZAI1mT+6CnGAFSVe9t3QHQTIfef6MOVAjqEmC2YQyoW/joHjdnXQox+TmyA9kTJPVqc9ZzrRs8= X-MS-TrafficTypeDiagnostic: VE1EUR01HT006: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: YaLsz2dbdXqlrK6U5wu4um9SaMXLWgSkvymq8VobCw5F/8fWnP5gae0paTYfQvUFJI4toFlUeVWipA/L9u18dtGiT2ShytaOESarl9+eNsThlqca4POo4N+hCFXYJIf72nfDS87ju4M2pFxKgjGFW2DoI6V2osmPEBnurIoaLlvR7lLScecPe97lEtHgLM578QMh01L3TMEPs6HxQB4sULH9psPHPK9zP0Xt0X01X1IaSxXCxMtjoTOv7jaVQqd7sHnoRVLeY2vax4I00A+ksXXZIMs8mY4tYxcjKvy7J21FRmPpi4r8MFLH1pT93pNGQZB2IyftksSa2Prj4JPmsoZu6ha4mxPTqp6Dc6UP9YxNSYXLSBY3u99+mMKDCuwjyMDkPELYYAiX6BptHvH6fw== X-MS-Exchange-AntiSpam-MessageData: CGVSIbojYUAsA3nCaxPSGImZSBq2ffAEQhXAJ9XBzUlMzjxeWRCfjwaFvekms8wQ1h5gvVBuOnO7BUuvNwYdivteUwBPiveY7fWz3mw28bIJkxijGENJbjXno8NgEJqxr+dWqEakK2AcDk9AsFzsug== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 565545f8-1d72-42a3-a3b9-08d91c394e77 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 May 2021 09:17:50.7721 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-AuthSource: VE1EUR01FT010.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: VE1EUR01HT006 Subject: [FFmpeg-devel] [PATCH 02/39] avcodec/libaomenc: Avoid copying data, allow user-supplied buffers 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: dWcnwF6CLwb0 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 use this information to avoid the implicit use of another intermediate buffer for the packet data; and by switching to ff_get_encode_buffer() one can also allow user-supplied buffers. Signed-off-by: Andreas Rheinhardt --- libavcodec/libaomenc.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libavcodec/libaomenc.c b/libavcodec/libaomenc.c index fcf75e835d..779714fdaa 100644 --- a/libavcodec/libaomenc.c +++ b/libavcodec/libaomenc.c @@ -36,6 +36,7 @@ #include "av1.h" #include "avcodec.h" +#include "encode.h" #include "internal.h" #include "packet_internal.h" #include "profiles.h" @@ -970,7 +971,7 @@ static int storeframe(AVCodecContext *avctx, struct FrameListData *cx_frame, { AOMContext *ctx = avctx->priv_data; int av_unused pict_type; - int ret = ff_alloc_packet2(avctx, pkt, cx_frame->sz, 0); + int ret = ff_get_encode_buffer(avctx, pkt, cx_frame->sz, 0); if (ret < 0) { av_log(avctx, AV_LOG_ERROR, "Error getting output packet of size %"SIZE_SPECIFIER".\n", cx_frame->sz); @@ -1344,11 +1345,12 @@ AVCodec ff_libaom_av1_encoder = { .long_name = NULL_IF_CONFIG_SMALL("libaom AV1"), .type = AVMEDIA_TYPE_VIDEO, .id = AV_CODEC_ID_AV1, + .capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY | + AV_CODEC_CAP_OTHER_THREADS, .priv_data_size = sizeof(AOMContext), .init = av1_init, .encode2 = aom_encode, .close = aom_free, - .capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_OTHER_THREADS, .caps_internal = FF_CODEC_CAP_AUTO_THREADS, .profiles = NULL_IF_CONFIG_SMALL(ff_av1_profiles), .priv_class = &class_aom,