Merge pull request #24215 from Kumataro:fix24213

core: arm64: v_round() works with round to nearest, ties to even.
This commit is contained in:
Alexander Smorkalov 2023-09-04 12:51:02 +03:00 committed by GitHub
commit 4dd755443a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 4 deletions

View File

@ -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)

View File

@ -1475,12 +1475,15 @@ template<typename R> struct TheTest
TheTest & test_float_math()
{
typedef typename V_RegTraits<R>::round_reg Ri;
Data<R> data1, data2, data3;
Data<R> 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<Ri> 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<typename R> 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<Ri>::lane_type)data1[i], resC[i]);
EXPECT_EQ(cvFloor(data1[i]), resD[i]);
EXPECT_EQ(cvCeil(data1[i]), resE[i]);