node-native-win-utils 1.3.4 → 2.1.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 (191) hide show
  1. package/README.md +30 -83
  2. package/binding.gyp +3 -0
  3. package/dist/dirnameLocal.cjs +4 -0
  4. package/dist/dirnameLocal.d.cts +1 -0
  5. package/dist/dirnameLocal.d.mts +1 -0
  6. package/dist/dirnameLocal.mjs +2 -0
  7. package/dist/{index.js → index.cjs} +49 -17
  8. package/dist/{index.d.ts → index.d.cts} +25 -12
  9. package/dist/index.d.mts +191 -0
  10. package/dist/index.mjs +177 -0
  11. package/dist/keyCodes.d.mts +101 -0
  12. package/dist/keyCodes.mjs +201 -0
  13. package/node22.json +16 -0
  14. package/package.json +22 -9
  15. package/prebuilds/win32-x64/node-native-win-utils.node +0 -0
  16. package/prebuilds/win32-x64/tesseract.dll +0 -0
  17. package/prebuilds/win32-x64/tiff.dll +0 -0
  18. package/src/cpp/keyboard.cpp +141 -140
  19. package/src/cpp/main.cpp +11 -3
  20. package/src/cpp/{capturewindow.cpp → screenshot.cpp} +174 -2
  21. package/src/cpp/tesseract.cpp +49 -0
  22. package/src/dirnameLocal.mts +3 -0
  23. package/src/index.mts +454 -0
  24. package/src/keyCodes.mts +203 -0
  25. package/include/opencv2/core/affine.hpp +0 -678
  26. package/include/opencv2/core/async.hpp +0 -105
  27. package/include/opencv2/core/base.hpp +0 -664
  28. package/include/opencv2/core/bindings_utils.hpp +0 -325
  29. package/include/opencv2/core/bufferpool.hpp +0 -40
  30. package/include/opencv2/core/check.hpp +0 -170
  31. package/include/opencv2/core/core.hpp +0 -48
  32. package/include/opencv2/core/core_c.h +0 -3128
  33. package/include/opencv2/core/cuda/block.hpp +0 -211
  34. package/include/opencv2/core/cuda/border_interpolate.hpp +0 -722
  35. package/include/opencv2/core/cuda/color.hpp +0 -309
  36. package/include/opencv2/core/cuda/common.hpp +0 -131
  37. package/include/opencv2/core/cuda/datamov_utils.hpp +0 -113
  38. package/include/opencv2/core/cuda/detail/color_detail.hpp +0 -2018
  39. package/include/opencv2/core/cuda/detail/reduce.hpp +0 -365
  40. package/include/opencv2/core/cuda/detail/reduce_key_val.hpp +0 -502
  41. package/include/opencv2/core/cuda/detail/transform_detail.hpp +0 -392
  42. package/include/opencv2/core/cuda/detail/type_traits_detail.hpp +0 -191
  43. package/include/opencv2/core/cuda/detail/vec_distance_detail.hpp +0 -121
  44. package/include/opencv2/core/cuda/dynamic_smem.hpp +0 -88
  45. package/include/opencv2/core/cuda/emulation.hpp +0 -269
  46. package/include/opencv2/core/cuda/filters.hpp +0 -293
  47. package/include/opencv2/core/cuda/funcattrib.hpp +0 -79
  48. package/include/opencv2/core/cuda/functional.hpp +0 -805
  49. package/include/opencv2/core/cuda/limits.hpp +0 -128
  50. package/include/opencv2/core/cuda/reduce.hpp +0 -209
  51. package/include/opencv2/core/cuda/saturate_cast.hpp +0 -292
  52. package/include/opencv2/core/cuda/scan.hpp +0 -258
  53. package/include/opencv2/core/cuda/simd_functions.hpp +0 -869
  54. package/include/opencv2/core/cuda/transform.hpp +0 -75
  55. package/include/opencv2/core/cuda/type_traits.hpp +0 -90
  56. package/include/opencv2/core/cuda/utility.hpp +0 -230
  57. package/include/opencv2/core/cuda/vec_distance.hpp +0 -232
  58. package/include/opencv2/core/cuda/vec_math.hpp +0 -923
  59. package/include/opencv2/core/cuda/vec_traits.hpp +0 -288
  60. package/include/opencv2/core/cuda/warp.hpp +0 -139
  61. package/include/opencv2/core/cuda/warp_reduce.hpp +0 -76
  62. package/include/opencv2/core/cuda/warp_shuffle.hpp +0 -162
  63. package/include/opencv2/core/cuda.hpp +0 -1279
  64. package/include/opencv2/core/cuda.inl.hpp +0 -763
  65. package/include/opencv2/core/cuda_stream_accessor.hpp +0 -86
  66. package/include/opencv2/core/cuda_types.hpp +0 -144
  67. package/include/opencv2/core/cv_cpu_dispatch.h +0 -381
  68. package/include/opencv2/core/cv_cpu_helper.h +0 -550
  69. package/include/opencv2/core/cvdef.h +0 -973
  70. package/include/opencv2/core/cvstd.hpp +0 -190
  71. package/include/opencv2/core/cvstd.inl.hpp +0 -197
  72. package/include/opencv2/core/cvstd_wrapper.hpp +0 -154
  73. package/include/opencv2/core/detail/async_promise.hpp +0 -71
  74. package/include/opencv2/core/detail/dispatch_helper.impl.hpp +0 -49
  75. package/include/opencv2/core/detail/exception_ptr.hpp +0 -27
  76. package/include/opencv2/core/directx.hpp +0 -184
  77. package/include/opencv2/core/dualquaternion.hpp +0 -979
  78. package/include/opencv2/core/dualquaternion.inl.hpp +0 -487
  79. package/include/opencv2/core/eigen.hpp +0 -402
  80. package/include/opencv2/core/fast_math.hpp +0 -433
  81. package/include/opencv2/core/hal/hal.hpp +0 -256
  82. package/include/opencv2/core/hal/interface.h +0 -190
  83. package/include/opencv2/core/hal/intrin.hpp +0 -939
  84. package/include/opencv2/core/hal/intrin_avx.hpp +0 -3177
  85. package/include/opencv2/core/hal/intrin_avx512.hpp +0 -3090
  86. package/include/opencv2/core/hal/intrin_cpp.hpp +0 -3321
  87. package/include/opencv2/core/hal/intrin_forward.hpp +0 -191
  88. package/include/opencv2/core/hal/intrin_lasx.hpp +0 -3236
  89. package/include/opencv2/core/hal/intrin_msa.hpp +0 -1887
  90. package/include/opencv2/core/hal/intrin_neon.hpp +0 -2610
  91. package/include/opencv2/core/hal/intrin_rvv.hpp +0 -3320
  92. package/include/opencv2/core/hal/intrin_rvv071.hpp +0 -2545
  93. package/include/opencv2/core/hal/intrin_rvv_scalable.hpp +0 -2080
  94. package/include/opencv2/core/hal/intrin_sse.hpp +0 -3467
  95. package/include/opencv2/core/hal/intrin_sse_em.hpp +0 -180
  96. package/include/opencv2/core/hal/intrin_vsx.hpp +0 -1608
  97. package/include/opencv2/core/hal/intrin_wasm.hpp +0 -2782
  98. package/include/opencv2/core/hal/msa_macros.h +0 -1558
  99. package/include/opencv2/core/hal/simd_utils.impl.hpp +0 -186
  100. package/include/opencv2/core/llapi/llapi.h +0 -102
  101. package/include/opencv2/core/mat.hpp +0 -3775
  102. package/include/opencv2/core/mat.inl.hpp +0 -3422
  103. package/include/opencv2/core/matx.hpp +0 -1536
  104. package/include/opencv2/core/neon_utils.hpp +0 -128
  105. package/include/opencv2/core/ocl.hpp +0 -917
  106. package/include/opencv2/core/ocl_genbase.hpp +0 -69
  107. package/include/opencv2/core/opencl/ocl_defs.hpp +0 -82
  108. package/include/opencv2/core/opencl/opencl_info.hpp +0 -212
  109. package/include/opencv2/core/opencl/opencl_svm.hpp +0 -81
  110. package/include/opencv2/core/opencl/runtime/autogenerated/opencl_clblas.hpp +0 -602
  111. package/include/opencv2/core/opencl/runtime/autogenerated/opencl_clfft.hpp +0 -146
  112. package/include/opencv2/core/opencl/runtime/autogenerated/opencl_core.hpp +0 -371
  113. package/include/opencv2/core/opencl/runtime/autogenerated/opencl_core_wrappers.hpp +0 -272
  114. package/include/opencv2/core/opencl/runtime/autogenerated/opencl_gl.hpp +0 -62
  115. package/include/opencv2/core/opencl/runtime/autogenerated/opencl_gl_wrappers.hpp +0 -42
  116. package/include/opencv2/core/opencl/runtime/opencl_clblas.hpp +0 -53
  117. package/include/opencv2/core/opencl/runtime/opencl_clfft.hpp +0 -53
  118. package/include/opencv2/core/opencl/runtime/opencl_core.hpp +0 -84
  119. package/include/opencv2/core/opencl/runtime/opencl_core_wrappers.hpp +0 -47
  120. package/include/opencv2/core/opencl/runtime/opencl_gl.hpp +0 -53
  121. package/include/opencv2/core/opencl/runtime/opencl_gl_wrappers.hpp +0 -47
  122. package/include/opencv2/core/opencl/runtime/opencl_svm_20.hpp +0 -48
  123. package/include/opencv2/core/opencl/runtime/opencl_svm_definitions.hpp +0 -42
  124. package/include/opencv2/core/opencl/runtime/opencl_svm_hsa_extension.hpp +0 -166
  125. package/include/opencv2/core/opengl.hpp +0 -733
  126. package/include/opencv2/core/openvx/ovx_defs.hpp +0 -48
  127. package/include/opencv2/core/operations.hpp +0 -610
  128. package/include/opencv2/core/optim.hpp +0 -302
  129. package/include/opencv2/core/ovx.hpp +0 -28
  130. package/include/opencv2/core/parallel/backend/parallel_for.openmp.hpp +0 -72
  131. package/include/opencv2/core/parallel/backend/parallel_for.tbb.hpp +0 -153
  132. package/include/opencv2/core/parallel/parallel_backend.hpp +0 -90
  133. package/include/opencv2/core/persistence.hpp +0 -1350
  134. package/include/opencv2/core/private/cv_cpu_include_simd_declarations.hpp +0 -30
  135. package/include/opencv2/core/private.cuda.hpp +0 -169
  136. package/include/opencv2/core/private.hpp +0 -896
  137. package/include/opencv2/core/quaternion.hpp +0 -1696
  138. package/include/opencv2/core/quaternion.inl.hpp +0 -1063
  139. package/include/opencv2/core/saturate.hpp +0 -180
  140. package/include/opencv2/core/simd_intrinsics.hpp +0 -87
  141. package/include/opencv2/core/softfloat.hpp +0 -514
  142. package/include/opencv2/core/sse_utils.hpp +0 -652
  143. package/include/opencv2/core/traits.hpp +0 -417
  144. package/include/opencv2/core/types.hpp +0 -2457
  145. package/include/opencv2/core/types_c.h +0 -2126
  146. package/include/opencv2/core/utility.hpp +0 -1229
  147. package/include/opencv2/core/utils/allocator_stats.hpp +0 -29
  148. package/include/opencv2/core/utils/allocator_stats.impl.hpp +0 -158
  149. package/include/opencv2/core/utils/buffer_area.private.hpp +0 -136
  150. package/include/opencv2/core/utils/configuration.private.hpp +0 -22
  151. package/include/opencv2/core/utils/filesystem.hpp +0 -82
  152. package/include/opencv2/core/utils/filesystem.private.hpp +0 -66
  153. package/include/opencv2/core/utils/fp_control.private.hpp +0 -29
  154. package/include/opencv2/core/utils/fp_control_utils.hpp +0 -69
  155. package/include/opencv2/core/utils/instrumentation.hpp +0 -125
  156. package/include/opencv2/core/utils/lock.private.hpp +0 -119
  157. package/include/opencv2/core/utils/logger.defines.hpp +0 -42
  158. package/include/opencv2/core/utils/logger.hpp +0 -218
  159. package/include/opencv2/core/utils/logtag.hpp +0 -28
  160. package/include/opencv2/core/utils/plugin_loader.private.hpp +0 -165
  161. package/include/opencv2/core/utils/tls.hpp +0 -235
  162. package/include/opencv2/core/utils/trace.hpp +0 -252
  163. package/include/opencv2/core/utils/trace.private.hpp +0 -421
  164. package/include/opencv2/core/va_intel.hpp +0 -75
  165. package/include/opencv2/core/version.hpp +0 -26
  166. package/include/opencv2/core/vsx_utils.hpp +0 -1047
  167. package/include/opencv2/core.hpp +0 -3365
  168. package/include/opencv2/imgcodecs/imgcodecs.hpp +0 -48
  169. package/include/opencv2/imgcodecs/imgcodecs_c.h +0 -1
  170. package/include/opencv2/imgcodecs/ios.h +0 -59
  171. package/include/opencv2/imgcodecs/legacy/constants_c.h +0 -54
  172. package/include/opencv2/imgcodecs/macosx.h +0 -20
  173. package/include/opencv2/imgcodecs.hpp +0 -407
  174. package/include/opencv2/imgproc/bindings.hpp +0 -34
  175. package/include/opencv2/imgproc/detail/gcgraph.hpp +0 -395
  176. package/include/opencv2/imgproc/hal/hal.hpp +0 -246
  177. package/include/opencv2/imgproc/hal/interface.h +0 -46
  178. package/include/opencv2/imgproc/imgproc.hpp +0 -48
  179. package/include/opencv2/imgproc/imgproc_c.h +0 -1177
  180. package/include/opencv2/imgproc/segmentation.hpp +0 -141
  181. package/include/opencv2/imgproc/types_c.h +0 -659
  182. package/include/opencv2/imgproc.hpp +0 -5035
  183. package/include/opencv2/opencv_modules.hpp +0 -17
  184. package/libs/libjpeg-turbo.lib +0 -0
  185. package/libs/libpng.lib +0 -0
  186. package/libs/opencv_core470.lib +0 -0
  187. package/libs/opencv_imgcodecs470.lib +0 -0
  188. package/libs/opencv_imgproc470.lib +0 -0
  189. package/libs/zlib.lib +0 -0
  190. /package/dist/{keyCodes.js → keyCodes.cjs} +0 -0
  191. /package/dist/{keyCodes.d.ts → keyCodes.d.cts} +0 -0
