From patchwork Wed Apr 14 21:22:09 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 26915 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id D98F444AD2F for ; Thu, 15 Apr 2021 00:22:20 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id BA8D168A199; Thu, 15 Apr 2021 00:22:20 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR02-VE1-obe.outbound.protection.outlook.com (mail-oln040092069089.outbound.protection.outlook.com [40.92.69.89]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 82DA7689AB3 for ; Thu, 15 Apr 2021 00:22:19 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Hbe+yscTJ5xAZd2FUJe9dkP/kTLynUme6myfMOrEyTvd9MQCNDD2oUTLQ8JiVS5pdmeM4rSp+BMw/O1HBwg8D+tHDXO2AyI/MmXcwKWwQesKTvMLV9l3NZOZ5tfLJNL7gpmF2g4fcp+ixbDkDzh06NRjez+XyF+9jlG+5Osgiz/PE7t6kQy3oJ0slIGAV8Tu4hOVOk1xBrP8yxvyld1gF8EW28PWOLx+O12WBz7+xNfk7swjZl/zMtbmidLf66CMxpJGhHoFSATQduMQpRIsawS+M8/W6crZELcVBVG+gMdt3vtmmRHbfCFzDdF8DO6fExvdWrEIAmu0yyEHYYLgww== 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=jW/WCG8BrXnxuivQmR6Cxi3vetpAQldQCbCnd1k79GM=; b=AOxtrlRo9nU61hZrQuF/uIFtZV+wCSUXnCfsnFQhCL9uA8YPojj0531MTOwo/n0ezyWZxWCSuPmKG+ol2o7cjm8fpV+B50LNpwKDpQABXXlXI3MVAY+VcFE5KK/CcqES81V7fSOR0IeKt7x8yZPAcr2oK6VybkNNh6v7T8cj7kyQInBAN0tJWQZwkicINvaUo9Yt6X6vX/W2g7Kwz+e+1CfVd57bsZF9PYYY01Y8Sj1ivy0ECaJ6yGfglzxC8f3UQyvFjxzwalX7/BM+Ir3/U/o3tRgMibVnhwQAgKjGoO8JCAXJLysFTR2RUeQLZ4WGSG7zuxktBYXnrH03efhvLA== 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=jW/WCG8BrXnxuivQmR6Cxi3vetpAQldQCbCnd1k79GM=; b=eZnYA8zthX1YZknnVTxpmJbZMRaXJgsDZZ8TFZD75TF87TSo+xqwLFK44m/fzx1FNRB5e3xav5cE2JepY0Pb1eRchFSAQALN8okazvbUTcdnv6e1+7PAbgFRzcL9odtfWyeMxT/NXHUO//TG8kv64WnTVlpQBGCbcbMZfl+L91mc4y1qCEQ6aoroUiTHzlpC3P67B6mvsKzE1KK13GHiOqBMHz9bC2GcXrEVSjg2CdUJjC3cTrI5koTpI+OTYjI8IpXOq+qwEeyYRbIy5OsrusypPzYg4d7t2DLRxDLrAxVtvVDmpPvM/C6Mu9bhlplbC3Yojgy8NFaRPTvm18Vytw== Received: from VE1EUR02FT015.eop-EUR02.prod.protection.outlook.com (2a01:111:e400:7e1e::53) by VE1EUR02HT236.eop-EUR02.prod.protection.outlook.com (2a01:111:e400:7e1e::392) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4020.17; Wed, 14 Apr 2021 21:22:18 +0000 Received: from HE1PR0301MB2154.eurprd03.prod.outlook.com (2a01:111:e400:7e1e::46) by VE1EUR02FT015.mail.protection.outlook.com (2a01:111:e400:7e1e::147) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4042.16 via Frontend Transport; Wed, 14 Apr 2021 21:22:18 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:BA1FD0A47576947D643B73CF266C3933784D1DE8CCD6C1168A15D6CE967710FF; UpperCasedChecksum:5E40E9A3171A478C53F32C837E047EC1F243DFE430E5A4F1C7FD7D75214B1690; SizeAsReceived:7394; Count:46 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.4042.018; Wed, 14 Apr 2021 21:22:18 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Wed, 14 Apr 2021 23:22:09 +0200 Message-ID: X-Mailer: git-send-email 2.27.0 X-TMN: [tG2dAKk3Pwq7vGF3/5zFjdsKCy5p9TJr] X-ClientProxiedBy: AM0PR02CA0172.eurprd02.prod.outlook.com (2603:10a6:20b:28e::9) To HE1PR0301MB2154.eurprd03.prod.outlook.com (2603:10a6:3:2a::22) X-Microsoft-Original-Message-ID: <20210414212209.1246074-1-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from sblaptop.fritz.box (188.192.137.96) by AM0PR02CA0172.eurprd02.prod.outlook.com (2603:10a6:20b:28e::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4042.16 via Frontend Transport; Wed, 14 Apr 2021 21:22:17 +0000 X-MS-PublicTrafficType: Email X-IncomingHeaderCount: 46 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-Correlation-Id: 38d19441-814a-4a42-9ea8-08d8ff8b61ec X-MS-Exchange-SLBlob-MailProps: gjx25WM8ZNWz9ZT4nZGZNWVvBF9S2TEbRnonU792kocKXgd1C/J3znEt3GoDQs71pItmSPZ6A+VgM0G9CMfdxUkJoJGWuL0FzOwVG6r9ryIVXv9yvhOf4FbevL12/FhZ71MzYkFzZhDvt0uItD/xaghOVko128MOgGKooerqaifIdV9ZQx+Qgm6CQ7mEAhXAaFlTzpY8DXCekQPngHrcZNSdYx2oCMeynEFE1eo+7Cd/Xg8hG30pJIeAQZRVroEshV2fsz0dA7p95ecSx5NE1kWW1nETPFt0E8Pnz9ZB4hENhsBRnXcCUDSNHaNt6gH3vI4jZlRI1zodt5uTZp8WwmNNA8r2riLIsSz8LvNiJuKOJzHsgzZU+GNgmRVdNvwrdb+sj/fNjO+faUSDMBTwzTkuJlQT8G42jzT/skLk5mHaUpLi1WWju7xumfd7Z2D92BWDehFQv0wVW3gfpfJYfX45tAQaFwOhFFKhBnlqob93TibrGST9P6qX3jzP2ZgqK/A0WIydKj4uEeml5G6BruPhk0z0wezcbduG6sfaOkphAIXG78bAqjqriega7KNJd1XQClPq2SpHmfLV0ypPXl38r1KIImoGbHR1lvA4WGLo9Ar2AKFgR0N1ILFyIoQl5bHxwEDJkEyDQ3hGE/tKUproM01mhEdm8Cocpr4ygMJ88ERl9eXC5GGMhhzDv4gZHNhNrj87kqSRqlvTWXRZuEXI2BbTOaoykpyfPk26A1U= X-MS-TrafficTypeDiagnostic: VE1EUR02HT236: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: OBu2raT3xC/NjGi7ZaQmzrtNMV5YrV+L5kSZz1nuu9KWmhwiiRSwa8ga04BsHWeen+Q3i3JbBe1pVGwsCskoZvUgQFbV6PbsfvlGEEb1A5Xh8DvVWESn8ReR2RogEoXprwLxQyKcJHc/I+Jl6dkZ9f86DUVGT0zpi9H+jy91D8yYC04Ru6S7ed53GdkNk6NHSUSE9kmaN92KSFZxDXlDjW64/Uljy5hTUNNn6dTsxO/aX4hIQUymrXOxEP49S+TFgBQJSrz08xIWfHT1Qp2ib1nFxtFhmwswKIsojQ5MQZe/BVDUbrTxIqtj2ZadyD8BEk0QxgiobSXgJe+rfXW+pfy1Pq41oNQEMktJlMeI7R+XFqukX7WwhIulsl+ncMOvAZscx1aBYzTWO+lEH6LZAw== X-MS-Exchange-AntiSpam-MessageData: yqK/P51ogeG7Ll+aMZATKmo4suU8bv4d45zyabogPoE+P61HRBACBK6966wqPO45YcWE7zaBLcAJ/bSCCOyI+pzsZc6cNwA6Txy1PdZYiaysUehsNdH60cQRaxIt2af1T5/dVFDRPY0WZPyfl0oubg== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 38d19441-814a-4a42-9ea8-08d8ff8b61ec X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Apr 2021 21:22:18.3218 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-AuthSource: VE1EUR02FT015.eop-EUR02.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: VE1EUR02HT236 Subject: [FFmpeg-devel] [PATCH] avformat/matroskaenc: Remove unnecessary function calls X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 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" ffio_fill() is used when initially writing unknown length elements; yet it can happen that the amount of bytes written by it is zero in which case it is of course unnecessary to ever call it. Whether it is possible to know this during compiletime depends upon how aggressively the compiler inlines function calls (i.e. if it inlines calls to start_ebml_master() where the upper bound for the size of the element implies that the size will be written on one byte) and this depends upon optimization settings. It is not the aim of this patch to inline all calls where it is known that ffio_fill() will be unnecessary, but merely to make compilers that inline such calls aware of the fact that writing zero bytes with ffio_fill() is unnecessary. To this end av_builtin_constant_p() is used to check whether the size is a compiletime constant. For GCC 10 this made a difference at -O3 only: The size of .text decreased from 0x747F (with 29 calls to ffio_fill(), eight of which use size zero) to 0x7337 (with 21 calls to ffio_fill(), zero of which use size zero). For Clang 11 it made a difference at -O2 and -O3: At -O2, the size of .text decreased from 0x879C to 0x871C (with eight calls to ffio_fill() eliminated); at -O3 the size of .text decreased from 0xAF2F to 0xAEBF. Once again, eight calls to ffio_fill() with size zero have been eliminated. Signed-off-by: Andreas Rheinhardt --- libavformat/matroskaenc.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libavformat/matroskaenc.c b/libavformat/matroskaenc.c index 3649ac25a2..0141fb0b8d 100644 --- a/libavformat/matroskaenc.c +++ b/libavformat/matroskaenc.c @@ -195,6 +195,8 @@ static void put_ebml_size_unknown(AVIOContext *pb, int bytes) { av_assert0(bytes <= 8); avio_w8(pb, 0x1ff >> bytes); + if (av_builtin_constant_p(bytes) && bytes == 1) + return; ffio_fill(pb, 0xff, bytes - 1); }