From patchwork Fri May 21 09:17:29 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 27887 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:b214:0:0:0:0:0 with SMTP id b20csp342119iof; Fri, 21 May 2021 02:22:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzRpHbz4YABFZuyBDLOUwNY6MaZPQrunvJ36jaswWJfduUcQVty9W8WgU58r/IgrAKsCXMT X-Received: by 2002:a05:6402:1256:: with SMTP id l22mr10183731edw.207.1621588931601; Fri, 21 May 2021 02:22:11 -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 b26si1973515eds.88.2021.05.21.02.22.11; Fri, 21 May 2021 02:22:11 -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=m2BA31ac; 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 840B9689CDD; Fri, 21 May 2021 12:18:34 +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-oln040092073018.outbound.protection.outlook.com [40.92.73.18]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 957B7689EC9 for ; Fri, 21 May 2021 12:18:32 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=C8XGIkKXSGnhwftlqm6cRJmnFylm1KxQZQJJh8YsK9PhrfrP3y7IqVVXn2kaf7XHkkg5qRsMlcsOd+IiDeIzz8KUt/4tto1Wu+rBMKYyRossCHKbNKPHRdjY9TelmROjXf5kGBjq6+iIZ/DIaw7hakTZ8B3AHhe/LF8xIOlQSjW3CTpjpmCBMDokgb1SjwiNQEQpsFKTgzoi+Nc6ztL1bJ2VlwnW0EsXBJ9OgUoKIw7Yune4Lq8y+rr1ObSBCaVSp7qUyKgmJoXjW2+9TLzWykjm5prVVA9CN9XTY5irT4i7VOQ5uKAw8JGCk2ap0auUH9ztn21j52kpmVmtnlwZLw== 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=4Jaa+9OYN7bi+xoIcjEQVqsJ2pu7M8hQpudljGwp4Sw=; b=MMpxYHP8h0moC9Glyu34h/HqFPtaLNZiZXtCwtFCM+1UWcKXyMA+UbRGNK2U9mcsNKNbwJ1K7Z5Ki5tVA/6KJGYeMC/aGNKwoOC99eBqQCPUm07qxgc2mS9TphW1TQVzVWpDGM4PhaxXdPtj7+9xDgGkTZ94dQGL2/ujrITLASHdd2i/m3zNhtKds0hP0j+P5JE4VjJ1V+6i/wJpY5Dd5Tqa5C/vNwefo+0dzTzPnv3s9IWog35RKtnJbetPns1M/DohoJa+RFmfog7Oe79IId58IfdHL/h2TgWVBhErGBOoeIifxSeVgn8ftT8jyKEFpWZIA1hNtfnQJ8r3e5f8lg== 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=4Jaa+9OYN7bi+xoIcjEQVqsJ2pu7M8hQpudljGwp4Sw=; b=m2BA31aceoyK52cjoCiNX+ZEDJv91VDNsmzaNuZ3LuSo8D405oUMuqRwaKjviCGsJ3l1I+/F7vcscpDhb1IQ9wllljIDKhR+e2rpnfbXa5zDeTqj/mYLR8s8dfMLZxkd/e3LJPUeLyYi7sUKa1FMUcoUVHyTHS/io8jC5/E3Bub5XifjICGinEBW387butFEcmStmXOfboRZ+C4/4mDypiQ9znjq2sxHXNx1kjLdv70BuRqYgYC4ZzibAJPZgyhnE4fNl0Ep/zoTqPrEN+FPkpbYFAWwfAvv+JlhdHi5ArLJpLTOiBCwB8HMh2EFxMTpZrBHuuq1qgztC8AF2K5HgQ== 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:31 +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:31 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:3B15E1B5CD759097F3F9AD73195D9C6C43F028C2AFC4C1998457A703FA257822; UpperCasedChecksum:7B42EB72031FFA3154A159D6FACBF776105BAEE10ABF96932438CBD87291BE88; SizeAsReceived:7605; 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:31 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Fri, 21 May 2021 11:17:29 +0200 Message-ID: X-Mailer: git-send-email 2.27.0 In-Reply-To: References: X-TMN: [lPfV30KqVEPbn2SaIm9eLpkBioNoO+bw] 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-25-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:30 +0000 X-MS-PublicTrafficType: Email X-IncomingHeaderCount: 48 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-Correlation-Id: 08017df5-9daf-44b2-ebb4-08d91c396680 X-MS-Exchange-SLBlob-MailProps: gjx25WM8ZNU/M7M4vrgvBd+IenKLBfau7KPNboV2V68F1F/pm1x9XFjMOAvYeBKh0eMFI+jLf4Tt+hFmq3pTK/E5Q4gyXJdMYuWqIx8dZZ3dkG4pC4O5gqZFYnbQ3rFp0HnqYrk+zPhbVfa3HvKKP9QOkF9EXcpLoc6IpVGAYnhio93fkw5tSXmKgSdQzlE5Ur/RA8NVTg9DezMeY2f0SQTn2AkWbdabg0+/6m9Lsl80c8U74CU2IBxMJ0Op3mzxwcPN+nuMpgQN5/Al6KTV/KTQw1PtweHLkGK6dV5U2fzNWER6bhN0wmDlaFcJVW5JAIA4Y0apFEHJVao0gg/Zp+O0ZzcQYQ0sT6boHTgrq6yHJ3eQZLDpE2ESSg25r2fVh/9ZZ2Uexl5EKmF7IVsJ5utCnTp7ldxY2mH+rD4uTehyiGQDxVBXgxvm9h/r/o5SaPkXQxh/vVO/bKYTusdkHm60fo3apKKox9ca4PG2CVn/jhY91EnNf0/UvC6yPyCWYtc0ulHQGY0f81ije1qp7+T7RMedq4lHM/ZtQgghhhGYTAjxKKwsKnN0oNXNt1iGeArERI2h8pLiCn3UVDvRLovmZDTTE7ngDT0tFcNa9oFLwRc/9/24u8rfi3pSKajEW7kF46ISUJ2mj+E8TUWgR86RVkYDrnBgxhxBrduSlhWZ6+tMNQprq7nDmQsWn7V1LnIJkYdk6FA7YdXwqjFgYz79c95Q9/F0bTUXrDBVLbQ= X-MS-TrafficTypeDiagnostic: DB3EUR04HT153: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: GCy2mOSALGl1ekZCoQ8TCIQOddgVoQyR6fJQ0pP/iH7uunIiVs6j4Y1z8uR8egoIlO6CfhaYg9tmaCYxWwp0XEZdOzKYr58DVlJYbSFqW0migwoW8ZGrmBcjEx07mhDF+lugKA6UuKx01+5DfwNU7S6OM0CneKs95ejZAXJDCVcwcFWm+27Q7vv0tf3c6bdhcfkx7r8DnhgjM+BctthV2/eDSVWDOz24Mj58gw3RTMz6px6Yru1crAO0JgNj1lozXEk2azxklUaDtcIsfr117HWWxRJUNNqHC6cs/vLjHSf6mDRwJY3ToDUTGywxkJBM8wfW7+enSdTGJqYrH3Cb2ymZzrmw5ZY/hcTmi1ONwF8ApvCHfA4YcJxdqIUjB04AtkraZZFPxDHIHd5jQXLHrA== X-MS-Exchange-AntiSpam-MessageData: PqCWLEKu3GF/kP2gGdxf8TCOtHHjcOAiOM7oLajUjWDOIsyV1NWS9icnyASIsiciw7oN7iGv8JeCsga58v+mm+cj64HqfwtcdQRT7/A69JBJSpxMh88AwaWPf5VID1tWV61kvQBnHfuy+wl5oHn47A== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 08017df5-9daf-44b2-ebb4-08d91c396680 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 May 2021 09:18:31.0393 (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 26/39] avcodec/dvenc: 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: VX2nUGjJ/XF0 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: The earlier code relied on the buffer having been initially zeroed by av_fast_padded_malloc(), so one now needs to zero the packet at first. Signed-off-by: Andreas Rheinhardt --- libavcodec/dvenc.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/libavcodec/dvenc.c b/libavcodec/dvenc.c index 393c8b34e9..a464e3ed87 100644 --- a/libavcodec/dvenc.c +++ b/libavcodec/dvenc.c @@ -39,6 +39,7 @@ #include "dv.h" #include "dv_profile_internal.h" #include "dv_tablegen.h" +#include "encode.h" #include "fdctdsp.h" #include "internal.h" #include "mathops.h" @@ -1170,8 +1171,10 @@ static int dvvideo_encode_frame(AVCodecContext *c, AVPacket *pkt, DVVideoContext *s = c->priv_data; int ret; - if ((ret = ff_alloc_packet2(c, pkt, s->sys->frame_size, 0)) < 0) + if ((ret = ff_get_encode_buffer(c, pkt, s->sys->frame_size, 0)) < 0) return ret; + /* Fixme: Only zero the part that is not overwritten later. */ + memset(pkt->data, 0, pkt->size); c->pix_fmt = s->sys->pix_fmt; s->frame = frame; @@ -1209,10 +1212,11 @@ const AVCodec ff_dvvideo_encoder = { .long_name = NULL_IF_CONFIG_SMALL("DV (Digital Video)"), .type = AVMEDIA_TYPE_VIDEO, .id = AV_CODEC_ID_DVVIDEO, + .capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_FRAME_THREADS | + AV_CODEC_CAP_SLICE_THREADS, .priv_data_size = sizeof(DVVideoContext), .init = dvvideo_encode_init, .encode2 = dvvideo_encode_frame, - .capabilities = AV_CODEC_CAP_SLICE_THREADS | AV_CODEC_CAP_FRAME_THREADS, .pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_YUV411P, AV_PIX_FMT_YUV422P, AV_PIX_FMT_YUV420P, AV_PIX_FMT_NONE