node-native-win-utils 1.1.0 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (174) hide show
  1. package/README.md +144 -27
  2. package/binding.gyp +18 -5
  3. package/dist/index.d.ts +146 -4
  4. package/dist/index.js +107 -3
  5. package/include/opencv2/core/affine.hpp +678 -0
  6. package/include/opencv2/core/async.hpp +105 -0
  7. package/include/opencv2/core/base.hpp +664 -0
  8. package/include/opencv2/core/bindings_utils.hpp +325 -0
  9. package/include/opencv2/core/bufferpool.hpp +40 -0
  10. package/include/opencv2/core/check.hpp +170 -0
  11. package/include/opencv2/core/core.hpp +48 -0
  12. package/include/opencv2/core/core_c.h +3128 -0
  13. package/include/opencv2/core/cuda/block.hpp +211 -0
  14. package/include/opencv2/core/cuda/border_interpolate.hpp +722 -0
  15. package/include/opencv2/core/cuda/color.hpp +309 -0
  16. package/include/opencv2/core/cuda/common.hpp +131 -0
  17. package/include/opencv2/core/cuda/datamov_utils.hpp +113 -0
  18. package/include/opencv2/core/cuda/detail/color_detail.hpp +2018 -0
  19. package/include/opencv2/core/cuda/detail/reduce.hpp +365 -0
  20. package/include/opencv2/core/cuda/detail/reduce_key_val.hpp +502 -0
  21. package/include/opencv2/core/cuda/detail/transform_detail.hpp +392 -0
  22. package/include/opencv2/core/cuda/detail/type_traits_detail.hpp +191 -0
  23. package/include/opencv2/core/cuda/detail/vec_distance_detail.hpp +121 -0
  24. package/include/opencv2/core/cuda/dynamic_smem.hpp +88 -0
  25. package/include/opencv2/core/cuda/emulation.hpp +269 -0
  26. package/include/opencv2/core/cuda/filters.hpp +293 -0
  27. package/include/opencv2/core/cuda/funcattrib.hpp +79 -0
  28. package/include/opencv2/core/cuda/functional.hpp +805 -0
  29. package/include/opencv2/core/cuda/limits.hpp +128 -0
  30. package/include/opencv2/core/cuda/reduce.hpp +209 -0
  31. package/include/opencv2/core/cuda/saturate_cast.hpp +292 -0
  32. package/include/opencv2/core/cuda/scan.hpp +258 -0
  33. package/include/opencv2/core/cuda/simd_functions.hpp +869 -0
  34. package/include/opencv2/core/cuda/transform.hpp +75 -0
  35. package/include/opencv2/core/cuda/type_traits.hpp +90 -0
  36. package/include/opencv2/core/cuda/utility.hpp +230 -0
  37. package/include/opencv2/core/cuda/vec_distance.hpp +232 -0
  38. package/include/opencv2/core/cuda/vec_math.hpp +923 -0
  39. package/include/opencv2/core/cuda/vec_traits.hpp +288 -0
  40. package/include/opencv2/core/cuda/warp.hpp +139 -0
  41. package/include/opencv2/core/cuda/warp_reduce.hpp +76 -0
  42. package/include/opencv2/core/cuda/warp_shuffle.hpp +162 -0
  43. package/include/opencv2/core/cuda.hpp +1279 -0
  44. package/include/opencv2/core/cuda.inl.hpp +763 -0
  45. package/include/opencv2/core/cuda_stream_accessor.hpp +86 -0
  46. package/include/opencv2/core/cuda_types.hpp +144 -0
  47. package/include/opencv2/core/cv_cpu_dispatch.h +381 -0
  48. package/include/opencv2/core/cv_cpu_helper.h +550 -0
  49. package/include/opencv2/core/cvdef.h +973 -0
  50. package/include/opencv2/core/cvstd.hpp +190 -0
  51. package/include/opencv2/core/cvstd.inl.hpp +197 -0
  52. package/include/opencv2/core/cvstd_wrapper.hpp +154 -0
  53. package/include/opencv2/core/detail/async_promise.hpp +71 -0
  54. package/include/opencv2/core/detail/dispatch_helper.impl.hpp +49 -0
  55. package/include/opencv2/core/detail/exception_ptr.hpp +27 -0
  56. package/include/opencv2/core/directx.hpp +184 -0
  57. package/include/opencv2/core/dualquaternion.hpp +979 -0
  58. package/include/opencv2/core/dualquaternion.inl.hpp +487 -0
  59. package/include/opencv2/core/eigen.hpp +402 -0
  60. package/include/opencv2/core/fast_math.hpp +433 -0
  61. package/include/opencv2/core/hal/hal.hpp +256 -0
  62. package/include/opencv2/core/hal/interface.h +190 -0
  63. package/include/opencv2/core/hal/intrin.hpp +939 -0
  64. package/include/opencv2/core/hal/intrin_avx.hpp +3177 -0
  65. package/include/opencv2/core/hal/intrin_avx512.hpp +3090 -0
  66. package/include/opencv2/core/hal/intrin_cpp.hpp +3321 -0
  67. package/include/opencv2/core/hal/intrin_forward.hpp +191 -0
  68. package/include/opencv2/core/hal/intrin_lasx.hpp +3236 -0
  69. package/include/opencv2/core/hal/intrin_msa.hpp +1887 -0
  70. package/include/opencv2/core/hal/intrin_neon.hpp +2610 -0
  71. package/include/opencv2/core/hal/intrin_rvv.hpp +3320 -0
  72. package/include/opencv2/core/hal/intrin_rvv071.hpp +2545 -0
  73. package/include/opencv2/core/hal/intrin_rvv_scalable.hpp +2080 -0
  74. package/include/opencv2/core/hal/intrin_sse.hpp +3467 -0
  75. package/include/opencv2/core/hal/intrin_sse_em.hpp +180 -0
  76. package/include/opencv2/core/hal/intrin_vsx.hpp +1608 -0
  77. package/include/opencv2/core/hal/intrin_wasm.hpp +2782 -0
  78. package/include/opencv2/core/hal/msa_macros.h +1558 -0
  79. package/include/opencv2/core/hal/simd_utils.impl.hpp +186 -0
  80. package/include/opencv2/core/llapi/llapi.h +102 -0
  81. package/include/opencv2/core/mat.hpp +3775 -0
  82. package/include/opencv2/core/mat.inl.hpp +3422 -0
  83. package/include/opencv2/core/matx.hpp +1536 -0
  84. package/include/opencv2/core/neon_utils.hpp +128 -0
  85. package/include/opencv2/core/ocl.hpp +917 -0
  86. package/include/opencv2/core/ocl_genbase.hpp +69 -0
  87. package/include/opencv2/core/opencl/ocl_defs.hpp +82 -0
  88. package/include/opencv2/core/opencl/opencl_info.hpp +212 -0
  89. package/include/opencv2/core/opencl/opencl_svm.hpp +81 -0
  90. package/include/opencv2/core/opencl/runtime/autogenerated/opencl_clblas.hpp +602 -0
  91. package/include/opencv2/core/opencl/runtime/autogenerated/opencl_clfft.hpp +146 -0
  92. package/include/opencv2/core/opencl/runtime/autogenerated/opencl_core.hpp +371 -0
  93. package/include/opencv2/core/opencl/runtime/autogenerated/opencl_core_wrappers.hpp +272 -0
  94. package/include/opencv2/core/opencl/runtime/autogenerated/opencl_gl.hpp +62 -0
  95. package/include/opencv2/core/opencl/runtime/autogenerated/opencl_gl_wrappers.hpp +42 -0
  96. package/include/opencv2/core/opencl/runtime/opencl_clblas.hpp +53 -0
  97. package/include/opencv2/core/opencl/runtime/opencl_clfft.hpp +53 -0
  98. package/include/opencv2/core/opencl/runtime/opencl_core.hpp +84 -0
  99. package/include/opencv2/core/opencl/runtime/opencl_core_wrappers.hpp +47 -0
  100. package/include/opencv2/core/opencl/runtime/opencl_gl.hpp +53 -0
  101. package/include/opencv2/core/opencl/runtime/opencl_gl_wrappers.hpp +47 -0
  102. package/include/opencv2/core/opencl/runtime/opencl_svm_20.hpp +48 -0
  103. package/include/opencv2/core/opencl/runtime/opencl_svm_definitions.hpp +42 -0
  104. package/include/opencv2/core/opencl/runtime/opencl_svm_hsa_extension.hpp +166 -0
  105. package/include/opencv2/core/opengl.hpp +733 -0
  106. package/include/opencv2/core/openvx/ovx_defs.hpp +48 -0
  107. package/include/opencv2/core/operations.hpp +610 -0
  108. package/include/opencv2/core/optim.hpp +302 -0
  109. package/include/opencv2/core/ovx.hpp +28 -0
  110. package/include/opencv2/core/parallel/backend/parallel_for.openmp.hpp +72 -0
  111. package/include/opencv2/core/parallel/backend/parallel_for.tbb.hpp +153 -0
  112. package/include/opencv2/core/parallel/parallel_backend.hpp +90 -0
  113. package/include/opencv2/core/persistence.hpp +1350 -0
  114. package/include/opencv2/core/private/cv_cpu_include_simd_declarations.hpp +30 -0
  115. package/include/opencv2/core/private.cuda.hpp +169 -0
  116. package/include/opencv2/core/private.hpp +896 -0
  117. package/include/opencv2/core/quaternion.hpp +1696 -0
  118. package/include/opencv2/core/quaternion.inl.hpp +1063 -0
  119. package/include/opencv2/core/saturate.hpp +180 -0
  120. package/include/opencv2/core/simd_intrinsics.hpp +87 -0
  121. package/include/opencv2/core/softfloat.hpp +514 -0
  122. package/include/opencv2/core/sse_utils.hpp +652 -0
  123. package/include/opencv2/core/traits.hpp +417 -0
  124. package/include/opencv2/core/types.hpp +2457 -0
  125. package/include/opencv2/core/types_c.h +2126 -0
  126. package/include/opencv2/core/utility.hpp +1229 -0
  127. package/include/opencv2/core/utils/allocator_stats.hpp +29 -0
  128. package/include/opencv2/core/utils/allocator_stats.impl.hpp +158 -0
  129. package/include/opencv2/core/utils/buffer_area.private.hpp +136 -0
  130. package/include/opencv2/core/utils/configuration.private.hpp +22 -0
  131. package/include/opencv2/core/utils/filesystem.hpp +82 -0
  132. package/include/opencv2/core/utils/filesystem.private.hpp +66 -0
  133. package/include/opencv2/core/utils/fp_control.private.hpp +29 -0
  134. package/include/opencv2/core/utils/fp_control_utils.hpp +69 -0
  135. package/include/opencv2/core/utils/instrumentation.hpp +125 -0
  136. package/include/opencv2/core/utils/lock.private.hpp +119 -0
  137. package/include/opencv2/core/utils/logger.defines.hpp +42 -0
  138. package/include/opencv2/core/utils/logger.hpp +218 -0
  139. package/include/opencv2/core/utils/logtag.hpp +28 -0
  140. package/include/opencv2/core/utils/plugin_loader.private.hpp +165 -0
  141. package/include/opencv2/core/utils/tls.hpp +235 -0
  142. package/include/opencv2/core/utils/trace.hpp +252 -0
  143. package/include/opencv2/core/utils/trace.private.hpp +421 -0
  144. package/include/opencv2/core/va_intel.hpp +75 -0
  145. package/include/opencv2/core/version.hpp +26 -0
  146. package/include/opencv2/core/vsx_utils.hpp +1047 -0
  147. package/include/opencv2/core.hpp +3365 -0
  148. package/include/opencv2/imgcodecs/imgcodecs.hpp +48 -0
  149. package/include/opencv2/imgcodecs/imgcodecs_c.h +1 -0
  150. package/include/opencv2/imgcodecs/ios.h +59 -0
  151. package/include/opencv2/imgcodecs/legacy/constants_c.h +54 -0
  152. package/include/opencv2/imgcodecs/macosx.h +20 -0
  153. package/include/opencv2/imgcodecs.hpp +407 -0
  154. package/include/opencv2/imgproc/bindings.hpp +34 -0
  155. package/include/opencv2/imgproc/detail/gcgraph.hpp +395 -0
  156. package/include/opencv2/imgproc/hal/hal.hpp +246 -0
  157. package/include/opencv2/imgproc/hal/interface.h +46 -0
  158. package/include/opencv2/imgproc/imgproc.hpp +48 -0
  159. package/include/opencv2/imgproc/imgproc_c.h +1177 -0
  160. package/include/opencv2/imgproc/segmentation.hpp +141 -0
  161. package/include/opencv2/imgproc/types_c.h +659 -0
  162. package/include/opencv2/imgproc.hpp +5035 -0
  163. package/include/opencv2/opencv_modules.hpp +17 -0
  164. package/libs/libjpeg-turbo.lib +0 -0
  165. package/libs/libpng.lib +0 -0
  166. package/libs/opencv_core470.lib +0 -0
  167. package/libs/opencv_imgcodecs470.lib +0 -0
  168. package/libs/opencv_imgproc470.lib +0 -0
  169. package/libs/zlib.lib +0 -0
  170. package/package.json +14 -3
  171. package/prebuilds/win32-x64/node.napi.node +0 -0
  172. package/src/cpp/capturewindow.cpp +36 -46
  173. package/src/cpp/main.cpp +10 -2
  174. package/src/cpp/opencv.cpp +425 -0
