From patchwork Fri May 21 09:17: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: 27885 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:b214:0:0:0:0:0 with SMTP id b20csp340586iof; Fri, 21 May 2021 02:19:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw0SmVd3nmho4z9dLWoFtosi7dU8UAiq/X3Qiga8V2agKgZVagqd7qAxy15YEBAaiZvLaM5 X-Received: by 2002:a17:906:694b:: with SMTP id c11mr9044293ejs.420.1621588782146; Fri, 21 May 2021 02:19: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 p20si4643646ejg.679.2021.05.21.02.19.41; Fri, 21 May 2021 02:19: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=RDsaGTDd; 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 A048E689993; Fri, 21 May 2021 12:18:18 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR01-DB5-obe.outbound.protection.outlook.com (mail-oln040092064080.outbound.protection.outlook.com [40.92.64.80]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 3873B689AFD for ; Fri, 21 May 2021 12:18:09 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=cAhyu5oDziNi+8WmrwpRgBpYdABRs2No/IE7XFoL4OMFYoFyHU9PBZ4hsaZuw3QI+XNb3gARRnh0BTaQdKH/yrHs9aGV+BuNc/qlvNUWEupsmxNHI+Zoh+H7MwQfu3RHlLvOvfHFdmqVLulk3vJLyO4ByCaTcXh+CKhs4uNBnxktmmS+NktWKWztraUD48Q4E5A9klWkMrW8Zd94Bywa2jEcywDXEvSBEPdhlMvu4UfkJMqzvllS1lcULMOC+RmOLQ8mEqpfDHiNxWyHc/KdoX0uSiwZIckG+XypVbbvYi7q2dFVGYjTI4xkVOIIGVgF75NGRDrmAivMWv0t3NbweQ== 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=cOawaIo94oV07xKEeOuwBWXE6b+Q9idiwT8tVShGwwQ=; b=K1JurUyq15xQf3/CqnnZYse/g8Bju9UacQbiV2iR19QiArI3ZuNMsQkFXc1m8H9ya8bWL5gQelhYxg3VyPl4Z4P8qflTY8dD3/uZ8HjhZ0cAc3OFylNzF/UEmgDRGTqZEXsvNI6s2PjEwNfz43b6NAB6JxGo60QRKXHMh5NNH7yQ+wPQ+xwrDmhTFNPVNgT15IdvMdrrtdthPtwnIh9z0y7T4C1u4acLdUeqV3PzkE2+POMXsMkbgCvRlzW5C9es4OmKAy2bvbMh+GCfyuDmNhvUT3clal3ZRl04UMOHeLljzewwqGqK5Em1FihVDorjPZKJcCrBPovjOG5z8IuQYA== 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=cOawaIo94oV07xKEeOuwBWXE6b+Q9idiwT8tVShGwwQ=; b=RDsaGTDd16dkZzDdnPnqtB29qBwSKuJRtPWnFbY03YHrAmpDzEh/wUUbAzDZ3ZB/f2YT7Lcma7Gs4F3lVBWTb+EQHPN92PmQVx78h6fvjQXkh3ZKhQ9KVh3o92T4EaQVD0Wld6Z2HDWIraijlD3s0zfgWqfV37HO7KDjxhvutyBmD8tuNlYdNG7P42PL3Fx+EwYrwf1Ts8hjf3DdtNLG4/BPGhT0mmwitM+OhMWl1Gs1eY/gb1/BtFfyAxr+EhiiP27ojJGP3eNdoCDh8X1NRzlOkSTnmCU+UFg44ww5OlZEOqqqKmv1eTlqBfhn1N2/9Yy7vWep6mtJCqYLqUlZBg== Received: from VE1EUR01FT010.eop-EUR01.prod.protection.outlook.com (2a01:111:e400:7e19::4b) by VE1EUR01HT064.eop-EUR01.prod.protection.outlook.com (2a01:111:e400:7e19::147) 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:07 +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:18:07 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:03BD0BA233F7C1896C62B983C229DD6C12DF9F9D185FBB64F0DF5F6FC4A88E4A; UpperCasedChecksum:31655C3BF31D3561FE286B2EA44CCBF32CE4849399121CBC9813C5373C00DB73; SizeAsReceived:7587; 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:07 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Fri, 21 May 2021 11:17:10 +0200 Message-ID: X-Mailer: git-send-email 2.27.0 In-Reply-To: References: X-TMN: [pizaoyhB9w6HFzl9KrhFzVScMxZc/lkM] 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-6-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:07 +0000 X-MS-PublicTrafficType: Email X-IncomingHeaderCount: 48 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-Correlation-Id: f105437f-bd32-41d3-c604-08d91c39589a X-MS-Exchange-SLBlob-MailProps: q+fD6XS3/UIohmq9k/yScywu9xPSfiUS4IDaJkvfungFP5w3Z1lRzE14xrkmHa9EgbGJSz1KG4RqO4IshNo5XZeS+BKHT9PkXwho0yWE1K762l2AhyvHQkiepqyJ0DbJQx3BlbpJbNVzRQixLSeuE47VP03z6o4Cz/N6H4zJ9mThXGNpx3v6cBSdyZESLDJopfv4jbk5lorM6M2KCKOwrgAERDe+D48sUWMr3txfO38waQoHqconK8PrmyQA+hElcXmIyR8MSoSlk3clvD2GhOu80OvJyNNF+/uKXEkJXrxYRD9BRv+liK5yU31ocYR38xGrjIDd+24SjcPgDKg0fweOhxYPlXgYZBJHgQkgxOQAXPWO8XAtHt9JMBjuIqHGGCubwjtEh6kaqvsqhYdQsPO2ZdIPSuIcKqjXpY/p0ZSsF/eJMTNjjVN9fEv1oQ5Pd+xH36LhmYOfgfoFUcKBJCK6u9ahvD0J9ks+MQmBs2h8aYhZtE8WNR8Q/ddZLmSUogLAnkc8hXL3xEIxH7ZuxByCaC9SSMxrcsMrRX64HGiYpGxPhXKwdKZV2aNydP8B9EvjKKwTYo+b4JYa5VvyZGhycxw72jhOTlGTQ40gc2/OtsIdHpgajjbenWw7YgrJpXIZJmbR8XyXBYPlDo0LF8X80GoC6yeV628qmixJDgQ7qIVhxXNeJxA8OqC1s8gFBYpL2r6NAVDiXNOOFioNcw== X-MS-TrafficTypeDiagnostic: VE1EUR01HT064: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 6vHAvD0V8ZiV3+Gy5HmkzcAEennVVGLvq1GRZKejzJxjSUCe7vgOk9DosJolCJ6/jZj0YQKrZTMbTaYIXdJ6HJebKbfDDGt2mJNKvTAbA2fYWbcJfNC3KhJo7n+07KpnJk7YtnicJb2GqMmScciMPKqFAo9S9tzlLlac7OKj0ZsTc2ZCI0QgACEViL0CUS5oCcGkf/QvDPW9Ygyp7WAGtngSmoaGlRPyjWKcxHjzW9FVsMXl4GGg0CRylOm3SJWLZKXNJscM8nuAqiGDul3SKN1TJ9YnlzA8mYtJML5jJAmyaoU3B4EBiYXkl2FWzKKcAjDrHfVcHrZm/yaiDbQAcvfvSwtPDLZRbki9lDsDW30/mKYlJH9P4rM7GgRpHjNhlGpFtPajDeYrWwYwdFG3nQ== X-MS-Exchange-AntiSpam-MessageData: DSrfdAJhJynDUT7n/I1Ie0xV/mJFEzMX6gyexVsmrDPFBRVdm1yhv9V/r5OdPFEL3yXFWHmr0bl0ZPtgNnANUxWqN28c+mqDgXcsadSCxQVmGCQDhGD21ffBHPBJCNZdtNwI4bm7rz2F2pztP+nD0g== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: f105437f-bd32-41d3-c604-08d91c39589a X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 May 2021 09:18:07.7106 (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: VE1EUR01HT064 Subject: [FFmpeg-devel] [PATCH 07/39] avcodec/libopenh264enc: 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: vfmqN0BU1HPw Here the packet size is known before allocating the packet, so that supporting user-supplied buffers is trivial. Signed-off-by: Andreas Rheinhardt --- libavcodec/libopenh264enc.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libavcodec/libopenh264enc.c b/libavcodec/libopenh264enc.c index 54babc3e97..de4b85c411 100644 --- a/libavcodec/libopenh264enc.c +++ b/libavcodec/libopenh264enc.c @@ -30,6 +30,7 @@ #include "libavutil/mathematics.h" #include "avcodec.h" +#include "encode.h" #include "internal.h" #include "libopenh264.h" @@ -404,10 +405,9 @@ static int svc_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, } av_log(avctx, AV_LOG_DEBUG, "%d slices\n", fbi.sLayerInfo[fbi.iLayerNum - 1].iNalCount); - if ((ret = ff_alloc_packet2(avctx, avpkt, size, size))) { - av_log(avctx, AV_LOG_ERROR, "Error getting output packet\n"); + if ((ret = ff_get_encode_buffer(avctx, avpkt, size, 0))) return ret; - } + size = 0; for (layer = first_layer; layer < fbi.iLayerNum; layer++) { memcpy(avpkt->data + size, fbi.sLayerInfo[layer].pBsBuf, layer_size[layer]); @@ -433,11 +433,11 @@ const AVCodec ff_libopenh264_encoder = { .long_name = NULL_IF_CONFIG_SMALL("OpenH264 H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10"), .type = AVMEDIA_TYPE_VIDEO, .id = AV_CODEC_ID_H264, + .capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_OTHER_THREADS, .priv_data_size = sizeof(SVCContext), .init = svc_encode_init, .encode2 = svc_encode_frame, .close = svc_encode_close, - .capabilities = AV_CODEC_CAP_OTHER_THREADS, .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE | FF_CODEC_CAP_INIT_CLEANUP | FF_CODEC_CAP_AUTO_THREADS, .pix_fmts = (const enum AVPixelFormat[]){ AV_PIX_FMT_YUV420P,