Skip to content

Commit ef8c919

Browse files
author
woody.chow
committed
Minor optimization of initUndistortRectifyMapLine_AVX
1 parent 39e7427 commit ef8c919

File tree

1 file changed

+4
-10
lines changed

1 file changed

+4
-10
lines changed

modules/imgproc/src/undistort.avx2.cpp

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -161,16 +161,8 @@ int initUndistortRectifyMapLine_AVX(float* m1f, float* m2f, short* m1, ushort* m
161161
__u = _mm256_mul_pd(__u, _mm256_set1_pd(INTER_TAB_SIZE));
162162
__v = _mm256_mul_pd(__v, _mm256_set1_pd(INTER_TAB_SIZE));
163163

164-
__m128 __u_float = _mm256_cvtpd_ps(__u);
165-
__m128 __v_float = _mm256_cvtpd_ps(__v);
166-
_mm256_zeroupper();
167-
static const __m128 __int_max = _mm_set1_ps((float)(std::numeric_limits<int>::max()));
168-
static const __m128 __int_min = _mm_set1_ps((float)(std::numeric_limits<int>::min()));
169-
__u_float = _mm_max_ps(_mm_min_ps(__u_float, __int_max), __int_min);
170-
__v_float = _mm_max_ps(_mm_min_ps(__v_float, __int_max), __int_min);
171-
172-
__m128i __iu = _mm_cvtps_epi32(__u_float);
173-
__m128i __iv = _mm_cvtps_epi32(__v_float);
164+
__m128i __iu = _mm256_cvtpd_epi32(__u);
165+
__m128i __iv = _mm256_cvtpd_epi32(__v);
174166

175167
static const __m128i __INTER_TAB_SIZE_m1 = _mm_set1_epi32(INTER_TAB_SIZE - 1);
176168
__m128i __m2 = _mm_add_epi32(
@@ -192,6 +184,8 @@ int initUndistortRectifyMapLine_AVX(float* m1f, float* m2f, short* m1, ushort* m
192184
}
193185
}
194186

187+
_mm256_zeroupper();
188+
195189
return j;
196190
}
197191

0 commit comments

Comments
 (0)