From patchwork Mon Mar 25 01:53:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andreas Rheinhardt X-Patchwork-Id: 47417 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:c889:b0:1a3:b6bb:3029 with SMTP id hb9csp930816pzb; Sun, 24 Mar 2024 18:55:02 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCW0jy5icc8KZWg+fAJQ4/PeW61dTb/ITzjEeYvadzD6JHVmTdSNIljR1gMCoA/WDVW9eUMOu3dcuB/e7gFKp5B5p9cbY115i3/hCA== X-Google-Smtp-Source: AGHT+IG39tnGZa1argDcWRTIrcaF/u3APfZ+rSVQYMXL/K8qVhKiG7MMzwdxBTAopWJ3AazK4Hf9 X-Received: by 2002:a17:907:9716:b0:a47:4f67:7085 with SMTP id jg22-20020a170907971600b00a474f677085mr2367309ejc.1.1711331702479; Sun, 24 Mar 2024 18:55: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 g3-20020a1709063b0300b00a46a6459f50si2052373ejf.783.2024.03.24.18.55.02; Sun, 24 Mar 2024 18:55: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=NK0uLtki; 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 63CA268D4C3; Mon, 25 Mar 2024 03:54:01 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-vi1eur04olkn2070.outbound.protection.outlook.com [40.92.75.70]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id D70CE68D33F for ; Mon, 25 Mar 2024 03:53:49 +0200 (EET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=D3GutrElmPkdquCeTKy5ESTrrs0EBAEbFZKCJI+3r/vfBN72jLmi+N0UoHeGrTOUgYsrPj7AO4V2RMQZ+pkLKcsBy7g7lP/2pavzTQAFpvkblPjtqya9h/vAv0ceif9mGfRC/00CqrJ/IpApyTx2itGTkM1NL0mwnDI7xiA+POB+Q1cEzajPkRjAq3QMF62oUetPmgud/S1F/CjY8ZT7xrsnxZPpTB7NXcOxeKbcqt4VJ77bxlVqAUyZ/b71XAq4yEo07D3Agghxb+ihPVejFk/YbXsxASXBXFkoT/ZkPYIyvBuTQCbIU8AwFPYT2qjFtfYLCJhMo2NM9ivGgvaTTg== 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=m7OVczz6ePek7nhUSjD9cZAm+mRgGwJPTkKNhtJVYEE=; b=PdWbBhslyfy7oxnOFQmgyhPac9wQkkQ4wMQPk7gPPuBLEIwXYY9YJAjRbBbzgd+K+KetxXOhCtuDe7bBsNLsCcx2nipPdYUeftM1ygE0LEyAcu2WDE3Bcy3HOcb1Zs+yA2XLgOw3pp0feivuTFYpT074g7je/z8L3OECF19tPP1eKvZzKT3hAzG8uMiC7vPn1/aFZYl4Pon20kgHEGnJUIX6sMDjWn4m1Qrc+o0GdiTz/ST/HNStJJw8PdRH1EPEMjbcqizBcK/ODagcEtANP5MIt7+1uBvjmszra51Jd9Et78h2sPQNVAsyVlkOchueGRf1e5M3959qtuVbEXo3aA== 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=m7OVczz6ePek7nhUSjD9cZAm+mRgGwJPTkKNhtJVYEE=; b=NK0uLtkio6w975lz0nSOa+wmzkzhS6sxFD96FjpA7vnfcMAfqTgRc7/X8d6Vh65PstsCaylUxybNYOBTmPqGG6ZFcSfFeC9di7Ve8G81nLJpgtFxdYJQY323OBtgp66yBa53P5Zl1YJnrWNlCMsISlOo61lQVJI8fbxUFQNr67E+A4btjFpRGeBFjwZrOpA4M6TlScKG0KE6jFEejOr3HBChJWFZenlukW3hZD5vhvfxym7G6jdOMZdrOq0hS8E8kUNf/4siPH+3g/fAKcpCeoJUp2+vR43r4b2hpQYaajXB7v34pxh3ufcSAdQb1nEWzYggCyVgdhKBhSA5q1H/oQ== Received: from GV1P250MB0737.EURP250.PROD.OUTLOOK.COM (2603:10a6:150:8e::17) by AS8P250MB0118.EURP250.PROD.OUTLOOK.COM (2603:10a6:20b:371::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7409.31; Mon, 25 Mar 2024 01:53:40 +0000 Received: from GV1P250MB0737.EURP250.PROD.OUTLOOK.COM ([fe80::4a3b:cf76:cddc:c68d]) by GV1P250MB0737.EURP250.PROD.OUTLOOK.COM ([fe80::4a3b:cf76:cddc:c68d%4]) with mapi id 15.20.7409.028; Mon, 25 Mar 2024 01:53:40 +0000 From: Andreas Rheinhardt To: ffmpeg-devel@ffmpeg.org Date: Mon, 25 Mar 2024 02:53:20 +0100 Message-ID: X-Mailer: git-send-email 2.40.1 In-Reply-To: References: X-TMN: [VY767E7UxrD++DEda21Ni5CR0oHc+tQPQ8x1YFKtrHo=] X-ClientProxiedBy: FR3P281CA0202.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:a5::6) To GV1P250MB0737.EURP250.PROD.OUTLOOK.COM (2603:10a6:150:8e::17) X-Microsoft-Original-Message-ID: <20240325015324.2348789-5-andreas.rheinhardt@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: GV1P250MB0737:EE_|AS8P250MB0118:EE_ X-MS-Office365-Filtering-Correlation-Id: 3f9379d7-53b3-47a0-8a09-08dc4c6e64c5 X-MS-Exchange-SLBlob-MailProps: quCBMN2EvO8nEvIMEUDP6I+v1XzAyT3i44V/i6IBIWWKjZkQZXHfW/J1878ha84BwrMOO79X9A+ifP090XVxAbcjJ34JiyPqwFq/Bopiz5MMXn/EZjM7RB6j2LnygdQlvb7YzDvUP2rd9TX+2CRdYqmsl9/G3nWv3ynja+nbuOfaPaVkeq/2iYamBfIrsBnprB5SBMB73NNYY3aJIJiEPR4GSvhsBWbxO+W7hEr85IWHeIN8NRPuwEN2eZZ4BpoNZl3HomzIRt9hzUcgVrjwo+rxrFSb9J2KVMz9je5qLO2sojzu8smIP4Xsa/VaMIFImIR/uC8kAIvxD9uV9g/QDfnb0fDH9f8LtlagODldv4Aet+WY/fnDtlAbdT89Tpfx3zdhU2gmB/blG+QiDqelwy514Wut7r2AlQCCdQ81MhYQh7ILItQyDb1DSpajUXBA/qcndgOcswzAEQrsMOMtm3kFJe1eVj0up6y+QdpRCwDRxpjNxoe77z5P4bbALfatSbYjK0YmizOcDQecuVmHLwl1QhT97DJKaKZOBdO+Hb1eaN8yb1pGIAvf3LV0HtTweWGNs1ZSRUib5C0NAi4kpUL4g9z9+fm1i2HOxhLuOWh8YFUftOz5P9NLQ4bsVAo2x4PMFltXHEm6OZQywaEC/P7G3ZfnRC+EN5kbUbnw8Ghc2ncUCcXBXSmI/JN3RK6UamAcUZM9QsjO635I66yypQ== X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: xIEB+aLYcvnLw7JC27pWJFnFWodJ8j1CcTBgTIpZJAs88L29MDntwIJgzk6oiokdFJFdCMwCL7Yft69E9FjgPeFVAUjZcBXhOZF4jo1KZ9t79E48UYwzJ72gm8wutw9IF//vAydjGBsS1KYi3Yj363+9eHy/UlNPlFuIrzurRE/OYMle/ySJojtjb89KD30iQa9GXdZfO30Am4bfbl1LfYoVZeQ030flQap1MapCLXt8P9Qrk14mRwnwK7MlKiWh70mq6pJqZCb9E0VOuK6Mm3BqigqSvPx19fFVWwPU1ezM6NW6QA79eQHiV1zPSBOAvB2w/3DbuXAetHzTk1x/Fmu6akgIp3iWcx0u6iwhfi7RN78yVqAsKNK5iA+XXBzbc+krsdqQriMBpOAi0FxJP/Fb0V3liokL9SyiopoGRtOr8P6un60aA61biX3xXciATcNjOlYVf2rBUUCCWtcdoyY7LLgLW3Lj7ulxnNdL2QdTkvwwcGFYBZAki/6a7s+oqCtdl7a3jNiPa3/BCEP8afv/855l7dkutjZCl5r1UtnjuMMwDkkSBBQiOgXZTXsM7P/NkXwKEwijNDUsNz+lTBGNGq543Zj0vwimZI9o0bxnf+LwsE7EUm2hDzbllND1 X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: So0ovtMWCmLXCznWiP7uSytMBCnyWnraSLajUcPxVhqE0U2rIXTnW1FYifvO4wH9GEhPJejfDWyVe3fc0vqrx/wF6eZa0oMtaKCQFgX+qbMAZGofURqYeQDRxpVKrijQauT6Fanhe5bsasmpCbxCZtmThYLhySPqOtmAjN5YkSAVsztO8tPQJfGCsIPb2YRaGZVU84itKCJveXK1FUmfOcRgEhKksriBSMkh+tTUaTZkwwhQATXwhUgfihOJWOX4tQ68ubl8gsBirgC20dByN+fURoUXTnqt6LfoNkUg50EAodJMeUnED3VFXTx/yAKpWix40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-AuthSource: GV1P250MB0737.EURP250.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Mar 2024 01:53:40.2364 (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: AS8P250MB0118 Subject: [FFmpeg-devel] [PATCH 06/10] avcodec/ratecontrol: Avoid function pointer casts 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: x2VkX31hLTuP It is undefined behaviour to call a function with a different signature for the call than the actual function signature; there are no exceptions for void* and RateControlEntry*. Signed-off-by: Andreas Rheinhardt --- libavcodec/ratecontrol.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/libavcodec/ratecontrol.c b/libavcodec/ratecontrol.c index 1e861e20c1..1ff209c00b 100644 --- a/libavcodec/ratecontrol.c +++ b/libavcodec/ratecontrol.c @@ -79,6 +79,11 @@ static inline double qp2bits(RateControlEntry *rce, double qp) return rce->qscale * (double)(rce->i_tex_bits + rce->p_tex_bits + 1) / qp; } +static double qp2bits_cb(void *rce, double qp) +{ + return qp2bits(rce, qp); +} + static inline double bits2qp(RateControlEntry *rce, double bits) { if (bits < 0.9) { @@ -87,6 +92,11 @@ static inline double bits2qp(RateControlEntry *rce, double bits) return rce->qscale * (double)(rce->i_tex_bits + rce->p_tex_bits + 1) / bits; } +static double bits2qp_cb(void *rce, double qp) +{ + return bits2qp(rce, qp); +} + static double get_diff_limited_q(MpegEncContext *s, RateControlEntry *rce, double q) { RateControlContext *rcc = &s->rc_context; @@ -507,8 +517,8 @@ av_cold int ff_rate_control_init(MpegEncContext *s) NULL }; static double (* const func1[])(void *, double) = { - (double (*)(void *, double)) bits2qp, - (double (*)(void *, double)) qp2bits, + bits2qp_cb, + qp2bits_cb, NULL }; static const char * const func1_names[] = {