@@ -1,514 +0,0 @@
1
- // This file is part of OpenCV project.
2
- // It is subject to the license terms in the LICENSE file found in the top-level directory
3
- // of this distribution and at http://opencv.org/license.html
4
-
5
- // This file is based on files from package issued with the following license:
6
-
7
- /*============================================================================
8
-
9
- This C header file is part of the SoftFloat IEEE Floating-Point Arithmetic
10
- Package, Release 3c, by John R. Hauser.
11
-
12
- Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017 The Regents of the
13
- University of California. All rights reserved.
14
-
15
- Redistribution and use in source and binary forms, with or without
16
- modification, are permitted provided that the following conditions are met:
17
-
18
- 1. Redistributions of source code must retain the above copyright notice,
19
- this list of conditions, and the following disclaimer.
20
-
21
- 2. Redistributions in binary form must reproduce the above copyright notice,
22
- this list of conditions, and the following disclaimer in the documentation
23
- and/or other materials provided with the distribution.
24
-
25
- 3. Neither the name of the University nor the names of its contributors may
26
- be used to endorse or promote products derived from this software without
27
- specific prior written permission.
28
-
29
- THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
30
- EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
31
- WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
32
- DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
33
- DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
34
- (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
35
- LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
36
- ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
37
- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
38
- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
39
-
40
- =============================================================================*/
41
-
42
- #pragma once
43
- #ifndef softfloat_h
44
- #define softfloat_h 1
45
-
46
- #include "cvdef.h"
47
-
48
- namespace cv
49
- {
50
-
51
- /** @addtogroup core_utils_softfloat
52
-
53
- [SoftFloat](http://www.jhauser.us/arithmetic/SoftFloat.html) is a software implementation
54
- of floating-point calculations according to IEEE 754 standard.
55
- All calculations are done in integers, that's why they are machine-independent and bit-exact.
56
- This library can be useful in accuracy-critical parts like look-up tables generation, tests, etc.
57
- OpenCV contains a subset of SoftFloat partially rewritten to C++.
58
-
59
- ### Types
60
-
61
- There are two basic types: @ref softfloat and @ref softdouble.
62
- These types are binary compatible with float and double types respectively
63
- and support conversions to/from them.
64
- Other types from original SoftFloat library like fp16 or fp128 were thrown away
65
- as well as quiet/signaling NaN support, on-the-fly rounding mode switch
66
- and exception flags (though exceptions can be implemented in the future).
67
-
68
- ### Operations
69
-
70
- Both types support the following:
71
- - Construction from signed and unsigned 32-bit and 64 integers,
72
- float/double or raw binary representation
73
- - Conversions between each other, to float or double and to int
74
- using @ref cvRound, @ref cvTrunc, @ref cvFloor, @ref cvCeil or a bunch of
75
- saturate_cast functions
76
- - Add, subtract, multiply, divide, remainder, square root, FMA with absolute precision
77
- - Comparison operations
78
- - Explicit sign, exponent and significand manipulation through get/set methods,
79
- number state indicators (isInf, isNan, isSubnormal)
80
- - Type-specific constants like eps, minimum/maximum value, best pi approximation, etc.
81
- - min(), max(), abs(), exp(), log() and pow() functions
82
-
83
- */
84
- //! @{
85
-
86
- struct softfloat;
87
- struct softdouble;
88
-
89
- struct CV_EXPORTS softfloat
90
- {
91
- public:
92
- /** @brief Default constructor */
93
- softfloat() { v = 0; }
94
- /** @brief Copy constructor */
95
- softfloat( const softfloat& c) { v = c.v; }
96
- /** @brief Assign constructor */
97
- softfloat& operator=( const softfloat& c )
98
- {
99
- if(&c != this) v = c.v;
100
- return *this;
101
- }
102
- /** @brief Construct from raw
103
-
104
- Builds new value from raw binary representation
105
- */
106
- static const softfloat fromRaw( const uint32_t a ) { softfloat x; x.v = a; return x; }
107
-
108
- /** @brief Construct from integer */
109
- explicit softfloat( const uint32_t );
110
- explicit softfloat( const uint64_t );
111
- explicit softfloat( const int32_t );
112
- explicit softfloat( const int64_t );
113
-
114
- #ifdef CV_INT32_T_IS_LONG_INT
115
- // for platforms with int32_t = long int
116
- explicit softfloat( const int a ) { *this = softfloat(static_cast<int32_t>(a)); }
117
- #endif
118
-
119
- /** @brief Construct from float */
120
- explicit softfloat( const float a ) { Cv32suf s; s.f = a; v = s.u; }
121
-
122
- /** @brief Type casts */
123
- operator softdouble() const;
124
- operator float() const { Cv32suf s; s.u = v; return s.f; }
125
-
126
- /** @brief Basic arithmetics */
127
- softfloat operator + (const softfloat&) const;
128
- softfloat operator - (const softfloat&) const;
129
- softfloat operator * (const softfloat&) const;
130
- softfloat operator / (const softfloat&) const;
131
- softfloat operator - () const { softfloat x; x.v = v ^ (1U << 31); return x; }
132
-
133
- /** @brief Remainder operator
134
-
135
- A quote from original SoftFloat manual:
136
-
137
- > The IEEE Standard remainder operation computes the value
138
- > a - n * b, where n is the integer closest to a / b.
139
- > If a / b is exactly halfway between two integers, n is the even integer
140
- > closest to a / b. The IEEE Standard’s remainder operation is always exact and so requires no rounding.
141
- > Depending on the relative magnitudes of the operands, the remainder functions
142
- > can take considerably longer to execute than the other SoftFloat functions.
143
- > This is an inherent characteristic of the remainder operation itself and is not a flaw
144
- > in the SoftFloat implementation.
145
- */
146
- softfloat operator % (const softfloat&) const;
147
-
148
- softfloat& operator += (const softfloat& a) { *this = *this + a; return *this; }
149
- softfloat& operator -= (const softfloat& a) { *this = *this - a; return *this; }
150
- softfloat& operator *= (const softfloat& a) { *this = *this * a; return *this; }
151
- softfloat& operator /= (const softfloat& a) { *this = *this / a; return *this; }
152
- softfloat& operator %= (const softfloat& a) { *this = *this % a; return *this; }
153
-
154
- /** @brief Comparison operations
155
-
156
- - Any operation with NaN produces false
157
- + The only exception is when x is NaN: x != y for any y.
158
- - Positive and negative zeros are equal
159
- */
160
- bool operator == ( const softfloat& ) const;
161
- bool operator != ( const softfloat& ) const;
162
- bool operator > ( const softfloat& ) const;
163
- bool operator >= ( const softfloat& ) const;
164
- bool operator < ( const softfloat& ) const;
165
- bool operator <= ( const softfloat& ) const;
166
-
167
- /** @brief NaN state indicator */
168
- inline bool isNaN() const { return (v & 0x7fffffff) > 0x7f800000; }
169
- /** @brief Inf state indicator */
170
- inline bool isInf() const { return (v & 0x7fffffff) == 0x7f800000; }
171
- /** @brief Subnormal number indicator */
172
- inline bool isSubnormal() const { return ((v >> 23) & 0xFF) == 0; }
173
-
174
- /** @brief Get sign bit */
175
- inline bool getSign() const { return (v >> 31) != 0; }
176
- /** @brief Construct a copy with new sign bit */
177
- inline softfloat setSign(bool sign) const { softfloat x; x.v = (v & ((1U << 31) - 1)) | ((uint32_t)sign << 31); return x; }
178
- /** @brief Get 0-based exponent */
179
- inline int getExp() const { return ((v >> 23) & 0xFF) - 127; }
180
- /** @brief Construct a copy with new 0-based exponent */
181
- inline softfloat setExp(int e) const { softfloat x; x.v = (v & 0x807fffff) | (((e + 127) & 0xFF) << 23 ); return x; }
182
-
183
- /** @brief Get a fraction part
184
-
185
- Returns a number 1 <= x < 2 with the same significand
186
- */
187
- inline softfloat getFrac() const
188
- {
189
- uint_fast32_t vv = (v & 0x007fffff) | (127 << 23);
190
- return softfloat::fromRaw(vv);
191
- }
192
- /** @brief Construct a copy with provided significand
193
-
194
- Constructs a copy of a number with significand taken from parameter
195
- */
196
- inline softfloat setFrac(const softfloat& s) const
197
- {
198
- softfloat x;
199
- x.v = (v & 0xff800000) | (s.v & 0x007fffff);
200
- return x;
201
- }
202
-
203
- /** @brief Zero constant */
204
- static softfloat zero() { return softfloat::fromRaw( 0 ); }
205
- /** @brief Positive infinity constant */
206
- static softfloat inf() { return softfloat::fromRaw( 0xFF << 23 ); }
207
- /** @brief Default NaN constant */
208
- static softfloat nan() { return softfloat::fromRaw( 0x7fffffff ); }
209
- /** @brief One constant */
210
- static softfloat one() { return softfloat::fromRaw( 127 << 23 ); }
211
- /** @brief Smallest normalized value */
212
- static softfloat min() { return softfloat::fromRaw( 0x01 << 23 ); }
213
- /** @brief Difference between 1 and next representable value */
214
- static softfloat eps() { return softfloat::fromRaw( (127 - 23) << 23 ); }
215
- /** @brief Biggest finite value */
216
- static softfloat max() { return softfloat::fromRaw( (0xFF << 23) - 1 ); }
217
- /** @brief Correct pi approximation */
218
- static softfloat pi() { return softfloat::fromRaw( 0x40490fdb ); }
219
-
220
- uint32_t v;
221
- };
222
-
223
- /*----------------------------------------------------------------------------
224
- *----------------------------------------------------------------------------*/
225
-
226
- struct CV_EXPORTS softdouble
227
- {
228
- public:
229
- /** @brief Default constructor */
230
- softdouble() : v(0) { }
231
- /** @brief Copy constructor */
232
- softdouble( const softdouble& c) { v = c.v; }
233
- /** @brief Assign constructor */
234
- softdouble& operator=( const softdouble& c )
235
- {
236
- if(&c != this) v = c.v;
237
- return *this;
238
- }
239
- /** @brief Construct from raw
240
-
241
- Builds new value from raw binary representation
242
- */
243
- static softdouble fromRaw( const uint64_t a ) { softdouble x; x.v = a; return x; }
244
-
245
- /** @brief Construct from integer */
246
- explicit softdouble( const uint32_t );
247
- explicit softdouble( const uint64_t );
248
- explicit softdouble( const int32_t );
249
- explicit softdouble( const int64_t );
250
-
251
- #ifdef CV_INT32_T_IS_LONG_INT
252
- // for platforms with int32_t = long int
253
- explicit softdouble( const int a ) { *this = softdouble(static_cast<int32_t>(a)); }
254
- #endif
255
-
256
- /** @brief Construct from double */
257
- explicit softdouble( const double a ) { Cv64suf s; s.f = a; v = s.u; }
258
-
259
- /** @brief Type casts */
260
- operator softfloat() const;
261
- operator double() const { Cv64suf s; s.u = v; return s.f; }
262
-
263
- /** @brief Basic arithmetics */
264
- softdouble operator + (const softdouble&) const;
265
- softdouble operator - (const softdouble&) const;
266
- softdouble operator * (const softdouble&) const;
267
- softdouble operator / (const softdouble&) const;
268
- softdouble operator - () const { softdouble x; x.v = v ^ (1ULL << 63); return x; }
269
-
270
- /** @brief Remainder operator
271
-
272
- A quote from original SoftFloat manual:
273
-
274
- > The IEEE Standard remainder operation computes the value
275
- > a - n * b, where n is the integer closest to a / b.
276
- > If a / b is exactly halfway between two integers, n is the even integer
277
- > closest to a / b. The IEEE Standard’s remainder operation is always exact and so requires no rounding.
278
- > Depending on the relative magnitudes of the operands, the remainder functions
279
- > can take considerably longer to execute than the other SoftFloat functions.
280
- > This is an inherent characteristic of the remainder operation itself and is not a flaw
281
- > in the SoftFloat implementation.
282
- */
283
- softdouble operator % (const softdouble&) const;
284
-
285
- softdouble& operator += (const softdouble& a) { *this = *this + a; return *this; }
286
- softdouble& operator -= (const softdouble& a) { *this = *this - a; return *this; }
287
- softdouble& operator *= (const softdouble& a) { *this = *this * a; return *this; }
288
- softdouble& operator /= (const softdouble& a) { *this = *this / a; return *this; }
289
- softdouble& operator %= (const softdouble& a) { *this = *this % a; return *this; }
290
-
291
- /** @brief Comparison operations
292
-
293
- - Any operation with NaN produces false
294
- + The only exception is when x is NaN: x != y for any y.
295
- - Positive and negative zeros are equal
296
- */
297
- bool operator == ( const softdouble& ) const;
298
- bool operator != ( const softdouble& ) const;
299
- bool operator > ( const softdouble& ) const;
300
- bool operator >= ( const softdouble& ) const;
301
- bool operator < ( const softdouble& ) const;
302
- bool operator <= ( const softdouble& ) const;
303
-
304
- /** @brief NaN state indicator */
305
- inline bool isNaN() const { return (v & 0x7fffffffffffffff) > 0x7ff0000000000000; }
306
- /** @brief Inf state indicator */
307
- inline bool isInf() const { return (v & 0x7fffffffffffffff) == 0x7ff0000000000000; }
308
- /** @brief Subnormal number indicator */
309
- inline bool isSubnormal() const { return ((v >> 52) & 0x7FF) == 0; }
310
-
311
- /** @brief Get sign bit */
312
- inline bool getSign() const { return (v >> 63) != 0; }
313
- /** @brief Construct a copy with new sign bit */
314
- softdouble setSign(bool sign) const { softdouble x; x.v = (v & ((1ULL << 63) - 1)) | ((uint_fast64_t)(sign) << 63); return x; }
315
- /** @brief Get 0-based exponent */
316
- inline int getExp() const { return ((v >> 52) & 0x7FF) - 1023; }
317
- /** @brief Construct a copy with new 0-based exponent */
318
- inline softdouble setExp(int e) const
319
- {
320
- softdouble x;
321
- x.v = (v & 0x800FFFFFFFFFFFFF) | ((uint_fast64_t)((e + 1023) & 0x7FF) << 52);
322
- return x;
323
- }
324
-
325
- /** @brief Get a fraction part
326
-
327
- Returns a number 1 <= x < 2 with the same significand
328
- */
329
- inline softdouble getFrac() const
330
- {
331
- uint_fast64_t vv = (v & 0x000FFFFFFFFFFFFF) | ((uint_fast64_t)(1023) << 52);
332
- return softdouble::fromRaw(vv);
333
- }
334
- /** @brief Construct a copy with provided significand
335
-
336
- Constructs a copy of a number with significand taken from parameter
337
- */
338
- inline softdouble setFrac(const softdouble& s) const
339
- {
340
- softdouble x;
341
- x.v = (v & 0xFFF0000000000000) | (s.v & 0x000FFFFFFFFFFFFF);
342
- return x;
343
- }
344
-
345
- /** @brief Zero constant */
346
- static softdouble zero() { return softdouble::fromRaw( 0 ); }
347
- /** @brief Positive infinity constant */
348
- static softdouble inf() { return softdouble::fromRaw( (uint_fast64_t)(0x7FF) << 52 ); }
349
- /** @brief Default NaN constant */
350
- static softdouble nan() { return softdouble::fromRaw( CV_BIG_INT(0x7FFFFFFFFFFFFFFF) ); }
351
- /** @brief One constant */
352
- static softdouble one() { return softdouble::fromRaw( (uint_fast64_t)( 1023) << 52 ); }
353
- /** @brief Smallest normalized value */
354
- static softdouble min() { return softdouble::fromRaw( (uint_fast64_t)( 0x01) << 52 ); }
355
- /** @brief Difference between 1 and next representable value */
356
- static softdouble eps() { return softdouble::fromRaw( (uint_fast64_t)( 1023 - 52 ) << 52 ); }
357
- /** @brief Biggest finite value */
358
- static softdouble max() { return softdouble::fromRaw( ((uint_fast64_t)(0x7FF) << 52) - 1 ); }
359
- /** @brief Correct pi approximation */
360
- static softdouble pi() { return softdouble::fromRaw( CV_BIG_INT(0x400921FB54442D18) ); }
361
-
362
- uint64_t v;
363
- };
364
-
365
- /*----------------------------------------------------------------------------
366
- *----------------------------------------------------------------------------*/
367
-
368
- /** @brief Fused Multiplication and Addition
369
-
370
- Computes (a*b)+c with single rounding
371
- */
372
- CV_EXPORTS softfloat mulAdd( const softfloat& a, const softfloat& b, const softfloat & c);
373
- CV_EXPORTS softdouble mulAdd( const softdouble& a, const softdouble& b, const softdouble& c);
374
-
375
- /** @brief Square root */
376
- CV_EXPORTS softfloat sqrt( const softfloat& a );
377
- CV_EXPORTS softdouble sqrt( const softdouble& a );
378
- }
379
-
380
- /*----------------------------------------------------------------------------
381
- | Ported from OpenCV and added for usability
382
- *----------------------------------------------------------------------------*/
383
-
384
- /** @brief Truncates number to integer with minimum magnitude */
385
- CV_EXPORTS int cvTrunc(const cv::softfloat& a);
386
- CV_EXPORTS int cvTrunc(const cv::softdouble& a);
387
-
388
- /** @brief Rounds a number to nearest even integer */
389
- CV_EXPORTS int cvRound(const cv::softfloat& a);
390
- CV_EXPORTS int cvRound(const cv::softdouble& a);
391
-
392
- /** @brief Rounds a number to nearest even long long integer */
393
- CV_EXPORTS int64_t cvRound64(const cv::softdouble& a);
394
-
395
- /** @brief Rounds a number down to integer */
396
- CV_EXPORTS int cvFloor(const cv::softfloat& a);
397
- CV_EXPORTS int cvFloor(const cv::softdouble& a);
398
-
399
- /** @brief Rounds number up to integer */
400
- CV_EXPORTS int cvCeil(const cv::softfloat& a);
401
- CV_EXPORTS int cvCeil(const cv::softdouble& a);
402
-
403
- namespace cv
404
- {
405
- /** @brief Saturate casts */
406
- template<typename _Tp> static inline _Tp saturate_cast(softfloat a) { return _Tp(a); }
407
- template<typename _Tp> static inline _Tp saturate_cast(softdouble a) { return _Tp(a); }
408
-
409
- template<> inline uchar saturate_cast<uchar>(softfloat a) { return (uchar)std::max(std::min(cvRound(a), (int)UCHAR_MAX), 0); }
410
- template<> inline uchar saturate_cast<uchar>(softdouble a) { return (uchar)std::max(std::min(cvRound(a), (int)UCHAR_MAX), 0); }
411
-
412
- template<> inline schar saturate_cast<schar>(softfloat a) { return (schar)std::min(std::max(cvRound(a), (int)SCHAR_MIN), (int)SCHAR_MAX); }
413
- template<> inline schar saturate_cast<schar>(softdouble a) { return (schar)std::min(std::max(cvRound(a), (int)SCHAR_MIN), (int)SCHAR_MAX); }
414
-
415
- template<> inline ushort saturate_cast<ushort>(softfloat a) { return (ushort)std::max(std::min(cvRound(a), (int)USHRT_MAX), 0); }
416
- template<> inline ushort saturate_cast<ushort>(softdouble a) { return (ushort)std::max(std::min(cvRound(a), (int)USHRT_MAX), 0); }
417
-
418
- template<> inline short saturate_cast<short>(softfloat a) { return (short)std::min(std::max(cvRound(a), (int)SHRT_MIN), (int)SHRT_MAX); }
419
- template<> inline short saturate_cast<short>(softdouble a) { return (short)std::min(std::max(cvRound(a), (int)SHRT_MIN), (int)SHRT_MAX); }
420
-
421
- template<> inline int saturate_cast<int>(softfloat a) { return cvRound(a); }
422
- template<> inline int saturate_cast<int>(softdouble a) { return cvRound(a); }
423
-
424
- template<> inline int64_t saturate_cast<int64_t>(softfloat a) { return cvRound(a); }
425
- template<> inline int64_t saturate_cast<int64_t>(softdouble a) { return cvRound64(a); }
426
-
427
- /** @brief Saturate cast to unsigned integer and unsigned long long integer
428
- We intentionally do not clip negative numbers, to make -1 become 0xffffffff etc.
429
- */
430
- template<> inline unsigned saturate_cast<unsigned>(softfloat a) { return cvRound(a); }
431
- template<> inline unsigned saturate_cast<unsigned>(softdouble a) { return cvRound(a); }
432
-
433
- template<> inline uint64_t saturate_cast<uint64_t>(softfloat a) { return cvRound(a); }
434
- template<> inline uint64_t saturate_cast<uint64_t>(softdouble a) { return cvRound64(a); }
435
-
436
- /** @brief Min and Max functions */
437
- inline softfloat min(const softfloat& a, const softfloat& b) { return (a > b) ? b : a; }
438
- inline softdouble min(const softdouble& a, const softdouble& b) { return (a > b) ? b : a; }
439
-
440
- inline softfloat max(const softfloat& a, const softfloat& b) { return (a > b) ? a : b; }
441
- inline softdouble max(const softdouble& a, const softdouble& b) { return (a > b) ? a : b; }
442
-
443
- /** @brief Absolute value */
444
- inline softfloat abs( softfloat a) { softfloat x; x.v = a.v & ((1U << 31) - 1); return x; }
445
- inline softdouble abs( softdouble a) { softdouble x; x.v = a.v & ((1ULL << 63) - 1); return x; }
446
-
447
- /** @brief Exponent
448
-
449
- Special cases:
450
- - exp(NaN) is NaN
451
- - exp(-Inf) == 0
452
- - exp(+Inf) == +Inf
453
- */
454
- CV_EXPORTS softfloat exp( const softfloat& a);
455
- CV_EXPORTS softdouble exp( const softdouble& a);
456
-
457
- /** @brief Natural logarithm
458
-
459
- Special cases:
460
- - log(NaN), log(x < 0) are NaN
461
- - log(0) == -Inf
462
- */
463
- CV_EXPORTS softfloat log( const softfloat& a );
464
- CV_EXPORTS softdouble log( const softdouble& a );
465
-
466
- /** @brief Raising to the power
467
-
468
- Special cases:
469
- - x**NaN is NaN for any x
470
- - ( |x| == 1 )**Inf is NaN
471
- - ( |x| > 1 )**+Inf or ( |x| < 1 )**-Inf is +Inf
472
- - ( |x| > 1 )**-Inf or ( |x| < 1 )**+Inf is 0
473
- - x ** 0 == 1 for any x
474
- - x ** 1 == 1 for any x
475
- - NaN ** y is NaN for any other y
476
- - Inf**(y < 0) == 0
477
- - Inf ** y is +Inf for any other y
478
- - (x < 0)**y is NaN for any other y if x can't be correctly rounded to integer
479
- - 0 ** 0 == 1
480
- - 0 ** (y < 0) is +Inf
481
- - 0 ** (y > 0) is 0
482
- */
483
- CV_EXPORTS softfloat pow( const softfloat& a, const softfloat& b);
484
- CV_EXPORTS softdouble pow( const softdouble& a, const softdouble& b);
485
-
486
- /** @brief Cube root
487
-
488
- Special cases:
489
- - cbrt(NaN) is NaN
490
- - cbrt(+/-Inf) is +/-Inf
491
- */
492
- CV_EXPORTS softfloat cbrt( const softfloat& a );
493
-
494
- /** @brief Sine
495
-
496
- Special cases:
497
- - sin(Inf) or sin(NaN) is NaN
498
- - sin(x) == x when sin(x) is close to zero
499
- */
500
- CV_EXPORTS softdouble sin( const softdouble& a );
501
-
502
- /** @brief Cosine
503
- *
504
- Special cases:
505
- - cos(Inf) or cos(NaN) is NaN
506
- - cos(x) == +/- 1 when cos(x) is close to +/- 1
507
- */
508
- CV_EXPORTS softdouble cos( const softdouble& a );
509
-
510
- //! @} core_utils_softfloat
511
-
512
- } // cv::
513
-
514
- #endif