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,