diff --git a/modules/core/include/opencv2/core/hal/intrin_neon.hpp b/modules/core/include/opencv2/core/hal/intrin_neon.hpp index 6f8973231b..14eb180819 100644 --- a/modules/core/include/opencv2/core/hal/intrin_neon.hpp +++ b/modules/core/include/opencv2/core/hal/intrin_neon.hpp @@ -1997,12 +1997,12 @@ inline v_int32x4 v_trunc(const v_float32x4& a) inline v_int32x4 v_round(const v_float64x2& a) { static const int32x2_t zero = vdup_n_s32(0); - return v_int32x4(vcombine_s32(vmovn_s64(vcvtaq_s64_f64(a.val)), zero)); + return v_int32x4(vcombine_s32(vmovn_s64(vcvtnq_s64_f64(a.val)), zero)); } inline v_int32x4 v_round(const v_float64x2& a, const v_float64x2& b) { - return v_int32x4(vcombine_s32(vmovn_s64(vcvtaq_s64_f64(a.val)), vmovn_s64(vcvtaq_s64_f64(b.val)))); + return v_int32x4(vcombine_s32(vmovn_s64(vcvtnq_s64_f64(a.val)), vmovn_s64(vcvtnq_s64_f64(b.val)))); } inline v_int32x4 v_floor(const v_float64x2& a) diff --git a/modules/core/test/test_intrin_utils.hpp b/modules/core/test/test_intrin_utils.hpp index 481e6bb1f2..1ece6de82f 100644 --- a/modules/core/test/test_intrin_utils.hpp +++ b/modules/core/test/test_intrin_utils.hpp @@ -1475,12 +1475,15 @@ template struct TheTest TheTest & test_float_math() { typedef typename V_RegTraits::round_reg Ri; - Data data1, data2, data3; + Data data1, data1_border, data2, data3; + // See https://github.com/opencv/opencv/issues/24213 + data1_border *= 0.5; data1 *= 1.1; data2 += 10; - R a1 = data1, a2 = data2, a3 = data3; + R a1 = data1, a1_border = data1_border, a2 = data2, a3 = data3; Data resB = v_round(a1), + resB_border = v_round(a1_border), resC = v_trunc(a1), resD = v_floor(a1), resE = v_ceil(a1); @@ -1493,6 +1496,7 @@ template struct TheTest { SCOPED_TRACE(cv::format("i=%d", i)); EXPECT_EQ(cvRound(data1[i]), resB[i]); + EXPECT_EQ(cvRound(data1_border[i]), resB_border[i]); EXPECT_EQ((typename VTraits::lane_type)data1[i], resC[i]); EXPECT_EQ(cvFloor(data1[i]), resD[i]); EXPECT_EQ(cvCeil(data1[i]), resE[i]);