EstervQrCode 1.1.1
Library for qr code manipulation
neon_utils.hpp
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) 2015, Itseez Inc., all rights reserved.
14 // Third party copyrights are property of their respective owners.
15 //
16 // Redistribution and use in source and binary forms, with or without modification,
17 // are permitted provided that the following conditions are met:
18 //
19 // * Redistribution's of source code must retain the above copyright notice,
20 // this list of conditions and the following disclaimer.
21 //
22 // * Redistribution's in binary form must reproduce the above copyright notice,
23 // this list of conditions and the following disclaimer in the documentation
24 // and/or other materials provided with the distribution.
25 //
26 // * The name of the copyright holders may not be used to endorse or promote products
27 // derived from this software without specific prior written permission.
28 //
29 // This software is provided by the copyright holders and contributors "as is" and
30 // any express or implied warranties, including, but not limited to, the implied
31 // warranties of merchantability and fitness for a particular purpose are disclaimed.
32 // In no event shall the Intel Corporation or contributors be liable for any direct,
33 // 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
36 // and on any theory of liability, whether in contract, strict liability,
37 // or tort (including negligence or otherwise) arising in any way out of
38 // the use of this software, even if advised of the possibility of such damage.
39 //
40 //M*/
41 
42 #ifndef OPENCV_HAL_NEON_UTILS_HPP
43 #define OPENCV_HAL_NEON_UTILS_HPP
44 
45 #include "opencv2/core/cvdef.h"
46 
49 
50 #if CV_NEON
51 
52 inline int32x2_t cv_vrnd_s32_f32(float32x2_t v)
53 {
54  static int32x2_t v_sign = vdup_n_s32(1 << 31),
55  v_05 = vreinterpret_s32_f32(vdup_n_f32(0.5f));
56 
57  int32x2_t v_addition = vorr_s32(v_05, vand_s32(v_sign, vreinterpret_s32_f32(v)));
58  return vcvt_s32_f32(vadd_f32(v, vreinterpret_f32_s32(v_addition)));
59 }
60 
61 inline int32x4_t cv_vrndq_s32_f32(float32x4_t v)
62 {
63  static int32x4_t v_sign = vdupq_n_s32(1 << 31),
64  v_05 = vreinterpretq_s32_f32(vdupq_n_f32(0.5f));
65 
66  int32x4_t v_addition = vorrq_s32(v_05, vandq_s32(v_sign, vreinterpretq_s32_f32(v)));
67  return vcvtq_s32_f32(vaddq_f32(v, vreinterpretq_f32_s32(v_addition)));
68 }
69 
70 inline uint32x2_t cv_vrnd_u32_f32(float32x2_t v)
71 {
72  static float32x2_t v_05 = vdup_n_f32(0.5f);
73  return vcvt_u32_f32(vadd_f32(v, v_05));
74 }
75 
76 inline uint32x4_t cv_vrndq_u32_f32(float32x4_t v)
77 {
78  static float32x4_t v_05 = vdupq_n_f32(0.5f);
79  return vcvtq_u32_f32(vaddq_f32(v, v_05));
80 }
81 
82 inline float32x4_t cv_vrecpq_f32(float32x4_t val)
83 {
84  float32x4_t reciprocal = vrecpeq_f32(val);
85  reciprocal = vmulq_f32(vrecpsq_f32(val, reciprocal), reciprocal);
86  reciprocal = vmulq_f32(vrecpsq_f32(val, reciprocal), reciprocal);
87  return reciprocal;
88 }
89 
90 inline float32x2_t cv_vrecp_f32(float32x2_t val)
91 {
92  float32x2_t reciprocal = vrecpe_f32(val);
93  reciprocal = vmul_f32(vrecps_f32(val, reciprocal), reciprocal);
94  reciprocal = vmul_f32(vrecps_f32(val, reciprocal), reciprocal);
95  return reciprocal;
96 }
97 
98 inline float32x4_t cv_vrsqrtq_f32(float32x4_t val)
99 {
100  float32x4_t e = vrsqrteq_f32(val);
101  e = vmulq_f32(vrsqrtsq_f32(vmulq_f32(e, e), val), e);
102  e = vmulq_f32(vrsqrtsq_f32(vmulq_f32(e, e), val), e);
103  return e;
104 }
105 
106 inline float32x2_t cv_vrsqrt_f32(float32x2_t val)
107 {
108  float32x2_t e = vrsqrte_f32(val);
109  e = vmul_f32(vrsqrts_f32(vmul_f32(e, e), val), e);
110  e = vmul_f32(vrsqrts_f32(vmul_f32(e, e), val), e);
111  return e;
112 }
113 
114 inline float32x4_t cv_vsqrtq_f32(float32x4_t val)
115 {
116  return cv_vrecpq_f32(cv_vrsqrtq_f32(val));
117 }
118 
119 inline float32x2_t cv_vsqrt_f32(float32x2_t val)
120 {
121  return cv_vrecp_f32(cv_vrsqrt_f32(val));
122 }
123 
124 #endif
125 
127 
128 #endif // OPENCV_HAL_NEON_UTILS_HPP