From patchwork Thu Apr 29 23:25: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: 27531 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a11:4023:0:0:0:0 with SMTP id ky35csp2058095pxb; Thu, 29 Apr 2021 17:58:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy2HIBHSmpRYuNP9LOGefAWMY+xM8JSlB+oRzggLpDhO9payVaJIG/8TPtCTB0D/unZG/6m X-Received: by 2002:a05:6402:138f:: with SMTP id b15mr2726468edv.121.1619744294042; Thu, 29 Apr 2021 17:58:14 -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 w13si162576edd.475.2021.04.29.17.58.08; Thu, 29 Apr 2021 17:58:14 -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=jJaZzR3z; 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 9482368A293; Fri, 30 Apr 2021 03:57:38 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR03-AM5-obe.outbound.protection.outlook.com (mail-oln040092070069.outbound.protection.outlook.com [40.92.70.69]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 2CA76680825 for ; Fri, 30 Apr 2021 03:57:32 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=esYY025SUVlSTBanxE5djB9pdkJKVNhYNwGtFXJdexEQsV1uNSW1pUs5D1kpT5lHIwwyOubGkBn9Rd7AJyFjjpJXH1d22H8qvcy+WeaNoWwVY6J6gVBtsaBOJGPtRLzI3jADetyETUv8bB6tewaTpfrWT0fkrv78BgxS3RfDIFlnz7ihXUCDF3XHJQFPKt38s7v5zpV1IiW6vbdWkYBpK08ODWtz6qeVbXy4qcGNd1oC6dbSCmY2l9zabz0Ha7FdOSPWBVfqgy5sebkc2LXJKH6uJ9WdY0P/zRnmw2Q2WLzuYUMVy3R2nLUfnmo1uLNuPFuMDpRgWZj8pSMKm5auFA== 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=Yd7QiO1WFAiqBML464ES+rt/M/HAz8p3j2Cb79iUTV0=; b=W57vLCaEinaH/rqUQYCqetK8iy1E/3IC0f7OSyERGk+Q/BbJuNOJU8JV+kQ2xS0Gyqxn26tP5FofNp3P1OuA8QYkZjAo6jOBUImkTA/kXrfrE3EXAcXOkM/jRzdGAoKYDlL5jLNS23LqED6rymmhbMsZEZAiP+EFio0wsJX4qmfbr16ltKAz8If6VpQZQmiRVaEWUGzBRwV0pL6At5ctIJqAnBA+tyo3dhtFlJBX30Ri9+8ryzutF3JEJReTL1Zct92arZjT3bkOu5/lw6u0LQFvTOx6BvRzBUfth0Fp87Dj2pPXTbB4P1GXnWWKqa0/xnInqHnAcqxZ8Cl71EcliQ== 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=Yd7QiO1WFAiqBML464ES+rt/M/HAz8p3j2Cb79iUTV0=; b=jJaZzR3zFmuRUMuBRI7BtDdqUxsPQtkTX3RAayHNCsmB8i0N5gyPhX3vhW2PUp7fBOAsnWeoCo+O9u0Q/tR1k/1NhY9obmre4uiL3GbQtcl+6jJeO+Pz1tCItK6XEolV2koyxIw5TbJEr6iMJW4ec885CB+OUztsthJJvlCpfgKG+IWd+Fs/9ZSRDKnw2qHVpIjpx0bAaffgBIoHU1+mTyNDRrgMoFzFYDNyfMF0xo5iHr5YY+gBOa++isYvV52/qAgN88z5qWXtwhX0lveyOCxfpk4y3n786Dabxu4Ju9+F23QbUPTQ1UqeM0ON/NOMffXU3b9v3BsxN6mtI/QXBQ== Received: from VE1EUR03FT038.eop-EUR03.prod.protection.outlook.com (2a01:111:e400:7e09::46) by VE1EUR03HT042.eop-EUR03.prod.protection.outlook.com (2a01:111:e400:7e09::478) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4065.21; Thu, 29 Apr 2021 23:26:06 +0000 Received: from HE1PR0301MB2154.eurprd03.prod.outlook.com (2a01:111:e400:7e09::46) by VE1EUR03FT038.mail.protection.outlook.com (2a01:111:e400:7e09::368) 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:26:06 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:A5F6F421C65F0C85875258D6A3660A6BCAE6785846DA95868EC648DD717669B1; UpperCasedChecksum:4024678F56D5CEF2A8FA325334564D90A3701C7DE13A706034B28E4E71A1E46B; SizeAsReceived:7400; Count:46 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:26:06 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Fri, 30 Apr 2021 01:25:09 +0200 Message-ID: X-Mailer: git-send-email 2.27.0 X-TMN: [m56xMnDzgZfkPbN7BdqpnTTB2oymsQJp] X-ClientProxiedBy: ZR0P278CA0038.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:1d::7) To HE1PR0301MB2154.eurprd03.prod.outlook.com (2603:10a6:3:2a::22) X-Microsoft-Original-Message-ID: <20210429232554.2066739-1-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from sblaptop.fritz.box (188.193.248.86) by ZR0P278CA0038.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:1d::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4087.25 via Frontend Transport; Thu, 29 Apr 2021 23:26:05 +0000 X-MS-PublicTrafficType: Email X-IncomingHeaderCount: 46 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-Correlation-Id: 2028e26a-e6c5-4868-66f3-08d90b662927 X-MS-Exchange-SLBlob-MailProps: ISIDp/2nRg3KXokOksxCiagcE7D5FxNrj1UKnJ2l3Qsmeg8JZsgK0thCVUDTy8oLB6/1QP4NZYes9xMnzYBmHCq33f02H2AiP4H6dR1ormjpPeOwYXwqvZmEEUTmUPbHApMXJ2oILTc28GtYGDtsvlBmAEsZROmMNlVbEdu8ttIetULGBgnDLTTD0/UkDPhFzlWy/hCix5VXqkrIixBUZfeNfqEQESsS8xWoL/Y7lxSOux4rF7n8OOPw1xKa8tovVCOHH8jUFN6wPNYQSePqC0OYLgx6d+FZ/BoTQYHoBJDQCI9hT0513JvuatT6JWV4MJDZyXH3/Vwpv2clihh0IHZ1aeTGDYhSujnmLyH2Az1H7B+qIdgh9hzuFaurXuhZ67JIaYaJB5U5ul2FzDTPFHBRYY3sFao3tOI49cuOM1C1PRPH0Zc9S9rjJxYKYfUwjqPVRi+Rqy+HFH7sPrOzL+cEAM70LGUIyBk1q3lj9Q8QQM+ZPnbmS6G/eqbpNGTmUrinKn5H/8JNPHDZNgfr92/R9+V346xZsjwXIQli/tot2dcAJkVfKh1tX2rCk66bP/GyyPIy0cfRQno6hx9JMgy0G4AfvxgDOKOvIj1/W90JV1pgWVlcGGxas1233yxKFcHu1YK1/mG2m/fwP8ezPddrrq2WbmrHuI2p8eCY+B5J3W1cjNSHKsN26kmVdTXfYwvVvZy57UY93QMDUks/kLMf/ujQ7feQ02mngou0ARy2oTClBkLZF8UP+kk8OA2l2JLpnKzTec2udw8xp4ZsCQDCn26cu8wzhRMoiIJ55spsXsRBF6/d3MXSn8bCNeERedzFpYCXBJWZMCep+jtv1TZgKXCMPIRG5lezstUJKV/Q19GeBPA4QDz32s6dw8HLYJ5xb4qzQfM= X-MS-TrafficTypeDiagnostic: VE1EUR03HT042: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: szfzCmpbjSFCD/O/lA3wjNlKWZfDQiFhO9xK8BfR1jACrxWOuIy51FLbxjNs8XSaqUJV9kLKR84J4bmowCvGv6yV4I+kccpYMkxBqpCQkDoet4kmZfbeHr8v238dh3bviIs7CiGLpA/U8ap+RLCjj6b7OI85w6qtVv3sSbwgy4OJrqzQvaMm7gDs9WgC1lNVfH03/5OZkfR1eOtTkBlBUD+eTImyKuxuxbmbXAwS8q2BEn6Y+10NIggHTZwCpnPln6Qbm7eBJY/arXtSl8yjAyxWZ5V4rkCVhLBDrU0/ojXSC8i2sZPXRn7pYxtBAt+Jhq/Js/YDRLlkB6gjefcH58kaLW2U8Vlx3Q+xfv3eFOTrTNTWehcrS9CtyOhI0MEv6U6O0iauo9lA8BhmVZZu2G3X6MLjb2MYnB7OUBPifUVZxPZ8QkO2xVMCEO5+24dnGezXnE0dXUp/1EhH5NHv0Muo9IXOADXsFZT2V/ZODGI= X-MS-Exchange-AntiSpam-MessageData: 3K4bCnn8uYTTVyC55Pq0FZxCJeJZPDnLXvj6tubAuaEQwmRc8FcuVuecOqE+ZmA9LSK07/H5XubTXL1T+ynu0vmCW1kZvAeCB/NwCabNUR3/0TBYmnq9kD1iUpUBBHPOFSSn8+XKy+PwS2LqDPmEmw== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2028e26a-e6c5-4868-66f3-08d90b662927 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Apr 2021 23:26:06.5159 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-AuthSource: VE1EUR03FT038.eop-EUR03.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: VE1EUR03HT042 Subject: [FFmpeg-devel] [PATCH 01/46] avcodec/a64multienc: Avoid intermediate buffer 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: 0xXZLHJon3BB Signed-off-by: Andreas Rheinhardt --- This patchset is the first batch of patches to implement support for user-supplied buffers in encoders; those who can't wait can already look here for the second part dealing with encoders with external libs: https://github.com/mkver/FFmpeg/commits/ff_alloc_packet2 This patchset supersedes https://ffmpeg.org/pipermail/ffmpeg-devel/2021-April/279571.html libavcodec/a64multienc.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/libavcodec/a64multienc.c b/libavcodec/a64multienc.c index 9dc859b271..1b52631193 100644 --- a/libavcodec/a64multienc.c +++ b/libavcodec/a64multienc.c @@ -50,7 +50,6 @@ typedef struct A64Context { int *mc_charmap; int *mc_best_cb; int mc_luma_vals[5]; - uint8_t *mc_charset; uint8_t *mc_colram; uint8_t *mc_palette; int mc_pal_size; @@ -197,7 +196,6 @@ static av_cold int a64multi_close_encoder(AVCodecContext *avctx) A64Context *c = avctx->priv_data; av_freep(&c->mc_meta_charset); av_freep(&c->mc_best_cb); - av_freep(&c->mc_charset); av_freep(&c->mc_charmap); av_freep(&c->mc_colram); return 0; @@ -231,8 +229,7 @@ static av_cold int a64multi_encode_init(AVCodecContext *avctx) if (!(c->mc_meta_charset = av_mallocz_array(c->mc_lifetime, 32000 * sizeof(int))) || !(c->mc_best_cb = av_malloc(CHARSET_CHARS * 32 * sizeof(int))) || !(c->mc_charmap = av_mallocz_array(c->mc_lifetime, 1000 * sizeof(int))) || - !(c->mc_colram = av_mallocz(CHARSET_CHARS * sizeof(uint8_t))) || - !(c->mc_charset = av_malloc(0x800 * (INTERLACED+1) * sizeof(uint8_t)))) { + !(c->mc_colram = av_mallocz(CHARSET_CHARS * sizeof(uint8_t)))) { av_log(avctx, AV_LOG_ERROR, "Failed to allocate buffer memory.\n"); return AVERROR(ENOMEM); } @@ -284,7 +281,6 @@ static int a64multi_encode_frame(AVCodecContext *avctx, AVPacket *pkt, int *charmap = c->mc_charmap; uint8_t *colram = c->mc_colram; - uint8_t *charset = c->mc_charset; int *meta = c->mc_meta_charset; int *best_cb = c->mc_best_cb; @@ -346,10 +342,7 @@ static int a64multi_encode_frame(AVCodecContext *avctx, AVPacket *pkt, return ret; /* create colorram map and a c64 readable charset */ - render_charset(avctx, charset, colram); - - /* copy charset to buf */ - memcpy(buf, charset, charset_size); + render_charset(avctx, buf, colram); /* advance pointers */ buf += charset_size; From patchwork Thu Apr 29 23:56:33 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 27493 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a11:4023:0:0:0:0 with SMTP id ky35csp2014249pxb; Thu, 29 Apr 2021 16:57:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy5C6BJFgjE0uVfmfg5ROfVW+c3Qu1eSimXajDRMwzR6xpfW8FD8+UnMT1+mz6eq5Jl9+Gp X-Received: by 2002:a17:906:f283:: with SMTP id gu3mr1063281ejb.91.1619740661482; Thu, 29 Apr 2021 16:57:41 -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 y11si48518edv.309.2021.04.29.16.57.40; Thu, 29 Apr 2021 16:57:41 -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="WIJWm/U6"; 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 CF7CF6897BB; Fri, 30 Apr 2021 02:57:36 +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-am7eur06olkn2017.outbound.protection.outlook.com [40.92.16.17]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 4F9B4688138 for ; Fri, 30 Apr 2021 02:57:30 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FZefQ+pDYTsoVH/y62IeBuonT0lwqHfA0o6s8tyfurSCTUGpUJ+DX+Jsnv9IMLFfyO+pm55rRrfmgZxg6PSvkJnv819Fo8BcwACUx3Jv/gYvNMJRTtUYbuexM9avljdn05QFLQzsM1vi/JMfWXS7Qzxt72fyEucyhcOxIISZt+iR/ALr05fabGFW8lmcAAblsqbFOwiMNmzEcDNNvg/WdGSFyErNJ9s9iTHV6Oo/FXeyG5W04sQQTKDqpPaI5hrerDsZJ1FZq5o8lalMvUJYqhteGYJb+xYOw7BlXedsq43HcKiEbB9aaGDdfHqJhww8IAGgLXvSd4LoKqwhp2eTtw== 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=djRhsT9gfhlE4TyuSubZBBqJVnE3/9eXKDOWGf/5wFA=; b=I0uPkQsrVAcPB87CsiGV8ODPQ5Rv3wgvBP08AwN2c8HBK9vY7SGU/doXX2i2HwNic3hETckPIZ8YQ8IgGQ736Jl3f1p1BnAS9DgpfmzNJtgUwAW6TD1dKF80Aw3rSQSn5LJ9ECcPK9tdhKZJsKLcj5BFbQielNtTiO8O9V4qAPKR7ENlTrHP+ZvQ6pS/altkoBmZFz/fy83femVsy2UC5qkH1ZtWJCMx14OcEDcE1dYG0mTc7b7rf4ZHDur5D0UDEkr0HnZub7K6M5iQt1CRXFUCvs2UpanIPNCi+PGBAqCJIE+vuH4d3KQJzzw/MW4HNeKtd3TAuKkJLOjZQFGuYg== 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=djRhsT9gfhlE4TyuSubZBBqJVnE3/9eXKDOWGf/5wFA=; b=WIJWm/U6AwU+2M9Ucn1pWJbm/AEQHY2BsDZ47pwmNIppHOoNz8baCnLLjYC0ic3sKm65F/9tPFoJ2l7RqW124ffjhogCnBPCviSIUZ+X/uMn8moAhI/vPS9pAxX4sknsCzaQ0ErWikm9Oqow47Gt8XSjkFQhFsnruXvNK2J8blk3eO2NqRCXdzNUhPrnLU5SWWRu+jOvKgWMp0wy7dFAJFYMOK+XywcpZ7CSIqioUBnHQUTmPzJLWs0mebTEA64+2dQzsglvJ6VEO36BOqY8xeGiy8WLIUPhciwTmB4AWoZ/rCTIyOJUQaGlTg8SRoZO1q2Ivv+ombf7+GeKnKSu9A== Received: from AM7EUR06FT005.eop-eur06.prod.protection.outlook.com (2a01:111:e400:fc36::52) by AM7EUR06HT127.eop-eur06.prod.protection.outlook.com (2a01:111:e400:fc36::122) 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:57:28 +0000 Received: from HE1PR0301MB2154.eurprd03.prod.outlook.com (2a01:111:e400:fc36::4c) by AM7EUR06FT005.mail.protection.outlook.com (2a01:111:e400:fc36::397) 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:57:28 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:A9401562FC23CD75403A05AF0460EA54257A366FF5D62B2F9DC48F3B0C5BE327; UpperCasedChecksum:B7E9B88176B5CEA7574BADCF43AF69209A6E9572AE3D1A2C34343EBC64E4D2E0; SizeAsReceived:7617; 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:57:28 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Fri, 30 Apr 2021 01:56:33 +0200 Message-ID: X-Mailer: git-send-email 2.27.0 In-Reply-To: References: X-TMN: [H933JXwfNklZ6f99RNrFs2CFnkkZx5J7] 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-1-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:57:27 +0000 X-MS-PublicTrafficType: Email X-IncomingHeaderCount: 48 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-Correlation-Id: f1e54211-0a07-45dd-8bd2-08d90b6a8b26 X-MS-Exchange-SLBlob-MailProps: +LiGfBxqLEtm0bFsxt0Y8BBBVgX1iNhUX+RTrTawC4xXHPgLULGlColmtpBLPlCton5Ex9Ws14qwsT7kp5F5saZp1arQfSOEFK22hTrExyiCjbrtnRHEw4TndHKt+K81yJb4q80uJ/ZWJTZfIk7iOFU54NdCC5VgqGEJZZ/01PPEiihpEnSt5DC69Z1DmcBDIyZgB7wlBGfAWkPR726jwzOWxl/X4rmNQ+A6hJSjpQHwcaZU9iHPKkjjyws6kRRCDey95kK5wRjSVBMgvbcgFqkLgl3SU04JLY8S+qa7Td3DHCMaCDLFRsuPuNlS/FlPY+vCnW8N7ahr22Y7Y/wNlUHA5xddKPFTfj9XGdaSqSxdTfB45ui/SqG4AaT//XCEvHsgfGw8NIFNt7pWenzoK9d2e865RK7mLTc43RtY5OugBOEW9nvi8K2mVbFnzn395QYl0Kk7UcXI3JyaMeBuCX3YV8BlUvKIiOStrfbzfEz4Ih68ic2MN64QDmG9V8MCczFmXpXdd3HI7fDPnNxOWRafjg/WRISvhTphPlum73trAH+9nNILNO19+VILOzKTDlk2vmKwdW3lR6AINpLW+0F2BXEf6TczKpvsXQgiBUGDbluqOKHsemO6sah9IDLsYxUluKulzFIFqpGPAN6/JfjGonUOUnrnohKDjcuLPB2Gt1gAWmYRamMyHo9clBBrnMIGkp+oCfBACL6ucm+S6DYVJOe9QM4JAXD/sHqByFh3AJsp/P9J7M3tpOd7WwhF5IjRVdgMlexpA9H0qxoGM4ElnPkQ+SQm X-MS-TrafficTypeDiagnostic: AM7EUR06HT127: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: /z/4RUaNmDZxcn3gUmHdrAd6WPW1x1cERZa+Refmbj2XVrFHHXta1zC6Jn/hxfVmk6GQUAPegbalZNNbrChAliJhjBXVzivNXOW4jhlnn1wQpsc77WeKNmqlysrdgtMx7suGY0kF66/pORTIYQel6/Y+bPgSlL6C8bjr9OquLutmKt9OQfLwOMAqxzGm33Czb3tXpwkZwyxO7lOLQFZ8pVhjLYrInt2fICbW7BioL0PkBzkg+1rwGzxarv3ujbAB86UVGv4WkSLYlCOA7kgxTRHQY5Uqdkp56HJV6V/GoeVq9+peHp9u0YoBFE9xRaN+ac9XbZqS0DO+PGsMrEoNER2KyVBj/jO0km48FZMTkGhqeFQbQkTtYYd2EspA2WAgrwSe34xyi9LwYWzDf5huOQ== X-MS-Exchange-AntiSpam-MessageData: p6ZOSTalQpkwE4pr9uyXHixsUacRYCLXBVqpR8II7N945efgm4v+ruXtD4nUwmkfWwMtA/AX7jTEyGNyRtcdmJGgkZOBQlmlsPy8otqvgSqThnb+KiuRWUZMtAnJOkC/V/EVZ7rDuaRgW1HWDfL0tg== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: f1e54211-0a07-45dd-8bd2-08d90b6a8b26 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Apr 2021 23:57:28.4781 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-AuthSource: AM7EUR06FT005.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: AM7EUR06HT127 Subject: [FFmpeg-devel] [PATCH 02/46] avcodec/a64multienc: Don't modify AVCodecContext.global_quality 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: jkJbSHrVpkyR According to the doxy, this field is set by the user. Signed-off-by: Andreas Rheinhardt --- libavcodec/a64multienc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/a64multienc.c b/libavcodec/a64multienc.c index 1b52631193..ad2500e41a 100644 --- a/libavcodec/a64multienc.c +++ b/libavcodec/a64multienc.c @@ -210,7 +210,7 @@ static av_cold int a64multi_encode_init(AVCodecContext *avctx) if (avctx->global_quality < 1) { c->mc_lifetime = 4; } else { - c->mc_lifetime = avctx->global_quality /= FF_QP2LAMBDA; + c->mc_lifetime = avctx->global_quality / FF_QP2LAMBDA; } av_log(avctx, AV_LOG_INFO, "charset lifetime set to %d frame(s)\n", c->mc_lifetime); From patchwork Thu Apr 29 23:56:34 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 27487 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a11:4023:0:0:0:0 with SMTP id ky35csp2014385pxb; Thu, 29 Apr 2021 16:57:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwgHo1/HzWID/n4bC5JaA2CwNzn0kueuFISb1+ZzyNKL0wub+QlPx7UrBZlmnOgXBfSIvr9 X-Received: by 2002:a17:907:3e27:: with SMTP id hp39mr997163ejc.373.1619740675780; Thu, 29 Apr 2021 16:57:55 -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 ka21si1432652ejc.323.2021.04.29.16.57.52; Thu, 29 Apr 2021 16:57:55 -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="ZdYso3X/"; 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 180FF689A17; Fri, 30 Apr 2021 02:57:46 +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-am7eur06olkn2075.outbound.protection.outlook.com [40.92.16.75]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id A6D506883B3 for ; Fri, 30 Apr 2021 02:57:38 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=eLDrlIdWjEzdeU0jzqmZF+aSldRlfhBs8yecewHfAdUUMXTZ2EyHFB4SsrY7Kmicn2vh9BZhuCkRhbpDHuXgIM0KbtKO+QESfAzNjlco58W9gdQBR85YtvtQjiMA5S4JJVAwV1TTmtzwnVM6oGJWSB55dOdQm0hRnJE2OOpi4I8Yd12/D+6zPxw55VOGlA7MDgmJes6llFKZyfOmE0Eb4PqOEhLldesOBPAnEan0bV9Ye5/qiAVVoJEPvoa1yKyaRXh+PeNVkwis8xpAMcta9/x1T9U4623PdVfh0XS5R6ip6FRMt9jA+q8NRS+sVARUhabiZrbdI+VNnpGLnot6tg== 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=VcgxLjiHzJdt8xycvf+AYpPZmT6ytBQtDsEInX+jFBg=; b=iPY91M4KT89WH6MNoatO0JwlTffuKeY+U0eX0KaDZiz8X9jsP377krJMHV1kVvwCeNHUvYMXZXnXALg6NX2VlOaqu5saK3aQTqxg7CXL03BzFH1ixnxGtFnuMa4pxOPlzWjObi596Fg3Q2kXFCbCUisUo//CBgbOX+lTlmM1g2WUfUkHLkniS/dl/kpFGP+QTr2rNZFjbOEZlAN5aK0uMvdR66fG+zWdYvXdoOxNyTI5t8y7fZcmTs4wThqY5ZZgGZJH89GEbXf6BRyX2ZqCrYa9hpU8IlCSZ/yeMwG54ZRfKiNqFVwr97bOJ3qPnWDZPqxsepahalMQOx9UyJyEvQ== 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=VcgxLjiHzJdt8xycvf+AYpPZmT6ytBQtDsEInX+jFBg=; b=ZdYso3X/5ExkOUwJP4xFWpaKN1Ii8BLSNzrNbKSaHGe96/LA2yGNrzJqErWaGTj2ldnAl51b/c45EU9vCXQLuk8KgjMXUT3wz+NmQ+gcNxm4thTLLr5dBsk2h0Fq+2C6NrhNLPwmVbb8HfworKPqDyrqs7MlVw+DtPvL+sOcDsTzvSbwU4N4ZaqlJ1t54Be4k6hf9TQZGg3UCEkGwcDYRO5dLyaY0dXYab6y5xT89VUBhc//RGjf5wT3z7K6qYLut3Xb3Ib50uNpBoa3VDvyA7ZuuN3io9texvEUCp5vsjnrLTuHeFBWAP1ZsEhshkniKasAy4Z6Sks5+DlsqceSLw== Received: from AM7EUR06FT005.eop-eur06.prod.protection.outlook.com (2a01:111:e400:fc36::45) by AM7EUR06HT210.eop-eur06.prod.protection.outlook.com (2a01:111:e400:fc36::476) 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:57:37 +0000 Received: from HE1PR0301MB2154.eurprd03.prod.outlook.com (2a01:111:e400:fc36::4c) by AM7EUR06FT005.mail.protection.outlook.com (2a01:111:e400:fc36::397) 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:57:37 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:4CE76DBAEE7468A3D97CB2A627EA9B653250D22D217F4BD49E7D146CC3286526; UpperCasedChecksum:EC8BBE531A4233C0981F5F461527215F808176D0F12C08EA9DBFB7B7DC2D2914; SizeAsReceived:7616; 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:57:37 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Fri, 30 Apr 2021 01:56:34 +0200 Message-ID: X-Mailer: git-send-email 2.27.0 In-Reply-To: References: X-TMN: [OsuCviTDwcmDJZLXtJ5eJEAPhb+fvNHW] 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-2-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:57:36 +0000 X-MS-PublicTrafficType: Email X-IncomingHeaderCount: 48 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-Correlation-Id: f9b35d79-6a21-4997-f7f4-08d90b6a90b2 X-MS-Exchange-SLBlob-MailProps: S/btQ8cKWiQnJqnaHo6w7XTEhYoMxTOU3BddjpLSyRvWaHQ+5gYDMFpFzpnJka0SSyXbIyYYIVs6/tbBVKvSbWS1L/vaVUuIU5Y5Zmfdn92ZUfSL6WNf1H+p4QyB5KyWetR9oDxhJMJ4bEpI1C2CQJT1H3AG2p37zGN4LadpvtpB+a1gPmceDogWqRlvIVkighYE+GaBJs9qSDkUR61Qg6DG8shtzRUOkYvXC/o9V04YBRMs5ml6O6kMGbE9c/Eg5J6euBlCcMfpaUtByZ2lZqq9gbLlJV3DP6lfAh4jo12IKPbvIryB4e84XtOYq39p8QEKF3HH46q/iV4ciaDd/tphMPpmo1pMbjS1B1qLibYzOKegQ7oO549R8rnWHaaD+pBxlydh7hjHAg6m+eDVPI1SbvfBd39zqfFVbIphnSH02qvuMHiUCKjBFBVMi32GHs8AMPcBYdbKyvllJ1zKRayHawrHKmz9bJJbnkDgV+yN3QFFrblBDu/znsF4MxJu+/K2ho03XvX+QIcar4UX+YyB80RyPEa9na2JpGVELofB/51dCOdseE1XMd3YDTvzThcb2bDwpdse0a7+0F0e6w1G0woZGbG17c/OUr8XBA4bw7osmzNuSFhp4/vGfDAZEMC8CCvjtJbvV6nAX7+QkrYDoUqGgftbLNG2eV073N62bD4/7iXwU4kWXnthpxmXIjegGCJ7XBGNwM9oTX65wXlQP7NxW2pYhN1hGv+98ikg5895h3K8bbaaIdHzjR2UXfF4ifuHArE= X-MS-TrafficTypeDiagnostic: AM7EUR06HT210: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Yolxquz5R7/WaLv1F4kAq+nTF5gmA301v42Pc3RJy5g3mpEms0KuinTP2KlLzA1RFMIpy5ziPa6ZHJPrIbm7ShqzotAfp4o16Sz5Hsf8IUB7gqzUSUTQpSvUPVLDya3WOmJ15r5Zvx4a5wQbIYPdKxYAVVxzGHwU29Hb5D+fvmMdJEtMldrkVGLfhfW2SokpJ/YCfIY9ZkQWIbiIGRdyjNdbA6st5tfUtIdvkNth0yG6ZbgZxrVfSftscWfd9LXpguIaDSJ9zrJDP4Kmp5rhYgX+1wBPDmgH2NA6KuoIMLRqXu6cp+OjZYrLiZWy3MpaB2TayumnrW7X7XCKaeFCA0g8IHMZ2K0Seb1ps0qE8BAqxZmV4heFNzHksLfBYSAukh7lISpolwxiiIhDVFSJPA== X-MS-Exchange-AntiSpam-MessageData: VCjPVHpky3+qsHCplNI5sM0cU4w2KDjdLtZXrYxaqhzzceypo6BSkrl8ISKkpMxG2PkTrIin6hccys2gFPJViuMNMNtFUpQWYWOJxW8v+a/c05VRHTFZcYjlYDslhSTCjQRpr0LHvV4ouGFI9jQDpw== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: f9b35d79-6a21-4997-f7f4-08d90b6a90b2 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Apr 2021 23:57:37.3421 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-AuthSource: AM7EUR06FT005.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: AM7EUR06HT210 Subject: [FFmpeg-devel] [PATCH 03/46] avcodec/a64multienc: 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: S9stdwizy9wv 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/a64multienc.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/libavcodec/a64multienc.c b/libavcodec/a64multienc.c index ad2500e41a..e2dd85b756 100644 --- a/libavcodec/a64multienc.c +++ b/libavcodec/a64multienc.c @@ -27,6 +27,7 @@ #include "a64colors.h" #include "a64tables.h" #include "elbg.h" +#include "encode.h" #include "internal.h" #include "libavutil/avassert.h" #include "libavutil/common.h" @@ -327,7 +328,7 @@ static int a64multi_encode_frame(AVCodecContext *avctx, AVPacket *pkt, /* any frames to encode? */ if (c->mc_lifetime) { int alloc_size = charset_size + c->mc_lifetime*(screen_size + colram_size); - if ((ret = ff_alloc_packet2(avctx, pkt, alloc_size, 0)) < 0) + if ((ret = ff_get_encode_buffer(avctx, pkt, alloc_size, 0)) < 0) return ret; buf = pkt->data; @@ -383,8 +384,7 @@ static int a64multi_encode_frame(AVCodecContext *avctx, AVPacket *pkt, pkt->pts = pkt->dts = c->next_pts; c->next_pts = AV_NOPTS_VALUE; - av_assert0(pkt->size >= req_size); - pkt->size = req_size; + av_assert0(pkt->size == req_size); pkt->flags |= AV_PKT_FLAG_KEY; *got_packet = !!req_size; } @@ -397,12 +397,12 @@ const AVCodec ff_a64multi_encoder = { .long_name = NULL_IF_CONFIG_SMALL("Multicolor charset for Commodore 64"), .type = AVMEDIA_TYPE_VIDEO, .id = AV_CODEC_ID_A64_MULTI, + .capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY, .priv_data_size = sizeof(A64Context), .init = a64multi_encode_init, .encode2 = a64multi_encode_frame, .close = a64multi_close_encoder, .pix_fmts = (const enum AVPixelFormat[]) {AV_PIX_FMT_GRAY8, AV_PIX_FMT_NONE}, - .capabilities = AV_CODEC_CAP_DELAY, .caps_internal = FF_CODEC_CAP_INIT_CLEANUP | FF_CODEC_CAP_INIT_THREADSAFE, }; #endif @@ -412,12 +412,12 @@ const AVCodec ff_a64multi5_encoder = { .long_name = NULL_IF_CONFIG_SMALL("Multicolor charset for Commodore 64, extended with 5th color (colram)"), .type = AVMEDIA_TYPE_VIDEO, .id = AV_CODEC_ID_A64_MULTI5, + .capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY, .priv_data_size = sizeof(A64Context), .init = a64multi_encode_init, .encode2 = a64multi_encode_frame, .close = a64multi_close_encoder, .pix_fmts = (const enum AVPixelFormat[]) {AV_PIX_FMT_GRAY8, AV_PIX_FMT_NONE}, - .capabilities = AV_CODEC_CAP_DELAY, .caps_internal = FF_CODEC_CAP_INIT_CLEANUP | FF_CODEC_CAP_INIT_THREADSAFE, }; #endif From patchwork Thu Apr 29 23:56:35 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 27491 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a11:4023:0:0:0:0 with SMTP id ky35csp2014693pxb; Thu, 29 Apr 2021 16:58:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwsSPTqIMDul1IgttM3BlZTbFOZG3xQKjsRKscVOPX7lMS5CdsnXOoFnjZiaKi9yMHSBzRo X-Received: by 2002:a17:906:26d4:: with SMTP id u20mr1163472ejc.114.1619740702009; Thu, 29 Apr 2021 16:58:22 -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 y24si75387edt.176.2021.04.29.16.58.21; Thu, 29 Apr 2021 16:58:22 -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=KT4MBLIX; 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 934A4689D92; Fri, 30 Apr 2021 02:58:02 +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-am7eur06olkn2066.outbound.protection.outlook.com [40.92.16.66]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id EFA10689EC9 for ; Fri, 30 Apr 2021 02:57:54 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=A4OmkwWaIHTaXuLdiM938m6aJ8NxrKKaO75ziWy30hgSizPLshtKmEyoGxaN2ROsB0TPiRH0e5a91TuPQlEAGQCa108I2ORniV4X4rHJ3sj6gSfAAGwVVmjuGLQiUJBCOspqUNJzymREZTjd6ojs2HtUxeZ6m5ZWrKaYoSKC0b4yWVmJtLnnyotjTY2kz+7kHysYGa+7qTG5Z3zA4vWAAO8AR3SO6CNmSSP8F4FEtfvBQGYQArtWhTcwKGTcDJV5Rdad82s9ZOxyVPcwCsBiZLJXs9Dp+Txs65OCwGrvIkXrSYzC6O8Puc0bjaLWv/9i5SuTcmQUv0v/BjXZMdQR4w== 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=6KMIb4jQw9GH3pk3l1PZddj7Sjzh+tRAH0vD9hlzP6o=; b=YT/dzGMW3HhQzfzv+t8Ix+kTG1Q+mDzS4GwcnbWl4QEiduwPUfSCt1d++0o1+l897cXajKNuoOQ55Ppe2FJtLSXc6alyR4EGPzFC6wJJl1SF/KGC5RFoq8aspV2Fxx6oGlzNdbDHjk/ZfMUbcGkYy6+fO57TXhBwJp9MaOpeO8DeM+JvjtwJKVRv4zZFDEGcpn6r0DZEECA71llzUtkGbcGL/Um6Omz9pZK04l7W7ar+2lZTA8tSCmYa55nWls6Xqy58vBNsLF9t1REAGZMoXP+czrLm3Ovl2oYjplrbwzUVhDjHK5MA8iFuyvT3QrR6fqLzR98LbwICcAksAIfAig== 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=6KMIb4jQw9GH3pk3l1PZddj7Sjzh+tRAH0vD9hlzP6o=; b=KT4MBLIXOv84XcM2xRHNViviw98PAmG3Ajqjaz8Blvl4dbqx2MYN4goJ+vILJBPvKQW+rQn3heNj6ZOICKyGvD7oSAW+2Sejz8RGT+xAIpttxA192yWgx7+8TxlB7Vj1ewyqi+vBIK/B1LT0Iv1tbiiobw4tmGAxmgqMWo1QQZ4Ot8/CifuS3gasQs7dsYriPAG0+BmBA2wktIoPePCViH85nDNGmDU6NyVNcSX6aHVTcLVxZtYGTDtYkd0JqSs03HOISIce+tHvQzQtcWVVGyKk3BWo8HwGboUiY/3gluHoeKc/lKUzChl/8+wSWEfopfLG9EGm2M9xNMoNBTT58w== Received: from AM7EUR06FT005.eop-eur06.prod.protection.outlook.com (2a01:111:e400:fc36::47) by AM7EUR06HT123.eop-eur06.prod.protection.outlook.com (2a01:111:e400:fc36::506) 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:57:54 +0000 Received: from HE1PR0301MB2154.eurprd03.prod.outlook.com (2a01:111:e400:fc36::4c) by AM7EUR06FT005.mail.protection.outlook.com (2a01:111:e400:fc36::397) 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:57:54 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:A3924C450806AD841C7ED87654003A54CB5D775511FE6DA6931B2809AC0ACBE7; UpperCasedChecksum:67B674F0D58F2C2054B23517995F2CDC334103F212E1656C11B5BD2893833B33; SizeAsReceived:7607; 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:57:54 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Fri, 30 Apr 2021 01:56:35 +0200 Message-ID: X-Mailer: git-send-email 2.27.0 In-Reply-To: References: X-TMN: [ru3L9NhfJx7H+A8WzdVb6XqjMFJl1f8Q] 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-3-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:57:53 +0000 X-MS-PublicTrafficType: Email X-IncomingHeaderCount: 48 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-Correlation-Id: afefdb78-4be0-48d0-c172-08d90b6a9a9c X-MS-Exchange-SLBlob-MailProps: S/btQ8cKWiQnJqnaHo6w7XTEhYoMxTOUhz8NJb6DXXqkCtKTKWWCaZCnAyrsjFE6KQAijnueXP0hg1HGlol+MSV9D37NWEakCvQnnvmELvNmmBcm7b3H7sa9io9isYVQu3TE9QTTfU72Dvfa2cWcJIxfOcX4SfSJ+Ggl+QjbxYLfAjoalvCUZm8jSrPhCr0RrjD9ZOxCLTsTXbHVleUUalVVizJU0gRFpuETH44ALK/spbJiPA67yNJd0ylrCG/QQnL62IDmDamLCa894MvblgJbAzy5WFpVAZ1wVV/9f4OjGB7Awsm5dnOPowUqspFjrOofcnqJWig4OaUEfth8IL8oX9FQij51FluJvV0qGrHjJbO57wH2h5AyUqizLzaFrSBolGtzIjpoXkDWm770AmmlUXG52emPGBWxtvzyza+4wpriqPL3LvTTfeoRGk0uC32Nr0MLD0dzcfpkceo6GPsukN/Cfp7OKt2WqC4rYZ+/2FPMZ9aD8Tz+ol2ghPOL2GY2LwGPHYLsVzrFbOn03we/S0UMWOv7TkV/Wi5MSqXZzZVfHsZ86D9wDvkQ1/s4uN8KahzEwRlMf0QhgnD8sUQKzsekQn8H2TstwUTveYZTS+lY3SBFV8i2f6eh7RhZRbH1i1EKCv0p+YiGMB8vD3GORBtdRS7T6Wo8A9194TZ5jwXAlNH0tZDqdE+lCnbVgvflRd825HyD+nLF7VLyGoqC5iyLqmrab1oT2YjOkVO5IMGMgRSfZ9xgcmGTwDi2pggzLKZ8clA= X-MS-TrafficTypeDiagnostic: AM7EUR06HT123: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: NUPMNRI89r/3//QY+534KeQp5h9XyWs20zcYneOMFzebp3yIPUTMpYwZtobZBTKGErDFob4eP9VJ6TtaLrXktSApNSbMdxY+ffNLlix1iME4aRzTpNSzf5zq3uBvQM2IIF6F2ivrrUdRrrhI0QCRujuc5wMFt+FEx0WKf7WZClsm5odMXzHS/ZDvB3c45DTj1pkSDs0eCslSg1sG4Lzwg2NGeW76qBbNS6jlgB4XKL/N4KKU+SqDBeBzlUlDeBX6mhRsBjCV0TN8nZAMAUNrs18+DukWKvhnvEGDgOhN5olqlb/kA2CxWXMARj4YKV6GJO8D6geH1Ezby0smlmULf7EFVjaVKGDxNUr1FtynN7ajvjSb5wVBNNXOUE8Wsbjjk0FEfDZwttIIVtcx1CnSPg== X-MS-Exchange-AntiSpam-MessageData: Ov/YcX6nyxhrta6Nw12m9eAjpkVnz0H3TVg1Kjg4jF5fCm0GuJ3MiE3fDlEMoIDLGYPXzgCsVVXzpCnVnbsycX9cWjWN/1Bl9dCrfwdYfhKXhmKzrjtIJO3RTzdjRoa0oDuzPDTVymJCTSiu+qFOQw== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: afefdb78-4be0-48d0-c172-08d90b6a9a9c X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Apr 2021 23:57:53.9888 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-AuthSource: AM7EUR06FT005.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: AM7EUR06HT123 Subject: [FFmpeg-devel] [PATCH 04/46] avcodec/adpcmenc: Avoid copying packet data, allow direct rendering 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: gstLVoiBSvwT When the packet size is known in advance like here, one can avoid an intermediate buffer for the packet data; and one can also use user-supplied buffers. Signed-off-by: Andreas Rheinhardt --- libavcodec/adpcmenc.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libavcodec/adpcmenc.c b/libavcodec/adpcmenc.c index 1c62ca5a83..2b5a606699 100644 --- a/libavcodec/adpcmenc.c +++ b/libavcodec/adpcmenc.c @@ -29,6 +29,7 @@ #include "bytestream.h" #include "adpcm.h" #include "adpcm_data.h" +#include "encode.h" #include "internal.h" /** @@ -605,7 +606,7 @@ static int adpcm_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, pkt_size = (frame->nb_samples * avctx->channels) / 2; else pkt_size = avctx->block_align; - if ((ret = ff_alloc_packet2(avctx, avpkt, pkt_size, 0)) < 0) + if ((ret = ff_get_encode_buffer(avctx, avpkt, pkt_size, 0)) < 0) return ret; dst = avpkt->data; @@ -960,7 +961,6 @@ static int adpcm_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, return AVERROR(EINVAL); } - avpkt->size = pkt_size; *got_packet_ptr = 1; return 0; } @@ -1005,7 +1005,7 @@ const AVCodec ff_ ## name_ ## _encoder = { \ .encode2 = adpcm_encode_frame, \ .close = adpcm_encode_close, \ .sample_fmts = sample_fmts_, \ - .capabilities = capabilities_, \ + .capabilities = capabilities_ | AV_CODEC_CAP_DR1, \ .caps_internal = FF_CODEC_CAP_INIT_CLEANUP | FF_CODEC_CAP_INIT_THREADSAFE, \ .priv_class = &name_ ## _encoder_class, \ } From patchwork Thu Apr 29 23:56:36 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 27492 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a11:4023:0:0:0:0 with SMTP id ky35csp2014479pxb; Thu, 29 Apr 2021 16:58:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwX5aNduNGmW28Ssoj2qa1dUD427j3RmEUgh/iHUkXkjoPOQAEyMu6eANqOno8nUp87hRCK X-Received: by 2002:a17:906:2557:: with SMTP id j23mr1084688ejb.153.1619740683342; Thu, 29 Apr 2021 16:58: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 ca23si67075edb.279.2021.04.29.16.58.03; Thu, 29 Apr 2021 16:58: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=gnL4mszB; 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 5C76F689E05; Fri, 30 Apr 2021 02:57:59 +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-am7eur06olkn2071.outbound.protection.outlook.com [40.92.16.71]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 27CCE689829 for ; Fri, 30 Apr 2021 02:57:57 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=OQIUv8kvHHzQJV+O9kZVBl6IU8UA2iQGzumb34GuJj3hOirEDqpSSUJXciwA1gYSjKOHgzakMb1IKPupAlSrJPssccX6Gx6fBnOd5omEX3iOqUxCBV7n0mdMKw2SOpADh8wmRxlYw7T/r+aVMRlbE6nfpR8AUL0oiebwwI+5cTlPl3D3yfqhraTJrMqjrzJAfg2UEp5KL0spCun55c5tpqSliGRsi3M3DHWZB05ZPhPEknW/6FO5KFBPHw9HeGxwHXCY5JGfloB7k9Zl9YTl3SsFD4jTBdsrg56ux8REhVE+d3G1jp4FPJvkoKUhAAZRsFqZV+O9sosOEVMOD7xRvg== 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=aTT/kwdkByFCua9fB9KNCrNwSlcOk9TJjA2KQRC5Fg8=; b=mUTdxacK2bK4QwUFyjXM99BqxKaRp0PmiYQotku6E2QquYN0nf9d4o0x1NFTFjX6dQaEhStOSF5IE56bS1VdwGbkoAlLDDlK1kJo6XCwjFmJJbKqu2GsTNMihMDgAjf2OYmfAT1xdFEg3VPqoyaNfhayRQu3ezF4NlDy3GknK7G/Kwrb/beS3pW9yqU2CxLau78agjhl+qKTgnjzkQdxCWBVZJFnrksVHhIRUBZ2+0LQRYQbPwKFQwBzl2i3jbPeNQ18gLz/K5WM0xajLrrHAuY84TKy9Q5gDAeJL/+qbSqriGRnOcAnoPst9lEGJpVpisTKolsE3SfrR/yOER2ZoA== 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=aTT/kwdkByFCua9fB9KNCrNwSlcOk9TJjA2KQRC5Fg8=; b=gnL4mszBxw1wMoQrl5CeRpmjyIv9OnlXkas/z4RtxbFqwea+eC/73GUl8AcENLH4naj8aR2ZqJOi9+YXcWn3Xj1JeB3Lnhkc7UG6YonILCWeUvN7WBKtSMe5o+68cgxkmrTWm7PZ2y0MmCTIM0DIYlv2rPXJby6RcoaljZMuuzGdynS9SWu9O4oQj1lrXOLFGPKfVL755dKAOBYLs1/9/pFvWvl9VjLMTznPIQ3pIOQeoQDzVITT/U+cDqtPjswp298cfwcUhtMwHRnEOylgzovWMUy/7HccYehAqt+ecXhaeoiYAYw9BHN9tiHT7NMC2NuLwtOl1fsQwHq6o2TO6w== Received: from AM7EUR06FT005.eop-eur06.prod.protection.outlook.com (2a01:111:e400:fc36::4e) by AM7EUR06HT017.eop-eur06.prod.protection.outlook.com (2a01:111:e400:fc36::313) 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:57:56 +0000 Received: from HE1PR0301MB2154.eurprd03.prod.outlook.com (2a01:111:e400:fc36::4c) by AM7EUR06FT005.mail.protection.outlook.com (2a01:111:e400:fc36::397) 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:57:56 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:F2BE068E72734DEF3D4B96239EC7975C09E7DD35E2BC3FEB5E942DE84CB64A8A; UpperCasedChecksum:3AB622BADBD6FF629FF1D5B37B98E44933DCDC1894CF4BE49098669A78D468FC; SizeAsReceived:7587; 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:57:56 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Fri, 30 Apr 2021 01:56:36 +0200 Message-ID: X-Mailer: git-send-email 2.27.0 In-Reply-To: References: X-TMN: [7LxpZFu+AspRMHf2C37fi/9FGXe0N38G] 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-4-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:57:56 +0000 X-MS-PublicTrafficType: Email X-IncomingHeaderCount: 48 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-Correlation-Id: ed48d979-d02f-4ab1-dcef-08d90b6a9c4a X-MS-Exchange-SLBlob-MailProps: gjx25WM8ZNU6XUx7q8EQ5McclV510mdNxjNwsFtrBKtdAI++ovOETmt3AgrlkwDOiNLQKkoEVZJuJTBy+vCBvT1VfQAAWe/gKHx5+cfHJZSvIfagr+gSaHxZJxizaE6yo62QQJQS2HN5w3LYNlvWekve4fsEc003oHzJE6j5mkqnNsDg7UwzYLZe8tA7PjMXNuhEtuWB+GH/+//aBg5QEnftV64bgEED1dN14ZJUyiUZkMbo6Dz5uvkMchbEtiPna1hKRM2JaPwcLmUobLk5V5bM0NsAIuw1DmtnFFMKQTkRPJ+aOQvVngrTGUPPnhffpFOraBNd7pSoL7y/bz2YL9Sv7lr36sV742YOP3rNgbOgpSVglJamMGR3PIDBTx4s5CHWCvGDRwOwPTG8Rtr6v7EPXFElX/47F1mYxe2KBFdI3Lzu4It+TC7ah2SAB+HLYTAFlhCfOf6ioc9gTEge/hrp2YIQ0FMIOeqv+MuDLEsTFTJmNCJvZktcS3R6zKO1t4i2uGHORdSSSx+Vu5jBTvAMBrXQHg7gxon9c+w7ErAP8q5iWEqCsfVOrXPCDgDzyuIZGiFL9FHzkhk8jaJI5NMvvdmtuqkRXyOe02XHg7W2+6lZO4W4Y4+t9m0vFnwQaqNun6UETQANKv1c2yoPXC9kRQ//6R7YrlrbqMIpLaNihuDdAu1F6PrqFdnd8Gf07s2R/FyvMKmlzejdwMHDDKve6VHy7vS6IoeRYsEYpVM= X-MS-TrafficTypeDiagnostic: AM7EUR06HT017: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: bOmWZE9EKGs+RmX9Ax3oUWlssdAYMrGE2n7Ap4DzPX9rfTOwUKeqgCbf091aF5xNM+LcTNltLWHInY0gAoKCMwbIbbwkfAav7H2dEjdhwkQNfYZ/FhnJs3k0McRWkRKF2TuQq/HgLeOc5V5v09y3xVhwNiSsbrSJzjn7Fa4l74Nj/MkUSkO/sgvDkoZtMoH/+vBAE/eetDO3MXRrNb05n0QP5OPrt+ce/S5wHNGHx5fDNsgTrZi5Zx+FPgVKtSXaX9veiATzoRbojiQinJeCKE3QRpl8U7vTdcNHUo0F3V/UV47o0jgCrDUaaD1p9rj+AYeSY/rho/nccwRp1RFTaJFsAA8qm/RqguDWrf5GkIj5S0AwBHpiTOmVw+YVf3s9+QFEMyt8Q7+o/wwLhubXMA== X-MS-Exchange-AntiSpam-MessageData: 8w+I+YcjhIKrh5euTHmCOTf3IxsvKMdGsSBRBPi1JJuEZ9ltLsw1Vz/MbBV2vNSfl4shNLlD8VtwAMG9MNi2Jf9BSpCGI5YGxzTx987j6k1j/0ebUVyTN17vE7Oa2Q4so9y3LOuRr5E+JgYEFmt7dA== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: ed48d979-d02f-4ab1-dcef-08d90b6a9c4a X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Apr 2021 23:57:56.8065 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-AuthSource: AM7EUR06FT005.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: AM7EUR06HT017 Subject: [FFmpeg-devel] [PATCH 05/46] avcodec/[e]ac3enc: 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: EBNbOlSe8uu6 The size of the output buffer is always known in advance and the code has no alignment requirement (it uses mostly the PutBits API), so allowing user-supplied buffers is trivial. Signed-off-by: Andreas Rheinhardt --- libavcodec/ac3enc.c | 3 ++- libavcodec/ac3enc_fixed.c | 1 + libavcodec/ac3enc_float.c | 1 + libavcodec/eac3enc.c | 1 + 4 files changed, 5 insertions(+), 1 deletion(-) diff --git a/libavcodec/ac3enc.c b/libavcodec/ac3enc.c index 8d9de8e108..0036f7d8bc 100644 --- a/libavcodec/ac3enc.c +++ b/libavcodec/ac3enc.c @@ -38,6 +38,7 @@ #include "libavutil/opt.h" #include "libavutil/thread.h" #include "avcodec.h" +#include "encode.h" #include "internal.h" #include "me_cmp.h" #include "put_bits.h" @@ -1760,7 +1761,7 @@ int ff_ac3_encode_frame_common_end(AVCodecContext *avctx, AVPacket *avpkt, ac3_quantize_mantissas(s); - ret = ff_alloc_packet2(avctx, avpkt, s->frame_size, s->frame_size); + ret = ff_get_encode_buffer(avctx, avpkt, s->frame_size, 0); if (ret < 0) return ret; ac3_output_frame(s, avpkt->data); diff --git a/libavcodec/ac3enc_fixed.c b/libavcodec/ac3enc_fixed.c index fe8607988b..58decc594e 100644 --- a/libavcodec/ac3enc_fixed.c +++ b/libavcodec/ac3enc_fixed.c @@ -132,6 +132,7 @@ const AVCodec ff_ac3_fixed_encoder = { .long_name = NULL_IF_CONFIG_SMALL("ATSC A/52A (AC-3)"), .type = AVMEDIA_TYPE_AUDIO, .id = AV_CODEC_ID_AC3, + .capabilities = AV_CODEC_CAP_DR1, .priv_data_size = sizeof(AC3EncodeContext), .init = ac3_fixed_encode_init, .encode2 = ff_ac3_fixed_encode_frame, diff --git a/libavcodec/ac3enc_float.c b/libavcodec/ac3enc_float.c index e5c2cbd42c..f9759bd2cf 100644 --- a/libavcodec/ac3enc_float.c +++ b/libavcodec/ac3enc_float.c @@ -136,6 +136,7 @@ const AVCodec ff_ac3_encoder = { .long_name = NULL_IF_CONFIG_SMALL("ATSC A/52A (AC-3)"), .type = AVMEDIA_TYPE_AUDIO, .id = AV_CODEC_ID_AC3, + .capabilities = AV_CODEC_CAP_DR1, .priv_data_size = sizeof(AC3EncodeContext), .init = ff_ac3_float_encode_init, .encode2 = ff_ac3_float_encode_frame, diff --git a/libavcodec/eac3enc.c b/libavcodec/eac3enc.c index 38ca31a219..96ef00ea4f 100644 --- a/libavcodec/eac3enc.c +++ b/libavcodec/eac3enc.c @@ -253,6 +253,7 @@ const AVCodec ff_eac3_encoder = { .long_name = NULL_IF_CONFIG_SMALL("ATSC A/52 E-AC-3"), .type = AVMEDIA_TYPE_AUDIO, .id = AV_CODEC_ID_EAC3, + .capabilities = AV_CODEC_CAP_DR1, .priv_data_size = sizeof(AC3EncodeContext), .init = ff_ac3_float_encode_init, .encode2 = ff_ac3_float_encode_frame, From patchwork Thu Apr 29 23:56:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 27489 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a11:4023:0:0:0:0 with SMTP id ky35csp2014613pxb; Thu, 29 Apr 2021 16:58:13 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyUZuMzHEMzDMfq9l6Y/i6Tj28HBI8lNSx/vppFWvrjWxcCS1i3OyvXm3B16EX1sC03AGX0 X-Received: by 2002:a05:6402:5158:: with SMTP id n24mr2561244edd.74.1619740693036; Thu, 29 Apr 2021 16:58:13 -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 dy11si87091edb.47.2021.04.29.16.58.12; Thu, 29 Apr 2021 16:58:13 -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=bGKZXSHl; 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 7322E689F4F; Fri, 30 Apr 2021 02:58:01 +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-vi1eur06olkn2098.outbound.protection.outlook.com [40.92.17.98]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id E6E6B689E94 for ; Fri, 30 Apr 2021 02:57:59 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lDYVtTLmxpFrplootjr9C0dPbxXIdLDfUojkDLVPeeYbzoq9aLrR0M7qSzId1TpofUtaoRa+I3HyHfFFT2jW4uUZ/GONU+aeXN2nbynK0JSkOeaLeowP0s6bu/NPzOuh3GZcsx5U/+ixR8WQqswDy/QbzyEz9/kpCJ8qOfKyD0w8k4f7/JbMeA13U7W1wubn4W98Ppy8Rn+JeKZsvtkz1ZHjhnJrbwrGWbgTHdqUbJ/K/RjcGlzR2M61tbtCjnzxMv6196Trz7rTRE3hwtpZO7WQMzqAkDaUP8diR5EL2JfX00HkD1bnacLRud5ku+BQSCJPaH2V2EkmIkjMf61N1w== 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=4gWOvU0w30J//jpXRZUPKZLQTUrDWaNm95mxGZijgoM=; b=ofEFDTHV/tdmH7Dw8vQmOAmrjkpvTmGMIevvpbgjIVfzy2DIuxl8ANBih+xeLZefarM5ZOXXAEHVj+QfUmM8uiS9EVp8bqUJSl+//KMqW57XmDo+J8j4EIYSMXTlSWEm5epwH3iQx99E16QDMhfgGVVXZIA3+Gwyg4KwTknAVerJRytf2aGlj4uiE5m3cr610ejQrmWTz2Pe+sYnckXqKAYY3e1Ru8qeAmOd/65lsBuDiErJ2rvCBVKpSOrQWIdFzMY2JW1F32GczY1pgKuygDf7F7nfZulE2TAbdi8umIB1XypA2CGwx8B5JFNINyFIIjrjEFt+RP36qucY1RCZ5w== 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=4gWOvU0w30J//jpXRZUPKZLQTUrDWaNm95mxGZijgoM=; b=bGKZXSHlD6V6J5ALm0kRZ7ZvkYRYAgGo/UlvhQ2Nt2K3Gd/68HgLpe8KbY+84CGvkppz/ylJ21Jtid9FA81nlV23/uWwkSyyAMtBcf6/NvqvhlVNMHAEowqNc6ZOlVAgrIRFe0ROf0EEA4r1AU5nAKgchtstrr1ClHPmYD7EUGXSkFmVHVaKGMKagVOAkUC2cTmFXfXrua+dUpF8s6/N1WGgcAnJ+FVZ5hZ+Df5FLLZEAIDuKPmd65+AQBqWlH4bGENqAxd8MStbx+iLlRLJBchj2yJrFB9fpEBxOuCT728OtLgl9uYQvr0hRqcdTaAkVaPBDLB/1+yAaGgF78bkLg== Received: from AM7EUR06FT005.eop-eur06.prod.protection.outlook.com (2a01:111:e400:fc36::4a) by AM7EUR06HT053.eop-eur06.prod.protection.outlook.com (2a01:111:e400:fc36::62) 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:57:58 +0000 Received: from HE1PR0301MB2154.eurprd03.prod.outlook.com (2a01:111:e400:fc36::4c) by AM7EUR06FT005.mail.protection.outlook.com (2a01:111:e400:fc36::397) 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:57:58 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:37C3DB80FF7F0F68908DAC39A9FB9651A9A1BCD93E7CF5D1EE7B57A5BFD2BF2C; UpperCasedChecksum:93527F103BBDF7F2D813C8118A026886FDDEEA87285853C057E3E765CB7F8A8A; SizeAsReceived:7609; 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:57:58 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Fri, 30 Apr 2021 01:56:37 +0200 Message-ID: X-Mailer: git-send-email 2.27.0 In-Reply-To: References: X-TMN: [yymu8FhQNhk2tWb8mMrZD8bzunVH1GI1] 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-5-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:57:57 +0000 X-MS-PublicTrafficType: Email X-IncomingHeaderCount: 48 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-Correlation-Id: ff88c466-f235-4de2-4dde-08d90b6a9d33 X-MS-Exchange-SLBlob-MailProps: S/btQ8cKWiQnJqnaHo6w7XTEhYoMxTOUqqC1aAam4bzntlwSzJ+E2IxE8Ij/uc+Wr5yS0eTUv0iYvAYoQ+qM6AETmkrcjVSvPP6UG9z07vCWQU065hinSaVnAikqz47rbMp05LQvaq8cubWqGuleOr7ZgyxgiD6ty/44fOVaBDnP5Y9rswgHLhNwN04rdkb5BtsIavesoftVKYFBcQ6hOR6/VmYXC04ompBTCDG+GTodftuWUDRSyWjkycvS9leGcDB2pdiycBV/Xe7T5Ax9mvXEyF+tpLheNY0jysN2BDEWW/bvZkX0TFMurjC6yv2xGfWgdAkNv4jjnLOehT5FVUC81YpcAq+biWtfowmLJnI6UzIuAQBoVaaCUR/9p2v9avlHo2TexeBB1HQTnEP09lNtaApJTj2FFzlwBBbxn+6QLZKTTeJQ//nnKyvUDGP33OaXch8Kzt2rcvwYIRHJvO5/98bgH7gQfi/D8Xs/M0iJ3O8TX6693SsxRbEncn3Wx0pK9r0K9weN8nDa0TlhoPdYY8A9RE4wQzObOOJzBAZwTklfu+gffd8caDCr24QqOY+F1uXPHM4XWvvS8/n84Mwe6uNLrn4I1V/djPbjn9TMSmSBKRrDX3biuxQYSgVQ/ClPmrs4yXg1UplF9vROr7OTfYRgVq+7KVGJVOID6j6mtRk1uflwm3oDxJRfPp5v8Z+tC8/zjeDOiCl0dIJbKszndIyYm1Go2gx6oWn/BfA1Cb9m1feriX51DALWdGZzd6eXjb7rkhE= X-MS-TrafficTypeDiagnostic: AM7EUR06HT053: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: hRDuviKckEGPhK4SmsDMUUp9YK5R7hrdVh2vZnHEYk4OEPa6trvhdNMuf8HB3yyZjCGdeaSArqORPbkDsr48SPm4caIKGG949T8S18zL87mrKUWTVa+9ehEv0+VRXkzVqcU0ZBUv2xuQM2EAPlxNtwpCkavEs4k4Dl5eXCVPs9AkNZ3TH+9fMwWFaohcltxCw8ydf9M6+Eg175uTt+gTLrGehjJ9kyOjUETTKga+ER6KfV7xsKwBTNJVet8Gm6lW8ipO5vocV5m0H8GqIwT3HqlmkL0c6wto78pm2ZATmRMiwih/MTd6ZUa3SJcEccua8Csnuf+w+Gl0ca3D8ND6HR3oNnqXQYCam1papZx9YtgnG7DuCi2USckv/b6xOOXW43FnfBzIFKZb8qErgfircg== X-MS-Exchange-AntiSpam-MessageData: lEx8Rnm6A2D9JNfy9xWUxPQ5bOj1vlBN3+NoFxR+5hnpKiB5e9pG97KHQrSBxMqtYf46fTNRyoW5zdOhUkmDCR3DpTraUkpR3XnvlvceaGyug8RzgVLSGPFqFW3AbkQUGPFulN2p6INKlMd+RDG5BA== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: ff88c466-f235-4de2-4dde-08d90b6a9d33 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Apr 2021 23:57:58.3539 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-AuthSource: AM7EUR06FT005.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: AM7EUR06HT053 Subject: [FFmpeg-devel] [PATCH 06/46] avcodec/adxenc: 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: AeEfX/7kbXVD 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/adxenc.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/libavcodec/adxenc.c b/libavcodec/adxenc.c index f507840a1a..fc31351330 100644 --- a/libavcodec/adxenc.c +++ b/libavcodec/adxenc.c @@ -22,6 +22,7 @@ #include "avcodec.h" #include "adx.h" #include "bytestream.h" +#include "encode.h" #include "internal.h" #include "put_bits.h" @@ -148,7 +149,7 @@ static int adx_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, if (!samples) { if (c->eof) return 0; - if ((ret = ff_alloc_packet2(avctx, avpkt, 18, 0)) < 0) + if ((ret = ff_get_encode_buffer(avctx, avpkt, 18, 0)) < 0) return ret; c->eof = 1; dst = avpkt->data; @@ -162,7 +163,7 @@ static int adx_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, } out_size = BLOCK_SIZE * avctx->channels + !c->header_parsed * HEADER_SIZE; - if ((ret = ff_alloc_packet2(avctx, avpkt, out_size, 0)) < 0) + if ((ret = ff_get_encode_buffer(avctx, avpkt, out_size, 0)) < 0) return ret; dst = avpkt->data; @@ -192,10 +193,10 @@ const AVCodec ff_adpcm_adx_encoder = { .long_name = NULL_IF_CONFIG_SMALL("SEGA CRI ADX ADPCM"), .type = AVMEDIA_TYPE_AUDIO, .id = AV_CODEC_ID_ADPCM_ADX, + .capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY, .priv_data_size = sizeof(ADXContext), .init = adx_encode_init, .encode2 = adx_encode_frame, - .capabilities = AV_CODEC_CAP_DELAY, .sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_NONE }, }; From patchwork Thu Apr 29 23:56:38 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 27494 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a11:4023:0:0:0:0 with SMTP id ky35csp2014796pxb; Thu, 29 Apr 2021 16:58:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJysIBz6ueocUxcXflrZc+JQLeCBIKDg94+NFV8soBTiphFU78xgjRYOCyVT/7cEy2nAuo1q X-Received: by 2002:a05:6402:42d0:: with SMTP id i16mr2574745edc.212.1619740711612; Thu, 29 Apr 2021 16:58: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 p31si63775edb.415.2021.04.29.16.58.31; Thu, 29 Apr 2021 16:58: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="o20/W26/"; 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 714F3689829; Fri, 30 Apr 2021 02:58: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-am7eur06olkn2027.outbound.protection.outlook.com [40.92.16.27]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 2399768A0AB for ; Fri, 30 Apr 2021 02:58:01 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Ou92z9UdG8KpS3T17gg0OImu8FuJxTJ8IKRzcGwky+cA3EFdwl2KpyzhDU5ekYwCytRvP1M50etQ4TwsG0Y2oxVGL3xBxxCHM7faanCHrPVDQYiK3qQrJgAkKqQaim7n32hCrOjFsamsz2CWqR0+avlyD1bXxIXq9hfVZuxSd2J8LIwX9B6YX6pZnWJtq/vHJEaCOSsSD44v3Lt2fWmWhyC/GTQWdlRIYlsy2uatl5cLghYXYNiF+pmz2BVxAWGT8dkjXJPttHQQ6ycEu+IFiT66PegfIk7hJkF3AQMBgxvKISTvX95lwKXfHq0NoJamvOSfnUDp9EN2ZerJIUxiYg== 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=vWyRiSexbYaulPLMHsELCohXINRzz1ggZC8Bcc+mLGg=; b=PWMw6CV7JAwuG2qvoTK8RXyPUmbBfubb4QhSgdtV7RW8yHR/5G9w0o6ccIn4xuyyBaBBAJjKvwyrMkJb/e4R4C6B84w/HFwOiast3TebEBqj4idpngKamL2we8kNRea5dahLgivS3pRwykdWVeuQNYix8UJigIPs0oK9gF8A/FwEbpniwhVEwmOXLS3o8yo2B66ImCp8zG8KhJ+zVaL9ZAzkDdKaQheixR2FgrPE7bbwZkysOrhLmHMbWrscDLdUTLddSbZXn09TDgW0EI3PNr7VCB61EsrdemI2KoCNwlkGxSkBPOz79tlU/y7u/kOleEX4dFeh9nFiP6vBiRpUFw== 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=vWyRiSexbYaulPLMHsELCohXINRzz1ggZC8Bcc+mLGg=; b=o20/W26/DaasNjw+tzB+GIXtr06LA6PaRGmnKgbqXeQ7Mjs8me80njv17K2rsJQ8yVTkq/MYcRBSO/cE0xFPJ0ZmTvViER4Kx0Db8H6UELPJxIOtaYzoz0RMJmYpvx2XIjGO1+zxDVxsjR/SB02HhGhn7Y9OKCspHmT+So94bMEBH4ycv4THGkHSC8FRzPQapFtlfdJ+GtrwBsYZH3IVB72Rf/XSdMrAq7kHRT/lCO+XHYfxs76ow8bHetVIa4Ta2skMhpmfFT7YTnXPyMxVpEQxj8EAu8SB6YC2Sc/ZndWx5QJWt86+kkRWlBmv9B6sNg+7BnRfqfTADtY4hUGWIQ== Received: from AM7EUR06FT005.eop-eur06.prod.protection.outlook.com (2a01:111:e400:fc36::41) by AM7EUR06HT255.eop-eur06.prod.protection.outlook.com (2a01:111:e400:fc36::117) 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:58:00 +0000 Received: from HE1PR0301MB2154.eurprd03.prod.outlook.com (2a01:111:e400:fc36::4c) by AM7EUR06FT005.mail.protection.outlook.com (2a01:111:e400:fc36::397) 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:58:00 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:CAEDB81B2B4759A848FAD6620EFBD9F6A96229EE30EC8821B9B73A66BD182383; UpperCasedChecksum:3D8D060D9728F68F0EC1C6C876602FDE36FD09A75F89305FF29A7B3A96E065A6; 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:58:00 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Fri, 30 Apr 2021 01:56:38 +0200 Message-ID: X-Mailer: git-send-email 2.27.0 In-Reply-To: References: X-TMN: [sBp4XaAFXlrQViNjXzclJVPKJGDmwdzb] 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-6-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:58:00 +0000 X-MS-PublicTrafficType: Email X-IncomingHeaderCount: 48 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-Correlation-Id: 388a00aa-53ef-4431-d398-08d90b6a9ea8 X-MS-Exchange-SLBlob-MailProps: S/btQ8cKWiQnJqnaHo6w7XTEhYoMxTOUdiV/cvqPi1sITop5PsqPFhJvAnTEfRNNu11AnzfPY2pC29+flNY0HYodloMFx/8TTQk5U2hNH3n6dPJmbumPLY21mK2YIKAbxkO1JLNTSUn4rie9Wa3lEIRrFhoyBq+5muuSGLgLU6jyVjovn8g3Sb3SNdFKKTkTn06+TjMC8saJgQ171m+m46Md7OyXyMDaZcAPI2PAshO3r1KuUtyFtgXxS0Ndnw/790Z0RtxSDJePHI188oGaNOVenNAX/u3xFwE+DB4LRoPJ63arWTlich+6sKKtk+Jy8PaJjQVYuOezhMK99sa9gT8WOQwdycXB0zxThSLn5SiuTTUm9krG9NJk/wn4RYW8NWcyxkYkXxB1uczMqhSAZ2wzbsFRcy5iITI59mPJIeaDdY7VuvJ/evL7pcYMxMD6PnOp2awe7IsSKVwaKy0+O9eZOLweWvDm9UfJ26RyitTuMxZE/BCQvv2lQmOrJFqT/eHf1N9/sVv8+EKK9BTC3lkh7We0jl4ZzP5pSnpgvLjD3es7Mif//duj0D8/4xGm6yqklGNJ4eoQTYLRafrg6WOVmYEIAk5TBk5VNSW1u0hN0TAP9fqNxM7PqJmWplXNn8hVbtZ6yVrBUXFlZJr7Plq6LDq0fmryP2TF8fUKdddZ36n/yy0u2gdnAKz813zQ79ACsLN/EwJnU71OMtaIeGpq1CPoDzAZsz3qe29IsnPmi+FIvLuqw4S6XoAu2HhX9jSZ5/GsYq8= X-MS-TrafficTypeDiagnostic: AM7EUR06HT255: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: IYMbv+NYa9TVbVvvYP8DFiLdAd3bMo19Mwvp7IXJHd6Y1VidYDqv8VhUX289BoW9yPhtyaBqgyGZZ8jdt5s5g3waT55Di6q6qWFX4xbKnFhmC5tVfRMMk3iYPnb9JWDP0GgiL5Js6tpRjzhbN76rxLyinNCBphIAXm6RvtODkbhqfhYR9TZJaDIvm0A7FVQSDgdrTAnJ5ywvHHy0ChGXnMEQitlPZRY42swQc+WUrBgvA2d9MaTzfAsN2sjofc9dp37x1j9pSgv7BviEFgkeQ+VTqKeZ9sTnokS2qABiILTRRC6oHkxDMDvF0FBdPSCDvBVbR7fI+cDDlQ/ZWWv+AONHSAegLil0/+Eq+pnd+MujWhYh6FncBj+FM9D4JCSB0z3D5eVJj9g0Kc1gPfNh9g== X-MS-Exchange-AntiSpam-MessageData: 9Aeyw78ihKZFCznyLhKkZyG3qASks+srgVt/PhHP1oYXSbJy/Q+OpPgpym9iisw+Vl4roVqyahfSV7ku4G5GSxUxqHFSt/r22wtQiK5LzeEiFz67WTzIhcXL6OWPd9flmtrOjE+tu+R/sLqKB+1nNQ== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 388a00aa-53ef-4431-d398-08d90b6a9ea8 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Apr 2021 23:58:00.7718 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-AuthSource: AM7EUR06FT005.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: AM7EUR06HT255 Subject: [FFmpeg-devel] [PATCH 07/46] avcodec/aptxenc: 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: kOLS7uN9WmKU 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/aptxenc.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/libavcodec/aptxenc.c b/libavcodec/aptxenc.c index f432a123d0..733ebc42c3 100644 --- a/libavcodec/aptxenc.c +++ b/libavcodec/aptxenc.c @@ -21,6 +21,7 @@ */ #include "aptx.h" +#include "encode.h" /* * Half-band QMF analysis filter realized with a polyphase FIR filter. @@ -214,7 +215,7 @@ static int aptx_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, return ret; output_size = s->block_size * frame->nb_samples/4; - if ((ret = ff_alloc_packet2(avctx, avpkt, output_size, 0)) < 0) + if ((ret = ff_get_encode_buffer(avctx, avpkt, output_size, 0)) < 0) return ret; for (pos = 0, ipos = 0; pos < output_size; pos += s->block_size, ipos += 4) { @@ -245,11 +246,11 @@ const AVCodec ff_aptx_encoder = { .long_name = NULL_IF_CONFIG_SMALL("aptX (Audio Processing Technology for Bluetooth)"), .type = AVMEDIA_TYPE_AUDIO, .id = AV_CODEC_ID_APTX, + .capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_SMALL_LAST_FRAME, .priv_data_size = sizeof(AptXContext), .init = ff_aptx_init, .encode2 = aptx_encode_frame, .close = aptx_close, - .capabilities = AV_CODEC_CAP_SMALL_LAST_FRAME, .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE, .channel_layouts = (const uint64_t[]) { AV_CH_LAYOUT_STEREO, 0}, .sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_S32P, @@ -264,11 +265,11 @@ const AVCodec ff_aptx_hd_encoder = { .long_name = NULL_IF_CONFIG_SMALL("aptX HD (Audio Processing Technology for Bluetooth)"), .type = AVMEDIA_TYPE_AUDIO, .id = AV_CODEC_ID_APTX_HD, + .capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_SMALL_LAST_FRAME, .priv_data_size = sizeof(AptXContext), .init = ff_aptx_init, .encode2 = aptx_encode_frame, .close = aptx_close, - .capabilities = AV_CODEC_CAP_SMALL_LAST_FRAME, .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE, .channel_layouts = (const uint64_t[]) { AV_CH_LAYOUT_STEREO, 0}, .sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_S32P, From patchwork Thu Apr 29 23:56:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 27488 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a11:4023:0:0:0:0 with SMTP id ky35csp2014890pxb; Thu, 29 Apr 2021 16:58:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx+LL/wUB8ALn6IeTyxIf6AfKFgLbsrD7cS6GEJQAEbwQUbaqH1OO2j9BRIYajANtF7rpxG X-Received: by 2002:a05:6402:694:: with SMTP id f20mr2537284edy.93.1619740720372; Thu, 29 Apr 2021 16:58:40 -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 l7si1785798ejk.583.2021.04.29.16.58.40; Thu, 29 Apr 2021 16:58:40 -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="haUYsG/R"; 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 7135B68A126; Fri, 30 Apr 2021 02:58:05 +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-am7eur06olkn2016.outbound.protection.outlook.com [40.92.16.16]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 987FF689D84 for ; Fri, 30 Apr 2021 02:58:04 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ls8QCR/rxfEkeYQJTuutdyktnQdv2hVrdkD58RmuZZI3VXrnvZ491L6iFsrA9P5C4xu7t1SC2drkrBZTl9osKbWF8xpISlr9LRMrPODcn87Ga0oRbgJxKt0nJ9MDJRMjwpjV0baGfOVLgDGbCzt/oB+B//k9hQ8J9D20QeFC5oYEjprVYgSknNrPwK9jZkFK4zOiB2CzbrIvKQ1q2bx+E6HT5fPbCCAh7EjzWf9DYLhy99CKzspML4DKBB1yXdt8HmsYaoeiieGIiYiqj3NngCG7pIBJhLz5UBd+MpxEuz7ZoZ6o1btPMhnOoXJ+KPsqwGrL1hro22kfRB7vieNepA== 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=BPEcBLqbeVey9eYMciaUl+6NFe0EzY04PLA4g35ddeo=; b=IzdeuREA/DNwK3X85xbHe0C2OVPWVh+5JXHL+yjb6U9LLVrbK/rKbT9y7ogt/Lb515DJl+N4zqOsYGeoJSWAKWMmYwMJBak/aPlr4VSFDugoEcuyIzXvEkIj8ZEmfEB44U0zG55PMfFYv1x4x2zxharRZbTaaMCFfKteQ66sJ2PCKUmQesXIU2vHC4kFQ2RWtXXfCA10aEDLOFNCsahSAFC4hYZ7yIEqdYlf8Lki+bneppcb5d1pj8O2co30eAMjC0w6IoJ+WzjImmjjaHTiXXwJ+h1ubSaGxSNSVYCieni8LCBJ/6a+EjudAH5mpJW40uSASaNkM49USBBV++V1cA== 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=BPEcBLqbeVey9eYMciaUl+6NFe0EzY04PLA4g35ddeo=; b=haUYsG/RIASbFGXDSJuXpYv0Q0dOtOxIywoDyimcNw62EqnR7lD5d7dP653dNx1yjxhVyD5eaBPCuXGAP8br1vkmWjQ6te3M1TEvTj6xdU7VIy1EVNto6tncsxUjA0N3gOmzZJNlaS5hO/T5+e6DHjsCZxs+HYmkshou3o5H0lKKOYOpU7y7Lt8a+o2HtkvMjDihINfgQoBNSiszha0XPCUStFb57lzFyqXG0HtrNUSv2MwZTNk2ej4GZcBjHhXObZeFAxnVr/Lt8xnLihNy8REU+DU+JiJT3EO5rha3Ke5+KdSsta4Jp7Z+kktjmxN7YTR3/sBgBA7HKPBwG5gFBQ== Received: from AM7EUR06FT005.eop-eur06.prod.protection.outlook.com (2a01:111:e400:fc36::41) by AM7EUR06HT255.eop-eur06.prod.protection.outlook.com (2a01:111:e400:fc36::117) 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:58:03 +0000 Received: from HE1PR0301MB2154.eurprd03.prod.outlook.com (2a01:111:e400:fc36::4c) by AM7EUR06FT005.mail.protection.outlook.com (2a01:111:e400:fc36::397) 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:58:03 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:23FE276742F658A69ACDD470D866F51CD71D6768DF42B79B790704B51C8FC18F; UpperCasedChecksum:4501AF5BF733F7C2B3F006B76A10809CC19A4FBD5532300D56ADB99F05AD9398; SizeAsReceived:7575; 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:58:03 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Fri, 30 Apr 2021 01:56:39 +0200 Message-ID: X-Mailer: git-send-email 2.27.0 In-Reply-To: References: X-TMN: [i+0UkB+NBjmsD1hJHEUM73aOBCvATy0e] 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-7-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:58:02 +0000 X-MS-PublicTrafficType: Email X-IncomingHeaderCount: 48 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-Correlation-Id: 884a717e-ed91-496d-595d-08d90b6aa01e X-MS-Exchange-SLBlob-MailProps: gjx25WM8ZNU6XUx7q8EQ5McclV510mdN6KDHjc5pS3u7ostM0t1Y38ASN/v5+OZBV+8isIJWrKVT+8AyMNKiG+DpraovghQAqwMwJ0a3mzZQXk/FG7ucP6WLlM80/gBfjJGWCEPqK4k0l2Fs27Svuep98rMnLmTz9WgwUn+FYhjeZ4ekfq64J0kz8k9cUoBlK9v0VAOzNLILMK37R5C5eBLH2TgfvxXPZsEghxCpmtPOTQ0v555clP9LQiq8NmDg97m0pyUNf8ITa6QdejmA6mACH0hFLB2HVPTvQ2O23wtacig9lEoiN29CGdFVgQYIB3Ww5yCQGwTcU6PkKZqjmw2hvNwH7D2VAxMtJ/zI/mFDtmuhUd3rjpWBYt5t16hjYwzzbmULpa2nnSTePCa1zy2IN2SCURQmPiU5i72hone5TLz90Dex8AeRa6JOKz2lCOlwRMIF9Y42+Vi8W70uvIpIJAjKxsRP4KamMw+38psvZdMs84/O8/8Ri68f9YipczOwba6xNI6u/d5cs0hZ8nVDFaXI/GfpZuncRBekWJ/1XqsPbiqou9uGREB8VqBKgQGOKrBvVrlCGwj5KUahAULf3zIaXm+BuoRBjEfSSeXs6oYz6wOitA+jgNJEh3hXv3L3HADgmmyyizY/Dzr7XB1ZcJI5nrEZ4HjPaz9B6rKM1lAEXkM7diznkV7JUiQ+yrqm0Zi4QIXrF50Qj6oSHv38nmNUfIHCfpp0QDFtIjI= X-MS-TrafficTypeDiagnostic: AM7EUR06HT255: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 8X7le2vtCUpIsG9E8XXitUSP7CgJcZ4KW9kq/nZCeLlzF46VxnxIrDD5rWUCfYK+YH7cosky8K02aiSzcS4KZVMgPlQ1TBIRZbs3qKVAP/cmTYD78DrJ0scLd8PlHG51FNrfJhss425OcjpAUPWdGRH8ubfdOCMvhJb2xDsQBMZ6VYTgJGWV+pMXPdeR7ac2uXUxbfTLT5jhQeK3whp8BsYMB0RKrlaIfOHCdExZY+lc6jVycKODc/FbuRtE/gdK/ZqVM47m0bjW65OBc7fjvrPCab/fRGlhx+D9OP+riIbYc+jY1znoexm23Yg1qX/rqn31nM+Un1MLBnfxKwHQosaW/zyqO+pbyCspv/LOQsuUm1HZoNwKQUhjWXhwyv+iwV29r8+Wkg1Ny+BekMPBQQ== X-MS-Exchange-AntiSpam-MessageData: qU9f8Wuz4Bi9mhe6K+2ojQrzZGZltNQHwvw3GRtOLU7ysz8GUPB+cUsMbK6TWcFS89v08wtt3w7x6vAGa0SAldanHbKb9c2gTjQgk7DzZEajmNyOr5t7M3uwDmcMJBuPZ+xMGS97XvfNieclLTJ8DQ== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 884a717e-ed91-496d-595d-08d90b6aa01e X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Apr 2021 23:58:03.2537 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-AuthSource: AM7EUR06FT005.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: AM7EUR06HT255 Subject: [FFmpeg-devel] [PATCH 08/46] avcodec/avuienc: 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: DNfPlZ4Pv3iZ Trivial given that this encoder knows the size of the output buffer in advance. Signed-off-by: Andreas Rheinhardt --- libavcodec/avuienc.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/libavcodec/avuienc.c b/libavcodec/avuienc.c index e9e30fe7f4..1c67af3fb5 100644 --- a/libavcodec/avuienc.c +++ b/libavcodec/avuienc.c @@ -21,6 +21,7 @@ */ #include "avcodec.h" +#include "encode.h" #include "internal.h" #include "libavutil/intreadwrite.h" @@ -62,7 +63,7 @@ static int avui_encode_frame(AVCodecContext *avctx, AVPacket *pkt, skip = 16; } size = 2 * avctx->width * (avctx->height + skip) + 8 * interlaced; - if ((ret = ff_alloc_packet2(avctx, pkt, size, size)) < 0) + if ((ret = ff_get_encode_buffer(avctx, pkt, size, 0)) < 0) return ret; dst = pkt->data; if (!interlaced) { @@ -98,6 +99,6 @@ const AVCodec ff_avui_encoder = { .id = AV_CODEC_ID_AVUI, .init = avui_encode_init, .encode2 = avui_encode_frame, - .capabilities = AV_CODEC_CAP_EXPERIMENTAL, + .capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_EXPERIMENTAL, .pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_UYVY422, AV_PIX_FMT_NONE }, }; From patchwork Thu Apr 29 23:56:40 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 27495 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a11:4023:0:0:0:0 with SMTP id ky35csp2014963pxb; Thu, 29 Apr 2021 16:58:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwMZbYX56AXqaXdshWZ4oSs2FQed3Mq5IpTJRb40V1UjD4Kg8kC7a8auliTsezMrEi9BJi8 X-Received: by 2002:a05:6402:c:: with SMTP id d12mr2566709edu.100.1619740729598; Thu, 29 Apr 2021 16:58:49 -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 f19si56037edq.277.2021.04.29.16.58.49; Thu, 29 Apr 2021 16:58:49 -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=gEv5Jhn6; 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 C2B2168A0D3; Fri, 30 Apr 2021 02:58:09 +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-am7eur06olkn2047.outbound.protection.outlook.com [40.92.16.47]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 1E1BA68A0B7 for ; Fri, 30 Apr 2021 02:58:07 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hqNv0UNQsYJvxe2TnX1kejcmimblnOn7n+aarVCf+55oTl5hS76CxXpcbE91FTOdmWLZOyz9r6MRFY7yNfVkLg6C+OarFIyVLpIYFfur232HCRP9oPSxa3g+tHl/Og5w97YkGX2qQs+wrjz6vMRtaEhzWhkAiD++CC56g8M81EMT6vYL0SalLEeRXk8N0GX8LIVs4oySy5W3pD9rvM1qLzyxAbkE5JAgZvrd4MTYPCdQIsf8lX//YB7/ydwmPg8xumEtDn+7UxiPsDqpcB3REYe9UjUTaxuRTw6/8qUjBlcWE2zS/+EdL6y6jALEpBOY6FmMvk3Bl4BCc16PFLoU8w== 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=5xg1cEViVadjDlgOWUZft0Q/h3v52P6sIm7Nz/aFZ9s=; b=b2CbokkYBuJXNGHEJjRaYHuYgqX65ExDWaoYIYgwc7HfLYfChSXER+iOtWQQZ4HK/3BGCh+1imFWRynT7B9EQB6w65EMU8ZLdH0fQVNo1kebUxDYDs2fxUdWYgfdEnDtmqK8il3cG3ysNvf7m3Z8tq8p7c3t2SHPCV1uoxt5/angb73UlH0FV2mJ8JgBWu024CAoHXPBjh7d79VQb93skIdgD0C07bDygLKYuKV/Jnd6Y6u1G3GeN8xsEGzRWX5Te8UWywF0PwtveZFkXmZiT00FX0YxdJGGHhHoYTegEa0rk9rZHkHG711483Rn8Syp9KY5304x4ky35plNN/Tf4A== 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=5xg1cEViVadjDlgOWUZft0Q/h3v52P6sIm7Nz/aFZ9s=; b=gEv5Jhn6Te/UBy8Br8eYJcDuAmzETfk6T8RdJU3hFyBJzohzO4HbGZYTSNYc4BMoHisJ9mR9wndK52I0WGKs0KV/ay+u73ORNw6xLg2VHEFyYQbPwCIOck8qtDnmTwQykTYDgEvbZ2nL2+iPmZRN48jZH5YL/2JVGB44Zt7A42P5cbOcw2dapf6l55+CjZG24tijEjxwYIayroPh6/UkZjDUQD04NYuepe7OrfJhYHWfIJe/QYf05m40tM+BVz6SWo3H3jDuDKVvFNoFGIC7SenHxULtfFiuXmnQ9T4YYcvF5ATx/itn3D0aK6APOQaK9pef/6cbfWd0eretmr/xPg== Received: from AM7EUR06FT005.eop-eur06.prod.protection.outlook.com (2a01:111:e400:fc36::4c) by AM7EUR06HT109.eop-eur06.prod.protection.outlook.com (2a01:111:e400:fc36::229) 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:58:06 +0000 Received: from HE1PR0301MB2154.eurprd03.prod.outlook.com (2a01:111:e400:fc36::4c) by AM7EUR06FT005.mail.protection.outlook.com (2a01:111:e400:fc36::397) 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:58:06 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:0282F048E2E0AB5DD3BF9E70D10146BD234A9C859B6B01C5AB66618B5CA3DBBA; UpperCasedChecksum:AC30D8D1F9EC9883770009055A720F383C07487DEDC6D687805270FFABFC0A35; SizeAsReceived:7601; 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:58:06 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Fri, 30 Apr 2021 01:56:40 +0200 Message-ID: X-Mailer: git-send-email 2.27.0 In-Reply-To: References: X-TMN: [QoLZdHP+JCNxGqgNyxe6ToaCn9HwoAh6] 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-8-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:58:06 +0000 X-MS-PublicTrafficType: Email X-IncomingHeaderCount: 48 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-Correlation-Id: 8466f16e-d955-4bb5-15e9-08d90b6aa235 X-MS-Exchange-SLBlob-MailProps: S/btQ8cKWiQnJqnaHo6w7XTEhYoMxTOUdiV/cvqPi1sITop5PsqPFr2aMsd+U77vzPCr3CDhdaGSQFHaYx2rJBRvOVT5vLKKFMJGyhFLYGLwfJa/pLmD1vIKpkvvEuH35nhkX/qvD4KtNU126SZvf6NEuRxU+w0nW2gmxE23Q6KTjok3k0gYqZLhkoUdKVPUQpDZlrDx8tLPFtJAw7W6jGI9ZDnhclLDrueiET1FvHVxW4Nqy78QEbONprZm/3qr2f+uQbV0Kwr+N0VKfCqYwJFiBs6GqC1R4plzPcEHVmuDEhTGN1Bx+rNDtdYXowoLGFg8QlMVUQj+G3sjXZ0P/oFlJR+JJ5QOfXSX9sO4fxV+uZhJR/HypKJ+3tjpzLNsTD/xZL6RURh8A1ZCOFw36BFtcxO4A9HAWmdUJaCWjg4L0lRS0w8dhC/d64taGUsAzmBv68ZDt5P+d3D9XzrVyCeHD9gJaSpjP1olQNjYAnEyPLtfS7kK0C2Jj0hkIsOqHftXbhCd4p+G1aKT9y3XHTvkJNszOdaCfXUGCFqJAygPpCAuiFzyP5ECfzyR1Q+kcczrYXYUN2A9k2eFXEDR9oc5Sumzzgql2wX8YqbrIku6fA7ijKkidNqPKm5prKi8EhfMku07AufM8PkGPjBfB2UjarnUOWWord9GKvxUtsmUrTVCAVa4WkZ7nCa2FSgwNkaWwntvZ2U57iryo9tv/JBTGbOmvbUTOr5oblhu4nLsn7VQMjsjrGkxAlIGc5XF1QTNliLP7Tg= X-MS-TrafficTypeDiagnostic: AM7EUR06HT109: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: MjER38r/Q+ZZYstvRz+4jfGaWezSUTy41+qLFGC96tP51XNpnW/Vhu0XnoyoX3qHJ3wM8qjLX0j4bOqp1I55MNIH+2BP/EzFY2JI3yaiD9XP6e7zHLYAfl/gfXvhEKLmYaMdQtNFEHcJCtVeJ8JgJSCbj58LL5w40N/T/stZYtKJy3CP+IoUYRzUCXdUjCdfDaApckL/e1O7Dr9kL80LQ2J+jY55/AJ0SKaQEamvmalLlH5snvMQExHEJt8SXUZJkmVxha7oXm5T/f7B6u+Tyv+4cTJVSUHQq9NtQe5cGt5x8PK9uSJBw9w4mt96NqNifmSfrkb1MSg51cwAR8HuFsd1Ixyl//vkTnC2S7mYsvSrXXJzwzsVOgYb7dvAORm9TNSalIghBvf+9mK/5iDV6g== X-MS-Exchange-AntiSpam-MessageData: G1hGe2nNJwhynD9uc8JuFNWOpRrrsy1K179mepG6izpWHSfuhSg0XuwV0Wq1wWh2LUnToFBRCxunlgA7OQG3Z5rX33ynyOlCIzKb9a1jIX/sovWPRbKl5vrclg75UWyZUJJLhxjC5E/7xi1f9ICEvg== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8466f16e-d955-4bb5-15e9-08d90b6aa235 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Apr 2021 23:58:06.7311 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-AuthSource: AM7EUR06FT005.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: AM7EUR06HT109 Subject: [FFmpeg-devel] [PATCH 09/46] avcodec/bmpenc: 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: CgFRZe7uyz1u When the packet size is known in advance like here, one can avoid an intermediate buffer for the packet data; this also makes it easy to allow user-supplied buffers. Only one thing needed to be changed: One can no longer use a pointer to uint16_t for the destination buffer because its alignment is unknown. Signed-off-by: Andreas Rheinhardt --- libavcodec/bmpenc.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/libavcodec/bmpenc.c b/libavcodec/bmpenc.c index ee2a2d0ea9..409564d257 100644 --- a/libavcodec/bmpenc.c +++ b/libavcodec/bmpenc.c @@ -25,6 +25,7 @@ #include "avcodec.h" #include "bytestream.h" #include "bmp.h" +#include "encode.h" #include "internal.h" static const uint32_t monoblack_pal[] = { 0x000000, 0xFFFFFF }; @@ -112,7 +113,7 @@ static int bmp_encode_frame(AVCodecContext *avctx, AVPacket *pkt, #define SIZE_BITMAPINFOHEADER 40 hsize = SIZE_BITMAPFILEHEADER + SIZE_BITMAPINFOHEADER + (pal_entries << 2); n_bytes = n_bytes_image + hsize; - if ((ret = ff_alloc_packet2(avctx, pkt, n_bytes, 0)) < 0) + if ((ret = ff_get_encode_buffer(avctx, pkt, n_bytes, 0)) < 0) return ret; buf = pkt->data; bytestream_put_byte(&buf, 'B'); // BITMAPFILEHEADER.bfType @@ -140,9 +141,8 @@ static int bmp_encode_frame(AVCodecContext *avctx, AVPacket *pkt, for(i = 0; i < avctx->height; i++) { if (bit_count == 16) { const uint16_t *src = (const uint16_t *) ptr; - uint16_t *dst = (uint16_t *) buf; for(n = 0; n < avctx->width; n++) - AV_WL16(dst + n, src[n]); + AV_WL16(buf + 2 * n, src[n]); } else { memcpy(buf, ptr, n_bytes_per_row); } @@ -162,6 +162,7 @@ const AVCodec ff_bmp_encoder = { .long_name = NULL_IF_CONFIG_SMALL("BMP (Windows and OS/2 bitmap)"), .type = AVMEDIA_TYPE_VIDEO, .id = AV_CODEC_ID_BMP, + .capabilities = AV_CODEC_CAP_DR1, .init = bmp_encode_init, .encode2 = bmp_encode_frame, .pix_fmts = (const enum AVPixelFormat[]){ From patchwork Thu Apr 29 23:56:41 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 27490 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a11:4023:0:0:0:0 with SMTP id ky35csp2015047pxb; Thu, 29 Apr 2021 16:58:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzXrrH7lOHBpVNQnunabDgPo5l4ggVVZRQpYqYW00b5k8WDSXQkw1pxt7u3Chks1IF8RvNs X-Received: by 2002:a17:907:2cc2:: with SMTP id hg2mr1069191ejc.62.1619740737813; Thu, 29 Apr 2021 16:58:57 -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 gz1si1469583ejc.342.2021.04.29.16.58.57; Thu, 29 Apr 2021 16:58:57 -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=DqbCCvkO; 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 B395668A214; Fri, 30 Apr 2021 02:58:11 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR06-DB8-obe.outbound.protection.outlook.com (mail-db8eur06olkn2070.outbound.protection.outlook.com [40.92.51.70]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id AD2EE6802E8 for ; Fri, 30 Apr 2021 02:58:10 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hpTT4iKScgPlB15pNKYz4/UWqsD69ZkxYYSxAskl/046ITAKlCO33g6x5EvuYiGelh6QA3PZhTfu9gtzROZvntYvM5hdNu2pamZo1iQnxUva+wxmpNhzhguxBE55iuVhmMv9X8/1yDocnrJ9WewQSTxdxTYovILtNtEu5hHt0TnSKRxLEOCXHe01gMu7mwucCm81TV4t/EIeTDFPr/+RS75D7LQz+Z60k13cLBDpcX3NEbr3fEE/GfliOcBtHYJSPknFVqKHlxCharp5HHe6hFqKX1S9Komx2tKktrEhn/fGjPr07mvVGHBlSHRGxjtbNySMCuRD3NADKSb54CnNMg== 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=4s+485nZuWmZnI+jlA5Ws+BbyOGTqGlk+0tJredeCCA=; b=B1jc3IS2VhPM4dB0QO+4mxWAY3soJZo7zg3Njh1OpGfUThp8ekQXf8gATBgkjlfWSL12oTUoENmQ/4gfxr/fpDuMNEvkyIU+CjNNoJ8i1LDpl9DTdV8JojlyGYCVIwG3EklPMAapAkK1qF17feJ8PcwGd68CJ0JVGPKeDtbnLZcrQ6WFYtKbDJ3GqUZYBULB2k8l9XPLXqwByTo/IdnIsLu3/PxYqgFt5cQLsqcnMjOCb/sfNiXSDbjT337a9Q2q/+Jl5VTDIjuX6T86sfs1hM1A/0RsHpMAx7evkwlehiX5zXwtJEsV/HaAW1uJZVqtY5t0YPyP/gLG5Kt7+NlQIA== 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=4s+485nZuWmZnI+jlA5Ws+BbyOGTqGlk+0tJredeCCA=; b=DqbCCvkOjIeV1PqQmD3Y8q1SPxU9zH2iQg6GduZm/Mv+l3SVrEyM1lvm0jDaYKusSfUdbMGOK5MqePEcOd3WBquOOu1olk8wTbV5bRNjPEsSQ2DlS7t95TGGdGLDJ/voQ+y1iV30ZY3poeISyhMu8abzEMs9cQKasK0PIe1nnn/pIfWburGA32pM7O2ae+7e61rDs4WKN8Oo+xXJ9NxmaxX5c1nk44iagO/DtWlfAreTQGvthUuqd2HZpZPDjXtuDu8obMgoCCMKkVpmJAOOkaUx2EIkdFbHsPI0RzYEqVvkG+WH3N4+hkBFRV0Rug7DK4cJcGomPrk90EomYbjuFg== Received: from AM7EUR06FT005.eop-eur06.prod.protection.outlook.com (2a01:111:e400:fc36::51) by AM7EUR06HT202.eop-eur06.prod.protection.outlook.com (2a01:111:e400:fc36::277) 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:58:08 +0000 Received: from HE1PR0301MB2154.eurprd03.prod.outlook.com (2a01:111:e400:fc36::4c) by AM7EUR06FT005.mail.protection.outlook.com (2a01:111:e400:fc36::397) 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:58:08 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:E786EBCC0B94D8D765DE134F1D531BB547215B71A6909E9793C0E87E77F97488; UpperCasedChecksum:FE0984EF297C8AAC42A961057707840EC84F168652882577560BA888ED00F013; SizeAsReceived:7590; 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:58:08 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Fri, 30 Apr 2021 01:56:41 +0200 Message-ID: X-Mailer: git-send-email 2.27.0 In-Reply-To: References: X-TMN: [h98a5p/hsPzmCn1iTQChuvDzCTXfEAAx] 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-9-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:58:08 +0000 X-MS-PublicTrafficType: Email X-IncomingHeaderCount: 48 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-Correlation-Id: 0e2b6034-5ab7-4918-7284-08d90b6aa36d X-MS-Exchange-SLBlob-MailProps: gjx25WM8ZNU6XUx7q8EQ5McclV510mdNanTThyki/Dmg1Rk7pZOx3N3XuSQ2Ce1vLJRcVyWdiChzsyuwM9MkydU09qfIonwq2KqQr217wWOLCwr6r+mAwRROeSUgEjS/NMpYR5e4cXcR16efRv91X6w8Xe9mXSdLFRKq85cGGX7Msu2Rm6VNHxEMC5uLFzo86mSue9v8PP7VcCtV3dfnyrTX1dJGLYcRUZ+s9ujYwkm9G9RluIzP/ElQJ86bnv/QgiO+oAmjW2urNFngVkia+nxShpCxqKK4NeJo43640CNckmBEe/HX5gk7/AEUrsBDnIv/qNV39qYSFTQ9hQi4LB8CG8TCzmd5uU2bYEYDdy1FwdSHECWFsNE0vt5DSU93XfvExn0G19y/hDToQVpw1LispLdx9AyuL8xGiolRJeuvsIC1uZ6PhGELrH+SGWkvIrHZkc74AcZr8pwDg3cY4INONO/Hxb57b6yjAMfQBAY0JYI4AntwM43YprIU06NhKQGGTlzvLfKE+qKmd5GUWifPAeIdPbQJMnUQZILYtQdHEKCuDC6iu1oYpgB03P30neLMOF+WPrhgyVJvwclSIz2wJeHuxNb3PDwWjc49EpEMcrrZfbczhj8NK6aGrRKZ+88aUakQS9ajuWZ34IISD3QmJ6nGtclymC2gFU905aDIk8k6/K1rEh+1q3sxNRMRxT+WNgzpuDXoiwdSEM+nBA8s2fncgiHLHQ1NoHCLlwA= X-MS-TrafficTypeDiagnostic: AM7EUR06HT202: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: aDbBXP/6OQ5rynVh7ONCkuGZ/mzD38VU1ylWQzGNafSaVPEFMPxCocjvp0X6ab5MfqRPThw3CLAbj9SewPBZJoD2pn1eKsvvVJlrtpWzs+Rmgz73PUhepVUPQYmItkuU5h5y72mpKhSuxCI77UYr8wfIYHNkbnn67tJKFad1kGFLc0W3EJoPjG9cFpnjAcHNWKHpdaPs9HYWJRHSXAIR8JH6NZGuGX//I3SQ4gPzwIsZxHJ6fs4cqOmvl5fmdpEPvLflfxMC8kMnUOyZ9vQMwBN8PP+vG+smPpaYhD7QTNLH7VHPJuocJMOMpb96ccv92KxwktGDUtCi07Yr8i87eEoscqiwrt2oAz5NyiD4v8P6T2l2FZ1rGi9GAE5iumbtFmq2gkMtDmjjJuWN7D8G+w== X-MS-Exchange-AntiSpam-MessageData: DSif/CFNG3TV/KUYJfVY3KeVFpSBbpnaaYJgmKntjPDxGKuy2Pd0ig14iHkAVReEBEn6loRRr1BAkMUf8q2oMZoIafClqyLazOTmqSS8b7iNur6axnJOXXVPnd7T8mjXAHgK/W87IvH4DeXTRXIvyw== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0e2b6034-5ab7-4918-7284-08d90b6aa36d X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Apr 2021 23:58:08.8102 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-AuthSource: AM7EUR06FT005.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: AM7EUR06HT202 Subject: [FFmpeg-devel] [PATCH 10/46] avcodec/bmpenc: Use memcpy when data has desired endianness 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: FlSH6oapugdk Signed-off-by: Andreas Rheinhardt --- libavcodec/bmpenc.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libavcodec/bmpenc.c b/libavcodec/bmpenc.c index 409564d257..0082ec675a 100644 --- a/libavcodec/bmpenc.c +++ b/libavcodec/bmpenc.c @@ -20,6 +20,8 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +#include "config.h" + #include "libavutil/imgutils.h" #include "libavutil/avassert.h" #include "avcodec.h" @@ -139,7 +141,7 @@ static int bmp_encode_frame(AVCodecContext *avctx, AVPacket *pkt, ptr = p->data[0] + (avctx->height - 1) * p->linesize[0]; buf = pkt->data + hsize; for(i = 0; i < avctx->height; i++) { - if (bit_count == 16) { + if (HAVE_BIGENDIAN && bit_count == 16) { const uint16_t *src = (const uint16_t *) ptr; for(n = 0; n < avctx->width; n++) AV_WL16(buf + 2 * n, src[n]); From patchwork Thu Apr 29 23:56: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: 27510 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a11:4023:0:0:0:0 with SMTP id ky35csp2015295pxb; Thu, 29 Apr 2021 16:59:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxx5Yf3sj1CvsSMU1tV5MA6LEC6NUW1exWedSZRsvMVC+TqMMPeM6d9V9bho8Ydx6xet0ds X-Received: by 2002:a17:907:10cb:: with SMTP id rv11mr1051896ejb.379.1619740759697; Thu, 29 Apr 2021 16:59:19 -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 r26si1395539ejc.505.2021.04.29.16.59.19; Thu, 29 Apr 2021 16:59:19 -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=hW9ReVdX; 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 E5E3168A247; Fri, 30 Apr 2021 02:59:07 +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-am7eur06olkn2057.outbound.protection.outlook.com [40.92.16.57]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id AF170689D92 for ; Fri, 30 Apr 2021 02:59:00 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=eBaq9bB0dBWZQXhIqOHwog93T0ezQnf1NiGDAziYqCAlmIgABspHohFGZZSgsfS+XoIw61Jtq/ASpUQL6Za5FO629jNEkXtcTUFJgJQndCEBkcVvqMG2wbCJbo7SwEm1HIFMklGh4bRWHTrjJ8qu+WA5kZuADi2acWObuNps+X7XOvJpoz6cWIiDwG+nDIIRrNL1dmsxZm9WF6SjWao1inSmvLDGAkQVkrSD7s9poZaxwlYur71guE5nGqXrAou4XDKvW8No9VMzXobwKYbiggp5/ycZT8NXMbRh3UuugZayJxtHYwwel1MDdysZnUn+2beg+h20DSFKK1nKWbRscA== 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=YMX1ysP4lnPdSqwy/QSGYMLhJj3Gf/xULO2R8uAbC2U=; b=Kard2HkHifTXWWTwumOd7xpMtPH8MyoDRXCbjyf86fyy2gSSbSM7CBQmXB7rBKly0CJW+i3/Dko+mrXhoeYcELuJNN2mmp7+w9SOfq3ghnkRvDhLtXGbSvvNx3mKZWtxz37jYeMEh7uGQWR1gD/hPTUPrNe/Lm40yN197f7O7hjYnsoPfmlvCAi041b1TjgfPAk2ruvGAG0cTS0wrSzHCLOad/Y452YHpG7FkejjUEYobGZdE+vEUmCtXTbAGUXyPiX4kQzV+K8r4BjUHM2W+ieheC9Gr+AqlCxHTVKaLshZTT3ACNF99ovSFSflc9dBi2CszoH6Hv5bW5ycQWzsrg== 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=YMX1ysP4lnPdSqwy/QSGYMLhJj3Gf/xULO2R8uAbC2U=; b=hW9ReVdXBhm7dRL7GdMQtNoanzDMJwjHEKLM40LVeTeWifDoHeRpE/q/LY1dzsn5PcV1AyqUHKLoy4SpZNaeI1N1lvRG+iZf655uKU7sIoHr/iGsD7eAMXWeSw4a4wuEhQVFiix5qIuCs9yafYH0F1URAsEfz+hSvAD9C4uSnpOgx9rorkKxfXc9Dn3zGRehgBnFqU135IowRpY90O33Z8cee6GgwepFA0dhHV9i6UgmH4nQZfGu3WtZJZrM7hdRDLi4RHDKLPomSO4+fiiFJS1ZqlEAyRcGjEji9XDnWLkPsit82glxCIdwJRCIcSrtHdwGA7OV5c/Ei2f00WxCUw== Received: from AM7EUR06FT005.eop-eur06.prod.protection.outlook.com (2a01:111:e400:fc36::4b) by AM7EUR06HT161.eop-eur06.prod.protection.outlook.com (2a01:111:e400:fc36::231) 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:58:59 +0000 Received: from HE1PR0301MB2154.eurprd03.prod.outlook.com (2a01:111:e400:fc36::4c) by AM7EUR06FT005.mail.protection.outlook.com (2a01:111:e400:fc36::397) 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:58:59 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:BDAD8A6CAE3B18A14663E61F79B7FE57239CC37EFED4B9DF80BE7CF7C5377156; UpperCasedChecksum:BD09FCC675BB720253433368C626B3616313F08ED33F1EB5F9E83131DB0DE045; SizeAsReceived:7613; 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:58:59 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Fri, 30 Apr 2021 01:56:42 +0200 Message-ID: X-Mailer: git-send-email 2.27.0 In-Reply-To: References: X-TMN: [IhCVacCkOSxn7thpr9khKyf56hSp/hYr] 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-10-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:58:59 +0000 X-MS-PublicTrafficType: Email X-IncomingHeaderCount: 48 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-Correlation-Id: f59eb0a8-0c0e-4eef-0678-08d90b6ac1b1 X-MS-Exchange-SLBlob-MailProps: gjx25WM8ZNU6XUx7q8EQ5McclV510mdNNJ6vQ2SSPtVVEH+bkaPcCJIvziV40z8S54JG8vKsXDXy51RTtfB6feZSLHgAqGgH0IU9OHvSH1gVkF9qULAusjIwnv1PQL3V6CV2TNq0LSx/E7QE9AOX0yW9M5ovcA7tyB0Y+uYqWznoOD4SffFm9T559FF99o77ZjyJMe/W/kdCR5R2t/55m8Z74ROgp6USRiNP04ZuyXZLLdSsZxfI0ToeihWXJzOymqCiKc8HhmdScVakn/WUH6GDD/MDuwsJuuRKIDQEccmLdUJPobekw8u2a7bwxEzk6gaGhbmfRBioiGKtteFnhrbDAEbK/n1n0du5hJw5SGD2/l+wobew+oHrnC95odXq9XZkDD2+N8HgBIXORAp7pYo1MbVyeEMmbbYqOrxvcdCtDtpiMfttRBvwviworqqNgszuteneUjBjgGbVcxdcKNmRKVvQIIjZjIClVE8llEcz7T7zvis5Y3+r7ad5Jbh0a/n7FEqPc32nm4IaLIudQhQu/nestZ7EkVfn1XP93axUBlPf/nVE2nZCaUgN+rQy2rf5JP3/Ji2wC/zfPkOQKW018u6NXGAPuc0Jbtebf+c6QXaMp+DD0Seaf5R8Bltd9RMYU0z2FIPCebiIrLteR3dgCKOQEfkP0Nc0z2teG3FPOfgk3vDC2ekrUOQL4m50SycN5cNuLtFr02VWRvWbA0F6PUMJbPxu48iK7HsTKg4= X-MS-TrafficTypeDiagnostic: AM7EUR06HT161: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: QEDwwjL74dozhM566yJOyjFRnyxJIUdOLFaBYcsIy44FvODpo9Ygg9yUgV4kSzrmz9IvI+971D7vZCMmCmf2z8I+jT6mrSA7Y3wBsgsVdcQgVu20PICAE64WYLQvDxieEhsBofp5LKHRqfcLKp8ATVQTPLCd0qHCsyQ39Y2UA9V/6nmRGV2NpiWcgSWfFsIhZIVIxRTYuYCmQ7aIqR8a+UiXV9sm087VUxKvM4BFsMzx6FHAVdUFLK1dtI5rh5Tux5noKH/6eKui6T8MMxGvrfZ0C9U/+aSCH3JyTYiIJcM1zbI6oChAza5Ci74kYmg6ENfxbQNY7xI+z/Ug5kDMhQ5zWduNS1gBOBeN6YZLWSWjf3KQb0CpFKw0vpNFiqo52TnKAj5RJUpIfrySJr9dVg== X-MS-Exchange-AntiSpam-MessageData: /jJGQYCrm19kEsSFz6A8qw3niYxv2FT9OVeFeHHhWNhJaALbkIFGLKUNYbtlkMYHSUtGjbcVZNONU6xW2Lh/bMN4AoSUGWWj5Rik+E4hxK6EiJHIuVqgEPrNIPnpPE4jDw24vK4zlGpM4ma+eWNuew== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: f59eb0a8-0c0e-4eef-0678-08d90b6ac1b1 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Apr 2021 23:58:59.5518 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-AuthSource: AM7EUR06FT005.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: AM7EUR06HT161 Subject: [FFmpeg-devel] [PATCH 11/46] avcodec/cljrenc: Don't use too big buffers, don't copy them, set CAP_DR1 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: muj8f614dGGx Up until now, the cljr encoder used buffers that were too big by a factor of eight (probably bit/byte confusion). This has been fixed. And because the needed buffer size can be easily calculated in advance, one can avoid the implicit use of an intermediate buffer and can even allow user-supplied buffers. Signed-off-by: Andreas Rheinhardt --- libavcodec/cljrenc.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libavcodec/cljrenc.c b/libavcodec/cljrenc.c index 6f04c62cb0..15fe43e073 100644 --- a/libavcodec/cljrenc.c +++ b/libavcodec/cljrenc.c @@ -28,6 +28,7 @@ #include "libavutil/opt.h" #include "avcodec.h" +#include "encode.h" #include "internal.h" #include "put_bits.h" @@ -56,7 +57,8 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt, return AVERROR_EXPERIMENTAL; } - if ((ret = ff_alloc_packet2(avctx, pkt, 32*avctx->height*avctx->width/4, 0)) < 0) + ret = ff_get_encode_buffer(avctx, pkt, 4 * avctx->height * ((avctx->width + 3) / 4), 0); + if (ret < 0) return ret; init_put_bits(&pb, pkt->data, pkt->size); @@ -89,7 +91,6 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt, flush_put_bits(&pb); - pkt->size = put_bytes_output(&pb); pkt->flags |= AV_PKT_FLAG_KEY; *got_packet = 1; return 0; @@ -114,6 +115,7 @@ const AVCodec ff_cljr_encoder = { .long_name = NULL_IF_CONFIG_SMALL("Cirrus Logic AccuPak"), .type = AVMEDIA_TYPE_VIDEO, .id = AV_CODEC_ID_CLJR, + .capabilities = AV_CODEC_CAP_DR1, .priv_data_size = sizeof(CLJRContext), .encode2 = encode_frame, .pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_YUV411P, From patchwork Thu Apr 29 23:56:43 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 27517 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a11:4023:0:0:0:0 with SMTP id ky35csp2015387pxb; Thu, 29 Apr 2021 16:59:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwrA0lDpTejKPeV2Gj+zx/qUVgiEvbijxrOoIr34pwGK+doQe0hlIC6Q52LiwOoIMI/qit5 X-Received: by 2002:a17:906:31c6:: with SMTP id f6mr1127356ejf.446.1619740769309; Thu, 29 Apr 2021 16:59:29 -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 jl6si1475130ejc.751.2021.04.29.16.59.29; Thu, 29 Apr 2021 16:59:29 -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="KPGt5h/Z"; 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 1FC9D68A27E; Fri, 30 Apr 2021 02:59:10 +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-am7eur06olkn2057.outbound.protection.outlook.com [40.92.16.57]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id D400C689923 for ; Fri, 30 Apr 2021 02:59:05 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fedUcHDxV62vDudJLd1FA4PoU1LuqQ/cDb9wLRGSLshSviCPyZiZtg99JebJDD2Q1UfcuhR5FwALsJZ+C8d8waE+2ORqcoFegzXFCFFXiaQSQmyMyVZBDvjtRbvot+lLoa+ZL3EPA9Uv8F0uRVqxBvvRGVnibexToHtCySxGh7s7Jb2SrMLcgoFLiopEUQZemrTfk5QwNLKmpu5X6f7aG6kpjtbXQwRIgWiZGQrmUDkUn1OLrw+RoohJfpgSom8OAibpARP2iLHKgu1xiFiIN7pC8KUHw8HQLWdj3dXk02tmhWNUX2S1XsQUAOf99xtJW7AXoLTgJ+NmN0WGSm5Mfw== 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=6enY6bvHuEGxssJ1yR89dxOsLW/WyK5gCENK0Ubxco4=; b=WC1Bw95ZI1WN44EkwkfXece+gP9nr7XK/weRPX3zLOnBkv3CSvOCkYx0kkjVg7ntAr+bPdeJ7/Phusp5xXlIOJnw+XAz/bu4thcVpzl3Qrqfv9l2pL4glHMD7I3Tc9cvVh4L5peLCZIIEBUfGH9Fw3D1Lq6xDn+if1ZuhIwaPiTZiTl/9DAYSKxZTOutrUPsm7xDTSksT3cGtvW1wCBKQ29NmqODt2Buxed/CUfRPQstmpu9KaMFlpUvfeitZCzMp9SBUq43PP38TgsPx6kkCH5uFrTZebvWr4jualGJ2zxgM0yXZEsCBX9I6dp+4uK1tMpBw31GOyRGuMmh4+4Czw== 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=6enY6bvHuEGxssJ1yR89dxOsLW/WyK5gCENK0Ubxco4=; b=KPGt5h/ZEtFxnoGXGZZBCeq13pLR6ZOtDCoUP0gXKtvLSMQ/osE4cmc9Bp+peSa8fE4AvA58KcLFLrVg5NiTsGpEkumEDyXpJmVKWFZPvGYhXYXZBGKJi4XZo5WynzMWmAx3gg68SwTBp3BX4PZHgkj4tpuH9AGGqYagh9pfxaTyQvQEaHEJcyaWrwZc43CDiaoI2VRK7g6hCouDt6h8RHo/QdK1AK8eu9RhqADQeijw9fCDbpIMtM7j+z0YYFNbm65IZ/BCyTkEdYvu2+K/axmjpdNhkX1TJ8PyZqMyaWXzkM56z2gA2TF+i+OQ/DWWSzexQNYNtTJ4GKGGw4zE7A== Received: from AM7EUR06FT005.eop-eur06.prod.protection.outlook.com (2a01:111:e400:fc36::4b) by AM7EUR06HT161.eop-eur06.prod.protection.outlook.com (2a01:111:e400:fc36::231) 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:02 +0000 Received: from HE1PR0301MB2154.eurprd03.prod.outlook.com (2a01:111:e400:fc36::4c) by AM7EUR06FT005.mail.protection.outlook.com (2a01:111:e400:fc36::397) 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:02 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:2158E5BC58692CF2403B2059FC83EF11906FE965E86DF1652D90BCE02FA0550F; UpperCasedChecksum:A0BE9C187CCFC5EB6CF07E4EAA22F6B385DBA7A325EEDD242782EB7953E2C355; SizeAsReceived:7584; 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:02 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Fri, 30 Apr 2021 01:56:43 +0200 Message-ID: X-Mailer: git-send-email 2.27.0 In-Reply-To: References: X-TMN: [v6vUMEwg3JvIe46zNwDniNbi1EEa69gS] 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-11-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:01 +0000 X-MS-PublicTrafficType: Email X-IncomingHeaderCount: 48 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-Correlation-Id: 0d7d6258-5d9c-4f37-1768-08d90b6ac31d X-MS-Exchange-SLBlob-MailProps: gjx25WM8ZNU6XUx7q8EQ5McclV510mdN6KDHjc5pS3uOisJjw15TVI9JpOTYqbzmSAohjGKFiqonkdgQ0kMC/BmgYZ4tAyci0hD9h3+HGEr0yFJEqIUv2WL1ls8UxfA3pU07m9ucvwA2U/JJeJO/vh5tfeqOqMl3Jm/gJz4k8e9l9vwTvGXafv0IxH+bpt29mxboQwZXKQrAU408N+4fKjEpXSqfn22CauyK2CbW2Oa4n6ro0ek+K6BNOITlq22ATgDL9glyAWuJFN6LIXRw96xbJmI49QslWm1xZKKnI0uVkN44jAYxo7TMM4aZ+5R53wdZJ+0W1nCnbe/sTGLaVtsP9dExFBj3l0h5Y4VI0bUp29gE/bUvRVfp7/y3+KKn8ipHf1d2adTqbjZ9n+OrGFyFGiU6PvX4Wm7FLnWLX4xn1W5jPqI1o5kmSF9iOTGXL2PqyOGLtzJDGk1HpaxC3KdOF1p8vqsAvzi5RddIZlHDRFxn2JjH0hEPPG81EqDDSui9Lgjekv4SgwIQE/qFcMDRoV+ynvWBF5Zpa7KRVt5cY6NolEA33m8NuLbXtymqEoCaglmJkPd5YTxPmx+lCGPJA6MA4SOEZZBYtlFC/+khM31+9thuMDboaqc0WrzBrQQQJK9mWy2gMvSv2AAKmReN/OTg/eBbS/hQE7hPOYcOf5mVcjhnrAACKYi0qhXj5hF8D+vIUHEBfGrPgR07cfRXhpIkf85RbhTJf7lDH8Q= X-MS-TrafficTypeDiagnostic: AM7EUR06HT161: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: VF7dmJWYhpFlHGJpAiXyguj84blnlSb2+vv+/P7se5ya+GfqZmaj5g5jvX/OthizlLSh9uKaHKpIlgThtQIa6AmH6sM1RlL+Pr8aNM4c4S+qZIW3/3FMP+gkbaNgnkzZMce6UUW0oEHk0LDmPXy7+Ayw7ACqc/vIfNPga3c8GR0wIfnkzye/7czxOAC946Dh9AgZsTF8Itp5/vrydDZ00OIh25TMjcosgWfE3ITwWuZ8s9BB9h1PKLDemeidjixf+CenUAIMRS59UQYVxn5D+iNDK8hCGzUCt5IZXh5CpyzH4O5N/IJvfGGuoL9YdssL4k8v/lC23tvlFgb/xje6RClWxwwJ+cA6hVObY5bY7jyptrZfTcghSWu/U7geiOV43iskTjPR7oVxOdfPZYxVmg== X-MS-Exchange-AntiSpam-MessageData: 9Rrcb8zfC92yu7D3DsHHLCAM8PGU/Iom+1M6Rv076iXKFcNJk1LlqnPHfoVBsfK9cZArNrbJMQC2pjtJtcAtQ7XnLEj3BSQcdgpYG4JMYEaDVHbnG1J52g1Dg+7Ug2bqcbD69kEbNwVtiKA5glG2dQ== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0d7d6258-5d9c-4f37-1768-08d90b6ac31d X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Apr 2021 23:59:01.9797 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-AuthSource: AM7EUR06FT005.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: AM7EUR06HT161 Subject: [FFmpeg-devel] [PATCH 12/46] avcodec/cngenc: 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: fIxxkNftcee4 Trivial for an encoder that knows the size of the output packet in advance. Signed-off-by: Andreas Rheinhardt --- libavcodec/cngenc.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libavcodec/cngenc.c b/libavcodec/cngenc.c index 55826c75be..f37d586744 100644 --- a/libavcodec/cngenc.c +++ b/libavcodec/cngenc.c @@ -23,6 +23,7 @@ #include "libavutil/common.h" #include "avcodec.h" +#include "encode.h" #include "internal.h" #include "lpc.h" @@ -73,7 +74,7 @@ static int cng_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, int qdbov; int16_t *samples = (int16_t*) frame->data[0]; - if ((ret = ff_alloc_packet2(avctx, avpkt, 1 + p->order, 1 + p->order))) { + if ((ret = ff_get_encode_buffer(avctx, avpkt, 1 + p->order, 0))) { av_log(avctx, AV_LOG_ERROR, "Error getting output packet\n"); return ret; } @@ -105,6 +106,7 @@ const AVCodec ff_comfortnoise_encoder = { .long_name = NULL_IF_CONFIG_SMALL("RFC 3389 comfort noise generator"), .type = AVMEDIA_TYPE_AUDIO, .id = AV_CODEC_ID_COMFORT_NOISE, + .capabilities = AV_CODEC_CAP_DR1, .priv_data_size = sizeof(CNGContext), .init = cng_encode_init, .encode2 = cng_encode_frame, From patchwork Thu Apr 29 23:56:44 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 27527 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a11:4023:0:0:0:0 with SMTP id ky35csp2015197pxb; Thu, 29 Apr 2021 16:59:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwD7bC1aTXREcGo59Ys4uX0ePW+kCQvTP3UqLLDTmhxVOQ31+fUPt3ANNDWUitXxzx/3sg9 X-Received: by 2002:a17:906:a212:: with SMTP id r18mr1090601ejy.438.1619740750392; Thu, 29 Apr 2021 16:59:10 -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 n8si1418609eje.94.2021.04.29.16.59.10; Thu, 29 Apr 2021 16:59:10 -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=lwDtroRD; 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 BEC84689923; Fri, 30 Apr 2021 02:59:06 +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-am7eur06olkn2028.outbound.protection.outlook.com [40.92.16.28]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id BB37C689D92 for ; Fri, 30 Apr 2021 02:59:04 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=UnVvC9+88HCG09gBnA1AygVQ8rgWqn0q+pl89+AEj9/2hvWnTTe//TyTKEKV0vi4IkLGfz/XBmM+Rv3MNnpEsq7rz+ZCMqbZ7cZ751z5ZuyT3eYBwUDKT1pAweHBYKeUVXDCpFcx/vqBW7SuI1ewS/m1X0u4RvovCJXXyjjnizqkogSQzC5mbRfb1FDl0nfGycx4tuwkDX2A1koIa7NbPv/Ag8qV/FyjQ6RrCTUK/DF9TUJjrbGfy7MXHIWmh14Y5knrRlOcF+NFui8CuGsYJw7/Mg3jBbcmyZkyLDM9o5+Fb5Cg0RDh/iflICV7GzDOcp8nWMvwsUTNDkqqK1vGQg== 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=a83prdD9ZEpIXc1pdgjQbtA525rh37rKB5RDdVOamxE=; b=PnxFHkWXGrwfbmVxiwqU3JluqQREb/LfJ+S9+xFiitYNmvv6eOhAuSRqR9liUyHlUTH33fWU3BwWX3FG2vSHxNMriS3t5gpZ6odPNLK6nA4aUP3RHjDN1Ngt/Or9Sx+9O+7o9I629nbYpq/yDreI9lJzR5lXCiCcLZRBgQUJGSS9ENib+V4Z8k9EWLTVhcM5syBPCzGn0Li5dnV9Xjo6Nv+J7oBqcHUkec7wIf/FbaqLheZgYkGiGgThjMVk+U0leyQLNfUDVsmH2YBv8JxmlZsd9E4uhUoyJ4vIgFF75pQMb6RppC5YMw/J9uwWQzZe02IRiTfTSSUzOBCfjwPNxA== 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=a83prdD9ZEpIXc1pdgjQbtA525rh37rKB5RDdVOamxE=; b=lwDtroRDzk1/izwExQK1kOkxjbg5IblhxbHWRHO8MVfHZ4gLugZ/sYErahyoog5rQ3MERI29r8DtNQAWlWmzXbyRcwy5j0agwzq5UwFww6MQTJi6azX1X6OuLKfqhZl/DPQZe0rgBsuB6y9DQvoYsbtIaxoqL0UMtEDTkKHT7/0JbEHF8OPA/6afV3s/aW4e3quZCQl6b8MevVZLo8Ecnu2jjKOsmjkYkTcP0mTzYIwz47naZFoCMlE1tzHYutVW+mXKmemNpLfoVRb158gtTl+c8eL1NywsOCuM4au8z/s7mIqErpNJmPTblwyeRjxYORtl4Zvxd40HMhGJ2McF4Q== Received: from AM7EUR06FT005.eop-eur06.prod.protection.outlook.com (2a01:111:e400:fc36::48) by AM7EUR06HT193.eop-eur06.prod.protection.outlook.com (2a01:111:e400:fc36::299) 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:03 +0000 Received: from HE1PR0301MB2154.eurprd03.prod.outlook.com (2a01:111:e400:fc36::4c) by AM7EUR06FT005.mail.protection.outlook.com (2a01:111:e400:fc36::397) 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:03 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:B448FCD254490579E47E65C9BD89E6FBCC31F6017353080BB620A781B7D62437; UpperCasedChecksum:5662ABD071C42464A6DE9F73812A87F4A9DA15D8CEE58026A325509C8D9A6A9E; SizeAsReceived:7587; 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:03 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Fri, 30 Apr 2021 01:56:44 +0200 Message-ID: X-Mailer: git-send-email 2.27.0 In-Reply-To: References: X-TMN: [+l2Lxyl2FNoubCOYLlr+M1gEwxPNIsGQ] 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-12-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:02 +0000 X-MS-PublicTrafficType: Email X-IncomingHeaderCount: 48 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-Correlation-Id: f1488445-a004-4ca8-2df9-08d90b6ac3f0 X-MS-Exchange-SLBlob-MailProps: q+fD6XS3/UIO6YRda03MtHguxZve2k0PBhLqNIYdEBDm2K1NQ2qk5t6aF2HghZn4UMEwW5DgFW4CKD5hSFwYMxDlfCDTiaJC/aI3waM/AI44BPdx54b7Tjqg0H6Jrs6qx+38U4aZh3Y4cg/A3Uu6JOgTD1Sa7zFEvQpjVQGK11cYMPsoy5z7UsESqKw7Aei7X4e469Zhc+PYD44WPDpL1ofc7r0//Af72Unuy0kdKyOUm9MLlfeBJJDvugtIyYiQPGtNR9w6hMpBWcaOta/Z3eEPC1cFHgEdppSDzz+niUTxUaZC35mviaI/MP2buGPdEqnVJsTvHXMn+2fHecQVhUyPgegSD60RlqQe2H7qbIfHxteGvoAns1IZTtWtDghtVnp+vU1Ptko0DXiiNY55mmpY/bSAzjXwUMFXkL4zQlSWyfJAQ9oZh49W869RdqHcEIrYhjKS6OYbg3HKi/rIZaGSscrFkRDY9i9NzP3fUx1ITdZX3x596RRTRINKZmypcgtMEGkfYCCiUyJhieTwKZXKDkDlVD6SOK+EN75h41xojLncY/CcQkw15W9TdmQXNP8JgBRMs9mqznuYl2zP6VCbGjIAMbDP+lsDAH8NwT9H+Tl8KJm7wpTjyceeh3B6oSRfFx30vChK6M9Kf/c6qss1r88FZE+zxDAhLc3iXRysrNrM2cMCyAl2NywSc0Eq6ilRlgJaEQ4uZSSlknxyNg== X-MS-TrafficTypeDiagnostic: AM7EUR06HT193: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: csJX12MYTFy4tJ8Jd3ATlDxUpMfIapM4b7BDd71dUDyG+r51QCjYwfIJz/rGsiewBtjPW8msKe9A17fvrceSr36UVApe3dX/cSbz/r6FlqIavpYRS/bWMB20pg/mXDja5pHgwUvfMQ6QUQFT6gmG5C9a4jEniPdgsRJ4M9Qxe8g6AM1g0bM6T45gduowkE+EGq9CTZJdOM6x9/Q5J59GXDMcuVYl/wuJEm5nKrSIQhuMaTWUBoeFveVWGvyIYkUGQvd6Qs2W1wSoomh2HGLWq4knFinzWIbuZPAwq0d6Npcq0Gk0ZzIe+49zh0fifz+/KWsWiI855cI+7a7DcdizFa6envZ9JGp4kzzre3tqOO3adhNcOdcyneMhVqRfIN82q/1+n5qIOGk2E5YUteSdyw== X-MS-Exchange-AntiSpam-MessageData: su3KE8IHmT9uQOxq7EtiHhSIV2nmhDXXV8LuPSmohXWa95jSRsStz7o6/mQoHb5DShpcEs+qvg/gut3DTDP4AiOpvX06NENdWmcvnVdWIFbhCJCaNpaTnMoKihovRMoTVT01ao57FkcTEned2t8dfg== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: f1488445-a004-4ca8-2df9-08d90b6ac3f0 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Apr 2021 23:59:03.3761 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-AuthSource: AM7EUR06FT005.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: AM7EUR06HT193 Subject: [FFmpeg-devel] [PATCH 13/46] avcodec/dcaenc: Don't write one bit at a time 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: 9ElC3zD6q9PA Signed-off-by: Andreas Rheinhardt --- libavcodec/dcaenc.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/libavcodec/dcaenc.c b/libavcodec/dcaenc.c index bd08ccd331..76f1f141d1 100644 --- a/libavcodec/dcaenc.c +++ b/libavcodec/dcaenc.c @@ -1206,14 +1206,10 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *avpkt, for (i = 0; i < SUBFRAMES; i++) put_subframe(c, i); - - for (i = put_bits_count(&c->pb); i < 8*c->frame_size; i++) - put_bits(&c->pb, 1, 0); - flush_put_bits(&c->pb); + memset(put_bits_ptr(&c->pb), 0, put_bytes_left(&c->pb, 0)); avpkt->pts = frame->pts; - avpkt->size = put_bytes_output(&c->pb); avpkt->duration = ff_samples_to_time_base(avctx, frame->nb_samples); *got_packet_ptr = 1; return 0; From patchwork Thu Apr 29 23:56:45 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 27498 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a11:4023:0:0:0:0 with SMTP id ky35csp2015505pxb; Thu, 29 Apr 2021 16:59:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxm6MWJ7xa3ybOGlJV4+bOjweXh0X+eMlOIuiOWUnsz66mr835KlPKQyusoxMThUC4tNnTK X-Received: by 2002:a17:906:170f:: with SMTP id c15mr1097379eje.358.1619740778689; Thu, 29 Apr 2021 16:59:38 -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 h16si106393edv.35.2021.04.29.16.59.38; Thu, 29 Apr 2021 16:59:38 -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=hYqz8Str; 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 4007968A2AE; Fri, 30 Apr 2021 02:59:13 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR06-DB8-obe.outbound.protection.outlook.com (mail-db8eur06olkn2041.outbound.protection.outlook.com [40.92.51.41]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id B1552689F19 for ; Fri, 30 Apr 2021 02:59:11 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jzrumh99fb0Xa+3bGN3o7nxcc3/5RpqAo6voa7zYPb7WPXz/SvNVjVc9uHZcWDdI7cyrTa2rbCPqqeqexBMs/+Rz0apSovCZiFPQ/KF8uIQcnhm/eAG1nyxzwoCN+/uh73jFw+GN8uNwYtZZYxzn1kyMu/YnUiNW9WIf5Np7Il1idnZ+anUonGAO6OmVKuRSEvJWUDzODjkbRo1TRmlSNHMcslBMJvsRKpR/4z5xM7l2vbEfoGI+DM/eAam4ixs5FdVhkWBXopOmCjOtA1CIC74pNLL1choyRuLyn4eALb8Dw+XKQB9RYxCi2I1LOJdjfJsNlaI/ZV3v97aO9no/+Q== 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=i6A+aUWd/imrvhNOOFOf+1Esc6a4EDbObO2ozKoiui0=; b=XJY5w8AHA3tq8Ps2g3R0wzHiVcX+yuCsGQ7Kiao7QjLMifjO+Ak80PyCOMhq7PIHlVJejGD35TXfoQMID2Doi8dZDyEJ0q1jdv70f6APczMsRnRrMflHNWGhhiqxdNax6NRt0yPaTlgQHs8DkNiYF8rkWH5k/bH22wnbr3W+jyI/T65unZEHza/QsICXCmYXQHcm8GrZ485wniejJsr/oV5G3paoWQ+KonPkJKPjD20KjuDeYTO4iEy7yBcDgvGfJz0hQihTNCr6+l6PE9j+i1hMhvYYgT3TCwOD5W7BhuRcUdhValyv88ALwtMv1tm2WuSVfm1+00i7jeducJjbng== 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=i6A+aUWd/imrvhNOOFOf+1Esc6a4EDbObO2ozKoiui0=; b=hYqz8Streu/Z38UojX6+AMFFWPtRbxChPmNjb6xd3qxgYuxJwbTugqQJLyyEJpFpabuONfszQQCp/B/0i4YnhMxAk25/Nhn5qG4klwKbfh3PPK7s5Szl4tZRChUqLnUZAjpbV/3sJmv50uMIdIlAwJ0aoVMYk/BeUwr67r1k2TGKg1Urqd1jvJ7akK0rD+oiroNgpUFeuLGlkCFu+UpIWiuvYuig3JkVKEZNEiYhxz9SoX7qA9eCgkrebl+3E1vWZGtCJ2xKOBJDKg8Gt0c0ueGaAYBESdlMvnfe3CaqsQmr8gvGjiS5hpecbN58TYE8cz2Io7xZ6hwe+IXwQf8k0g== Received: from AM7EUR06FT005.eop-eur06.prod.protection.outlook.com (2a01:111:e400:fc36::53) by AM7EUR06HT213.eop-eur06.prod.protection.outlook.com (2a01:111:e400:fc36::137) 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:10 +0000 Received: from HE1PR0301MB2154.eurprd03.prod.outlook.com (2a01:111:e400:fc36::4c) by AM7EUR06FT005.mail.protection.outlook.com (2a01:111:e400:fc36::397) 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:10 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:609ED2B8972E4993C25CF39764F49C7C282066893DAE32261B6CBE4EB996B648; UpperCasedChecksum:7B7063FA688E48E981DDCA41BFBACA263649977DBC4681A6CC9E68CC9BA89B0A; SizeAsReceived:7610; 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:10 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Fri, 30 Apr 2021 01:56:45 +0200 Message-ID: X-Mailer: git-send-email 2.27.0 In-Reply-To: References: X-TMN: [b2FDhagjjJscG/+2LP+iww3rtrZMc450] 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-13-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:09 +0000 X-MS-PublicTrafficType: Email X-IncomingHeaderCount: 48 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-Correlation-Id: c1443d3d-258d-49a2-0ad3-08d90b6ac81d X-MS-Exchange-SLBlob-MailProps: gjx25WM8ZNU6XUx7q8EQ5McclV510mdNSQ6zVwN/I7EX+rk7h1h8roCTGdsyjXMArBwxX0cv8ZAYALSTjF4VUUAm6tCpDOSEvvLY9pBm6CCsepI7oX4RuzmOJCiVqnRfWtyAwzCk3BZmajqeDBLzFggGumyM7gSCaz1IsFlaR6fyveGEMa/ftvvF3CLqNhvxtQj93tkx8bYktLRtsffbEcuCwbCgEAChQlqwe+EyB2rpd666Itkf1CMWsSeJ409T1HiEdAmsMnTdzMlfXs1fiCwUGZ94aN8HTehk27SOqkgYn4niHGFBAVzJZX5m67P7h6PXRa0M45iaBCoHDVHWJmOR2HrWqHtVI4JQJiBkA3TBZ9Vk13DwZI1YB6dyKK4WWACCgdbdWTIPH8ht++AL3tBs78IrrYMPtOTcM/zqgQXuoN99hLxnc+ckMX8EWgVdYqRgARD7Ut8NqmY1aXLxV11jb3XTCjvpD6G5NZ57cYjNAeZgMNG6DV1vVsBoFY30zebrr2rmDd5M0+i7+3e0jZ808JAr5TkEutNNdn2cLJeXejBwrmJP8hh8tWPfVI6zLba/grhdCaHZIRXbHuHs3DYKCFZIEetZ/RHAVH3RE4Ow6e2VGw1koTzJzYLgLmE4ySO1qbF68cd0zMDDLGuHnwIhjZvIBzm3ViJ1eBaIlpy/v3+tjKHPkpcSe/uCCd5I/9j7fj1Nxp4Ar1hq1TS1H0vgbU5tnnmbesbZIgFVTHI= X-MS-TrafficTypeDiagnostic: AM7EUR06HT213: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: TfDzM9Wh4R5h3hGGlnfwKD3KlAvSbRaR//89vFFv/Uwy7P/RzWz1cYkSsgPQ7aFBROmNmKM/i0QccNoyEd7jxUOfu3JVVCacFavs/JKcgFFHrAAdYxuEXt+PERhkwh60CJ5clXbujzrHDMFcwQcP30DhPg3rEct2D0Z2ii4fmB2GDvwoU7IkxwlvfnNaAu41nFmFQ8jKdo4Pusqp2nkXgrH9FLM+6cWAEj5ocfh+eGwUjVAkgybdFaAXLPAHd84LmIOdkI/3h1u7TU7hYh5es53DNqht9VFAuvQEQKu5dainwT0pzSGJDgalI1sGWIXgAZbcSBqEcS5fbNGhCYtTTVMgLDPgcbRZat0DRnkEJPnkqZnrBTSay9RyfsxPEslhicur10i+mHrQylsp9xBbJw== X-MS-Exchange-AntiSpam-MessageData: wjhagIpxqRRjhvc06nwc5HFf4r3DIiYnIu6RzUWkI3tWS3WpbwU/7S2zJlcN4dYwMUqyvtEsRwBcQ02ESSK1OPg+oKkRH9IGs98Kcq8JaVG+Qkoy8UauinlKTsCG+v7EVqwPNvzvnPGxbmYdlU/fvA== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: c1443d3d-258d-49a2-0ad3-08d90b6ac81d X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Apr 2021 23:59:10.3220 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-AuthSource: AM7EUR06FT005.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: AM7EUR06HT213 Subject: [FFmpeg-devel] [PATCH 14/46] avcodec/dcaenc: 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: iL9pOPi/Nk7d 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/dcaenc.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/libavcodec/dcaenc.c b/libavcodec/dcaenc.c index 76f1f141d1..71a76bc356 100644 --- a/libavcodec/dcaenc.c +++ b/libavcodec/dcaenc.c @@ -37,6 +37,7 @@ #include "dca_core.h" #include "dcadata.h" #include "dcaenc.h" +#include "encode.h" #include "fft.h" #include "internal.h" #include "mathops.h" @@ -1182,7 +1183,7 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *avpkt, const int32_t *samples; int ret, i; - if ((ret = ff_alloc_packet2(avctx, avpkt, c->frame_size, 0)) < 0) + if ((ret = ff_get_encode_buffer(avctx, avpkt, c->frame_size, 0)) < 0) return ret; samples = (const int32_t *)frame->data[0]; @@ -1239,11 +1240,11 @@ const AVCodec ff_dca_encoder = { .long_name = NULL_IF_CONFIG_SMALL("DCA (DTS Coherent Acoustics)"), .type = AVMEDIA_TYPE_AUDIO, .id = AV_CODEC_ID_DTS, + .capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_EXPERIMENTAL, .priv_data_size = sizeof(DCAEncContext), .init = encode_init, .close = encode_close, .encode2 = encode_frame, - .capabilities = AV_CODEC_CAP_EXPERIMENTAL, .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE | FF_CODEC_CAP_INIT_CLEANUP, .sample_fmts = (const enum AVSampleFormat[]){ AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_NONE }, From patchwork Thu Apr 29 23:56:46 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 27497 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a11:4023:0:0:0:0 with SMTP id ky35csp2015630pxb; Thu, 29 Apr 2021 16:59:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxK1jCr8DvWOW3DSnUqz5vouvR9WtJ3VHrPxZa6hCyj2hwmoG4tB8kBHzB7OlxNAhhXyJpv X-Received: by 2002:a05:6402:234b:: with SMTP id r11mr2512365eda.137.1619740789372; Thu, 29 Apr 2021 16:59:49 -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 n11si47330edy.507.2021.04.29.16.59.49; Thu, 29 Apr 2021 16:59:49 -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=s03EG4DN; 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 5399F6802E8; Fri, 30 Apr 2021 02:59:14 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR06-DB8-obe.outbound.protection.outlook.com (mail-db8eur06olkn2031.outbound.protection.outlook.com [40.92.51.31]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 0244168A28B for ; Fri, 30 Apr 2021 02:59:12 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=npFV/ftcZwVyZIGAB8XGkU6wSuCUHw6HT0nIeW1rUoi4HYNZJi2rfn3GiEWSD5LlEoRpHewGuuLmxa9ixxjcKJ7i3FvvabDrUhoBY+35YrZJbkbEdqCXF+bvpKthX+a4oCjePS7otEHX4s8F6fQPcktGPRdYLVDGTpcJ82syOIMADP5Ki04dGPU1+BjJ/BHR50vxllBb66yHrhc09ADzkg+fFCfCBNjYhLSdxvOv7Ak5Z5LTKZqh+pLVBT4xinRtRpXW6lonXvDZb2NTkLfPEhgoR0FinbrlMUWSE4kRmtkcvL0jJymyT9ff5jxKu+UylyguaNrQI5mpHta/ACuHTw== 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=AJ6oYgpRfyFgytqTW4m0HOTCXbuKNjUebpNCSU/rMUI=; b=FENUDKdkxzbL/v9n1j0SZFYy3Xe/L1Pmyx2/4qW68ck6NRZYKbmhToz/HQ3yuPi4h+JaZzxMKypyD0WfPTH7EwET2YH4A4tH6+eEC6cNXxWZuaC18V5FbBFT6OJzsGW9n9xyJrbrHY//CM+KPHc1NNVTVyw5Y4LU0HGbWXzehBkOpPoMIc8AlbJF22636coWETRmUP9LZlD3T7APOW0pZ8Qkjcu6wxnsjFfP5DDJZKXwKrb8KXe76VQTG7bdaI69pOQHAAAFEzqNB2Y8QEq73Ykf5DyF6zCccL7V9J8nGEANEqK4OKsWQGYRe1hf7D2YqPwdclgWNU+y3uFROHsBmQ== 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=AJ6oYgpRfyFgytqTW4m0HOTCXbuKNjUebpNCSU/rMUI=; b=s03EG4DNoQDOCHO9zhbP4nTT1nwnjOSUvekCjrs4UgBTNQws4VUeg2afhUWkzY3j6TuryBUyY0WHe11Czq9J5isewfOcKfMNkUygciy8RQPV7M+UTAK/aQVFjm2sO8GnOyUopcFhfuAKuNSvwDdbuKkXNDaLyOXdKCjfWSNuZmMjSL1FihPXBtVfUIJr8ImbEWxacSi+Vawo7Me/aF0CBc3ZLCbgwkLRW1Ng6Kj+KxPszainDnf/spHw9hMj7l5t4VdTGKKUyj+IFVwGN/wPbzonHD8XxgXThUWn4VojcaEOPQlsxUH9eoAfdNVTqc08mz9bLLYvuYSCGTfQLXBh5w== Received: from AM7EUR06FT005.eop-eur06.prod.protection.outlook.com (2a01:111:e400:fc36::47) by AM7EUR06HT099.eop-eur06.prod.protection.outlook.com (2a01:111:e400:fc36::209) 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:11 +0000 Received: from HE1PR0301MB2154.eurprd03.prod.outlook.com (2a01:111:e400:fc36::4c) by AM7EUR06FT005.mail.protection.outlook.com (2a01:111:e400:fc36::397) 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:11 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:BFB9DEE9740FF01D7441E348BB5B61D78C38088A1ECC2751E79D7A81C966FC16; UpperCasedChecksum:A0C5936F0CE7865DE4C0A1157BBCBD08E231C5FC0B8237D8FBB057BDA767436C; SizeAsReceived:7604; 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:11 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Fri, 30 Apr 2021 01:56:46 +0200 Message-ID: X-Mailer: git-send-email 2.27.0 In-Reply-To: References: X-TMN: [YqqnzEm8ZGCuriqYFr3A+a1Ugdf9hlNN] 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-14-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:11 +0000 X-MS-PublicTrafficType: Email X-IncomingHeaderCount: 48 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-Correlation-Id: 92a5c9d1-3564-45b6-f137-08d90b6ac8fc X-MS-Exchange-SLBlob-MailProps: gjx25WM8ZNU6XUx7q8EQ5McclV510mdNSQ6zVwN/I7EX+rk7h1h8roCTGdsyjXMArBwxX0cv8ZAYALSTjF4VUaCnTGAaHBsrbV5hOtZru1/i3nQws+uhr+tZyOVC0ug+e5OHXpydGk1CzQoztb/0jARx7cCCZWrA0+QUrFLW5Qghj3Pnvw597J4NTuz/2gnPEtdb9eZ8bQ8X7IudTVTiS401iiKZUPaWa4bnjcQVB1aLLMtEFsyvZa1yqPS95nIPqDoa+e1yXiVaRlmjKmLRByDF3dVTRzzEJ8f17JwuatLxnBbQZT/BHpDTKGrr4pzs6fUM64q1kaiwTPVQY5Qj6CpZbeBDiiAKRbWAOpiLQ74O/s432g1BrTGovMd2xk68uLVvnNkaP3yVenKL8XGsklMJtgVbQMTHH/mvj9u3jdecXWfyBudZjp9N59YDb7FJmzBni1sfTqn2OntNRz/tWjdOWjpIIMkeEhVwn8DeLBc97V0RELpSr+m3ZL62Ws+Q6cb8DtaT7M0qWgFCO+v47xRDZtN5hdarODhDkWBVMyHMt9GQaio343CEUzEN2DC7n7Ldq8JFQwx7tACp5vCCaokc3VCg3N8/y8KecX3RNzT5NLFlbDLdsOMRsuo6m7UJ7gA5KC5ier6+5/H5jY+x52/CPBSYEPH8+14qPBPmn5WEw9QXFU9Pfr8nDcV3rprMrC0K6wWgonVc9tIQmk2fIyy3/IAe6ld589eHiN8x1Tw= X-MS-TrafficTypeDiagnostic: AM7EUR06HT099: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: u7FFHFYdpaF0ydxAaDArD5v80gqy/mpjQ94PqszFBo2zCXPoN27cdySz+ROLL8LdVMgnQ+vgOKi+fPVGInZ643qHGEFcb3w5F/wfGw8VWzsc213EiHsQx26Y8Ed8Usnajt6Ca+RGxUHbgEk2CQzjZV+ZsYFzCw71hSz12qErBqvrnwQxVdujZKWEgdQLnTJYS4rQuxPQEkp1/Nvz1sXsiWvUEuSJmWgKpwn6jd/Mi03HVfQcUl8mfYTpL+yafKQ9mJZ+jq/275zJPdKAn7Givzsmr8oJY8eUdON0hp07DlFHfBcis3XP7NEIAoBzVfIzAg9z7r3uEtceVheMqE2zoYisMmq+NjyFVodzsMggU0meLrOtxlazydTCPjAtxXfCB3pxpoyC0/ZuJf/ieXUkDA== X-MS-Exchange-AntiSpam-MessageData: MxiSazsrj9vikjGh4unNd3BiB2XgYoGsqk1A8LDqGmTQ7ZowyPzOTIL5OSlxTz6+0MD3i0XzPCcs36CQ0PIna63mojDBYYrZB3yv64dvnZNmXLmhih0VhOZIPgb7z8gGW08nX0yPcPGburpc3YenvA== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 92a5c9d1-3564-45b6-f137-08d90b6ac8fc X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Apr 2021 23:59:11.7814 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-AuthSource: AM7EUR06FT005.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: AM7EUR06HT099 Subject: [FFmpeg-devel] [PATCH 15/46] avcodec/dnxhdenc: 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: fwVr3GuQTYVu 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/dnxhdenc.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libavcodec/dnxhdenc.c b/libavcodec/dnxhdenc.c index 23c3f6fdb9..7f18aff66e 100644 --- a/libavcodec/dnxhdenc.c +++ b/libavcodec/dnxhdenc.c @@ -30,6 +30,7 @@ #include "avcodec.h" #include "blockdsp.h" +#include "encode.h" #include "fdctdsp.h" #include "internal.h" #include "mpegvideo.h" @@ -1257,7 +1258,7 @@ static int dnxhd_encode_picture(AVCodecContext *avctx, AVPacket *pkt, int offset, i, ret; uint8_t *buf; - if ((ret = ff_alloc_packet2(avctx, pkt, ctx->frame_size, 0)) < 0) + if ((ret = ff_get_encode_buffer(avctx, pkt, ctx->frame_size, 0)) < 0) return ret; buf = pkt->data; @@ -1354,11 +1355,12 @@ const AVCodec ff_dnxhd_encoder = { .long_name = NULL_IF_CONFIG_SMALL("VC3/DNxHD"), .type = AVMEDIA_TYPE_VIDEO, .id = AV_CODEC_ID_DNXHD, + .capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS | + AV_CODEC_CAP_SLICE_THREADS, .priv_data_size = sizeof(DNXHDEncContext), .init = dnxhd_encode_init, .encode2 = dnxhd_encode_picture, .close = dnxhd_encode_end, - .capabilities = AV_CODEC_CAP_SLICE_THREADS | AV_CODEC_CAP_FRAME_THREADS, .caps_internal = FF_CODEC_CAP_INIT_CLEANUP, .pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_YUV422P, From patchwork Thu Apr 29 23:56:47 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 27518 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a11:4023:0:0:0:0 with SMTP id ky35csp2015735pxb; Thu, 29 Apr 2021 16:59:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyh4cbLVfa9wXznwH1NAsYihLUeCUUTLS36/VR6xA3G+Mv98pQKSSDOGEOYCrTkGXCmdZn3 X-Received: by 2002:a50:ee88:: with SMTP id f8mr2521357edr.176.1619740799032; Thu, 29 Apr 2021 16:59:59 -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 dy11si90306edb.47.2021.04.29.16.59.58; Thu, 29 Apr 2021 16:59:59 -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=sg6p4IRu; 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 6E6A368A2F4; Fri, 30 Apr 2021 02:59:16 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR06-DB8-obe.outbound.protection.outlook.com (mail-db8eur06olkn2064.outbound.protection.outlook.com [40.92.51.64]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 7D87768A0E7 for ; Fri, 30 Apr 2021 02:59:14 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=e3z1v+gF9eI66k81KM3tIcl08Urq1GtPQAcHuvSYypOaeHots+6FhKmC+zVOvwmDpizLhpzVoVBC7kTNzmBCcMln24ga3TVIw30QCd51I7LU61Nu50OnvkV3Iuiu7xuTBoU0kWbea37AJtOfiRZ/PWr2EMXNRVvWSfmFb2EaS9ZT1Oh78okY9eDLEXb5VcK3KrPsUUzHLu/dkHSkdyZK3lIoWjrPtnNRH4qKx6IT7H2Ep00Y81O0HgJys7mQ3dQ088kr9sGtnZ8VAUymtzZaFqIQULcfjf/Axw02tK6o9Iy9f/OVvETwS/I96+C57EcOP02GJsH2IvZ3KXZpv6Q2lw== 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=o5g+VrBHlLskhK4m7FMSYvb28SfVnDikzD/RGR2xenE=; b=OBY1wRvXLAW9qUdy9mB1wpHP7+O+i8ylgJDCmUCrs0hZ7nz0dKAyPYC/EC4qx6ck2VMUgP+R0aTtpssjMc9B4k+ZWckL6y25yiNLcdnsnbNnn+PUYujOVg9BwBBAVkkrpjQ93BugZjWSg5IkPsvDuCS2E1G8JseUySE4tVa0M4hhmfqzQ6XrSVVVaYrl1DYVF6EA7VH64Cd/vKI7hrtBhGLgy1gGmcvSEZY0oq/smZCn5+6JkEom3YJmDEm7vjaVLlTMOg1KVmfp4cna+qVnqVkJdH0A+NUxwZyqNEIE8zx48WkPUP51Ws5DIVymA8D8ZIMFXdkgrx5fzoKPW5kGBw== 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=o5g+VrBHlLskhK4m7FMSYvb28SfVnDikzD/RGR2xenE=; b=sg6p4IRudcOg5eEO9Ol60WOmgXfoEDoMetw8PPthgYMNAjf76NSFceySqoK2vcRnTD9Dd3qaBml8IWwJeXB2SP/HvRhJrKm9NjAT1Qqa3GCbUk9aGeTj8q4j5uRfEF96RebDpbGLhMC6hlfpbmIBQG3LxqpE14giyzAPtckfK3MIUAn7N65i3M4dAHgzdt+aoWYlzDZizaGlrq+crs/9rV+7PFP1VCyiJv2iILpgQzQau87fAUPG6NCfkHwAFpfJ8zUpsvbBOks2vYFFlxHAu/1g0MMyX4KS/Ne7YH+nDTlrjBZ7iYav5YHboLhOlF4cQLXQpT32p04bRmd9pCOwmQ== Received: from AM7EUR06FT005.eop-eur06.prod.protection.outlook.com (2a01:111:e400:fc36::42) by AM7EUR06HT005.eop-eur06.prod.protection.outlook.com (2a01:111:e400:fc36::390) 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:12 +0000 Received: from HE1PR0301MB2154.eurprd03.prod.outlook.com (2a01:111:e400:fc36::4c) by AM7EUR06FT005.mail.protection.outlook.com (2a01:111:e400:fc36::397) 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:12 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:95AE43D53313AD656B8ACA3365924F450F8ED33F918563F648D731EAADB9AE45; UpperCasedChecksum:2E19A607ABE0CB95D9C5191300BE8F6D0CFFF007B0B79B8D2E7855E0FE1AF94B; SizeAsReceived:7611; 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:12 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Fri, 30 Apr 2021 01:56:47 +0200 Message-ID: X-Mailer: git-send-email 2.27.0 In-Reply-To: References: X-TMN: [LMqUTPkDoYRCRrhijloYeOw8rUBxA3M7] 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-15-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:12 +0000 X-MS-PublicTrafficType: Email X-IncomingHeaderCount: 48 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-Correlation-Id: 8732145a-97bd-4a2b-f874-08d90b6ac998 X-MS-Exchange-SLBlob-MailProps: S/btQ8cKWiQnJqnaHo6w7XTEhYoMxTOUdiV/cvqPi1sITop5PsqPFqeg3i6sSnQc/V694WYln2h7EOK5he6qVgvVOLXqmZohgXemGikRVE/0ktZDjCb4gjtUgOiRjATa4iOOrDZU/w33jjAfZnoHZdG5Ek0TFgLOvHc2iXBiDbR/TugPfsNsw6Hf5HMpB6WEFeR5c92B75N7pJ0xwWE6Du8N04Z6khqI+IbXMSnVtGwSMBrbZnHH8Q27+32HXJz0NgUM2wonmQy9GTbbv3JlQJhqJt29dk+QtUnMxnrggNuRRZT97MFnbTF9Prm7/TGzqUi1jgIy1os1wkDmTlKvUdaLgdQgjUiPobZ7jbxgr+p+dmfNkP2oX76vVdbl8THPpM/NbrKvSg27heXsrV8yIVUjQk7CJiNq7RK1V0XgE7u9eGPgnOfg9bgs04P3P7vhxIZAUHeeZBMaJrO7Y9MGf3J17RgQm1siOfRrt0cC26QNvJDtHJLgxRNsgTL5GUxP7gq4UN5Prr2wHl8Pacebcqu3gFt7ap58hd72775G/Fl4yU/ve668C2Ea4WR91jLf4F/L62RLFDYYP//7Qx/m04t7lO30FA/TclrkwaAeRezdJISkatDjvdmz5AJ/QpBScfQhUOcy0LbvDMrpKstbpagDkW87zinq2mBKA+v7JrIjb7/XvuhxuXP93eVSn4F6Dj5dn+qfKxTy0J9rx8+CKjXX4hk7V/gKBbLoio+F2NWiXm9UrSHk+9PXiB/UM0AK0EF6ZeF1uhQ= X-MS-TrafficTypeDiagnostic: AM7EUR06HT005: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: A45HUZHDdfn2+Zc2HEfmFJdMSLoniG/NRQjMfQs1Rwyb0V6lIANIv/hOAjPaYAEkpemSViuW6caO6gVahw/Dnm5qjL94zLa+uGR8CxShFbMnllSvHcCmqtyPCGABEbelmsdpdwpShA6xgnDz3wlGbN8oS1CqcaqDenVWnApg6y4Mn7aD/WwoZsPM75C+EfWCpPPFhAfCCayMZ7APBz3odtQBpgMer48X/k2wIHagzSDP4jtmo+3ZzyHdwi5okCm78NNUUnlKyVr61VNuxjtEyvTYjRS93wkwJ9vw55HX5eTAQpSfrIlZE7Lj4G7QvKjxvP4vVkTLQlxLLQ6sMuJLd4S+sufVpTt+6bSkO07oCipQqdhGl6uFHsJAhkGvF4tKboJspvam+hxq47/9jKsrxA== X-MS-Exchange-AntiSpam-MessageData: oS3m+/jyfByunrScZczcOZ+oaV9XbSQD/dAPRO+aHiSwCd/h04pMaN9joTLljgsZGc17HRXYc7VMC2dd722wLLxaBtvEYxfZRgSB7HY1L0DsLgsC2t30UC+7ioqH7RaCaVZePEnMKpViT+nVDbQNsw== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8732145a-97bd-4a2b-f874-08d90b6ac998 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Apr 2021 23:59:12.7899 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-AuthSource: AM7EUR06FT005.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: AM7EUR06HT005 Subject: [FFmpeg-devel] [PATCH 16/46] avcodec/dpxenc: 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: 5vuMgIn0bfAr When the packet size is known in advance like here, one can avoid an intermediate buffer for the packet data; this also makes it easy to allow user-supplied buffers. Only one thing needed to be changed: One can no longer use a pointer to uint16_t for the destination buffer because its alignment is unknown. Signed-off-by: Andreas Rheinhardt --- libavcodec/dpxenc.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/libavcodec/dpxenc.c b/libavcodec/dpxenc.c index 615623bf94..1213ea71c3 100644 --- a/libavcodec/dpxenc.c +++ b/libavcodec/dpxenc.c @@ -23,6 +23,7 @@ #include "libavutil/intreadwrite.h" #include "libavutil/imgutils.h" #include "avcodec.h" +#include "encode.h" #include "internal.h" typedef struct DPXContext { @@ -142,7 +143,7 @@ static void encode_gbrp10(AVCodecContext *avctx, const AVFrame *pic, uint8_t *ds } } -static void encode_gbrp12(AVCodecContext *avctx, const AVFrame *pic, uint16_t *dst) +static void encode_gbrp12(AVCodecContext *avctx, const AVFrame *pic, uint8_t *dst) { DPXContext *s = avctx->priv_data; const uint16_t *src[3] = {(uint16_t*)pic->data[0], @@ -163,11 +164,11 @@ static void encode_gbrp12(AVCodecContext *avctx, const AVFrame *pic, uint16_t *d value[2] = AV_RL16(src[1] + x) << 4; value[0] = AV_RL16(src[2] + x) << 4; } - for (i = 0; i < 3; i++) - write16(dst++, value[i]); + for (i = 0; i < 3; i++, dst += 2) + write16(dst, value[i]); } - for (i = 0; i < pad; i++) - *dst++ = 0; + for (i = 0; i < pad; i++, dst += 2) + AV_WN16(dst, 0); for (i = 0; i < 3; i++) src[i] += pic->linesize[i]/2; } @@ -196,7 +197,7 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt, need_align = size - len; size *= avctx->height; } - if ((ret = ff_alloc_packet2(avctx, pkt, size + HEADER_SIZE, 0)) < 0) + if ((ret = ff_get_encode_buffer(avctx, pkt, size + HEADER_SIZE, 0)) < 0) return ret; buf = pkt->data; @@ -259,7 +260,7 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt, encode_rgb48_10bit(avctx, frame, buf + HEADER_SIZE); break; case 12: - encode_gbrp12(avctx, frame, (uint16_t*)(buf + HEADER_SIZE)); + encode_gbrp12(avctx, frame, buf + HEADER_SIZE); break; default: av_log(avctx, AV_LOG_ERROR, "Unsupported bit depth: %d\n", s->bits_per_component); @@ -281,6 +282,7 @@ const AVCodec ff_dpx_encoder = { .long_name = NULL_IF_CONFIG_SMALL("DPX (Digital Picture Exchange) image"), .type = AVMEDIA_TYPE_VIDEO, .id = AV_CODEC_ID_DPX, + .capabilities = AV_CODEC_CAP_DR1, .priv_data_size = sizeof(DPXContext), .init = encode_init, .encode2 = encode_frame, From patchwork Thu Apr 29 23:56:48 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 27512 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a11:4023:0:0:0:0 with SMTP id ky35csp2015885pxb; Thu, 29 Apr 2021 17:00:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwv9uPY1n08OpN8Pmz2uB7f2C2Ixid/7UcIuF5H2uKNnfN+DHLd6dWnrpUyjDZNWVdY9x2s X-Received: by 2002:aa7:dc10:: with SMTP id b16mr2610023edu.258.1619740810723; Thu, 29 Apr 2021 17:00:10 -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 r17si66853edw.273.2021.04.29.17.00.09; Thu, 29 Apr 2021 17:00:10 -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=CqKi1dU+; 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 99149689829; Fri, 30 Apr 2021 02:59:17 +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-vi1eur06olkn2025.outbound.protection.outlook.com [40.92.17.25]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 5984068A2B0 for ; Fri, 30 Apr 2021 02:59:15 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=T7srfbfmRa7u83HIQdZEg7Y4kZSI5VTMmDdqA+6fqqHaLp1puIDowULHXXPGWFBiQbwKKMvjxUyAEzbau4yfq0IvZeRQzukc59v81wO0HmlaJ4Rw1HNAZCJHxBi/p6FQNi9sGFeldOTmr8qQ1uoEj7JwQzQEruZvL1bc9lw2pOUq1o3r0F2jORryn12yLOUI4wnpikbzodVAGQ8bT8t162OTlZrO04W+QMib6SmYbsqyj1Jd8JVUWq4NKhEH5TclWZ2PdyL4CPWeumjODNXArHio8FGDFjaTTPwLo2h6Aft8vrtQKgAzfYCCGlXOEfPJyPaUaop3Z16kTWKU38UgOA== 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=d6GR+foVTXE+spwQw2QEhHkGbpEv4qtS5+dZ2y84UV0=; b=UjNOVhcN7FCJ8wNh2S59z/Nq2FrNW69de5ASg82wSaZ5Ha0qOR0jtMcxoNs8DW+HqwmjHKVVbiFE+kZbz4PGsXQVn+vYf6ZmEqbxFpXPsFwSfQD581xMCF0qFymdefa06U8sILajUzJDd253PheJTfduOxpFulHFx3Yhy0hQYVjc6olZihNUu/+u5SAB097EEvkZVDWytejLckltD2hNXXxO/dEKDvDGdB2vvtUVJknOJIEWSiMXMWAhz0KevVW0sH+jLbUMMuKU8hhZW9vDdjKY1tFjvcLXn7E9t7gjeGqkGgJ8r/R8E6CanlVFseQ3jybKEhq6bOIShMUvfauGRQ== 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=d6GR+foVTXE+spwQw2QEhHkGbpEv4qtS5+dZ2y84UV0=; b=CqKi1dU+2iGQRwEEt0uOc1BG6WU95cdvDUkj7NbgZJDtvqJccD68c50Bljj1CWeAZ0hzcVqCHb6he1Xkc0yENwBekPnz9A9Qce2uLSHiIT1x9urNt2HHYKvpMdy/TqgcgbsZKqCLb/3VMkCVAXrwpsI7MlCaFn6KImY0deh9gFPdLrLIjyDrcn+3/wTS2YEi8nhgNgPRisP17iPZdpvtLepsJLVtY60NG2eh1DpiQ/RuFL6njGLx0PTxoeVejh/2rrHGfs5JhvfyMjOzpB8ol+LxqfSO6B7wpP5J9zxKt0iYla1HsCF8vk8DBKbmdUYPXNzFUfEmVfLsHYSicAEwNQ== Received: from AM7EUR06FT005.eop-eur06.prod.protection.outlook.com (2a01:111:e400:fc36::4f) by AM7EUR06HT034.eop-eur06.prod.protection.outlook.com (2a01:111:e400:fc36::443) 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:14 +0000 Received: from HE1PR0301MB2154.eurprd03.prod.outlook.com (2a01:111:e400:fc36::4c) by AM7EUR06FT005.mail.protection.outlook.com (2a01:111:e400:fc36::397) 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:14 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:5FA20DFF16F9B1ED276CEB6852E3240E91706BFA7CF6E88702DF4B4D21AAE7E2; UpperCasedChecksum:3A1FA5EFC53AFC49E7EB5E69ECF8FC42C10B1719431C1A2FE951A6D6D1CB3730; SizeAsReceived:7584; 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:14 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Fri, 30 Apr 2021 01:56:48 +0200 Message-ID: X-Mailer: git-send-email 2.27.0 In-Reply-To: References: X-TMN: [rRvxgsVqKG9XVpelsyQr1NUa5PZv/BJz] 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-16-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:13 +0000 X-MS-PublicTrafficType: Email X-IncomingHeaderCount: 48 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-Correlation-Id: 484b5a3f-d6eb-499b-4bd0-08d90b6aca6b X-MS-Exchange-SLBlob-MailProps: gjx25WM8ZNU6XUx7q8EQ5McclV510mdN6KDHjc5pS3uOisJjw15TVCk3UxdRZgVA4/jS1xl/2xfs9aaM173/RTxcHhuOKiIcUuWp19vYQKFMTwojg7lsGKjo4gsrM1s6o1M2HkYIYqLRW5OafoAHJkjYcT3birLBReie0Y9A+ks4pk0huMnBwmA1bmeVAztQLwHBRq0clhtXILiEZ+PTZsGCxJdUSHaQdHsfAtRPT4j3uni8J/mUFcihSXK3kziExuup1vhMpjFUd4gzZ1rajLaBqqwDq/IpjpVOK0NaDf0IRclA9X/C/LlbQ5FPqLmH9P6k4m6d8Ov50Dvy8GzdmwaLgq6eOgBvFGkcQTvLFnimRKOmiwtAuMtyOPJtN2DQAZGTIwVr+u2Dt8yUecEYX7nYN80Kme/aiwq0hGRrXf/p++0RiQ1C7FtkR94PEV/JfSKiAxjKUGWOOKaPT+ye1GXYV1cB0EOHmEVHyJTZ1fBHslKXZVPrgA8rcLlhMymZYmEIudbK9qVDL9s+N6Odko3/N+alqQn4z6N6tffSDUi/3Ln25i6hmcPabwzvSj7NF3pg7+PHA1YJnkdYppYyTfGEfUiS5MLBw4J0ZdGsx26gQcxc/MHX0j2h2Yr9ht/pFA/71ALhU5oQ3HjuYxw2tEhhO3vDl9ZWOFnBsaznuFCdWiqR3X23EwYtnommsHTJRJ2FnV27bfMbv8SiTp02jJX4bZkt7zsSuv8YwQcNWDw= X-MS-TrafficTypeDiagnostic: AM7EUR06HT034: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 53anUQEpEsAlMPWADE7X+pkHre65gMGV0KY7nABOEJLHjtvv8+TBQvyECOgtj7MoJvITNetxWCdJvjOHm8CNfl4fjtKDWLGQqsIeWg0k1BDvD+Gn2ZBLs/I9cJ5L5J+oObUKdo+cQfCDTnRxk4go15Fjt1IU2jeKOyjCEoZm71y10sxLAhK8uBTKJNs10X+gDBjy/h97KnR0Px1qKBetJuIZAHptq1Fh1XgR495PxPkgHr90nweVNRApfvss2TOrIsTJUD2r+wgNn8pcnlkToULVY52wg/WLRr4t601VPKTB8qYZX0EcdebfM4yzAsygRWAjaC3bqZeEDX5wGwOiF2LBZIDohKAtSUTyVFdkKH2qUucILv8OpSss1nf68fJEnYxIiUvWTZQ9aHR7qwyohg== X-MS-Exchange-AntiSpam-MessageData: CtISz2VzLwB/4k0+I3Ltq6CwcRCoUKEwGdwHQPesPElA9jSdKm0WVg7eZcC+GzicQwrAjKZZ0hC7RLy49s//LJZNyKB92wvWEJoYNo97mb/ejuQ4xyfZ4EDLRHcRCn7JV1UJgTMRtYJsKO14sXRrYQ== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 484b5a3f-d6eb-499b-4bd0-08d90b6aca6b X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Apr 2021 23:59:14.2153 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-AuthSource: AM7EUR06FT005.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: AM7EUR06HT034 Subject: [FFmpeg-devel] [PATCH 17/46] avcodec/exrenc: 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: hgL7NPGAXYLs Trivial for an encoder that knows the size of the output packet in advance. Signed-off-by: Andreas Rheinhardt --- libavcodec/exrenc.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/libavcodec/exrenc.c b/libavcodec/exrenc.c index b2cb9c4205..60a9948b79 100644 --- a/libavcodec/exrenc.c +++ b/libavcodec/exrenc.c @@ -33,6 +33,7 @@ #include "libavutil/pixdesc.h" #include "avcodec.h" #include "bytestream.h" +#include "encode.h" #include "internal.h" #include "float2half.h" @@ -352,7 +353,7 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt, avctx->width, avctx->height, 64) * 3LL / 2; - if ((ret = ff_alloc_packet2(avctx, pkt, out_size, out_size)) < 0) + if ((ret = ff_get_encode_buffer(avctx, pkt, out_size, 0)) < 0) return ret; bytestream2_init_writer(pb, pkt->data, pkt->size); @@ -541,10 +542,10 @@ const AVCodec ff_exr_encoder = { .priv_class = &exr_class, .type = AVMEDIA_TYPE_VIDEO, .id = AV_CODEC_ID_EXR, + .capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS, .init = encode_init, .encode2 = encode_frame, .close = encode_close, - .capabilities = AV_CODEC_CAP_FRAME_THREADS, .pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_GBRPF32, AV_PIX_FMT_GBRAPF32, From patchwork Thu Apr 29 23:56:49 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 27499 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a11:4023:0:0:0:0 with SMTP id ky35csp2016030pxb; Thu, 29 Apr 2021 17:00:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz3knh5Rq33xRfSLNERklastX+6N2+eQzO95pCuIfX36tQzaS6JfTuW7U5Z4qEAqXWCa19G X-Received: by 2002:a17:906:4ec3:: with SMTP id i3mr1086791ejv.119.1619740821820; Thu, 29 Apr 2021 17:00:21 -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 o9si1477445ejc.407.2021.04.29.17.00.20; Thu, 29 Apr 2021 17:00:21 -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=O+TxgcHH; 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 A3D01689F19; Fri, 30 Apr 2021 02:59:18 +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-vi1eur06olkn2056.outbound.protection.outlook.com [40.92.17.56]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 19E186802B6 for ; Fri, 30 Apr 2021 02:59:16 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MNKHprSq0Yc6fF/2rd/G/J0cWxGzm9MWcpSyeP54ffJ6BXEM+Mi94I5RaissDTkavIatEz/mUMMI8FtwQWd1UqPf4Ok/NE4q2DvnCeKSDpFRt2Y5MTZRFCDrmjD0hxu/j6bznGqMnlAh5+4hImPCuEWkwBNMjvHfcFl45GA3lAT/Fz1E/E+d1saCz3VQQOafVgISUmCnP/8ZPhqs7iTYaL2V7axtTqKU1A0vPL8bSECClxFeDg3uW3j0QSVnletjfaYCaIbCQVvZqcqMXeLLepMIVpRHpt018cKNGxAzSNov9r+/tdhXqG3y8kUQ45/pXk8UxmVAlF8BK39mOcjvbw== 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=eaRJVMvjBaDWOtvwaMZJgBwR+MxLx7PUrPdBtmDZNnI=; b=kQGJs/iShyf1iNF/GvndO/gfn2tr59pI3ohixEBv4WkllnmatcN3dP6pzJbHEjrKCWegwG4oxNWJ2BSEd5GH4wH/qQQEr07ZLWe7ATboeqoPHFeiu6ORJ6+fbSRKJiyyjckfVlp7fjAXOdTbG/Cj5kB2bO4BVhdCchVUfsHR/vgnXXBzImOHt0cD00O8795iw59NqKiTuCYmBxFPH3ooQGzjKh11bDP7klCSxAHJHTyKYgrY+jv/I9j7bKUAA49/N8lDusBm6Vv4dIR6yr3CiBtrFr+P3dK/nk8SONzPXVVMZCsUrZUk+jVjaqkyTwywZnc+5uB+oXTeOHuZm8aCjg== 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=eaRJVMvjBaDWOtvwaMZJgBwR+MxLx7PUrPdBtmDZNnI=; b=O+TxgcHHVVVhnrQOep9AaTGiVpDYEwL3TCtiOPcKCTKCD8PG2UqqSPbU2RKINSxeK7ZiPUPJJK4t6sFSZR9erTCPqRoF4xL8An0CkGCkqPei3WxR8HkrWZczHwiwpQgsfwQypfj5zeHr0V0h48lfkZRE7zF4TF9EyTn05gyezsQtZNsO3i5mN1OM0/pQpyWXMIV6qDP5Pl8WYDS4/eAXgZTxIxoNwXQ4qfA8Kx8euXZYfipBdr2kd08qX+aIWx4Fz8wr6kxUZT88JI7gjjQKJ2tRUTvEEfLBnv+RFeYbUpXE9/H4Fi65xEjhNxz2AcmaVtHccfXZHJcImS0w3DQCQA== Received: from AM7EUR06FT005.eop-eur06.prod.protection.outlook.com (2a01:111:e400:fc36::53) by AM7EUR06HT141.eop-eur06.prod.protection.outlook.com (2a01:111:e400:fc36::120) 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:15 +0000 Received: from HE1PR0301MB2154.eurprd03.prod.outlook.com (2a01:111:e400:fc36::4c) by AM7EUR06FT005.mail.protection.outlook.com (2a01:111:e400:fc36::397) 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:15 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:58322FCB9CFCC368F0F15C406D7A030BE64AB2015454A59EA4A4785AED78C2E4; UpperCasedChecksum:F5AA4720B394788C7E1DAEDA1CB7C7001301ABC4A3FC1AA048F7F3909965D85D; SizeAsReceived:7603; 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:15 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Fri, 30 Apr 2021 01:56:49 +0200 Message-ID: X-Mailer: git-send-email 2.27.0 In-Reply-To: References: X-TMN: [r+puq2edOfHS4Ucs38MXfiFamFm9GuQD] 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-17-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:15 +0000 X-MS-PublicTrafficType: Email X-IncomingHeaderCount: 48 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-Correlation-Id: a7ebb86d-8e2b-4602-7211-08d90b6acb6c X-MS-Exchange-SLBlob-MailProps: gjx25WM8ZNU6XUx7q8EQ5McclV510mdNA5vT/fXqaCFZrX0prHkG4iykoLu1iS6FuwIXk6aZkigrgMZpbXUUCKJyJ8TQ69e8U2ig+1SY9YzwePPwhNg/t5khKRQAAIwpADr3k5fO02+KsbyihHmiwxU9XuDLCWhTb1E8DKHyXhDcm/Q7QncFyWZ6rQD5s5PKAibtulxreGVgGQqu99cREpahnMNQrctHs/yxhU5CPFjON/0a46rxjm8lGwPzd48aX00FrqQXsT2nnElhQ/id7OFbupUHn6vqkfIOXTb0VrS/ThU81MWMeQ6kywm8tSihZk+/+pbL2urUOZ5wShgULch+xnHGchOsCodEA0WgYTE2l+Bvi4paRPD/bhF/ZQ7X7gip98v1IdJ5BjSqaDIslWL8lude/6vY2BH2A73Z0DG6KLyufj/eZ6KTvsSs2uL8iaAjYwM8XWy4hvHJod1eT021mbac9YL/P3uEV0iqkSqUwrZtAkHjb6pkppdAAmjKyVdkHXdkR3XPmDX5qE1fLC/snxwMMOErpp5fznnfidviiAXaF1p9oO9vy997LfcRgSQTE07rjvtHY/8sol3W7JqiVnk9j14dHmWuUfm6P0IGbLJsJnJhAy6gjm/3etXNvdrp+NeepwaRiRomjXpRJRqhyjHbglUr+KQ0j7npSBeAE6Py1YD0NIpLmeKfokjD/1C1tLkfHnBmeX+VCSciTFtnkgJWbmSmqw+rNHwJe0o= X-MS-TrafficTypeDiagnostic: AM7EUR06HT141: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: YfMf1O+BQa6b2ilp56JKyaHjKKum4MMyEiLOzuVNChI8czFQpw0RBTlVsRWA2NT4z32Tff0meQQ6j3zdlZAvrbBEpEKyJdeLu8XE3znX4s1qo1IuNuiVicU3zLuuBOBs9wPzd/5vPK0FQeV6OFBfAjVsn1Csr/luQqNA6cZPigBJlImOr7wbV5HhQMCQjiYqZo2Six7gqZrXYEorIVsubtZ9W6Mu0IEIJO/tURM5g8DTrAF4Ol2MWER2V8dsMNc5g2mm/Cwcq9wpix1hJAF9XRavgf/0ppl89jQtGgux87WAyc00V0UB0Bguu9bD1XTdMwn++nnRINafgFDpyAoPXFIwpdf/p0Q63T8lhRbHoPtFiGFp6j0AdLDoxnuZCaLC1SmNtv93IE1SKrjisz79CA== X-MS-Exchange-AntiSpam-MessageData: ZKYk2x768Bol2elYlYzv1tAJ1TZJ4lE08j4XLW6jRmbk8cP0fZsFiFkEHLJuXEUyCrLiSUIBg7aCG9BSdKa4R2vDbFy5Gx/8PY90xA+2ohygyzT+UteIb6koMA4A93t/jwAB5dTJza6N4eD+iDBJ3w== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: a7ebb86d-8e2b-4602-7211-08d90b6acb6c X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Apr 2021 23:59:15.8985 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-AuthSource: AM7EUR06FT005.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: AM7EUR06HT141 Subject: [FFmpeg-devel] [PATCH 18/46] avcodec/fitsenc: 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: K1aM6Sm4Am3y 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/fitsenc.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/libavcodec/fitsenc.c b/libavcodec/fitsenc.c index 80d0d71d1d..d96baad986 100644 --- a/libavcodec/fitsenc.c +++ b/libavcodec/fitsenc.c @@ -32,13 +32,14 @@ #include "libavutil/intreadwrite.h" #include "avcodec.h" #include "bytestream.h" +#include "encode.h" #include "internal.h" static int fits_encode_frame(AVCodecContext *avctx, AVPacket *pkt, const AVFrame *pict, int *got_packet) { AVFrame * const p = (AVFrame *)pict; - uint8_t *bytestream, *bytestream_start, *ptr; + uint8_t *bytestream, *ptr; const uint16_t flip = (1 << 15); uint64_t data_size = 0, padded_data_size = 0; int ret, bitpix, naxis3 = 1, i, j, k, bytes_left; @@ -80,10 +81,9 @@ static int fits_encode_frame(AVCodecContext *avctx, AVPacket *pkt, data_size = (bitpix >> 3) * avctx->height * avctx->width * naxis3; padded_data_size = ((data_size + 2879) / 2880 ) * 2880; - if ((ret = ff_alloc_packet2(avctx, pkt, padded_data_size, 0)) < 0) + if ((ret = ff_get_encode_buffer(avctx, pkt, padded_data_size, 0)) < 0) return ret; - bytestream_start = bytestream = pkt->data; for (k = 0; k < naxis3; k++) { @@ -104,9 +104,7 @@ static int fits_encode_frame(AVCodecContext *avctx, AVPacket *pkt, bytes_left = padded_data_size - data_size; memset(bytestream, 0, bytes_left); - bytestream += bytes_left; - pkt->size = bytestream - bytestream_start; pkt->flags |= AV_PKT_FLAG_KEY; *got_packet = 1; @@ -118,6 +116,7 @@ const AVCodec ff_fits_encoder = { .long_name = NULL_IF_CONFIG_SMALL("Flexible Image Transport System"), .type = AVMEDIA_TYPE_VIDEO, .id = AV_CODEC_ID_FITS, + .capabilities = AV_CODEC_CAP_DR1, .encode2 = fits_encode_frame, .pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_GBRAP16BE, AV_PIX_FMT_GBRP16BE, From patchwork Thu Apr 29 23:56:50 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 27514 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a11:4023:0:0:0:0 with SMTP id ky35csp2016148pxb; Thu, 29 Apr 2021 17:00:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJykFpFRq2Px+zTW25pbzuIbP4JuQjDxgdXH9g75uFlpIf/K5F8XIHH+fzhyQYaJm8ISMXaH X-Received: by 2002:a05:6402:2216:: with SMTP id cq22mr2590878edb.265.1619740831620; Thu, 29 Apr 2021 17:00: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 pk10si1433164ejb.359.2021.04.29.17.00.31; Thu, 29 Apr 2021 17:00: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=qEGXHWSj; 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 CA6FC68A336; Fri, 30 Apr 2021 02:59:20 +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-vi1eur06olkn2033.outbound.protection.outlook.com [40.92.17.33]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 1605568A2F6 for ; Fri, 30 Apr 2021 02:59:17 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=A5ceq7DndGHjDuzH7xOHwkMBBB6bSntBL8JzFQtXmry3IDIbHaMuioGx5obZznVy33wJl0DnCLKGo1waUy3tZSgezY8et6dnyYEn4xzja/CXmxPAAXbXy5kBsNhbsrdgnlSSMC6Ds8+l2qVJjoS7pYfBoRdHi2chW0ac9VQKf2OQ/Eu+8ut/PemKl2WkLTWCqGIx/uUPT9cLgYBQxZHxqdHiuFoubM0ECoyLVFoXlVjzQL47HAWhufUEajnWN8HMNl702Cs8qweSuWs1pYG48K0PxIW2/S0rXKVHNCE1GcWWlr4bJFByVykXWA0CklQFViHcEiOlCQu0e4Qexb6Jcg== 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=TAMo6BWGBHFVyKrrh7siCeA1QvJo56AGBLw50MRRt/c=; b=iLGuV9lkXuZlCmPiu/O3UIeWQzOMiMytv3IF/CnoVnFvmA/gQsysYCehIZNdnIqLLnc4RUL0HT3I4Rr8oth1Y/Bvwd0xhQQxyb9KU4XEVwhSunAryY08JyCIhY6yrLctsgXFM2n11NAwG1qhl1jQXUIqIW4B40voUxJ9+gRNmrDae154EuAc4DOU+aG8fqMmRK5EBr/s5KDgp4bpB64vh+Pfsr7ay16aivkcwGnMQeb74S9KXOUe7sAdJ6tgpFBlr+fxPi8MCPvclaDN+GdTkFsYLBD4ZCvH9E3A5tWj6A44FSlMybN4FmYsMWYUo+hPeSDcsU+z051T/XNANVnhnw== 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=TAMo6BWGBHFVyKrrh7siCeA1QvJo56AGBLw50MRRt/c=; b=qEGXHWSjNFXH/1vjjSvI8wNGBS42ia2SgPc7w8o+w9BQoHw6zpKNjhjBGsH+t14xVmol69NAYfBHwSU302wlbEcmRueqcacc+d4hapJT/Qbn9WHCwyqs8whpqimF8yAZWJoGe3H5UGQsjER2RO9CGXGq6TUqaPUtvDjj97y0ax7wIVee9u1t8c93uIU3J3WxJIHFCx9tq6B0PDN/HsWZhhjc8ClsvkBB6bQoQd/YNTClYr2TD8kljZxjQIlLdYB54FT7Is0upUZstL+P9EY971sjuWZewUSdwVxV3czXOICFPzsiy+zNJOL+qH7VbxO7su39/q7uWjc8Y9uVXoTRFA== Received: from AM7EUR06FT005.eop-eur06.prod.protection.outlook.com (2a01:111:e400:fc36::53) by AM7EUR06HT141.eop-eur06.prod.protection.outlook.com (2a01:111:e400:fc36::120) 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:17 +0000 Received: from HE1PR0301MB2154.eurprd03.prod.outlook.com (2a01:111:e400:fc36::4c) by AM7EUR06FT005.mail.protection.outlook.com (2a01:111:e400:fc36::397) 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:17 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:5600F707E3BFAADD19FC5E5D8558888D6D4730BB617B20F9A26B57583CBA3EEC; UpperCasedChecksum:06A4F69DBCE7A5858EDDB05A4A691AA94D9FEFA707AA89BE9D095D50706D88C8; SizeAsReceived:7613; 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:17 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Fri, 30 Apr 2021 01:56:50 +0200 Message-ID: X-Mailer: git-send-email 2.27.0 In-Reply-To: References: X-TMN: [L0qvDzLe3iODkgKae16hYo+i80zLFr33] 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-18-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:16 +0000 X-MS-PublicTrafficType: Email X-IncomingHeaderCount: 48 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-Correlation-Id: 6c69afa5-2197-48e1-62f2-08d90b6acc1b X-MS-Exchange-SLBlob-MailProps: S/btQ8cKWiQnJqnaHo6w7XTEhYoMxTOUqqC1aAam4bzntlwSzJ+E2NJMR6q+pEDMHtaAnWskKt5ZEiwKxpjI8b/rcjtSSq01wZS7HqoQLhgwVlKJIXfpSk0PRkMmYu3DiMSrFekfE1Oyf33WxKhg/0Y76qr6J7v99Wg6NxCNisVfeV1wBZFEHBL8jEVtAmAndZ/LgNaOivwJoGdzghrnWdK238iVkHH/GozWO6uPlMEYwn1MgJCE1O8yPiQcNtp/+4LaH4OcWZMionLdiSaZVhTZzo5FNoN/FEUqVL8TAF0I9zXhSc/78/Av+MKDHzYyMWixkokzVguwduFmmzGA4aHcKQSQRslvM7FpleKkflDW9TM7wVcSv1gtJsjzp6A3Fy5huA9rPKux6bx2zO9WKBZvpsjJpjuhz+kLOcfZ8FiBN6auWhXVXxyjeebPTqyKGUzaJgGXlzM1AymdcJmjZBRh93FI8+Sx+FAQMPStYJZ7AD8s7Iqya52YusIQ30VA7jKqpHAqn0XSlRBpUoTT0yk8aXtRo4m4g+TzwWKokcr5oPGpngvjh9cXlRoATj/Mg+DGu2RhvWjMvLc64hJgosrXCD7K/d+2TVVr7wZsV0IIbrOCk1hrlddGBnspxp4/14tO+p1zFL1aqI7nxX5c1sOWDRQU1tqGIRGGSawSJvdWJPKgNe5ma84eMIVeoASRmr7xUgsyse6v0jqnnccwZZGFeb7kaivM2L8jlm8Oz5ZLeLBnjM9cynvL1+jg8GnJNv7Mx0yu+MQ= X-MS-TrafficTypeDiagnostic: AM7EUR06HT141: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: B4C8ucgBS5PeZXqMDoYuTPfMilf3dBYYGlEsaAJSQWy6azZYLhxjp3snU9ZcYDt8P/56sjarvmC5PIDmjCsaDqVskOn4KisLBbvH6n4DnWm2jFJi/1b+V0TYTSub81poCu2EXB9dxQ3evBWzzmVyzJ5VZLAvlkSKqTFG0/Z8FJKgMIy/Vz9jM30UHryEc7p1KP6+a+UqqLTfr6uLdxq+Uvpb+Exq3vAHIue42AtgAEilyy1FgWndXvhNjmwuHj8qWed/N6k6etUxdOONrxiNOOzVzSDetEw7S5Vmx74Py6Efa7QAoBohT4Qmz7Ftj196EWJXdj4GPBTV4KFw43VUi2tlPVn2Or4VHps8J9tGjDFpVsO0+UiMwKxh5u5qoIrzDyfe95fNGcoQPlNgA0Ld3Q== X-MS-Exchange-AntiSpam-MessageData: XS7Y3adUel0ucJY+WMmSD8mX1z2JxqCEacYQ+ZGiYYYy5EAJIG0NXB+jGQI8UkZ1Dkg8dsc7l2ZUWFLFZVM99VQjKG4IEer1OwemnBzPbGLe/Kk6HosmgrpVSMJhQ3hIkjOZwNxPgG6tzMXu0Q5l2A== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6c69afa5-2197-48e1-62f2-08d90b6acc1b X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Apr 2021 23:59:17.0500 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-AuthSource: AM7EUR06FT005.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: AM7EUR06HT141 Subject: [FFmpeg-devel] [PATCH 19/46] avcodec/g722enc: 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: ZiMVPHXXtDrC 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/g722enc.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/libavcodec/g722enc.c b/libavcodec/g722enc.c index 24880f9550..fadadd5cdf 100644 --- a/libavcodec/g722enc.c +++ b/libavcodec/g722enc.c @@ -29,6 +29,7 @@ #include "libavutil/avassert.h" #include "avcodec.h" +#include "encode.h" #include "internal.h" #include "g722.h" #include "libavutil/common.h" @@ -346,7 +347,7 @@ static int g722_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, int nb_samples, out_size, ret; out_size = (frame->nb_samples + 1) / 2; - if ((ret = ff_alloc_packet2(avctx, avpkt, out_size, 0)) < 0) + if ((ret = ff_get_encode_buffer(avctx, avpkt, out_size, 0)) < 0) return ret; nb_samples = frame->nb_samples - (frame->nb_samples & 1); @@ -373,11 +374,11 @@ const AVCodec ff_adpcm_g722_encoder = { .long_name = NULL_IF_CONFIG_SMALL("G.722 ADPCM"), .type = AVMEDIA_TYPE_AUDIO, .id = AV_CODEC_ID_ADPCM_G722, + .capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_SMALL_LAST_FRAME, .priv_data_size = sizeof(G722Context), .init = g722_encode_init, .close = g722_encode_close, .encode2 = g722_encode_frame, - .capabilities = AV_CODEC_CAP_SMALL_LAST_FRAME, .sample_fmts = (const enum AVSampleFormat[]){ AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_NONE }, .channel_layouts = (const uint64_t[]){ AV_CH_LAYOUT_MONO, 0 }, .caps_internal = FF_CODEC_CAP_INIT_CLEANUP, From patchwork Thu Apr 29 23:56:51 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 27502 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a11:4023:0:0:0:0 with SMTP id ky35csp2016321pxb; Thu, 29 Apr 2021 17:00:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyNEPFnI6Xm9dOoaVlDGFb7NRL04TunvEK+y/wxy9MvivKj9EE6+pXMqI01XiX5xdUZ5LZz X-Received: by 2002:a17:906:ae0a:: with SMTP id le10mr1130869ejb.86.1619740842864; Thu, 29 Apr 2021 17:00:42 -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 g9si57102edb.385.2021.04.29.17.00.42; Thu, 29 Apr 2021 17:00:42 -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=jkeEhMar; 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 D2389689DD1; Fri, 30 Apr 2021 02:59:21 +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-vi1eur06olkn2107.outbound.protection.outlook.com [40.92.17.107]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 62D2868A181 for ; Fri, 30 Apr 2021 02:59:19 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=IW9ta17qiTbRG/M7aFEx9caNrlOnhXJpJeTKyljx7SJSQcAeOtq190EQmm6a+NgD65+AD3FwiYx7zdEuRBhm0j4k33k0x550ANG66t/FWHm09IGomf0Fp6ZoPKAk+4XSxU7smMFwj0Xhn03AUPV0gNXbNml9FNxgsgIckSkEjX5mxUaV7EUxdV/fTxO+aAYfii0dlS4jxa/k1eeDnKsiiG2WuJWHHejKmPOwuu0LYrj/Xo/5+YR9T33b6T8+rsOdaUmKTiGx8Kwhq8xRXOqz5yZqOYONxj6UcIteZFyEUjJY3JyuMRv7gw3ejslFxJgGbSceUs0yVyOHu++DkLxZWw== 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=tXIG9T6QS+t5KgirwsLbmcExDwQnS1blJg+4ulk/wbs=; b=gr8a08cRvfPqlsdkzylVfSg7cNEFOM3DmgUN9ryXzRTTMe2ddy+BciAZ5NEpJwchZehsNaLyVggtfxyCd/yGy4Zv1HduiyBNExg2w0yJrGof5od59EHDdLMEug15AWln0s9jCNiycrvCegb6eMiMyZfolCnfOC2h6JT6dN5AG1esc9c3u8I0keyNJ2cPxP/GJGcg1MML5ur/GLuLMkdHHO24mEv+Myu0MRG460WALgEJjkMMOFO9kodiZYBceJRYcCnEw18iT7HYsRI1jhxA/hrjUat1cakU73LxaXBWVfmImOapWu6NErVKiXeADDzgjOP099e5YarQv4F1qUlMUQ== 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=tXIG9T6QS+t5KgirwsLbmcExDwQnS1blJg+4ulk/wbs=; b=jkeEhMarFzlNFc0lY7qNoBGWcwDRE/bKzjspS4Rp6ttwhx57fj2d9yYCNeJNaR1CfcT1CgkrPXlyaoltubmZSxhkk3YGc1MJuX8H7crLmYl+viTFF7seJlE5Eckg1tk6EFlncZaNaYRg+Yx8Kau+qZQXX2PAH476rnGC7q9ukq11qQQq106E2O60EZPDs/uy5lAh2tTaLKoZkKy+vYj+n4fCKrFDhnxdgWXEboXpLpME23UOD4pYvuNZKgLlMrAl4+knD/2cS/xQpET3X5OggDevMdlWlaItHfWpDXZvJvuv7RKZfPQY2LbpLaVnCqnB6KeeZdlE2Bi6UI6Eitymow== Received: from AM7EUR06FT005.eop-eur06.prod.protection.outlook.com (2a01:111:e400:fc36::42) by AM7EUR06HT230.eop-eur06.prod.protection.outlook.com (2a01:111:e400:fc36::216) 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:18 +0000 Received: from HE1PR0301MB2154.eurprd03.prod.outlook.com (2a01:111:e400:fc36::4c) by AM7EUR06FT005.mail.protection.outlook.com (2a01:111:e400:fc36::397) 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:18 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:6BC4E72CA5E843BDD154ABACD3A1CE46BFA7252AA1B9CDDDA08F699F301CD13B; UpperCasedChecksum:2A9E654428DBB112A6E640F5FB5AC5F2D8CC47D810EC83DA4AA81A48C2CFA7A4; SizeAsReceived:7614; 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:18 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Fri, 30 Apr 2021 01:56:51 +0200 Message-ID: X-Mailer: git-send-email 2.27.0 In-Reply-To: References: X-TMN: [NUDJfX2PkKp1oTbvrQB0lXsq0bWQwrVY] 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-19-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:17 +0000 X-MS-PublicTrafficType: Email X-IncomingHeaderCount: 48 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-Correlation-Id: 9e9b0462-e7b5-4b44-da97-08d90b6accc2 X-MS-Exchange-SLBlob-MailProps: S/btQ8cKWiQnJqnaHo6w7XTEhYoMxTOU4shK0srjCm8ZsCbtbyYGzU79oqXSEt2D2qCogDYyLa/RshEck92om7bAu5AavlzS9YpTOVF06N5LzZHwrzDgalLALs6BjAh4e1guEvtKXvEvZRGnu8qwAjGLxrAwRHdvr2rVsqqcd+c7tRXwFyUVe2MrkhMRJcUEXDMmF+f/6ucdcC0qWfLGKo9WCLJGPQEfLxVGb7D0BeGuLsKfy1ayVsIY/1BvDjuviACcUnDGk0UgX8iMT3Gx6bFXKDKB5MnnQf4AfMxRNdyU0Q/+kRuX9Nxc2OM3wad3+SD4hRNX/+cYacSE2D/24hDdJRffwVZ2vHhKzJo2fRenN8ipkpT1E7TkA/YpIvi4RrTqVqSMzvpYdxTaGY1PP6o6jXIF0FgyaKhl1GFxDregPFddO5z4HMdjtBYhOPC6rs86GAMRYFNth31G2OVi5YSwSh+2AkiKZzLiLd2dKnMip+oBTGoukdbo5pC5wX/I9/TwXrlgdc31FgWeCc2lDlPz1Yqe3pIGWMX6ilBZOxWGsCc4hi3NAajxbpuvwgWmXgHSxmICYGZlCcM3xXFGxbwNOf01uGRcxfBQpirT4CHGqU5qLSMeoLKuYghwicnncnJQSViEOaO2oDOpBki7cVzU/8GpGCauoypCMNiTeUyIGqc7sSW7I7+unsr1WE8oDRO0QCV2FuQAljkHk4yy8cuAJ4yNaeKna3yZRd/2ODuCUixDAlx2CJg3BSfUlaxgyEJwDNh1pEU= X-MS-TrafficTypeDiagnostic: AM7EUR06HT230: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: yWxg316y3cUKJEZ2t0/3Sn4p2UV1U+f4Ns8y0DMZjtnx6sSqaDWjB8uplQfucHBaBDla646rQyxs0Zu7cXk+pmXp7vXBzKPS7YW16seCNV4CeJcWZq0Sbs+HX/YJYP5TGnIfjU5ILvvYGBhYRntTQFf6JJSpJev15uwd53HxdIlGpuWu8Lmj8K0VZpzQjQDYOlLyC2wsWzP55MqtchM50MAz4U6kZxJst94bfrbLSZ8E5sdeWxKEDgSoMKmFWDNaJvyRyW/ijCN8E8CAGa0Wu4TfaULUoc8nDZnMcLoflJx/dg/ev0E2gmEMFvTXquGj9uFHTd87zG0GuMQiAQIwdlIUCCbGnxw7ypnhDDxdTfvl93h8VhP+Jj67MzFYTn/B1IITjoLrki2dkgp1I/FxcA== X-MS-Exchange-AntiSpam-MessageData: 5y215H3+1iodqpEPMXFDwTAGeEuHruNdqz+dEmM1I2kzkIKxi6gGOdVhm5CA1OExvY1goxkmvtPAhbTeczx89AAnEyKb9/mAHDL5D1vv3V0q7NR97ldeYVyeyqEfQDK3JkDmdjYgiSl3Ei83kgNEQA== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9e9b0462-e7b5-4b44-da97-08d90b6accc2 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Apr 2021 23:59:18.1205 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-AuthSource: AM7EUR06FT005.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: AM7EUR06HT230 Subject: [FFmpeg-devel] [PATCH 20/46] avcodec/g723_1enc: 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: OXDQpp5mFjJn 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/g723_1enc.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/libavcodec/g723_1enc.c b/libavcodec/g723_1enc.c index 2fb4b7fc82..93e7c1cc60 100644 --- a/libavcodec/g723_1enc.c +++ b/libavcodec/g723_1enc.c @@ -34,6 +34,7 @@ #include "avcodec.h" #include "celp_math.h" +#include "encode.h" #include "g723_1.h" #include "internal.h" @@ -1044,10 +1045,9 @@ static void fcb_search(G723_1_ChannelContext *p, int16_t *impulse_resp, * @param frame output buffer * @param size size of the buffer */ -static int pack_bitstream(G723_1_ChannelContext *p, AVPacket *avpkt) +static void pack_bitstream(G723_1_ChannelContext *p, AVPacket *avpkt, int info_bits) { PutBitContext pb; - int info_bits = 0; int i, temp; init_put_bits(&pb, avpkt->data, avpkt->size); @@ -1099,7 +1099,6 @@ static int pack_bitstream(G723_1_ChannelContext *p, AVPacket *avpkt) } flush_put_bits(&pb); - return frame_size[info_bits]; } static int g723_1_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, @@ -1112,7 +1111,7 @@ static int g723_1_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, int16_t cur_lsp[LPC_ORDER]; int16_t weighted_lpc[LPC_ORDER * SUBFRAMES << 1]; int16_t vector[FRAME_LEN + PITCH_MAX]; - int offset, ret, i, j; + int offset, ret, i, j, info_bits = 0; int16_t *in, *start; HFParam hf[4]; @@ -1231,11 +1230,12 @@ static int g723_1_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, av_free(start); - if ((ret = ff_alloc_packet2(avctx, avpkt, 24, 0)) < 0) + ret = ff_get_encode_buffer(avctx, avpkt, frame_size[info_bits], 0); + if (ret < 0) return ret; *got_packet_ptr = 1; - avpkt->size = pack_bitstream(p, avpkt); + pack_bitstream(p, avpkt, info_bits); return 0; } @@ -1249,6 +1249,7 @@ const AVCodec ff_g723_1_encoder = { .long_name = NULL_IF_CONFIG_SMALL("G.723.1"), .type = AVMEDIA_TYPE_AUDIO, .id = AV_CODEC_ID_G723_1, + .capabilities = AV_CODEC_CAP_DR1, .priv_data_size = sizeof(G723_1_Context), .init = g723_1_encode_init, .encode2 = g723_1_encode_frame, From patchwork Thu Apr 29 23:56:52 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 27520 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a11:4023:0:0:0:0 with SMTP id ky35csp2016478pxb; Thu, 29 Apr 2021 17:00:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxMWC5773Cr+b3KNK0WvHhXaqAPn5g4GZFyfvOm6CfbN+M85fReeW7zW/1NtY700SoynHd+ X-Received: by 2002:a05:6402:1ed:: with SMTP id i13mr196460edy.27.1619740852712; Thu, 29 Apr 2021 17:00:52 -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 k9si1809502eje.640.2021.04.29.17.00.52; Thu, 29 Apr 2021 17:00:52 -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=O4Yt6TNN; 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 CD9AC68A360; Fri, 30 Apr 2021 02:59:24 +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-vi1eur06olkn2067.outbound.protection.outlook.com [40.92.17.67]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id A05EF68A336 for ; Fri, 30 Apr 2021 02:59:20 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=EcuTN5gXAwy/mbXMNFyICCDlhwYVyidf6ZHi6UUQXYVSlD0THy2ZETTqPfGjzuScaSDbgV3c9ctUUqBG+pj1Lx/LG1cxb9Rkil+lCE3DQ48F/tMGY5pGc4LquCQGnPAavG8t09Ma+9MRpIJs5Mos3p//jxm9jMQgFwOSVck8wcgBrVwtdyaE+ZG7wLLOTjJLn8pIWq12WlDyWa4U6LQ3YzA3a8iNd17PfG1CGJM84DwpiU2mj7sd+LVNFLKOSsBorlKM4BqXmZHV1oeDw00hxwNNzKW4GD++QXKVUKuctIasVZxNtGiX7WuJQ1+/dwyMgUwNhslRHwYpq6TcxdRu4w== 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=8ynb0EA03qyFih+tH59lsxFE7D8xGiq54s1uTf/U1ro=; b=Psteet7+oI2FMFT8hPP2n5sPsYbJpiKcDZbdAVBkPQNEu5GpLU3RBWXN1OXWSSh0O4vuSOPyAQ3l1D1JUm88KjjXNIHm9IqztKjcEbKP/XjdSCD/0+34uhIMJqccMmMgUPP4V70ZI4G90+BNUQ2UIvCDWwH1aKM+HUzFIiyTwW/67D9yvi2fap7/gOgHRHpt2ntPl5vqymSQplyV6V3pGqCWfwnX/MVMJotgRsJmYC7h5X5X/mVvukBQdX7wEApygE683MjXjAsIBqXHQulfC9a2duMcmgVCfxAmJ/L8fSyeP0N2QRhbKWrfYPaMM54l3YwaQl5JxffPxVtch8l9aw== 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=8ynb0EA03qyFih+tH59lsxFE7D8xGiq54s1uTf/U1ro=; b=O4Yt6TNNbgCF33Y3C+iIZulGMDMh+eQO9Tfb4gceGkw04TtGxxiMa7SzlhjlxPnNfPQFYMYZXqpGJoLRh0/WRmD8Desf8cTtHCRjR+9PmhKgFMpC43J2Y6XY/aMNhaCDspqqY5vxfgmZCcsdiM2SMfsPFGh1aOKe67fS8pBUw/yV4kwLr2R2M2kFX7MqkFmJ8LyLU0c6dcYHWGxADNMwAiNekGHLlRhejLacg4OFkpAiGSyPhnF+MA1DSNwIVCFKEFo46i44LnV9voYV4QBaTa6SEQpA9TGIkM3nF6yX2ecg8gOEoFvkfBsAd5YX70tZywZQDzjT/oCafVqXG9/HVA== Received: from AM7EUR06FT005.eop-eur06.prod.protection.outlook.com (2a01:111:e400:fc36::4f) by AM7EUR06HT034.eop-eur06.prod.protection.outlook.com (2a01:111:e400:fc36::443) 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:19 +0000 Received: from HE1PR0301MB2154.eurprd03.prod.outlook.com (2a01:111:e400:fc36::4c) by AM7EUR06FT005.mail.protection.outlook.com (2a01:111:e400:fc36::397) 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:19 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:9FB6386BAED82221CCA468CEF24AA0499BC24CD7F0B288CCA1364EC9E4EAA937; UpperCasedChecksum:CE37D2F7A42DE8B1FE57DECA57A6A7C889922B346CDD3B857671498C71206056; SizeAsReceived:7610; 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:19 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Fri, 30 Apr 2021 01:56:52 +0200 Message-ID: X-Mailer: git-send-email 2.27.0 In-Reply-To: References: X-TMN: [NtkLnzB/ibwRpjy6RYRZDN0ey4S+BMNf] 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-20-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:19 +0000 X-MS-PublicTrafficType: Email X-IncomingHeaderCount: 48 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-Correlation-Id: 25e00441-2700-45a6-2e3a-08d90b6acd8c X-MS-Exchange-SLBlob-MailProps: S/btQ8cKWiQnJqnaHo6w7XTEhYoMxTOUdiV/cvqPi1vyON20WG+G9KZgk9GyYwdnUoTjgCJzEbeRvD07kHFhPDn6wEQWnYojIzhiVu7/sHay7pOrEbX9mi39eU76mSSF1OocTQN2FPET5JtUrR/1vHNsdFz47Jsze1gOqoWSqogjnrLKqwkJ2F0uVwqYgnIs8h+cxXdET7hpUlTA3s9wG2ayLGfHx6gkfhBeYMceNhVyNzDzhEg/xWeAN3BeFMEg39Okm4YBBikv88yys45sjHgXM5MylSVVpL3Q6llPK5CCHmY7uBimr0r7oc9Yp+7yxiM6Qi+PjnY3QNlX4w7Lt/dcOXpUrJWrWwk5uiISFvpyaYrJHaU8j2SpAG9lslA7li0M5WAtY+69a0711ml37Mu5fPLidJZYqZb6BYazXsAeGtLGLGOJJepV5zsKceMIm+lV+USH1x4RCdY2HYnG66qZvSPpwIy0BzcdnZWdyX6naEVHGZnl9GbeSlf2IM8Eb+nignOxR+8gXWjAZ9A/jnq8btZrdJc/9eMhTJP+9CyavT8euQzap6vC+cdT9VDcYbGf4PLhdMYyEiWI0wJCP4J1q3ItSnCgVKYALdrGa7fe/gWEpJ9c98JJGuBrFWZk/0eOjRMOoJdH259Pivc9WyD6pDfA1B+8hgfWZA3oDVhR43Y0RV3Rz97JYZIglTNh9BBtdEps8igiCqazkdX1MZLQfxgbRD22pwek4JW59DZu06V1xUmosKbGn/LDs/J8Acz8LJDFkoI= X-MS-TrafficTypeDiagnostic: AM7EUR06HT034: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: urGQIXO0y3JJM7JOSzG3c4to4STlV5zEZm3movOXIcg+7Bg6w+Kr2W6kpSYm7zqL0pZBC8cwopkvyOUVkSNF9wg9dK68+Oeehxdldy+UMsu+AnF1WqZDvo183hEZkHJsQ6zXLuAh1ong0xftw3Nx0LTH+Baze2tHjcgoVGzunW600yMSWKPZ7hV2lIlSYgpwlmzzMHhrZhLZJvOw0u4T3neL//dSg3f4oG+VF29CLXdlyrfcGpwJcCuOM7OQWMM0OevW+eR2wmYbiGzyHuAL66sZPJxE6B/5FLQvkwQPM1gRNxynaXYJ0w+hdBq6d+iTkqSBYLYJ3lzCADjWeKX414BQQIyWhgzQwhtTXEOeBQC1gnz05WGLLMMs+9x29R2smjgeV9K8KrcC5jhuxtjsSQ== X-MS-Exchange-AntiSpam-MessageData: hRVd/5v9l4Fa2Z9+vj85ft53mGHPFICTIUF7QnfmPABmIb7exJMnIrBifMfCxGRn52lU9Tce3C8ZxAujREagtfbEapndi6eH2dB+/ybCbQSZspTQWYTl8LItGuhEGl6peQHOWawsHLYfaPppXbqHMQ== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 25e00441-2700-45a6-2e3a-08d90b6acd8c X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Apr 2021 23:59:19.4590 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-AuthSource: AM7EUR06FT005.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: AM7EUR06HT034 Subject: [FFmpeg-devel] [PATCH 21/46] avcodec/g726: 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: M31vSOX96l1D 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/g726.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libavcodec/g726.c b/libavcodec/g726.c index d643fbf968..8818589540 100644 --- a/libavcodec/g726.c +++ b/libavcodec/g726.c @@ -26,6 +26,7 @@ #include "libavutil/channel_layout.h" #include "libavutil/opt.h" #include "avcodec.h" +#include "encode.h" #include "internal.h" #include "get_bits.h" #include "put_bits.h" @@ -353,7 +354,7 @@ static int g726_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, int i, ret, out_size; out_size = (frame->nb_samples * c->code_size + 7) / 8; - if ((ret = ff_alloc_packet2(avctx, avpkt, out_size, 0)) < 0) + if ((ret = ff_get_encode_buffer(avctx, avpkt, out_size, 0)) < 0) return ret; init_put_bits(&pb, avpkt->data, avpkt->size); @@ -370,7 +371,6 @@ static int g726_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, flush_put_bits(&pb); } - avpkt->size = out_size; *got_packet_ptr = 1; return 0; } @@ -401,10 +401,10 @@ const AVCodec ff_adpcm_g726_encoder = { .long_name = NULL_IF_CONFIG_SMALL("G.726 ADPCM"), .type = AVMEDIA_TYPE_AUDIO, .id = AV_CODEC_ID_ADPCM_G726, + .capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_SMALL_LAST_FRAME, .priv_data_size = sizeof(G726Context), .init = g726_encode_init, .encode2 = g726_encode_frame, - .capabilities = AV_CODEC_CAP_SMALL_LAST_FRAME, .sample_fmts = (const enum AVSampleFormat[]){ AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_NONE }, .priv_class = &g726_class, @@ -425,10 +425,10 @@ const AVCodec ff_adpcm_g726le_encoder = { .long_name = NULL_IF_CONFIG_SMALL("G.726 little endian ADPCM (\"right-justified\")"), .type = AVMEDIA_TYPE_AUDIO, .id = AV_CODEC_ID_ADPCM_G726LE, + .capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_SMALL_LAST_FRAME, .priv_data_size = sizeof(G726Context), .init = g726_encode_init, .encode2 = g726_encode_frame, - .capabilities = AV_CODEC_CAP_SMALL_LAST_FRAME, .sample_fmts = (const enum AVSampleFormat[]){ AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_NONE }, .priv_class = &g726le_class, From patchwork Thu Apr 29 23:56:53 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 27519 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a11:4023:0:0:0:0 with SMTP id ky35csp2016614pxb; Thu, 29 Apr 2021 17:01:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw+YswU0rhG9TS6HoYTN6LFR21yOfmUGDtnrjD4HR8yZJZlWj+Nsbx39tNoZTbY9+QnqLRe X-Received: by 2002:a17:906:b048:: with SMTP id bj8mr1128256ejb.236.1619740861629; Thu, 29 Apr 2021 17:01:01 -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 sa7si1986312ejb.243.2021.04.29.17.01.01; Thu, 29 Apr 2021 17:01:01 -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=SmmVotGT; 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 CD0A568A328; Fri, 30 Apr 2021 02:59:28 +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-am7eur06olkn2106.outbound.protection.outlook.com [40.92.16.106]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id E5E01689F4F for ; Fri, 30 Apr 2021 02:59:27 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Z1seQeAvUNXooZ5VNvxr8y2aDzv8szzA664L9maGBvPGHfZLswNecrJbRgPWhspFA9f1tl7/DA5+k53xMfxu8Tp9+Ucdhcqmp1uwX5edRxXB7VrZyO1meGaN1p4azT7Gl67AZbI8L9TRMKB/T13ObiaOMEmvDXruJte97DjVDmxF8hM33s0IfT9ZE4CirIpvK7f4muh0D/uPHsX7vkreCNqtUy5PIyfKrMUwmqylC29Q+PO8ceU3JELffhUtzwiUSz5kKJKaqncKAc78b3GXEoXNe1G7JJkZo1GALtB9nL2po0Zei9WoymfMSF8aV6YD06NZN918qttWyb6whLdK7A== 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=zdvsghTMqRPUIlVGtNPDxFdAaDKllSD3XEGvO+sMxuo=; b=hS1xDgyNDavSI0VF8UjYH/Oojr8Nfx5hqZua4PMONeMrllNTmm7d/8gnJkSVPFVV0+YfOjiRSBIOXypN/2NsNvUoaAKhMnF81aLEl59hohkO9LuYKFopZyJpmg1VxzW/GBP17NqcL7nzHcrUjSFyO8WJSdqL05rvy+m4b8Ruc18FXoTHTR+IxyXiVgvh+m0enk6YU83VQ1QnQ9TfncSxHanjSZb1SRz1cPLi043T4WojFcljKkRH9I42be1uzqC0C9vReXliLQdZud+I+k+TM7ccCjMryjR6thGFhgcIj/iD9QOHFN8RN6cqZ5y523UQ8l0xwr3om8SpIsNUFmjY+g== 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=zdvsghTMqRPUIlVGtNPDxFdAaDKllSD3XEGvO+sMxuo=; b=SmmVotGTnxDaBU35r4wQdM1y2FlnKFwIJ68muF56UtXzWcvRLf+FLXG27USY2E9FDVM+cIPgSboGwtS4cW3GTwC27Hpm4s1xfQXrXccx8QGt9l9mS2nPZiJu3oYr69f1jbj3wlYVea3bH2cqt2VGDJtPUyI3BQ9G3T2pp3DM4ynFVaTFodie40YzlUXPUOtsat3h7Dn6kByrFSPpikBTzDwFrYYn0E4O9j34NFsnXc5Zl8RKthEWgfEiMaQMqGyphu40FwKbr4X/ClPq1oYbLkYwV6ZOj7ojL0rrdEyodFsGH5XtqZZYPA7rTXHHpTgMEJYZ0bJB/rmZ7IRFTGMHeg== Received: from AM7EUR06FT055.eop-eur06.prod.protection.outlook.com (2a01:111:e400:fc36::4c) by AM7EUR06HT175.eop-eur06.prod.protection.outlook.com (2a01:111:e400:fc36::327) 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:26 +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:26 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:D599E2FD0A275AADC4CA7FB758D358BCD58C7C2FF56E91FC2901230FF7DB62FC; UpperCasedChecksum:3A772E26CA9FD26BA25D3668BF47A26F4CB49D6A4F7CDB2E33270A4C47EC19C9; SizeAsReceived:7588; 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:26 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Fri, 30 Apr 2021 01:56:53 +0200 Message-ID: X-Mailer: git-send-email 2.27.0 In-Reply-To: References: X-TMN: [zvgxONxvCZYPXX0CD3C4Xk5zwRHGlRAe] 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-21-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:25 +0000 X-MS-PublicTrafficType: Email X-IncomingHeaderCount: 48 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-Correlation-Id: f90549ee-a4a9-43a6-332e-08d90b6ad19e X-MS-Exchange-SLBlob-MailProps: q+fD6XS3/UIO6YRda03MtHguxZve2k0PPQ+hppdbUVZk5oRVLNGDdXzQDINwa3b8q++oNUw3PD6TxAnZAL9AoZus1/ZtPb+emBMiDqo/mvoW/wr0w7mDzPqeniXzOUMe8SQmIanQaJC/RuRI3VXugsLpawI1mFktWMWgUsZ2UtIzCkR0C3I5J2fyHxIMCKl0/IphDSaruTIkmSvbYP3yAFUwo9lYSOwmAvKZSkpHmUcbvgk3vMx1QxoQSBnOfTuPbcZNROAp4I01rhd7QYW//9lFPrvob9Skv8hNH5dO7MM32KgCMbZuS4iBIoJoiuNmHr9UF/7onrknFk9pD261q28efQsmhXz2JcbgOoFRl6xMaXvtmDl3ipyBmxLCiyNMgMbcZoWdv9zZye/dGXKqr1NxNothCHb/nsykw2/nxf1W/JbXn66NzlXPgxQY/AoXCyiftBgezLyUVwTR4OLbC2Bm8077fMgoG3sdTv11VXmd0LtVRDqSCogVA/O+gddjOgHiwfZWmPQgL1uSAluNohDwHKR2jTcYG789P4uda+eWEqLXjafu+juE9VhtrSFqc7Ktxh+65cmnsQH2ZIebMrS1xoSbPwKFnPVGmJrvgBl/5H/kKC2Vu8/JObpZVNwijjQiSOHfS3fRGIZEyyWH7jlw/OmslWxauAUfJb35FxIQwEuuun0HV2sPXywTHQG2/1T/4NGt4Gs7bLTEv5FzNA== X-MS-TrafficTypeDiagnostic: AM7EUR06HT175: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 30kQkGSqIao72snWXzVM3zjhT91Fw3BsBFGwvPIchTrtQ8C/q4dDEh/JZujDLCbgqzQkvxIDU3U+G+vCkXAaUkBNvzkbmtfV1nIVa0cI1fbK5eiaWNMNAQuo0+IMitmQD2l1KAP/I9GiO9ETZUZ87ldNdJef531W6vtKLyjfmD4Xx0GbKAi610dFU3wCdzZawGERvucqirSXssxC7TV/X4JeeLvc1D+kaQ1M8no+1dkfVkrbps+BSSTkSbYtfk3Q9CTZNAqsQqBMGyzy43jbEar7cvQf2jnW6eOcT1qEx3JPRUcNkK+hO4Z3KlC6P9wun5+Rnfnl//GOFjjJSeXogXieh1LNJsjvTflQ7qOm+ITyTy/dofaH3ZQLXJgDDAYPTsrPzPL1FWlbvyHfrCAfxA== X-MS-Exchange-AntiSpam-MessageData: cF7xGrmWIQekyzoVE5WPGyfBvjxQqupIXsIe/hDQDtPFDgUdZjGLNDrpw6coW0jdi8hhx0fkSA32LJMa4+r4v+Ifl1w+srDpGW5wRsqax8q9q+QWn+I1vswXdt9hFIhgpw4+m6eYVx/mSgCNWOJyoQ== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: f90549ee-a4a9-43a6-332e-08d90b6ad19e X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Apr 2021 23:59:26.3129 (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: AM7EUR06HT175 Subject: [FFmpeg-devel] [PATCH 22/46] avcodec/jpeglsenc: Check for invalid dimensions 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: PiQ13UyZv3nb The dimensions are written on two bytes. Signed-off-by: Andreas Rheinhardt --- libavcodec/jpeglsenc.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/libavcodec/jpeglsenc.c b/libavcodec/jpeglsenc.c index 3e73b04c0e..15d9204b1d 100644 --- a/libavcodec/jpeglsenc.c +++ b/libavcodec/jpeglsenc.c @@ -413,6 +413,15 @@ static int encode_picture_ls(AVCodecContext *avctx, AVPacket *pkt, return 0; } +static av_cold int encode_jpegls_init(AVCodecContext *avctx) +{ + if ((avctx->width | avctx->height) > UINT16_MAX) { + av_log(avctx, AV_LOG_ERROR, "Dimensions exceeding 65535x65535\n"); + return AVERROR(EINVAL); + } + return 0; +} + #define OFFSET(x) offsetof(JPEGLSContext, x) #define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM static const AVOption options[] = { @@ -439,6 +448,7 @@ const AVCodec ff_jpegls_encoder = { .priv_data_size = sizeof(JPEGLSContext), .priv_class = &jpegls_class, .capabilities = AV_CODEC_CAP_FRAME_THREADS, + .init = encode_jpegls_init, .encode2 = encode_picture_ls, .pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_BGR24, AV_PIX_FMT_RGB24, From patchwork Thu Apr 29 23:56:54 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 27532 Delivered-To: andriy.gelman@gmail.com Received: by 2002:a25:49c5:0:0:0:0:0 with SMTP id w188csp1903159yba; Thu, 29 Apr 2021 17:01:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyzBnW8KlBcGNJQ9C+Bh/3LOIx4D0fMg22YLAYPhUJFboF7HyTI0+5b/8m89lcmi1OvaYGt X-Received: by 2002:a17:906:a44d:: with SMTP id cb13mr334824ejb.107.1619740872770; Thu, 29 Apr 2021 17:01: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 bz20si1682087ejc.70.2021.04.29.17.01.12; Thu, 29 Apr 2021 17:01: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=aMvHMqqh; 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 550FA68A3AF; Fri, 30 Apr 2021 02:59:31 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR06-DB8-obe.outbound.protection.outlook.com (mail-db8eur06olkn2047.outbound.protection.outlook.com [40.92.51.47]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 657D168A375 for ; Fri, 30 Apr 2021 02:59:29 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=N22FR3NzPws9niVVsVh6K9zrXUPmT0q9Im8X/6KNHgUIFzF6POBXQdo0+U4ow7TCH2xITwdlGl68DSyh75GZgLA5kdqaMOCbZ6XOAYC2BIMJFHokcCQ7UP8vmj2JbO41vpltpZm7I/g84eKprjBKzaihxKa6zQgeaNksY93rterX3Kr2UPg5eYrOOIxTB6vJRS5zrrP5QqrY3j5leJ6k+q7wV2XaVFs9LYghMI2V3mEZwh2r3TD50I5cGihr6paY+xPjgiSum237CIlNbGi3HLo2zBJPXlfo4DVNf18++bqbbZIWliDTK4rd3j5yOwcbTy0MwcD/USv5ONVzv4OGhg== 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=R+OQCXB/VcVWCr/h/5zRjstrPxyYNNZZW1Qm1GX7R9Y=; b=WuYigZW8qI21KqZAYCKOVtAjoVH1ZG+Zzz63RpqQOU4TWtDre8StW44yFKieSlWsqk8/EnpKkcHLAkiYamYmJsMA5XeMnkraleYL4yrX/LZkwpZi5nczIYfWc5guAJ/9M2SUnTvbudx+OkNWWwok4ylUs2+TzBy3DrTQkX6adB1lBBHnN9K/PqlnEu8igZ/CiBuVk95/T4+ADInXNmjK4a+HHYN6hlS5FgscgAkAyahTI+CwiZDaT0yZM8DcQwv13MQCSShJa4J89xoB0+vWn6J5h4pAGiUAXpvXhD/LHRSUp1i+Ucv3dMkjmvBZCTk+njQuIT0fK1/ZWINy9SYVlw== 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=R+OQCXB/VcVWCr/h/5zRjstrPxyYNNZZW1Qm1GX7R9Y=; b=aMvHMqqhXHPs3EV68lg2sYzLabARATgyN9voMDQaaGFGPJXmIATGJzIhrHr32BnGKtcs5IUVPk+3jdhJmCf4tkqITiLNNrnxUONFf5/sA4zl08Tr2NhdTFaS6Z2iKhEm89dTu7rqBCIs0XVfcG5ujqh9Ho4MUFuOzi4i4nkZUnn5C/PkDq8cXo9u9KzUHcCY5l+QEvzXD7VUv69bSajuLWlr1B9IelPvcxZ0Dq37J6lQS5HtfIsTsXMzq76LciyjTieysHrx5guE1Rt6hJtcuyLzDzgRehBn+UeXSJamVy6AYd+8tM7mJPHh7WcGlD2EP7/mvh6X/5yT+mblImnHnQ== Received: from AM7EUR06FT055.eop-eur06.prod.protection.outlook.com (2a01:111:e400:fc36::45) by AM7EUR06HT063.eop-eur06.prod.protection.outlook.com (2a01:111:e400:fc36::222) 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:27 +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:27 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:D73A943C8B7A0A971DB78EA395A51C5D8170CFDCB1DEB0EB654172828B262BD4; UpperCasedChecksum:832A6348A59F8A065CBD89213522F8DDEF0180BEFE293577506EE0C356A6CA39; SizeAsReceived:7602; 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:27 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Fri, 30 Apr 2021 01:56:54 +0200 Message-ID: X-Mailer: git-send-email 2.27.0 In-Reply-To: References: X-TMN: [U0BnAxd+iLTQhCM7W3MbxInrY7NAunv4] 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-22-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:27 +0000 X-MS-PublicTrafficType: Email X-IncomingHeaderCount: 48 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-Correlation-Id: f5585974-7aa6-49d6-6c5a-08d90b6ad273 X-MS-Exchange-SLBlob-MailProps: S/btQ8cKWiQnJqnaHo6w7XTEhYoMxTOU4wGPKUbhM4L2f118KPBbUMjOWbMTs6yGjuMugXcBQ74e734UH27wzxmo0IHFcgzqyJlGJMf84v2hgoHhY/vnbMpQRDpfKRqAseQr49ImwPib0nfgREre1PbIFUn2z9YqOMgwo8k73kKBoQYvr8GiJUuoKTUPnmz2ILROrXDs2rjOJ8fG89Ix/QzO7qVsMyFxC7NV2UEufstvey/SKBYgn1N5Efk/Z3g+xNOtQIjnr4XZQ/Kkk+byNqhacXH9NLPpCG1XIw4+gJEpFcK9z1wZhr0X/RT/pQwq+xeYURNijI59cJBOygsQuwi7wUZMml0LTehUhn8+yeWU1H0vLLbOsu1tkJthLTEgEyHIzNL5z/C+Cagp7g+FFuJZt5ruTH41lyr/K57lNbtbGkDcSITdhsNiMTuydMz6MLRH0ij0rp4NIUumf05jZc+XjkEd6zoviw/3z9EO/iAOI5ABxqVA7K1MB/kv/9B1FVLXfa8f4Pp4RWQIQwRllAaRCZ5Q+m1gjIRG8D8mFq0t+orpg3OCmjx25GCgKjaNxXTmtDm/kE6SLmZdxueAUnWWks5GX9jknl5tptme73Wx5OdkEVn1gLBuMrG6kxHTvku2ioyimWjBRySbPdJRIT9TKwW/uf/hS0g5yEz8qD6Knbz4Bd8nUNqrbPt81vuqP0zxD46omAhL5TPeZN64PWZ9Q7orsW2R+dwllvGqMikH2ftUJmjHwP2WI75sXl6XszQiffIydmY= X-MS-TrafficTypeDiagnostic: AM7EUR06HT063: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 2tpNPmYV5ai3gpoS/Qh+7sKcS8ilw7ScSLbLu29okQpjvK72CVQMMCNJRAUEjAQaqWwgVzRFxMs5NP/rq3QNSZQvC2BmClKXJSHeYCid5hcmVEVejxBn4h2UPddLvHmKl/Ee7RZlvsMEzUtWeYlokfsrPb6SIvnPgdztfRc81gguDyhYpVMk5v1ZwGE5N/P7/P4MGiA3NxvL1xGb6cGnkPGDn8V93BfdV15UJPSQXNPPVSdru1c4RqB+5dT2F+qH+0+fqkDPqv4Hw8diawqmEuE+Z1GMKKHaUo4K3f4NJYJMYaKx1msYxlWQZPe25Je4g4Q98YVpBNTnfvG8/meYpM0sx5iuboveVBruGKV9X9QOSb12qhT+6jDW06ykVDQMolcxteY1A8BuLPsU/EQ9Gw== X-MS-Exchange-AntiSpam-MessageData: l7cevu9PZU4BgOrTEDWln2tlIIu+JIMtJo29yCYhR860y3huwTw0DpHC0UHLZ72Bf41v0EpEBym5CthG0EOwbr3/MjEXo1jHMZTl7O+8cX/i2RgP7s1tro+mk457XzZYzt+eCr5x12YZO3LEkZ4Sfw== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: f5585974-7aa6-49d6-6c5a-08d90b6ad273 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Apr 2021 23:59:27.6413 (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: AM7EUR06HT063 Subject: [FFmpeg-devel] [PATCH 23/46] avcodec/jpeglsenc: Allocate buffer with fixed size only once 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: aDVaQi/WaIrC Content-Length: 3505 Signed-off-by: Andreas Rheinhardt --- libavcodec/jpeglsenc.c | 46 ++++++++++++++++++++++++++++++++---------- 1 file changed, 35 insertions(+), 11 deletions(-) diff --git a/libavcodec/jpeglsenc.c b/libavcodec/jpeglsenc.c index 15d9204b1d..17d46c0449 100644 --- a/libavcodec/jpeglsenc.c +++ b/libavcodec/jpeglsenc.c @@ -40,6 +40,10 @@ typedef struct JPEGLSContext { AVClass *class; int pred; + int comps; + + size_t size; + uint8_t *buf; } JPEGLSContext; static inline void put_marker_byteu(PutByteContext *pb, enum JpegMarker code) @@ -282,25 +286,18 @@ static int encode_picture_ls(AVCodecContext *avctx, AVPacket *pkt, int i, size, ret; int comps; - if (avctx->pix_fmt == AV_PIX_FMT_GRAY8 || - avctx->pix_fmt == AV_PIX_FMT_GRAY16) - comps = 1; - else - comps = 3; - - if ((ret = ff_alloc_packet2(avctx, pkt, avctx->width *avctx->height * comps * 4 + - AV_INPUT_BUFFER_MIN_SIZE, 0)) < 0) + if ((ret = ff_alloc_packet2(avctx, pkt, ctx->size, 0)) < 0) return ret; - last = av_malloc((unsigned)pkt->size + FFABS(p->linesize[0])); + last = av_mallocz(FFABS(p->linesize[0])); if (!last) return AVERROR(ENOMEM); - memset(last, 0, FFABS(p->linesize[0])); bytestream2_init_writer(&pb, pkt->data, pkt->size); - init_put_bits(&pb2, last + FFABS(p->linesize[0]), pkt->size); + init_put_bits(&pb2, ctx->buf, ctx->size); /* write our own JPEG header, can't use mjpeg_picture_header */ + comps = ctx->comps; put_marker_byteu(&pb, SOI); put_marker_byteu(&pb, SOF48); bytestream2_put_be16u(&pb, 8 + comps * 3); // header size depends on components @@ -415,10 +412,36 @@ static int encode_picture_ls(AVCodecContext *avctx, AVPacket *pkt, static av_cold int encode_jpegls_init(AVCodecContext *avctx) { + JPEGLSContext *ctx = avctx->priv_data; + size_t size; + if ((avctx->width | avctx->height) > UINT16_MAX) { av_log(avctx, AV_LOG_ERROR, "Dimensions exceeding 65535x65535\n"); return AVERROR(EINVAL); } + if (avctx->pix_fmt == AV_PIX_FMT_GRAY8 || + avctx->pix_fmt == AV_PIX_FMT_GRAY16) + ctx->comps = 1; + else + ctx->comps = 3; + size = AV_INPUT_BUFFER_MIN_SIZE; + /* INT_MAX due to PutBit-API. */ + if (avctx->width * (unsigned)avctx->height > (INT_MAX - size) / 4 / ctx->comps) + return AVERROR(ERANGE); + size += 4 * ctx->comps * avctx->width * avctx->height; + ctx->size = size; + ctx->buf = av_malloc(size + AV_INPUT_BUFFER_PADDING_SIZE); + if (!ctx->buf) + return AVERROR(ENOMEM); + + return 0; +} + +static av_cold int encode_jpegls_close(AVCodecContext *avctx) +{ + JPEGLSContext *ctx = avctx->priv_data; + + av_freep(&ctx->buf); return 0; } @@ -450,6 +473,7 @@ const AVCodec ff_jpegls_encoder = { .capabilities = AV_CODEC_CAP_FRAME_THREADS, .init = encode_jpegls_init, .encode2 = encode_picture_ls, + .close = encode_jpegls_close, .pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_BGR24, AV_PIX_FMT_RGB24, AV_PIX_FMT_GRAY8, AV_PIX_FMT_GRAY16, From patchwork Thu Apr 29 23:56:55 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 27501 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a11:4023:0:0:0:0 with SMTP id ky35csp2016960pxb; Thu, 29 Apr 2021 17:01:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx+e+n35KElWSqiC7ivK0gEaPKlUAHsjwqdEBJFGEEEWFq3EPJ/UXW4pVK501eavi/T60jx X-Received: by 2002:a17:906:1c83:: with SMTP id g3mr1091478ejh.93.1619740883942; Thu, 29 Apr 2021 17:01:23 -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 ca23si75722edb.279.2021.04.29.17.01.23; Thu, 29 Apr 2021 17:01:23 -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="iEEK3wG/"; 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 B169668A3B8; Fri, 30 Apr 2021 02:59:32 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR06-DB8-obe.outbound.protection.outlook.com (mail-db8eur06olkn2037.outbound.protection.outlook.com [40.92.51.37]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id EF59C689F4F for ; Fri, 30 Apr 2021 02:59:29 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=C/GrSt5NYeDl/9oD/uB2Pbri1ejqItzH9AQuNnzaxsjSIS1wcqk9ANvh5KKSEMDtfunvDm2BsyC45+cC8o6OI9/5s9ktG0hKj8NOrGs4Za8AUO6iv9+fYJhwJS2/Z5mYPOan/Vv+j2SFLVTkkDTRGi/FM3kLSqOu7TEnysFDPfXrOxPhd8W3Kmo4stMrp0hZgAlBkCy7wZ42NkcDDSk+tj+2FB8M410DL7DHVBRX5c4o5+St9h6U7d208x1qeMHJlOsPeV22M/cdsdxN1j2Yjxw6Yn+oTkH3ZdnGLTrOewdG0X6BSw7g2QfKQNw0k2DFb8hh5LdRmgUKoVhYUZ8oig== 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=rJhkp6n6kHEdWzhlq75J8ihYWhIQ1enK+4RJFaxY92s=; b=L+07YpHkKEmVk+UYgCY7zi7OD2CwqdS0+02gu9kLXELY+9+KsDbwzgXeHwR8wPWv/qVUlHRKHmB/PWSJGercjANxJI2Pvx/oOVYAR3vJmBLGjDNvlOMWidtRZDodw3jxUqe5tBmvWeQE8/sAzt2C4IwO0/yJtLj/FVx9mFhFCuPVFd/SokUOry6xJMksKup4S5ddAm8icaxCv8VvcSIPYcludOdp3qifJhc7cZ6J7l2MloIATK4UPjPFRVgMjlD9oRhyAyvbCOl5NvGiyUmojPHpdN5TT/FsrfzzERkuEDfwG5C/hcxBE0fvYEXtotvFBVIqnVRSZVdM2QjKIOtK5w== 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=rJhkp6n6kHEdWzhlq75J8ihYWhIQ1enK+4RJFaxY92s=; b=iEEK3wG/hHr0Mkwk+G15fxtZO22y1M8cADpa5TsoEY7Ig6zv1dYthRD3XeFN3cftKu/iDOCy43CaJR/c74EPDT++LOMtuWKOiY24u+o3nMyC5s0deYSuCj7MYQK3XNrU3+OIx01wE3+mkCvObRt5PMMz/RmRDgi0ash45VDpCS6th8M+UESAbnLdRpic5nnZOEl7CDMmEEvb797Xd1OL03+zurMjRI63/gVf7Coffz9JzL/EEkrGkXevEFxSVYzf5Ks1dfuLgbsGds5zRFv0jqnyTlZdNMgI0Qr6nJuyOfu6elerAL4shYKueuIRVwPuBVzvIq86NJyp0JYnz+WaIQ== Received: from AM7EUR06FT055.eop-eur06.prod.protection.outlook.com (2a01:111:e400:fc36::4e) by AM7EUR06HT158.eop-eur06.prod.protection.outlook.com (2a01:111:e400:fc36::490) 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:28 +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:28 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:1FE4774B76166EB06E74ECB5A184395BAF2F7DA84D65839E197E5DFCDE97ABE1; UpperCasedChecksum:940ECE74242911017828E949FA244578E38CE2E261A0F874B8D5DB5BEC90A3AA; SizeAsReceived:7606; 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:28 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Fri, 30 Apr 2021 01:56:55 +0200 Message-ID: X-Mailer: git-send-email 2.27.0 In-Reply-To: References: X-TMN: [rQtO+Wgrj9FxzeMUmLeYUsiecUaR5GbM] 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-23-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:28 +0000 X-MS-PublicTrafficType: Email X-IncomingHeaderCount: 48 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-Correlation-Id: fc2125df-7c2b-498d-df9b-08d90b6ad31c X-MS-Exchange-SLBlob-MailProps: q+fD6XS3/UIO6YRda03MtHguxZve2k0PFRWwNVam2X8mGv8oS+krzmVsIOIzxKHRQM8+j6S7rDeuyXZL2YmIcIOFEO0682+dfk9O6lOCQ2jCZ0Ac09r3o8Z14+X/uC2hzN2MbvqaaZQ1wal4bDYeqfrK8EiJ//Ouhw22JnE1DgTZj0u6MEjk9PyZujkfwXRLWi0Wk9uQKdv48CZYeFjKYFXPXgTi6MT3L4Yw1j3CU6ZWFZuE/rq2ullbXiJ7QLP+MhR1U8+xA3lHaDqI1Q5XYuhBfeyq59QckfVPjxH8b4xwFIJJUJPtPtfeD+80iJtaToCtJgm4rTqFCKAXL2qy8GljC45IReL7dnA768fcv2ZU03s8hvjNGmD2c7B5iatqrP/dwtBGoNsi3z/B3PV8osJSBK7FJfoM8iMe77oymESbUezlNoXpMNnpeqjN5LFmESgRI/rjO35359aBXT4mTqfZTtJnRMgHRe7aoo9HdtKT3xW1ceRoG4TAt3emGnxJ9xnlox84R5XuKmx2gLYAaEZLopuJpaGG/vpFqpXrB6u+yU+hIkqLy6RoqtSAMYlnYPtoMXXzVWSQ95fGYOkj8/r2i9giQ2hjeUl+NaxFRXbbuHDYT1jEj0lUgwIg1VkG76jLDRwghAaJ4Yf1eeMe/6tS8pLBXMbZmabhA7fivVbJVBBVy9eFyGGY15TeAVFARbQ0GioTl+kBtOJE5xYPPg== X-MS-TrafficTypeDiagnostic: AM7EUR06HT158: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: U3Yf09jwH6fVwVwD+ET3g7NYTkrEP9KplksfE7qsQyPgNL93k42sKsvQTSLzmCHnjj9lOVvxIzZoUyHFUEUEvmx6nl+Mw1yH0PSz0kr8uJoPK2iRDG8rzVmEVWGqxjBT3H0DFxFziwlb7sZLatQh2x8ZlDMSnOWF7o+dKQfzQpRoeYLWC50jgmHRm5XHR+RJZl8d8fd7Fj3Z+zR5xhzEj5DHTEoyXJ9DH5UFkNFsW0pYVu+xd3+uLdLFX/QmM6fBv4oJ6z0qBB8q5PdPFoGumWXXFSOrBWB5AkImTdT0Qwsys4C0di9CCWDCVCLOFmGGp1OSc2lcvvg8r7MSTuMTT6lyU7AnUOLsuxvB3ssDvyii/wUvEmk4cBg8dPS8wH+3mZREql53fMh42SUA9eGTpw== X-MS-Exchange-AntiSpam-MessageData: DnInsbFSaUk8bzFcB7uVi4523yDlpUBBPKp0bnQmfANdcS2M/WcBJ504pCzM67kRZ/vKrBu25WzuhA87rf9D0lzhZ5EzEcWqnzkrAke5wo3iZI9IBZz8nVrsdOAM8V9pqKGWZJfXFe8TC0efD397Bw== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: fc2125df-7c2b-498d-df9b-08d90b6ad31c X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Apr 2021 23:59:28.7658 (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: AM7EUR06HT158 Subject: [FFmpeg-devel] [PATCH 24/46] avcodec/jpeglsenc: Avoid intermediate buffer, 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: wZjA/QcuzntV Up until now, the JPEG-LS encoder allocated a worst-case-sized packet at the beginning of each encode2 call; then it wrote the packet header into its destination buffer and encoded the actual packet data; said data is written into another worst-case-sized buffer, because it needs to be escaped before being written into the packet buffer. Finally, because the packet buffer is worst-case-sized, the generic code copies the actually used part into a fresh buffer. This commit changes this: Allocating the packet and writing the header into it is deferred until the actual data has been encoded and its size is known. This gives a good upper bound for the needed size of the packet buffer (the upper bound might be 1/15 too large) and so one can avoid the implicit intermediate buffer and support user-supplied buffers by using ff_get_encode_buffer(). Signed-off-by: Andreas Rheinhardt --- libavcodec/jpeglsenc.c | 102 ++++++++++++++++++++++++----------------- 1 file changed, 59 insertions(+), 43 deletions(-) diff --git a/libavcodec/jpeglsenc.c b/libavcodec/jpeglsenc.c index 17d46c0449..a7bcd78275 100644 --- a/libavcodec/jpeglsenc.c +++ b/libavcodec/jpeglsenc.c @@ -27,6 +27,7 @@ #include "avcodec.h" #include "bytestream.h" +#include "encode.h" #include "get_bits.h" #include "put_bits.h" #include "golomb.h" @@ -283,53 +284,23 @@ static int encode_picture_ls(AVCodecContext *avctx, AVPacket *pkt, const uint8_t *in; uint8_t *last = NULL; JLSState state = { 0 }; - int i, size, ret; + size_t size; + int i, ret, size_in_bits; int comps; - if ((ret = ff_alloc_packet2(avctx, pkt, ctx->size, 0)) < 0) - return ret; - last = av_mallocz(FFABS(p->linesize[0])); if (!last) return AVERROR(ENOMEM); - bytestream2_init_writer(&pb, pkt->data, pkt->size); init_put_bits(&pb2, ctx->buf, ctx->size); - /* write our own JPEG header, can't use mjpeg_picture_header */ comps = ctx->comps; - put_marker_byteu(&pb, SOI); - put_marker_byteu(&pb, SOF48); - bytestream2_put_be16u(&pb, 8 + comps * 3); // header size depends on components - bytestream2_put_byteu(&pb, (avctx->pix_fmt == AV_PIX_FMT_GRAY16) ? 16 : 8); // bpp - bytestream2_put_be16u(&pb, avctx->height); - bytestream2_put_be16u(&pb, avctx->width); - bytestream2_put_byteu(&pb, comps); // components - for (i = 1; i <= comps; i++) { - bytestream2_put_byteu(&pb, i); // component ID - bytestream2_put_byteu(&pb, 0x11); // subsampling: none - bytestream2_put_byteu(&pb, 0); // Tiq, used by JPEG-LS ext - } - - put_marker_byteu(&pb, SOS); - bytestream2_put_be16u(&pb, 6 + comps * 2); - bytestream2_put_byteu(&pb, comps); - for (i = 1; i <= comps; i++) { - bytestream2_put_byteu(&pb, i); // component ID - bytestream2_put_byteu(&pb, 0); // mapping index: none - } - bytestream2_put_byteu(&pb, ctx->pred); - bytestream2_put_byteu(&pb, (comps > 1) ? 1 : 0); // interleaving: 0 - plane, 1 - line - bytestream2_put_byteu(&pb, 0); // point transform: none - /* initialize JPEG-LS state from JPEG parameters */ state.near = ctx->pred; state.bpp = (avctx->pix_fmt == AV_PIX_FMT_GRAY16) ? 16 : 8; ff_jpegls_reset_coding_parameters(&state, 0); ff_jpegls_init_state(&state); - ls_store_lse(&state, &pb); - in = p->data[0]; if (avctx->pix_fmt == AV_PIX_FMT_GRAY8) { int t = 0; @@ -378,17 +349,63 @@ static int encode_picture_ls(AVCodecContext *avctx, AVPacket *pkt, in += p->linesize[0]; } } - - /* the specification says that after doing 0xff escaping unused bits in - * the last byte must be set to 0, so just append 7 "optional" zero bits - * to avoid special-casing. */ + av_free(last); + /* Now the actual image data has been written, which enables us to estimate + * the needed packet size: For every 15 input bits, an escape bit might be + * added below; and if put_bits_count % 15 is >= 8, then another bit might + * be added. + * Furthermore the specification says that after doing 0xff escaping unused + * bits in the last byte must be set to 0, so just append 7 "optional" zero + * bits to avoid special-casing. This also simplifies the size calculation: + * Properly rounding up is now automatically baked-in. */ put_bits(&pb2, 7, 0); - size = put_bits_count(&pb2); + /* Make sure that the bit count + padding is representable in an int; + necessary for put_bits_count() as well as for using a GetBitContext. */ + if (put_bytes_count(&pb2, 0) > INT_MAX / 8 - AV_INPUT_BUFFER_PADDING_SIZE) + return AVERROR(ERANGE); + size_in_bits = put_bits_count(&pb2); flush_put_bits(&pb2); + size = size_in_bits * 2U / 15; + size += 2 + 2 + 2 + 1 + 2 + 2 + 1 + comps * (1 + 1 + 1) + 2 + 2 + 1 + + comps * (1 + 1) + 1 + 1 + 1; /* Header */ + size += 2 + 2 + 1 + 2 + 2 + 2 + 2 + 2; /* LSE */ + size += 2; /* EOI */ + if ((ret = ff_get_encode_buffer(avctx, pkt, size, 0)) < 0) + return ret; + + bytestream2_init_writer(&pb, pkt->data, pkt->size); + + /* write our own JPEG header, can't use mjpeg_picture_header */ + put_marker_byteu(&pb, SOI); + put_marker_byteu(&pb, SOF48); + bytestream2_put_be16u(&pb, 8 + comps * 3); // header size depends on components + bytestream2_put_byteu(&pb, (avctx->pix_fmt == AV_PIX_FMT_GRAY16) ? 16 : 8); // bpp + bytestream2_put_be16u(&pb, avctx->height); + bytestream2_put_be16u(&pb, avctx->width); + bytestream2_put_byteu(&pb, comps); // components + for (i = 1; i <= comps; i++) { + bytestream2_put_byteu(&pb, i); // component ID + bytestream2_put_byteu(&pb, 0x11); // subsampling: none + bytestream2_put_byteu(&pb, 0); // Tiq, used by JPEG-LS ext + } + + put_marker_byteu(&pb, SOS); + bytestream2_put_be16u(&pb, 6 + comps * 2); + bytestream2_put_byteu(&pb, comps); + for (i = 1; i <= comps; i++) { + bytestream2_put_byteu(&pb, i); // component ID + bytestream2_put_byteu(&pb, 0); // mapping index: none + } + bytestream2_put_byteu(&pb, ctx->pred); + bytestream2_put_byteu(&pb, (comps > 1) ? 1 : 0); // interleaving: 0 - plane, 1 - line + bytestream2_put_byteu(&pb, 0); // point transform: none + + ls_store_lse(&state, &pb); + /* do escape coding */ - init_get_bits(&gb, pb2.buf, size); - size -= 7; - while (get_bits_count(&gb) < size) { + init_get_bits(&gb, pb2.buf, size_in_bits); + size_in_bits -= 7; + while (get_bits_count(&gb) < size_in_bits) { int v; v = get_bits(&gb, 8); bytestream2_put_byte(&pb, v); @@ -397,15 +414,14 @@ static int encode_picture_ls(AVCodecContext *avctx, AVPacket *pkt, bytestream2_put_byte(&pb, v); } } - av_freep(&last); /* End of image */ put_marker_byte(&pb, EOI); emms_c(); - pkt->size = bytestream2_tell_p(&pb); pkt->flags |= AV_PKT_FLAG_KEY; + av_shrink_packet(pkt, bytestream2_tell_p(&pb)); *got_packet = 1; return 0; } @@ -468,9 +484,9 @@ const AVCodec ff_jpegls_encoder = { .long_name = NULL_IF_CONFIG_SMALL("JPEG-LS"), .type = AVMEDIA_TYPE_VIDEO, .id = AV_CODEC_ID_JPEGLS, + .capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS, .priv_data_size = sizeof(JPEGLSContext), .priv_class = &jpegls_class, - .capabilities = AV_CODEC_CAP_FRAME_THREADS, .init = encode_jpegls_init, .encode2 = encode_picture_ls, .close = encode_jpegls_close, From patchwork Thu Apr 29 23:56:56 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 27528 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a11:4023:0:0:0:0 with SMTP id ky35csp2017125pxb; Thu, 29 Apr 2021 17:01:35 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzpx62xfPEGii4PxrYOsxUoUinxLoOPoMzM9cAceOP5X8RazKZF8RQe1LMTGQM8FCPOxE+W X-Received: by 2002:a17:906:a28e:: with SMTP id i14mr1063964ejz.461.1619740895489; Thu, 29 Apr 2021 17:01:35 -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 l23si1842215ejb.573.2021.04.29.17.01.35; Thu, 29 Apr 2021 17:01:35 -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=IjQgK9Q7; 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 4273468A252; Fri, 30 Apr 2021 02:59:40 +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-am7eur06olkn2106.outbound.protection.outlook.com [40.92.16.106]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 9887968A2B9 for ; Fri, 30 Apr 2021 02:59:30 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lrvnD1WPOTv44FttceUVPPsAnNAfGnzWicMkLpJs0Jd7sC1k46iNNiDlXIuN3Py+hcPF9ViZRbZqFTE0lJvfuY+rjzfL3V3fDEp0DAHYqYynpXGmzMibpR6LatZU5ia/T1GlaVP4pT0PmE7OLeEdNykpZwaSbzjVn89oOqMjQwiIy/vYBdOT4grJFuFFsAtkjb2EQgJytCQIWD0nr9WrNR45OAbZUqFWhLeX52K3Ql1KS848z8W4K4bOIUaSp1/d2gk6KrXOuz8kc/fwy/WTzlWPuO4ODuchRC2Jgb2QmKm6PlyH7L56vo+IH90aUIJ6jxDOglhc6Uypdpm+vKIsXg== 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=h1l8lNnR5E/lq5pEcZeGighoCeXTZVxNcj8BtevHvtA=; b=ZaOaRO3X5lqHG+Q1ANj0ncaHB9q5260nXMFj/1oc9ePdpVeboAyzycS1EvvdkRmZ6xl6mV8wNY0GOkCwcSI+mMuzCwc2PsZDYVSlznFneVXOmK1xCAIUUvmxI4/3L1XVikmy7xdNJxYFx391AabWobf0iFVCwjOuOGyPW5WuBgnJ5p3DBXo2cwnLVXhTTMeXekn2HrmDcndCgNj/1e+kdZbIv5EXjuMvVOfzhwbfxTPZhZPSalsDkHSf5yw4QWYnbo3XRAt0qldW21ad4q60kKCcMfk3fLiyQjt4UyCoJ6WGGxc1yFW3LsYqzjyLuNscVhtI7reyKSiTC7AMHYNvQQ== 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=h1l8lNnR5E/lq5pEcZeGighoCeXTZVxNcj8BtevHvtA=; b=IjQgK9Q7osLwfZCrLdjCPogUC4PXSFbm+LV4JLkfGiSuveiyvX6fmVYj4KzBE6IPBzxYZIbdi9sFg1hrIZh6SthvC0gnI/nU8W52jaIzvl/E4K1A0dKOan/Bf0GUHRfx0FMpYRbF3calp4DWF2G6zP+bVs81YUYWQpF6rPOeAlo7s2muAW4V0A4Rkq1rDk9uvD9fIQMNizAlObSWsiEh1KmieoTHS6GZ2JN5bgrRL70GTNuBch5JQYP2XxaC3+BI7IsqkZM0dcAIYrpoK+bgUiiThLpzF666cBEF/dVmVegopHZNSbDQs1eu1Df0QzADTFiNlC4RsUs5wa48SrPRkA== Received: from AM7EUR06FT055.eop-eur06.prod.protection.outlook.com (2a01:111:e400:fc36::41) by AM7EUR06HT145.eop-eur06.prod.protection.outlook.com (2a01:111:e400:fc36::367) 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:29 +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:29 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:4171D094C4CB7B61AA3DBD1C251A63B5092AE29713547BCF2F9CACF42A0D7A8A; UpperCasedChecksum:390236B6C923145C4C750072375F52128188E1CBE83DD7AFA984159B9437739C; SizeAsReceived:7593; 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:29 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Fri, 30 Apr 2021 01:56:56 +0200 Message-ID: X-Mailer: git-send-email 2.27.0 In-Reply-To: References: X-TMN: [UQkeCIGMdg9g433528PVdc5EP+2PI6yi] 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-24-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:29 +0000 X-MS-PublicTrafficType: Email X-IncomingHeaderCount: 48 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-Correlation-Id: a5274a00-8a0d-4100-532b-08d90b6ad3bd X-MS-Exchange-SLBlob-MailProps: dEG5jEBie8lZ/qLiIvG7M26yVq6lLwmYXRyi5DHSv5bW5hdRURHrfVOeiX1dixqTGOsCvm6OGPl/KoxF7f+MoirpXlJ/GGAkY1axe/kwh70ZyTP5TuJoLn50TZVakUy4VbXjXZsthTBndFxrFzkk7ErQ6klrTF4qWV3vFXWWkZ6ye+TlYd8I55/2RF6/YW5Tst8ykWRVr2X5n4UWdJnLN0GXoKwk28f8DaltA9LPutEoTb4iDrW09QnHb+v8nVVn7KXt4XYCjG58FegoT5821hzMfMVCKtFhvDfsgs/24VICyNdOtDfNWMYGKkC/yziKUod5/4shvJkBfawOfgxOilUkjxTUF3sFSfUg/qKlXkeJxJS5LiWtwN7Xu69t4+K9oMfMWaK6CzxR9qLC033ZSoD9SNOlK4b0EP4tnissLiu3bTugc3jI4tEZo3KyJVmUGmsWIm2DXxq2iwbXLB3tpZnEtJMJpejc5CEP/DNyndK2uTguUGcPG1XKa4oM8gwjh2/Y+mjhJ+X/F1vUUG4rVAd3GsHY17GypDDv+1rjGZv77msW3hZvz+66AT0zwSFRV+VZs4a5Xg5O3rIYXG3DXzeglSKhrPN3xl43rtx54lMW5w0L+kJFL40y0ac7suls4bdyzv3yrPNmBPdmVHvD+8n20kIaA1rSPJwg6NwNQ/mVCj74+24I6g== X-MS-TrafficTypeDiagnostic: AM7EUR06HT145: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: HdGZ85M3NVJTL13JWpDzHUxij913YzVzOdg8QEKvm7V8Y2tUe+ch+d1J7DnH2jLqwCSMY59wVcatpQWOl6n2GzCG6Pl+5CAfaWHTEF0SiC9o8wenqsCtprsInA971zKYIu0FFDBnsjBgqU/+xwHwW0XbqacmPKwis+qUozd+01mIZ0RP69RYG6y6UZBvf47ckGLL+EjBW4QtNyhh9hTUHadWmgKrTuDS6Mz7hhfvEzY0zhALMuFRuQIxnsjds6UDvFz65pSA6KrC7K7vOc6u7Eq6N7LS0WhQdbTBaweNY7dElzKYIT/dzwV8H7sowiHV9GIPZWPbPWE2FpkPAGXc6ZqCoQ5ottpM2q8guSAcrOmBZ8bZvsghjw6INC2nJDr5ImX/+B7ITAGSnrfrZSiU4w== X-MS-Exchange-AntiSpam-MessageData: kyaAhnAvGTsgtk6Huc8YoV30prp0jSyqNi64YumIeawbtsH2vLCnl7t6qKz2gUN//sAhpcZwq3H08T/A9qOscfVV0bhw79hSkjXPsm4fOdpaAa+s/afLK8p62bYuZks+2bav6OuXxX+3tKnSEhaLWg== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: a5274a00-8a0d-4100-532b-08d90b6ad3bd X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Apr 2021 23:59:29.8314 (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: AM7EUR06HT145 Subject: [FFmpeg-devel] [PATCH 25/46] avcodec/jpeglsenc: Remove redundant implicit checks 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: vabdf3rTaIay Now that the proper buffer size is calculated (and checked) before allocating the buffer, it is known that the buffer always suffices. So use the unchecked PutBit-API; and also use an unchecked bitstream reader as we check ourselves. Signed-off-by: Andreas Rheinhardt --- libavcodec/jpeglsenc.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/libavcodec/jpeglsenc.c b/libavcodec/jpeglsenc.c index a7bcd78275..c80d7373cf 100644 --- a/libavcodec/jpeglsenc.c +++ b/libavcodec/jpeglsenc.c @@ -25,6 +25,7 @@ * JPEG-LS encoder. */ +#define UNCHECKED_BITSTREAM_READER 1 #include "avcodec.h" #include "bytestream.h" #include "encode.h" @@ -53,12 +54,6 @@ static inline void put_marker_byteu(PutByteContext *pb, enum JpegMarker code) bytestream2_put_byteu(pb, code); } -static inline void put_marker_byte(PutByteContext *pb, enum JpegMarker code) -{ - bytestream2_put_byte(pb, 0xff); - bytestream2_put_byte(pb, code); -} - /** * Encode error from regular symbol */ @@ -408,15 +403,15 @@ static int encode_picture_ls(AVCodecContext *avctx, AVPacket *pkt, while (get_bits_count(&gb) < size_in_bits) { int v; v = get_bits(&gb, 8); - bytestream2_put_byte(&pb, v); + bytestream2_put_byteu(&pb, v); if (v == 0xFF) { v = get_bits(&gb, 7); - bytestream2_put_byte(&pb, v); + bytestream2_put_byteu(&pb, v); } } /* End of image */ - put_marker_byte(&pb, EOI); + put_marker_byteu(&pb, EOI); emms_c(); From patchwork Thu Apr 29 23:56:57 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 27516 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a11:4023:0:0:0:0 with SMTP id ky35csp2017675pxb; Thu, 29 Apr 2021 17:02:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzScRBwCtuPBF634m+REhYOqrtmGnAT3eTKcRLdQZaofRosD0fKJ9h8iHhwjD/WRJK6f5Hm X-Received: by 2002:a17:906:364d:: with SMTP id r13mr1155695ejb.250.1619740935461; Thu, 29 Apr 2021 17:02:15 -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 ay17si1760006ejb.340.2021.04.29.17.02.10; Thu, 29 Apr 2021 17:02:15 -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=dctJnaeu; 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 364EF68A41B; Fri, 30 Apr 2021 02:59:44 +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-vi1eur06olkn2034.outbound.protection.outlook.com [40.92.17.34]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 8771968A3BF for ; Fri, 30 Apr 2021 02:59:31 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=NBdEVaRea9AxNjtUAllZa2R2a2YZn8c7G77ncIziDUHtynDsdpQnL3gsBO21d8IYpvxz4zftth16l4GlmhjDGvmdcNgSou3PcP8vflyCGadq5GlF4LJ2PHKatgAfehjvNr63xwgF5bVtCtpnbwmPvDi94u+d9bNZ66GPiQoGtpoaYJPV2ELB41LluvGV9pk/o96hH5lMByBQ89vsp6oTKEG53F2avfGXt4+TKjZrpJaO54cX0so6Va1mS+ofDZM/rhYyZO5YodltLBYAF+6muEGbk+tRjxRM8xBXllbY8djbeb3feM6J1t+vDKXsXxmxHX5IdptUvPI23QJ9+6apFg== 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=KUa3YM4ZkhtSwTPqg76fR879iTw4fGqs2RbaF/Kw/eY=; b=DCtVZ1W1FJ4mh4y5e3oxvUYg9kpaf1nlSUsY6XF3oBp07Ao+XcfXTv3o59WDm2ViS8i363hItBsSh6Z02n9MV+5xIRRaz9bxsZdwVLtwSH1kzjuJg8tHEjbKBIaRD6jYiubSTBlFHRGAmCFnuYNak5xZkmmf4a4H3ocCNGl68IAmJLZ1tU/clyfUKZ4Io0e682N5+jDLbZVzZMqjXC3zAPePqFsM9sK3gZC+fxsFw3x65ICGw7OyN3ccSJZ9JyZroX+5uwOFd3/cOePyGEnmlfjeAYVoneWaYkuf/CYKuwQL2VnGPCwraqY7w5K7VELWD2/B+G2CqsNh5iiG5Tuc7w== 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=KUa3YM4ZkhtSwTPqg76fR879iTw4fGqs2RbaF/Kw/eY=; b=dctJnaeu0zjuX3PIAN7AKPGlaNzPcKv5g5gM2+GoDrhCLRXoU4mKAuCguFKBXS3N2ETuWn2F+bdeDOBwWkqDGa012fJ9LUpJAIwPtEIp2Ql+xlnMO8cnXGn9IG6IQwvp6lL3gCqjxuOpFGdf1huQgVm/FJTI4MbUldL3mqRXGtvldKctEM7PBCyfi/C0aug5RPV/GCkvSQumVbtIioRXvUSt92CfNDgX+A5OzCDX5ISKudTZuRBmaSZ/Ilwm3PIwUsOOCuEYXRGrbKgmMYg49qLYpXHm3KbRKSew/iWQf6DGIpQnC/03e5B7sQkaD6K/nxuHRORrEMc1JahwhS28HA== Received: from AM7EUR06FT055.eop-eur06.prod.protection.outlook.com (2a01:111:e400:fc36::4a) by AM7EUR06HT132.eop-eur06.prod.protection.outlook.com (2a01:111:e400:fc36::155) 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:30 +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:30 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:C3F2F164A7477761F13476007E0992D024B5EC7BD434A66C8E1FACF1D8D7082F; UpperCasedChecksum:DEC8824E237E22D4E9463A8280A58EF652B0DED90084F1406160DA16E5B730C0; SizeAsReceived:7585; 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:30 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Fri, 30 Apr 2021 01:56:57 +0200 Message-ID: X-Mailer: git-send-email 2.27.0 In-Reply-To: References: X-TMN: [DEuV3EO/iAdIj+/OyFWmNYiuHjnWyBby] 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-25-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:30 +0000 X-MS-PublicTrafficType: Email X-IncomingHeaderCount: 48 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-Correlation-Id: 560a3113-ad7a-46b3-2ae8-08d90b6ad454 X-MS-Exchange-SLBlob-MailProps: q+fD6XS3/UIO6YRda03MtHguxZve2k0PwSXqXz9fm/4d8XAf5eYulkyJVcjX48uwrvCbIycSCsNVbwLmKhKrhJUBwRNSjTiQ2UWsVUe/mgqaAvckgQshCiTU7+PuXKgNdQswyVri+GVwwV1NrA+jrfzwUNosdXJfyIxa6/GU3UX3SvmM2XxaIQWIJuB65LUX2r0XR12h8i1KM+WfW4IiSpQq1RITl+938arIBJW9hGo3lz45GN6J+ihmmBqWEMN7E51yGm69uULvnZNlwnGZ3Jd9KDDMcHIvjqsH9Q6zoO9T73SejMSJ90XN3DMVGzpLMuOpzVh1egX1bgP5YdD7Zeu/dM+LAPwnZjBeAyphM1VTgS+6bBRT0sW1Q9uBMsq6zByFKjtAPfAEg6WryJi+BCFbv54J2hVfuYYOv3PJCdF5fiaNs4OUPUGNJabV785OA7E2W10kDapKGg41L3gik+uOklWo2molte7y4D7w16roaqHcLr46jGmkvAWhGBYDxXVTmjJizMHwwizhnw2Bzr65L5y52ALF7UzbP3Wc1cRrhieXroemZq8P8R0NUvtmBtiVAhgvKeWnf1b77+w+7nzPO+wqnyjDHlyH6+VrKmdRCXxTA547ZXnGFBuqYlcSnEaJbvNwB0VUVtZClNrrvT/RtGFcjbZzKB2L7UxpWWtaiQXRJ+/BY9zVcNXVE77/RzDXfiKJ+Sn9RrLzniIjbw== X-MS-TrafficTypeDiagnostic: AM7EUR06HT132: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 2Rzl0tuytQJsvfJdYmX+GaF6q3SHrwYc9DPdYR90YLLF/yVphfIiGUgOk2TVap3TnrJvLrmbSIIsE/Kd5HMcrU3Nk3bPkKK7wyddVG6SbmUkZXFBlp6ZSWMZMt/ww+p3s3V4JqbQdPv1SxSP7HMFLMAPvm7rTNc+2un3PYW+sFN5AKklr9+ed5TChd3156WXBKkp97c7Zlc6BbjqlW2HBo4hZmtfsXCBEkGXnTHTr+nF3ujxLuiV1925Luda9mVQdI7Cu5nYVwKGunwBm1aMcPRRTpffQEo8y14YiMW0oFDfwPtki0+7iDorURufuVspD48CWteDIdr7TglftvUi7BFgq/Kkb7SND/1bILgaV39xpiYfTIn3ufEe455kpVIEMjeGABVhFJ3aL24WfDtxRA== X-MS-Exchange-AntiSpam-MessageData: Wy+nYjigHkNrrNwVNK2bnNi4lnLzyG62xyZrqgs5GFJzZM8r+/U4fri+vdKR76Bua8PHyE6CV0VRMOk8z2+pNbQpZQnMQ9urR51pah4RhVL6IWbdl/t+ZQABRMRpXLILCk3VcQmK2EujwoPpW7eWKA== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 560a3113-ad7a-46b3-2ae8-08d90b6ad454 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Apr 2021 23:59:30.8419 (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: AM7EUR06HT132 Subject: [FFmpeg-devel] [PATCH 26/46] avcodec/jpeglsenc: Remove unnecessary header 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: XGtU7EP5kh1R Unnecessary since 130d89d786d29148deb846de48b16e11a894e8a7. Signed-off-by: Andreas Rheinhardt --- libavcodec/jpeglsenc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/jpeglsenc.c b/libavcodec/jpeglsenc.c index c80d7373cf..a0552b3c54 100644 --- a/libavcodec/jpeglsenc.c +++ b/libavcodec/jpeglsenc.c @@ -26,6 +26,7 @@ */ #define UNCHECKED_BITSTREAM_READER 1 +#include "libavutil/opt.h" #include "avcodec.h" #include "bytestream.h" #include "encode.h" @@ -35,7 +36,6 @@ #include "internal.h" #include "mathops.h" #include "mjpeg.h" -#include "mjpegenc.h" #include "jpegls.h" typedef struct JPEGLSContext { From patchwork Thu Apr 29 23:56:58 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 27533 Delivered-To: andriy.gelman@gmail.com Received: by 2002:a25:49c5:0:0:0:0:0 with SMTP id w188csp1912277yba; Thu, 29 Apr 2021 17:14:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxKUa2LsKQc288qB9yFfeeCUTB99aer8fp+dMXZoEo9crSd2ojDU9olRJ007Rk2xB8z7Fm7 X-Received: by 2002:aa7:cf86:: with SMTP id z6mr2635330edx.120.1619741679765; Thu, 29 Apr 2021 17:14:39 -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 d12si1714638ejj.422.2021.04.29.17.14.39; Thu, 29 Apr 2021 17:14:39 -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=PDQXRrsz; 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 4DDF068A375; Fri, 30 Apr 2021 03:14:36 +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-vi1eur06olkn2010.outbound.protection.outlook.com [40.92.17.10]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id A0D486891CF for ; Fri, 30 Apr 2021 03:14:28 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GeTBklG4wgjjXSjQhNGu6Pe6IZKULP3HHonEAaLKfWe1Bbivk5pAsVHcjxxbkqxz13b9w1QstfE0gP0zf2SAsAhGxnlEhWUOnflt9z46EaZzjNDfRVL7fkYmVMu101CPfOZD+rtxmt1dmJn+bNurAzZfCu8UU0G+0a/7iWxNia2JJs6LnjaxwK+dEtADnFk8cLubPHLMeB38xqrsvhEXuD4YxuBm7xXPDNrgDoVHm+Hy3tqBy7zydDtOZue6/34X+AhRA6SgC5K7arnZ0o7AKVRSCdcQ155hgucKir3iIzvSg4ZNnH5JC78AWF4ltHu0tF0xiIzUHCF1g/gBofDjEw== 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=71W9vra3B4q86GznY/2BRecpRPtYaV2Knm3AVCEnO4E=; b=IyNTz8NYxaxIeQkOK4/B6h05q8EXAEFwPWZPQkqh0cCiJyHEM8Jo9p9x93dDhPjFdDWPpuPmeW67CnmbkKoaTF422kxuvh25ETJEYMPH8UvL0dmpJbWkKtjA4LVooRIyL6y8JaemOqsuClbog7qQjgFwAfkBCtw6PYYeza3E+lJyFAUZM2q0vGXD2bhDjcqicg3kAdatemH6WZ5Kxqy39F/9ldKgJ0dJf2LmaESNaVxjVHTDeT+cZt4M8HYI6n65rNtZ/Q8aIZnPpJcyW/6IFblL12Zm0HMHCzHCmAbeEqy/F3lV6BKG8uyqrucQpJyHDRB17KIinmJ3a0aXg98etA== 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=71W9vra3B4q86GznY/2BRecpRPtYaV2Knm3AVCEnO4E=; b=PDQXRrszWaS5moZXBaXclXM8gXEkBcPGFIxXPX3suziL7eI3nMcRYNNUThPPXP9Jck88qUuLo5VV9dyuEq3k7iyPVaJE1Mk1vYPInOugwjitx7orkOCfn0fObDIMsXtapKctuhRGD4PnqzbISfTKfZVWGRhFjlEa2gkR+FLN4dbk3IaTT23PlLJxs3viye2qn7UEYSWBhlSyVhmIW8hkiBpbgyA/uw92Ltih34TyV0f/KAAHczNseSoCneUa1EbdRmAFhpOMJZU9aRXA8PIQBISz6hoDmKsAEjYFGP2YuWN8aY0xSpNjl2q4nNcC/zbfwyCcOMUzR5f478dDHFYL1Q== Received: from AM7EUR06FT055.eop-eur06.prod.protection.outlook.com (2a01:111:e400:fc36::40) by AM7EUR06HT040.eop-eur06.prod.protection.outlook.com (2a01:111:e400:fc36::94) 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:32 +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:32 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:3ABA531351DF62DF17928F0AB4ECCB72D46A6F8215CBCB1F222B5C4CC6BAE44C; UpperCasedChecksum:42A4862D4E9DB1C2657878A39FAD084B60A331BC8518DB16DF60AF05B72DB359; SizeAsReceived:7618; 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:32 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Fri, 30 Apr 2021 01:56:58 +0200 Message-ID: X-Mailer: git-send-email 2.27.0 In-Reply-To: References: X-TMN: [g30ydo/OkjJ/XQx+yhHPsZk3tYSzd4CI] 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-26-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:31 +0000 X-MS-PublicTrafficType: Email X-IncomingHeaderCount: 48 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-Correlation-Id: 66742bbd-4cfb-4d1f-ef49-08d90b6ad51f X-MS-Exchange-SLBlob-MailProps: S/btQ8cKWiQnJqnaHo6w7XTEhYoMxTOUtcA6bzJ0rs7JsUC/xI7faNOwIpqM5hIS/7dGyVs9l2/taPZOOc3ZhMGuNw3lojFrt3RF9IeG6tO+Kd5VrG8mfH/erQ0eDbcmjHDi/Zp8WHmx9isEVMpZUwtuMuCnMaSr5W+CVIWw7EJbyCDEiSx2rw/+kDlVk9jOgCP4BtHa2hW70TEdaS9vUknOMslTd9fYTexLo0D5Xm7XusHn5q40c1L/2nd6bUxfwFg0PBpw5UW0roqJ5nETsDemu/GJ+DyOjLuWIwUdbILGj8bnMZmRef+j5cg1o3EgUHNfMiqBphCacyr2wCaW9/xwqcmv4Eq916AYMX8dQcCWfwYlZ/MoNEGXxyx/OXrl3+GrVF9OgC6Gn1IHoU3LRxGAzUWClIA+08WRrTncDxrx6R1ubOOtNi/+pTKrm2NSSimvekLlgxjfNn6AeiU3zwbTgHwBDNkaXg+qR5+sFYzP49IuUujgSodzs4aSVCOc7S5cOi+VowZd3uhXCZ1PHH6QIMuwjC8cX70E7IbQ4jcwzrmHdhAAqKchdHX+K/IdNG4O53NkmjGtuB5seGCBuZm/qCnr48k3Cb/eVt0k3yEpX6u+TfDRYU1B0HvQhzxpg7U4XdV1cs0NrO8jw75F/cHUSMfiE9m0wiUt5dSRvmMrMw2aKWirkPEzL3qBhAFi+MV4Amme0llhkBBg1FoNT81a0d/b90sNdOrAW6tMbEj+BWDe6MPmKq2NDrKbhKtwHC1iiwon0EA= X-MS-TrafficTypeDiagnostic: AM7EUR06HT040: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Kh/uG6+k3frwjgKfgluTtj1iyYN/NV7QHSUxa62eXA8rcKup7JbKZ/RAlQCwVI8EcD2kkv9LE4yKBOl5ZnoAp1Rva9U59gqiVoCzxeFCz19AoQ4htsB3AlSJTHq21SLe6v09379MEqy1vUNU/l4HjCuKNtEhGKISF5kvAKcApBbuWDbJONGNOjcW2xYZqN/pXBCU5SSShaswZLGDXottw29hcqUrvTxa1fidVtk5mk8/Lb66gtDK9U//Q4qvE3dVS97mlhcHVssMc+UW8fdvr3+9vyGZDyiILXvj0PHQud2uhmq1XBag9ufRfQdNuo4qyTAI3kiSh2/ZbrQz2uME5zY3UKKTAm4qbvLCNAi7siVrhmFKWSooY7YNQx7X9mTGyF3vh1qVfBIPPSL5ZmNgVg== X-MS-Exchange-AntiSpam-MessageData: n+K6gdle0wgnh532oK7NLcuOHpEurZJ10iV/Y4aeol/n8bZMvWxzsw+5gQ7sBPx4n50RPfzee9ex4MJaxU70ax5pztBR/IPDxV+akRJDbPnx/87MD5Oa0r47xDFbxpWfQTVuPHGNwXPRiRJuV4KsZw== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 66742bbd-4cfb-4d1f-ef49-08d90b6ad51f X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Apr 2021 23:59:32.1573 (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: AM7EUR06HT040 Subject: [FFmpeg-devel] [PATCH 27/46] avcodec/nellymoserenc: 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: PIXeD5jc+NIT Content-Length: 2089 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/nellymoserenc.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libavcodec/nellymoserenc.c b/libavcodec/nellymoserenc.c index 2e13e6af08..41d9117065 100644 --- a/libavcodec/nellymoserenc.c +++ b/libavcodec/nellymoserenc.c @@ -42,6 +42,7 @@ #include "audio_frame_queue.h" #include "avcodec.h" +#include "encode.h" #include "fft.h" #include "internal.h" #include "nellymoser.h" @@ -405,7 +406,7 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *avpkt, s->last_frame = 1; } - if ((ret = ff_alloc_packet2(avctx, avpkt, NELLY_BLOCK_LEN, 0)) < 0) + if ((ret = ff_get_encode_buffer(avctx, avpkt, NELLY_BLOCK_LEN, 0)) < 0) return ret; encode_block(s, avpkt->data, avpkt->size); @@ -422,11 +423,12 @@ const AVCodec ff_nellymoser_encoder = { .long_name = NULL_IF_CONFIG_SMALL("Nellymoser Asao"), .type = AVMEDIA_TYPE_AUDIO, .id = AV_CODEC_ID_NELLYMOSER, + .capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY | + AV_CODEC_CAP_SMALL_LAST_FRAME, .priv_data_size = sizeof(NellyMoserEncodeContext), .init = encode_init, .encode2 = encode_frame, .close = encode_end, - .capabilities = AV_CODEC_CAP_SMALL_LAST_FRAME | AV_CODEC_CAP_DELAY, .sample_fmts = (const enum AVSampleFormat[]){ AV_SAMPLE_FMT_FLT, AV_SAMPLE_FMT_NONE }, .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE | FF_CODEC_CAP_INIT_CLEANUP, From patchwork Thu Apr 29 23:56:59 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 27508 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a11:4023:0:0:0:0 with SMTP id ky35csp2018011pxb; Thu, 29 Apr 2021 17:02:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyk2VZaa2r8G1KjHCSpRydo7MVrRLVk+ttlUpRGyrL7na2B9789cUdoU61qkRlnXCIIIoql X-Received: by 2002:a05:6402:c1:: with SMTP id i1mr2487373edu.315.1619740957776; Thu, 29 Apr 2021 17:02:37 -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 q9si1459316ejy.299.2021.04.29.17.02.32; Thu, 29 Apr 2021 17:02:37 -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=l6QVmZvO; 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 C2EEC68A437; Fri, 30 Apr 2021 02:59:45 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR06-DB8-obe.outbound.protection.outlook.com (mail-db8eur06olkn2059.outbound.protection.outlook.com [40.92.51.59]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id BE15D68A3BE for ; Fri, 30 Apr 2021 02:59:34 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MjfnTOrszIG94p23hBhH7Otw57ZH2GHVFUMuDOvRM9ex1cx9jFYwlDQihCSZzhEPhVg0gxkcxL1pSFrz595Dm9qsxus4dM5uzyTxm1F2PROPcIPartOenGf3EhTQ3fGyu+zq3dLJYcdnmI5AUadNFp9ADhGeeeqTmasilBAgTOvONrGLEtYZXwe4DF4ntubAnRlBKM8LdrBrLirmhHD+d5stDW9bh5LRDbf2OB4c8o1xZFi2YP58fTlUEb6bjPOR4Xr6zBMGlG8NthtzbqCdF4GkE6S1OPNL+OQow9sHOLwa4/3YNjZoyqwS3nhGVnR24GqtpQ2fJuuU5RLh7SXiQw== 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=mHUYtTHbLQFDjTKyfjggu7bgEsYMAiZRzXc0LM/4uzY=; b=I/wrEewKSSHjmzh03BQ7tYXqIsCNdnRvI8wbN3H+Zkd9Iedpq4uNWfweNVw9tXlCcMIdG8rtJ/x9UA7tTer0v+JDVvUT84UjphPTiuFMfbpwHiMhg6PPjjxFCeKx5wt+vPN5r1O8HIuFk0d2i/ZJsnqeSQJF9qJ4Yvr9oXa/8z0wRSbG5jGYTawOWQFUAwQD2a7tuIMWWWewomZjoUg2Bmg9Y5Z0UyO3n7ZxHa9eajBTLIkuTibtcYQ4sR3caOsm3c84n3h8owEinXVKGKZ/HbxsGtKde51wk68gP3ZbeufebMB3zC+5RGSqiNwP1r6tleauldt3uh9OGtlerLe1Lw== 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=mHUYtTHbLQFDjTKyfjggu7bgEsYMAiZRzXc0LM/4uzY=; b=l6QVmZvOtd0Pelvh/sM+Ix/v+ohFLFtb819xFA7yDyMF5Nq514byTAY6+Cb4Dwxu7O671zx9a13QLxK4VRfucFp47bky+2p4Qx5MxFDVJsu1ZyWDvW+/U0eaj9C3ELjhFkC0TvExLNuXA/O+u1/CJRHEVtyhVpXOcFHk7cwcAqdD/MKLrvq1aNSf+cDWxEQm2fOsxnXWZiEpwEAW9NvGCIR4CGl1PkSmysvjv014YXjWJpNqm3n4mqCV5yOEGupm0qNoD5H5dJF6htiIEO8teG0QVrWhIE0oDsCsOfI+8ZOtjlflmQr2260wshQuNbcWps4KknJufWJQsrU9/+1/aw== Received: from AM7EUR06FT055.eop-eur06.prod.protection.outlook.com (2a01:111:e400:fc36::41) by AM7EUR06HT098.eop-eur06.prod.protection.outlook.com (2a01:111:e400:fc36::130) 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:33 +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:33 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:64FF5D788DC1519EADF74F06A83EDB6FB33552C1F9F25DAAB5B5D091793C731B; UpperCasedChecksum:3F55572FD6ABAAB1781FE205A8BC363D1E7E5AE2C276865F528F9B08565792BA; SizeAsReceived:7616; 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:33 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Fri, 30 Apr 2021 01:56:59 +0200 Message-ID: X-Mailer: git-send-email 2.27.0 In-Reply-To: References: X-TMN: [3p4rJNS4aOHZ7yWeoqdU+renfKntNAc2] 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-27-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:32 +0000 X-MS-PublicTrafficType: Email X-IncomingHeaderCount: 48 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-Correlation-Id: 43744281-eed3-45f0-57b9-08d90b6ad603 X-MS-Exchange-SLBlob-MailProps: S/btQ8cKWiQnJqnaHo6w7XTEhYoMxTOU9yELH1qRlIbwB2HmR2GBCRzf6G1lf1PxXN23Tiif3Ane4vfzSTA8uHSA5VQRD6quamzceN4ML2CVXajS+i1ab01U08Cal5Z3raeD0DLkglzlSSFJ8z7QfDpajvSvx/pUohbGCjPi+aRR39wKJoY2EnwAXIjImue6/die2hLrnQMJ6VjNTWP3zWISpiDsayG7PYsDxgVA8UjP2Lld2dcAApUwLWk0p7GuECktkn+GjunT62cbtPbTko6tKtEJKUXROwi2mfjsg7QJKIRCUpLc5MO2ckztdSkAYZsd4OtW8zPptFKNSGnFEasNraz2+T3NYt9tG61iTNq4OAJeADx2YO7RoYkYobpxCaf79fygQBOyN/Fcr2MqTBAXxYdmUQoNlr9yM6OH9LjPfGJxl2YF6yxwRwacw01Qppv57FPtS0LqV2W8BJsK9uRMON0q+P4KUq2nJmatqS02P/HsdDuNSgKZqY9MLzaAcT/UXnv1m555H6YRP59OB0tDQ4JXYSDt6Z32RsrkRqPQro6P1yNepXgIBZlEuEI0xsjpsMByv3cK0Z5cx04wa02JqtwpN2kZ689/G6/Dz6SLBHDZ++Kd/YIBKSrj3TkPiZps0U487+c7/G6UzW0wsLC68LHnNv9RhEwsCaQ+AFEyI97l8mjPq1vAQF1nnQwmS0k5OEr8gE11Tb8j5rTTufOXfPM951r4+aT42UVawWPnx/yvD0SHOxqKVvzbr+mTXqLi1snwzKg= X-MS-TrafficTypeDiagnostic: AM7EUR06HT098: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 6MT3kPd1sqkMCSlYJAJMDrgXbe5O6tTREkLV16GuhN3TjL+UESzFPB7tO9ZldPDUTvKAwGSpoBfuJ3X1ZBDPCCncofLwjyKA4f298gLQ9ooE1z1YsVdgfa/jS9GEq8u38gK9gzExdU2YdkhkggPmSkxc0pqNWtqhNagsRgAcJGmOzlt6WHJ0R55Nmg7ukgcJwaTIV39co/++7YPm0cPpJK5Ws/6oxFX7EgqHYGUJgYXm+PIXRcjB9PNvWu7r4SHUu2Pv35IOleXkUmcjcfqlSMskYliamGNla+WEkyJWB+ugWSuvAWxZsUj7+v1qJ9pVxxHwgDGBXFO7J7FLkRiUH4LroM6YJJPgtxFTzZs7huX/ZRNF5hlf7DdOZj5A5mMk632UUhbZro12jU2Daj7QFA== X-MS-Exchange-AntiSpam-MessageData: P/9ewQdc/Xmzfx84QOutOjyEAppEQlootONVPdSSNB50VYPBFD8EpMeT/1lbEm3MFPrnjGUtyvhF3qbU2TflYQ6k7ZXHl5VZv2RarmmIKk5ycEGIV0oIEM3T2hSP9S4OOHR+wYA+tKZH1GenbNIjsw== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 43744281-eed3-45f0-57b9-08d90b6ad603 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Apr 2021 23:59:33.6747 (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: AM7EUR06HT098 Subject: [FFmpeg-devel] [PATCH 28/46] avcodec/pcm-dvdenc: 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: eJDZ9mVEeBy3 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/pcm-dvdenc.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libavcodec/pcm-dvdenc.c b/libavcodec/pcm-dvdenc.c index e644f30f5d..ae7de65f1d 100644 --- a/libavcodec/pcm-dvdenc.c +++ b/libavcodec/pcm-dvdenc.c @@ -21,6 +21,7 @@ #include "avcodec.h" #include "bytestream.h" +#include "encode.h" #include "internal.h" typedef struct PCMDVDContext { @@ -119,7 +120,7 @@ static int pcm_dvd_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, PutByteContext pb; int ret; - if ((ret = ff_alloc_packet2(avctx, avpkt, pkt_size, 0)) < 0) + if ((ret = ff_get_encode_buffer(avctx, avpkt, pkt_size, 0)) < 0) return ret; memcpy(avpkt->data, s->header, 3); @@ -163,7 +164,6 @@ static int pcm_dvd_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, } avpkt->pts = frame->pts; - avpkt->size = pkt_size; avpkt->duration = ff_samples_to_time_base(avctx, frame->nb_samples); *got_packet_ptr = 1; @@ -175,10 +175,10 @@ const AVCodec ff_pcm_dvd_encoder = { .long_name = NULL_IF_CONFIG_SMALL("PCM signed 16|20|24-bit big-endian for DVD media"), .type = AVMEDIA_TYPE_AUDIO, .id = AV_CODEC_ID_PCM_DVD, + .capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_SMALL_LAST_FRAME, .priv_data_size = sizeof(PCMDVDContext), .init = pcm_dvd_encode_init, .encode2 = pcm_dvd_encode_frame, - .capabilities = AV_CODEC_CAP_SMALL_LAST_FRAME, .supported_samplerates = (const int[]) { 48000, 96000, 0}, .channel_layouts = (const uint64_t[]) { AV_CH_LAYOUT_MONO, AV_CH_LAYOUT_STEREO, From patchwork Thu Apr 29 23:57:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 27496 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a11:4023:0:0:0:0 with SMTP id ky35csp2017373pxb; Thu, 29 Apr 2021 17:01:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwLHuEwb5XtVbvwcHTeGrjWUQEGJ1wkHpyKYnfoo0ydM+Uh9/Ocx/6ugrBHfhk89pJSTiwB X-Received: by 2002:a17:906:bb0e:: with SMTP id jz14mr1054149ejb.285.1619740913878; Thu, 29 Apr 2021 17:01:53 -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 o7si1358828ejj.449.2021.04.29.17.01.46; Thu, 29 Apr 2021 17:01:53 -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=pMB4Vq1c; 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 75F3868A1BC; Fri, 30 Apr 2021 02:59:41 +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-vi1eur06olkn2033.outbound.protection.outlook.com [40.92.17.33]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id B750768A3BD for ; Fri, 30 Apr 2021 02:59:35 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bzZqPUr2TQElhsFHZM3LPLOJIouEFqxSF+FNf+WdEhyaN2FD1lkR6DZ1crHochaZY2ubTQgB3ndmxo8Rkb+mFlxd4Dwb5wMiQUk+Rsx0b49MufGqGQG7Gr5LgV4gJ+Qv8dkoNxfOaSu+Q5xfMBKQtiKtSvdIn0d0xm6znxERBayv63jdYci0IDvv1uVD5AOy7TABwe8DBEuuNiI4RKOhWz7tDo82R6kCxpTWS9wjluBfU3DxM7t7ByKGcOErKTCGQ0htIWxrfVE2TzP/Asca/dsQdVyEVPeQ0tjF3wiNPTavKIyHW/IL/mNc7irE8efV+v3ULB6ZIEkuarLqb24crw== 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=SlZ5qLsm1qWGEh/fv/d/n9LgNV7/Oj0/FTXOZdre8Hw=; b=Nl3opx/OFt8/7Nocti/kVGuqNmfBh1bv9UQWmZw7ucn/xQ4veahpAtV+uTWZzkLy/XLDTVR2F/m4npUS+kp3X6xFsDYX0hRZdAOcmKFPt1y+sip6R2zJ9bncCsxxAE2fS5OWx1x9CMk2IAhUnhQnG9YhqrJvhs6AZzz9S8wuUqK2v/RuE7A2IMDLx6x4x4c/Ps+sFPzynQZFhDncAPf13y5RDXRYCzdgSi6VbUeCu9TcQxQkwANMcO9NYNa2dbZU+jNKgaZbrEp1l2DNZt0f8lvEreD/Vd7mH+WefAuEPDhmRgdKX/+7zX0kwxGHcId7BeOJPOmP3GOHssEYMkgcSw== 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=SlZ5qLsm1qWGEh/fv/d/n9LgNV7/Oj0/FTXOZdre8Hw=; b=pMB4Vq1cMFdnLa3kIhuoZ4gFtimWw/wKLAM7/MyEItYTWF9Vo1wMgk6PEt+vYHeCCeZ7Du/GuhAQAErBEnkLcJ2V0Vo18en2XUzyCSo0imLyb0WD9DFPtCE7Sy9+/Jm9tXYtig9sQqhsYqnrWd88rfmcWOuXgiVHmqexjvrUwgfpUKXsKRdDkaEsI2FoD34sqSuYA2a2jOzh5N7fJXzadS4l6kOs3GodWPkS6rzwYgrsWY2meCFIv2J8KZo65hguPpJbNUIDz5JKivxKu5YRLcuSx9dy5PYVcRxe/0w9iGvAUW5xSsuCQIZF/xZVJl8gqfqRZimgqzdH91dLvjzyBw== Received: from AM7EUR06FT055.eop-eur06.prod.protection.outlook.com (2a01:111:e400:fc36::4f) by AM7EUR06HT003.eop-eur06.prod.protection.outlook.com (2a01:111:e400:fc36::401) 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:35 +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:35 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:16486550394100C8B9B67CD006E05D4DE3816DF28BD973F8FF147EA8A1977473; UpperCasedChecksum:1D6D246F622D27C1BC1A6AB636D8448FCBB5F77E20B3D671C9E88B306432D858; SizeAsReceived:7582; 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:35 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Fri, 30 Apr 2021 01:57:00 +0200 Message-ID: X-Mailer: git-send-email 2.27.0 In-Reply-To: References: X-TMN: [Mc12YAr5LFhsq9NjdXSCJ/HjuTDmQ+td] 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-28-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:34 +0000 X-MS-PublicTrafficType: Email X-IncomingHeaderCount: 48 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-Correlation-Id: 429e298d-8f8d-4bc9-afcb-08d90b6ad6ca X-MS-Exchange-SLBlob-MailProps: gjx25WM8ZNU6XUx7q8EQ5McclV510mdNEaeC2RGhNi1JWnrjufdjSZaNVbq/AWby9Jwreh7G3Ef6JhprCscOlw+B0pcEhgOQ0YiME1/kRIhijT8bBwD5xnues2Z2lDoLiwY/a9NtN7ODTAi5b1KRpI0CR7Fw5S0iTrTjdCcZEBIxj5dIlc8DiP3zJ7bB3uHtB+vLv+0Z8hODmxSOwmVmuWxgwHXhv90YI0Mm8RWqL+SVbeuJSLE3wnuE1enTHHOZ1oWaKlrz/oaxgZ5TgYjfLE2fqhNmYnWFI4Z0zL+miGBloBZ6L4FgFJ6O3j8AorVPV3gXxGKFC4rGgAl7OgemjPSJsuwuf2IrGtXsTPik9/uzfgRO8PAZbG/WQpgn4+zwN+5WEnLaWMz4q066Sf4z5mFHYkb1E0vvV9gFRq/Ho7Cwn/lb/+whb/y++HIFVQHa7pKY/1HhLdJHBg9WhV7+h7W9rNWA3twZha4M9OsWWPxgXztdqPDk6Fw1farUSjP73pCjsbnGwJFnfjVwewhJE3sgxKRKwtmsbvXrFr/MSoIcO9Dx5Z4kl9Grm5tUPM9Q70wHNHYDZrabkInHSwcJ/WVpoTSTVyBQkhqXbeVgRqfmUT9VbSOVeIgryWXHVckuinLGqDWO6CxNAl2ajK8iDtmGAUZ3K2RLePF634/ao9UkkJCI3DiqP1HTVjy1FQDc3PD9pN/Q6xpyX7BDwy7BoF1SbVpKHnSpzwdHIAeC65Q= X-MS-TrafficTypeDiagnostic: AM7EUR06HT003: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: kjLAibzx/tkSsTYL4uIF5mA5S79pz+8U1IiKJpYqD+y9qHCT4Fb2QQX7xOCmWu9BR7ICNGaUXoccy/WebdYwrSxbJt/WFLEfgNbuOWIH1mhhp1P1ciq3MQ7jFEKt+hycqUZsuj/WdCusQGkVXjcwrI5SQpDAhj6HwhMo314pc4PXs0JfMbLWidxcXR16yj+yqwSwYsG3LU8E8pmfbJUhLnUpl1qKlHAnR0O8avG+7t/lA/qu/IR4O4MBaa6T6cowI/xRxKdzqSTc/loeSl1hyxCyVzyMNcEZ1cSUX4N1ckRNQAtQTC1pbAKOB+dEKmWKrzV5GTqmI1iEi7Wf4Mw9dZV/Z0esZ8A7vIzMWrU6ROlTZtIyKHE10mApX+41F5h9Ioae0vpd+esD4fIPw+WoNw== X-MS-Exchange-AntiSpam-MessageData: YsZ88QfeSLWyMQ1tzAtg7OcK6sMf17vpjs/ZzF2jEjUknpqytDIRk5qrSUCt0puSobWG80Uze8572btr7aN695A4C2EChDLqii9hdT2GUiu0VWz24leyD2emq0ynIwkflK9HVbNnkQlMBJVeEZhKXA== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 429e298d-8f8d-4bc9-afcb-08d90b6ad6ca X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Apr 2021 23:59:34.9621 (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: AM7EUR06HT003 Subject: [FFmpeg-devel] [PATCH 29/46] avcodec/pcm: 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: lMIgX2SzoVnc Trivial for encoders that know the size of the output packet in advance. Signed-off-by: Andreas Rheinhardt --- libavcodec/pcm.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/libavcodec/pcm.c b/libavcodec/pcm.c index 79b33b935c..e9b8eab484 100644 --- a/libavcodec/pcm.c +++ b/libavcodec/pcm.c @@ -30,6 +30,7 @@ #include "libavutil/thread.h" #include "avcodec.h" #include "bytestream.h" +#include "encode.h" #include "internal.h" #include "mathops.h" #include "pcm_tablegen.h" @@ -106,7 +107,7 @@ static int pcm_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, n = frame->nb_samples * avctx->channels; samples = (const short *)frame->data[0]; - if ((ret = ff_alloc_packet2(avctx, avpkt, n * sample_size, n * sample_size)) < 0) + if ((ret = ff_get_encode_buffer(avctx, avpkt, n * sample_size, 0)) < 0) return ret; dst = avpkt->data; @@ -555,9 +556,9 @@ const AVCodec ff_ ## name_ ## _encoder = { \ .long_name = NULL_IF_CONFIG_SMALL(long_name_), \ .type = AVMEDIA_TYPE_AUDIO, \ .id = AV_CODEC_ID_ ## id_, \ + .capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_VARIABLE_FRAME_SIZE, \ .init = pcm_encode_init, \ .encode2 = pcm_encode_frame, \ - .capabilities = AV_CODEC_CAP_VARIABLE_FRAME_SIZE, \ .sample_fmts = (const enum AVSampleFormat[]){ sample_fmt_, \ AV_SAMPLE_FMT_NONE }, \ .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE, \ 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 }, From patchwork Thu Apr 29 23:57:02 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 27507 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a11:4023:0:0:0:0 with SMTP id ky35csp2017801pxb; Thu, 29 Apr 2021 17:02:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzKAXa2dmOETZyX9jfszEUcWFpGQDj/LsZK7QGQdEYqRDkzYRzWcZKvvcVKc0kCDDTp4DJ8 X-Received: by 2002:a17:906:3e89:: with SMTP id a9mr1028772ejj.405.1619740942882; Thu, 29 Apr 2021 17:02:22 -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 w24si1723714ejb.752.2021.04.29.17.02.22; Thu, 29 Apr 2021 17:02:22 -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=FAP74yc0; 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 081A568A0EA; Fri, 30 Apr 2021 02:59:45 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR06-DB8-obe.outbound.protection.outlook.com (mail-db8eur06olkn2102.outbound.protection.outlook.com [40.92.51.102]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 8A1C968A3BD for ; Fri, 30 Apr 2021 02:59:38 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=g2NAeBo5UwxDE8t7DVBSxWD6hkyvFTtIwRGWINCCcUy+Julq/ZkOAJrFkh5yxrUm6sWSXy3ec7EHf/2oYDQV4LOMv9Ef5Ylv+DwjzoAl9qM2yBe3MQ4ZIKmkiADfzaphvVio69Ve0AyZcXR3eLJciTlC+wsdxzzcQRwVSBLFOLqNTLhb4GVMKn+qtyHVhko9/3yovW23FUl5D7zAzIo/5vQnPjoqjopHqTsVj6dXiRG4qZAYmpocto96RlxLBZM2vsX7HHJIC3JsSBkYXJ10OMfGUZ+JR5p3i34QGsFk26kQZ8j9ZKOEF73gNpSrDqpap89KevbF0tzXuasR2Kduuw== 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=XmiPmHQUySqUcfeNsxnpBgxdfOKMVpnSuCP+MJGzz5c=; b=dhfGH9J3sPeUpcmDKZJeTcFMVLO6Ny6eLSMhA4Q3RS/jh5ZDhwxpfVJDhkhZSik5J+V0K/QVQZrZgh31VjqjCGlKzSXf8kc1kTsVoVtxn9hvm8j4nDGmIXm8YLyXAN81O2PbrqC6hkhnYPtkGXMlmhJ0GoK9uTYSSw0hbbynBSFSkHbpDcxo7SQnJWnw5tnY85aexkkVqBbb74xIsqotBmXVy4CpqVQEYMtVzZksaxyyBIQ7Plxdbnk9BG6G8uPeX1YMUsLwMqrCdBhmGhZRzLqir0twCJNug3gvsqV5odCo9vCKnVDK1N8Je4Xs69Qaisd63Yb4/fhSfdPF6DvssA== 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=XmiPmHQUySqUcfeNsxnpBgxdfOKMVpnSuCP+MJGzz5c=; b=FAP74yc0nuDaU7Xi9bR0Q+z6yzicAKue0ARStfol5jBLFsPSjPyhBzQ4nwGNlqS5ObYdMHCJDJcb61NE/sGgBNE2/19KFK5csxVTyu7xnD2Ch9Kkcs7uWNZUY/BW5jxEVguoPuX7kAuqOvy9M+3hUmboWhv+QwvAdK+vcD8e9OOm7sYhaAz1wQ5sk6PtlhfnzXOGrf4XBwRIKwxi3fANtlQaSf/51yCrzJ/u5deRfi8Mdgf8qBT/Wwd9iYW1AZFYHoopjk3vBCszVp1dMH30PnAu17mB8XoWRdT9Q4KUz52/GbodEba3fGjoA5amDg2coL5Xhz8Qo59lYCcf3w70+A== Received: from AM7EUR06FT055.eop-eur06.prod.protection.outlook.com (2a01:111:e400:fc36::4c) by AM7EUR06HT148.eop-eur06.prod.protection.outlook.com (2a01:111:e400:fc36::294) 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:37 +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:37 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:1758FF6E0BA6A5C339E9AD89694BB05367910AC411A74F88F389A47EDD964739; UpperCasedChecksum:522F110E7AABE44330F03CA39461FF1F365747C09ED5D52AD389957CF01B713B; SizeAsReceived:7576; 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:37 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Fri, 30 Apr 2021 01:57:02 +0200 Message-ID: X-Mailer: git-send-email 2.27.0 In-Reply-To: References: X-TMN: [oc3tHt1Off59cbSvL6XjUIsAfSU8alTl] 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-30-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:36 +0000 X-MS-PublicTrafficType: Email X-IncomingHeaderCount: 48 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-Correlation-Id: b3818d3e-7f19-4555-8e1a-08d90b6ad80f X-MS-Exchange-SLBlob-MailProps: dEG5jEBie8lZ/qLiIvG7M26yVq6lLwmYUabBBUV7sVkDkF1gNINDE7WsgrORU4+k00kYFH4sC9IZJ3QKzBkVcqvmHz++/DkAxV8IoV9OXMen+zUsexqlNuEp2ThtV5A+B9VPQKBSJiqJjGMEd7P3LMBEsVy1Fz3zagG4DLce6bry1+cwuWipohTvOmqhWCmH50yzUDhjKKp4JOU3uAKIeo1SAMw5CYNY0JZcmkvKSgltpMkQjZsYJVxBlMM/yEOcVV5AR2qNmzYw2eCRY4vdr6bhkgdUx60JmeORwTklEwSYfqSci04hcW/wpEic1G9Ic6tkbmrYCYTcsIBaWZji9lk5Pfl8jgz+TE4UbUJP9mpJ5VYnXcbC76TWxZOkXzm/fbfSu4b0+j5JOzoaixTVgbMDVN5uiqc8ViYc1ozNvg222SDRWh7EpfbpQ0Vol2Jh+kYEJFJPqC69snw81uSitReCUzyDkv2hWYn/4wD1Dl2sY96udMavyzsaMoNrQ+f2nlZ+SW2r+FUSOoW9/ANnTHqGrfqOrtQ3agnwnngYZ3iVMXCqix/+bR4tCR6scpGVi8Khzj6Xz76n5EoVs/VdTyj7ShXbFcvEzUK+XkRNdtW36c3IH6x5eUTScPVTz/yfv19+7WNsGBBbwratss+9teFDkGjZgY+DtDSTY62c1c4kPAFLAnF7rQ== X-MS-TrafficTypeDiagnostic: AM7EUR06HT148: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: eFPOahV4XqA1lt/O+q5Fz4ex401Q/b50HLN+uDD1vpAXo8RX6BncsuELFPK7BKc9rC/cjp4RDKr1cOJTD3CGLB3dpzZejoBwCHpBd3yP9v/rkzCmDwJL/PkftBDINRtLc/4AoSR1rcsY7k+KO/gW9mG2+QB9674qI0HEk6t9braYQCXiQk/dCYJANAO4Mn5fXd6ZmdsjeqcRQys+mUN6LEQLWB8iCwW9YFAULZ1UtrslSYO+VGOtMm/4SF7FQoJnGlGl5eN/VtXqa/SxrCDV+wKw6O4YKHOEifJcY0VF6bj8MRhiBwMz4nrrTK2Np1RlDzIfqePDyKLprWTNnTmqZdtjL+bVbazK9TPxZx5euGKgXkQFOjQUo+m41+5P2gd7cyNokjKR8far4GFq7KPeMw== X-MS-Exchange-AntiSpam-MessageData: uPV4EuBGK+oYFLlRlXigl5O6MIQK3b8NIfI+snLcOcTn+gJs/PoQsGWuCmHvtfxEIF7MbVgkUgTq0++7V65TPOge/Nsd3TyvehmTq/ESBVmPAmjh3/UPOx9yju2YeIjJFlmmGiZTyl1ggiwwmkDd5g== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: b3818d3e-7f19-4555-8e1a-08d90b6ad80f X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Apr 2021 23:59:37.1081 (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: AM7EUR06HT148 Subject: [FFmpeg-devel] [PATCH 31/46] avcodec/r210enc: Deduplicate pix_fmts arrays 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: bPXacGTzMGYh Signed-off-by: Andreas Rheinhardt --- libavcodec/r210enc.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/libavcodec/r210enc.c b/libavcodec/r210enc.c index b143f516c1..2f641223d4 100644 --- a/libavcodec/r210enc.c +++ b/libavcodec/r210enc.c @@ -86,6 +86,7 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt, return 0; } +static const enum AVPixelFormat pix_fmt[] = { AV_PIX_FMT_GBRP10, AV_PIX_FMT_NONE }; #if CONFIG_R210_ENCODER const AVCodec ff_r210_encoder = { @@ -96,7 +97,7 @@ const AVCodec ff_r210_encoder = { .capabilities = AV_CODEC_CAP_DR1, .init = encode_init, .encode2 = encode_frame, - .pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_GBRP10, AV_PIX_FMT_NONE }, + .pix_fmts = pix_fmt, }; #endif #if CONFIG_R10K_ENCODER @@ -108,7 +109,7 @@ const AVCodec ff_r10k_encoder = { .capabilities = AV_CODEC_CAP_DR1, .init = encode_init, .encode2 = encode_frame, - .pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_GBRP10, AV_PIX_FMT_NONE }, + .pix_fmts = pix_fmt, }; #endif #if CONFIG_AVRP_ENCODER @@ -120,6 +121,6 @@ const AVCodec ff_avrp_encoder = { .capabilities = AV_CODEC_CAP_DR1, .init = encode_init, .encode2 = encode_frame, - .pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_GBRP10, AV_PIX_FMT_NONE }, + .pix_fmts = pix_fmt, }; #endif From patchwork Thu Apr 29 23:57:03 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 27522 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a11:4023:0:0:0:0 with SMTP id ky35csp2018067pxb; Thu, 29 Apr 2021 17:02:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx+Am9rTSfYtJMkIQqZsefL1coEYmmKcX5pJz9BgsRU0OvLdJ84cKwniMFT6X/6lqpmnC+R X-Received: by 2002:a05:6402:120c:: with SMTP id c12mr2588334edw.98.1619740961502; Thu, 29 Apr 2021 17:02:41 -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 a20si1937257ejg.286.2021.04.29.17.02.41; Thu, 29 Apr 2021 17:02:41 -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=BJpZVyoE; 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 B2F3D689F10; Fri, 30 Apr 2021 02:59:54 +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-vi1eur06olkn2104.outbound.protection.outlook.com [40.92.17.104]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 1B02A689923 for ; Fri, 30 Apr 2021 02:59:52 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=J6k7W6hzG9hiFWlwR722I+w8PnVU1KqCe3mFtk4lzW36q/RR3WHvMGbEpKvCXG4NPl3mVl5Rh14LMlOdJtEcXTx+VSyZHQymoP3LoWhmAL8bf7nBlhW332seevJq/EZzt/UbvGrTbi2OF+8jedXx0zTvkfg7K4KZS5daKxzUAOPSRdIcX4gA7jAHGaUGEKVWCcatb3KBGXSMyu34NlwlUFat8GXUNDb4+eL2f3eHwFZ2yWUpkZMmTN6bFJ1oMF/RKg6Xrpx+9oP1AqDYJv4wN1dtYqBjJ6eBPqmqcxaHhbOs3+e7LZWyFMW6FsH4zkUO2+HfN/6HDrjPHWfiYBjcBw== 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=g4D0AV6i/0BnGA+dF5njwGXkDLpsYR96VvjNr+wz2Ok=; b=UgRIc/XlzwjrK95+xcVbkFcxL9TB2JnZGJMlgAV+p0Q8R0CIBMXMeOuVguF7MitQo8hf+JbKkWFN+cwdsqcRS9BCQgPBwUH1Cupry4WzMuaGAP/SQ/p9hkaaGnQEc+mdVgFj9eh3L9e2saEHpQTs2kMVs13z3ROMi2m9PIqVmXAGEQ0lZNLvae/DtcQNE+yiH5xnurYW35Pl21klIwQnzHWlxluM48M1sb9hvX3XZOhKJ9vvvRmQqbmowpvNvD/gW7pHCiHwoe3Hfx2kfLnyJG6p9rurfih9VtlrtQiBQjYKtBrMHS3AHblPzpQ8RmA/ha0aGvrNXrC5OorbGQ3ZIQ== 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=g4D0AV6i/0BnGA+dF5njwGXkDLpsYR96VvjNr+wz2Ok=; b=BJpZVyoEIwIxFGd/V72OTubbalZjU4wje4AUHKWBPuuXQWnv6aZfz1nA+jEZTDDK4TsKJnvsL8EsDM3o1CJEeJQoAQaee5M03SQUs8Ha2E+HCQJPxPCyWjdcFkrWTUWgb9YjHSCFEz9/JeTzoFFHyMZwj51mGmscbxO7pjNopHrejhEJI4dg3sH/5dkeWVIYv3Fimcr4PaxxdDNC1b4MXPvDuNNX+uYYMNs0dXfgXkXi73l9jGkO7824QL7CctD7NC2RQLzxUND9AHnntMlGIinveZtvn89P4Ra9mEIv94mcz+sMCmhGR4MOkLB8ACqs1SOxxeaM0nUmwn6tplWJTA== Received: from AM7EUR06FT055.eop-eur06.prod.protection.outlook.com (2a01:111:e400:fc36::50) by AM7EUR06HT029.eop-eur06.prod.protection.outlook.com (2a01:111:e400:fc36::477) 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:52 +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:52 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:3B3AC445985AD496B56F7158F01E87FD497432909E049001CAF630629E66EC25; UpperCasedChecksum:61F9927E4B253FCBB8642B8456F664C3F3C5A02BA07770F325C85C409470957B; 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; Thu, 29 Apr 2021 23:59:52 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Fri, 30 Apr 2021 01:57:03 +0200 Message-ID: X-Mailer: git-send-email 2.27.0 In-Reply-To: References: X-TMN: [9l8XMSTQegPm3oBANpRGtPlp3mWoxe3k] 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-31-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:51 +0000 X-MS-PublicTrafficType: Email X-IncomingHeaderCount: 50 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-Correlation-Id: 81966fb0-bb2f-46f6-d21e-08d90b6ae0ed X-MS-Exchange-SLBlob-MailProps: gjx25WM8ZNU6XUx7q8EQ5McclV510mdNSQ6zVwN/I7EX+rk7h1h8rgqhciQx18U9NLAZa+qA6gywEMO0gZY3oPJJPv7F+yYeSh4tKSZq7WBOqgpTv8bIW5jmAx63XVnKbxK25Uhw2X/WxgjY5ab/pRBv3ZGpqnL0aG6H1uH5lj0iaDzpPRi78JUWEHX7rxbinyBa9bRJYFR5f0sTtQFQBwjeWV9Dn772RczlLh3ihK5AuvvThZ0OjWGJqqysuM3Zt1E4UyzvpakW+kgS5Q27V8k2CDgC5KmCB8IBuXVQS1sITcVdYOYuRV+e+utjbovyeOndNk5IPrgVJNWl8uqlkjbeAlWa4DZJWccb7yUf9GFulJywpUdMtF7q+YTqDrmG0Uk/I9jY2B+YKuGTnzOq97X1XYuZZzW7oOCpcsJaql6b7UUiId8lKKjlkEc+7nUIhOUgoVZVfHyaKKYLtpzGlodCb1YN8+xvXqJqLOz7IqMSDcuy64cGEcoyozWY+CGnU2fYbZkHE8n9wCFA6gR7mksHGQoFmSCsJNiL6LJm9UGkUnbk5QemZEZ7++MpuhSEOeRxokgxXEUuZBOntz0gl9iN2s6Lh3jehMtSpVvbal2rkf0uHuvGsK1yJCvbA7pDQCIXIHdTGtleL5xYcOBFrgEcJNNheAkEMAGG+5ira+7L2nCKvJBRCCqvBp+RT1o+Q/z1yoO1kUAUxhSmynHo0jsHGi1watCbqnNxtuIoqHQ= X-MS-TrafficTypeDiagnostic: AM7EUR06HT029: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 3uAeCFEXz76eWogBijHzR+fJ6xaRprgRU/ASxIJBxUC4qwdEHl0FxykUAvgcVoy3RiT8ycOflQOVN66VLuuVSDFv5VSGnhA3nxvJPFuirt1OAvPGZsvlpP13nSXqXdP7zAbo3KArqo9CJHBNgCyph6BUg6ZbkZBVf3L6WsDLQl8ljKIwrrgMI7rW2T2NW0cOnHARNBFzgvzlib4KW9Kt8Et9lRqun7DPx4QQXdAIlo98Hpe1pxALNH6zZrEdWLlBC5NrVs7XS8Cb6P20qBRht/UfPWrOg5Lslcv3jxrsc9nALilLSEmZYv2agHZt70ZX52ax94Ah6VtMRnXDsHM0T+piqvS22wn/IvLM9JFWS0y5lfao8wC0RevAIzCOH6ghuhcSyi65BEGLVf9joL397w== X-MS-Exchange-AntiSpam-MessageData: zJX0cM90NpnmCrlJh3kPmpQ9ag22cpTc/D1viSskUbnDP1LTlPBP8rVTp2+rIpI3QH0gRprWO7sYhgUwFrkgNTAIczNT/Gstm8VcKvIHpHzwlA7jxkkHwGwhg65IGfCn9NIb7F24ESFYy5qyGyU9jw== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 81966fb0-bb2f-46f6-d21e-08d90b6ae0ed X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Apr 2021 23:59:51.9446 (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: AM7EUR06HT029 Subject: [FFmpeg-devel] [PATCH 32/46] avcodec/ra144enc: 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: YreghEC4fQsJ 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/ra144enc.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/libavcodec/ra144enc.c b/libavcodec/ra144enc.c index 0eb151a49e..fdb2cfae8e 100644 --- a/libavcodec/ra144enc.c +++ b/libavcodec/ra144enc.c @@ -30,6 +30,7 @@ #include "avcodec.h" #include "audio_frame_queue.h" #include "celp_filters.h" +#include "encode.h" #include "internal.h" #include "mathops.h" #include "put_bits.h" @@ -444,7 +445,7 @@ static int ra144_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, if (ractx->last_frame) return 0; - if ((ret = ff_alloc_packet2(avctx, avpkt, FRAME_SIZE, 0)) < 0) + if ((ret = ff_get_encode_buffer(avctx, avpkt, FRAME_SIZE, 0)) < 0) return ret; /** @@ -533,7 +534,6 @@ static int ra144_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, ff_af_queue_remove(&ractx->afq, avctx->frame_size, &avpkt->pts, &avpkt->duration); - avpkt->size = FRAME_SIZE; *got_packet_ptr = 1; return 0; } @@ -544,11 +544,12 @@ const AVCodec ff_ra_144_encoder = { .long_name = NULL_IF_CONFIG_SMALL("RealAudio 1.0 (14.4K)"), .type = AVMEDIA_TYPE_AUDIO, .id = AV_CODEC_ID_RA_144, + .capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY | + AV_CODEC_CAP_SMALL_LAST_FRAME, .priv_data_size = sizeof(RA144Context), .init = ra144_encode_init, .encode2 = ra144_encode_frame, .close = ra144_encode_close, - .capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_SMALL_LAST_FRAME, .sample_fmts = (const enum AVSampleFormat[]){ AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_NONE }, .supported_samplerates = (const int[]){ 8000, 0 }, From patchwork Thu Apr 29 23:57:04 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 27521 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a11:4023:0:0:0:0 with SMTP id ky35csp2018293pxb; Thu, 29 Apr 2021 17:02:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy9CQifJbztbO9x5wqcoUu3YGfyw56/54KPlJSQ0HaeD1RQli9IsZjzIeTpNizc1vVO0xqe X-Received: by 2002:a05:6402:11cb:: with SMTP id j11mr2650657edw.282.1619740974866; Thu, 29 Apr 2021 17:02:54 -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 a15si72766edr.347.2021.04.29.17.02.50; Thu, 29 Apr 2021 17:02:54 -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=USVYeaL1; 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 BFF5868A459; Fri, 30 Apr 2021 02:59:55 +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-am7eur06olkn2053.outbound.protection.outlook.com [40.92.16.53]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id D20C568A44C for ; Fri, 30 Apr 2021 02:59:54 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VHyN/qGGvjryd70/r52aALXRqOwgSTbw1t9SBcRFl9cT/veyptgnfgyjg6tVgcnd51pX4CWmXeIa5mYaJVFzTSniLBcTDXXwACslT+y/oBDFHwGFSXzZQyQ60x6l1/X2p72LDDDOqqcYBwtGmSVTdozcfn3Cxbm1e4JDpszny1nC8uZF/ekGXJh8CW6ZYc4rnqXR/1/VJGcgbVyMab3iKt0T7b9Iw7a11LsXZVa7k/50huf4expSjWWvP7mUkhsjuCcnJD5PseX1QOTPXrVClXF5v/Pt5YsitJI785xAA4MMJLCCPDQOPtjeOTRlgLV/j65rCKdwSTOai2q8i3sDew== 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=DYnsmgJVDZ/ggHmK9k0J/HG0/KrarEj3gmPXSi37FFM=; b=YCki+tgVDM1flM2X04HCzV13PdxsJt6mV52qKX1RBZQrwIN4LxNZG1mcJE4mtJFZyy/YLOuQZmpdv70CLqY+HLi0iebE1OP2DLwyNLYHRHGifeIKzA5S/8Kiw2VtkImeExE8+bNmsl0K1iMVtXrXb1hJn+Yrdi7c2HCNqMrgqbcXD/34WgDI9QbxbYWM/QOIg71myfQtHhoAY3sUK6bc7lb2Hr8sSTU6dxu6QB9GwJbBzknpqN8ekjZdH2TSCuSo4OCA+ooDZOrP8NiH8s9t0Ll0GH6msQZLnOo2cPN8X6UhCIE8L+YReyp44QVtI9kXHqVqw8eEIOXdf3uIzdUoKA== 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=DYnsmgJVDZ/ggHmK9k0J/HG0/KrarEj3gmPXSi37FFM=; b=USVYeaL1VXxl0k5l0vnxATKSEZA5Q9CsYC5Ku/SamWGiZ0EaKwHhDoHPHj4y8Gjb28AKcpGWTL2fLjN9hgsn/u5H+6ozZ+0QoxUKoORYA3iMS7xk50puGeAy2PkYICFcDN0Uu0dXLjkQutnYhLt0Zs15sbIRWmMDEX2v/CSpbCzh58IT+w25A1ileKouX2ydLWc0d0liCLgJ+em/bazE/UvqyGsdYzXi6/Qowu0NVw7DfmM3Fnmi1JTtYXKQKYbImxbpZa+fpUCgFT3/u4MFcbp4MceRzaghln8KZQLkEzDKGE7tMwfdGmB0UREy62egbi+PAppYafDG2+VovcTcWA== Received: from AM7EUR06FT055.eop-eur06.prod.protection.outlook.com (2a01:111:e400:fc36::4f) by AM7EUR06HT208.eop-eur06.prod.protection.outlook.com (2a01:111:e400:fc36::271) 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:53 +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:53 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:C08F879282A966246CE5BE065F06FF265029A2A4188234D832E76BB449A5D0C1; UpperCasedChecksum:AFF51F556026225E39EEB482E5A32BF5C4AED7E23175BD96F2BD8934263C9552; SizeAsReceived:7740; 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; Thu, 29 Apr 2021 23:59:53 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Fri, 30 Apr 2021 01:57:04 +0200 Message-ID: X-Mailer: git-send-email 2.27.0 In-Reply-To: References: X-TMN: [5SZZj7trZlNqZq5bnwD+rrVsDse13P91] 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-32-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:52 +0000 X-MS-PublicTrafficType: Email X-IncomingHeaderCount: 50 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-Correlation-Id: 278aab01-03d6-410a-c411-08d90b6ae1f4 X-MS-Exchange-SLBlob-MailProps: q+fD6XS3/UIO6YRda03MtHguxZve2k0Pehq22FssKt6blf4rKSZa7zGk8wCyzcxX6oQftRJpFl24JuFQh0wEdXG1gkXzdDq0jCBm4lrpv0Uf2ZnG4uLXXv5PbGrSwaVdBLVPWAg0LLEd+x1ZZUVm69ByHiB9uqK5vy7erzNWwR7On9TxBcEWIhnkhjRU3vhasq7NrbyQM3DoYpYuqaKWRniRR/PMPRdhrO9Q5vJXqfTjnFbp/XDJ/uou/E3X2OkrW7zVc4iwvbd0TSTwDe3fkSCIo/v4H1jTupSRamaDjoKtckiIV6tYmG/8vs3KySKtHhrRZPxDiznq/qor1ujUnld6fTVDXTyBLVkWb0bI83Uft3LkvSbK+QyIg5r9vay4HhR0Lu3or6InO7KsYtAfeGDU9BWZgJcW8ESKiHsdmJocWE8fpPrnIqDkw88ZM8TFCkye4gE3y2YXZjt9nMRPYXXFoZ5C3OM+r5UJ8Fr9aopIFOsesRF9VUU/iobzwZFyxjCdVSzuH6JAiwk0DK8ibZ7BmaHRRPSuSUqEdKuqHH00aTSE5vBQj1WGYpZXIq5gedsYmF2oTUunGmhpfOT89QD9vsyBLYLBdIKvgoVYcDzoqW8/mGO91RjQwb0z+NKivMoRx2ostxMDCNo6bJh9rDPk73fvjTHLX4c03/H+G6DZlRFBcBT7Y4aNqjJIqNUG1cIenxkfig5ZnoAwyzngaQ== X-MS-TrafficTypeDiagnostic: AM7EUR06HT208: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: rZeZQMHE5jL6++T5Epg6HF7ZqGiJopEGijTOUt4MZ/1B4GBSlBvf7xZzqa5KnxtWui6ktA5usAXh4lisW/RDoTP/OwYRuSLiPCLQ1GoHp5TTx2knC586z09Eop50vjG2R2/mOGg3sl+GaWkEGeRr0fS+vbjKZrZjeu1+8bTSlulVMtHn/4E8F1fFrlUSvBW+x3j8Tr+6OjxhiI9nxSTrUFmTFWrgHEa/U3DxEjfoLmcK1zChwUFhZKGazTueqFeXOMLw61WoUcgxqSjquWGwuyhYCxeYCzWu1Y9LRvAEaN0CgGwwm4xm9gtYjGZFCFTRIpl9hHtiZ9rbEUOU1S2URI4gZY5h72hsyEpqqLe/1AdmxlthUWAKa/IN1YU4I5HnEgwWj0+4APtC2rc4q7g4qw== X-MS-Exchange-AntiSpam-MessageData: T90zr7f3EzsFoVP0gVvgWwqJJ1ry0iGRswXSGAEVuPCqmjkZOLKuqkPd/zGaV4g32TCWEqC3vLjtgSVNxkksLoLxJoSv8wroO0P6mnW6MwO1p4RhVyVlO1UCHh98mgWSIQsTl30bJsuuC/vwKeoC6Q== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 278aab01-03d6-410a-c411-08d90b6ae1f4 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Apr 2021 23:59:53.7148 (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: AM7EUR06HT208 Subject: [FFmpeg-devel] [PATCH 33/46] avcodec/rawenc: 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: zY8k+VAMbMPd Trivial for an encoder that knows the size of the output packet in advance. Signed-off-by: Andreas Rheinhardt --- libavcodec/rawenc.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libavcodec/rawenc.c b/libavcodec/rawenc.c index baaab749fd..eec304448e 100644 --- a/libavcodec/rawenc.c +++ b/libavcodec/rawenc.c @@ -25,6 +25,7 @@ */ #include "avcodec.h" +#include "encode.h" #include "raw.h" #include "internal.h" #include "libavutil/pixdesc.h" @@ -53,7 +54,7 @@ static int raw_encode(AVCodecContext *avctx, AVPacket *pkt, if (ret < 0) return ret; - if ((ret = ff_alloc_packet2(avctx, pkt, ret, ret)) < 0) + if ((ret = ff_get_encode_buffer(avctx, pkt, ret, 0)) < 0) return ret; if ((ret = av_image_copy_to_buffer(pkt->data, pkt->size, (const uint8_t **)frame->data, frame->linesize, @@ -85,6 +86,7 @@ const AVCodec ff_rawvideo_encoder = { .long_name = NULL_IF_CONFIG_SMALL("raw video"), .type = AVMEDIA_TYPE_VIDEO, .id = AV_CODEC_ID_RAWVIDEO, + .capabilities = AV_CODEC_CAP_DR1, .init = raw_encode_init, .encode2 = raw_encode, }; From patchwork Thu Apr 29 23:57: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: 27504 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a11:4023:0:0:0:0 with SMTP id ky35csp2018465pxb; Thu, 29 Apr 2021 17:03:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzOs//SeB5lv4kWTDFfSagVDDl70P9GiDrb7EpyhMhFre/G2SUg5hvG+m4BVqcJMNfsgDR8 X-Received: by 2002:a05:6402:1c0b:: with SMTP id ck11mr2566865edb.264.1619740986070; Thu, 29 Apr 2021 17:03:06 -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 d2si1426803ejm.291.2021.04.29.17.02.59; Thu, 29 Apr 2021 17:03:06 -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=cpOxdFb8; 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 D15A468A46B; Fri, 30 Apr 2021 02:59:57 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR06-DB8-obe.outbound.protection.outlook.com (mail-db8eur06olkn2030.outbound.protection.outlook.com [40.92.51.30]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id B2F4968A451 for ; Fri, 30 Apr 2021 02:59:56 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JOqdzRShv9Tqut8/BDGoEezjJzn8ipTmokWkL/j9lg0ihSyL00wun7hf4eJUdORCw63AzPzVmPVynloJ/FfKCvA3eLl/iGX5SgvWncrOEsFZeGqpPRJCx202vou5UzDqGGH/Voqek1L+esF1JhKlJjCzdKTldhzQS7Vo2iVQvLppXxlPHfpfEvKPSl7jfKdy7gi7G0V0KAgQ9NcjlBUw7JBnLXPHE+O6BOcqrJrbawdHYTDhvF9X0946CtfKgnYFQRYMkwkCXqWI+RbssZc7Urk68GOw0nACayv7jWWdVOz3aWhJPiaOb3is3Gjq/3amwS/MVd8gDSbOSf43Cqu4Lg== 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=x0movYRk2MzCvLrbSEh6WeA1KeR+19PYKe7JyweytjQ=; b=JvRjZuQS5Z03IMmItdHoUhOCcC6zmatKdsiKW+mugRXNwkYGGQ5HIOf9gFjR8/Y4+e1ZmoHZI9JYr+1LTl7DaqvSjylaihvtOMDB6hRI4xprkLBlu+kCTrSWXJwQO618FA1WmbZHS6cXsq5rrpk13dq5TV1Iryr41TinhI61+ugRf0Yj/3V6hDqCr3SCnOfBjNjET1GSxObQkQJTtoIP8rfq5/rF55FBXw1yCk7lleu79xLFzyuNI+eBGAdsJ0pmzL6/mSULuniK/sLshukFsI0MZIaeIhKx4/D5YikMtFzGYBQHpeN17ZCnZn3N+srm7ByV4ATjmEKQtDYC7meZnA== 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=x0movYRk2MzCvLrbSEh6WeA1KeR+19PYKe7JyweytjQ=; b=cpOxdFb8gw/RtK+tWjP9Vo9RLmL99OA7MgsRhMhy2BOWAyQShpbbPwxA6EGnyoKI419IgC9NO7VA/aG3iOnIRjikAihR7W/v0JgUmKRjJbuVM+7BQTwPJBMrIZxtFw19yT9NChvJAug682qzMCYnCNiKhS9TXz/84qCVvmuGuunM0sv6bEOE1Myfx9I2H5cKzH3rHi+8A4iWY7MA8+ySqBpCAcD5oLK2n+mrBjZ+Y//XuDkCxBMjXD8TcYF7tnqHUr8pKcH3XJjpKBSxq/ZVxmuD1bkNJVlPvDvuQPUcV89bYXLSW1148nq8VpxdlSWRemF4cyUJGy0uPMXYoAtwTA== Received: from AM7EUR06FT055.eop-eur06.prod.protection.outlook.com (2a01:111:e400:fc36::42) by AM7EUR06HT121.eop-eur06.prod.protection.outlook.com (2a01:111:e400:fc36::235) 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:55 +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:55 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:E61ABE307DD27F81B0E8BF05AFAAD936351C544DF6B0AF15174580F64BAB7096; UpperCasedChecksum:13E9154972F1D2F128E647283301C5747DF37267250106DF5016462E34947742; SizeAsReceived:7772; 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; Thu, 29 Apr 2021 23:59:55 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Fri, 30 Apr 2021 01:57:05 +0200 Message-ID: X-Mailer: git-send-email 2.27.0 In-Reply-To: References: X-TMN: [Qa3SmPp91P8PkpaMNinQpayQZjvxqHbh] 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-33-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:54 +0000 X-MS-PublicTrafficType: Email X-IncomingHeaderCount: 50 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-Correlation-Id: 6cf6cf10-804a-4207-8121-08d90b6ae313 X-MS-Exchange-SLBlob-MailProps: gjx25WM8ZNU6XUx7q8EQ5McclV510mdNWlKGkLg5ADoIDNtjMvY6Lidy/Mpyv3/ndVPxS5S+tf+ET9d9oLyD7Mw+4qCOE5NdulbKz46NY1H3iYH+v8P519qbJxnOD7YOhVCEv61T1Upr1X2FR+VVF0/rpxctQibQTRlez2UWPiE5o/gvuLasSbn8MqiSiZeL/kv3DCwb0e5FehuHPNXmvZRgU2t46TiiMYyr6MLlcZ+Wgj8TCW1aWe1dF2bUDRwfarRwq1vKdotcIRuwCoBfmvPUUC3TyuxaSGl6MV8jCp5Q9ZLP/dLBwjIbU9ze0hW2MqIgxNxPGOnYnikHvmR6+2p/iuxInZB2Vk/UrSj67poLf4RRRWwvtGsjgCTJiCeNlJlQ6KT0LDcLRXhw4mVpNyFfGyQyMe/j+qcrrr7jT79pJkZnISp5FTB0Tj3SErOh/uS3ewlZKiNNcmSUnfAnmYWpHfzScFYZ1An40Wk9wh6cn3vnnNY8QJD2YSx94/DOWgRrZYUl9YtZJVzjnIApwnNiWeXW+AB8LLXW8Cl6ZTwWVidk/9FYnJzfuOwHjMKe+J2YS4/oLpnM24XXpMM7beW3MiVdhPWBRDyPcCIsCvy/aM9K9O2kZ5DJ5hxxk6dXNir0J+Jgrjmrqd27h2norHacJfshSrbTkyDCHOePUmgmAm5HMVz4PNvKeARZgxOeMWY1gbr/NavMc0JCSiJSv7puWmDB9C/6C+g/G8aEOPw= X-MS-TrafficTypeDiagnostic: AM7EUR06HT121: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: D4IgUtFU2HC4JadG800lrYovlExtbwONz/uBwew4srX+LDXUUOTGleJXWZpUmJTpKUEeINxv/WwUv+5y6qdC/NOJu2i3w8mFAS/5TQ1WyuMPSJlQbVDzUcXM1xw8z9a6H2/2veQg0fhi1tJm3QwP0Y9HRFVTSI0RkcmJ0yO8rI8lPPsvCfpdnppHFsEcnPMnH1mnBgnx6msWqnD2as2cKRTQxF8ktE60gK3old1vwzT6eI+pYpMWGUFiPqu69DrXccL18dDKdmqzzPscJYqHTV69PrvKiD+CSxA91eZQhejZ8uLwZiyfwOJ99YAlpwJm8eW5HhIn7e7NglZUKlL/Sn1gDGWyHR+EmEucmM2iiEPVQVPDRS08yjZCnk0IV4wx+LIS2Nb4sApHnd+55w3L5g== X-MS-Exchange-AntiSpam-MessageData: 8cTPZIxPRcPPDVhXkSz4fAgvJb4FOzyqP8a8ls8X3eRH0Dch9xKvKd3GGdo0cZtGrZNQUCo73zq0hKqtgB5KDdt3iTEjR9tIQzOt3+LuCK6Ji9eSSGpiFMknSmBctehzqAnTvYNYarrqiHIDDadB/w== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6cf6cf10-804a-4207-8121-08d90b6ae313 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Apr 2021 23:59:55.5550 (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: AM7EUR06HT121 Subject: [FFmpeg-devel] [PATCH 34/46] avcodec/roqaudioenc: 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: Vd2Nhlcpg15m 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/roqaudioenc.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libavcodec/roqaudioenc.c b/libavcodec/roqaudioenc.c index 9a636179b1..5908b71eb4 100644 --- a/libavcodec/roqaudioenc.c +++ b/libavcodec/roqaudioenc.c @@ -23,6 +23,7 @@ #include "avcodec.h" #include "bytestream.h" +#include "encode.h" #include "internal.h" #include "mathops.h" @@ -154,7 +155,8 @@ static int roq_dpcm_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, else data_size = avctx->channels * avctx->frame_size; - if ((ret = ff_alloc_packet2(avctx, avpkt, ROQ_HEADER_SIZE + data_size, 0)) < 0) + ret = ff_get_encode_buffer(avctx, avpkt, ROQ_HEADER_SIZE + data_size, 0); + if (ret < 0) return ret; out = avpkt->data; @@ -188,11 +190,11 @@ const AVCodec ff_roq_dpcm_encoder = { .long_name = NULL_IF_CONFIG_SMALL("id RoQ DPCM"), .type = AVMEDIA_TYPE_AUDIO, .id = AV_CODEC_ID_ROQ_DPCM, + .capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY, .priv_data_size = sizeof(ROQDPCMContext), .init = roq_dpcm_encode_init, .encode2 = roq_dpcm_encode_frame, .close = roq_dpcm_encode_close, - .capabilities = AV_CODEC_CAP_DELAY, .sample_fmts = (const enum AVSampleFormat[]){ AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_NONE }, }; From patchwork Thu Apr 29 23:57:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 27500 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a11:4023:0:0:0:0 with SMTP id ky35csp2018601pxb; Thu, 29 Apr 2021 17:03:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwPdMFJkR79pgALQN/JVJ0RsbVJgqyqg+xxCj4X5oPTvlKsISl6LoCGK60kF4Om8ALxno6h X-Received: by 2002:aa7:cf06:: with SMTP id a6mr2550915edy.340.1619740995595; Thu, 29 Apr 2021 17:03:15 -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 o7si1360786ejm.741.2021.04.29.17.03.08; Thu, 29 Apr 2021 17:03:15 -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=Zu1ZcCTr; 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 D3E5368A247; Fri, 30 Apr 2021 02:59:59 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR06-DB8-obe.outbound.protection.outlook.com (mail-db8eur06olkn2048.outbound.protection.outlook.com [40.92.51.48]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 32F7168A46F for ; Fri, 30 Apr 2021 02:59:57 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=WchQdbmii45dQquHuAZznBS8LTunQIVv2J4UAdAuqnKtLsDxqZD0ALMfuf1R9AHfMeexffg5b9FPLG0aPCXRHHLT1+h22JPnzsYQYUtiZPMVtoeg4MSSeGAGrW6K8Q2c+hBPsSnPUYr8cdFHRLq/3cZkGfGiXH1r//bDt6Jl0Wg7A0KJsEW+i/KeuOHmz29KJUM8fQVss/a+1gIP0WiWUALTk9PSV+Wdo6chaU8MGaJ1VlPPmHnYCLtiHXd1Kr4FN2omBxUPcNnHMm81HAZJcvMm88WfMrLcqjuT8vRpJ0VFxDCILqDO6B5g7VPoByoLHz8tAg1k3uLFGHM3m7aLXA== 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=E/Y9YFw6wpe43lcR6D1FMrUqnXlgfmHTZLb5rkWEICQ=; b=d47VHEPsHhVomEzNSz4RQpMhpzO7QMLUv698dWJrgGhTYJ6/wkfAl20tgH44ak2wdxwnGeA3HGDEiLYUu9zcVJhV1bVXSb23HYwhbAfpBLgKd0GahDGnBpCwENXTHYGZ0PZbdbd6xrrqVKtL9J5QtlNgPufaVfdjyIN8v2Evb7b6bAe39by/7ggpN79XbAWf7OYnlLM8YAIvJ/RI6QqtW76I9doEoR+91wmz7dvwJ60fTBIgPx+k7SQhU0UBKPIhQafrdWq1rMUB9DyZNrc2XJCcCUR/RcEkkOXzDfRkuewFAlQxsonuBb1L1G4HgQLnNoedot2HwvicyQCbsCu/xg== 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=E/Y9YFw6wpe43lcR6D1FMrUqnXlgfmHTZLb5rkWEICQ=; b=Zu1ZcCTrFjE8QtUVwaeL/cTd7P95dDAhK7h7o+Y+Mn9Jzqu+cZI0GgC9yJrBLNGEtBahYeKzHg/fgYfDDHRbajfoSPnWyGm1WEn8GE/VAcg67ghlA3/oD3Daci6EO5gR0R3hfppU1GdUMd66vcMyqPi9Lar/Uo0i+qsfvIQmd6itR0mf/4WHAsNx3yocQshSPLCtRdfpnD94VYdXqZNhSwpES01/D/PHqO5TsDqxtZclIQV9xt5CVcpoBreMPwirx0dIgd2bCor/vsRN3eOmS9FO51DaDgKQfBteowphDffuD/KXBsXsbsEiBr4xI9u7QEqb5Fz29WLhCn7aB+GcpA== Received: from AM7EUR06FT055.eop-eur06.prod.protection.outlook.com (2a01:111:e400:fc36::42) by AM7EUR06HT229.eop-eur06.prod.protection.outlook.com (2a01:111:e400:fc36::204) 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:56 +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:56 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:9BA588706AB6E127AF707BB770445F6BD7492C51B7FDD41A6FE1ABBAFE498DF7; UpperCasedChecksum:D3E6726B6945A753B18562023474038C7134FCF1823967774F7840817F15ADAF; 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; Thu, 29 Apr 2021 23:59:56 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Fri, 30 Apr 2021 01:57:06 +0200 Message-ID: X-Mailer: git-send-email 2.27.0 In-Reply-To: References: X-TMN: [J6Hp54rlzLxu2Urj6X6XqpyM5FWrHiUc] 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-34-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:56 +0000 X-MS-PublicTrafficType: Email X-IncomingHeaderCount: 50 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-Correlation-Id: d091840e-bc41-47ba-c00e-08d90b6ae3c2 X-MS-Exchange-SLBlob-MailProps: gjx25WM8ZNU6XUx7q8EQ5McclV510mdNSQ6zVwN/I7EX+rk7h1h8rgqhciQx18U9NLAZa+qA6gywEMO0gZY3oEJvcr7n7HWA6JBl08oqPxDq7IbNnuk9rge5a2NDL6CSqXZNA+ohPCU4I7mrh9Az4AfThiKvYisGEEyIlHxN+VLENsQASYO3sVcIa5yiK/8JyXkUzYV094rFPrbVSn7KCQAWW7IwxYjXasMA1u2ncxUjio8L+rI1DFZp7NsjbWNolEy0dtlayrIQxDt1yiC6Ux7lm9PGE41zuUQ/kKP1QFJFEMlidumNS1zSgNk0ctI2mpm5z4i2fvbx3yt74s3m3994SORPDt+ljERRJjdjGKcMVoGBL4ku1Kf3rfo2ub4HlSF4b+D5v3DxlnBDa/t5YkUd5NJXHcOFyeCrEzQbQ45HhM4HUdVDsDpVGrm4QWqVX4vLytCrQrMXW7NxAkWuFHeuly9nPQjbkStzi7UmKHjMyjXVq61yvch2m6X41nDcmoEvdFSMtBh6mloXfPPchDwZ7ZM4mYsJM2fEdy4sLXcFJxrY5OyPKexaNB2x7FoSFZWO6or+uVjsNo6nhFhJBx1/D+02vuwt6d/41TWdEBbFYVUyZAzozriwA7HrREFXltKRW3VxUcqoGa2Skf2vs97NA6DjG6S3lIsfu4UndJ8feRVsxuPMcASbQiwLzCGlmWjIFYqDvo+O+Sp4E1jWD81uh41ymmxXs0T9g/0BWZM= X-MS-TrafficTypeDiagnostic: AM7EUR06HT229: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ULPvpaC3DrkRZnlFBmctGBIet1nyWqH1rq5DnjU8k6p6DzefezGpRqSqUjfgSvEyxSxPkLErw3QElm4ZfAY0r9PMNHDFJTUkbHssXLIxgvBgn6iZTQRSE+DMoXSNCqJy1oYj9s8upUlndU0yI2QOR4WPnmiH5pkEAH5jiyySHSIRkxP+KStvkp7n7ZPcClJ0ULYzakd+JvFxhSiWXq+yXggOjm6wkaUOtT83TXV6NnPEroaGSFYNjDPaawDFt3cqaq8ShWhK31KwS5aVC5LWS9RRY3kf/ghwAn1gKTnd+LXGpECDsKVR+z9l3e5gHua+BSymn34nPXumHLLdGoYn5ILRBL6R4rodL8gcI9oTZP4O+oSZiLOm6OWVisjAv+SQYfL2s0WgOwY6erJD3G7vmw== X-MS-Exchange-AntiSpam-MessageData: 5fLNtuLP9qRuIMj/X4FS+SUZKSwi7PlxCwZXtUxjL8Kj90AqPx3tCozPQ7BItzV0oDdr8xS9SUVqi0zA+uhgYY2GQcmLr4vYHlkXa/eztpJz0/2ZbbODDXG0ZKLpEc1iJaQUbNrJIyX5nR0eAmG27g== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: d091840e-bc41-47ba-c00e-08d90b6ae3c2 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Apr 2021 23:59:56.7005 (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: AM7EUR06HT229 Subject: [FFmpeg-devel] [PATCH 35/46] avcodec/s302menc: 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: NAgi/l8a4Xzy 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/s302menc.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libavcodec/s302menc.c b/libavcodec/s302menc.c index 2d0615bb2c..f145fd5f4f 100644 --- a/libavcodec/s302menc.c +++ b/libavcodec/s302menc.c @@ -21,6 +21,7 @@ */ #include "avcodec.h" +#include "encode.h" #include "internal.h" #include "mathops.h" #include "put_bits.h" @@ -83,7 +84,7 @@ static int s302m_encode2_frame(AVCodecContext *avctx, AVPacket *avpkt, return AVERROR(EINVAL); } - if ((ret = ff_alloc_packet2(avctx, avpkt, buf_size, 0)) < 0) + if ((ret = ff_get_encode_buffer(avctx, avpkt, buf_size, 0)) < 0) return ret; o = avpkt->data; @@ -172,13 +173,14 @@ const AVCodec ff_s302m_encoder = { .long_name = NULL_IF_CONFIG_SMALL("SMPTE 302M"), .type = AVMEDIA_TYPE_AUDIO, .id = AV_CODEC_ID_S302M, + .capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_EXPERIMENTAL | + AV_CODEC_CAP_VARIABLE_FRAME_SIZE, .priv_data_size = sizeof(S302MEncContext), .init = s302m_encode_init, .encode2 = s302m_encode2_frame, .sample_fmts = (const enum AVSampleFormat[]){ AV_SAMPLE_FMT_S32, AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_NONE }, - .capabilities = AV_CODEC_CAP_VARIABLE_FRAME_SIZE | AV_CODEC_CAP_EXPERIMENTAL, .supported_samplerates = (const int[]) { 48000, 0 }, /* .channel_layouts = (const uint64_t[]) { AV_CH_LAYOUT_STEREO, AV_CH_LAYOUT_QUAD, From patchwork Thu Apr 29 23:57:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 27525 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a11:4023:0:0:0:0 with SMTP id ky35csp2018639pxb; Thu, 29 Apr 2021 17:03:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzri/6ca9IxyviHyNbdzhFK593PtkRR8OVP6jeAAb8a+Snqxg3r1zRbWZU+dSzIizgpRD6b X-Received: by 2002:a17:906:a155:: with SMTP id bu21mr1142557ejb.400.1619740998689; Thu, 29 Apr 2021 17:03:18 -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 f27si1829944ejf.327.2021.04.29.17.03.18; Thu, 29 Apr 2021 17:03:18 -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=DmUHr4c8; 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 E3E3868A487; Fri, 30 Apr 2021 03:00:00 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR06-DB8-obe.outbound.protection.outlook.com (mail-db8eur06olkn2077.outbound.protection.outlook.com [40.92.51.77]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 6B08368A467 for ; Fri, 30 Apr 2021 02:59:59 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=YfddJuOTXzKjh4QhOBsQ1NOVmu5wVkzWbyFMq/yWdZ4S0bwpsppHL/ykfoC8eqDTaN6nycyK5tu3bz76RBgnO1HXxSaabb+KQQfx3SDFwVArf8SOJQF6Mb1SE4W7BY0Friv25DXTXYMKZWDkOciuuMH+uMJG8gx1l7y4RuVCrGl1bk4cHh42gZ2HAO2MuIYpj/Gmv/s8mZN6prNBt3YbOl26ujg3Ly9qbtF4QbT+1BV4fZEJw/32kiRLl+aKgUNAnKVV+QZgFzwAawS1hGc24WJZ3oHfuEAsJ3ZWh5uUHrKkAxdzq+C/SzXFFHKGO2P3foAgpoDd/mdIFAYOwoEOjg== 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=d+EwNRhqzTHHOcihuC7gWLqgoO0E1gushwZoytxZM4g=; b=Eq5zVHVBWgzHxsCrOLDQHb5XDISlozsCXZdsqrbXgc2QxIJ+czbpNl1VUVULxXGKTEC6BTEWR2qrInGHef6S9hLKZUbRwr3dclG7PDGqaM2MK3oPuRub01H1qUoFQGinzSZHaeB/2fRVRxRF89FZIWs3eaCbnXEHz90go/LZQNWFCGIA0JzBoNR0u6qjl9ulDrceKbjiJy89lhduCLwG04iZEwdX53LpAPSVXO/NnvrP2Z1NN4XOC8Csny/VN0EPwEeed9i9Fe2F01UNcYMOmKt6yxeF09ZB1IKiPPv8Fa7qzuI7zq+bC+muH8JzAMKPubvfklP9R5WBFjuLU6uvcg== 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=d+EwNRhqzTHHOcihuC7gWLqgoO0E1gushwZoytxZM4g=; b=DmUHr4c8evJMXo6XPo0k2Lj37A4YzSvH9Wm1DfhzvvgJkP7uWblTkSGatCXuaKLxDLvPmJ3oj3JhKf7gP6eFVapbqD4U7Wpqgkca6rtpBW5mUa+F1AHl1bw+PhqEm0vmTjCZwQxaeVDG/IVBcuAegNW0RGaybKsI9l/TLlBAcAAcaD4DyJU5uDwGXpvMrcH2vqySHW1xxA+Ew279pfcbMgkNo4nhoL9ViQT4T2OuzEAmlkui4spFyAVMM6CbM3U6wxMxZF5svM9MSvDRNcZiwolzbfJHHmoFQRtFPV1bzj5y/HMCg/boV/V6XrTONVzlKEWJ+qBvbQqPIIkuI3rSpQ== Received: from AM7EUR06FT055.eop-eur06.prod.protection.outlook.com (2a01:111:e400:fc36::4a) by AM7EUR06HT040.eop-eur06.prod.protection.outlook.com (2a01:111:e400:fc36::94) 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:58 +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:58 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:3CF1BD9B5F9B2D06380F667074AE6BE00D582805896EC55D7AD21F48655D22F4; UpperCasedChecksum:8B9A8F33CC622BCEAF89B2D62903678B68E21E3BD217592033A84C742663B424; SizeAsReceived:7750; 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; Thu, 29 Apr 2021 23:59:58 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Fri, 30 Apr 2021 01:57:07 +0200 Message-ID: X-Mailer: git-send-email 2.27.0 In-Reply-To: References: X-TMN: [HBJGN6cIfeiWdv6qpghjaUhrnqt51t3O] 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-35-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:57 +0000 X-MS-PublicTrafficType: Email X-IncomingHeaderCount: 50 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-Correlation-Id: c8edb1d2-4ebe-45b1-24b3-08d90b6ae496 X-MS-Exchange-SLBlob-MailProps: q+fD6XS3/UIO6YRda03MtHguxZve2k0Pehq22FssKt6blf4rKSZa7zGk8wCyzcxX6oQftRJpFl24JuFQh0wEdWRwajLlpC3uavL+1Xbcs/s6Thjjcfcq0OQIspTkVrl7DpGh0HgQ/mPPF8SLkTe3bH+rjthI0Pjq/yHVUgjoJHsq8Av2ErDm/k1PEpAJ/kU0qYEb4NtexPD5Qjqw+/v+YiM34Fp9OiSB9ySceytftSilU+NjGPBrDkaYdPWcDGDO8wgGHFH7Oe5DJa/d9Ynra2LlfGOx4sx9K7wuzhiSCgzazm1U4BAOQCYtgdED3dip9E2rUOMWKOBBdOtVo4GKOl66mjT0wsSp7JagQhJ2zMpCrU3guzhxLJPtKpqkN1izklnedCxAoUTnsIH5nINWROHQqs6Q02zz7osyTpa3Ksf2ADHcXUhTXsBjsg2yTgcWb/I1KMe7t6uP4LvdOY5g/X2wVhVROAIfbVuV0PAEBfML/bAuTih87S7H9ggvgq9Ab38zVP9guIoJcOLsTTU2sy/9x7zqQDdR2xwBC4FHpA7qfm83L0rxrBPAhMUIc13CGt1McrKrB8OVyHaVhOAmo/+nTtb3lJcmniDTxX6iy3dXLxOY8eejdPfcbNg9s7IJL28gQ1L3xYXo0riKA25Fi+M3mQee7JzBi2Hb84H4JlYrxDgtC4RBVTop08QwEqPvBHFYywX5e5u5n1buXoi67w== X-MS-TrafficTypeDiagnostic: AM7EUR06HT040: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: aTert0vLcdC+XptzO6j3Sq6ZwQ3Et0BDYa+vCcOl1AOCR/GvO/PQ58TBrx7pnOXdhKabjb45KRx9cAFmDfOGhx4gO97XbNGbkT9oeAZncJTqkaPVy4AJVGXKqa+oawDPmu4a1hCXgkQajyAFJ25xBJEDiZN/ZEkVeNXlKtwhQtYXbstk9SMq0Zz+N7onA3JqeGSs8SxlOPM7PcjOcm6ciJFRV0HebQzN98a1yu43vLkNy4+WtWoq87w/9kiS1BSP4MqGmP194VD0IbPKCAHrdNF9r+x/7RfomMKLTi/xZEiiMniZRMt+Vj79RByvCMhIPKAmAWYYn3gQgRdpwqjTDUBFM2eGBzHlM0aciWEdquxbdRmPHS9uGRed1JROu+CLYbR6FaqBuPsQCTQMWrgzRw== X-MS-Exchange-AntiSpam-MessageData: SCdZEg+aNX71vaQZz1mCrLsuMLqRD8I5ajaeaOlKmin46STha8SEaFnSZOK0l5GC5j9ctUW+0RkXWHY6agSyWRZNXFsWfIlkvOCbUtwv4z+V5B/5lgrq2+I+jXftTVVIecvj6CRhYzlVKofoJUFZrw== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: c8edb1d2-4ebe-45b1-24b3-08d90b6ae496 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Apr 2021 23:59:58.1278 (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: AM7EUR06HT040 Subject: [FFmpeg-devel] [PATCH 36/46] avcodec/v210enc: 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: ItG9xmDaGit2 Trivial for an encoder that knows the size of the output packet in advance. Signed-off-by: Andreas Rheinhardt --- libavcodec/v210enc.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libavcodec/v210enc.c b/libavcodec/v210enc.c index 020f0fffe5..ffa1cb6f4b 100644 --- a/libavcodec/v210enc.c +++ b/libavcodec/v210enc.c @@ -23,6 +23,7 @@ #include "avcodec.h" #include "bytestream.h" +#include "encode.h" #include "internal.h" #include "v210enc.h" @@ -118,7 +119,7 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt, int ret; uint8_t *dst; - ret = ff_alloc_packet2(avctx, pkt, avctx->height * stride, avctx->height * stride); + ret = ff_get_encode_buffer(avctx, pkt, avctx->height * stride, 0); if (ret < 0) { av_log(avctx, AV_LOG_ERROR, "Error getting output packet.\n"); return ret; @@ -156,6 +157,7 @@ const AVCodec ff_v210_encoder = { .long_name = NULL_IF_CONFIG_SMALL("Uncompressed 4:2:2 10-bit"), .type = AVMEDIA_TYPE_VIDEO, .id = AV_CODEC_ID_V210, + .capabilities = AV_CODEC_CAP_DR1, .priv_data_size = sizeof(V210EncContext), .init = encode_init, .encode2 = encode_frame, From patchwork Thu Apr 29 23:57:08 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 27513 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a11:4023:0:0:0:0 with SMTP id ky35csp2018868pxb; Thu, 29 Apr 2021 17:03:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzK84mUaOp3zoX+krAoS0eaLfdEQOxFLQAnlUNoQI1byGoiKs2ZPMWQtW7AXHfD8HzTCkkM X-Received: by 2002:a50:fe8c:: with SMTP id d12mr2580410edt.336.1619741014756; Thu, 29 Apr 2021 17:03:34 -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 me3si1488692ejb.129.2021.04.29.17.03.27; Thu, 29 Apr 2021 17:03:34 -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=jtfur8vQ; 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 EB27568A464; Fri, 30 Apr 2021 03:00:01 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR06-DB8-obe.outbound.protection.outlook.com (mail-db8eur06olkn2094.outbound.protection.outlook.com [40.92.51.94]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 16F0968A467 for ; Fri, 30 Apr 2021 03:00:00 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=W5dCE11MSx76IXWdOP8DbHCzrhA7wpuTYaBKkKUAeutXawL53YCQNZmQj1+f4nHnLPB2q6Wp9w+H9YFBZ4aZ+5/E5wweSLcibfaDymyZXGdZQ9tZpupnMzIOmxJ20i+f+wlvu+MwXP27W5/QLXcsRzasPzRk8TC1FKOZrRGvOpmllOpL31ujgfoDTHfcvYRmQ0cYfba+vHRslOeiZ+43oqMy3XMtH/YwYJJSC1zh4Khx22JdUTw2AsK6mdolXBOxzKeGYBu2rRFqs3uguH3Hix6cfMmHIM3enZgY04OaX6xRQCYAQLLkWrkeznE8PPfy9RWlnlZ81oSjHETmSrQu1Q== 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=ZN+/QAtnzRvsseRPeuKA7kgwenpDuHwP06I8JdXj+rk=; b=kg36tDhTOAJCFOkCSUK7TwghK1UYc1aNz4XeyTfg6zciofUq8A5HYGr4iclAEcOuDMFPEVRCqmYSXUsduHPYf9faSbH0D2jN6FqKn3uM2sHmI9+wxfYiSe9alxqwybpNFCTDGyD42IAuHSnzp/9jneawCn+Hh8g1YcWFh1uLncv4w7shLW4NVtq5qfegyptXXXGbmo3Gx8BORrAzj7V6H11+xnS8kldyqm8Rd9ESx2EgEsTTdHQ9RS/bTFGUy54klRO5WvH592on8MZzbvg3Ey97sRFUf23iBktLIDo9Z6+9/k5uU4dyrYI2tHKllWcAGPfHifWfOsfikrsSN9jWUQ== 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=ZN+/QAtnzRvsseRPeuKA7kgwenpDuHwP06I8JdXj+rk=; b=jtfur8vQVZ5HiRYLr0MKTPBIpaMVGvTB/F+aK7kFjKp+xCxrV7bTsftVictmF5BU4uGffmjta8ntr4O+wDJxrPfNS+j0otIKVsVPtxKPcPv8o0/2FM85YogJdcadWPh/gpsnd8bcY03AG4sMo1MOW6E9rdPeaAP4I+xRwnpB5CStiajq4XnQW8kwvKDtIso/43uxUcbe1U0wXHE0zd4HrOhABxCMM+LUKfiIbHj9L32bm6dcfa+oFZtqWcTRMrOH8GmBWMv/OvtN68GTdrIwLCYvYMWknh/cGWaCz+AXgK5CuUJOnjTk4XRh8CcBI7oLvaAOflPKaB9/nJAWgHsXiQ== Received: from AM7EUR06FT055.eop-eur06.prod.protection.outlook.com (2a01:111:e400:fc36::4a) by AM7EUR06HT040.eop-eur06.prod.protection.outlook.com (2a01:111:e400:fc36::94) 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:59 +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:59 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:5BB83758294DFA631D0D2796B5985F6EE7C19FC37C20377792C438BF3DF16836; UpperCasedChecksum:2E20D0CB0517D1A801F2134704E8F94B210A1C73DB9700FB8A666D8C20A27CA2; 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; Thu, 29 Apr 2021 23:59:59 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Fri, 30 Apr 2021 01:57:08 +0200 Message-ID: X-Mailer: git-send-email 2.27.0 In-Reply-To: References: X-TMN: [62XyXkXRqYNg/fghmGmQua0VpCu+bj2N] 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-36-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:58 +0000 X-MS-PublicTrafficType: Email X-IncomingHeaderCount: 50 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-Correlation-Id: b0f3550e-45d2-4de4-b168-08d90b6ae54e X-MS-Exchange-SLBlob-MailProps: gjx25WM8ZNU6XUx7q8EQ5McclV510mdNSQ6zVwN/I7EX+rk7h1h8rgqhciQx18U9NLAZa+qA6gywEMO0gZY3oJdyL8QvwqvEI6c6viBW11p/QMKTf40K/eVqCMZOcUPLwNQoroVPuv7nFlD6hk2rJ8iA0CrP7OIcPUXItQ6qTQiGBZIaOojUN8amR0SeuzkN256iJ/4qyqED/wb0kgo1bcbCVanISL28LvxY0S+Z4OVj8yzAit664SGmatH334VTUiBw8HwonWh37g5lGxpfbcUfB+bu+u4sJqOz9KwkB6j3zphJBXqzOx/GyPV9GCmGAVxlsCBaLaVyJLOEznylvgiylzvKU9xhkQt/C+4nQ7lvd3zuuOcAxfARD5FhXG+nQpyGML9cmrayIlxJfkOqb0bayjPA911hiLYaKcmrhgiJxTBbfya9Z5F3TQTC8JzlKnApE+tmBSniLGkYUSfX37P4qLWa62VD7osDrsvoBXZo+IaeqpTmDOSn9G2kyiRITdeClSf/u8Ebq1cuJrXnW092zvKUXLeRjI/jXNIOL//H7eCYEltCwiYF9JGuij2UAJ2YGsk/UYBn3h/3kFKB4tIbeR6l80s+5f1EhrmkqI5i6j1bMnKbMzO3wGc3V29xgV+1xZ59oNJQfEmo5hUjA7WVM94now2UxOS+m51adSmyziw4I447ptH/SSGVBlyn89m8nwRkHxCtZt5djsiDnPMnEV1tyXcb+MPU0RIDobM= X-MS-TrafficTypeDiagnostic: AM7EUR06HT040: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: DLqp0VxhR0SKb0d1Sdyz+iOoDealckfwQm4Dx7Y2i/vZ6PNYMyLIFMgLljNyt2So6GqEPwkbUGboeUwlEVLBY/T5PKWEQh9bqktMVXHaUzPel09Q0swW1SZQSHIsV0Z+Gm9QKJbnScVBxoPp+p8N3Xkgdzyo89x4wW7PUD7zqmI4QjpuIHuNIHxziOBAoTtyssnMpewahu+SpyHIaRSoEwuLJXsDqhDuGdNcEe+FW6TE5fXARB8QLUNvo2J6P3IzrMDfFfBsgEDuOWC+xkBlrJSUiXlk0ZL09PtHa3fQ0Ohnm4360qL8ws+wPfuSvnl8wfoP49Vllwz+I1e/ZpQSJ3wqMDyI2fJEdUbN4JzBwf0G9xt969DgJNkpMN71ZXuWkHI+0LgPAG3nPVEBkOwxSg== X-MS-Exchange-AntiSpam-MessageData: 6ZzsJCusII4rMDMrH4x59b9wE9eM0Zd49d8oSFrrbSMvLyVkb6kQ2zxjoBqYorr7tEN7ow/6UvIL7lVwbPVeDFAPxyoOkp05jOXWvCT63cO9rozVPt0XTgSep8HbfIiU3fNfnauT0KMRu3LfDL4LWA== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: b0f3550e-45d2-4de4-b168-08d90b6ae54e X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Apr 2021 23:59:59.3093 (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: AM7EUR06HT040 Subject: [FFmpeg-devel] [PATCH 37/46] avcodec/v308enc: 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: J9yWEkup1zvo 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/v308enc.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libavcodec/v308enc.c b/libavcodec/v308enc.c index 919f0ea10b..18ce926b15 100644 --- a/libavcodec/v308enc.c +++ b/libavcodec/v308enc.c @@ -22,6 +22,7 @@ #include "libavutil/intreadwrite.h" #include "avcodec.h" +#include "encode.h" #include "internal.h" static av_cold int v308_encode_init(AVCodecContext *avctx) @@ -44,7 +45,8 @@ static int v308_encode_frame(AVCodecContext *avctx, AVPacket *pkt, uint8_t *y, *u, *v; int i, j, ret; - if ((ret = ff_alloc_packet2(avctx, pkt, avctx->width * avctx->height * 3, 0)) < 0) + ret = ff_get_encode_buffer(avctx, pkt, avctx->width * avctx->height * 3, 0); + if (ret < 0) return ret; dst = pkt->data; @@ -73,6 +75,7 @@ const AVCodec ff_v308_encoder = { .long_name = NULL_IF_CONFIG_SMALL("Uncompressed packed 4:4:4"), .type = AVMEDIA_TYPE_VIDEO, .id = AV_CODEC_ID_V308, + .capabilities = AV_CODEC_CAP_DR1, .init = v308_encode_init, .encode2 = v308_encode_frame, .pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_YUV444P, AV_PIX_FMT_NONE }, 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 }, From patchwork Thu Apr 29 23:57:10 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 27505 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a11:4023:0:0:0:0 with SMTP id ky35csp2019121pxb; Thu, 29 Apr 2021 17:03:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx4gWVXwz8zsO/QlG2FVNGCaKHRCPIpANfTjvppUm6f70wAPs4ipD74njdUcD8wjPWcYlwe X-Received: by 2002:a17:906:1684:: with SMTP id s4mr1065308ejd.506.1619741032850; Thu, 29 Apr 2021 17:03:52 -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 zc8si1438216ejb.452.2021.04.29.17.03.47; Thu, 29 Apr 2021 17:03:52 -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=MdRmPAZl; 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 8F77C68A467; Fri, 30 Apr 2021 03:00:08 +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-am7eur06olkn2021.outbound.protection.outlook.com [40.92.16.21]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 2D8D468A46F for ; Fri, 30 Apr 2021 03:00:05 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Ds+WdkoBBW5rgKTcpw6ysHUnX+gjyRdsMyZ1tTEmBuKRXIBRJvRuvxglg/M5t3897Sj+JReD+j0zCovVIOtt+lBZ5z46zq3lriK51d/khWFsKc+p7svmQdasDRLKuoPyuO1Cjmg+yDjP/nv/CY85PKmr6HRDdnHB5DfkpqzwvT4xYzB13TGRzAwIXCmmk1qPr3erxL1U/7RAcCUWDqEGedot/iRFCv7wxtwrSyBGUlBsNJdvH85G694cToLRzyZWdtMgj/NW5sKwjanssOlK5oPyGgq8/VKzaOqm+Ageeueg15gABohUfQyOVfVwaguoRbJgqAR65EeIkCIKxGrjqg== 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=TUMEjbwfTeQTuQk+3p0bCp35NTS+oBPIl1wmkGbW3eE=; b=ZZwz5YhS4ZOP03P+7mVy16bfduW88zFcC/87Dtf2H4beGkoeyK/dOeWyupcHA4o9M+WA/BTNME8SDkiMUlqKmolWUos6+xTbsSv7s4MN/onqtlH6/GFISVoS6O9rGWpI6TbttKGlzkYV9YGl7OAyCnhi+Yolr4VFi35Pi6kO4R8rV+bIe6eFaY1pCDd6ZsQM7MhIKZugshBUGFRQsZumPkCfOZlwYXXPOqmMBhOduKryr36fBiyIjc8Z4rYNBQXwQ8JhCzulnl2bOtpsyHRJP02KxHMPq8dXgkE8spP/UEsUpl5jtHScgE6WNvsPrMavH0iW4xCbvI+LggbbbLpg4Q== 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=TUMEjbwfTeQTuQk+3p0bCp35NTS+oBPIl1wmkGbW3eE=; b=MdRmPAZlRKUb2vmwGLz8pqvycIoQtPRtaoL7b8dHSivUXZhqMudoXjgDtYw6QJfgsbrzmW3Pam8dJ2AlS6xbkvaUnVXyXoh/JBiVI5OIUQLwlF7Toggtg1NhWDu2/4RLsfJRtBd9VN7QkEcBTtZuUW5PUebikcCvVEYvv1EMa7aNVNuNFVm5AjvF1iaEJ4s5VcReABccU/Cg+DBU6J5claH3E9W8SDwScaaXxpv36Yju0vHXfD4YnLsJpIGlbQdXQ2RLGkAXfG+db5cO7+4dCH/yuCS/GZm0yC1FwlDGNMO+bT8gYuwuUu5VoxQr9v96MOfSJe4hJ5tyX+AYHCTZYQ== Received: from AM7EUR06FT055.eop-eur06.prod.protection.outlook.com (2a01:111:e400:fc36::4b) by AM7EUR06HT209.eop-eur06.prod.protection.outlook.com (2a01:111:e400:fc36::129) 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:04 +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:04 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:72B6478EAF1AAB7B0858FBFBD132AAFC8744AA20E5815777558B8F699D13F977; UpperCasedChecksum:ADF8D23E7FDD07A45DEB733643F6BE82650B74D00B4CA3622C1DA77BCD80CA45; SizeAsReceived:7776; 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:04 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Fri, 30 Apr 2021 01:57:10 +0200 Message-ID: X-Mailer: git-send-email 2.27.0 In-Reply-To: References: X-TMN: [u2hoLH0/r+6oqs7kswbAfisNEWesWV+7] 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-38-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; Fri, 30 Apr 2021 00:00:04 +0000 X-MS-PublicTrafficType: Email X-IncomingHeaderCount: 50 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-Correlation-Id: 4224766d-644d-4834-56bf-08d90b6ae879 X-MS-Exchange-SLBlob-MailProps: gjx25WM8ZNU6XUx7q8EQ5McclV510mdNA5vT/fXqaCFWWg8dLxrqsvly2ofy1qPnI1xAoF9E6tcQ3/58sTqneWv/MIjMaKYMTjy35B1av9ijRjz4wscEXdV3b93WShjCT4XtiMi06Tbtd4YxSXhrzt0RnxJ0v8t/Se+iobVSFYs6CQQ/ffqFWB/UYOZYZfWnJLo0RS3fKHnA4ryhdddgsBabD7iZjiUSAfQWux+0ozoemYrZKZFxh4fkYfV4hJNgofK25f29NwDR8kYw6+A7gVHjlXlChNPRRwGrgOHk/BQgHHQYQW0eE0JQRFJ9xtK/61hFKNCesHsaHB+e2DU8k7KxhgaqiKJ8XDgRDKuGVnj+T+id9D715AZD04OAra/knx2cEn5uaR4iwW2IljmaKyH/dFm9mAwAQoy0UINjacWuGBekAfEY9Bi2HFW9qBJWqKsaf/UupyUaebZYJSwvuvlJHz/nOeGRHJXJTCxzcPPtcR7HboW4PYYqz9gJs0Hs2HWgxLwNwmuJjei+NgApdnyzgoD/xjVWofW6hPqz9gsQNdCgGTm1vOi4/ZcuSTLtFoLlXNOF2Oa1bpG2k1UJwMZJpSEw/Dzp/4PHLUp+hAaxfr0FzMxa6qru+FIZ/bEbGE++cTrcmeCkS7F1YR9EKprTlIZ9u1RAFTBBsfTFgKnkp0eUpq7mtrtRCus6tQibu7pp23tNfrH5Shx7q4WT6eWyl07TTmdaqCvYAwgIUiY= X-MS-TrafficTypeDiagnostic: AM7EUR06HT209: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: lEYGDYxmU/k1DqumkqYO4xH/n52tRspnqssH4BAjqSPAYp2mET3yN26rwarlGpnzf66Ip7tJgNFXD1QPFovFfm+8MYbVI5gVb+4fnV+82ezO9vPjD2onBClJxlk/rk6/ju32I50xAFVo4EphU9uOMir0EAIK0GvVXgRRQIEKx3jDSwKU+G8tIqhzExLaax3JlsYgXANpA0YBJDdUpSYGMk1X6z1JqKDtXC703ME0Q70m4bGlcBzRDoeyu2RmOjI5TnjdOID6xJaLUdPmMILQ2c9MaaM8DZeQ1zsOs6j52G5Q0x1GmoMd0hoWk11hXsD+Q9jBAOA8zM+xmjDRPRgUjf13khrQniYSU7QGZMUNCgwn65I9vyPEXjx/kf+PQAjj/gmolnT+JQTkapyAsXr2wg== X-MS-Exchange-AntiSpam-MessageData: fgNkEnUG+GA7qDLlKoip2Ox9bKisAn57eNwPSQeeq0ZQroroqyufuk1BXAvmH16UZPFrEbXvspejVCDfoSlfiG2bVX0U2xjR/umHIVHxSnwFqgVN+Zdx8eCfcVdkJHd805ZI1lnFa4bBU+TAFLolzg== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4224766d-644d-4834-56bf-08d90b6ae879 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Apr 2021 00:00:04.6050 (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: AM7EUR06HT209 Subject: [FFmpeg-devel] [PATCH 39/46] avcodec/v410enc: 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: U1d8ejFQnsfW 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 ++++-- libavcodec/v410enc.c | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/libavcodec/v408enc.c b/libavcodec/v408enc.c index a0cda6fb0c..af9fcfa9e2 100644 --- a/libavcodec/v408enc.c +++ b/libavcodec/v408enc.c @@ -75,6 +75,8 @@ static int v408_encode_frame(AVCodecContext *avctx, AVPacket *pkt, return 0; } +static const enum AVPixelFormat pix_fmt[] = { AV_PIX_FMT_YUVA444P, AV_PIX_FMT_NONE }; + #if CONFIG_AYUV_ENCODER const AVCodec ff_ayuv_encoder = { .name = "ayuv", @@ -84,7 +86,7 @@ const AVCodec ff_ayuv_encoder = { .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 }, + .pix_fmts = pix_fmt, }; #endif #if CONFIG_V408_ENCODER @@ -96,6 +98,6 @@ const AVCodec ff_v408_encoder = { .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 }, + .pix_fmts = pix_fmt, }; #endif diff --git a/libavcodec/v410enc.c b/libavcodec/v410enc.c index c31bf7f4d8..07d1565980 100644 --- a/libavcodec/v410enc.c +++ b/libavcodec/v410enc.c @@ -23,6 +23,7 @@ #include "libavutil/common.h" #include "libavutil/intreadwrite.h" #include "avcodec.h" +#include "encode.h" #include "internal.h" static av_cold int v410_encode_init(AVCodecContext *avctx) @@ -46,8 +47,8 @@ static int v410_encode_frame(AVCodecContext *avctx, AVPacket *pkt, uint32_t val; int i, j, ret; - if ((ret = ff_alloc_packet2(avctx, pkt, avctx->width * avctx->height * 4, - avctx->width * avctx->height * 4)) < 0) + ret = ff_get_encode_buffer(avctx, pkt, avctx->width * avctx->height * 4, 0); + if (ret < 0) return ret; dst = pkt->data; @@ -78,6 +79,7 @@ const AVCodec ff_v410_encoder = { .long_name = NULL_IF_CONFIG_SMALL("Uncompressed 4:4:4 10-bit"), .type = AVMEDIA_TYPE_VIDEO, .id = AV_CODEC_ID_V410, + .capabilities = AV_CODEC_CAP_DR1, .init = v410_encode_init, .encode2 = v410_encode_frame, .pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_YUV444P10, AV_PIX_FMT_NONE }, From patchwork Thu Apr 29 23:57:11 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 27526 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a11:4023:0:0:0:0 with SMTP id ky35csp2019316pxb; Thu, 29 Apr 2021 17:04:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwJMMLnUtj+i+X0HiLoM4+Hy0A6fpf4C670gKajVh4ZWcqEVpsQkqBsB5t0ao/FBRCh5jXf X-Received: by 2002:aa7:cb48:: with SMTP id w8mr2562540edt.55.1619741047069; Thu, 29 Apr 2021 17:04:07 -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 x25si65908edl.238.2021.04.29.17.03.57; Thu, 29 Apr 2021 17:04:07 -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=Ffaesxc4; 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 85ECF68A4B0; Fri, 30 Apr 2021 03:00:09 +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-am7eur06olkn2085.outbound.protection.outlook.com [40.92.16.85]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 3A65C68A473 for ; Fri, 30 Apr 2021 03:00:06 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=PK8GVZHodFi/uVlQGCj5K78WgVyHsGiqXF/OTAf67+YBDCRc1qekOfoy+vRF/EC4M/1Rg76OQO/DrR3JRw11S5FRBkFxJS3FlvVBzTDGzLXCKkZTHXnYY2fhXTQ9B7IdWNk7RNDkzOnqxJS3HDLkbmdF1V6/HcIwcLSgpXCcTSy24gN6lV6O57x6ccNAv38FaHjbCfCb0+jDnZpxGoWo5SLnPHV7OQGJanPDq2sjx04TXZZoTThoPXclHr8BxNHO+SVDoJ/UoS3tOvIGkh+lzzDAUAk+4ZHg+tMpHgDbu8GkjGBz7MKerYJpZok7+NmKvYbnT11xmaCWU6nsAGbWPQ== 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=B6WpdI5i71rOMmERZbQkpSQAatAS/YiIACqsc1cy2gs=; b=S4JEGsu21DZAhKQzKmse/29GFXrpfC9rskcqYAXWbxuKk0q6pG6kvLuCvH73VDRbR5fFBvMhjaNkbbKRFl1OK5smp1Hw/enHAVT6RFFZ5JVwLaRE3Pjs9LdXMz6l393/AMdDtHCUftAFqI9bJfh7hP2IwfnoJXrfJTEO4JzHFity1zAUbeWZI2XzWabOtSsA30wzFMMUjZE+3x3GY2YYviL9zRampEwdCK1lorS1WuZ3izCM8oKj2EX6jcF3/MzO4ezyzDmVjM9Twy/mxgjYk1XBkJpi2eonf5RrAlLqbDMXVUwhl/L18rxNiVze7iHM5UpM8B5I0Z8qDtqV/OY2LA== 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=B6WpdI5i71rOMmERZbQkpSQAatAS/YiIACqsc1cy2gs=; b=Ffaesxc4FPthqmqQvjLiTJmWX8WLJI/WDAY9s6o/sR5h1sQZaMt11BVGjCReIrhNr69aYAHy0tu2T7V1QtwszoWkQ4t0rpN9ifUUZAn4pRAi/rsaCKyZOM4ha6hKD2IGe27zlxKUhleJ+bMbWz5wbEByPTl2PN8gW8SQ6Qq8QdZ+oyvWGOYespudH3r/6lOsf0VqMqZxc2xQK4w+2dwJ9bCI6XFKjy5gGq5h1YskyeEdhwe/Ov+xnqiAvosYKnIfPIlth/2hxNKi9BF0aQcY12r+dQkXUcvYMwKJe96hzijgtG8mPhNH+RBTriL6JAVaUpm9XQez26Ac6ak8LQOXvQ== Received: from AM7EUR06FT055.eop-eur06.prod.protection.outlook.com (2a01:111:e400:fc36::44) by AM7EUR06HT075.eop-eur06.prod.protection.outlook.com (2a01:111:e400:fc36::73) 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:06 +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:06 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:12F5665A435F9D6DA10FC2635FD2953EA4270E3AECBCBB19CF6150EEAF450D75; UpperCasedChecksum:DD52C89D29D9B8BE53F82E41A83697D8834097A9AB7844A312B7A03C149E70A2; SizeAsReceived:7778; 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:06 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Fri, 30 Apr 2021 01:57:11 +0200 Message-ID: X-Mailer: git-send-email 2.27.0 In-Reply-To: References: X-TMN: [mEXfsV2lXDJJX4a4i9QAyu48Kp4bEkTp] 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-39-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; Fri, 30 Apr 2021 00:00:05 +0000 X-MS-PublicTrafficType: Email X-IncomingHeaderCount: 50 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-Correlation-Id: 25172adb-b9f5-4258-7211-08d90b6ae941 X-MS-Exchange-SLBlob-MailProps: gjx25WM8ZNU6XUx7q8EQ5McclV510mdNSQ6zVwN/I7EX+rk7h1h8roCTGdsyjXMArBwxX0cv8ZAYALSTjF4VUdO3YS3J0sWa1YDgyFInh/qTVEcWc3yrDvRxnhFZsFGfgSz/g9wUy6HhfkZmAmEecdPpCeq4zZ5/3vjpXmJGxuIg2meezMu3pmAjP6HTBfDgJxtRnqt43cLWDVOWiwC3w1xVms67kCwCmUwGjUfB6TUVmAyuki4wPGIPPsYNm2JFAN/IuY4d6N4WzHEq0Zgj6/syRhvnoAbng/0EaEgOTm76EJFyo+M5djAAF2vf8g72IbS1tfvstFkHOryFY4d8Qw12i+wBV3HphVDZ1IPCzSGS9LP1HR+3COaR/BSA94JM6lXiGVnW/l9o4UThxGXTDVeR8zEP/MuLP0i4Tk/ne/1seEe43bbNA7q1LDGeKHBd3vdAePz+b/pzNnclaKsAmnxdq+lx3jx7uEKd1MqhHzK2Ft4HNU5ZudKa9RdnvB7h4DysdBZlD9r99TGHuX30GvocviQa4wQUDEQWHNjgM+lwGvdwKdCxrpzEcVCrbVe6c0RKcZcpnf87ioTnNBB4qhhQB1ARhr4hxjRdpgmrQ8YadQmc8eCCvWnqcBPFtw84AyWQUna27MRa31WkE5AqEyxqiAuxtssKRRmb+plsYv+YrOTkD/DLrZEv7YBJGZkGM7OML/DUU03dQL7IshsP34KDaAQBFECE86+W3L0lWv4= X-MS-TrafficTypeDiagnostic: AM7EUR06HT075: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 9xTv81Hy4aYLduRDwJVglewyhaQ6i40TINJihBKOwvAygaUMRfNP8SpT0lNxXvjcsHHri7S44qUnRb3UBQnl6mw7eT8wrr+7i33cfxjVMgC6nNxZHD8/F5qGw3xfMiJduVWBEZ0n3yWss898iZdDnTO1e4Xu5z4lev0jP15718T8Q8CNtzC8p26rePyMw56eOZJmwYDzVnRalrgVHYRP+pcqZHU1ZAq+5Conr3qNKQS4IOYS1DkYE7r7rhNq9g7bHrjy4qAw7XJmaR/kKgqGczfIDN1k772TLTuF7zRXQzmXoiNpji4GHb8P9FuujX27A+/zGgMKQcMBcBhNpzrMdLv3O9XESWFnvk9XsXwZ7RMUPqHI6KdLBSzKo9dQO/RW3B19ppt/T4pNQh5InviBFA== X-MS-Exchange-AntiSpam-MessageData: xr+xLDR3rurmZZTHexOC2xvlJOHD3pOffZ0hMGpIUr3VJQYFylP1QoHhK/ivM7tJ65uJeB8jP8Z0Uay/FBHwsyMSs8M9QpviJoA7qKATtcwWyW1icz4GUBEoomalbm1kXt5oUKmVAbHpDih5kFYd1A== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 25172adb-b9f5-4258-7211-08d90b6ae941 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Apr 2021 00:00:06.0223 (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: AM7EUR06HT075 Subject: [FFmpeg-devel] [PATCH 40/46] avcodec/xfaceenc: 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: kgzFkSGYoFwy 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/xfaceenc.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libavcodec/xfaceenc.c b/libavcodec/xfaceenc.c index 21c7d8f31c..aa9e905965 100644 --- a/libavcodec/xfaceenc.c +++ b/libavcodec/xfaceenc.c @@ -26,6 +26,7 @@ #include "xface.h" #include "avcodec.h" +#include "encode.h" #include "internal.h" #include "libavutil/avassert.h" @@ -195,7 +196,7 @@ static int xface_encode_frame(AVCodecContext *avctx, AVPacket *pkt, intbuf[i++] = r + XFACE_FIRST_PRINT; } - if ((ret = ff_alloc_packet2(avctx, pkt, i+2, 0)) < 0) + if ((ret = ff_get_encode_buffer(avctx, pkt, i + 2, 0)) < 0) return ret; /* revert the number, and close the buffer */ @@ -216,6 +217,7 @@ const AVCodec ff_xface_encoder = { .long_name = NULL_IF_CONFIG_SMALL("X-face image"), .type = AVMEDIA_TYPE_VIDEO, .id = AV_CODEC_ID_XFACE, + .capabilities = AV_CODEC_CAP_DR1, .priv_data_size = sizeof(XFaceContext), .encode2 = xface_encode_frame, .pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_MONOWHITE, AV_PIX_FMT_NONE }, From patchwork Thu Apr 29 23:57:12 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 27524 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a11:4023:0:0:0:0 with SMTP id ky35csp2019446pxb; Thu, 29 Apr 2021 17:04:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxJygqAzw0e4e0/otwNtnlH30pc7n1rmBQ38FX+/pglwl66/U6dp7ZRB2EKxnqnSA0avBwu X-Received: by 2002:a17:906:af73:: with SMTP id os19mr190673ejb.218.1619741055294; Thu, 29 Apr 2021 17:04:15 -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 gt9si1471099ejc.524.2021.04.29.17.04.06; Thu, 29 Apr 2021 17:04:15 -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="AXjIK/kJ"; 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 545D368A4CB; Fri, 30 Apr 2021 03:00:10 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR06-DB8-obe.outbound.protection.outlook.com (mail-db8eur06olkn2024.outbound.protection.outlook.com [40.92.51.24]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id BDDA968A4A3 for ; Fri, 30 Apr 2021 03:00:08 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ITakjYrE11MloqNfcza9p2x47VJZ4/j5YXqYZKGZeKDszbeq/1GcTjGtwQ/wAZ17oh5WQvLO9E1a9HLmlMszBpVRKl14yfh39MCTE5HVd2SgAMc+xs+QwJvPP7K8z0jFv7mi9rFWhMLwbOs0dmMekYOhA/jQvaRCej3glSDEnpgFxI4PesX7TBFfZiQj7DNT5tVMXQVEuNI6rEbgjqLMSFYnwZ2W3Ii4dKJj6QB54RU2kL+LDeuw1iiCwalq8y5PmVZbM6qfnxYdbxIp0MSYKnHhE0D9RJr11lWRcTQZPRqJPzShJ+iVb7oQTT/3CVXQIq4rCMRfPN8q9ileZ1AItQ== 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=H7KGIq//cAVwi/5JL7kjrbNG0/50fD7F0GdYVxILZB4=; b=NskYXI+HcYPmUt2mEqn6UQrEppNGNmfZ1RRsscj9T6t74NBlQYx1XpSMAnN4s37zwT3g1MWcAm/IsqF0S7TkYg1n6tH8FbsU2Bzv7AUx5TYFVdIPefnf1NxEvkFhGpIjdJ9R5HTwnoNwcTuhIabntMDcJ7bVYO0/WFilAGg4TF1a4AGtd9hHboeV1NxRVTrgaEzG0CUCssipMY5XTRIk5f/xWSwhBUPioRNDER9TPS16Ly7D7PkpzcR++9SfZ/soKMgwZOLYJ6DtumpDGJo5TtYZm4b/CJLd8JKm42TUwZ+FAqQdGYt71DAQyFzh3hf4dypW02Ih9c31xm+/ynHcVw== 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=H7KGIq//cAVwi/5JL7kjrbNG0/50fD7F0GdYVxILZB4=; b=AXjIK/kJSq8BMxCxndYcEa9thQMIsCON8d7RmhbUN7lsM94HxmdMNls8iYhrctHFqQc/Lgf2tjubVlePu0zVt/kSydoulljp7P1ORpUl2ZkWw7wWzgXB6fjDqUsxGBZMJE0f9SdDVmDp+93nC5po6yaJq9OvFNoeJwlb7o0AJj67trC3z7tQvwds1ujgKxTdXuLMXMcTWakJX6QqQZeE/9Nll60UYLdHplD7ci7EktnpGV2ipKYCcy+N1chicXKivl48nMo6BAM6zC6qmXz8iWFVUScYmWG0+7RT13RFQh5ELFdWIP02bILXkynn635Rz4YdoSpMN8nSxWK5mSADpg== Received: from AM7EUR06FT055.eop-eur06.prod.protection.outlook.com (2a01:111:e400:fc36::45) by AM7EUR06HT179.eop-eur06.prod.protection.outlook.com (2a01:111:e400:fc36::215) 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:07 +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:07 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:261E739A9BD74689F457D63B521EDEBD065115B9EA3B9DD863EBC5715FD3AFF1; UpperCasedChecksum:F930BAE40909D2F87A537D64ECBE7D8A98E0BFB827774F1E7AEA1E9EDE785F1E; SizeAsReceived:7749; 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:07 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Fri, 30 Apr 2021 01:57:12 +0200 Message-ID: X-Mailer: git-send-email 2.27.0 In-Reply-To: References: X-TMN: [PY98Op60fObSyGYqKYWWQtIRnwqBSv9j] 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-40-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; Fri, 30 Apr 2021 00:00:06 +0000 X-MS-PublicTrafficType: Email X-IncomingHeaderCount: 50 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-Correlation-Id: 640f1ddf-cd86-4775-5407-08d90b6aea23 X-MS-Exchange-SLBlob-MailProps: gjx25WM8ZNU6XUx7q8EQ5McclV510mdN6KDHjc5pS3to8zzine/Vl3+XwWY6Wk6teC8TYnEm7OQXYDTec8X8SjxdwOgokGaeoqiexrPG1IQMk8wOIZ7nWPe2F6bokjSjcz9ulLzVDbxzC0eeomfrs/gfAOZKnGlKXB/6OMw5bK9fvNi5cLzNS6AttiPBMkB/+shVjqV0eX+mRjlnuKw01CbBwY+0m4epYLPFBGkvT8OCCi5OAju3blILwNtEu/MM/SpdFt4/XU9idg9l7pE86Z2hiNJpCNmEJBxloJn9UXnXgDVj+N8Ewtelnuh3e5lkCFNSEzhObEWQYcPQy8A3o9YCjnyEe5omGLs3stur5XHY5hkRYVcm3M3NwAyiw32VpSzItzOeX8AMbgby5WLsUJuHxpueVw42AsERUVeyb87jZi6TArhu88J4/BxbUo1C388BOfwguKSWN9QRaaqePm7ArNsGgTqHwwxJXkdStPfv8yTJqFao18KAIaAkxn+uo6zjUrpUyr7yeRP3ugeEMj8GVUk7E7pK7Y2TNFXqYKmrqY2XLJ5yohXeEXWuDg6FAY8w5vlnMU23zz7zjyCqdz7CXMoFjCxh2XTE+ac9C+dLAkyNqvmJDe3BBbMfJsknZQYVFqje7TPrTr+tNK07cCVPw5ZTEHolI18PKfxjBRgPEzwNSYX7bdcAh/XrFSpb8UwRkODM7+tMT2G29g5fFSOXvisgHFgEAchD0HObSlM= X-MS-TrafficTypeDiagnostic: AM7EUR06HT179: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: yBxRnZCDo8659ZQlxDQWpY8wfouoc4PVCc8ThvRhgfzT1F22rGjykqit+nn5ByBJfWXMMQkcQuXGUSFhEBe2ashgZ1U+gF3OlE9T6QJxlnSIAkMt/aFGIN0dykOTnbhh+denfdhLEY2IcYtcrzqJ1SYwYeSje4U0ppAYdp2jyMfjjdij6OZLrDYVPFA8HT88PMP9ot1qER3hjW/WHvP3n+UwqgNRYGdpGHUdR/uuiNbr90E8oZXfhWuyVPtlS3R6HAVPI8WHHgpJS/9/+5gW8PBC4YswYs7wf8RLZ+RntmvfjZ3IwG+Vl28C2WdHJhMcap8OUgUjKKOBOVLJ8oVVtrw9VbQKvLhmavYElYeR00DY66s9a03gWSiTkdChhuKE X-MS-Exchange-AntiSpam-MessageData: C8SEhujllI6caZ1HSC8n2t/tKpemXZ1cABO3yR4UXJTehArqDsoCZnHD5dJBsWX2XjOPRvg5JtB6yTUh0jcm/OqLWAKuxLkP5p9mI0YB5jmwM02sdpoWHRGnDd4bONDzOvARmCcjfC3L/iNuxZL0mA== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 640f1ddf-cd86-4775-5407-08d90b6aea23 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Apr 2021 00:00:07.4227 (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: AM7EUR06HT179 Subject: [FFmpeg-devel] [PATCH 41/46] avcodec/vc2enc: 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: CqiC5YD96I71 Trivial for an encoder that has a very good estimate of the size of the output packet in advance. Signed-off-by: Andreas Rheinhardt --- libavcodec/vc2enc.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libavcodec/vc2enc.c b/libavcodec/vc2enc.c index ca5cebb742..2de6d4b17a 100644 --- a/libavcodec/vc2enc.c +++ b/libavcodec/vc2enc.c @@ -22,6 +22,7 @@ #include "libavutil/pixdesc.h" #include "libavutil/opt.h" #include "dirac.h" +#include "encode.h" #include "put_bits.h" #include "internal.h" #include "version.h" @@ -914,9 +915,8 @@ static int encode_frame(VC2EncContext *s, AVPacket *avpkt, const AVFrame *frame, max_frame_bytes = header_size + calc_slice_sizes(s); if (field < 2) { - ret = ff_alloc_packet2(s->avctx, avpkt, - max_frame_bytes << s->interlaced, - max_frame_bytes << s->interlaced); + ret = ff_get_encode_buffer(s->avctx, avpkt, + max_frame_bytes << s->interlaced, 0); if (ret) { av_log(s->avctx, AV_LOG_ERROR, "Error getting output packet.\n"); return ret; @@ -1231,10 +1231,10 @@ const AVCodec ff_vc2_encoder = { .long_name = NULL_IF_CONFIG_SMALL("SMPTE VC-2"), .type = AVMEDIA_TYPE_VIDEO, .id = AV_CODEC_ID_DIRAC, + .capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_SLICE_THREADS, .priv_data_size = sizeof(VC2EncContext), .init = vc2_encode_init, .close = vc2_encode_end, - .capabilities = AV_CODEC_CAP_SLICE_THREADS, .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE, .encode2 = vc2_encode_frame, .priv_class = &vc2enc_class, From patchwork Thu Apr 29 23:57:13 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 27511 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a11:4023:0:0:0:0 with SMTP id ky35csp2019623pxb; Thu, 29 Apr 2021 17:04:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz1njN4+ljhtf431HrlJ+YM86d1mw+TWI+kk3TTTLCZFVv/9A7xbsamDBbzVoTPBCAWsI03 X-Received: by 2002:aa7:d6c6:: with SMTP id x6mr2491700edr.193.1619741066062; Thu, 29 Apr 2021 17:04:26 -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 hp35si1834977ejc.361.2021.04.29.17.04.16; Thu, 29 Apr 2021 17:04:26 -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="CIWuTcx/"; 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 35A0F68A4DF; Fri, 30 Apr 2021 03:00:12 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR06-DB8-obe.outbound.protection.outlook.com (mail-db8eur06olkn2078.outbound.protection.outlook.com [40.92.51.78]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 5B38768A484 for ; Fri, 30 Apr 2021 03:00:10 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JxW1wd7rdQvcTEwmrYl5/U1xNk/mUpX3fYSDQHMXbkGQpx3Fhd2H0b6R++gayC9SLSWTh+Feq7ESgFna9USxw+G+WXU4tJXwmMyT+i9r6MFxmt7KIzjrtLUbY4EdCLP2H49Xxdt6ULI0AuO9O5eoojJY5TeUHSQ+eGIPQB5L6sfAdkJjRA9eSyHEONlKu5kZAuwRCVBxEGiLSo+Im4w9P/w2fxKzZ3260xF5EqYBpP4FwpHlak8odVWKdyjRzU+Owact8medXXqOgpJC7bpLmmBnu3qOD55xwYGwxabl+Kzbwy5qqkPewuEdr2KemrGH36dO0ojuzol+eMYo4EsZfQ== 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=1JD0dGDeBzSWBgTmpm1/W6Vvgup0d62DSMEYOSsCe/Q=; b=l5iqXDWUspJF51AE+lOBt3n165LWgfya8Pw6GFwIXXytZGo2Uaska3+qfzHDrCzkTBrlzKDQ0tg5JSb5s1lzLyEe3DHsQkONg0EZjIyC3jRw3NfmSR19bZ+u/6j9yqEx3LyitOcXcBqpckn3DNxRjfOAyd9j0OL7WWyK2N9dtTlUQMh8iPy9GwLoW+CC78iZAISSGMmNlHXjpaUdfllDDHLisAqIoRkK7w2tPw/EQD1EsquKQi54EpoftZmKRMkow8nbGIESXRYfg8dyILAs9S1o60d7w+IqUasQdFvj2xUuLq5guhchuws4LNcKyAPlzcY7PJt63mCLu/SEssn2yg== 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=1JD0dGDeBzSWBgTmpm1/W6Vvgup0d62DSMEYOSsCe/Q=; b=CIWuTcx/sSuVG+fP4jPnZxKdgWPylg2fG62OQMEjFCQZ3hjT6PbKd/POX39gTEDBxFE1f2b9E65mBwowQhWrdkNAmqjshISFzC5iz9gvJkZ5F3aPde1JEYlMhPh9Zweitif58peCPFyk1SOm8m8hnQHsne1b5nx183jglAGwy+HXcabfdAee/Xr5WB6L0ZlLClKJRA2mlC+6hm/pB3Xp+xCnH0jMfK0xzKFL8ELjOX59sdvaH2j3deBrO4ZfJoNpYAa/PNur6906kWZrRDDjTPdnBUVVZbjwfBXWgAzlp628v7vpx7laoFRuFK7L/9j6wa7deOsYNpLnVH8vTICJZg== Received: from AM7EUR06FT057.eop-eur06.prod.protection.outlook.com (2a01:111:e400:fc36::4e) by AM7EUR06HT062.eop-eur06.prod.protection.outlook.com (2a01:111:e400:fc36::285) 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:09 +0000 Received: from HE1PR0301MB2154.eurprd03.prod.outlook.com (2a01:111:e400:fc36::4f) by AM7EUR06FT057.mail.protection.outlook.com (2a01:111:e400:fc36::445) 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:09 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:4162183377A629F5C8C474E10561AF9B4653FCEDD73410B2269FDEF658A14E01; UpperCasedChecksum:BDD41BDD690C71D0D229EE0658A040EF25A71CC0364583E498780FDDC57C182A; SizeAsReceived:7778; 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:08 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Fri, 30 Apr 2021 01:57:13 +0200 Message-ID: X-Mailer: git-send-email 2.27.0 In-Reply-To: References: X-TMN: [M1FEcQmV2roAXiauAlUiMqFmHBG6wKkO] 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-41-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; Fri, 30 Apr 2021 00:00:08 +0000 X-MS-PublicTrafficType: Email X-IncomingHeaderCount: 50 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-Correlation-Id: acfc0be7-2f1f-4160-42e2-08d90b6aeb08 X-MS-Exchange-SLBlob-MailProps: q+fD6XS3/UIO6YRda03MtHguxZve2k0PFRWwNVam2X8mGv8oS+krznAv4NqLV0HWO1oVe17A2AghLp/DC6KWlD5L+tFuVjeu9nK0W6Zztvnom5vJqQfI/661y17ktn28YsaTkTNJiP/Cq2nSOuH8XoZ6HQXkELG2kEwDiiZgEx4We0M+6fxYj2LupyM3kr0YYCNnBFJZGMBpYqAD2s5tkG2577ZmROBrUWG7DiugV7khj5LS3qroO90syfhZQTi9lXGOL7rt2nqnGpm56zMfCZrDNRn260d42FhcETLZHPKL1OP7uh3z+LEO0rqTJJfwT6ij4p4I+nGW4EhmnTYn476/6Yv3xFzH2AEuXuLavWjsLAYlOaeWvriwsde+3Sr4b3G+78PkA+YRBC1jFOQ9RKJJ9GJexASRB0LnGbe4jEnNn/UtrpP57psQv0xlNOmOAy3Y+OORf5MqNpftOuHUpCsec6gpMeQ3Ak8pkxFp+x/HxNuu7RepgtsEK9Yg3GflsljEpFoNXZYOsyciOy/pTM/X+X6LNClLHJOn2wvFMroxQex8ZmWjmcG5It0yGgIR0mB6JpCCqYOS5C5Cr6ZNIZDf8iTNVpuo5a1CLr2A1p40295qLwYaE1i/qzT7mHUmxIr53cJsnxXWdhQUmER/ZNOVxphIGAg8pD7Cztx8balUZYOFiPlEOte73P4muwTdCJZ36V8SxcDT/vrOn4HWTw== X-MS-TrafficTypeDiagnostic: AM7EUR06HT062: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: IELl3voasW5TdME9PQtcBTAIBXKHbmcmFaKDoqAFP0PAk6Fz94EmTsA4B0uwcydEGhAcDOt4/efPmi0s1eYOfUuhhrIWNPmOOHw8mAiYShkSmR1A4ZIp9UfSBdwg4+BcuA/795ZP0/14GunH5VvaFriqv6goSYxBcyE8p8qJp/X96KQ2VXFA+0SgVmI3dKaim8ESBL22le7r1gzaXfFYlVP9SxPkp0tjqXzgCYBnFIwNkj95NuBkW59hvAzCQdyS/+5HAp4QK8gTxWnDUQKLV77uOc92MNRAs7Bjm5Bzi119NMG3rlbwoU78bcHnyvwV+GBYjp5Hv5hGnezD4ce8NRUNO+rZd2+iZxNOl6kXhtps3AM6jPQinJmTsMv7ZZ7fy7HiTkGd5q3Ehk6NbsNH1w== X-MS-Exchange-AntiSpam-MessageData: ewcStlpGchZPmkYsiDv1ktllZKWkXUX9XzFQ3FYeGts1MdyTQhOgdiN8YTgFfKK5ggQ4pblNZqXbXqqsAnvTK1rfwWoMqkDYLgH38YdFpvXRgcw4ig2eoL12YYgnd7F41Gdt3Xpu9ICaWHuIVKYwRA== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: acfc0be7-2f1f-4160-42e2-08d90b6aeb08 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Apr 2021 00:00:08.8961 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-AuthSource: AM7EUR06FT057.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: AM7EUR06HT062 Subject: [FFmpeg-devel] [PATCH 42/46] avcodec/videotoolboxenc: 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: QlWnET+j+e6e Here the packet size is known before allocating the packet because the encoder provides said information (and works with internal buffers itself), so one 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 --- This is completely untested (but actually also trivial). I hope someone can actually test it. libavcodec/videotoolboxenc.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/libavcodec/videotoolboxenc.c b/libavcodec/videotoolboxenc.c index e576ff7d7e..f3e66c9e06 100644 --- a/libavcodec/videotoolboxenc.c +++ b/libavcodec/videotoolboxenc.c @@ -32,6 +32,7 @@ #include "internal.h" #include #include "atsc_a53.h" +#include "encode.h" #include "h264.h" #include "h264_sei.h" #include @@ -1974,7 +1975,7 @@ static int vtenc_cm_to_avpacket( sei_nalu_size + nalu_count * ((int)sizeof(start_code) - (int)length_code_size); - status = ff_alloc_packet2(avctx, pkt, out_buf_size, out_buf_size); + status = ff_get_encode_buffer(avctx, pkt, out_buf_size, 0); if (status < 0) return status; @@ -2017,7 +2018,6 @@ static int vtenc_cm_to_avpacket( time_base_num = avctx->time_base.num; pkt->pts = pts.value / time_base_num; pkt->dts = dts.value / time_base_num - dts_delta; - pkt->size = out_buf_size; return 0; } @@ -2664,12 +2664,12 @@ const AVCodec ff_h264_videotoolbox_encoder = { .long_name = NULL_IF_CONFIG_SMALL("VideoToolbox H.264 Encoder"), .type = AVMEDIA_TYPE_VIDEO, .id = AV_CODEC_ID_H264, + .capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY, .priv_data_size = sizeof(VTEncContext), .pix_fmts = avc_pix_fmts, .init = vtenc_init, .encode2 = vtenc_frame, .close = vtenc_close, - .capabilities = AV_CODEC_CAP_DELAY, .priv_class = &h264_videotoolbox_class, .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE | FF_CODEC_CAP_INIT_CLEANUP, @@ -2698,12 +2698,13 @@ const AVCodec ff_hevc_videotoolbox_encoder = { .long_name = NULL_IF_CONFIG_SMALL("VideoToolbox H.265 Encoder"), .type = AVMEDIA_TYPE_VIDEO, .id = AV_CODEC_ID_HEVC, + .capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY | + AV_CODEC_CAP_HARDWARE, .priv_data_size = sizeof(VTEncContext), .pix_fmts = hevc_pix_fmts, .init = vtenc_init, .encode2 = vtenc_frame, .close = vtenc_close, - .capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_HARDWARE, .priv_class = &hevc_videotoolbox_class, .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE | FF_CODEC_CAP_INIT_CLEANUP, From patchwork Thu Apr 29 23:57: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: 27523 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a11:4023:0:0:0:0 with SMTP id ky35csp2019794pxb; Thu, 29 Apr 2021 17:04:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxLnq+APidAvWF1JhAZnH2idDjiNFfObF4wrJIFzpD1GOpL6u53aYtieIfXUUxSyzlv8Lwl X-Received: by 2002:aa7:c7cc:: with SMTP id o12mr2567787eds.291.1619741077969; Thu, 29 Apr 2021 17:04:37 -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 g19si119901edu.85.2021.04.29.17.04.28; Thu, 29 Apr 2021 17:04:37 -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=C1HmUmb8; 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 57C9068A46F; Fri, 30 Apr 2021 03:00:15 +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-vi1eur06olkn2020.outbound.protection.outlook.com [40.92.17.20]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 0287868A4C5 for ; Fri, 30 Apr 2021 03:00:12 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=AzhLeUYK1aBObsRXoJe6D/H1aKyYSaV1jVHd0UMidllZNinFBpSJPBqRSLzjuw9MR1xCet7mHiFv27ZPrZWTJcZmCgeX7Q/DrxZKVWoITb4HP5tg1U/w79Pz0qhZI5MnKo+BS5SUsBv4v4/LxJqjCAQxtXq0uArhdInujIZwh1EfVEPSPvEbRxrTqdlgoFGz60a1i4WgQ7ixqbKT2jIxqSQIP0ds8VVjZHwXvoLMDhR3oXFRYcAl5MwxTp3zLoqlvU10cwydazrIBd5gId0eNNqrVfbZwH9YxJGSGIEjNHk/ZkgzxNLnwrvHAPg+mIU8BHDr9gVrLorBB9m1LzrYfA== 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=rVL9f7VK+ypDe1EzXBit/g6xErUuZIUYIac3YlUlxZ8=; b=V4B5jeY0VLtdG6ktPo9dE+8WsgMItYXiEvpzXgtYR7fAOdw8tIp8560LFITG3uXb6dQaPyxu8mAVDHNZVS/G675h8thTMP9u8A3ZmuyxODYeKvCCHh+VBkh8+/gTNIMSeEQJ/0YmKP9vZYs18ZrJFtb9WiPfxN53NTWfO5FUVnHQ0XH9ftEv7g60y75ri1jKN08R2Mt/HKkOJLbVC8eoNoTtKDLKDRhmk9e5CTfNZ3CdZ+zAHjWgZ4DY6g2BgDxREOJaYOH5ovc0HLMh+4MslB76mp+f2FSk9qFxh7HjOnvJQJ6+aSD+woJCnJuo4uwrTwSnrMNN+Xd5Dp/3OHWOPA== 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=rVL9f7VK+ypDe1EzXBit/g6xErUuZIUYIac3YlUlxZ8=; b=C1HmUmb8WVKSr7c/rZtSkaMSeoRQpVUKhY9ZMsp6h7ZqaL3wsDz2oFJaAsMKto7Qq7zkFOJi0d9jHJd3X04202Mav/cUhrUZkFLwWpvB46OmFSMtym64D3KX7zoVlXdOT/Xg44e/HCh4WNYZJjSwWAIyZ+71ksw1s1rJsqpQTXXacbxcD66tmPShMObwjBonS2IVWlyV02fr38Q7RXmGnoVcZC9svoS0pOaxwvpjgnnRJzsHQ1SIo+3uE1T1ZYZ2F1eSQo1RCp5VLkIhxD2tgm+lFMfMIpeJ5CfdnE7ux0IR4Cu5tziBQHwFkKq6cixWAeUXm3QN4Or/CFx5nlz3cA== Received: from AM7EUR06FT057.eop-eur06.prod.protection.outlook.com (2a01:111:e400:fc36::52) by AM7EUR06HT256.eop-eur06.prod.protection.outlook.com (2a01:111:e400:fc36::280) 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:12 +0000 Received: from HE1PR0301MB2154.eurprd03.prod.outlook.com (2a01:111:e400:fc36::4f) by AM7EUR06FT057.mail.protection.outlook.com (2a01:111:e400:fc36::445) 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:11 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:3DB166ECFA62E1AFD6AC6627CCD49E0114BB99AEFEA0E0D94DA5F1891FE6491E; UpperCasedChecksum:0C94D20BE1374906423FA411B07B7B9756B572558B8DA8C3B5BA2F29DA084185; SizeAsReceived:7765; 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:11 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Fri, 30 Apr 2021 01:57:14 +0200 Message-ID: X-Mailer: git-send-email 2.27.0 In-Reply-To: References: X-TMN: [TNuZjCWRjrgA3/CuwWz9u8wIXxDVg/M2] 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-42-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; Fri, 30 Apr 2021 00:00:11 +0000 X-MS-PublicTrafficType: Email X-IncomingHeaderCount: 50 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-Correlation-Id: 3d2bc775-88fd-4b1b-9a87-08d90b6aecc7 X-MS-Exchange-SLBlob-MailProps: gjx25WM8ZNU6XUx7q8EQ5McclV510mdNSQ6zVwN/I7HB/GmqUZWlwWszcNHnb+WvjPbV+P98tA79l3Xw9ieZsX+ysZO7FR7BWeipSnroLU5S/1yi8HSgUwMuWK+9UOhbgh8bVOppDWS5h701iA4rgWTwaoFAXg7frgjKaBFczDQPzeX04RQl2cSI7xJnhABP2qskbaxE7WxU3bl16lWwol6QK/kOn2qXAECjahyOmFm7DydVlsGJH8VMSEmg9GQjVsiyVeDW+iG00EWcKo/Y4s5nyziisN/oo+tVxcXGpwqczrW/n2EW9Vr7GvCnA8vk1gf4xJ1pcyg2GqeiLSaenxda8Fv2jWHBYUFDUXBxbSDJvnTfnOsV4wSNTMoAekGszhP8gmEOS2+WYv10TrgIEI/w/8cEIkLZ/gGaMksQSa5L0t4vKOYwuR2MOFMORShdB0q40Nxi4e2SGLKG0nbggUIPtXwAZQIVL4Q6b8qGa4tJDsy3SvAsF6I1kruIT/J4eioU61ZHrh/SOyUPuH98d0+zB4cCXu99cS0LS6zISqY91QeMkF4V8R7KHVuFuwvBWMJiqeCXjSL43wV3OLqFUojt2K0EIcaBi1GwNaQ+a7obmfRFaD+3fN2d7ndRAp136Koh4aynlTmfFxrqdYv9q26ar1q5aX5Q2OuMFy5Bz/Wzw+vVTkurGaqz3y0pHW5ruhLWnev+NEfKO0hx6Icc9XBv+oFHgHAo25wmGT7FekU= X-MS-TrafficTypeDiagnostic: AM7EUR06HT256: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: azbXiSK5CG0jWDf8DicOe0wijdPth5c3+Ht5rPXmAS5+ojEJHyYldub5tFtVE7G0QreJLQp1iBKJF5U5CT1y+z8OY8Z1C/acO6kFXKYRKyUSP+OO8gg5GNCR0Bc5efJv/JtQ8dZMFwp40cmGAc6iUgp4M/AxGVYEQiCifCRFzjT2dmZoZgSM1UxRdM/JuYALqe7wDHup6YwgfGm/+2s3VS7ZK2eeKk3jH1RpbOmleBsmAGXoklqr0U8T6HPONHWFeF0seppUv2Jk5LOxjoAZE1rSyHV3EdUF6LWwNK4itKrFlkbJ5ckGG3D7mk4C3HkcT0y2BoxbYd63R5PXGIQXA59EhFD7/6h1dcZoCdJGQztF1YaNQ2YguGq/h3h6FCjvjiTTt+N4ceXFEZ4b1VEqhQ== X-MS-Exchange-AntiSpam-MessageData: 1NicjihJrT5Q6AjL7Fcpe7EdXVdgxSWgDFjTn8TGomnXGMoZKEomuQrpMNUzlSuLlitOu4NvrsbOiKlSiyx3xvUaZfkNL3GEbpZ5nG+QL3iqjMCNY7U+KoOXFQbyCi712s0TjM4XFYe5pSzgWOZTHg== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3d2bc775-88fd-4b1b-9a87-08d90b6aecc7 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Apr 2021 00:00:11.9347 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-AuthSource: AM7EUR06FT057.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: AM7EUR06HT256 Subject: [FFmpeg-devel] [PATCH 43/46] avcodec/xwdenc: 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: MQ6bKBuMbUlB 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/xwdenc.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libavcodec/xwdenc.c b/libavcodec/xwdenc.c index 8eec700e9d..d7d18f913c 100644 --- a/libavcodec/xwdenc.c +++ b/libavcodec/xwdenc.c @@ -24,6 +24,7 @@ #include "libavutil/pixdesc.h" #include "avcodec.h" #include "bytestream.h" +#include "encode.h" #include "internal.h" #include "xwd.h" @@ -147,7 +148,7 @@ static int xwd_encode_frame(AVCodecContext *avctx, AVPacket *pkt, header_size = XWD_HEADER_SIZE + WINDOW_NAME_SIZE; out_size = header_size + ncolors * XWD_CMAP_SIZE + avctx->height * lsize; - if ((ret = ff_alloc_packet2(avctx, pkt, out_size, 0)) < 0) + if ((ret = ff_get_encode_buffer(avctx, pkt, out_size, 0)) < 0) return ret; buf = pkt->data; @@ -220,6 +221,7 @@ const AVCodec ff_xwd_encoder = { .long_name = NULL_IF_CONFIG_SMALL("XWD (X Window Dump) image"), .type = AVMEDIA_TYPE_VIDEO, .id = AV_CODEC_ID_XWD, + .capabilities = AV_CODEC_CAP_DR1, .encode2 = xwd_encode_frame, .pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_BGRA, AV_PIX_FMT_RGBA, From patchwork Thu Apr 29 23:57:15 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 27509 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a11:4023:0:0:0:0 with SMTP id ky35csp2019937pxb; Thu, 29 Apr 2021 17:04:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwAytPO2df4uV6oYdSE6BzkkP1DDxuOfkz/9sdlCZx/5B66I1HvGmUxaGZz+xBVulWAci5H X-Received: by 2002:a17:907:961d:: with SMTP id gb29mr1064079ejc.381.1619741086673; Thu, 29 Apr 2021 17:04:46 -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 gn22si1431142ejc.426.2021.04.29.17.04.39; Thu, 29 Apr 2021 17:04:46 -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=Fs5BhkT7; 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 3C37D68A52A; Fri, 30 Apr 2021 03:00:18 +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-vi1eur06olkn2025.outbound.protection.outlook.com [40.92.17.25]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 5242668A4EC for ; Fri, 30 Apr 2021 03:00:14 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=n9UPp4ksc2mdDHzTOFBAJMoYUE3Rx8YLGYKM9LSD5ZymgvAGFtaA1J/sPzz/AUPF/ZETDRHj4WI3o6hKHd6XmNwSb7GaAdRei1zWM29FzGILxHFdj5BeDKUZyjOHW+RGvySmCkaVEJtVjJpS+TnccsqVuwc1/nZk8FNBqfSt3rC0uhz33g2ZkrDUMg7ViULd8LTHE/Tuip+FA84mSd0VI50w2HN1SVM/kw+0BktVE9d8uf165BGY9LOvH+ZVswPB/LD0VM1ZGx7AkQtUfDuqWYckiMbN8wBWF5ycRduISIJpazfx3/eFDBBdfx1mlMp2Rgk7ighQ9rhIPoH4P+j5XQ== 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=y7oD5BGY7BS7Spc7NgFhndOSKbjvdPj7J+ppe7lw4uQ=; b=DDZAJ0obRoKMK95Upu8MXNK/aQZ82onvvsV4Z9v+ykCPvVbdec78pCCBoHtEgQ7SGzxNEKkNTGSh5VgFIUU2Xvy6//75Ej84TFUynzUhbYE8ubDE9x0/3QsOWVgi306RauZjIZtcoVV14F5wGHDl9AUmBKbGEMOPgmOwAhD1eVoCsmV+aLOsIDoQcJeQXptS025R3UQpSOGxRsceH2aQwSqDManSuf7KVnnF/Z4YyjFbEMg2OJtpAbAVsV3G35P3XlW1hDTO4x2gyv9N9gFkXtijvUs+gG9jbjSNANaPGMVO4sq7hDxCs/O0d9yq9gyTg5NIyKsumT0MzgiFgiMrvg== 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=y7oD5BGY7BS7Spc7NgFhndOSKbjvdPj7J+ppe7lw4uQ=; b=Fs5BhkT71wctTCNhxgdjPj2oRJPL3Sbb17y96d45KbIkeUPms+wEiPOa1dKz6zad12HXJVNIEBFJgBDYrmwGQc7pfb/Hn/QaE8qENhlLsYvI23RsADwViEeTHTXZc8wc45tsaLOo9TD+7E+6JjzPzQfZGsgpBzPte/+AMIQc+e4zIhtYhqCIjpBn15f980xooGrwyNBZjZAzZUNzlDkR5rw5v39BEfCAWWdnVKW05r4yJAgJFVa3dWM955RBkIDZ5Rs7iOn+gz6zMf/UoBkazwmEm1x0SyGUQb0J4D/CIPvJpPfOYqIvXgjgrnZpVORy3PBamux8w4ul5UG8nNwSVw== Received: from AM7EUR06FT057.eop-eur06.prod.protection.outlook.com (2a01:111:e400:fc36::40) by AM7EUR06HT225.eop-eur06.prod.protection.outlook.com (2a01:111:e400:fc36::507) 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:13 +0000 Received: from HE1PR0301MB2154.eurprd03.prod.outlook.com (2a01:111:e400:fc36::4f) by AM7EUR06FT057.mail.protection.outlook.com (2a01:111:e400:fc36::445) 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:13 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:0C87990FC23C2F4DC26BB8EFBD99E1AFC0B500DD08B6F8F004F9CEA62F1383EF; UpperCasedChecksum:46545AE98471371307B7523CDCA65E40B711FDBF26F7882FD1A9425CA9665F0B; 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:13 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Fri, 30 Apr 2021 01:57:15 +0200 Message-ID: X-Mailer: git-send-email 2.27.0 In-Reply-To: References: X-TMN: [RsMtnrbfG8Opaxz6Hi9HZIqlCt9BMwx/] 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-43-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; Fri, 30 Apr 2021 00:00:12 +0000 X-MS-PublicTrafficType: Email X-IncomingHeaderCount: 50 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-Correlation-Id: 5fb304d4-ccee-4140-72fa-08d90b6aedbf X-MS-Exchange-SLBlob-MailProps: S/btQ8cKWiQnJqnaHo6w7XTEhYoMxTOUqqC1aAam4by48Ty4c++T58WxgQac8GVsnJJamfQbDspX4PpXx24UwHsGcG/pkHUyf0kR5YwajV8uzTMCJJQYdiQ9dxmjGMxqOGI5PR8t+DeiAWql7R3l4Jd59zddvEsdkBpIgA496gAi6JuVsGQOlxLJQvb5fjhJlwoNrrvhE/DyRXdRR9HGhIc1/lUD1v5xTl/Ov+jgRQ6tN/SNyPrq4OAP6hobss7grfwMWh5sm9Sb7u3vILTMPbSkpD5+DGJFw8xZAje8FSrdAYmI55bd+pPyeguhq1t6mXS8KoH6PG86N76galBign8/4amMGrhLj/TnfAuqUe13+wVijYB8NGrMJ0mQsbnltiwSMwNHn+apHCDpd/I8u7yqTn7eipigf8Du8d6luFDGBDPDMFqqwicP5MVaWqrpC0U824d7mMMNsu6HOZZNC4bzV5OAEz8xSDdpW9RuYUz/NYPuEp9+zubOlUaiQIYjb0ig+DtQQEy9VcBvwW7jJ9FfIaeC3tl2grFionGECCujFBgdBrhIKnETLB8LOjf1/GWKmzjc9SCtUZJouCS7ednOh7VhoncfZG7qhXqu6fYl9ALukHBb7RMozaXJuOwLZzlZWOim8AQg2/EerYyPB96kIrqARPV1NWRB7i8GWo+o+GTjWeaNQu4VueNd3uSejKTPXQyajjrJtl5xVbYFOAPeZqFOmUC5JhVF30oOOx+Ft6p8hjd3B52RsB2IV0MmN16vAZOBD3M= X-MS-TrafficTypeDiagnostic: AM7EUR06HT225: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: oUBLc5TWMy8+mO8QaFW0yl2kAlwW1dJxzpMgD1Ugy5r9Y/1b6yTNV9eaWb3bTrDA0OAbJkxjECbhYUDEc0hjotelgUX4sxgVuWeMHf28Krc+r1+rO3uaXL/TyBgPXrqhsvgGsy5vmj1xjcbtynuSnR9CKA0otxD7/hpWNXKfTBx0JPo5x82KHOOgaQBNK6gommZco7qNy3dChxp/a9KlLpNMdqoWX0kw0J1kx5YV8/1Ltd/SD/RUCIDCZrk+rCMisWZKQSKOieeJdQMCzvPgHq1v+HkbvkNHbk3ZBqHodtH16mPErS3+ib/kNG7VKgzULgO/kwOmCC10nSn12hMiQ8bThgHYcHkySk+ZWD/sQOKGtnbeAKboV8YS7lQ6Lizb8xJyYVs7kVM890ZwitkMmg== X-MS-Exchange-AntiSpam-MessageData: NdRH/exS3IqA8Be1AegIPE3qtAraiFEKpzehot0aG6+hjdM4BIuBMyZqEpB2g/lKooRZ2FWHjopIs/NwuAVbG6ycAkEn8Sugbu4Dt72/nEQClZJ2O9vKf9SNs7ltq483EIH99lV/pl3Y6DwpY4iiBg== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5fb304d4-ccee-4140-72fa-08d90b6aedbf X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Apr 2021 00:00:13.4421 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-AuthSource: AM7EUR06FT057.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: AM7EUR06HT225 Subject: [FFmpeg-devel] [PATCH 44/46] avcodec/y41penc: 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: qYeQTSJqpFTo 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/y41penc.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libavcodec/y41penc.c b/libavcodec/y41penc.c index e7d639008f..cd4c43b800 100644 --- a/libavcodec/y41penc.c +++ b/libavcodec/y41penc.c @@ -21,6 +21,7 @@ */ #include "avcodec.h" +#include "encode.h" #include "internal.h" static av_cold int y41p_encode_init(AVCodecContext *avctx) @@ -43,7 +44,8 @@ static int y41p_encode_frame(AVCodecContext *avctx, AVPacket *pkt, uint8_t *y, *u, *v; int i, j, ret; - if ((ret = ff_alloc_packet2(avctx, pkt, avctx->width * avctx->height * 1.5, 0)) < 0) + ret = ff_get_encode_buffer(avctx, pkt, avctx->width * avctx->height * 1.5, 0); + if (ret < 0) return ret; dst = pkt->data; @@ -80,6 +82,7 @@ const AVCodec ff_y41p_encoder = { .long_name = NULL_IF_CONFIG_SMALL("Uncompressed YUV 4:1:1 12-bit"), .type = AVMEDIA_TYPE_VIDEO, .id = AV_CODEC_ID_Y41P, + .capabilities = AV_CODEC_CAP_DR1, .init = y41p_encode_init, .encode2 = y41p_encode_frame, .pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_YUV411P, From patchwork Thu Apr 29 23:57:16 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 27529 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a11:4023:0:0:0:0 with SMTP id ky35csp2019975pxb; Thu, 29 Apr 2021 17:04:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxIxtVQCjmfrbzL3X3ByDJfO6epAxI4o0rnClkyvqbeDK8ZS4HpLAAnGWI/IAC7sUxlM+ey X-Received: by 2002:a17:906:e118:: with SMTP id gj24mr1108565ejb.205.1619741089840; Thu, 29 Apr 2021 17:04:49 -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 fi16si1518971ejb.693.2021.04.29.17.04.49; Thu, 29 Apr 2021 17:04:49 -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=dM8oTF8i; 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 0330068A4DB; Fri, 30 Apr 2021 03:00:19 +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-vi1eur06olkn2056.outbound.protection.outlook.com [40.92.17.56]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 433BF68A4E2 for ; Fri, 30 Apr 2021 03:00:16 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gHS4qcW0TGInsuGOKOt7jbLuwFmH0cg89qGxKt8jgaWH4BlIgCe+M+zIo4wUN0qrGUeM87YkS3lX+h7D9QSzvNdRri2qc5bwW6lyN+Nq3WgUabAV1cuRkhNEbu+al+HFbKHV/KgRVACJK9WsKWeMnTBnWm0tsyR4ubpi2hQZ9lpMCjmyCciHb7egOji6nG1slckyZDTVT3/6bElQVk4h37q9APQkvoLbFw2kZxHd5c/GhEVC9o1OSfKq24ApOJLUJ5WvdVn+EAOjs8dQZdM6kqa+12fb//Sc9QRszcDDqVLnpp1/WWdgyag4muSA+oW3C5epaeT7dhPyrQ4dGgi5XA== 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=/+QNwiPfBmst54afvs2aF8y79hbAl+CozeA23RbTg7g=; b=DXyErKm45zWdjtXpey46kKiQKMxS0qZGwAXB/Ijcjv6xGzlc5xBREoTrNxLZdqP8wAG1qdHnCffEBTYf3FHBRM/H+KmcrJuNyM/dbJ82NXBDVqco5lQrWBdc+b6ClQf11x+JWZoodjVTUF6Tx0x5Utl7E9qXeaktuxwUAdblXLMYU+NVcXUS7Lq1lQx0xL0F8CUisLwWfcVubR8S9xa1gQvte2NSsyIw+EeI6OFchAYGFWU02sg2bbKQmO9IRueqOg0/ejt/FUeJXbhZq9VvOVmtJlIDcShKgcl2e+5EBS7fKdtcxRb3H6CxBKrWq+fC75e/F4yaj1/C453Ky8MWJA== 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=/+QNwiPfBmst54afvs2aF8y79hbAl+CozeA23RbTg7g=; b=dM8oTF8ims4jjChan/TqDuDPN0vAT7PbuCSXWYd1nIU7MA8wS4vMaf333UHdqo5/hlohUOTNqWnWvYn0tO2Ez4AfH1lyrkJpC7GGIr39mzQR2SlCP4g+G83wCnT0vAbXFXfFsRTQtmIokM55icMq0cAjBKojs7dBAW7CEUQVZPeJdc0hkoPF08Yc/TJ5hG77Cc7byc/RWfp4Ib3jA2P2nyZkUf1UZ2nkTE1AHaJPrb7HdyPSrAY7jbFkKemLAV+jkuHc/89Bqa2JivSMQnhyGWnSofDgDBQlil0DSvNlEjuI0CgksW9CEK5Ejq7hG/7HXLt1t7F3q6CbkyhdBq8fPA== Received: from AM7EUR06FT057.eop-eur06.prod.protection.outlook.com (2a01:111:e400:fc36::52) by AM7EUR06HT011.eop-eur06.prod.protection.outlook.com (2a01:111:e400:fc36::375) 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:15 +0000 Received: from HE1PR0301MB2154.eurprd03.prod.outlook.com (2a01:111:e400:fc36::4f) by AM7EUR06FT057.mail.protection.outlook.com (2a01:111:e400:fc36::445) 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:15 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:4A982348044D2844B231B3CE3C3EEFAF86C1C2A9A1E36F3BB6E6DBF3DDC5FE0B; UpperCasedChecksum:541798AAC00FC67EE9E87029039B9C6CCA298AA8D2EE38D50B952253F5416A14; 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:15 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Fri, 30 Apr 2021 01:57:16 +0200 Message-ID: X-Mailer: git-send-email 2.27.0 In-Reply-To: References: X-TMN: [fM0m5/qnTl9lZLonzWu0rLjI4JvtiGv5] 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-44-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; Fri, 30 Apr 2021 00:00:14 +0000 X-MS-PublicTrafficType: Email X-IncomingHeaderCount: 50 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-Correlation-Id: 21ae0cc5-f3b7-4649-e966-08d90b6aeefd X-MS-Exchange-SLBlob-MailProps: S/btQ8cKWiQnJqnaHo6w7XTEhYoMxTOUqqC1aAam4by48Ty4c++T584zuR2GPh9dESXs213GS1qasFp6r0d19jD6RUBCPZpR4XHRCU6U9Q36xL+vVEztgY7i7/IhXmN1NMiazzSjif7TOK9g+pBguhm9z9lCpYqgvoQ48mtB14E6x+Ll6cBN/9+52jfbpqGWQEN3fNOqssS2OKXYMPyhT0G7rsXrjpshoeAcVwxORkb49kv2a4Hx8gcD+2B+aTZV5Wg3scf9TdeonlvBZ+Oh+FUr+frTqO5xDhUNwIX1iePT/Q+NbnmFv0gYAD3W22q18/qe3nGTcK031ZW5GS9XuLUx91XY8Bn66sy+GWqAMpvHd3KjQuzUNqjKxLgUZHVECKp7wZIERrxqxERqs/LlSHQgWPLDqFkqdTncJ1XBTiFO0zimTI870v5E6THue4guDJrb3Q8OYAAPmFGMwf0Z/s3Kwvr9yii/hJ3oJa2pT/0S0uhoJay4DVuRN5qfBHnheD551TdX9f07wT35+YJU/PlkJLrXfPau5reRIo4F9xJ/7cVbxyYaeTLRxoLv1aqHDA1kWq5nMz0lB4OUoYmMoi0P6Bw/zVEae+4BAZQqZLBTbBOAhRkn0rg/50Ake6oYPiqqZeHU+W6yJJ3cKuDAsNOrhp9RGPPxV+jLfF2GskaUdOKjGRj7RSXnSgo/f/UK6OVqfQ2kMa3sWY64fSWiIKSByfQ7Piv8NXDRZQm347kevYsPe//lybJxjjGGyOhcQOFQxH12HSw= X-MS-TrafficTypeDiagnostic: AM7EUR06HT011: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: z9qvcP+9pgjaDxNTdnE+G2iRMBfX93jZ59S5Vk9+D2NI67rdCD4If4bO9YzfK444r8jAUeW9nRjvJrDhnqJsr0EHKJOuO7LCGgwsSgg6itfZ++IZ7gYzQiYL6Wcw73T2JwjuDfRuDbhml7+K5jdsI0qdyO58whhLkYZryyyuGbJE03QYjMcaQcWdwLB97EG9fpmKYwEPVgByP7b+mukUUxGQHwycbb/ZzhHLbbFzW+I8WGy5dldQi8UMGGpnAxIN7uCFd6kHNq/NsrOtk6zQBlA7MboKorV0gJ2h+kaL0M2lfAojZXNp86dx99lfaDFGvCsflFmb9Mgr/1UbhoU/D+2ZaUEYmpU+1xZUs6akTgnOKPuHhpBThW2atQkxc5I0R+h9QgQEh1VPVzkA2wjq7Q== X-MS-Exchange-AntiSpam-MessageData: nCznmZuf+Rx6AFLxh5rsnSLr224kE3tlV//c2q+EGInuPaoxjjtQvThluqaAmphDiwMOL0MgxVWxr+fRhWEtbJCQ40CR80m0pxpAWfNd6DIicrb5EeYLxmmR+2op33LNeKLroFK3ng3RKR2gPjX1Wg== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 21ae0cc5-f3b7-4649-e966-08d90b6aeefd X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Apr 2021 00:00:15.5691 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-AuthSource: AM7EUR06FT057.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: AM7EUR06HT011 Subject: [FFmpeg-devel] [PATCH 45/46] avcodec/yuv4enc: 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: Ah7L9FIP1dU4 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/yuv4enc.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/libavcodec/yuv4enc.c b/libavcodec/yuv4enc.c index 259395d9da..995c994b53 100644 --- a/libavcodec/yuv4enc.c +++ b/libavcodec/yuv4enc.c @@ -21,6 +21,7 @@ */ #include "avcodec.h" +#include "encode.h" #include "internal.h" static int yuv4_encode_frame(AVCodecContext *avctx, AVPacket *pkt, @@ -30,7 +31,9 @@ static int yuv4_encode_frame(AVCodecContext *avctx, AVPacket *pkt, uint8_t *y, *u, *v; int i, j, ret; - if ((ret = ff_alloc_packet2(avctx, pkt, 6 * (avctx->width + 1 >> 1) * (avctx->height + 1 >> 1), 0)) < 0) + ret = ff_get_encode_buffer(avctx, pkt, 6 * (avctx->width + 1 >> 1) + * (avctx->height + 1 >> 1), 0); + if (ret < 0) return ret; dst = pkt->data; @@ -62,6 +65,7 @@ const AVCodec ff_yuv4_encoder = { .long_name = NULL_IF_CONFIG_SMALL("Uncompressed packed 4:2:0"), .type = AVMEDIA_TYPE_VIDEO, .id = AV_CODEC_ID_YUV4, + .capabilities = AV_CODEC_CAP_DR1, .encode2 = yuv4_encode_frame, .pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_YUV420P, AV_PIX_FMT_NONE }, }; From patchwork Thu Apr 29 23:57:17 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 27506 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a11:4023:0:0:0:0 with SMTP id ky35csp2020168pxb; Thu, 29 Apr 2021 17:05:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwrW081jpLxQENZmXnp9dvWLOi7NPvpMXs9+5HpXONfJJ5gbBNHetFuTfuIE9OefgwVPPHc X-Received: by 2002:a17:906:d9c3:: with SMTP id qk3mr1116905ejb.376.1619741104808; Thu, 29 Apr 2021 17:05: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 r12si99383edp.101.2021.04.29.17.04.58; Thu, 29 Apr 2021 17:05: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="X/PRjUDj"; 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 EA35168A52D; Fri, 30 Apr 2021 03:00:19 +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-vi1eur06olkn2053.outbound.protection.outlook.com [40.92.17.53]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 24BF868A51F for ; Fri, 30 Apr 2021 03:00:17 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=mBjvdMg7J1qkjro/yJ1bjz5wSy3WtbSftMg/ZJXwBi/NbH4cGr2DOlJQ1z3aeTR84GSeSFLv2ns4RwH/51S8eEN7O+MbVCnLbua/MwsWA9DI4LFk5zp3pMomVp8eP7B65tdiMzBY5ua9W4aFEz51R24B1qKJSAK1sOerFy2PI0L45u8+AzZu5ZqZ5oK86XAcT00Kab6BvW2MBtQUcwoMKwG0uyXEMy7xokCPRKEGU2prjZL+yIYkHG2XcwijVB9WfmHTWWOhV6P+1/fAWZ7S8ydeV2LaK8cJEOR3hC+viLaK2DZrN6TTNMySaXalesv2GrvjLlNtZwNdEP873vTopA== 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=9m2OFE23hLMRap1vsAcDQOmNW9EZEDlpD06UYwhZ/bI=; b=VxOEZS42mU2WQGHoJSYTnfIAGAEg/BBgXYL3pJeYo4rCsnDL91clbIMfM6hSDehS9eQ8qldVxrIytUOP0GCDinM64R9bCr3F5DdTLv0bzn9y/n7PDLaoIJi/edpiCBw5v5hve+5C4B158IrPru6kr4mCD7yUYApBlGa14PXlDzS1yxU9KaTAaSkDfqB4Vdmoe2EW4C5/EGsYiREY6sEtHnUMr9vFdTZaG3dFtTzZVq/ONQ9GGLdzmX490p4e/0mwx7LZPFxaY22lqi5geQjhOVsQZ+M3D6O90gTWK+k1XMyTQIHf1v+dXjsyNJaL7A/s2Q9w8WpHa9wNh2tbifuqnQ== 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=9m2OFE23hLMRap1vsAcDQOmNW9EZEDlpD06UYwhZ/bI=; b=X/PRjUDjWg/+b+8ZyML7eHpdMImWwHkE6PUaZQU36W9RPoP9Z2XGdkpoOYkhyJv5b4jYO/+gQe1GCus8O8iR5qDcvf/0NSmSuHU03Oe5f7qOKp94eg16ymRR9M/rzA0S9Gb+9rQU6hqsmZiPGFRruKfglkB/5JW4xSnYnYr50ChtJz8pbVvYER9ghup0KiGGSQ+ONU3jB2YV2+beiDXoD6w/thAPpx/dAmGL5QOu9CtXvIIaE5VhTPARwI8WTWetoyH6f6/DlM6efSoCPAyIeh/9OyBcOkSRIKrPNbVJVItWPhc9XJulqqpOufOaOvi6Tqb5vHYPa1JH4GCNrU6N6w== Received: from AM7EUR06FT057.eop-eur06.prod.protection.outlook.com (2a01:111:e400:fc36::52) by AM7EUR06HT011.eop-eur06.prod.protection.outlook.com (2a01:111:e400:fc36::375) 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:17 +0000 Received: from HE1PR0301MB2154.eurprd03.prod.outlook.com (2a01:111:e400:fc36::4f) by AM7EUR06FT057.mail.protection.outlook.com (2a01:111:e400:fc36::445) 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:17 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:892C22A214F439E3B0B61A7A13389EFAF40E313C820BE4C2C6D5A0C544050E25; UpperCasedChecksum:FAB765A682E4BD947265822A4FA2A9E9EA86DB902C52B6354B5D419EF98CF959; SizeAsReceived:7776; 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:17 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Fri, 30 Apr 2021 01:57:17 +0200 Message-ID: X-Mailer: git-send-email 2.27.0 In-Reply-To: References: X-TMN: [ncdyIWG79acNZlLLifLpt7ZkGrdlqiyj] 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-45-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; Fri, 30 Apr 2021 00:00:16 +0000 X-MS-PublicTrafficType: Email X-IncomingHeaderCount: 50 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-Correlation-Id: 0af4d595-d5cf-4ad5-9351-08d90b6aefd5 X-MS-Exchange-SLBlob-MailProps: gjx25WM8ZNU6XUx7q8EQ5McclV510mdNSQ6zVwN/I7HfPahThcrjVxcGkGHRB7Vptrh81pajQRIBDJRuzYt2mjkCIx3YfP/iQz4LHLviJ3j0xCQYRy9sIXpdRBUwSDi2BhLqgdBuskSzIgL9uaDBvYg05lRTorDW7I5B6dml4qGFh3R8/EA0528mj6P/M2BkgJDBvXOs4NCJtmSgt4UzTWSioXxrI3bXrk2WpI0xRxPPFtU64/vS7GwU7MpHo6ShukmRS5kuGo3vqof6jx+Lg4wWqcqcC8x/U9d8T/rNWQYW7whmvhfIKPMyg1R4MdMOwczQ90wP1eOhoLOWyN/Zwq27u6EvgJnpLja3zruI4Ev/D0AsLDOT9vxq3ER1CIqowzY9J0UVso0HGjTkjnNLrnbULk842kZ7Y3ilHXoOJRSbruXGOTDnp5AuIMPQnyo7cUIGT5npt8jivXahp0Ma5cSzXu/s5l/y44KBLOzw3drBL1XMWVppSj1pMXB9oC5cXmwPf5UjH6OIUhrsYage1+uu/cp4q+2xTr4yFhgQxpxOl0ilaks0ytVP1cBffSHZezetMSKCOHPkKRXdUap7jt2vN8nBAuKkE3Ks4GUxO2kq4ncLUpwyrsxO2nFCjqGO5apjAUVs0vr5FzGo3q/lYOipsbj7thItWZq2x+ATqehNzODUo4z2fpP/HyW8SHiFATOzat+jF9tZaYOWx+8X7tth1iNCY8Bc96jFQy5B9UE= X-MS-TrafficTypeDiagnostic: AM7EUR06HT011: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: nPP1EM2k9bJqjCwdmEloQx3m4tXPT1Q1q6+eNxNiCsrYWPKZ6fbTRqs0WriK7flsBUVvvld574giipvlan3Bnq4xvbKsUrptEs9O473ZMtHV6ccaFqmBYfjXJFcm8WlKx+adj0OXndAE4FFfARnsWjn7gH3pVQP+bCKZ//ehIH79D1/IGM4unQIwx66KeHoco7JKQ2gOh9N+4/90PZ6QGmYKLt0Q84i1E5SNwjg/Tm5b9k7pia0O3EI0y9SnyFcxwLiQzrTxX6Mis2RxU9uYNCn+UiR6EqIzu35g+1zFzJhXzCh9znWWo2bNJd80pr0w4V+KaHC9jjJK6whMtlCCWGX4/5sOQQie4gZuE17HSENpDxT8sBIBU61GWr0VTet/XP8P5lyb1PPfWbFTnsFN0A== X-MS-Exchange-AntiSpam-MessageData: zx/+qNZKL7gvf5NSeJQn5R0ceoQG3em3O9xP7byPREIkEJlp1Xd/12bZGzviWLlTPgmmFGkD/CdLS6U5zCBeQ/rKI6tvPkawEXtTmy6DlZmLaUCa9zIRAudP0vTO/66oHiZhGJz/wzc+p6znWoccoQ== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0af4d595-d5cf-4ad5-9351-08d90b6aefd5 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Apr 2021 00:00:16.9715 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-AuthSource: AM7EUR06FT057.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: AM7EUR06HT011 Subject: [FFmpeg-devel] [PATCH 46/46] avcodec/zmbvenc: 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: kkxf56M4AeP6 Here the packet size is known before allocating the packet because the encoder itself works with an internal buffer, so one can use this information to avoid the implicit use of another intermediate buffer for the packet data; one can also switch to ff_get_encode_buffer() and directly use user-supplied buffers. Signed-off-by: Andreas Rheinhardt --- libavcodec/zmbvenc.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libavcodec/zmbvenc.c b/libavcodec/zmbvenc.c index 68618f77e9..531559e264 100644 --- a/libavcodec/zmbvenc.c +++ b/libavcodec/zmbvenc.c @@ -30,6 +30,7 @@ #include "libavutil/common.h" #include "libavutil/intreadwrite.h" #include "avcodec.h" +#include "encode.h" #include "internal.h" #include @@ -275,7 +276,7 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt, } pkt_size = c->zstream.total_out + 1 + 6*keyframe; - if ((ret = ff_alloc_packet2(avctx, pkt, pkt_size, 0)) < 0) + if ((ret = ff_get_encode_buffer(avctx, pkt, pkt_size, 0)) < 0) return ret; buf = pkt->data; @@ -427,6 +428,7 @@ const AVCodec ff_zmbv_encoder = { .long_name = NULL_IF_CONFIG_SMALL("Zip Motion Blocks Video"), .type = AVMEDIA_TYPE_VIDEO, .id = AV_CODEC_ID_ZMBV, + .capabilities = AV_CODEC_CAP_DR1, .priv_data_size = sizeof(ZmbvEncContext), .init = encode_init, .encode2 = encode_frame,