From patchwork Fri May 21 09:17:27 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 27859 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:b214:0:0:0:0:0 with SMTP id b20csp342026iof; Fri, 21 May 2021 02:22:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyw0J3Zv88kXQ7bT/RHirFEX6G8cplEWlKlhYuZz7q6J7xCKbAHKHuRsHGPLyQ9VGlRaMT0 X-Received: by 2002:a17:907:9d3:: with SMTP id bx19mr9374506ejc.63.1621588921427; Fri, 21 May 2021 02:22: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 z14si4942059ejp.735.2021.05.21.02.22.01; Fri, 21 May 2021 02:22: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=CuSwy1Yc; 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 9C08E689900; Fri, 21 May 2021 12:18:33 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-oln040092073098.outbound.protection.outlook.com [40.92.73.98]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 5F019689922 for ; Fri, 21 May 2021 12:18:30 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=AOM5XDvgmp1H+yPumm/qlnxspTxWUhfLbiWjPN6axB+ykpQfwgGgFLQLZD7ZqV6Se3zQaG9bTDPkxmts2Lqaf3z0hfWMjTxcPo+PRwZ9GV4jdwdyPb5D30dIs5hIf0wWjF2vYZbSHpYwBntMHjeMKW+/x7XB2U0lwA0+M1VjKpd/sWBAxnHFZfPNUWSZAuHjDADHLudAp2+94E6jWQPx9CRqrgFaz0d9b2qvH/ia8bh6toqfiRX8iYjBK+Jzgt6EhnvP3gleDxNLtMcbE2X2b90i9aS/ZJEf+/WVL4K4OX/tA8jRzVpiPv6AGKJtPeW5408awRoXIv0I2ndm/+1MWA== 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=VcTXb+B5BQeCDsCGJJyKF78HLHHAUWkLKSABkID+5gI=; b=mYyMBKS6Duo6LGbVD5DYrEaWedTaddxDGEcyBkrss9Wcpojb4ktYR6JtQXl835RvpOjPJ4qZh9z7+gsUDoSkp91AE/FWEZl/0MBabGtHp+TIAYoFUKEVHZGZFaEJBTa1hIUJzR9Gfq87mfcfSEFXuuujDfI3aYAez5VUGf2IzcG8MRk4XA08VkW31N9ipEdmlK6ClR2pM2wv5AI9o4vABT25rpuHIl7yWMnuDU7FV0qHSKwzQ8narCcObLp3rnrAYY+EXMcSoz1MJQE3vuYGdc7N8NdacvI3kpuiBJflhDB/HOQYV+thsNThj/0lQjvfLhw0tVAyP6WqYDmWYPTgrw== 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=VcTXb+B5BQeCDsCGJJyKF78HLHHAUWkLKSABkID+5gI=; b=CuSwy1YcxiXfjcLxuo6FW6qFPhXSW0Y+lrI2cZIeXwujbtg359KQt5gb/9WSqhLlcTO5rcimTNGzpO638n0nAMaPY/VHDge+wkdgT4IIkTjfPb5InrWwIxQQ+jAXqIlApfJ2hrcXQXyZtQfSvk+/7wGxDiZodglPRgqGbckkOSoXSw50quiXJzxfN8bLpcLw/Ca4FkUNlWyou+2Y1EJri3iupzac+knbt/MjPiROIHtCIoEaXPpUXDkmlHzZkcsxTtBGFi9YfSBc9LH5nKJeFlUWfbBKqdIYCjkLbnysVrLI7tokfPKp5WXNXg+LWkyqymYt2NlvXwH93/0blI5/Aw== Received: from DB3EUR04FT030.eop-eur04.prod.protection.outlook.com (2a01:111:e400:7e0c::53) by DB3EUR04HT153.eop-eur04.prod.protection.outlook.com (2a01:111:e400:7e0c::173) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4129.25; Fri, 21 May 2021 09:18:29 +0000 Received: from HE1PR0301MB2154.eurprd03.prod.outlook.com (2a01:111:e400:7e0c::41) by DB3EUR04FT030.mail.protection.outlook.com (2a01:111:e400:7e0c::99) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4129.25 via Frontend Transport; Fri, 21 May 2021 09:18:29 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:286A7AC2CC31AA3CAF48C43296D0F564F8F56751F14B0304301AFC4FE756450A; UpperCasedChecksum:0A509526B0B6D66DBB8E4C900D0D8D3346ABFE1002A6D230F6418BD96E4B9AF2; SizeAsReceived:7598; Count:48 Received: from HE1PR0301MB2154.eurprd03.prod.outlook.com ([fe80::f4cc:63fc:9cef:37fb]) by HE1PR0301MB2154.eurprd03.prod.outlook.com ([fe80::f4cc:63fc:9cef:37fb%6]) with mapi id 15.20.4150.025; Fri, 21 May 2021 09:18:29 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Fri, 21 May 2021 11:17:27 +0200 Message-ID: X-Mailer: git-send-email 2.27.0 In-Reply-To: References: X-TMN: [C4kX+DzWM9+U0zGKMbcnqZnpkUo/IiBf] 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-23-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from sblaptop.fritz.box (188.192.95.27) by PR0P264CA0070.FRAP264.PROD.OUTLOOK.COM (2603:10a6:100:1d::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4150.23 via Frontend Transport; Fri, 21 May 2021 09:18:28 +0000 X-MS-PublicTrafficType: Email X-IncomingHeaderCount: 48 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-Correlation-Id: d508a3a4-d726-4910-f75f-08d91c396545 X-MS-Exchange-SLBlob-MailProps: q+fD6XS3/UIohmq9k/yScywu9xPSfiUSUWWBJ9vat9yGda2uv9egNk9nm7rc5xF/JmN3PapTylVgHbG4GmG0a+R846V+JcHvCAhORMbEm9FOBgGry1hZWl3b8G7JlEo/VDsdG48o7AqKl+oiqUl6rDv+9b8R1Bq7+3uKVQWtoqQfi8tpDR1EWH37SRndk1mocs7E2g6NUFLN5pHN+aE19aOi6DM71yT1e6t/QnybKURb0fLWfzJ23th57W9JhQprtHAoJO9h9Q9aUEPq8E0t3mCC906JCtlfW+43Nwg75KNjwo4Aq+PaR6QOW2yu0Wcdek613ewCUV5RHRlz1+wp/cB1YuN+ULnaMnHq17NUJ9dC4Xjsc186GXYZxBu0boq/4YTpwTYilhh8yEtFAhYP3rOMo7E6A4hygHGyvoIYwofPH4bIaJ7K1ZBVV1mY54B8hWJ3+V+WIorROh0fYU/iKcHbVPaECMFyMw/XHgmwlDnQsrkq1sRmOnuUog05caAoX3J8BQwxVunu/qqGA/A2E6T2QZyhegOZp3GHqcRoUi318uabB9TN28grW0Dj/RHw3F+7i7M615j6SYjF3NxNf/lE0ttvs1A5JC8VBngghcz3sI22TN3e+2bT8Kf2dHIxuPw8fWDwH7NIwRGUIQNqA1Z/JX1QkJcivFw87P0LIt0B7I5RVrRXn/+ljQrtsrs2G6856x5jiz0J9fprIEHttw== X-MS-TrafficTypeDiagnostic: DB3EUR04HT153: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 0SUOwDL5VdWwO9LBCLJmcoovxoaHX56EAKf4UQdRqzIMc7FCGAE/lgiH8+JNM1a0ljZ23vcjBW9WZqgCPFTt39GN/TIJLwsufTXkf2P+EHehxbGt850QxVoz+1huxBJF9E5NMQrJ2lrmi/ig1vytaz0ZAfgD8VPSsB+3xU+Oqt1m9z0dMx4kTXjolfE/h/X2KhJdQjEOfoCrgefyfQAHv7DhEQpVlFuiMhAJ3/Ri5UjNC+gX2HY17117FqztMy1kKJu750r1WH9VK0FyEaNIMe24+ibWAQw+ngG+c0qWj//Krulf9WmHO83lZt0mXck+JfDE6SZciCw/12i/uqfQBG7kzwIDmhUWKRqk7fJerwQkWQECT05mNsWJ4W4u3p6rXXi4L9UOXD5+7/xl0gNKcg== X-MS-Exchange-AntiSpam-MessageData: eHx58m3HqUqpDCLbxLq2BcImJrdk50Ld0JYIioNSX8+2wjQCtj+XzKt1uEkOenZE0O0wfKGhV74JLYAoP7JTXoGYvgax3y1Xrr9rQcgLGSMwkxorUXzE1z/PrIsYCN+qhK6V9I/1KU17PzxCNTNGHA== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: d508a3a4-d726-4910-f75f-08d91c396545 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 May 2021 09:18:28.9592 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-AuthSource: DB3EUR04FT030.eop-eur04.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: DB3EUR04HT153 Subject: [FFmpeg-devel] [PATCH 24/39] avcodec/sbcenc: 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: q6nRnis6Cjn9 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/sbcenc.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/libavcodec/sbcenc.c b/libavcodec/sbcenc.c index e87c623d4b..5f9a214a1a 100644 --- a/libavcodec/sbcenc.c +++ b/libavcodec/sbcenc.c @@ -32,6 +32,7 @@ #include "libavutil/opt.h" #include "avcodec.h" +#include "encode.h" #include "internal.h" #include "profiles.h" #include "put_bits.h" @@ -290,7 +291,7 @@ static int sbc_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, if (av_frame->nb_samples * frame->channels * 2 < frame->codesize) return 0; - if ((ret = ff_alloc_packet2(avctx, avpkt, frame_length, 0)) < 0) + if ((ret = ff_get_encode_buffer(avctx, avpkt, frame_length, 0)) < 0) return ret; /* Select the needed input data processing function and call it */ @@ -346,10 +347,10 @@ const AVCodec ff_sbc_encoder = { .long_name = NULL_IF_CONFIG_SMALL("SBC (low-complexity subband codec)"), .type = AVMEDIA_TYPE_AUDIO, .id = AV_CODEC_ID_SBC, + .capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_SMALL_LAST_FRAME, .priv_data_size = sizeof(SBCEncContext), .init = sbc_encode_init, .encode2 = sbc_encode_frame, - .capabilities = AV_CODEC_CAP_SMALL_LAST_FRAME, .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE, .channel_layouts = (const uint64_t[]) { AV_CH_LAYOUT_MONO, AV_CH_LAYOUT_STEREO, 0},