@@ -0,0 +1,973 @@
1
+ /*M///////////////////////////////////////////////////////////////////////////////////////
2
+ //
3
+ // IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
4
+ //
5
+ // By downloading, copying, installing or using the software you agree to this license.
6
+ // If you do not agree to this license, do not download, install,
7
+ // copy or use the software.
8
+ //
9
+ //
10
+ // License Agreement
11
+ // For Open Source Computer Vision Library
12
+ //
13
+ // Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
14
+ // Copyright (C) 2009, Willow Garage Inc., all rights reserved.
15
+ // Copyright (C) 2013, OpenCV Foundation, all rights reserved.
16
+ // Copyright (C) 2015, Itseez Inc., all rights reserved.
17
+ // Third party copyrights are property of their respective owners.
18
+ //
19
+ // Redistribution and use in source and binary forms, with or without modification,
20
+ // are permitted provided that the following conditions are met:
21
+ //
22
+ // * Redistribution's of source code must retain the above copyright notice,
23
+ // this list of conditions and the following disclaimer.
24
+ //
25
+ // * Redistribution's in binary form must reproduce the above copyright notice,
26
+ // this list of conditions and the following disclaimer in the documentation
27
+ // and/or other materials provided with the distribution.
28
+ //
29
+ // * The name of the copyright holders may not be used to endorse or promote products
30
+ // derived from this software without specific prior written permission.
31
+ //
32
+ // This software is provided by the copyright holders and contributors "as is" and
33
+ // any express or implied warranties, including, but not limited to, the implied
34
+ // warranties of merchantability and fitness for a particular purpose are disclaimed.
35
+ // In no event shall the Intel Corporation or contributors be liable for any direct,
36
+ // indirect, incidental, special, exemplary, or consequential damages
37
+ // (including, but not limited to, procurement of substitute goods or services;
38
+ // loss of use, data, or profits; or business interruption) however caused
39
+ // and on any theory of liability, whether in contract, strict liability,
40
+ // or tort (including negligence or otherwise) arising in any way out of
41
+ // the use of this software, even if advised of the possibility of such damage.
42
+ //
43
+ //M*/
44
+
45
+ #ifndef OPENCV_CORE_CVDEF_H
46
+ #define OPENCV_CORE_CVDEF_H
47
+
48
+ #include "opencv2/core/version.hpp"
49
+
50
+ //! @addtogroup core_utils
51
+ //! @{
52
+
53
+ #ifdef OPENCV_INCLUDE_PORT_FILE // User-provided header file with custom platform configuration
54
+ #include OPENCV_INCLUDE_PORT_FILE
55
+ #endif
56
+
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))
60
+ // Guard to prevent using of binary incompatible binaries / runtimes
61
+ // https://github.com/opencv/opencv/pull/9161
62
+ #define CV__DEBUG_NS_BEGIN namespace debug_build_guard {
63
+ #define CV__DEBUG_NS_END }
64
+ namespace cv { namespace debug_build_guard { } using namespace debug_build_guard; }
65
+ #endif
66
+ #endif
67
+
68
+ #ifndef CV__DEBUG_NS_BEGIN
69
+ #define CV__DEBUG_NS_BEGIN
70
+ #define CV__DEBUG_NS_END
71
+ #endif
72
+
73
+
74
+ #ifdef __OPENCV_BUILD
75
+ #include "cvconfig.h"
76
+ #endif
77
+
78
+ #ifndef __CV_EXPAND
79
+ #define __CV_EXPAND(x) x
80
+ #endif
81
+
82
+ #ifndef __CV_CAT
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)
86
+ #endif
87
+
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))
90
+
91
+ #ifdef CV_Func
92
+ // keep current value (through OpenCV port file)
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__
99
+ #elif defined _MSC_VER
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__
107
+ #else
108
+ #define CV_Func "<unknown>"
109
+ #endif
110
+
111
+ //! @cond IGNORED
112
+
113
+ //////////////// static assert /////////////////
114
+ #define CVAUX_CONCAT_EXP(a, b) a##b
115
+ #define CVAUX_CONCAT(a, b) CVAUX_CONCAT_EXP(a,b)
116
+
117
+ #if defined(__clang__)
118
+ # ifndef __has_extension
119
+ # define __has_extension __has_feature /* compatibility, for older versions of clang */
120
+ # endif
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)
125
+ # endif
126
+ #elif defined(__GNUC__)
127
+ # if (defined(__GXX_EXPERIMENTAL_CXX0X__) || __cplusplus >= 201103L)
128
+ # define CV_StaticAssert(condition, reason) static_assert((condition), reason " " #condition)
129
+ # endif
130
+ #elif defined(_MSC_VER)
131
+ # if _MSC_VER >= 1600 /* MSVC 10 */
132
+ # define CV_StaticAssert(condition, reason) static_assert((condition), reason " " #condition)
133
+ # endif
134
+ #endif
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()); })
138
+ # else
139
+ namespace cv {
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 {};
143
+ }
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__)
146
+ # endif
147
+ #endif
148
+
149
+ // Suppress warning "-Wdeprecated-declarations" / C4996
150
+ #if defined(_MSC_VER)
151
+ #define CV_DO_PRAGMA(x) __pragma(x)
152
+ #elif defined(__GNUC__)
153
+ #define CV_DO_PRAGMA(x) _Pragma (#x)
154
+ #else
155
+ #define CV_DO_PRAGMA(x)
156
+ #endif
157
+
158
+ #ifdef _MSC_VER
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)
168
+ #else
169
+ #define CV_SUPPRESS_DEPRECATED_START
170
+ #define CV_SUPPRESS_DEPRECATED_END
171
+ #endif
172
+
173
+ #define CV_UNUSED(name) (void)name
174
+
175
+ //! @endcond
176
+
177
+ // undef problematic defines sometimes defined by system headers (windows.h in particular)
178
+ #undef small
179
+ #undef min
180
+ #undef max
181
+ #undef abs
182
+ #undef Complex
183
+
184
+ #if defined __cplusplus
185
+ #include <limits>
186
+ #else
187
+ #include <limits.h>
188
+ #endif
189
+
190
+ #include "opencv2/core/hal/interface.h"
191
+
192
+ #if defined __ICL
193
+ # define CV_ICC __ICL
194
+ #elif defined __ICC
195
+ # define CV_ICC __ICC
196
+ #elif defined __ECL
197
+ # define CV_ICC __ECL
198
+ #elif defined __ECC
199
+ # define CV_ICC __ECC
200
+ #elif defined __INTEL_COMPILER
201
+ # define CV_ICC __INTEL_COMPILER
202
+ #endif
203
+
204
+ #ifndef CV_INLINE
205
+ # if defined __cplusplus
206
+ # define CV_INLINE static inline
207
+ # elif defined _MSC_VER
208
+ # define CV_INLINE __inline
209
+ # else
210
+ # define CV_INLINE static
211
+ # endif
212
+ #endif
213
+
214
+ #ifndef CV_ALWAYS_INLINE
215
+ #if defined(__GNUC__) && (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 1))
216
+ #define CV_ALWAYS_INLINE inline __attribute__((always_inline))
217
+ #elif defined(_MSC_VER)
218
+ #define CV_ALWAYS_INLINE __forceinline
219
+ #else
220
+ #define CV_ALWAYS_INLINE inline
221
+ #endif
222
+ #endif
223
+
224
+ #if defined CV_DISABLE_OPTIMIZATION || (defined CV_ICC && !defined CV_ENABLE_UNROLLED)
225
+ # define CV_ENABLE_UNROLLED 0
226
+ #else
227
+ # define CV_ENABLE_UNROLLED 1
228
+ #endif
229
+
230
+ #ifdef __GNUC__
231
+ # define CV_DECL_ALIGNED(x) __attribute__ ((aligned (x)))
232
+ #elif defined _MSC_VER
233
+ # define CV_DECL_ALIGNED(x) __declspec(align(x))
234
+ #else
235
+ # define CV_DECL_ALIGNED(x)
236
+ #endif
237
+
238
+ /* CPU features and intrinsics support */
239
+ #define CV_CPU_NONE 0
240
+ #define CV_CPU_MMX 1
241
+ #define CV_CPU_SSE 2
242
+ #define CV_CPU_SSE2 3
243
+ #define CV_CPU_SSE3 4
244
+ #define CV_CPU_SSSE3 5
245
+ #define CV_CPU_SSE4_1 6
246
+ #define CV_CPU_SSE4_2 7
247
+ #define CV_CPU_POPCNT 8
248
+ #define CV_CPU_FP16 9
249
+ #define CV_CPU_AVX 10
250
+ #define CV_CPU_AVX2 11
251
+ #define CV_CPU_FMA3 12
252
+
253
+ #define CV_CPU_AVX_512F 13
254
+ #define CV_CPU_AVX_512BW 14
255
+ #define CV_CPU_AVX_512CD 15
256
+ #define CV_CPU_AVX_512DQ 16
257
+ #define CV_CPU_AVX_512ER 17
258
+ #define CV_CPU_AVX_512IFMA512 18 // deprecated
259
+ #define CV_CPU_AVX_512IFMA 18
260
+ #define CV_CPU_AVX_512PF 19
261
+ #define CV_CPU_AVX_512VBMI 20
262
+ #define CV_CPU_AVX_512VL 21
263
+ #define CV_CPU_AVX_512VBMI2 22
264
+ #define CV_CPU_AVX_512VNNI 23
265
+ #define CV_CPU_AVX_512BITALG 24
266
+ #define CV_CPU_AVX_512VPOPCNTDQ 25
267
+ #define CV_CPU_AVX_5124VNNIW 26
268
+ #define CV_CPU_AVX_5124FMAPS 27
269
+
270
+ #define CV_CPU_NEON 100
271
+ #define CV_CPU_NEON_DOTPROD 101
272
+
273
+ #define CV_CPU_MSA 150
274
+
275
+ #define CV_CPU_RISCVV 170
276
+
277
+ #define CV_CPU_VSX 200
278
+ #define CV_CPU_VSX3 201
279
+
280
+ #define CV_CPU_RVV 210
281
+
282
+ #define CV_CPU_LASX 230
283
+
284
+ // CPU features groups
285
+ #define CV_CPU_AVX512_SKX 256
286
+ #define CV_CPU_AVX512_COMMON 257
287
+ #define CV_CPU_AVX512_KNL 258
288
+ #define CV_CPU_AVX512_KNM 259
289
+ #define CV_CPU_AVX512_CNL 260
290
+ #define CV_CPU_AVX512_CLX 261
291
+ #define CV_CPU_AVX512_ICL 262
292
+
293
+ // when adding to this list remember to update the following enum
294
+ #define CV_HARDWARE_MAX_FEATURE 512
295
+
296
+ /** @brief Available CPU features.
297
+ */
298
+ enum CpuFeatures {
299
+ CPU_MMX = 1,
300
+ CPU_SSE = 2,
301
+ CPU_SSE2 = 3,
302
+ CPU_SSE3 = 4,
303
+ CPU_SSSE3 = 5,
304
+ CPU_SSE4_1 = 6,
305
+ CPU_SSE4_2 = 7,
306
+ CPU_POPCNT = 8,
307
+ CPU_FP16 = 9,
308
+ CPU_AVX = 10,
309
+ CPU_AVX2 = 11,
310
+ CPU_FMA3 = 12,
311
+
312
+ CPU_AVX_512F = 13,
313
+ CPU_AVX_512BW = 14,
314
+ CPU_AVX_512CD = 15,
315
+ CPU_AVX_512DQ = 16,
316
+ CPU_AVX_512ER = 17,
317
+ CPU_AVX_512IFMA512 = 18, // deprecated
318
+ CPU_AVX_512IFMA = 18,
319
+ CPU_AVX_512PF = 19,
320
+ CPU_AVX_512VBMI = 20,
321
+ CPU_AVX_512VL = 21,
322
+ CPU_AVX_512VBMI2 = 22,
323
+ CPU_AVX_512VNNI = 23,
324
+ CPU_AVX_512BITALG = 24,
325
+ CPU_AVX_512VPOPCNTDQ= 25,
326
+ CPU_AVX_5124VNNIW = 26,
327
+ CPU_AVX_5124FMAPS = 27,
328
+
329
+ CPU_NEON = 100,
330
+ CPU_NEON_DOTPROD = 101,
331
+
332
+ CPU_MSA = 150,
333
+
334
+ CPU_RISCVV = 170,
335
+
336
+ CPU_VSX = 200,
337
+ CPU_VSX3 = 201,
338
+
339
+ CPU_RVV = 210,
340
+
341
+ CPU_LASX = 230,
342
+
343
+ CPU_AVX512_SKX = 256, //!< Skylake-X with AVX-512F/CD/BW/DQ/VL
344
+ CPU_AVX512_COMMON = 257, //!< Common instructions AVX-512F/CD for all CPUs that support AVX-512
345
+ CPU_AVX512_KNL = 258, //!< Knights Landing with AVX-512F/CD/ER/PF
346
+ CPU_AVX512_KNM = 259, //!< Knights Mill with AVX-512F/CD/ER/PF/4FMAPS/4VNNIW/VPOPCNTDQ
347
+ CPU_AVX512_CNL = 260, //!< Cannon Lake with AVX-512F/CD/BW/DQ/VL/IFMA/VBMI
348
+ CPU_AVX512_CLX = 261, //!< Cascade Lake with AVX-512F/CD/BW/DQ/VL/VNNI
349
+ CPU_AVX512_ICL = 262, //!< Ice Lake with AVX-512F/CD/BW/DQ/VL/IFMA/VBMI/VNNI/VBMI2/BITALG/VPOPCNTDQ
350
+
351
+ CPU_MAX_FEATURE = 512 // see CV_HARDWARE_MAX_FEATURE
352
+ };
353
+
354
+
355
+ #include "cv_cpu_dispatch.h"
356
+
357
+ #if !defined(CV_STRONG_ALIGNMENT) && defined(__arm__) && !(defined(__aarch64__) || defined(_M_ARM64))
358
+ // int*, int64* should be propertly aligned pointers on ARMv7
359
+ #define CV_STRONG_ALIGNMENT 1
360
+ #endif
361
+ #if !defined(CV_STRONG_ALIGNMENT)
362
+ #define CV_STRONG_ALIGNMENT 0
363
+ #endif
364
+
365
+ /* fundamental constants */
366
+ #define CV_PI 3.1415926535897932384626433832795
367
+ #define CV_2PI 6.283185307179586476925286766559
368
+ #define CV_LOG2 0.69314718055994530941723212145818
369
+
370
+ #if defined __ARM_FP16_FORMAT_IEEE \
371
+ && !defined __CUDACC__
372
+ # define CV_FP16_TYPE 1
373
+ #else
374
+ # define CV_FP16_TYPE 0
375
+ #endif
376
+
377
+ typedef union Cv16suf
378
+ {
379
+ short i;
380
+ ushort u;
381
+ #if CV_FP16_TYPE
382
+ __fp16 h;
383
+ #endif
384
+ }
385
+ Cv16suf;
386
+
387
+ typedef union Cv32suf
388
+ {
389
+ int i;
390
+ unsigned u;
391
+ float f;
392
+ }
393
+ Cv32suf;
394
+
395
+ typedef union Cv64suf
396
+ {
397
+ int64 i;
398
+ uint64 u;
399
+ double f;
400
+ }
401
+ Cv64suf;
402
+
403
+ #ifndef OPENCV_ABI_COMPATIBILITY
404
+ #define OPENCV_ABI_COMPATIBILITY 400
405
+ #endif
406
+
407
+ #ifdef __OPENCV_BUILD
408
+ # define DISABLE_OPENCV_3_COMPATIBILITY
409
+ # define OPENCV_DISABLE_DEPRECATED_COMPATIBILITY
410
+ #endif
411
+
412
+ #ifndef CV_EXPORTS
413
+ # if (defined _WIN32 || defined WINCE || defined __CYGWIN__) && defined(CVAPI_EXPORTS)
414
+ # define CV_EXPORTS __declspec(dllexport)
415
+ # elif defined __GNUC__ && __GNUC__ >= 4 && (defined(CVAPI_EXPORTS) || defined(__APPLE__))
416
+ # define CV_EXPORTS __attribute__ ((visibility ("default")))
417
+ # endif
418
+ #endif
419
+
420
+ #ifndef CV_EXPORTS
421
+ # define CV_EXPORTS
422
+ #endif
423
+
424
+ #ifdef _MSC_VER
425
+ # define CV_EXPORTS_TEMPLATE
426
+ #else
427
+ # define CV_EXPORTS_TEMPLATE CV_EXPORTS
428
+ #endif
429
+
430
+ #ifndef CV_DEPRECATED
431
+ # if defined(__GNUC__)
432
+ # define CV_DEPRECATED __attribute__ ((deprecated))
433
+ # elif defined(_MSC_VER)
434
+ # define CV_DEPRECATED __declspec(deprecated)
435
+ # else
436
+ # define CV_DEPRECATED
437
+ # endif
438
+ #endif
439
+
440
+ #ifndef CV_DEPRECATED_EXTERNAL
441
+ # if defined(__OPENCV_BUILD)
442
+ # define CV_DEPRECATED_EXTERNAL /* nothing */
443
+ # else
444
+ # define CV_DEPRECATED_EXTERNAL CV_DEPRECATED
445
+ # endif
446
+ #endif
447
+
448
+
449
+ #ifndef CV_EXTERN_C
450
+ # ifdef __cplusplus
451
+ # define CV_EXTERN_C extern "C"
452
+ # else
453
+ # define CV_EXTERN_C
454
+ # endif
455
+ #endif
456
+
457
+ /* special informative macros for wrapper generators */
458
+ #define CV_EXPORTS_W CV_EXPORTS
459
+ #define CV_EXPORTS_W_SIMPLE CV_EXPORTS
460
+ #define CV_EXPORTS_AS(synonym) CV_EXPORTS
461
+ #define CV_EXPORTS_W_MAP CV_EXPORTS
462
+ #define CV_IN_OUT
463
+ #define CV_OUT
464
+ #define CV_PROP
465
+ #define CV_PROP_RW
466
+ #define CV_WRAP
467
+ #define CV_WRAP_AS(synonym)
468
+ #define CV_WRAP_MAPPABLE(mappable)
469
+ #define CV_WRAP_PHANTOM(phantom_header)
470
+ #define CV_WRAP_DEFAULT(val)
471
+
472
+ /****************************************************************************************\
473
+ * Matrix type (Mat) *
474
+ \****************************************************************************************/
475
+
476
+ #define CV_MAT_CN_MASK ((CV_CN_MAX - 1) << CV_CN_SHIFT)
477
+ #define CV_MAT_CN(flags) ((((flags) & CV_MAT_CN_MASK) >> CV_CN_SHIFT) + 1)
478
+ #define CV_MAT_TYPE_MASK (CV_DEPTH_MAX*CV_CN_MAX - 1)
479
+ #define CV_MAT_TYPE(flags) ((flags) & CV_MAT_TYPE_MASK)
480
+ #define CV_MAT_CONT_FLAG_SHIFT 14
481
+ #define CV_MAT_CONT_FLAG (1 << CV_MAT_CONT_FLAG_SHIFT)
482
+ #define CV_IS_MAT_CONT(flags) ((flags) & CV_MAT_CONT_FLAG)
483
+ #define CV_IS_CONT_MAT CV_IS_MAT_CONT
484
+ #define CV_SUBMAT_FLAG_SHIFT 15
485
+ #define CV_SUBMAT_FLAG (1 << CV_SUBMAT_FLAG_SHIFT)
486
+ #define CV_IS_SUBMAT(flags) ((flags) & CV_MAT_SUBMAT_FLAG)
487
+
488
+ /** Size of each channel item,
489
+ 0x28442211 = 0010 1000 0100 0100 0010 0010 0001 0001 ~ array of sizeof(arr_type_elem) */
490
+ #define CV_ELEM_SIZE1(type) ((0x28442211 >> CV_MAT_DEPTH(type)*4) & 15)
491
+
492
+ #define CV_ELEM_SIZE(type) (CV_MAT_CN(type)*CV_ELEM_SIZE1(type))
493
+
494
+ #ifndef MIN
495
+ # define MIN(a,b) ((a) > (b) ? (b) : (a))
496
+ #endif
497
+
498
+ #ifndef MAX
499
+ # define MAX(a,b) ((a) < (b) ? (b) : (a))
500
+ #endif
501
+
502
+ ///////////////////////////////////////// Enum operators ///////////////////////////////////////
503
+
504
+ /**
505
+
506
+ Provides compatibility operators for both classical and C++11 enum classes,
507
+ as well as exposing the C++11 enum class members for backwards compatibility
508
+
509
+ @code
510
+ // Provides operators required for flag enums
511
+ CV_ENUM_FLAGS(AccessFlag)
512
+
513
+ // Exposes the listed members of the enum class AccessFlag to the current namespace
514
+ CV_ENUM_CLASS_EXPOSE(AccessFlag, ACCESS_READ [, ACCESS_WRITE [, ...] ]);
515
+ @endcode
516
+ */
517
+
518
+ #define __CV_ENUM_CLASS_EXPOSE_1(EnumType, MEMBER_CONST) \
519
+ static const EnumType MEMBER_CONST = EnumType::MEMBER_CONST; \
520
+
521
+ #define __CV_ENUM_CLASS_EXPOSE_2(EnumType, MEMBER_CONST, ...) \
522
+ __CV_ENUM_CLASS_EXPOSE_1(EnumType, MEMBER_CONST); \
523
+ __CV_EXPAND(__CV_ENUM_CLASS_EXPOSE_1(EnumType, __VA_ARGS__)); \
524
+
525
+ #define __CV_ENUM_CLASS_EXPOSE_3(EnumType, MEMBER_CONST, ...) \
526
+ __CV_ENUM_CLASS_EXPOSE_1(EnumType, MEMBER_CONST); \
527
+ __CV_EXPAND(__CV_ENUM_CLASS_EXPOSE_2(EnumType, __VA_ARGS__)); \
528
+
529
+ #define __CV_ENUM_CLASS_EXPOSE_4(EnumType, MEMBER_CONST, ...) \
530
+ __CV_ENUM_CLASS_EXPOSE_1(EnumType, MEMBER_CONST); \
531
+ __CV_EXPAND(__CV_ENUM_CLASS_EXPOSE_3(EnumType, __VA_ARGS__)); \
532
+
533
+ #define __CV_ENUM_CLASS_EXPOSE_5(EnumType, MEMBER_CONST, ...) \
534
+ __CV_ENUM_CLASS_EXPOSE_1(EnumType, MEMBER_CONST); \
535
+ __CV_EXPAND(__CV_ENUM_CLASS_EXPOSE_4(EnumType, __VA_ARGS__)); \
536
+
537
+ #define __CV_ENUM_CLASS_EXPOSE_6(EnumType, MEMBER_CONST, ...) \
538
+ __CV_ENUM_CLASS_EXPOSE_1(EnumType, MEMBER_CONST); \
539
+ __CV_EXPAND(__CV_ENUM_CLASS_EXPOSE_5(EnumType, __VA_ARGS__)); \
540
+
541
+ #define __CV_ENUM_CLASS_EXPOSE_7(EnumType, MEMBER_CONST, ...) \
542
+ __CV_ENUM_CLASS_EXPOSE_1(EnumType, MEMBER_CONST); \
543
+ __CV_EXPAND(__CV_ENUM_CLASS_EXPOSE_6(EnumType, __VA_ARGS__)); \
544
+
545
+ #define __CV_ENUM_CLASS_EXPOSE_8(EnumType, MEMBER_CONST, ...) \
546
+ __CV_ENUM_CLASS_EXPOSE_1(EnumType, MEMBER_CONST); \
547
+ __CV_EXPAND(__CV_ENUM_CLASS_EXPOSE_7(EnumType, __VA_ARGS__)); \
548
+
549
+ #define __CV_ENUM_CLASS_EXPOSE_9(EnumType, MEMBER_CONST, ...) \
550
+ __CV_ENUM_CLASS_EXPOSE_1(EnumType, MEMBER_CONST); \
551
+ __CV_EXPAND(__CV_ENUM_CLASS_EXPOSE_8(EnumType, __VA_ARGS__)); \
552
+
553
+ #define __CV_ENUM_FLAGS_LOGICAL_NOT(EnumType) \
554
+ static inline bool operator!(const EnumType& val) \
555
+ { \
556
+ typedef std::underlying_type<EnumType>::type UnderlyingType; \
557
+ return !static_cast<UnderlyingType>(val); \
558
+ } \
559
+
560
+ #define __CV_ENUM_FLAGS_LOGICAL_NOT_EQ(Arg1Type, Arg2Type) \
561
+ static inline bool operator!=(const Arg1Type& a, const Arg2Type& b) \
562
+ { \
563
+ return static_cast<int>(a) != static_cast<int>(b); \
564
+ } \
565
+
566
+ #define __CV_ENUM_FLAGS_LOGICAL_EQ(Arg1Type, Arg2Type) \
567
+ static inline bool operator==(const Arg1Type& a, const Arg2Type& b) \
568
+ { \
569
+ return static_cast<int>(a) == static_cast<int>(b); \
570
+ } \
571
+
572
+ #define __CV_ENUM_FLAGS_BITWISE_NOT(EnumType) \
573
+ static inline EnumType operator~(const EnumType& val) \
574
+ { \
575
+ typedef std::underlying_type<EnumType>::type UnderlyingType; \
576
+ return static_cast<EnumType>(~static_cast<UnderlyingType>(val)); \
577
+ } \
578
+
579
+ #define __CV_ENUM_FLAGS_BITWISE_OR(EnumType, Arg1Type, Arg2Type) \
580
+ static inline EnumType operator|(const Arg1Type& a, const Arg2Type& b) \
581
+ { \
582
+ typedef std::underlying_type<EnumType>::type UnderlyingType; \
583
+ return static_cast<EnumType>(static_cast<UnderlyingType>(a) | static_cast<UnderlyingType>(b)); \
584
+ } \
585
+
586
+ #define __CV_ENUM_FLAGS_BITWISE_AND(EnumType, Arg1Type, Arg2Type) \
587
+ static inline EnumType operator&(const Arg1Type& a, const Arg2Type& b) \
588
+ { \
589
+ typedef std::underlying_type<EnumType>::type UnderlyingType; \
590
+ return static_cast<EnumType>(static_cast<UnderlyingType>(a) & static_cast<UnderlyingType>(b)); \
591
+ } \
592
+
593
+ #define __CV_ENUM_FLAGS_BITWISE_XOR(EnumType, Arg1Type, Arg2Type) \
594
+ static inline EnumType operator^(const Arg1Type& a, const Arg2Type& b) \
595
+ { \
596
+ typedef std::underlying_type<EnumType>::type UnderlyingType; \
597
+ return static_cast<EnumType>(static_cast<UnderlyingType>(a) ^ static_cast<UnderlyingType>(b)); \
598
+ } \
599
+
600
+ #define __CV_ENUM_FLAGS_BITWISE_OR_EQ(EnumType, Arg1Type) \
601
+ static inline EnumType& operator|=(EnumType& _this, const Arg1Type& val) \
602
+ { \
603
+ _this = static_cast<EnumType>(static_cast<int>(_this) | static_cast<int>(val)); \
604
+ return _this; \
605
+ } \
606
+
607
+ #define __CV_ENUM_FLAGS_BITWISE_AND_EQ(EnumType, Arg1Type) \
608
+ static inline EnumType& operator&=(EnumType& _this, const Arg1Type& val) \
609
+ { \
610
+ _this = static_cast<EnumType>(static_cast<int>(_this) & static_cast<int>(val)); \
611
+ return _this; \
612
+ } \
613
+
614
+ #define __CV_ENUM_FLAGS_BITWISE_XOR_EQ(EnumType, Arg1Type) \
615
+ static inline EnumType& operator^=(EnumType& _this, const Arg1Type& val) \
616
+ { \
617
+ _this = static_cast<EnumType>(static_cast<int>(_this) ^ static_cast<int>(val)); \
618
+ return _this; \
619
+ } \
620
+
621
+ #define CV_ENUM_CLASS_EXPOSE(EnumType, ...) \
622
+ __CV_EXPAND(__CV_CAT(__CV_ENUM_CLASS_EXPOSE_, __CV_VA_NUM_ARGS(__VA_ARGS__))(EnumType, __VA_ARGS__)); \
623
+
624
+ #define CV_ENUM_FLAGS(EnumType) \
625
+ __CV_ENUM_FLAGS_LOGICAL_NOT (EnumType) \
626
+ __CV_ENUM_FLAGS_LOGICAL_EQ (EnumType, int) \
627
+ __CV_ENUM_FLAGS_LOGICAL_NOT_EQ (EnumType, int) \
628
+ \
629
+ __CV_ENUM_FLAGS_BITWISE_NOT (EnumType) \
630
+ __CV_ENUM_FLAGS_BITWISE_OR (EnumType, EnumType, EnumType) \
631
+ __CV_ENUM_FLAGS_BITWISE_AND (EnumType, EnumType, EnumType) \
632
+ __CV_ENUM_FLAGS_BITWISE_XOR (EnumType, EnumType, EnumType) \
633
+ \
634
+ __CV_ENUM_FLAGS_BITWISE_OR_EQ (EnumType, EnumType) \
635
+ __CV_ENUM_FLAGS_BITWISE_AND_EQ (EnumType, EnumType) \
636
+ __CV_ENUM_FLAGS_BITWISE_XOR_EQ (EnumType, EnumType) \
637
+
638
+ /****************************************************************************************\
639
+ * static analysys *
640
+ \****************************************************************************************/
641
+
642
+ // In practice, some macro are not processed correctly (noreturn is not detected).
643
+ // We need to use simplified definition for them.
644
+ #ifndef CV_STATIC_ANALYSIS
645
+ # if defined(__KLOCWORK__) || defined(__clang_analyzer__) || defined(__COVERITY__)
646
+ # define CV_STATIC_ANALYSIS 1
647
+ # endif
648
+ #else
649
+ # if defined(CV_STATIC_ANALYSIS) && !(__CV_CAT(1, CV_STATIC_ANALYSIS) == 1) // defined and not empty
650
+ # if 0 == CV_STATIC_ANALYSIS
651
+ # undef CV_STATIC_ANALYSIS
652
+ # endif
653
+ # endif
654
+ #endif
655
+
656
+ /****************************************************************************************\
657
+ * Thread sanitizer *
658
+ \****************************************************************************************/
659
+ #ifndef CV_THREAD_SANITIZER
660
+ # if defined(__has_feature)
661
+ # if __has_feature(thread_sanitizer)
662
+ # define CV_THREAD_SANITIZER
663
+ # endif
664
+ # endif
665
+ #endif
666
+
667
+ /****************************************************************************************\
668
+ * exchange-add operation for atomic operations on reference counters *
669
+ \****************************************************************************************/
670
+
671
+ #ifdef CV_XADD
672
+ // allow to use user-defined macro
673
+ #elif defined __GNUC__ || defined __clang__
674
+ # if defined __clang__ && __clang_major__ >= 3 && !defined __ANDROID__ && !defined __EMSCRIPTEN__ && !defined(__CUDACC__) && !defined __INTEL_COMPILER
675
+ # ifdef __ATOMIC_ACQ_REL
676
+ # define CV_XADD(addr, delta) __c11_atomic_fetch_add((_Atomic(int)*)(addr), delta, __ATOMIC_ACQ_REL)
677
+ # else
678
+ # define CV_XADD(addr, delta) __atomic_fetch_add((_Atomic(int)*)(addr), delta, 4)
679
+ # endif
680
+ # else
681
+ # if defined __ATOMIC_ACQ_REL && !defined __clang__
682
+ // version for gcc >= 4.7
683
+ # define CV_XADD(addr, delta) (int)__atomic_fetch_add((unsigned*)(addr), (unsigned)(delta), __ATOMIC_ACQ_REL)
684
+ # else
685
+ # define CV_XADD(addr, delta) (int)__sync_fetch_and_add((unsigned*)(addr), (unsigned)(delta))
686
+ # endif
687
+ # endif
688
+ #elif defined _MSC_VER && !defined RC_INVOKED
689
+ # include <intrin.h>
690
+ # define CV_XADD(addr, delta) (int)_InterlockedExchangeAdd((long volatile*)addr, delta)
691
+ #else
692
+ #ifdef OPENCV_FORCE_UNSAFE_XADD
693
+ CV_INLINE int CV_XADD(int* addr, int delta) { int tmp = *addr; *addr += delta; return tmp; }
694
+ #else
695
+ #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)"
696
+ #endif
697
+ #endif
698
+
699
+
700
+ /****************************************************************************************\
701
+ * CV_NORETURN attribute *
702
+ \****************************************************************************************/
703
+
704
+ #ifndef CV_NORETURN
705
+ # if defined(__GNUC__)
706
+ # define CV_NORETURN __attribute__((__noreturn__))
707
+ # elif defined(_MSC_VER) && (_MSC_VER >= 1300)
708
+ # define CV_NORETURN __declspec(noreturn)
709
+ # else
710
+ # define CV_NORETURN /* nothing by default */
711
+ # endif
712
+ #endif
713
+
714
+ /****************************************************************************************\
715
+ * CV_NODISCARD_STD attribute (C++17) *
716
+ * encourages the compiler to issue a warning if the return value is discarded *
717
+ \****************************************************************************************/
718
+ #ifndef CV_NODISCARD_STD
719
+ # ifndef __has_cpp_attribute
720
+ // workaround preprocessor non-compliance https://reviews.llvm.org/D57851
721
+ # define __has_cpp_attribute(__x) 0
722
+ # endif
723
+ # if __has_cpp_attribute(nodiscard)
724
+ # define CV_NODISCARD_STD [[nodiscard]]
725
+ # elif __cplusplus >= 201703L
726
+ // available when compiler is C++17 compliant
727
+ # define CV_NODISCARD_STD [[nodiscard]]
728
+ # elif defined(__INTEL_COMPILER)
729
+ // see above, available when C++17 is enabled
730
+ # elif defined(_MSC_VER) && _MSC_VER >= 1911 && _MSVC_LANG >= 201703L
731
+ // available with VS2017 v15.3+ with /std:c++17 or higher; works on functions and classes
732
+ # define CV_NODISCARD_STD [[nodiscard]]
733
+ # elif defined(__GNUC__) && (((__GNUC__ * 100) + __GNUC_MINOR__) >= 700) && (__cplusplus >= 201103L)
734
+ // available with GCC 7.0+; works on functions, works or silently fails on classes
735
+ # define CV_NODISCARD_STD [[nodiscard]]
736
+ # elif defined(__GNUC__) && (((__GNUC__ * 100) + __GNUC_MINOR__) >= 408) && (__cplusplus >= 201103L)
737
+ // available with GCC 4.8+ but it usually does nothing and can fail noisily -- therefore not used
738
+ // define CV_NODISCARD_STD [[gnu::warn_unused_result]]
739
+ # endif
740
+ #endif
741
+ #ifndef CV_NODISCARD_STD
742
+ # define CV_NODISCARD_STD /* nothing by default */
743
+ #endif
744
+
745
+
746
+ /****************************************************************************************\
747
+ * CV_NODISCARD attribute (deprecated, GCC only) *
748
+ * DONT USE: use instead the standard CV_NODISCARD_STD macro above *
749
+ * this legacy method silently fails to issue warning until some version *
750
+ * after gcc 6.3.0. Yet with gcc 7+ you can use the above standard method *
751
+ * which makes this method useless. Don't use it. *
752
+ * @deprecated use instead CV_NODISCARD_STD *
753
+ \****************************************************************************************/
754
+ #ifndef CV_NODISCARD
755
+ # if defined(__GNUC__)
756
+ # define CV_NODISCARD __attribute__((__warn_unused_result__))
757
+ # elif defined(__clang__) && defined(__has_attribute)
758
+ # if __has_attribute(__warn_unused_result__)
759
+ # define CV_NODISCARD __attribute__((__warn_unused_result__))
760
+ # endif
761
+ # endif
762
+ #endif
763
+ #ifndef CV_NODISCARD
764
+ # define CV_NODISCARD /* nothing by default */
765
+ #endif
766
+
767
+
768
+ /****************************************************************************************\
769
+ * C++ 11 *
770
+ \****************************************************************************************/
771
+ #ifndef CV_CXX11
772
+ # if __cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1800)
773
+ # define CV_CXX11 1
774
+ # endif
775
+ #else
776
+ # if CV_CXX11 == 0
777
+ # undef CV_CXX11
778
+ # endif
779
+ #endif
780
+ #ifndef CV_CXX11
781
+ # error "OpenCV 4.x+ requires enabled C++11 support"
782
+ #endif
783
+
784
+ #define CV_CXX_MOVE_SEMANTICS 1
785
+ #define CV_CXX_MOVE(x) std::move(x)
786
+ #define CV_CXX_STD_ARRAY 1
787
+ #include <array>
788
+ #ifndef CV_OVERRIDE
789
+ # define CV_OVERRIDE override
790
+ #endif
791
+ #ifndef CV_FINAL
792
+ # define CV_FINAL final
793
+ #endif
794
+
795
+ #ifndef CV_NOEXCEPT
796
+ # if __cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1900/*MSVS 2015*/)
797
+ # define CV_NOEXCEPT noexcept
798
+ # endif
799
+ #endif
800
+ #ifndef CV_NOEXCEPT
801
+ # define CV_NOEXCEPT
802
+ #endif
803
+
804
+ #ifndef CV_CONSTEXPR
805
+ # if __cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1900/*MSVS 2015*/)
806
+ # define CV_CONSTEXPR constexpr
807
+ # endif
808
+ #endif
809
+ #ifndef CV_CONSTEXPR
810
+ # define CV_CONSTEXPR
811
+ #endif
812
+
813
+ // Integer types portability
814
+ #ifdef OPENCV_STDINT_HEADER
815
+ #include OPENCV_STDINT_HEADER
816
+ #elif defined(__cplusplus)
817
+ #if defined(_MSC_VER) && _MSC_VER < 1600 /* MSVS 2010 */
818
+ namespace cv {
819
+ typedef signed char int8_t;
820
+ typedef unsigned char uint8_t;
821
+ typedef signed short int16_t;
822
+ typedef unsigned short uint16_t;
823
+ typedef signed int int32_t;
824
+ typedef unsigned int uint32_t;
825
+ typedef signed __int64 int64_t;
826
+ typedef unsigned __int64 uint64_t;
827
+ }
828
+ #elif defined(_MSC_VER) || __cplusplus >= 201103L
829
+ #include <cstdint>
830
+ namespace cv {
831
+ using std::int8_t;
832
+ using std::uint8_t;
833
+ using std::int16_t;
834
+ using std::uint16_t;
835
+ using std::int32_t;
836
+ using std::uint32_t;
837
+ using std::int64_t;
838
+ using std::uint64_t;
839
+ }
840
+ #else
841
+ #include <stdint.h>
842
+ namespace cv {
843
+ typedef ::int8_t int8_t;
844
+ typedef ::uint8_t uint8_t;
845
+ typedef ::int16_t int16_t;
846
+ typedef ::uint16_t uint16_t;
847
+ typedef ::int32_t int32_t;
848
+ typedef ::uint32_t uint32_t;
849
+ typedef ::int64_t int64_t;
850
+ typedef ::uint64_t uint64_t;
851
+ }
852
+ #endif
853
+ #else // pure C
854
+ #include <stdint.h>
855
+ #endif
856
+
857
+ #ifdef __cplusplus
858
+ namespace cv
859
+ {
860
+
861
+ class float16_t
862
+ {
863
+ public:
864
+ #if CV_FP16_TYPE
865
+
866
+ float16_t() : h(0) {}
867
+ explicit float16_t(float x) { h = (__fp16)x; }
868
+ operator float() const { return (float)h; }
869
+ static float16_t fromBits(ushort w)
870
+ {
871
+ Cv16suf u;
872
+ u.u = w;
873
+ float16_t result;
874
+ result.h = u.h;
875
+ return result;
876
+ }
877
+ static float16_t zero()
878
+ {
879
+ float16_t result;
880
+ result.h = (__fp16)0;
881
+ return result;
882
+ }
883
+ ushort bits() const
884
+ {
885
+ Cv16suf u;
886
+ u.h = h;
887
+ return u.u;
888
+ }
889
+ protected:
890
+ __fp16 h;
891
+
892
+ #else
893
+ float16_t() : w(0) {}
894
+ explicit float16_t(float x)
895
+ {
896
+ #if CV_FP16
897
+ __m128 v = _mm_load_ss(&x);
898
+ w = (ushort)_mm_cvtsi128_si32(_mm_cvtps_ph(v, 0));
899
+ #else
900
+ Cv32suf in;
901
+ in.f = x;
902
+ unsigned sign = in.u & 0x80000000;
903
+ in.u ^= sign;
904
+
905
+ if( in.u >= 0x47800000 )
906
+ w = (ushort)(in.u > 0x7f800000 ? 0x7e00 : 0x7c00);
907
+ else
908
+ {
909
+ if (in.u < 0x38800000)
910
+ {
911
+ in.f += 0.5f;
912
+ w = (ushort)(in.u - 0x3f000000);
913
+ }
914
+ else
915
+ {
916
+ unsigned t = in.u + 0xc8000fff;
917
+ w = (ushort)((t + ((in.u >> 13) & 1)) >> 13);
918
+ }
919
+ }
920
+
921
+ w = (ushort)(w | (sign >> 16));
922
+ #endif
923
+ }
924
+
925
+ operator float() const
926
+ {
927
+ #if CV_FP16
928
+ float f;
929
+ _mm_store_ss(&f, _mm_cvtph_ps(_mm_cvtsi32_si128(w)));
930
+ return f;
931
+ #else
932
+ Cv32suf out;
933
+
934
+ unsigned t = ((w & 0x7fff) << 13) + 0x38000000;
935
+ unsigned sign = (w & 0x8000) << 16;
936
+ unsigned e = w & 0x7c00;
937
+
938
+ out.u = t + (1 << 23);
939
+ out.u = (e >= 0x7c00 ? t + 0x38000000 :
940
+ e == 0 ? (static_cast<void>(out.f -= 6.103515625e-05f), out.u) : t) | sign;
941
+ return out.f;
942
+ #endif
943
+ }
944
+
945
+ static float16_t fromBits(ushort b)
946
+ {
947
+ float16_t result;
948
+ result.w = b;
949
+ return result;
950
+ }
951
+ static float16_t zero()
952
+ {
953
+ float16_t result;
954
+ result.w = (ushort)0;
955
+ return result;
956
+ }
957
+ ushort bits() const { return w; }
958
+ protected:
959
+ ushort w;
960
+
961
+ #endif
962
+ };
963
+
964
+ }
965
+ #endif
966
+
967
+ //! @}
968
+
969
+ #ifndef __cplusplus
970
+ #include "opencv2/core/fast_math.hpp" // define cvRound(double)
971
+ #endif
972
+
973
+ #endif // OPENCV_CORE_CVDEF_H