45#ifndef OPENCV_CORE_CVDEF_H
46#define OPENCV_CORE_CVDEF_H
48#include "opencv2/core/version.hpp"
53#ifdef OPENCV_INCLUDE_PORT_FILE
54#include OPENCV_INCLUDE_PORT_FILE
57#if !defined CV_DOXYGEN && !defined CV_IGNORE_DEBUG_BUILD_GUARD
58#if (defined(_MSC_VER) && (defined(DEBUG) || defined(_DEBUG))) || \
59 (defined(_GLIBCXX_DEBUG) || defined(_GLIBCXX_DEBUG_PEDANTIC))
62#define CV__DEBUG_NS_BEGIN namespace debug_build_guard {
63#define CV__DEBUG_NS_END }
64namespace cv {
namespace debug_build_guard { }
using namespace debug_build_guard; }
68#ifndef CV__DEBUG_NS_BEGIN
69#define CV__DEBUG_NS_BEGIN
70#define CV__DEBUG_NS_END
79#define __CV_EXPAND(x) x
83#define __CV_CAT__(x, y) x ## y
84#define __CV_CAT_(x, y) __CV_CAT__(x, y)
85#define __CV_CAT(x, y) __CV_CAT_(x, y)
88#define __CV_VA_NUM_ARGS_HELPER(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, N, ...) N
89#define __CV_VA_NUM_ARGS(...) __CV_EXPAND(__CV_VA_NUM_ARGS_HELPER(__VA_ARGS__, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0))
93#elif defined __GNUC__ || (defined (__cpluscplus) && (__cpluscplus >= 201103))
94#define CV_Func __func__
95#elif defined __clang__ && (__clang_minor__ * 100 + __clang_major__ >= 305)
96#define CV_Func __func__
97#elif defined(__STDC_VERSION__) && (__STDC_VERSION >= 199901)
98#define CV_Func __func__
100#define CV_Func __FUNCTION__
101#elif defined(__INTEL_COMPILER) && (_INTEL_COMPILER >= 600)
102#define CV_Func __FUNCTION__
103#elif defined __IBMCPP__ && __IBMCPP__ >=500
104#define CV_Func __FUNCTION__
105#elif defined __BORLAND__ && (__BORLANDC__ >= 0x550)
106#define CV_Func __FUNC__
108#define CV_Func "<unknown>"
114#define CVAUX_CONCAT_EXP(a, b) a##b
115#define CVAUX_CONCAT(a, b) CVAUX_CONCAT_EXP(a,b)
117#if defined(__clang__)
118# ifndef __has_extension
119# define __has_extension __has_feature
121# if __has_extension(cxx_static_assert)
122# define CV_StaticAssert(condition, reason) static_assert((condition), reason " " #condition)
123# elif __has_extension(c_static_assert)
124# define CV_StaticAssert(condition, reason) _Static_assert((condition), reason " " #condition)
126#elif defined(__GNUC__)
127# if (defined(__GXX_EXPERIMENTAL_CXX0X__) || __cplusplus >= 201103L)
128# define CV_StaticAssert(condition, reason) static_assert((condition), reason " " #condition)
130#elif defined(_MSC_VER)
132# define CV_StaticAssert(condition, reason) static_assert((condition), reason " " #condition)
135#ifndef CV_StaticAssert
136# if !defined(__clang__) && defined(__GNUC__) && (__GNUC__*100 + __GNUC_MINOR__ > 302)
137# define CV_StaticAssert(condition, reason) ({ extern int __attribute__((error("CV_StaticAssert: " reason " " #condition))) CV_StaticAssert(); ((condition) ? 0 : CV_StaticAssert()); })
140 template <
bool x>
struct CV_StaticAssert_failed;
141 template <>
struct CV_StaticAssert_failed<true> {
enum { val = 1 }; };
142 template<
int x>
struct CV_StaticAssert_test {};
144# define CV_StaticAssert(condition, reason)\
145 typedef cv::CV_StaticAssert_test< sizeof(cv::CV_StaticAssert_failed< static_cast<bool>(condition) >) > CVAUX_CONCAT(CV_StaticAssert_failed_at_, __LINE__)
151 #define CV_DO_PRAGMA(x) __pragma(x)
152#elif defined(__GNUC__)
153 #define CV_DO_PRAGMA(x) _Pragma (#x)
155 #define CV_DO_PRAGMA(x)
159#define CV_SUPPRESS_DEPRECATED_START \
160 CV_DO_PRAGMA(warning(push)) \
161 CV_DO_PRAGMA(warning(disable: 4996))
162#define CV_SUPPRESS_DEPRECATED_END CV_DO_PRAGMA(warning(pop))
163#elif defined (__clang__) || ((__GNUC__) && (__GNUC__*100 + __GNUC_MINOR__ > 405))
164#define CV_SUPPRESS_DEPRECATED_START \
165 CV_DO_PRAGMA(GCC diagnostic push) \
166 CV_DO_PRAGMA(GCC diagnostic ignored "-Wdeprecated-declarations")
167#define CV_SUPPRESS_DEPRECATED_END CV_DO_PRAGMA(GCC diagnostic pop)
169#define CV_SUPPRESS_DEPRECATED_START
170#define CV_SUPPRESS_DEPRECATED_END
173#define CV_UNUSED(name) (void)name
184#if defined __cplusplus
190#include "opencv2/core/hal/interface.h"
200#elif defined __INTEL_COMPILER
201# define CV_ICC __INTEL_COMPILER
205# define CV_CDECL __cdecl
206# define CV_STDCALL __stdcall
213# if defined __cplusplus
214# define CV_INLINE static inline
215# elif defined _MSC_VER
216# define CV_INLINE __inline
218# define CV_INLINE static
222#ifndef CV_ALWAYS_INLINE
223#if defined(__GNUC__) && (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1))
224#define CV_ALWAYS_INLINE inline __attribute__((always_inline))
225#elif defined(_MSC_VER)
226#define CV_ALWAYS_INLINE __forceinline
228#define CV_ALWAYS_INLINE inline
232#if defined CV_DISABLE_OPTIMIZATION || (defined CV_ICC && !defined CV_ENABLE_UNROLLED)
233# define CV_ENABLE_UNROLLED 0
235# define CV_ENABLE_UNROLLED 1
239# define CV_DECL_ALIGNED(x) __attribute__ ((aligned (x)))
240#elif defined _MSC_VER
241# define CV_DECL_ALIGNED(x) __declspec(align(x))
243# define CV_DECL_ALIGNED(x)
252#define CV_CPU_SSSE3 5
253#define CV_CPU_SSE4_1 6
254#define CV_CPU_SSE4_2 7
255#define CV_CPU_POPCNT 8
258#define CV_CPU_AVX2 11
259#define CV_CPU_FMA3 12
261#define CV_CPU_AVX_512F 13
262#define CV_CPU_AVX_512BW 14
263#define CV_CPU_AVX_512CD 15
264#define CV_CPU_AVX_512DQ 16
265#define CV_CPU_AVX_512ER 17
266#define CV_CPU_AVX_512IFMA512 18
267#define CV_CPU_AVX_512IFMA 18
268#define CV_CPU_AVX_512PF 19
269#define CV_CPU_AVX_512VBMI 20
270#define CV_CPU_AVX_512VL 21
271#define CV_CPU_AVX_512VBMI2 22
272#define CV_CPU_AVX_512VNNI 23
273#define CV_CPU_AVX_512BITALG 24
274#define CV_CPU_AVX_512VPOPCNTDQ 25
275#define CV_CPU_AVX_5124VNNIW 26
276#define CV_CPU_AVX_5124FMAPS 27
278#define CV_CPU_NEON 100
279#define CV_CPU_NEON_DOTPROD 101
280#define CV_CPU_NEON_FP16 102
281#define CV_CPU_NEON_BF16 103
283#define CV_CPU_MSA 150
285#define CV_CPU_RISCVV 170
287#define CV_CPU_VSX 200
288#define CV_CPU_VSX3 201
290#define CV_CPU_RVV 210
292#define CV_CPU_LSX 230
293#define CV_CPU_LASX 231
296#define CV_CPU_AVX512_SKX 256
297#define CV_CPU_AVX512_COMMON 257
298#define CV_CPU_AVX512_KNL 258
299#define CV_CPU_AVX512_KNM 259
300#define CV_CPU_AVX512_CNL 260
301#define CV_CPU_AVX512_CLX 261
302#define CV_CPU_AVX512_ICL 262
305#define CV_HARDWARE_MAX_FEATURE 512
369#include "cv_cpu_dispatch.h"
371#if !defined(CV_STRONG_ALIGNMENT) && defined(__arm__) && !(defined(__aarch64__) || defined(_M_ARM64))
373#define CV_STRONG_ALIGNMENT 1
375#if !defined(CV_STRONG_ALIGNMENT)
376#define CV_STRONG_ALIGNMENT 0
380#define CV_PI 3.1415926535897932384626433832795
381#define CV_2PI 6.283185307179586476925286766559
382#define CV_LOG2 0.69314718055994530941723212145818
384#if defined __ARM_FP16_FORMAT_IEEE \
385 && !defined __CUDACC__
386# define CV_FP16_TYPE 1
388# define CV_FP16_TYPE 0
417#ifndef OPENCV_ABI_COMPATIBILITY
418#define OPENCV_ABI_COMPATIBILITY 400
422# define DISABLE_OPENCV_3_COMPATIBILITY
423# define OPENCV_DISABLE_DEPRECATED_COMPATIBILITY
427# if (defined _WIN32 || defined WINCE || defined __CYGWIN__) && defined(CVAPI_EXPORTS)
428# define CV_EXPORTS __declspec(dllexport)
429# elif defined __GNUC__ && __GNUC__ >= 4 && (defined(CVAPI_EXPORTS) || defined(__APPLE__))
430# define CV_EXPORTS __attribute__ ((visibility ("default")))
439# define CV_EXPORTS_TEMPLATE
441# define CV_EXPORTS_TEMPLATE CV_EXPORTS
445# if defined(__GNUC__)
446# define CV_DEPRECATED __attribute__ ((deprecated))
447# elif defined(_MSC_VER)
448# define CV_DEPRECATED __declspec(deprecated)
450# define CV_DEPRECATED
454#ifndef CV_DEPRECATED_EXTERNAL
455# if defined(__OPENCV_BUILD)
456# define CV_DEPRECATED_EXTERNAL
458# define CV_DEPRECATED_EXTERNAL CV_DEPRECATED
465# define CV_EXTERN_C extern "C"
472#define CV_EXPORTS_W CV_EXPORTS
473#define CV_EXPORTS_W_SIMPLE CV_EXPORTS
474#define CV_EXPORTS_AS(synonym) CV_EXPORTS
475#define CV_EXPORTS_W_MAP CV_EXPORTS
476#define CV_EXPORTS_W_PARAMS CV_EXPORTS
482#define CV_WRAP_AS(synonym)
483#define CV_WRAP_MAPPABLE(mappable)
484#define CV_WRAP_PHANTOM(phantom_header)
485#define CV_WRAP_DEFAULT(val)
487#define CV_WRAP_FILE_PATH
494#define CV_MAT_CN_MASK ((CV_CN_MAX - 1) << CV_CN_SHIFT)
495#define CV_MAT_CN(flags) ((((flags) & CV_MAT_CN_MASK) >> CV_CN_SHIFT) + 1)
496#define CV_MAT_TYPE_MASK (CV_DEPTH_MAX*CV_CN_MAX - 1)
497#define CV_MAT_TYPE(flags) ((flags) & CV_MAT_TYPE_MASK)
498#define CV_MAT_CONT_FLAG_SHIFT 14
499#define CV_MAT_CONT_FLAG (1 << CV_MAT_CONT_FLAG_SHIFT)
500#define CV_IS_MAT_CONT(flags) ((flags) & CV_MAT_CONT_FLAG)
501#define CV_IS_CONT_MAT CV_IS_MAT_CONT
502#define CV_SUBMAT_FLAG_SHIFT 15
503#define CV_SUBMAT_FLAG (1 << CV_SUBMAT_FLAG_SHIFT)
504#define CV_IS_SUBMAT(flags) ((flags) & CV_MAT_SUBMAT_FLAG)
508#define CV_ELEM_SIZE1(type) ((0x28442211 >> CV_MAT_DEPTH(type)*4) & 15)
510#define CV_ELEM_SIZE(type) (CV_MAT_CN(type)*CV_ELEM_SIZE1(type))
513# define MIN(a,b) ((a) > (b) ? (b) : (a))
517# define MAX(a,b) ((a) < (b) ? (b) : (a))
521#define CV_IMIN(a, b) ((a) ^ (((a)^(b)) & (((a) < (b)) - 1)))
522#define CV_IMAX(a, b) ((a) ^ (((a)^(b)) & (((a) > (b)) - 1)))
523#define CV_SWAP(a,b,t) ((t) = (a), (a) = (b), (b) = (t))
524#define CV_CMP(a,b) (((a) > (b)) - ((a) < (b)))
525#define CV_SIGN(a) CV_CMP((a),0)
543#define __CV_ENUM_CLASS_EXPOSE_1(EnumType, MEMBER_CONST) \
544static const EnumType MEMBER_CONST = EnumType::MEMBER_CONST; \
546#define __CV_ENUM_CLASS_EXPOSE_2(EnumType, MEMBER_CONST, ...) \
547__CV_ENUM_CLASS_EXPOSE_1(EnumType, MEMBER_CONST); \
548__CV_EXPAND(__CV_ENUM_CLASS_EXPOSE_1(EnumType, __VA_ARGS__)); \
550#define __CV_ENUM_CLASS_EXPOSE_3(EnumType, MEMBER_CONST, ...) \
551__CV_ENUM_CLASS_EXPOSE_1(EnumType, MEMBER_CONST); \
552__CV_EXPAND(__CV_ENUM_CLASS_EXPOSE_2(EnumType, __VA_ARGS__)); \
554#define __CV_ENUM_CLASS_EXPOSE_4(EnumType, MEMBER_CONST, ...) \
555__CV_ENUM_CLASS_EXPOSE_1(EnumType, MEMBER_CONST); \
556__CV_EXPAND(__CV_ENUM_CLASS_EXPOSE_3(EnumType, __VA_ARGS__)); \
558#define __CV_ENUM_CLASS_EXPOSE_5(EnumType, MEMBER_CONST, ...) \
559__CV_ENUM_CLASS_EXPOSE_1(EnumType, MEMBER_CONST); \
560__CV_EXPAND(__CV_ENUM_CLASS_EXPOSE_4(EnumType, __VA_ARGS__)); \
562#define __CV_ENUM_CLASS_EXPOSE_6(EnumType, MEMBER_CONST, ...) \
563__CV_ENUM_CLASS_EXPOSE_1(EnumType, MEMBER_CONST); \
564__CV_EXPAND(__CV_ENUM_CLASS_EXPOSE_5(EnumType, __VA_ARGS__)); \
566#define __CV_ENUM_CLASS_EXPOSE_7(EnumType, MEMBER_CONST, ...) \
567__CV_ENUM_CLASS_EXPOSE_1(EnumType, MEMBER_CONST); \
568__CV_EXPAND(__CV_ENUM_CLASS_EXPOSE_6(EnumType, __VA_ARGS__)); \
570#define __CV_ENUM_CLASS_EXPOSE_8(EnumType, MEMBER_CONST, ...) \
571__CV_ENUM_CLASS_EXPOSE_1(EnumType, MEMBER_CONST); \
572__CV_EXPAND(__CV_ENUM_CLASS_EXPOSE_7(EnumType, __VA_ARGS__)); \
574#define __CV_ENUM_CLASS_EXPOSE_9(EnumType, MEMBER_CONST, ...) \
575__CV_ENUM_CLASS_EXPOSE_1(EnumType, MEMBER_CONST); \
576__CV_EXPAND(__CV_ENUM_CLASS_EXPOSE_8(EnumType, __VA_ARGS__)); \
578#define __CV_ENUM_FLAGS_LOGICAL_NOT(EnumType) \
579static inline bool operator!(const EnumType& val) \
581 typedef std::underlying_type<EnumType>::type UnderlyingType; \
582 return !static_cast<UnderlyingType>(val); \
585#define __CV_ENUM_FLAGS_LOGICAL_NOT_EQ(Arg1Type, Arg2Type) \
586static inline bool operator!=(const Arg1Type& a, const Arg2Type& b) \
588 return static_cast<int>(a) != static_cast<int>(b); \
591#define __CV_ENUM_FLAGS_LOGICAL_EQ(Arg1Type, Arg2Type) \
592static inline bool operator==(const Arg1Type& a, const Arg2Type& b) \
594 return static_cast<int>(a) == static_cast<int>(b); \
597#define __CV_ENUM_FLAGS_BITWISE_NOT(EnumType) \
598static inline EnumType operator~(const EnumType& val) \
600 typedef std::underlying_type<EnumType>::type UnderlyingType; \
601 return static_cast<EnumType>(~static_cast<UnderlyingType>(val)); \
604#define __CV_ENUM_FLAGS_BITWISE_OR(EnumType, Arg1Type, Arg2Type) \
605static inline EnumType operator|(const Arg1Type& a, const Arg2Type& b) \
607 typedef std::underlying_type<EnumType>::type UnderlyingType; \
608 return static_cast<EnumType>(static_cast<UnderlyingType>(a) | static_cast<UnderlyingType>(b)); \
611#define __CV_ENUM_FLAGS_BITWISE_AND(EnumType, Arg1Type, Arg2Type) \
612static inline EnumType operator&(const Arg1Type& a, const Arg2Type& b) \
614 typedef std::underlying_type<EnumType>::type UnderlyingType; \
615 return static_cast<EnumType>(static_cast<UnderlyingType>(a) & static_cast<UnderlyingType>(b)); \
618#define __CV_ENUM_FLAGS_BITWISE_XOR(EnumType, Arg1Type, Arg2Type) \
619static inline EnumType operator^(const Arg1Type& a, const Arg2Type& b) \
621 typedef std::underlying_type<EnumType>::type UnderlyingType; \
622 return static_cast<EnumType>(static_cast<UnderlyingType>(a) ^ static_cast<UnderlyingType>(b)); \
625#define __CV_ENUM_FLAGS_BITWISE_OR_EQ(EnumType, Arg1Type) \
626static inline EnumType& operator|=(EnumType& _this, const Arg1Type& val) \
628 _this = static_cast<EnumType>(static_cast<int>(_this) | static_cast<int>(val)); \
632#define __CV_ENUM_FLAGS_BITWISE_AND_EQ(EnumType, Arg1Type) \
633static inline EnumType& operator&=(EnumType& _this, const Arg1Type& val) \
635 _this = static_cast<EnumType>(static_cast<int>(_this) & static_cast<int>(val)); \
639#define __CV_ENUM_FLAGS_BITWISE_XOR_EQ(EnumType, Arg1Type) \
640static inline EnumType& operator^=(EnumType& _this, const Arg1Type& val) \
642 _this = static_cast<EnumType>(static_cast<int>(_this) ^ static_cast<int>(val)); \
646#define CV_ENUM_CLASS_EXPOSE(EnumType, ...) \
647__CV_EXPAND(__CV_CAT(__CV_ENUM_CLASS_EXPOSE_, __CV_VA_NUM_ARGS(__VA_ARGS__))(EnumType, __VA_ARGS__)); \
649#define CV_ENUM_FLAGS(EnumType) \
650__CV_ENUM_FLAGS_LOGICAL_NOT (EnumType) \
651__CV_ENUM_FLAGS_LOGICAL_EQ (EnumType, int) \
652__CV_ENUM_FLAGS_LOGICAL_NOT_EQ (EnumType, int) \
654__CV_ENUM_FLAGS_BITWISE_NOT (EnumType) \
655__CV_ENUM_FLAGS_BITWISE_OR (EnumType, EnumType, EnumType) \
656__CV_ENUM_FLAGS_BITWISE_AND (EnumType, EnumType, EnumType) \
657__CV_ENUM_FLAGS_BITWISE_XOR (EnumType, EnumType, EnumType) \
659__CV_ENUM_FLAGS_BITWISE_OR_EQ (EnumType, EnumType) \
660__CV_ENUM_FLAGS_BITWISE_AND_EQ (EnumType, EnumType) \
661__CV_ENUM_FLAGS_BITWISE_XOR_EQ (EnumType, EnumType) \
669#ifndef CV_STATIC_ANALYSIS
670# if defined(__KLOCWORK__) || defined(__clang_analyzer__) || defined(__COVERITY__)
671# define CV_STATIC_ANALYSIS 1
674# if defined(CV_STATIC_ANALYSIS) && !(__CV_CAT(1, CV_STATIC_ANALYSIS) == 1)
675# if 0 == CV_STATIC_ANALYSIS
676# undef CV_STATIC_ANALYSIS
684#ifndef CV_THREAD_SANITIZER
685# if defined(__has_feature)
686# if __has_feature(thread_sanitizer)
687# define CV_THREAD_SANITIZER
698#elif defined __GNUC__ || defined __clang__
699# if defined __clang__ && __clang_major__ >= 3 && !defined __ANDROID__ && !defined __EMSCRIPTEN__ && !defined(__CUDACC__) && !defined __INTEL_COMPILER
700# ifdef __ATOMIC_ACQ_REL
701# define CV_XADD(addr, delta) __c11_atomic_fetch_add((_Atomic(int)*)(addr), delta, __ATOMIC_ACQ_REL)
703# define CV_XADD(addr, delta) __atomic_fetch_add((_Atomic(int)*)(addr), delta, 4)
706# if defined __ATOMIC_ACQ_REL && !defined __clang__
708# define CV_XADD(addr, delta) (int)__atomic_fetch_add((unsigned*)(addr), (unsigned)(delta), __ATOMIC_ACQ_REL)
710# define CV_XADD(addr, delta) (int)__sync_fetch_and_add((unsigned*)(addr), (unsigned)(delta))
713#elif defined _MSC_VER && !defined RC_INVOKED
715# define CV_XADD(addr, delta) (int)_InterlockedExchangeAdd((long volatile*)addr, delta)
717 #ifdef OPENCV_FORCE_UNSAFE_XADD
718 CV_INLINE int CV_XADD(
int* addr,
int delta) {
int tmp = *addr; *addr +=
delta;
return tmp; }
720 #error "OpenCV: can't define safe CV_XADD macro for current platform (unsupported). Define CV_XADD macro through custom port header (see OPENCV_INCLUDE_PORT_FILE)"
730# if defined(__GNUC__)
731# define CV_NORETURN __attribute__((__noreturn__))
732# elif defined(_MSC_VER) && (_MSC_VER >= 1300)
733# define CV_NORETURN __declspec(noreturn)
743#ifndef CV_NODISCARD_STD
744# ifndef __has_cpp_attribute
746# define __has_cpp_attribute(__x) 0
748# if __has_cpp_attribute(nodiscard)
749# define CV_NODISCARD_STD [[nodiscard]]
750# elif __cplusplus >= 201703L
752# define CV_NODISCARD_STD [[nodiscard]]
753# elif defined(__INTEL_COMPILER)
755# elif defined(_MSC_VER) && _MSC_VER >= 1911 && _MSVC_LANG >= 201703L
757# define CV_NODISCARD_STD [[nodiscard]]
758# elif defined(__GNUC__) && (((__GNUC__ * 100) + __GNUC_MINOR__) >= 700) && (__cplusplus >= 201103L)
760# define CV_NODISCARD_STD [[nodiscard]]
761# elif defined(__GNUC__) && (((__GNUC__ * 100) + __GNUC_MINOR__) >= 408) && (__cplusplus >= 201103L)
766#ifndef CV_NODISCARD_STD
767# define CV_NODISCARD_STD
778# if defined(_MSC_VER)
780# error "OpenCV 4.x+ requires enabled C++11 support"
782# elif __cplusplus < 201103L
783# error "OpenCV 4.x+ requires enabled C++11 support"
792# define CV_OVERRIDE override
796# define CV_FINAL final
800# define CV_NOEXCEPT noexcept
804# define CV_CONSTEXPR constexpr
834 explicit hfloat(
float x) { h = (__fp16)
x; }
835 operator float()
const {
return (
float)h; }
841 explicit hfloat(
float x)
843 #if CV_FP16 && CV_AVX2
844 __m128 v = _mm_load_ss(&
x);
845 w = (
ushort)_mm_cvtsi128_si32(_mm_cvtps_ph(v, 0));
849 unsigned sign = in.
u & 0x80000000;
852 if( in.
u >= 0x47800000 )
853 w = (
ushort)(in.
u > 0x7f800000 ? 0x7e00 : 0x7c00);
856 if (in.
u < 0x38800000)
859 w = (
ushort)(in.
u - 0x3f000000);
863 unsigned t = in.
u + 0xc8000fff;
864 w = (
ushort)((t + ((in.
u >> 13) & 1)) >> 13);
868 w = (
ushort)(w | (sign >> 16));
872 operator float()
const
874 #if CV_FP16 && CV_AVX2
876 _mm_store_ss(&f, _mm_cvtph_ps(_mm_cvtsi32_si128(w)));
881 unsigned t = ((w & 0x7fff) << 13) + 0x38000000;
882 unsigned sign = (w & 0x8000) << 16;
883 unsigned e = w & 0x7c00;
885 out.
u = t + (1 << 23);
886 out.
u = (e >= 0x7c00 ? t + 0x38000000 :
887 e == 0 ? (
static_cast<void>(out.
f -= 6.103515625e-05f), out.
u) : t) | sign;
898inline hfloat hfloatFromBits(
ushort w) {
902 hfloat res(
float(u.h));
907 unsigned t = ((w & 0x7fff) << 13) + 0x38000000;
908 unsigned sign = (w & 0x8000) << 16;
909 unsigned e = w & 0x7c00;
911 out.
u = t + (1 << 23);
912 out.
u = (e >= 0x7c00 ? t + 0x38000000 :
913 e == 0 ? (
static_cast<void>(out.
f -= 6.103515625e-05f), out.
u) : t) | sign;
919#if !defined(__OPENCV_BUILD) && !(defined __STDCPP_FLOAT16_T__) && !(defined __ARM_NEON)
920typedef hfloat float16_t;
929#include "opencv2/core/fast_math.hpp"
const CvArr CvArr * x
Definition core_c.h:1195
int64_t int64
Definition interface.h:61
unsigned short ushort
Definition interface.h:52
uint64_t uint64
Definition interface.h:62
CpuFeatures
Available CPU features.
Definition cvdef.h:309
#define CV_INLINE
Definition cvdef.h:218
@ CPU_AVX_512VBMI2
Definition cvdef.h:333
@ CPU_AVX_512VNNI
Definition cvdef.h:334
@ CPU_AVX2
Definition cvdef.h:320
@ CPU_AVX_512VL
Definition cvdef.h:332
@ CPU_AVX_512DQ
Definition cvdef.h:326
@ CPU_AVX_512IFMA
Definition cvdef.h:329
@ CPU_LASX
Definition cvdef.h:355
@ CPU_POPCNT
Definition cvdef.h:317
@ CPU_NEON_DOTPROD
Definition cvdef.h:341
@ CPU_SSE3
Definition cvdef.h:313
@ CPU_FMA3
Definition cvdef.h:321
@ CPU_AVX512_KNM
Knights Mill with AVX-512F/CD/ER/PF/4FMAPS/4VNNIW/VPOPCNTDQ.
Definition cvdef.h:360
@ CPU_AVX_5124VNNIW
Definition cvdef.h:337
@ CPU_AVX512_CLX
Cascade Lake with AVX-512F/CD/BW/DQ/VL/VNNI.
Definition cvdef.h:362
@ CPU_AVX_512CD
Definition cvdef.h:325
@ CPU_AVX_512IFMA512
Definition cvdef.h:328
@ CPU_AVX512_COMMON
Common instructions AVX-512F/CD for all CPUs that support AVX-512.
Definition cvdef.h:358
@ CPU_AVX512_SKX
Skylake-X with AVX-512F/CD/BW/DQ/VL.
Definition cvdef.h:357
@ CPU_AVX_5124FMAPS
Definition cvdef.h:338
@ CPU_AVX512_KNL
Knights Landing with AVX-512F/CD/ER/PF.
Definition cvdef.h:359
@ CPU_RVV
Definition cvdef.h:352
@ CPU_MAX_FEATURE
Definition cvdef.h:365
@ CPU_SSE
Definition cvdef.h:311
@ CPU_AVX_512ER
Definition cvdef.h:327
@ CPU_SSE4_2
Definition cvdef.h:316
@ CPU_AVX512_CNL
Cannon Lake with AVX-512F/CD/BW/DQ/VL/IFMA/VBMI.
Definition cvdef.h:361
@ CPU_NEON_FP16
Definition cvdef.h:342
@ CPU_NEON
Definition cvdef.h:340
@ CPU_AVX
Definition cvdef.h:319
@ CPU_VSX
Definition cvdef.h:349
@ CPU_MSA
Definition cvdef.h:345
@ CPU_AVX512_ICL
Ice Lake with AVX-512F/CD/BW/DQ/VL/IFMA/VBMI/VNNI/VBMI2/BITALG/VPOPCNTDQ.
Definition cvdef.h:363
@ CPU_NEON_BF16
Definition cvdef.h:343
@ CPU_MMX
Definition cvdef.h:310
@ CPU_SSE4_1
Definition cvdef.h:315
@ CPU_RISCVV
Definition cvdef.h:347
@ CPU_AVX_512BITALG
Definition cvdef.h:335
@ CPU_AVX_512PF
Definition cvdef.h:330
@ CPU_AVX_512BW
Definition cvdef.h:324
@ CPU_VSX3
Definition cvdef.h:350
@ CPU_FP16
Definition cvdef.h:318
@ CPU_AVX_512F
Definition cvdef.h:323
@ CPU_SSSE3
Definition cvdef.h:314
@ CPU_AVX_512VPOPCNTDQ
Definition cvdef.h:336
@ CPU_LSX
Definition cvdef.h:354
@ CPU_SSE2
Definition cvdef.h:312
@ CPU_AVX_512VBMI
Definition cvdef.h:331
CvSize int int int CvPoint int delta
Definition imgproc_c.h:1168
"black box" representation of the file storage associated with a file on disk.
Definition calib3d.hpp:441
ushort u
Definition cvdef.h:394
short i
Definition cvdef.h:393
unsigned u
Definition cvdef.h:404
int i
Definition cvdef.h:403
float f
Definition cvdef.h:405
double f
Definition cvdef.h:413
uint64 u
Definition cvdef.h:412
int64 i
Definition cvdef.h:411