From patchwork Sun Apr 25 22:34:22 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 27401 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:5014:0:0:0:0:0 with SMTP id e20csp3458243iob; Sun, 25 Apr 2021 15:36:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyZvrl2Bg1RsY+9iP0NVU+7FUqULIIqUBTANKP6pxNC7XCpULQTMA4o5LGFROndkUArY9DW X-Received: by 2002:a17:906:b6c5:: with SMTP id ec5mr15442595ejb.290.1619390178761; Sun, 25 Apr 2021 15:36:18 -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 pj26si11646898ejb.390.2021.04.25.15.36.18; Sun, 25 Apr 2021 15:36:18 -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=gsKnAF9r; 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 184DB68973D; Mon, 26 Apr 2021 01:35:28 +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-oln040092065051.outbound.protection.outlook.com [40.92.65.51]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id B96296881E8 for ; Mon, 26 Apr 2021 01:35:19 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=UFU5SwI0Adx16OZsJmN2aTH9kh8LSy9PzPSQhf0w4j/ke5XQ8KWbFHSazGlU4B8AChcCt7/AF5WUM2s9j/7HeL8DutnHeKammht6vimK2K2QJ9/9WxIOjBQSshtY/FxRJ0J4JNaWfY/gTW8hhhmYcwkago3sHKSLoRNOIi3apawA+/829enXltCFQ+QzVJacr53/+vfEumAPX+VnfarTBXLGfM58zuUxrRUJvU21zAuxIWV+0LvtkxdgTaqPXNhMqP4ka3HoixnPUBR61QamfuqvJnHJT8dEoFhQVfaA9pK5hfEnyfhEsxqy76bFaidLNUAdx38sICc5kMdAmQRajA== 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=aqaQQahvjm5DRiX0DwEMPtW69hpoTynN/U28L/Y3LXE=; b=VDHdV8rl9iRNQJJz/WzoRbGZMPVUGnM6tIY+4D4rPdzAcSdz12ePjbzgKArIcN6iHBFaYvcs2ytpEIQ8OMku765AkDcK1RLizJHedGfZ+tvOUMife12vRubRgH8jI9+LlIVkDbKTDaSwJGi0ufnNiHglvUw7MyF30hr6EZ4dE2erUmYaIy6h6lSGVxvYtradUkDBadIcQr8XqkXir7pn4CNSjFvVlc3AW0TY0Nr2S+LdQvQAR3KZl/76d5S2Iq+/M1R+HD4dzT7+tW9P/KwH1p35OA+7mw2xZHtoClznU4pzfc/Ci5b40CNOgYNr1FIvmZYEw/7bectswOt6GN2DPA== 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=aqaQQahvjm5DRiX0DwEMPtW69hpoTynN/U28L/Y3LXE=; b=gsKnAF9rrUwOWMOmr0mOlo9whi/0oJWVxNzPoCYJTkz9kTexAfrX2aakQaHwMtGIpebG3JcNi81v9HtPZqUXe5micB1PHJXzMaAyEGv/O4RkMl1BUBepMdb/+fRUvUTyfHpDF9bvq2ozzDbubDxoRHbEtFzevyGr6enwTuI8mjiExdLvUSdnfQwvxvQn42t72VEQoptOjbB6NjCwbxEE7uIKd3bshi8zfq13dqfu28H8qRtdkXn3v/M3PtmMSPY9PQaGC8Z5LYFKG2m2Zr8XsSsZ9rSMGdhD42ROmUxlMpoK9YsBy5wo1vcnhb3Y0U/ujOP7dlbLG+cwsH4dJGs7Zw== Received: from HE1EUR01FT030.eop-EUR01.prod.protection.outlook.com (2a01:111:e400:7e18::4c) by HE1EUR01HT194.eop-EUR01.prod.protection.outlook.com (2a01:111:e400:7e18::401) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4065.21; Sun, 25 Apr 2021 22:35:18 +0000 Received: from HE1PR0301MB2154.eurprd03.prod.outlook.com (2a01:111:e400:7e18::44) by HE1EUR01FT030.mail.protection.outlook.com (2a01:111:e400:7e18::170) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4065.21 via Frontend Transport; Sun, 25 Apr 2021 22:35:18 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:1214FBA8B209F3C904EF271809F9A79E8A2FE8E16A8A8B51D035FD9997F95B7F; UpperCasedChecksum:8444F45FBBA5EB235917FC991FBDFE5019605827F39982F33E8DA801F595E06A; SizeAsReceived:7573; Count:48 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.026; Sun, 25 Apr 2021 22:35:18 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Mon, 26 Apr 2021 00:34:22 +0200 Message-ID: X-Mailer: git-send-email 2.27.0 In-Reply-To: References: X-TMN: [UuDmXO4Nq0KeRau7uWg1Lw8NpG1UbxNN] X-ClientProxiedBy: ZR0P278CA0100.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:23::15) To HE1PR0301MB2154.eurprd03.prod.outlook.com (2603:10a6:3:2a::22) X-Microsoft-Original-Message-ID: <20210425223448.130684-7-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from sblaptop.fritz.box (188.193.248.86) by ZR0P278CA0100.CHEP278.PROD.OUTLOOK.COM (2603:10a6:910:23::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4065.22 via Frontend Transport; Sun, 25 Apr 2021 22:35:17 +0000 X-MS-PublicTrafficType: Email X-IncomingHeaderCount: 48 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-Correlation-Id: 8dd315f4-f026-452e-814c-08d9083a6734 X-MS-Exchange-SLBlob-MailProps: q+fD6XS3/UKBTepCewFwVSkfoADfkQpyvQJmww1KlXcr+VW7VMqeULMj5N7wZAJI/H851N+qGrblHUPARnFDFLTLw/h3IRZ73uoZO9Fr4CwKnaidxB5lEBmE4mVoN+nVE7cVnqXAvDyxhXFyG0ryKix5/JSnkoXP8bV72mDZ+Umi2LEkWxJg/zxmBPh6V6Ppndag+GVQNBdj18SUAokbXzwZSm+6tLjm44m0w2fsd8IOXqrxh8uOb9sSH6uOhyzCdN/CBLpQJfBHVzYYRsZCToeR7Vzn1NxexGiuWUN1tYEliZj3Bavr7vZG7ulObEJB45cxC5fDftUPzjz3/r2eeQ3/Gyo9nDw/pbdSnXcxDIKM3ittwS9ATo4SbOeQpQn/TfCmuYh2xeji1+SQNGhJW2Dy2sfZXO3P+Ejh09e3MiTlAOOgrwrzh/5lut7ac+ehR0th92SJ3hKRO751pGXJvfYE+q/5D8kvjEvFHr2aHlZU3AXiQuim8TBZagkmf9iPtE1ipwwMTFxpGONc/+y21KIzVYvmQlbg7YPX4F7c6PEPFJSy0y7U3K3d2es/dU2NbcLN/xnvRhtLqmFp/TNqBZ+a50pcd4RhtLgvzq51aPD4QYY5ZCVgmhdzLx55t0l5s2w9UjIMx1pQFzhgdWHh53Hvft06b9Hf8f3LCt9/+JSKVe/4FyfqtDY6oyfsU2HTUaaE8fxYx6HEu7mLGGDVYA== X-MS-TrafficTypeDiagnostic: HE1EUR01HT194: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: BBa4Pzk0PKmLmTGUkrrAQ7O5gRglyo6F21LQzs8uoRMxOrX/8nyjFZR4BY4zuri78nAzwrFw8Py3NMhnRrJmr1WE8yOtGMKftbNAr1AvVskY3kO9/7YZVHtA5/qT9d2nYJQgm9coQE/uSRd8aFJKYXG5h1h50Gvs/d/RRLVrvzLLXjV7K9iiHdllrYa8FUy351Rvi0AQ0IYk5QooM1oxPeKZmM5UxeKzpUYJmVkb8Na7ck/dTrC7HLmIqq41G4vm6W2x9WYvhaj0KjAOQzA7StFALVBAQfdI18Bf5QjLSDKTuyoNLNTIpMABaGVOEBaRdSdHsZgJtLc0RvD7oqgFN8yjbT1l/dlfoKwYjri1lrUjU8aR+BbfKHZLYVT/Yz79J1l9c/ghEAR7VCRGnXQNhQ== X-MS-Exchange-AntiSpam-MessageData: XAM0EBBH8DpZPRTI8MONq+uOVBDp2t5AoOxVPn9YNxASHk3L63Bq+Dwd9Roy0wtOSHI61Pm8V3ugC+l4PpoSTyB3+ble5rsukVfqsCt8V99BOvw47+pyodQtEXuHTsGMlaDcLb5HyXOAG+hbiKWryw== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8dd315f4-f026-452e-814c-08d9083a6734 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Apr 2021 22:35:18.4444 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-AuthSource: HE1EUR01FT030.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: HE1EUR01HT194 Subject: [FFmpeg-devel] [PATCH 08/34] avcodec/fitsenc: Avoid copying packet data 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: NDzI23XAcQ9l When the packet size is known in advance like here, one can avoid an intermediate buffer for the packet data. Signed-off-by: Andreas Rheinhardt --- libavcodec/fitsenc.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/libavcodec/fitsenc.c b/libavcodec/fitsenc.c index b44507e436..201604aa59 100644 --- a/libavcodec/fitsenc.c +++ b/libavcodec/fitsenc.c @@ -80,7 +80,8 @@ static int fits_encode_frame(AVCodecContext *avctx, AVPacket *pkt, data_size = (bitpix >> 3) * avctx->height * avctx->width * naxis3; padded_data_size = ((data_size + 2879) / 2880 ) * 2880; - if ((ret = ff_alloc_packet2(avctx, pkt, padded_data_size, 0)) < 0) + if ((ret = ff_alloc_packet2(avctx, pkt, padded_data_size, + padded_data_size)) < 0) return ret; bytestream_start = @@ -104,9 +105,7 @@ static int fits_encode_frame(AVCodecContext *avctx, AVPacket *pkt, bytes_left = padded_data_size - data_size; memset(bytestream, 0, bytes_left); - bytestream += bytes_left; - pkt->size = bytestream - bytestream_start; pkt->flags |= AV_PKT_FLAG_KEY; *got_packet = 1;