From a5479bf5026913806b6efc6db6b716bc5bba7793 Mon Sep 17 00:00:00 2001 From: Nano Date: Wed, 10 May 2023 19:46:35 +0800 Subject: [PATCH 1/2] fix(wechat_code): Modify `isnan` for compatibility with -ffast_math fix #3150 --- modules/wechat_qrcode/src/zxing/zxing.hpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/modules/wechat_qrcode/src/zxing/zxing.hpp b/modules/wechat_qrcode/src/zxing/zxing.hpp index 76efae22c87..1cfb8f0e3a1 100644 --- a/modules/wechat_qrcode/src/zxing/zxing.hpp +++ b/modules/wechat_qrcode/src/zxing/zxing.hpp @@ -54,8 +54,14 @@ typedef unsigned char boolean; #include namespace zxing { -inline bool isnan(float v) { return std::isnan(v); } -inline bool isnan(double v) { return std::isnan(v); } +inline bool isnan(float v) { + union { float v; uint32_t x; } u = { v }; + return (u.x & 0x7fffffffu) > 0x7f800000u; +} +inline bool isnan(double v) { + union { double v; uint64_t x; } u = { v }; + return (u.x & ~0x8000000000000000uLL) > 0x7ff0000000000000uLL; +} inline float nan() { return std::numeric_limits::quiet_NaN(); } } // namespace zxing From c10eb882a05a96936add671823f7c5b786330138 Mon Sep 17 00:00:00 2001 From: Alexander Smorkalov Date: Tue, 27 Jun 2023 21:48:41 +0300 Subject: [PATCH 2/2] Use OpenCV cvInf/cvNan --- modules/wechat_qrcode/src/zxing/zxing.hpp | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/modules/wechat_qrcode/src/zxing/zxing.hpp b/modules/wechat_qrcode/src/zxing/zxing.hpp index 1cfb8f0e3a1..d735c830f2f 100644 --- a/modules/wechat_qrcode/src/zxing/zxing.hpp +++ b/modules/wechat_qrcode/src/zxing/zxing.hpp @@ -11,6 +11,7 @@ #ifndef __ZXING_ZXING_HPP__ #define __ZXING_ZXING_HPP__ +#include "opencv2/core/fast_math.hpp" #define COUNTER_TYPE short @@ -54,14 +55,8 @@ typedef unsigned char boolean; #include namespace zxing { -inline bool isnan(float v) { - union { float v; uint32_t x; } u = { v }; - return (u.x & 0x7fffffffu) > 0x7f800000u; -} -inline bool isnan(double v) { - union { double v; uint64_t x; } u = { v }; - return (u.x & ~0x8000000000000000uLL) > 0x7ff0000000000000uLL; -} +inline bool isnan(float v) { return (bool)cvIsNaN(v); } +inline bool isnan(double v) { return (bool)cvIsNaN(v); } inline float nan() { return std::numeric_limits::quiet_NaN(); } } // namespace zxing