mirror of
https://github.com/opencv/opencv.git
synced 2026-07-31 08:13:04 +04:00
Merge branch 4.x
This commit is contained in:
@@ -3201,6 +3201,10 @@ public:
|
||||
* @overload
|
||||
*/
|
||||
CV_WRAP void write(FileStorage& fs, const String& name) const;
|
||||
#if CV_VERSION_MAJOR < 5
|
||||
/** @deprecated */
|
||||
void write(const Ptr<FileStorage>& fs, const String& name = String()) const;
|
||||
#endif
|
||||
|
||||
/** @brief Reads algorithm parameters from a file storage
|
||||
*/
|
||||
|
||||
@@ -75,20 +75,6 @@ String dumpString(const String& argument)
|
||||
return cv::format("String: %s", argument.c_str());
|
||||
}
|
||||
|
||||
CV_WRAP static inline
|
||||
String testOverloadResolution(int value, const Point& point = Point(42, 24))
|
||||
{
|
||||
return format("overload (int=%d, point=(x=%d, y=%d))", value, point.x,
|
||||
point.y);
|
||||
}
|
||||
|
||||
CV_WRAP static inline
|
||||
String testOverloadResolution(const Rect& rect)
|
||||
{
|
||||
return format("overload (rect=(x=%d, y=%d, w=%d, h=%d))", rect.x, rect.y,
|
||||
rect.width, rect.height);
|
||||
}
|
||||
|
||||
CV_WRAP static inline
|
||||
String dumpRect(const Rect& argument)
|
||||
{
|
||||
@@ -111,6 +97,42 @@ String dumpRotatedRect(const RotatedRect& argument)
|
||||
argument.size.height, argument.angle);
|
||||
}
|
||||
|
||||
CV_WRAP static inline
|
||||
String dumpRange(const Range& argument)
|
||||
{
|
||||
if (argument == Range::all())
|
||||
{
|
||||
return "range: all";
|
||||
}
|
||||
else
|
||||
{
|
||||
return format("range: (s=%d, e=%d)", argument.start, argument.end);
|
||||
}
|
||||
}
|
||||
|
||||
CV_EXPORTS_W String dumpVectorOfInt(const std::vector<int>& vec);
|
||||
|
||||
CV_EXPORTS_W String dumpVectorOfDouble(const std::vector<double>& vec);
|
||||
|
||||
CV_EXPORTS_W String dumpVectorOfRect(const std::vector<Rect>& vec);
|
||||
|
||||
|
||||
//! @cond IGNORED
|
||||
|
||||
CV_WRAP static inline
|
||||
String testOverloadResolution(int value, const Point& point = Point(42, 24))
|
||||
{
|
||||
return format("overload (int=%d, point=(x=%d, y=%d))", value, point.x,
|
||||
point.y);
|
||||
}
|
||||
|
||||
CV_WRAP static inline
|
||||
String testOverloadResolution(const Rect& rect)
|
||||
{
|
||||
return format("overload (rect=(x=%d, y=%d, w=%d, h=%d))", rect.x, rect.y,
|
||||
rect.width, rect.height);
|
||||
}
|
||||
|
||||
CV_WRAP static inline
|
||||
RotatedRect testRotatedRect(float x, float y, float w, float h, float angle)
|
||||
{
|
||||
@@ -126,19 +148,6 @@ std::vector<RotatedRect> testRotatedRectVector(float x, float y, float w, float
|
||||
return result;
|
||||
}
|
||||
|
||||
CV_WRAP static inline
|
||||
String dumpRange(const Range& argument)
|
||||
{
|
||||
if (argument == Range::all())
|
||||
{
|
||||
return "range: all";
|
||||
}
|
||||
else
|
||||
{
|
||||
return format("range: (s=%d, e=%d)", argument.start, argument.end);
|
||||
}
|
||||
}
|
||||
|
||||
CV_WRAP static inline
|
||||
int testOverwriteNativeMethod(int argument)
|
||||
{
|
||||
@@ -151,12 +160,6 @@ String testReservedKeywordConversion(int positional_argument, int lambda = 2, in
|
||||
return format("arg=%d, lambda=%d, from=%d", positional_argument, lambda, from);
|
||||
}
|
||||
|
||||
CV_EXPORTS_W String dumpVectorOfInt(const std::vector<int>& vec);
|
||||
|
||||
CV_EXPORTS_W String dumpVectorOfDouble(const std::vector<double>& vec);
|
||||
|
||||
CV_EXPORTS_W String dumpVectorOfRect(const std::vector<Rect>& vec);
|
||||
|
||||
CV_WRAP static inline
|
||||
void generateVectorOfRect(size_t len, CV_OUT std::vector<Rect>& vec)
|
||||
{
|
||||
@@ -323,6 +326,8 @@ private:
|
||||
typedef OriginalClassName::Params OriginalClassName_Params;
|
||||
} // namespace nested
|
||||
|
||||
//! @endcond IGNORED
|
||||
|
||||
namespace fs {
|
||||
CV_EXPORTS_W cv::String getCacheDirectoryForDownloads();
|
||||
} // namespace fs
|
||||
|
||||
@@ -441,6 +441,48 @@
|
||||
#endif
|
||||
#define __CV_CPU_DISPATCH_CHAIN_NEON_DOTPROD(fn, args, mode, ...) CV_CPU_CALL_NEON_DOTPROD(fn, args); __CV_EXPAND(__CV_CPU_DISPATCH_CHAIN_ ## mode(fn, args, __VA_ARGS__))
|
||||
|
||||
#if !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_COMPILE_NEON_FP16
|
||||
# define CV_TRY_NEON_FP16 1
|
||||
# define CV_CPU_FORCE_NEON_FP16 1
|
||||
# define CV_CPU_HAS_SUPPORT_NEON_FP16 1
|
||||
# define CV_CPU_CALL_NEON_FP16(fn, args) return (cpu_baseline::fn args)
|
||||
# define CV_CPU_CALL_NEON_FP16_(fn, args) return (opt_NEON_FP16::fn args)
|
||||
#elif !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_DISPATCH_COMPILE_NEON_FP16
|
||||
# define CV_TRY_NEON_FP16 1
|
||||
# define CV_CPU_FORCE_NEON_FP16 0
|
||||
# define CV_CPU_HAS_SUPPORT_NEON_FP16 (cv::checkHardwareSupport(CV_CPU_NEON_FP16))
|
||||
# define CV_CPU_CALL_NEON_FP16(fn, args) if (CV_CPU_HAS_SUPPORT_NEON_FP16) return (opt_NEON_FP16::fn args)
|
||||
# define CV_CPU_CALL_NEON_FP16_(fn, args) if (CV_CPU_HAS_SUPPORT_NEON_FP16) return (opt_NEON_FP16::fn args)
|
||||
#else
|
||||
# define CV_TRY_NEON_FP16 0
|
||||
# define CV_CPU_FORCE_NEON_FP16 0
|
||||
# define CV_CPU_HAS_SUPPORT_NEON_FP16 0
|
||||
# define CV_CPU_CALL_NEON_FP16(fn, args)
|
||||
# define CV_CPU_CALL_NEON_FP16_(fn, args)
|
||||
#endif
|
||||
#define __CV_CPU_DISPATCH_CHAIN_NEON_FP16(fn, args, mode, ...) CV_CPU_CALL_NEON_FP16(fn, args); __CV_EXPAND(__CV_CPU_DISPATCH_CHAIN_ ## mode(fn, args, __VA_ARGS__))
|
||||
|
||||
#if !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_COMPILE_NEON_BF16
|
||||
# define CV_TRY_NEON_BF16 1
|
||||
# define CV_CPU_FORCE_NEON_BF16 1
|
||||
# define CV_CPU_HAS_SUPPORT_NEON_BF16 1
|
||||
# define CV_CPU_CALL_NEON_BF16(fn, args) return (cpu_baseline::fn args)
|
||||
# define CV_CPU_CALL_NEON_BF16_(fn, args) return (opt_NEON_BF16::fn args)
|
||||
#elif !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_DISPATCH_COMPILE_NEON_BF16
|
||||
# define CV_TRY_NEON_BF16 1
|
||||
# define CV_CPU_FORCE_NEON_BF16 0
|
||||
# define CV_CPU_HAS_SUPPORT_NEON_BF16 (cv::checkHardwareSupport(CV_CPU_NEON_BF16))
|
||||
# define CV_CPU_CALL_NEON_BF16(fn, args) if (CV_CPU_HAS_SUPPORT_NEON_BF16) return (opt_NEON_BF16::fn args)
|
||||
# define CV_CPU_CALL_NEON_BF16_(fn, args) if (CV_CPU_HAS_SUPPORT_NEON_BF16) return (opt_NEON_BF16::fn args)
|
||||
#else
|
||||
# define CV_TRY_NEON_BF16 0
|
||||
# define CV_CPU_FORCE_NEON_BF16 0
|
||||
# define CV_CPU_HAS_SUPPORT_NEON_BF16 0
|
||||
# define CV_CPU_CALL_NEON_BF16(fn, args)
|
||||
# define CV_CPU_CALL_NEON_BF16_(fn, args)
|
||||
#endif
|
||||
#define __CV_CPU_DISPATCH_CHAIN_NEON_BF16(fn, args, mode, ...) CV_CPU_CALL_NEON_BF16(fn, args); __CV_EXPAND(__CV_CPU_DISPATCH_CHAIN_ ## mode(fn, args, __VA_ARGS__))
|
||||
|
||||
#if !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_COMPILE_MSA
|
||||
# define CV_TRY_MSA 1
|
||||
# define CV_CPU_FORCE_MSA 1
|
||||
|
||||
@@ -68,7 +68,7 @@
|
||||
// nothing, intrinsics/asm code is not supported
|
||||
#else
|
||||
#if ((defined _MSC_VER && defined _M_X64) \
|
||||
|| (defined __GNUC__ && defined __x86_64__ && defined __SSE2__)) \
|
||||
|| (defined __GNUC__ && defined __SSE2__)) \
|
||||
&& !defined(OPENCV_SKIP_INCLUDE_EMMINTRIN_H)
|
||||
#include <emmintrin.h>
|
||||
#endif
|
||||
|
||||
@@ -246,12 +246,6 @@ using namespace CV_CPU_OPTIMIZATION_HAL_NAMESPACE;
|
||||
|
||||
#include "opencv2/core/hal/intrin_lsx.hpp"
|
||||
|
||||
#elif CV_LASX
|
||||
#if !defined(CV_FORCE_SIMD128_CPP)
|
||||
#define CV_FORCE_SIMD128_CPP 1
|
||||
#endif
|
||||
#include "opencv2/core/hal/intrin_cpp.hpp"
|
||||
|
||||
#else
|
||||
|
||||
#include "opencv2/core/hal/intrin_cpp.hpp"
|
||||
|
||||
@@ -1419,20 +1419,6 @@ inline v_uint32x8 v_popcount(const v_int32x8& a)
|
||||
inline v_uint64x4 v_popcount(const v_int64x4& a)
|
||||
{ return v_popcount(v_reinterpret_as_u64(a)); }
|
||||
|
||||
/** Mask **/
|
||||
#define OPENCV_HAL_IMPL_REINTERPRET_INT(ft, tt) \
|
||||
inline tt reinterpret_int(ft x) { union { ft l; tt i; } v; v.l = x; return v.i; }
|
||||
OPENCV_HAL_IMPL_REINTERPRET_INT(uchar, schar)
|
||||
OPENCV_HAL_IMPL_REINTERPRET_INT(schar, schar)
|
||||
OPENCV_HAL_IMPL_REINTERPRET_INT(ushort, short)
|
||||
OPENCV_HAL_IMPL_REINTERPRET_INT(short, short)
|
||||
OPENCV_HAL_IMPL_REINTERPRET_INT(unsigned, int)
|
||||
OPENCV_HAL_IMPL_REINTERPRET_INT(int, int)
|
||||
OPENCV_HAL_IMPL_REINTERPRET_INT(float, int)
|
||||
OPENCV_HAL_IMPL_REINTERPRET_INT(uint64, int64)
|
||||
OPENCV_HAL_IMPL_REINTERPRET_INT(int64, int64)
|
||||
OPENCV_HAL_IMPL_REINTERPRET_INT(double, int64)
|
||||
|
||||
inline int v_signmask(const v_int8x32& a)
|
||||
{
|
||||
__m256i result = __lasx_xvmskltz_b(a.val);
|
||||
@@ -2151,7 +2137,8 @@ template<int n> inline
|
||||
void v_rshr_pack_store(uchar* ptr, const v_uint16x16& a)
|
||||
{
|
||||
__m256i res = __lasx_xvssrlrni_bu_h(a.val, a.val, n);
|
||||
__lsx_vst(_v256_extract_low(_v256_shuffle_odd_64(res)), ptr, 0);
|
||||
__lasx_xvstelm_d(res, ptr, 0, 0);
|
||||
__lasx_xvstelm_d(res, ptr, 8, 2);
|
||||
}
|
||||
|
||||
template<int n> inline
|
||||
@@ -2165,7 +2152,8 @@ template<int n> inline
|
||||
void v_rshr_pack_u_store(uchar* ptr, const v_int16x16& a)
|
||||
{
|
||||
__m256i res = __lasx_xvssrarni_bu_h(a.val, a.val, n);
|
||||
__lsx_vst(_v256_extract_low(_v256_shuffle_odd_64(res)), ptr, 0);
|
||||
__lasx_xvstelm_d(res, ptr, 0, 0);
|
||||
__lasx_xvstelm_d(res, ptr, 8, 2);
|
||||
}
|
||||
|
||||
template<int n> inline
|
||||
@@ -2179,7 +2167,8 @@ template<int n> inline
|
||||
void v_rshr_pack_store(schar* ptr, const v_int16x16& a)
|
||||
{
|
||||
__m256i res = __lasx_xvssrarni_b_h(a.val, a.val, n);
|
||||
__lsx_vst(_v256_extract_low(_v256_shuffle_odd_64(res)), ptr, 0);
|
||||
__lasx_xvstelm_d(res, ptr, 0, 0);
|
||||
__lasx_xvstelm_d(res, ptr, 8, 2);
|
||||
}
|
||||
|
||||
// 32
|
||||
@@ -2198,7 +2187,8 @@ inline void v_pack_store(short* ptr, const v_int32x8& a)
|
||||
inline void v_pack_store(ushort* ptr, const v_uint32x8& a)
|
||||
{
|
||||
__m256i res = __lasx_xvssrlrni_hu_w(a.val, a.val, 0);
|
||||
__lsx_vst(_v256_extract_low(_v256_shuffle_odd_64(res)), ptr, 0);
|
||||
__lasx_xvstelm_d(res, ptr, 0, 0);
|
||||
__lasx_xvstelm_d(res, ptr, 8, 2);
|
||||
}
|
||||
|
||||
inline void v_pack_u_store(ushort* ptr, const v_int32x8& a)
|
||||
@@ -2212,7 +2202,8 @@ template<int n> inline
|
||||
void v_rshr_pack_store(ushort* ptr, const v_uint32x8& a)
|
||||
{
|
||||
__m256i res = __lasx_xvssrlrni_hu_w(a.val, a.val, n);
|
||||
__lsx_vst(_v256_extract_low(_v256_shuffle_odd_64(res)), ptr, 0);
|
||||
__lasx_xvstelm_d(res, ptr, 0, 0);
|
||||
__lasx_xvstelm_d(res, ptr, 8, 2);
|
||||
}
|
||||
|
||||
template<int n> inline
|
||||
@@ -2223,7 +2214,8 @@ template<int n> inline
|
||||
void v_rshr_pack_u_store(ushort* ptr, const v_int32x8& a)
|
||||
{
|
||||
__m256i res = __lasx_xvssrarni_hu_w(a.val, a.val, n);
|
||||
__lsx_vst(_v256_extract_low(_v256_shuffle_odd_64(res)), ptr, 0);
|
||||
__lasx_xvstelm_d(res, ptr, 0, 0);
|
||||
__lasx_xvstelm_d(res, ptr, 8, 2);
|
||||
}
|
||||
|
||||
template<int n> inline
|
||||
@@ -2234,7 +2226,8 @@ template<int n> inline
|
||||
void v_rshr_pack_store(short* ptr, const v_int32x8& a)
|
||||
{
|
||||
__m256i res = __lasx_xvssrarni_h_w(a.val, a.val, n);
|
||||
__lsx_vst(_v256_extract_low(_v256_shuffle_odd_64(res)), ptr, 0);
|
||||
__lasx_xvstelm_d(res, ptr, 0, 0);
|
||||
__lasx_xvstelm_d(res, ptr, 8, 2);
|
||||
}
|
||||
|
||||
// 64
|
||||
@@ -2263,7 +2256,11 @@ v_uint32x8 v_rshr_pack(const v_uint64x4& a, const v_uint64x4& b)
|
||||
|
||||
template<int n> inline
|
||||
void v_rshr_pack_store(unsigned* ptr, const v_uint64x4& a)
|
||||
{ __lsx_vst(_v256_shuffle_odd_64(__lasx_xvsrlrni_w_d(a.val, a.val, n)), ptr, 0); }
|
||||
{
|
||||
__m256i res = __lasx_xvsrlrni_w_d(a.val, a.val, n);
|
||||
__lasx_xvstelm_d(res, ptr, 0, 0);
|
||||
__lasx_xvstelm_d(res, ptr, 8, 2);
|
||||
}
|
||||
|
||||
template<int n> inline
|
||||
v_int32x8 v_rshr_pack(const v_int64x4& a, const v_int64x4& b)
|
||||
@@ -2271,7 +2268,11 @@ v_int32x8 v_rshr_pack(const v_int64x4& a, const v_int64x4& b)
|
||||
|
||||
template<int n> inline
|
||||
void v_rshr_pack_store(int* ptr, const v_int64x4& a)
|
||||
{ __lsx_vst(_v256_shuffle_odd_64(__lasx_xvsrarni_w_d(a.val, a.val, n)), ptr, 0); }
|
||||
{
|
||||
__m256i res = __lasx_xvsrarni_w_d(a.val, a.val, n);
|
||||
__lasx_xvstelm_d(res, ptr, 0, 0);
|
||||
__lasx_xvstelm_d(res, ptr, 8, 2);
|
||||
}
|
||||
|
||||
// pack boolean
|
||||
inline v_uint8x32 v_pack_b(const v_uint16x16& a, const v_uint16x16& b)
|
||||
|
||||
@@ -2007,11 +2007,9 @@ inline v_int32x4 v_round(const v_float32x4& a)
|
||||
#else
|
||||
inline v_int32x4 v_round(const v_float32x4& a)
|
||||
{
|
||||
static const int32x4_t v_sign = vdupq_n_s32(1 << 31),
|
||||
v_05 = vreinterpretq_s32_f32(vdupq_n_f32(0.5f));
|
||||
|
||||
int32x4_t v_addition = vorrq_s32(v_05, vandq_s32(v_sign, vreinterpretq_s32_f32(a.val)));
|
||||
return v_int32x4(vcvtq_s32_f32(vaddq_f32(a.val, vreinterpretq_f32_s32(v_addition))));
|
||||
// See https://github.com/opencv/opencv/pull/24271#issuecomment-1867318007
|
||||
float32x4_t delta = vdupq_n_f32(12582912.0f);
|
||||
return v_int32x4(vcvtq_s32_f32(vsubq_f32(vaddq_f32(a.val, delta), delta)));
|
||||
}
|
||||
#endif
|
||||
inline v_int32x4 v_floor(const v_float32x4& a)
|
||||
|
||||
@@ -32,6 +32,8 @@
|
||||
namespace cv
|
||||
{
|
||||
|
||||
//! @cond IGNORED
|
||||
|
||||
CV_CPU_OPTIMIZATION_HAL_NAMESPACE_BEGIN
|
||||
|
||||
#define CV_SIMD128 1
|
||||
@@ -3336,7 +3338,8 @@ inline void v_cleanup() {}
|
||||
|
||||
CV_CPU_OPTIMIZATION_HAL_NAMESPACE_END
|
||||
|
||||
//! @endcond
|
||||
|
||||
}
|
||||
} // namespace cv
|
||||
|
||||
#endif
|
||||
|
||||
@@ -2536,5 +2536,5 @@ CV_CPU_OPTIMIZATION_HAL_NAMESPACE_END
|
||||
|
||||
//! @endcond
|
||||
|
||||
}
|
||||
} // namespace cv
|
||||
#endif
|
||||
|
||||
@@ -38,6 +38,9 @@
|
||||
|
||||
namespace cv
|
||||
{
|
||||
|
||||
//! @cond IGNORED
|
||||
|
||||
CV_CPU_OPTIMIZATION_HAL_NAMESPACE_BEGIN
|
||||
|
||||
#define CV_SIMD_SCALABLE 1
|
||||
@@ -445,29 +448,7 @@ OPENCV_HAL_IMPL_RVV_LOADSTORE_OP(v_float64, vfloat64m1_t, double, VTraits<v_floa
|
||||
#define OPENCV_HAL_IMPL_RVV_LUT(_Tpvec, _Tp, suffix) \
|
||||
inline _Tpvec v_lut(const _Tp* tab, const int* idx) \
|
||||
{ \
|
||||
vuint32##suffix##_t vidx = vmul(vreinterpret_u32##suffix(vle32_v_i32##suffix(idx, VTraits<_Tpvec>::vlanes())), sizeof(_Tp), VTraits<_Tpvec>::vlanes()); \
|
||||
return vloxei32(tab, vidx, VTraits<_Tpvec>::vlanes()); \
|
||||
} \
|
||||
inline _Tpvec v_lut_pairs(const _Tp* tab, const int* idx) \
|
||||
{ \
|
||||
std::vector<uint> idx_; \
|
||||
for (int i = 0; i < VTraits<v_int16>::vlanes(); ++i) { \
|
||||
idx_.push_back(idx[i]); \
|
||||
idx_.push_back(idx[i]+1); \
|
||||
} \
|
||||
vuint32##suffix##_t vidx = vmul(vle32_v_u32##suffix(idx_.data(), VTraits<_Tpvec>::vlanes()), sizeof(_Tp), VTraits<_Tpvec>::vlanes()); \
|
||||
return vloxei32(tab, vidx, VTraits<_Tpvec>::vlanes()); \
|
||||
} \
|
||||
inline _Tpvec v_lut_quads(const _Tp* tab, const int* idx) \
|
||||
{ \
|
||||
std::vector<uint> idx_; \
|
||||
for (int i = 0; i < VTraits<v_int32>::vlanes(); ++i) { \
|
||||
idx_.push_back(idx[i]); \
|
||||
idx_.push_back(idx[i]+1); \
|
||||
idx_.push_back(idx[i]+2); \
|
||||
idx_.push_back(idx[i]+3); \
|
||||
} \
|
||||
vuint32##suffix##_t vidx = vmul(vle32_v_u32##suffix(idx_.data(), VTraits<_Tpvec>::vlanes()), sizeof(_Tp), VTraits<_Tpvec>::vlanes()); \
|
||||
auto vidx = vmul(vreinterpret_u32##suffix(vle32_v_i32##suffix(idx, VTraits<_Tpvec>::vlanes())), sizeof(_Tp), VTraits<_Tpvec>::vlanes()); \
|
||||
return vloxei32(tab, vidx, VTraits<_Tpvec>::vlanes()); \
|
||||
}
|
||||
OPENCV_HAL_IMPL_RVV_LUT(v_int8, schar, m4)
|
||||
@@ -479,6 +460,55 @@ OPENCV_HAL_IMPL_RVV_LUT(v_float32, float, m1)
|
||||
OPENCV_HAL_IMPL_RVV_LUT(v_float64, double, mf2)
|
||||
#endif
|
||||
|
||||
#define OPENCV_HAL_IMPL_RVV_LUT_PAIRS(_Tpvec, _Tp, suffix1, suffix2, v_trunc) \
|
||||
inline _Tpvec v_lut_pairs(const _Tp* tab, const int* idx) \
|
||||
{ \
|
||||
auto v0 = vle32_v_u32##suffix1((unsigned*)idx, VTraits<_Tpvec>::vlanes()/2); \
|
||||
auto v1 = vadd(v0, 1, VTraits<_Tpvec>::vlanes()/2); \
|
||||
auto w0 = vwcvtu_x(v0, VTraits<_Tpvec>::vlanes()/2); \
|
||||
auto w1 = vwcvtu_x(v1, VTraits<_Tpvec>::vlanes()/2); \
|
||||
auto sh1 = vslide1up(v_trunc(vreinterpret_u32##suffix2(w1)),0, VTraits<_Tpvec>::vlanes()); \
|
||||
auto vid = vor(sh1, v_trunc(vreinterpret_u32##suffix2(w0)), VTraits<_Tpvec>::vlanes()); \
|
||||
auto vidx = vmul(vid, sizeof(_Tp), VTraits<_Tpvec>::vlanes()); \
|
||||
return vloxei32(tab, vidx, VTraits<_Tpvec>::vlanes()); \
|
||||
}
|
||||
OPENCV_HAL_IMPL_RVV_LUT_PAIRS(v_int8, schar, m2, m4, OPENCV_HAL_NOP)
|
||||
OPENCV_HAL_IMPL_RVV_LUT_PAIRS(v_int16, short, m1, m2, OPENCV_HAL_NOP)
|
||||
OPENCV_HAL_IMPL_RVV_LUT_PAIRS(v_int32, int, mf2, m1, OPENCV_HAL_NOP)
|
||||
OPENCV_HAL_IMPL_RVV_LUT_PAIRS(v_float32, float, mf2, m1, OPENCV_HAL_NOP)
|
||||
OPENCV_HAL_IMPL_RVV_LUT_PAIRS(v_int64, int64_t, mf2, m1, vlmul_trunc_u32mf2)
|
||||
#if CV_SIMD_SCALABLE_64F
|
||||
OPENCV_HAL_IMPL_RVV_LUT_PAIRS(v_float64, double, mf2, m1, vlmul_trunc_u32mf2)
|
||||
#endif
|
||||
|
||||
|
||||
#define OPENCV_HAL_IMPL_RVV_LUT_QUADS(_Tpvec, _Tp, suffix0, suffix1, suffix2, v_trunc) \
|
||||
inline _Tpvec v_lut_quads(const _Tp* tab, const int* idx) \
|
||||
{ \
|
||||
auto v0 = vle32_v_u32##suffix0((unsigned*)idx, VTraits<_Tpvec>::vlanes()/4); \
|
||||
auto v1 = vadd(v0, 1, VTraits<_Tpvec>::vlanes()/4); \
|
||||
auto v2 = vadd(v0, 2, VTraits<_Tpvec>::vlanes()/4); \
|
||||
auto v3 = vadd(v0, 3, VTraits<_Tpvec>::vlanes()/4); \
|
||||
auto w0 = vwcvtu_x(v0, VTraits<_Tpvec>::vlanes()/4); \
|
||||
auto w1 = vwcvtu_x(v1, VTraits<_Tpvec>::vlanes()/4); \
|
||||
auto w2 = vwcvtu_x(v2, VTraits<_Tpvec>::vlanes()/4); \
|
||||
auto w3 = vwcvtu_x(v3, VTraits<_Tpvec>::vlanes()/4); \
|
||||
auto sh2 = vslide1up(vreinterpret_u32##suffix1(w2),0, VTraits<_Tpvec>::vlanes()/2); \
|
||||
auto sh3 = vslide1up(vreinterpret_u32##suffix1(w3),0, VTraits<_Tpvec>::vlanes()/2); \
|
||||
auto vid0 = vor(sh2, vreinterpret_u32##suffix1(w0), VTraits<_Tpvec>::vlanes()/2); \
|
||||
auto vid1 = vor(sh3, vreinterpret_u32##suffix1(w1), VTraits<_Tpvec>::vlanes()/2); \
|
||||
auto wid0 = vwcvtu_x(v_trunc(vid0), VTraits<_Tpvec>::vlanes()/2); \
|
||||
auto wid1 = vwcvtu_x(v_trunc(vid1), VTraits<_Tpvec>::vlanes()/2); \
|
||||
auto shwid1 = vslide1up(vreinterpret_u32##suffix2(wid1),0, VTraits<_Tpvec>::vlanes()); \
|
||||
auto vid = vor(shwid1, vreinterpret_u32##suffix2(wid0), VTraits<_Tpvec>::vlanes()); \
|
||||
auto vidx = vmul(vid, sizeof(_Tp), VTraits<_Tpvec>::vlanes()); \
|
||||
return vloxei32(tab, vidx, VTraits<_Tpvec>::vlanes()); \
|
||||
}
|
||||
OPENCV_HAL_IMPL_RVV_LUT_QUADS(v_int8, schar, m1, m2, m4, OPENCV_HAL_NOP)
|
||||
OPENCV_HAL_IMPL_RVV_LUT_QUADS(v_int16, short, mf2 , m1, m2, OPENCV_HAL_NOP)
|
||||
OPENCV_HAL_IMPL_RVV_LUT_QUADS(v_int32, int, mf2, m1, m1, vlmul_trunc_u32mf2)
|
||||
OPENCV_HAL_IMPL_RVV_LUT_QUADS(v_float32, float, mf2, m1, m1, vlmul_trunc_u32mf2)
|
||||
|
||||
#define OPENCV_HAL_IMPL_RVV_LUT_VEC(_Tpvec, _Tp) \
|
||||
inline _Tpvec v_lut(const _Tp* tab, const v_int32& vidx) \
|
||||
{ \
|
||||
@@ -509,7 +539,6 @@ inline v_uint32 v_lut_pairs(const unsigned* tab, const int* idx) { return v_rein
|
||||
inline v_uint32 v_lut_quads(const unsigned* tab, const int* idx) { return v_reinterpret_as_u32(v_lut_quads((int*)tab, idx)); }
|
||||
inline v_uint64 v_lut(const uint64* tab, const int* idx) { return v_reinterpret_as_u64(v_lut((const int64_t *)tab, idx)); }
|
||||
inline v_uint64 v_lut_pairs(const uint64* tab, const int* idx) { return v_reinterpret_as_u64(v_lut_pairs((const int64_t *)tab, idx)); }
|
||||
inline v_uint64 v_lut_quads(const uint64* tab, const int* idx) { return v_reinterpret_as_u64(v_lut_quads((const int64_t*)tab, idx)); }
|
||||
|
||||
////////////// Pack boolean ////////////////////
|
||||
inline v_uint8 v_pack_b(const v_uint16& a, const v_uint16& b)
|
||||
@@ -1390,23 +1419,23 @@ OPENCV_HAL_IMPL_RVV_REVERSE(v_float64, 64)
|
||||
#define OPENCV_HAL_IMPL_RVV_EXPAND(_Tp, _Tpwvec, _Tpwvec_m2, _Tpvec, width, suffix, suffix2, cvt) \
|
||||
inline void v_expand(const _Tpvec& a, _Tpwvec& b0, _Tpwvec& b1) \
|
||||
{ \
|
||||
_Tpwvec_m2 temp = cvt(a, vsetvlmax_e##width##m1()); \
|
||||
_Tpwvec_m2 temp = cvt(a, VTraits<_Tpvec>::vlanes()); \
|
||||
b0 = vget_##suffix##m1(temp, 0); \
|
||||
b1 = vget_##suffix##m1(temp, 1); \
|
||||
} \
|
||||
inline _Tpwvec v_expand_low(const _Tpvec& a) \
|
||||
{ \
|
||||
_Tpwvec_m2 temp = cvt(a, vsetvlmax_e##width##m1()); \
|
||||
_Tpwvec_m2 temp = cvt(a, VTraits<_Tpvec>::vlanes()); \
|
||||
return vget_##suffix##m1(temp, 0); \
|
||||
} \
|
||||
inline _Tpwvec v_expand_high(const _Tpvec& a) \
|
||||
{ \
|
||||
_Tpwvec_m2 temp = cvt(a, vsetvlmax_e##width##m1()); \
|
||||
_Tpwvec_m2 temp = cvt(a, VTraits<_Tpvec>::vlanes()); \
|
||||
return vget_##suffix##m1(temp, 1); \
|
||||
} \
|
||||
inline _Tpwvec v_load_expand(const _Tp* ptr) \
|
||||
{ \
|
||||
return cvt(vle##width##_v_##suffix2##mf2(ptr, vsetvlmax_e##width##m1()), vsetvlmax_e##width##m1()); \
|
||||
return cvt(vle##width##_v_##suffix2##mf2(ptr, VTraits<_Tpvec>::vlanes()), VTraits<_Tpvec>::vlanes()); \
|
||||
}
|
||||
|
||||
OPENCV_HAL_IMPL_RVV_EXPAND(uchar, v_uint16, vuint16m2_t, v_uint8, 8, u16, u8, vwcvtu_x)
|
||||
@@ -1759,8 +1788,8 @@ inline int v_scan_forward(const v_float64& a)
|
||||
// mask: {0,0,0,1, ...} -> {T,T,T,F, ...}
|
||||
#define OPENCV_HAL_IMPL_RVV_PACK_TRIPLETS(_Tpvec, v_trunc) \
|
||||
inline _Tpvec v_pack_triplets(const _Tpvec& vec) { \
|
||||
size_t vl = vsetvlmax_e8m1(); \
|
||||
vuint32m1_t one = vmv_v_x_u32m1(1, vl/4); \
|
||||
size_t vl = __cv_rvv_e8m1_nlanes; \
|
||||
vuint32m1_t one = vmv_v_x_u32m1(1, __cv_rvv_e32m1_nlanes); \
|
||||
vuint8m1_t zero = vmv_v_x_u8m1(0, vl); \
|
||||
vuint8m1_t mask = vreinterpret_u8m1(one); \
|
||||
return vcompress(vmseq(v_trunc(vslideup(zero, mask, 3, vl)), 0, vl), vec, vec, VTraits<_Tpvec>::vlanes()); \
|
||||
@@ -2126,6 +2155,8 @@ inline void v_cleanup() {}
|
||||
|
||||
CV_CPU_OPTIMIZATION_HAL_NAMESPACE_END
|
||||
|
||||
//! @endcond
|
||||
|
||||
} //namespace cv
|
||||
|
||||
#endif //OPENCV_HAL_INTRIN_RVV_SCALABLE_HPP
|
||||
|
||||
@@ -781,7 +781,7 @@ inline Matx<_Tp, m, n>::operator Matx<T2, m, n>() const
|
||||
template<typename _Tp, int m, int n> template<int m1, int n1> inline
|
||||
Matx<_Tp, m1, n1> Matx<_Tp, m, n>::reshape() const
|
||||
{
|
||||
CV_StaticAssert(m1*n1 == m*n, "Input and destnarion matrices must have the same number of elements");
|
||||
CV_StaticAssert(m1*n1 == m*n, "Input and destination matrices must have the same number of elements");
|
||||
return (const Matx<_Tp, m1, n1>&)*this;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user