From patchwork Thu Apr 29 23:57:01 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 27515 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a11:4023:0:0:0:0 with SMTP id ky35csp2017530pxb; Thu, 29 Apr 2021 17:02:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzGsUjEp2Dc3VxofKHRe1igh6dQ3/B2f+is2Sj9sZrEnIf3ZRA30m03/rEYpu5M9VnNczzP X-Received: by 2002:a17:906:9407:: with SMTP id q7mr1089709ejx.434.1619740924279; Thu, 29 Apr 2021 17:02:04 -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 gx22si1499024ejc.568.2021.04.29.17.01.57; Thu, 29 Apr 2021 17:02:04 -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=LQU5bhr5; 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 5631B68A3F4; Fri, 30 Apr 2021 02:59:43 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR06-VI1-obe.outbound.protection.outlook.com (mail-vi1eur06olkn2046.outbound.protection.outlook.com [40.92.17.46]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 84C1068A3C6 for ; Fri, 30 Apr 2021 02:59:36 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=P4V1h45uLfojlO30yXe7wCnDVfXrrXcc3jRIKHfRnZFXbgg7zDrFDSh5bdRZ3WW20CV7RWoA2NXaJDELIPuGNLsM8FXnDBXdhWQ4wBzyluOeDp1vVQPtEiSV5uO5lw+CeBKThRE9JND+57OQ8xEZf9sexFtQb1inktJmN8MyHVvLQ++8ZBCxdmsJFqyvtxcwcHrL2Csd/ZiUdi/Hz723a3WX7A0pfo4I11jUQKri5L1Usv04edn6wA3dS/n5WDr47jkyiZX0sFNR+AiJw8sab92Jn+fuM95rUXZbs2SLLdPhdOzC8TQnzJ5KCuVP1w0NuuFtD8/OaAGNIFnpFbmrTQ== 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=gS7efSc7G9sY3Ye3xyfdgMA3eC2KortZZAoZ8LQ96cY=; b=cz/8ffoX/SsoqAtsyHtMcxL1dVxVw5vwHHi+4uUyCXsDYL/scMuf18FizxqMMKSaxhnBpiOVtYK7OJoQm7MZCgNGjC9L1y9ctl9NmYfjujrTDlr4XvTShv0Mqac1wGXa/uFUm/OBDkBQSYaBFl1jbG8v+qODfQVHBM1xgsLwuWmHNBV6T0YtStl3Ifciyqk9Dr7Rub3Nj+WC9NQ++kEN6Kq1bQhwMV4hloTYR/IqojS9ZTOu9ccAjRspx5w/xM3MY4ETjGcGAxy3g54J3zQHD6Vas+2IcIbpgyXgHg5Td0/m39v7VDIaYNKyo8Q4KISNz1k1LBeJO6s5VHMF6O0ImQ== 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=gS7efSc7G9sY3Ye3xyfdgMA3eC2KortZZAoZ8LQ96cY=; b=LQU5bhr5if0lish+VkbhnURJpUbKe0kZ0Mzn1eo1hHke27nDRQwfYU2FvmEJyL88jdERmkhpH+dBe58zf58f2zkmNV0rIHCPzzIbfoMj//V8eYJ8Ar7XP9kfgCDxwqmLaFknxSztXDyG5QCM1ai+C/woEYL5v+faqdjZ9qvWmXaf1mebfsPDU0JuT274nf9kfIUYH6vMbgxaUw9GAboT8OIxr+4N3VRL5bCdl/pCa+26cczQrzuqar4rEHHnxZRV/vTRbwdowSyBF6htkclmE2wCFoRbB0KAchiZmpwErGFLY91CPVlIiIDq0rvTUQnnfej0ch/GtbN+djJ4GrK08w== Received: from AM7EUR06FT055.eop-eur06.prod.protection.outlook.com (2a01:111:e400:fc36::48) by AM7EUR06HT027.eop-eur06.prod.protection.outlook.com (2a01:111:e400:fc36::473) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4087.27; Thu, 29 Apr 2021 23:59:36 +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; Thu, 29 Apr 2021 23:59:36 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:7376074A19C2F956AB880F003722E9A0F3E2A256075041AB456FAF370F020DA6; UpperCasedChecksum:0C6FBA5C12E143B9955BE01F558F2139495C7102A2270B7A5218FCDD5F1AD5D0; SizeAsReceived:7612; 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.027; Thu, 29 Apr 2021 23:59:36 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Fri, 30 Apr 2021 01:57:01 +0200 Message-ID: X-Mailer: git-send-email 2.27.0 In-Reply-To: References: X-TMN: [5b8LOIqbEpH0IMFX9T14qZYcUZCRpfy/] 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-29-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:35 +0000 X-MS-PublicTrafficType: Email X-IncomingHeaderCount: 48 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-Correlation-Id: 5f1a206a-de9c-4d9c-4a1e-08d90b6ad774 X-MS-Exchange-SLBlob-MailProps: gjx25WM8ZNU6XUx7q8EQ5McclV510mdNA5vT/fXqaCFWWg8dLxrqsvly2ofy1qPnI1xAoF9E6tcQ3/58sTqneSS0VoM94d3ITnA+walKerf0fQX6GvRBM1cFJfKWjmM2uErsDUHDc6mlqRgYI12GKbZdVd4Kfznw3RYJcXLbHBdd8N0iWVOleBKC+NmlkcZQnd6tBX0EtOhC8KoI/4+JCLyweRkNP64+BJhNR7D6xoC2PYXIlUgiuSPP2Gwvp4c9yxiwW6fAmnfhHFKZ22Pv3cJGoRcRfJmV0puqmwMtGvJaAG7EAfAtBoqs1CWiNhqLo8brPFrFQaNc/tBOLzKoVRE7xxGDSrOSrZJ8PrmjhwB+ZIxoRnKw323IWe6eO3HYhqy/OJRfgHafpw5yeR4HzeHHvUwID3ipSRd0oGAX4hJIDiNjvtQ5mciu7G5hfM5jCK02cL255M+S4rRzncr3QAL5DVgkTwdllpLKaTNHWw8jqAIt24/A/9+T7dcThezTDTDf6tLAba7eIrqiOWlLCDlBK2UpUVcIL73m7/k7GRQq0qQzdg8n8FCgfXAWU04X2gxSZcqLApbLzE1NJms76HlGhWSAMw/kZ/dVGa1AENxYSCCmoQHIyE3LZ4wxMSQRD2BbJrO+x38cLk9CnlmQNar8Cg8T2dw0eyublH/HoSJtVbPfmSTwk9iMLJkJQQcnnzZP9y0T+t0k4jesIwd4o1eOtajQtnQCXl7WS1kmbMQ= X-MS-TrafficTypeDiagnostic: AM7EUR06HT027: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: kUI9lYGNnTS/eHJJFQHQp45l/WaelWtoJ5l3ap/y51k19ythFhLA2+fFPc7TaehR7zlS5dehVC1brsZGrg2pl+aNCZfyHhGoITrZYu3FePur6DtvjX8yq8WFxJLmX7P8NBfUjwwRfTvx00VHzH469ZegD09yz5R8Vi1YQPBq0BBDmwYDRcPYLX3bcTkX4ccmQbnlU//O0kSaJ8hFPH6rNbYgMU2PqCyCCYPdKJgUdnMpALYak30+Vnfzcl83IMhL0zdYVp951ScSJV3RsiFiwXrPW45Iy4fm16i9hloDznkK/4RX6MTvnu6xR344Fvz0efTNQMWV/SJXRBTiP6NuWBnXT2HmiMq2Rbis3z8WxP9WE2B3p28AdEJbl+C4+PGS0YdqQZGzDim40kROyyryoQ== X-MS-Exchange-AntiSpam-MessageData: bJvQBE2hrQU4MC7bY3JOKKhAyMH2FlMWY5NMa8FTWk5hWi2/vqSSp3gfU2CqpvcZwZziTcphJuDXPmAtOm8RgxXEodrJpqAIPua+8W4JDr+8P7ou9s6jcuaiq6n09L9Ew985Otw8QCSpRh+2lDX/xg== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5f1a206a-de9c-4d9c-4a1e-08d90b6ad774 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Apr 2021 23:59:36.0646 (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: AM7EUR06HT027 Subject: [FFmpeg-devel] [PATCH 30/46] avcodec/r210enc: 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: 2foC4D+hxK7f 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/r210enc.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/libavcodec/r210enc.c b/libavcodec/r210enc.c index 89518bce29..b143f516c1 100644 --- a/libavcodec/r210enc.c +++ b/libavcodec/r210enc.c @@ -21,6 +21,7 @@ */ #include "avcodec.h" +#include "encode.h" #include "internal.h" #include "bytestream.h" @@ -46,7 +47,8 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt, uint8_t *srcr_line, *srcg_line, *srcb_line; uint8_t *dst; - if ((ret = ff_alloc_packet2(avctx, pkt, 4 * aligned_width * avctx->height, 0)) < 0) + ret = ff_get_encode_buffer(avctx, pkt, 4 * aligned_width * avctx->height, 0); + if (ret < 0) return ret; srcg_line = pic->data[0]; @@ -91,6 +93,7 @@ const AVCodec ff_r210_encoder = { .long_name = NULL_IF_CONFIG_SMALL("Uncompressed RGB 10-bit"), .type = AVMEDIA_TYPE_VIDEO, .id = AV_CODEC_ID_R210, + .capabilities = AV_CODEC_CAP_DR1, .init = encode_init, .encode2 = encode_frame, .pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_GBRP10, AV_PIX_FMT_NONE }, @@ -102,6 +105,7 @@ const AVCodec ff_r10k_encoder = { .long_name = NULL_IF_CONFIG_SMALL("AJA Kona 10-bit RGB Codec"), .type = AVMEDIA_TYPE_VIDEO, .id = AV_CODEC_ID_R10K, + .capabilities = AV_CODEC_CAP_DR1, .init = encode_init, .encode2 = encode_frame, .pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_GBRP10, AV_PIX_FMT_NONE }, @@ -113,6 +117,7 @@ const AVCodec ff_avrp_encoder = { .long_name = NULL_IF_CONFIG_SMALL("Avid 1:1 10-bit RGB Packer"), .type = AVMEDIA_TYPE_VIDEO, .id = AV_CODEC_ID_AVRP, + .capabilities = AV_CODEC_CAP_DR1, .init = encode_init, .encode2 = encode_frame, .pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_GBRP10, AV_PIX_FMT_NONE },