From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id 0EA2D4444D for ; Sat, 10 Sep 2022 16:34:51 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 9D2B868BB26; Sat, 10 Sep 2022 19:34:48 +0300 (EEST) Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05olkn2033.outbound.protection.outlook.com [40.92.91.33]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id B71A668B9B2 for ; Sat, 10 Sep 2022 19:34:42 +0300 (EEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=DN5D/WJxqbtfUa5e66ak/qHveS1jN+t33CZW8RhSS6nPpaufEw09UsWQMX34aRQDpCOQiQtM7EDZ+f4fz7ltooemtROF030dAbV5xLY3UHeNXQxWUkOEy9YbV4nqyKK7xQzPzEK0obPkd/LJFXuU80WcMpXHD7bIqlF119vDF9VnUrf52yKcAIdKXMzhRR4tZxiDpTiToNycHA+FTVmx8zToiyeENMvvYSCX+/Athc6Yuv2HMwixULKKtfytym4P0n3Yh46FF5Ovlh521RGTwT2P7Bqvb4t7/iuS4Yag9Wq/Ea1UitXl5I9RtSyliOjy2toRjl6fmskOjObJRxHRQQ== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=R7dW9FLjrQkZNwVT9Dy7jG8z2gT74e7ezGVhou6SUro=; b=XZH5NZyhRUN4gDWxUK2Av/kqZ10TTdElEMh9bEK9F5kRBpVPeSp7npxgbqnQO54k/WJkxy3SWD3pmRfghsbHMvIY1YuOHOCMxyrqx6QeOyiJejgqu/eqrNMeuVj/CwUZiIwFnv9JZeARJb8JdIMtEcvgpXporsyygYY+OFWC8GDgK0BdOQWrzqib4wFqMBkuOSFswf0HhO/PKSMSP5gzCz9mcun61DUWVf1qVgsXJkX7OpBoaTwDAbQwBUcdY4VZhrsqG6fNF/o6NWDEzYd1N8EmkNELqIURDZARnbUdBwVnTRT7B//xXeV2mof6Cla25d2ioTKQneisDt8xvQIarw== 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=R7dW9FLjrQkZNwVT9Dy7jG8z2gT74e7ezGVhou6SUro=; b=p4NFaGFvYJg8HeFqXpfc2TtS0HcyoDuuEf5mS8/B72sXlxyr7g5FGC1x+uC6eCw2BLUmFVk5kM3EcGiNHce+0V0CoePpSZZI8dln5+fX1ndKCfT2Xvf+LI6ggfrciCEVCZDsSe1pKcbagYJ8+d9B6AHDbbfUuyMkxKmp3T6e69wtlslkyWid66eGLpHqQR3ab6yIwRz4GDIAinDo7Vs0GLkMHqcWCWucq4bAyeznzOGpeQuNE8iamiTkXlkkFLGWfpSZRI/WX5SXpTVwO2uKkwZDWZ4pLkmAxwsX13n31+5UaHnYpewxUoTSkeCn+ZLEzk7a3k19i22zAhcJCLyGJA== Received: from AS8P250MB0744.EURP250.PROD.OUTLOOK.COM (2603:10a6:20b:541::14) by GV2P250MB1000.EURP250.PROD.OUTLOOK.COM (2603:10a6:150:da::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5612.16; Sat, 10 Sep 2022 16:34:40 +0000 Received: from AS8P250MB0744.EURP250.PROD.OUTLOOK.COM ([fe80::611e:1608:45cb:b58a]) by AS8P250MB0744.EURP250.PROD.OUTLOOK.COM ([fe80::611e:1608:45cb:b58a%4]) with mapi id 15.20.5612.019; Sat, 10 Sep 2022 16:34:40 +0000 Message-ID: Date: Sat, 10 Sep 2022 18:34:43 +0200 Content-Language: en-US To: ffmpeg-devel@ffmpeg.org References: <20220908173911.GA2088045@pb2> <20220908202528.GB2088045@pb2> <20220909145558.GE2088045@pb2> <20220910152931.GI2088045@pb2> From: Andreas Rheinhardt In-Reply-To: <20220910152931.GI2088045@pb2> X-TMN: [Co940L6/CXUFCGjjgOOMT3j/negObtNHBcjg/Dfgbys=] X-ClientProxiedBy: AS9PR04CA0048.eurprd04.prod.outlook.com (2603:10a6:20b:46a::27) To AS8P250MB0744.EURP250.PROD.OUTLOOK.COM (2603:10a6:20b:541::14) X-Microsoft-Original-Message-ID: MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS8P250MB0744:EE_|GV2P250MB1000:EE_ X-MS-Office365-Filtering-Correlation-Id: 3efca042-d484-4cae-ffa3-08da934a5bf4 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: vHBO3hatGNi4ePUx8/L2aKdurj/IBLQssCB6Q1k8+4Uwsf2EihwVnnz7NXzt3zTZ0u0hg2/SCacKBZuZ5Dp9mxOUJ9Wvt6E8pSUf4S0K4ieYTPMOzmGKkTfmW4PaVL2XqA2zEU9xVxfRP08eyRVCIrkJV7yJyAkXbcmJetINM8HFoE3ZSVJGcfX6uy4Zg7D/3KtEggDIhFLWuF6I+fhDXwN2cENi/HzKZv1TUA4zpg4dhgSG6ENcnKONQ/FBDFqBKd5ZqFE8zB1GIcAY30f18H+rYmWRbW4Ym/EOEqxbTg8T8aDB46x9RkjjQFlTI1q/VrhxVATcz2peYeVJlWg6BLxxFIzYTF0suvvZqbrp46l3sshRjHf7DjjRIBlb/aslpLbZ1riA7u34rTQqx7nqGAvae5wq87zVPWysqfruUNzG7cd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MVVjZFFs?= =?utf-8?B?OEIrNFlBYVZ6azdxV1hzYkF5S0tDL2Zmdk5LWEtKYXZaOFFhSk9jbk4zYWdJ?= =?utf-8?B?RWxUNGtxWmRxdG5nNzd0NTh1ektkUDZlaVptbFBIQTJhUE1OaWlkMjUrTmVJ?= =?utf-8?B?TWRYS2EwUXN2S1FyWTc3c2podHgvS2lOWUZtVFNZYTlJUUJRdkVVSFlPSGFq?= =?utf-8?B?L2VnRGRyVTJ2WlFqTGplaG1ZOXN5UUgrQWlaQ3FVYSttQkttKzB1K1JjcmdQ?= =?utf-8?Q?rmJ0lxecnu0e7f8WV6eeGSgodi+qZynrBsS+lDq?= X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3efca042-d484-4cae-ffa3-08da934a5bf4 X-MS-Exchange-CrossTenant-AuthSource: AS8P250MB0744.EURP250.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 10 Sep 2022 16:34:40.7867 (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: GV2P250MB1000 Subject: Re: [FFmpeg-devel] [PATCH 2/2] swscale/input: Avoid calls to av_pix_fmt_desc_get() 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 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: Michael Niedermayer: > On Fri, Sep 09, 2022 at 08:15:22PM +0200, Andreas Rheinhardt wrote: >> Michael Niedermayer: >>> On Thu, Sep 08, 2022 at 11:44:51PM +0200, Andreas Rheinhardt wrote: >>>> Michael Niedermayer: >>>>> On Thu, Sep 08, 2022 at 09:38:51PM +0200, Andreas Rheinhardt wrote: >>>>>> Michael Niedermayer: >>> [...] >>>>> To me if i look at the evolution >>>>> of isBE() / code checking BE-ness it become more messy over time >>>>> >>>>> I think it would be interresting to think about if we can make >>>>> av_pix_fmt_desc_get(compile time constant) work at compile time. >>>>> or if we maybe can return to a simpler implementation >>>>> >>>> >>>> We could put the av_pix_fmt_descriptors array into an internal header >>>> and use something like >>>> >>>> static av_always_inline const AVPixFmtDescriptor >>>> *ff_pix_fmt_descriptor_get(enum AVPixelFormat fmt) >>>> { >>>> if (av_builtin_constant_p(fmt)) >>>> return &av_pix_fmt_descriptors[fmt]; >>>> return av_pix_fmt_desc_get(fmt); >>>> } >>> >>> yes thats what i was thinking of too. >>> >> >> Seems like Anton is away for a week or so. I am sure he has an opinion >> on the above approach. I think we will wait for him or shall I apply the >> patches as they are given that they do not block any later alternative >> solution? > > please dont apply code like "IS_BE(BE_LE)" > iam sure it makes sense to you today but it requires an additional step > for the reader to understand > simplest is a seperate endianness and isbe variable. on the wrapper > that should be less code too but quite possibly you see a better and > cleaner way > I actually thought that my solution is superior to the one you seem to have in mind; after all, the parameter for isbe is redundant: It can also be derived from the pixfmt-name. > >> (There is one thing I already don't like about the alternative solution: >> It relies on av_builtin_constant_p, which not every compiler supports.) > > Thats why i didnt suggets to use av_builtin_constant_p() i was hoping you > saw a better way to achieve it. > Well, without av_builtin_constant_p() the only other way for this would be to add two systems to get the information, one for compile-time constants and one for not-constants. Ensuring that the former is only used for compile-time constants will be a challenge, to say the least. > But this is a problem which occurs more than once in the codebase. > mapping some identifer to some value just depending on the identifer, > something that is compile time constant, yet it calls to a function to > do a lookup > Another idea from the top of my head: - We could provide some of the info contained in the descriptors via separate defines/enums that parallel the actual enum, like enum AVPixelFormatFlags { AV_PIX_FMT_YUV420P_FLAGS = AV_PIX_FMT_FLAG_PLANAR, AV_PIX_FMT_YUYV422_FLAGS = 0, ... }; The list in pixdesc.c would then use these constants instead of defining the flags twice (to avoid inconsistencies). These constants can be used from macros via fmt ## _FLAGS, avoiding the av_builtin_constant_p() issue. This could even be made public if we add a big warning that new flags may be added in the future. Other such enums for other values may be added, too, but honestly I don't really like this approach. We could also use make an xmacro out of the list in lavu/pixdesc.c and use this xmacro to query the values. E.g. isBE() would then in effect become one big switch: isBE(fmt) { switch (fmt) { case AV_PIX_FMT_YUV420P: return 0; .... } } This could be made to handle non-compile-time constants as well (by having a default that uses av_pix_fmt_desc_get()), but it has a downside: There would be runtime checks for whether we are in the default branch or not. So once again this function should not be used with non-compile time constants. - Andreas _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".