From patchwork Fri May 21 09:17:14 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 27869 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:b214:0:0:0:0:0 with SMTP id b20csp340483iof; Fri, 21 May 2021 02:19:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwS3nuH1+bu729P78yByV0eJE1r2l7Lfe4YJrfyQz2DynyA7XfKZVJDMzHNhm1VtA/glCiF X-Received: by 2002:a05:6402:2691:: with SMTP id w17mr10282748edd.140.1621588771163; Fri, 21 May 2021 02:19:31 -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 h15si4959619ejt.69.2021.05.21.02.19.30; Fri, 21 May 2021 02:19:31 -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="FxtyY4B/"; 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 9C374689CCF; Fri, 21 May 2021 12:18:17 +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-oln040092065039.outbound.protection.outlook.com [40.92.65.39]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 33097689A91 for ; Fri, 21 May 2021 12:18:13 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=F+fdcYmT8ZgA9eiB42V51hC9nqpoP7tg9XNZAqxKSvFkj41xV2Ef3+S1aHsQxqx451muXt769KmjXKb8cXi0+oBH10cpYpTJncevgREIlgFggANdY7hLph6KtpqxkWCrZl8eJlN+8aKX1VD4EoIfceqoKRgPhvYIZLVmaPF/WF+sz64oyZxr845RzrJ5NK5QEtlAhMcwjDezZ0ijuPZh5yCcveNV8JBgJNbEZk51P58k9BTBPQ7ydR5QuCVv+rcVndEaChBTz4Xd2HVoMMHN2c0WhvVcwy6NuV9T4PZRSrDZZMqJegxVYNpNhXNYFNq84hXAX4Zq7s0KRDAawcescw== 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=l9LxuugfZBBgHGzU2AS3FPXBRN35NCcCFHnd1bB01o0=; b=gqzRU8cSGSz2oeEXIWzsQvLwufEY9n3mYcnx79Szb5I3xYE1jYYO7QxShePAX5w3n+/CPTDPHOO77sp82WNvDjGPaIWono7Mb4TF87KRV3E+ifF1AFpRmq4ksRD3cUOe218NfKPEiil1bE/+BE53H/GQycjP31QqJR7qS5lbUHknTfQpu1nbBcdoedXEJvuygQO8gxp/atLZDBZbTReTF0wzfRw6MC+Xs5IkwY4nFyEEFEFs0i6zWTAZLLlvKD1VD3lpZc+Seez0Bkl7O8PzrSFJp0e8YPIWxRa2pOBTE1PDXuPseEvftHRoLaM7ex3Irgh5v5lDIT+RV576zBt2iw== 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=l9LxuugfZBBgHGzU2AS3FPXBRN35NCcCFHnd1bB01o0=; b=FxtyY4B/q8PSfaUQUCScxg9JFrWCswHllTT1efUZoitk1aLm7/m1W9DpwyTJ50OPUhFZbUWfOsKYPfYt6Cvog3ajK1x8SMQkyBxLU32M2WSxxqBdeAVOoxu8c8+ZLEEZ2dD4DJXmRlAjrSF9thVIZSlYMkVBwCSgbuf4ekh4FHzn4xypXK3iyv4WYBFsHQAlYlWObNLkhkvytho4xNwkFzr86XHOtml5gd6KIG5PbzeVlIhuBm+lHNENWdfyv/AIXp5Q70bXybMvHcuRmCJ/JS5NgafkxBkQQiKwnZc/4bAH7AKVQYL0qyfW9046oHTcoYjaJ5CuWlt9KeKbyarWTA== Received: from VE1EUR01FT010.eop-EUR01.prod.protection.outlook.com (2a01:111:e400:7e19::4f) by VE1EUR01HT016.eop-EUR01.prod.protection.outlook.com (2a01:111:e400:7e19::276) 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:18:12 +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:18:12 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:FDCB1B3A7F3EA480D069F7AC303D1441A5D97F82D6EE3024AC0EBA19903424D2; UpperCasedChecksum:1C1041684771704193A75CF352C75AD4F664D974A34A027E84EDFE81C3265A72; 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:18:12 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Fri, 21 May 2021 11:17:14 +0200 Message-ID: X-Mailer: git-send-email 2.27.0 In-Reply-To: References: X-TMN: [DBpnGkRCaCqp9ECOCL0FT/Z6R3gcf1rj] 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-10-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:18:11 +0000 X-MS-PublicTrafficType: Email X-IncomingHeaderCount: 48 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-Correlation-Id: f0148caa-cac1-4f6c-9a0e-08d91c395b69 X-MS-Exchange-SLBlob-MailProps: S/btQ8cKWiSiYaxVAPXjtBLAGaAm06UeinPAOcakI1x4rZACpuzIU2/ugI9cbZjGmJYDafTEGMR9jQVsdac6mbmPgJlHBSdgbm8nDGzD7jVKlWsZE2lDXhWxbHP9k3BeojU0NlW3lk/3BAN7jjlNVJJfRA2nsTsBgqalmnQAoQzKqpNUlZGc15ACS8UV8/7ZOVt8EZ8531bEazNfj5rxUH+jlaGK+FyZZlhPqbDDGhyAeHvEHgLMzyxQWoreP2OuSHR/9wNMYhPbtJQ6o0B30MRhmugP93Ds13uqCTRjgwjk0NZZTlShxChSGhcmqJDotthBHJru6qz6LFLS+EcRXef7wb+V64vagmBfw7IuINbHCDiglQQxyiLK/lQNVB1+qAMV67o7yEmVrnRAzS8veO5mqIsolDuxYXGSaOm9ofccejCjNY9wr0E63SlL+L85iGxxRuI+eKF8OXdjsYMjAjP/q7iZ6ZJAlcK9O1/MReDB+jjNwsPE9sQluvwUZu6p2MKnfbBmcyHhLv16yWD5biA1BPHb5xnZW0n8sNEf1Ds5GOXUgwt++6zkpIjycd97H+RcBNnx6zf96Iw6nt0FI3pZ/I0waecVUzpBPMyVm8Wfd37GwzmUj+CdhchGE2OmXNMEMpQ9vz8JX2E9iX+1mv/sLZbCPgwNHzLYFjQwm7z38b9809f8l79IAjko6elPeYUdfs+e9LPmXC/gkZrL6w5YlMLp7cLwwSxm0O8pjYzndyJW8OPP8IDmjb+0akowiIlweU8OWzg= X-MS-TrafficTypeDiagnostic: VE1EUR01HT016: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: K5d0cmcjwPzyyigbKskbZ+oeuX5hKP4Kw5CFPKWBJDwaakTvJYp6pg+BuAFv33caDy9Ta5I/sUkkm2U8rEww3KyBjoyJJ64drlEFS6Jt14FPgP8ld4QrM58nEVAhPe1rSTk3TMM24/vf/J7/ZaSABBMiP4G6fPYjcMIB0Ylv3momwDWVfnSjXNktQV5SLE28D6r7XcOs+bgMzlqHZwwyz28OM5SDctlJFs9b6eiUQGVgDgWum6/gSncRP+RvSHkotzx6KLIfiN1S61Cp/2awghvJklK1GoStRFWdAUadE+adYKtqmkKGgBFbxbJu0qa54rNTvjLv/BTtyWvLPnUsUv0jI1in5bItlbojw6WC5mOkFw5nTyC+1ruGdGOH9jHLqYgMmoBug9b2O+C4rRbktQ== X-MS-Exchange-AntiSpam-MessageData: YMhBN0IIFYpGNHGKLNImgJut+/Si+kUheA4ED4CPW9tCJFFYb7jqptYhdRrQvJL8Nc54QGPvaXiQ7r4KyzMcBRLpBwS7eMFykjiRHoNa9tPPta99UroPJHvJsKP1dVzzXmmyQQThBeFqeSmMMl0Xrg== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: f0148caa-cac1-4f6c-9a0e-08d91c395b69 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 May 2021 09:18:12.4575 (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: VE1EUR01HT016 Subject: [FFmpeg-devel] [PATCH 11/39] avcodec/libvpxenc: 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: 9Nt+tpFMwVKR 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/libvpxenc.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/libavcodec/libvpxenc.c b/libavcodec/libvpxenc.c index 8173af5dce..2d9e56837b 100644 --- a/libavcodec/libvpxenc.c +++ b/libavcodec/libvpxenc.c @@ -29,6 +29,7 @@ #include #include "avcodec.h" +#include "encode.h" #include "internal.h" #include "libavutil/avassert.h" #include "libvpx.h" @@ -1173,7 +1174,7 @@ static inline void cx_pktcpy(struct FrameListData *dst, static int storeframe(AVCodecContext *avctx, struct FrameListData *cx_frame, AVPacket *pkt) { - int ret = ff_alloc_packet2(avctx, pkt, cx_frame->sz, 0); + int ret = ff_get_encode_buffer(avctx, pkt, cx_frame->sz, 0); uint8_t *side_data; if (ret >= 0) { int pict_type; @@ -1830,11 +1831,12 @@ const AVCodec ff_libvpx_vp8_encoder = { .long_name = NULL_IF_CONFIG_SMALL("libvpx VP8"), .type = AVMEDIA_TYPE_VIDEO, .id = AV_CODEC_ID_VP8, + .capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY | + AV_CODEC_CAP_OTHER_THREADS, .priv_data_size = sizeof(VPxContext), .init = vp8_init, .encode2 = vpx_encode, .close = vpx_free, - .capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_OTHER_THREADS, .caps_internal = FF_CODEC_CAP_AUTO_THREADS, .pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_YUV420P, AV_PIX_FMT_YUVA420P, AV_PIX_FMT_NONE }, .priv_class = &class_vp8, @@ -1861,11 +1863,12 @@ AVCodec ff_libvpx_vp9_encoder = { .long_name = NULL_IF_CONFIG_SMALL("libvpx VP9"), .type = AVMEDIA_TYPE_VIDEO, .id = AV_CODEC_ID_VP9, + .capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY | + AV_CODEC_CAP_OTHER_THREADS, .priv_data_size = sizeof(VPxContext), .init = vp9_init, .encode2 = vpx_encode, .close = vpx_free, - .capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_OTHER_THREADS, .caps_internal = FF_CODEC_CAP_AUTO_THREADS, .profiles = NULL_IF_CONFIG_SMALL(ff_vp9_profiles), .priv_class = &class_vp9,