From patchwork Fri May 21 09:17: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: 27853 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:b214:0:0:0:0:0 with SMTP id b20csp339689iof; Fri, 21 May 2021 02:18:13 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwmixv4ifiStJSj/RPWsrwMFExHFEKaux/0mTv9CMkDFBludaWwqwTHfD5tuOESfE17McI+ X-Received: by 2002:a17:907:7283:: with SMTP id dt3mr9195719ejc.253.1621588693350; Fri, 21 May 2021 02:18: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 i8si2617572ejj.74.2021.05.21.02.18.12; Fri, 21 May 2021 02:18: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=O9PKQLdD; 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 D799E689916; Fri, 21 May 2021 12:18:04 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR01-HE1-obe.outbound.protection.outlook.com (mail-oln040092065060.outbound.protection.outlook.com [40.92.65.60]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 6DAA5688043 for ; Fri, 21 May 2021 12:17:58 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=J2ZeT4rhldO0C2SaOJMxEKNGHx8kE7fZrhyozlz/uuRLYAw/AzdZF0G095ZGBIIz8Bi7PLid6/lmOdDhyEt3jhsphW2xdYv+OC/FMhv1v6BDi9NQ00wSjCTa/+jNTjQjVNXFVE1Nt/qBrvOO5BXObOyYRr9UIZmO9W2DDo99O71ZOVnljkF5GOZBZ+j1u9trCRvdYwgkuHopKbsIb18vbc43sLJ7Pmqm667sT7qxprSrEGN2YNOz1tr2hHBifCV62ZtMqoCqFKxHVXqOxoDFcvrqjXY0k9HOSW40azUT7xwqjrlwjYzVWt2PNidb4ochEbGcusBW6jmvNPph8CNM8g== 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=YoVZCY7Kpqe4dOO9ZN0BFMwoTZZn7qrwJ5xjMlWU5qE=; b=NF7aO/PiJXlsp2lrSYWbGefKDaEdblWdQ5Md914d3uxygTIPkbsEA1CjhUPg8oFDHghMd1+/xdMgy5FHq+y2zUX5i0lou89OuETpx/C/6vlkYxvkoyJqGgiCNrSbbpaQ0QfSOfaASu1Y5nLH2Y2lc5EimHvXO+qAiu9lrxiEHu33HnmQwj6QoRcQMzW4N/DfKRUtaQavhXZcQE3kndWKPbrotLgk8lhipXfc5xHBAQYRmA/wdD1GafJo8NpNti3OjWeJjIummnWFn1fXHc+T1KjcQofROoQPBYcsG01qPboHzSrUxh9qqJogAzoIPbM50Ib5vq4T5+FhE6BtJBfE3g== 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=YoVZCY7Kpqe4dOO9ZN0BFMwoTZZn7qrwJ5xjMlWU5qE=; b=O9PKQLdDZczKjERl2LldUvtXvwDJWNUc5MuP3Q9LriGet3VGwj4IHR9lwJtT1mtNsCGS3pMnj8wZKvNqxqIedpEO4y+kxqqv2goOFhXeFj5ryqR6z0s7kGjOMHToewphMsXZDFbq+mGTUfG2/xeLiKYPBpVBVpnvm3n2gaChK3s9u1hpDPDgu8pMF7mIpAnefNuUbFYYdokzt0tW0Papitshx9WTtaBrQemMNp7jy+eMDm9vyrbMvGSyI6ysCxjUvuY/ySJvgulMEbfb6wd6Ac3aXTGiUr0jGFDTdYXWhmYILUsrQnV3qpgxlnoS1/TO1Qx4DZIj7C7O9eDSUzq78A== Received: from VE1EUR01FT010.eop-EUR01.prod.protection.outlook.com (2a01:111:e400:7e19::42) by VE1EUR01HT117.eop-EUR01.prod.protection.outlook.com (2a01:111:e400:7e19::368) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4129.25; Fri, 21 May 2021 09:17:56 +0000 Received: from HE1PR0301MB2154.eurprd03.prod.outlook.com (2a01:111:e400:7e19::41) by VE1EUR01FT010.mail.protection.outlook.com (2a01:111:e400:7e19::83) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4129.25 via Frontend Transport; Fri, 21 May 2021 09:17:56 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:1D2D7A6377A0EC3CD255DDC22D0D720DBB10775CF646FE9D094840E3EE468163; UpperCasedChecksum:A7DF1B1FE664273C28DDF691A2079CD049225F0EB8194E69B23E1CDF92A4D613; SizeAsReceived:7609; Count:48 Received: from HE1PR0301MB2154.eurprd03.prod.outlook.com ([fe80::f4cc:63fc:9cef:37fb]) by HE1PR0301MB2154.eurprd03.prod.outlook.com ([fe80::f4cc:63fc:9cef:37fb%6]) with mapi id 15.20.4150.025; Fri, 21 May 2021 09:17:56 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Fri, 21 May 2021 11:17:06 +0200 Message-ID: X-Mailer: git-send-email 2.27.0 In-Reply-To: References: X-TMN: [hTVAZYta2tKAr0iHd96qnjPqNVriq80m] X-ClientProxiedBy: PR0P264CA0070.FRAP264.PROD.OUTLOOK.COM (2603:10a6:100:1d::34) To HE1PR0301MB2154.eurprd03.prod.outlook.com (2603:10a6:3:2a::22) X-Microsoft-Original-Message-ID: <20210521091742.184902-2-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from sblaptop.fritz.box (188.192.95.27) by PR0P264CA0070.FRAP264.PROD.OUTLOOK.COM (2603:10a6:100:1d::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4150.23 via Frontend Transport; Fri, 21 May 2021 09:17:56 +0000 X-MS-PublicTrafficType: Email X-IncomingHeaderCount: 48 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-Correlation-Id: 7eb0885d-cb6d-4c26-712c-08d91c3951fa X-MS-Exchange-SLBlob-MailProps: gjx25WM8ZNU/M7M4vrgvBd+IenKLBfauhVzhm2vTQJkvw2B8vu12jP71AGeBnOzfy2s7Ft4gzvHwa9xzNDPS19k3mGAupuh+9oBCOI6JjHn35TlX3OGH2gKbas2p/DBaOJQvxUn+f1Ja1VvMiQGbFRZuAvbaA8sNixbKGSEkU3YAIMAWkepEQLX7gLmQ2H+URVDfkEshDX479Vf6ACUDxjCG0NHNKnOLIOQ8e4YDi0YqaSWsikC01b/d2ucxX4AiLRTfzBoDjtfr8YPXdIZIeuEtPLbPxfancpqKTITvrhplUAUSvBTbmRchDM/nmBttE/9ZDYzBx3rbOANB3nhIoboGD/qsE0OS/wDWsCWsPWjDZsscwYylRQGWEM7s/ta9kTpXIXJh1nen8LNkIXIg2sQCOqJC9TvWvM+IPXU8ZyCbEIy5jUXPdjHcsN0iGj4rX1AZldkMEAB/aPYLFjQeG7oB75l8uyvh8bhcyuYpkxboaGFl9w0m4Ss522fbX0AFyOW1G34prAUjjkrfTeKyNoFEkhKO+1EU3ZyBUuxQcrKMZsqxLK01/AFVsSm5yyWnrIVbQWCmS97FWvHJhq0RFgbzp22pT8pJz7vkyDM5jofQCt8zaK5qB/rGAkJNapq63H7hyEirQUwD4qJSY1Rr29MS6RgmPlmV1lryU+sKOttiBQ6XQlyavrln74bYkRhd1m/pLj9uFtjqR3ZVThXU9uiZaLIxgfZzOoSeGdNO2H4= X-MS-TrafficTypeDiagnostic: VE1EUR01HT117: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: KuDtSs7B8/H7sYvyn2AHOO9Q7CV6f1zl/HfmGs3/4zgXReQghWSLU2vmPQbefcsFrwYopc6ibyfl+jNAa+HZNBAaciJ1ARdPU5VaEETXM8K4cnWE6bKXnHmy8jQHMBflb7TCwPQs3KTDxh7TsRoywV4UNw6o+4zJts6yVt1azVbVHKJFvoEVoaNPJLUVVWwmAUzFF+a0VA+ra1KpqitfPsJR25g1ds+2utHNZ+67CfBdVletpFpUsaB5zJrInLpZxQrd30OTS9vKDUR73nU234M66Yys4ezB3STV62RppyZKMKEE1S7HHrauWIeZcBQxsaTdzJAj9w3Dr8Imz8WhVSX/8WneJp+Yu84mST9ntSDh9Badg6Cr5Hp+LOWkOvqP8GZ6BVrTMwQcSB52o2Ne9Q== X-MS-Exchange-AntiSpam-MessageData: 4xARVhcS+OL18pt7hPs8tSfwnE1iMpmG+b5eHmHjDb+U0gIVtRTl7+c3jdO7NitiomjiFbxJ6UedrV1wvcVE3o4HcpC7y1x/9XmZdXhLi4Eb7LbDf/dHfVh4bpgdA4pxBC1kd9f1hBgXeqvsBSqW0g== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7eb0885d-cb6d-4c26-712c-08d91c3951fa X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 May 2021 09:17:56.6055 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-AuthSource: VE1EUR01FT010.eop-EUR01.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: Internet X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1EUR01HT117 Subject: [FFmpeg-devel] [PATCH 03/39] avcodec/libcodec2: 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: vAXt4RPh+W8L 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/libcodec2.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/libavcodec/libcodec2.c b/libavcodec/libcodec2.c index 562a616f59..2996dc42f5 100644 --- a/libavcodec/libcodec2.c +++ b/libavcodec/libcodec2.c @@ -22,6 +22,7 @@ #include #include "avcodec.h" #include "libavutil/opt.h" +#include "encode.h" #include "internal.h" #include "codec2utils.h" @@ -169,7 +170,7 @@ static int libcodec2_encode(AVCodecContext *avctx, AVPacket *avpkt, LibCodec2Context *c2 = avctx->priv_data; int16_t *samples = (int16_t *)frame->data[0]; - int ret = ff_alloc_packet2(avctx, avpkt, avctx->block_align, 0); + int ret = ff_get_encode_buffer(avctx, avpkt, avctx->block_align, 0); if (ret < 0) { return ret; } @@ -201,11 +202,11 @@ const AVCodec ff_libcodec2_encoder = { .long_name = NULL_IF_CONFIG_SMALL("codec2 encoder using libcodec2"), .type = AVMEDIA_TYPE_AUDIO, .id = AV_CODEC_ID_CODEC2, + .capabilities = AV_CODEC_CAP_DR1, .priv_data_size = sizeof(LibCodec2Context), .init = libcodec2_init_encoder, .close = libcodec2_close, .encode2 = libcodec2_encode, - .capabilities = 0, .supported_samplerates = (const int[]){ 8000, 0 }, .sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_S16, AV_SAMPLE_FMT_NONE }, .channel_layouts = (const uint64_t[]) { AV_CH_LAYOUT_MONO, 0 },