mirror of
https://github.com/opencv/opencv.git
synced 2024-11-24 11:10:21 +08:00
Merge pull request #24215 from Kumataro:fix24213
core: arm64: v_round() works with round to nearest, ties to even.
This commit is contained in:
commit
4dd755443a
@ -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)
|
||||
|
@ -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]);
|
||||
|
Loading…
Reference in New Issue
Block a user