From 2bd72af2ef06f73e8fb8c0d4915825aeccc5bf03 Mon Sep 17 00:00:00 2001 From: HAN Liutong Date: Sun, 24 Jul 2022 17:15:13 +0800 Subject: [PATCH] Merge pull request #22292 from hanliutong:fix [GSoC] Fix compilation errors and warnings when using MSVC on Windows. * Pass reference of the argument. * Add some cast to suppress warnings. --- modules/core/include/opencv2/core/hal/intrin.hpp | 12 ++++++------ .../include/opencv2/core/hal/intrin_rvv_scalable.hpp | 6 +++--- modules/core/test/test_intrin_utils.hpp | 8 ++++---- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/modules/core/include/opencv2/core/hal/intrin.hpp b/modules/core/include/opencv2/core/hal/intrin.hpp index d79c995a27..a04de3a12d 100644 --- a/modules/core/include/opencv2/core/hal/intrin.hpp +++ b/modules/core/include/opencv2/core/hal/intrin.hpp @@ -714,7 +714,7 @@ namespace CV__SIMD_NAMESPACE { return a - b; \ } \ template \ - inline _Tpvec v_add(_Tpvec f1, _Tpvec f2, Args... vf) { \ + inline _Tpvec v_add(const _Tpvec& f1, const _Tpvec& f2, const Args&... vf) { \ return v_add(f1 + f2, vf...); \ } @@ -765,7 +765,7 @@ namespace CV__SIMD_NAMESPACE { return a * b; \ } \ template \ - inline _Tpvec v_mul(_Tpvec f1, _Tpvec f2, Args... vf) { \ + inline _Tpvec v_mul(const _Tpvec& f1, const _Tpvec& f2, const Args&... vf) { \ return v_mul(f1 * f2, vf...); \ } OPENCV_HAL_WRAP_BIN_OP_MUL(v_uint8) @@ -820,7 +820,7 @@ namespace CV__SIMD_NAMESPACE { //////////// get0 //////////// #define OPENCV_HAL_WRAP_GRT0_INT(_Tpvec, _Tp) \ - inline _Tp v_get0(v_##_Tpvec v) \ + inline _Tp v_get0(const v_##_Tpvec& v) \ { \ return v.get0(); \ } @@ -839,7 +839,7 @@ namespace CV__SIMD_NAMESPACE { #endif #define OPENCV_HAL_WRAP_EXTRACT(_Tpvec, _Tp, vl) \ - inline _Tp v_extract_highest(_Tpvec v) \ + inline _Tp v_extract_highest(const _Tpvec& v) \ { \ return v_extract_n(v); \ } @@ -858,7 +858,7 @@ namespace CV__SIMD_NAMESPACE { #endif #define OPENCV_HAL_WRAP_BROADCAST(_Tpvec) \ - inline _Tpvec v_broadcast_highest(_Tpvec v) \ + inline _Tpvec v_broadcast_highest(const _Tpvec& v) \ { \ return v_broadcast_element::nlanes-1>(v); \ } @@ -868,7 +868,7 @@ namespace CV__SIMD_NAMESPACE { OPENCV_HAL_WRAP_BROADCAST(v_float32) -#endif //CV_SIMD +#endif //!CV_SIMD_SCALABLE //! @cond IGNORED diff --git a/modules/core/include/opencv2/core/hal/intrin_rvv_scalable.hpp b/modules/core/include/opencv2/core/hal/intrin_rvv_scalable.hpp index b984411436..30c7524699 100644 --- a/modules/core/include/opencv2/core/hal/intrin_rvv_scalable.hpp +++ b/modules/core/include/opencv2/core/hal/intrin_rvv_scalable.hpp @@ -123,7 +123,7 @@ struct VTraits //////////// get0 //////////// #define OPENCV_HAL_IMPL_RVV_GRT0_INT(_Tpvec, _Tp) \ -inline _Tp v_get0(v_##_Tpvec v) \ +inline _Tp v_get0(const v_##_Tpvec& v) \ { \ return vmv_x(v); \ } @@ -137,12 +137,12 @@ OPENCV_HAL_IMPL_RVV_GRT0_INT(int32, int) OPENCV_HAL_IMPL_RVV_GRT0_INT(uint64, uint64) OPENCV_HAL_IMPL_RVV_GRT0_INT(int64, int64) -inline float v_get0(v_float32 v) \ +inline float v_get0(const v_float32& v) \ { \ return vfmv_f(v); \ } #if CV_SIMD_SCALABLE_64F -inline double v_get0(v_float64 v) \ +inline double v_get0(const v_float64& v) \ { \ return vfmv_f(v); \ } diff --git a/modules/core/test/test_intrin_utils.hpp b/modules/core/test/test_intrin_utils.hpp index 7477a004ef..763702bf38 100644 --- a/modules/core/test/test_intrin_utils.hpp +++ b/modules/core/test/test_intrin_utils.hpp @@ -1004,7 +1004,7 @@ template struct TheTest TheTest & test_reduce() { Data dataA; - LaneType min = VTraits::vlanes(), max = 0; + LaneType min = (LaneType)VTraits::vlanes(), max = 0; int sum = 0; for (int i = 0; i < VTraits::vlanes(); ++i) { @@ -1016,9 +1016,9 @@ template struct TheTest EXPECT_EQ((LaneType)min, (LaneType)v_reduce_min(a)); EXPECT_EQ((LaneType)max, (LaneType)v_reduce_max(a)); EXPECT_EQ((int)(sum), (int)v_reduce_sum(a)); - dataA[0] += VTraits::vlanes(); + dataA[0] += (LaneType)VTraits::vlanes(); R an = dataA; - min = VTraits::vlanes(); + min = (LaneType)VTraits::vlanes(); for (int i = 0; i < VTraits::vlanes(); ++i) { min = std::min(min, dataA[i]); @@ -1029,7 +1029,7 @@ template struct TheTest TheTest & test_reduce_sad() { - Data dataA, dataB(VTraits::vlanes()/2); + Data dataA, dataB((LaneType)VTraits::vlanes() /2); R a = dataA; R b = dataB; uint sum = 0;