From patchwork Thu Apr 29 23:57: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: 27503 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a11:4023:0:0:0:0 with SMTP id ky35csp2019002pxb; Thu, 29 Apr 2021 17:03:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxYPoFxWv1kCYgCAUXg4MovXBEM/HoBDA+PSbE7QGAIg/HZb9qBEFeq4og/MxmFKiF/NfrJ X-Received: by 2002:a17:906:f56:: with SMTP id h22mr1121683ejj.366.1619741024319; Thu, 29 Apr 2021 17:03:44 -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 kl2si1781749ejc.82.2021.04.29.17.03.38; Thu, 29 Apr 2021 17:03:44 -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=fE951VB5; 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 7B3C168A497; Fri, 30 Apr 2021 03:00:03 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR06-AM7-obe.outbound.protection.outlook.com (mail-am7eur06olkn2082.outbound.protection.outlook.com [40.92.16.82]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 1E65268A473 for ; Fri, 30 Apr 2021 03:00:01 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=TUxFoqrKJycQC31xpwV02+MhIazk0vFTWrj8P/zLHghEosfIt7kt5mq2/nKLOvuU7ybAmtl7KKu7rVkf7kUudkBhXnkiF+Pg1KMUujFwUnYf1f5JaRymh/xytA7LD7vVgcKFyf1qEJOfH4gpa4v/eJg6E+sd1a+899q2sKH4WdacXHryF7JsVPxTrtSFaC7OmzbIdAUAyeUxiWvVSXcYVytcRGtJX1+Ns67D9gDX/ugh2oa1y1laCHdpi6cesXP/4ZCK+xkuiI6cwdH/Fmhul9vtxp15g+hEQ5MdGY33AcSVe/GrLXXgdYrOYGJQ6TQ11AgEkb/jjfIgXNcm1JXqsw== 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=Aeq03cQRAJd20/41OXuMg+JNAZGvoWsZIFJQ2QzBZQE=; b=cyAcsNIkhKt04X2XW5oDL1l8ea+H8oJdKmy2niDE3y9+Z/mvtRzXuft6g0KpHhxRa3czV8pz1c9jgAc4e4ABXR4DcIxwyzYfKV8rAqQK6Bn7SADuzaiMEUffnBFs4juM4OFwTlbcfDRPs+pnBL0r7jbU1k813k7e/NFSD03CYBO/0donJKwrUnt41TC5bAqPzrbjMQOwlhoqSWVUPxViyMUEtIkZQ/Mz3pJ2+vryPOV1Nxrn6a5wLoux7YduKAPlHr7BW6AaxJm0HcEp7VvchUr5UmejOdcpi/UE7yA7RTh5O7jxPvItruW4jYwZlJBI4mgwJWAEzwJke35Q8NQ6UA== 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=Aeq03cQRAJd20/41OXuMg+JNAZGvoWsZIFJQ2QzBZQE=; b=fE951VB5mdESEcAb5Kjw1uzXNf/oBk0NeOMskSPaEP/0IxKOxKhdxdfxqvMI/nzL/wMLNIYCkzdD8siM08qAYYKWEkJoqYOk+eWreTUR6d1cUSC8VYOaGjFASuDmvsVbADpaiwLUpuZ96BcnKCshyJYitcAT1y1YWHVKGX06+0CVW/9bj30JWITK+V7Va7HSpKrKkpbk460560zqATnDUioW4b2Xz1tmKQ7sMqb4yebGWcWbpaERDB+fdpQeKliIjz+4XQ3W1FNqd3NMBo8Pq7fP65mCjq6Kxf3cXMk50UP4X0Z71+516HU083+RnLfg+zM0Zgfw1S8R8dbHWRxdKg== Received: from AM7EUR06FT055.eop-eur06.prod.protection.outlook.com (2a01:111:e400:fc36::4c) by AM7EUR06HT060.eop-eur06.prod.protection.outlook.com (2a01:111:e400:fc36::466) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4087.27; Fri, 30 Apr 2021 00:00:00 +0000 Received: from HE1PR0301MB2154.eurprd03.prod.outlook.com (2a01:111:e400:fc36::49) by AM7EUR06FT055.mail.protection.outlook.com (2a01:111:e400:fc36::61) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4087.27 via Frontend Transport; Fri, 30 Apr 2021 00:00:00 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:94DDE2A825E57567F10BCDF97853F3A962DA93BC7954E5538F1514C1DFAF1B91; UpperCasedChecksum:F1C770AA7058131E6348B47388063F0136FF462E31CBAC5420ECE4158C122437; SizeAsReceived:7777; Count:50 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; Fri, 30 Apr 2021 00:00:00 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Fri, 30 Apr 2021 01:57:09 +0200 Message-ID: X-Mailer: git-send-email 2.27.0 In-Reply-To: References: X-TMN: [fy+zDGoL0vaXCyScFe8uu8/GmMr0AV5V] X-ClientProxiedBy: ZR0P278CA0088.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:22::21) To HE1PR0301MB2154.eurprd03.prod.outlook.com (2603:10a6:3:2a::22) X-Microsoft-Original-Message-ID: <20210429235717.2067041-37-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from sblaptop.fritz.box (188.193.248.86) by ZR0P278CA0088.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:22::21) 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:59:59 +0000 X-MS-PublicTrafficType: Email X-IncomingHeaderCount: 50 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-Correlation-Id: c31c18b4-b592-4eb7-fa30-08d90b6ae5de X-MS-Exchange-SLBlob-MailProps: gjx25WM8ZNU6XUx7q8EQ5McclV510mdNSQ6zVwN/I7EX+rk7h1h8rgqhciQx18U9NLAZa+qA6gywEMO0gZY3oBXsMgjObX9DwWAFCv0y3hiYg6N+UAws/taakZGdsXJd0XHzmR0v51Yil0eLC7lkb88op8p4IUvp7/sqOWBy+1RjkDxkkPmFoao3O+rn7vkuJbENwibvZkgerO0dEJvGzACLaNqsNJaziPQzu1wwOJySmcoG38AwsY3dZ0u1vanAOfENXcCAMuF2gNXDCwsPX+nWrgf30CoWXQmZzzGlcjCWcZjs8o46fWnb34Q+UWI2oKJBekwilkFJ6AItQxBZrJR8sUyYtNcLrXHFChFITBYUF9lHF9nElZH5WXVBL51lQX/z+OfVaCSUj9MDmu2c9pBdqQ20qW0bIN3B+0wN4xkj7FlhaAmtujVrQ4TevfnHJeple0dvfiLBnBt0LXN0sswx6+E7b/56ewwtnl2644NIXEEExqrOwgCY1MdTzVkUaYn4jKhV/N2ErqzH1lbLPo6KIiyvA16bXm/M7uU9vCMAvuAiL6iy1nsQE1w0ED8iNUeHqjFPVvFLrTV2LjRZNPCQNmpz+9gPXwrOaefuDv/HWsoME0gJbJYBTd8U79S/pv4bPAQjv2VWDar6rYdchG26qi1W3sYip12OUlQBic4Ewrt4mwU9ke1RC806+4HbGwDgdG7V+aoSi+naKvWBijoNQ12P85cfGVPttZkh/dA= X-MS-TrafficTypeDiagnostic: AM7EUR06HT060: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: dg5ArLLbj7Bj0w6k+CW5i8WNlhKAde30dxllrfcbYF3Ejm407GkohuN+gO6IV+MKpQAbPGJMKO7oF41/27il4cqfCNAlaZBv9qi8lJAxH4v8pReNnl/PHUVTScbcnXT6jyFNZC/+Ua9mF060O8pUqCdMqC6YnyHRxiUNOj2yUJo9YxfMZna01JxUbJFw0kpkY8AKvsJQb/7Yok7S+MZZfwTsj0SCvq1t8VxyW2P26I0Yjs7ECjrIYvE88ZXS3Bt/qLf+UXvoX8rh0MUPAuAuQaokTL9mTYFlI0Vm4GWDytxUEQQYsrOTsu5Wf8u6cEtyzavS6VFL1fBIbABxcV3DbNj3Ki6Y88qYRFynyd85Nmptpxgg1yfe4FjYJoy8//mDwvs1Lp/FBXHHWQw7c7qa9A== X-MS-Exchange-AntiSpam-MessageData: UzuqkmxnHVHwH5A83qY4kqb85bYnXqs/yVbgHyIRNiD83XCUkBXGURxjx25Um8nPsL0ceCZtuka+1TK9hO/ajhYmlpnxDwt6WeXla8YF8AUBJtZN/YSYTnaLhUdVmHQTFNwSgB3o5imB9ykYy1OPOQ== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: c31c18b4-b592-4eb7-fa30-08d90b6ae5de X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Apr 2021 00:00:00.2499 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-AuthSource: AM7EUR06FT055.eop-eur06.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: AM7EUR06HT060 Subject: [FFmpeg-devel] [PATCH 38/46] avcodec/v408enc: Avoid copying packet 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: 5S2IG3Hfllle When the packet size is known in advance like here, one can avoid an intermediate buffer for the packet data by using ff_get_encode_buffer() and also set AV_CODEC_CAP_DR1 at the same time. Signed-off-by: Andreas Rheinhardt --- libavcodec/v408enc.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/libavcodec/v408enc.c b/libavcodec/v408enc.c index 7df371f0ea..a0cda6fb0c 100644 --- a/libavcodec/v408enc.c +++ b/libavcodec/v408enc.c @@ -22,6 +22,7 @@ #include "libavutil/intreadwrite.h" #include "avcodec.h" +#include "encode.h" #include "internal.h" static av_cold int v408_encode_init(AVCodecContext *avctx) @@ -39,7 +40,8 @@ static int v408_encode_frame(AVCodecContext *avctx, AVPacket *pkt, uint8_t *y, *u, *v, *a; int i, j, ret; - if ((ret = ff_alloc_packet2(avctx, pkt, avctx->width * avctx->height * 4, 0)) < 0) + ret = ff_get_encode_buffer(avctx, pkt, avctx->width * avctx->height * 4, 0); + if (ret < 0) return ret; dst = pkt->data; @@ -79,6 +81,7 @@ const AVCodec ff_ayuv_encoder = { .long_name = NULL_IF_CONFIG_SMALL("Uncompressed packed MS 4:4:4:4"), .type = AVMEDIA_TYPE_VIDEO, .id = AV_CODEC_ID_AYUV, + .capabilities = AV_CODEC_CAP_DR1, .init = v408_encode_init, .encode2 = v408_encode_frame, .pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_YUVA444P, AV_PIX_FMT_NONE }, @@ -90,6 +93,7 @@ const AVCodec ff_v408_encoder = { .long_name = NULL_IF_CONFIG_SMALL("Uncompressed packed QT 4:4:4:4"), .type = AVMEDIA_TYPE_VIDEO, .id = AV_CODEC_ID_V408, + .capabilities = AV_CODEC_CAP_DR1, .init = v408_encode_init, .encode2 = v408_encode_frame, .pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_YUVA444P, AV_PIX_FMT_NONE },