From patchwork Thu Aug 12 17:10:34 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 29489 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:8e8b:0:0:0:0:0 with SMTP id q133csp950295iod; Thu, 12 Aug 2021 10:11:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwDb/smS695FghulZvlaZXWrm5R6XqLdz1LTvHSS+DaKhM4fzKwyUJkI9R9uOV8Z+YufsQA X-Received: by 2002:a05:6402:1057:: with SMTP id e23mr6895469edu.352.1628788262215; Thu, 12 Aug 2021 10:11:02 -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 ec28si3292479edb.143.2021.08.12.10.11.00; Thu, 12 Aug 2021 10:11:02 -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=FrxIpY3X; 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 A911868A1C3; Thu, 12 Aug 2021 20:10:55 +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-oln040092064056.outbound.protection.outlook.com [40.92.64.56]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 7A64768A12D for ; Thu, 12 Aug 2021 20:10:49 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Fi4++2W7Z9opu4avyjQwd9IvW5W2m2yRMp3QKnmwatSrnkuF0o3PkXGTCmjYhCrEFiG9svHMib4Ykr/E7i5vCholb9X6zvQ3t5b4ic2dNXhwyZdYNJHVvcMp/Xj6oDlbkjIHEAbh3Kb7pnVFp+nSUQhdm8SfUyueo/w2oXSFZjdb7+fZveAeABgjnmX3gPeU0gfCno/qFpDjbhJdea191fzSsRQncCD2nRY4IjDaBfP4L7hu6RU1kq5SyHBvmjuyXj4MQwt/1do60JQtzWeALOM21e4SdTh6KaKY2nPfcDCo5FY/y2zyWvODCn9YYwqzez0Rdfc1T42iydry8EH6GA== 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=pS6kGhjDKjyapkvu46URiP7rkmiqcDS+f90CFS/8eNw=; b=XbHrAG7C9MV944O+/SPuI+9k8V3WNInIwa607OKgxylxDdXc6omOZ3ZMQE9bnpJGiRycQf2f7MYOP2OEKryRqN+v25Egcz5UYyorQhpg+qgln7I4MwaKxATk2zAT6vmM5kHD/zIIP6aP/IsqALD0VXHusZAjZPbkXxr6yJRxmWTbMDvYa97C6ip2GFmrgjSFThZrRedVa4/g4SDHjFIq/3KCJOdr1yg+efkhJaHz0B/Vwyz1Wb7+hP2sBfJLco6CaaVrUxJpn42/H0gGVBYex3Sg40xzdQB1TS2j9sAsqDxV0FN/pfZP7rlXRsi9P9/a9q12juVB0j8gIFMpZFQjBQ== 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=pS6kGhjDKjyapkvu46URiP7rkmiqcDS+f90CFS/8eNw=; b=FrxIpY3XRLg3Kz5eYcT91/T/zgmZUo6l8nBaxFMQh85QrQzURSXOBq+eFNR3+016Cs7b4sQ7uCNk4Kumd2wkPeaN4Q4NaxFweUDQeT+p44GyNe11Zk/7yTJvHm4Jj7fOfRRXozpIwBjNl4T6cnoUpKkj10v9cFM1EinDQBIBZuN0y++fZOzv5rtCUudYi1fj6MIZDDOyCbEDcImWq87MmBZhVOrzY4gozfqN3pNPIcsITh60h68XpQqZHyeT86shz9O2HvURRgw3oe1DpClVhACD4brC4tCdo3jN5CkPfDsgIIsxxFQlRJACISZhoIvnEilBLGPt4ZAY0mnCQX8pRg== Received: from AM7PR03MB6660.eurprd03.prod.outlook.com (2603:10a6:20b:1c1::22) by AS8PR03MB7381.eurprd03.prod.outlook.com (2603:10a6:20b:2e2::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4415.17; Thu, 12 Aug 2021 17:10:46 +0000 Received: from AM7PR03MB6660.eurprd03.prod.outlook.com ([fe80::ded:bace:bc7:e91d]) by AM7PR03MB6660.eurprd03.prod.outlook.com ([fe80::ded:bace:bc7:e91d%3]) with mapi id 15.20.4415.017; Thu, 12 Aug 2021 17:10:46 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Thu, 12 Aug 2021 19:10:34 +0200 Message-ID: X-Mailer: git-send-email 2.30.2 X-TMN: [txpp7pzaEceZlrlNnmGsQudoTT3GzDgG] X-ClientProxiedBy: AM3PR07CA0106.eurprd07.prod.outlook.com (2603:10a6:207:7::16) To AM7PR03MB6660.eurprd03.prod.outlook.com (2603:10a6:20b:1c1::22) X-Microsoft-Original-Message-ID: <20210812171037.1559296-1-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from sblaptop.fritz.box (188.192.93.129) by AM3PR07CA0106.eurprd07.prod.outlook.com (2603:10a6:207:7::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4436.8 via Frontend Transport; Thu, 12 Aug 2021 17:10:46 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 826eb0b0-c253-4b01-825a-08d95db4201a X-MS-Exchange-SLBlob-MailProps: gjx25WM8ZNUV2AKzJQ6OV+KUMEtXCR7XIUipRV+btBCQk7f20DRONJZKwANdfjKkE0cHVjDRyff0unhcDWng6sPEpT0hgfoeXMPcjt8Ri+4dX2J244rD/DxILC9nOFys+yyU3TxtyMJV3LMVUxmlIxsCzPzCTBI2AX1dDx96vPJgqMF3QXnZZCfYNtUVUDz0hRMsvM/Mjk7vIfja/Dn9VNz7EVW+ZrmjZerI297FCSs5sRLSIoNwxVY8OpgKcbe4FPXbLCsNDZw9DIicE3EGMPXzDa0JYpXI5N5zjNwdeLnZLrkI7vzUFHDV6NlFcBgqEVm1n+GvXHF5GNyxehpy6PLjwxBr6kbzHObp3vGWLh8jSLPMFuHcJsLs+JLE/PDDn5Ek2vVecf9JkZBG/Z9PaqUQocu0Q2rMB/1pbB1i2A2DqgqLW+o3CD3c653jhiNzcAi/yVtFXU55eX4kASz6veFc29ZPMN6Rdb1GvqQU+awwldW0HzA/MPpqKIMj5yuIsd0Pw5DNhYuxy/t+u0/Zs8KSqaoX/hxW5Ou4bVXQ2GeX+HQfGN29dnXgwJ2MrpVA1l0o79evyP4if/uTp62ze6eW6T7MRHz7Jr3vGOeJhu4AT2asZs5h530YL+RG/2YOtn25qXcVtq65bEiM4ySawHrQOWQzWWlTk0XyxsjVvSMn0kFVMnsxnSWfm60tpg0LSktUhcpiQR84MTxRgZBzLwbV9eUnifVMieGORaPCPYQ= X-MS-TrafficTypeDiagnostic: AS8PR03MB7381: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: hgTg8Z5ZnpE4SMjPWl9q+5ru2KZlI3DRjFFTCybZrMVdKHigreSxcZMz8exYvREFxlG1CenWuxZ4A5k9XzWb4B8NUXIvWoKklevMeC96fb0NWRRbkrlRveg83qMavTBuGMjZMZ7/sQvw9jf25i2Q4mRdj7uoFgePeFavu3r/FupeS9gmtXicP0GUWALI5QZ0mI2BV+4GHjF4hl9XYI3dXYqx9o2y9jKbGvkzXY+nrngnaU/5gjmuqkmrzji1aJYfP/ht9NXD3cKQRwM3L7sH79XwTFrRmYmgf4AgZ9g0MU6NyKnP84UAMvQzw1zJiY0cRgcXv9MoI7czsJmdoakXGp1W2tbUjlpZdrwEiS5BYcTB0YVTbR+7QArq0s1EoLgL+yD3etCHX5+oM8XQZq/5YkHKsTenHwaXNFGPijOG9OiJ4GFnAp4TNJNu1Nq+tG2L X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: hNHydKHDk8doe8DMdv7bbT6/PNruppHRLawqVAtPteS+6RdjVBIvEXDWGhP6OZBP1U3TmmeT+nYP7zLCTKqpqHAmymWEwXdgcBWei/0S8ize0z3gYocXP9gwhf1nbZBn96WNrLBG5kbTG/9O0P+/6g== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 826eb0b0-c253-4b01-825a-08d95db4201a X-MS-Exchange-CrossTenant-AuthSource: AM7PR03MB6660.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Aug 2021 17:10:46.8897 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR03MB7381 Subject: [FFmpeg-devel] [PATCH 1/4] fftools/cmdutils: Use avfilter_pad_count() for AVFilter's number of pads 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: NZ/tviHuOoth Besides being nicer code this also has the advantage of not making assumptions about the internal implementation: While it is documented that the AVFilter.inputs and AVFilter.outputs arrays are terminated by a zeroed sentinel, one is not allowed to infer that one can just check avfilter_pad_get_name(padarray, i) to see whether one has reached the sentinel: It could be that the pointer to the string is contained in a different structure than AVFilterPad that needs to be accessed first: return pad->struct->string. It could be that for small strings an internal buffer in AVFilterPad is used (to avoid a relocation) whereas for longer strings an external string is used; this is useful to avoid relocations: return pad->string_ptr ? pad->string_ptr : pad->interal_string Or it could be that the name has a default value: return pad->name ? pad->name : "default" (This actually made sense for us because the name of most of our AVFilterPads is just "default"; doing so would save lots of relocations.) The only thing one is allowed to infer from the existence of the sentinel is that one is allowed to use avfilter_pad_count() to get the number of pads. Therefore it is used. Signed-off-by: Andreas Rheinhardt --- fftools/cmdutils.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/fftools/cmdutils.c b/fftools/cmdutils.c index 6d0bcd6085..96d38803df 100644 --- a/fftools/cmdutils.c +++ b/fftools/cmdutils.c @@ -1707,12 +1707,14 @@ int show_filters(void *optctx, const char *opt, const char *arg) while ((filter = av_filter_iterate(&opaque))) { descr_cur = descr; for (i = 0; i < 2; i++) { + unsigned nb_pads; if (i) { *(descr_cur++) = '-'; *(descr_cur++) = '>'; } pad = i ? filter->outputs : filter->inputs; - for (j = 0; pad && avfilter_pad_get_name(pad, j); j++) { + nb_pads = avfilter_pad_count(pad); + for (j = 0; j < nb_pads; j++) { if (descr_cur >= descr + sizeof(descr) - 4) break; *(descr_cur++) = get_media_type_char(avfilter_pad_get_type(pad, j));