mirror of
https://github.com/opencv/opencv.git
synced 2026-07-29 23:33:05 +04:00
Merge pull request #26454 from fengyuentau/imgproc:update_warp_c4_kernels
imgproc: fix perf regressions on the c4 kernels of warpAffine / warpPerspective / remap #26454 ## Performance Previous performance regressions on c4 kernels are mainly on A311D https://github.com/opencv/opencv/pull/26348. Regressions on c3 kernels on intel platform will be fixed in another pull request. M2 ``` Geometric mean (ms) Name of Test base patch patch vs base (x-factor) WarpAffine::TestWarpAffine::(640x480, INTER_LINEAR, BORDER_CONSTANT, 16UC4) 0.338 0.163 2.08 WarpAffine::TestWarpAffine::(640x480, INTER_LINEAR, BORDER_CONSTANT, 32FC4) 0.310 0.107 2.90 WarpAffine::TestWarpAffine::(640x480, INTER_LINEAR, BORDER_REPLICATE, 16UC4) 0.344 0.162 2.13 WarpAffine::TestWarpAffine::(640x480, INTER_LINEAR, BORDER_REPLICATE, 32FC4) 0.313 0.111 2.83 WarpAffine::TestWarpAffine::(1280x720, INTER_LINEAR, BORDER_CONSTANT, 16UC4) 0.676 0.333 2.03 WarpAffine::TestWarpAffine::(1280x720, INTER_LINEAR, BORDER_CONSTANT, 32FC4) 0.640 0.240 2.66 WarpAffine::TestWarpAffine::(1280x720, INTER_LINEAR, BORDER_REPLICATE, 16UC4) 1.212 0.885 1.37 WarpAffine::TestWarpAffine::(1280x720, INTER_LINEAR, BORDER_REPLICATE, 32FC4) 1.153 0.756 1.53 WarpAffine::TestWarpAffine::(1920x1080, INTER_LINEAR, BORDER_CONSTANT, 16UC4) 0.950 0.475 2.00 WarpAffine::TestWarpAffine::(1920x1080, INTER_LINEAR, BORDER_CONSTANT, 32FC4) 1.158 0.500 2.32 WarpAffine::TestWarpAffine::(1920x1080, INTER_LINEAR, BORDER_REPLICATE, 16UC4) 3.441 3.106 1.11 WarpAffine::TestWarpAffine::(1920x1080, INTER_LINEAR, BORDER_REPLICATE, 32FC4) 3.351 2.837 1.18 WarpPerspective::TestWarpPerspective::(640x480, INTER_LINEAR, BORDER_CONSTANT, 16UC4) 0.336 0.163 2.07 WarpPerspective::TestWarpPerspective::(640x480, INTER_LINEAR, BORDER_CONSTANT, 32FC4) 0.314 0.124 2.54 WarpPerspective::TestWarpPerspective::(640x480, INTER_LINEAR, BORDER_REPLICATE, 16UC4) 0.385 0.226 1.70 WarpPerspective::TestWarpPerspective::(640x480, INTER_LINEAR, BORDER_REPLICATE, 32FC4) 0.364 0.183 1.99 WarpPerspective::TestWarpPerspective::(1280x720, INTER_LINEAR, BORDER_CONSTANT, 16UC4) 0.541 0.290 1.87 WarpPerspective::TestWarpPerspective::(1280x720, INTER_LINEAR, BORDER_CONSTANT, 32FC4) 0.523 0.243 2.16 WarpPerspective::TestWarpPerspective::(1280x720, INTER_LINEAR, BORDER_REPLICATE, 16UC4) 1.540 1.239 1.24 WarpPerspective::TestWarpPerspective::(1280x720, INTER_LINEAR, BORDER_REPLICATE, 32FC4) 1.504 1.134 1.33 WarpPerspective::TestWarpPerspective::(1920x1080, INTER_LINEAR, BORDER_CONSTANT, 16UC4) 0.751 0.465 1.62 WarpPerspective::TestWarpPerspective::(1920x1080, INTER_LINEAR, BORDER_CONSTANT, 32FC4) 0.958 0.507 1.89 WarpPerspective::TestWarpPerspective::(1920x1080, INTER_LINEAR, BORDER_REPLICATE, 16UC4) 3.785 3.487 1.09 WarpPerspective::TestWarpPerspective::(1920x1080, INTER_LINEAR, BORDER_REPLICATE, 32FC4) 3.602 3.280 1.10 map1_32fc1::TestRemap::(640x480, INTER_LINEAR, BORDER_CONSTANT, 16UC4) 0.331 0.153 2.16 map1_32fc1::TestRemap::(640x480, INTER_LINEAR, BORDER_CONSTANT, 32FC4) 0.304 0.128 2.37 map1_32fc1::TestRemap::(640x480, INTER_LINEAR, BORDER_REPLICATE, 16UC4) 0.329 0.156 2.11 map1_32fc1::TestRemap::(640x480, INTER_LINEAR, BORDER_REPLICATE, 32FC4) 0.306 0.121 2.53 map1_32fc1::TestRemap::(1920x1080, INTER_LINEAR, BORDER_CONSTANT, 16UC4) 2.046 0.930 2.20 map1_32fc1::TestRemap::(1920x1080, INTER_LINEAR, BORDER_CONSTANT, 32FC4) 2.122 1.391 1.53 map1_32fc1::TestRemap::(1920x1080, INTER_LINEAR, BORDER_REPLICATE, 16UC4) 2.035 0.954 2.13 map1_32fc1::TestRemap::(1920x1080, INTER_LINEAR, BORDER_REPLICATE, 32FC4) 2.127 1.410 1.51 map1_32fc2::TestRemap::(640x480, INTER_LINEAR, BORDER_CONSTANT, 16UC4) 0.329 0.157 2.09 map1_32fc2::TestRemap::(640x480, INTER_LINEAR, BORDER_CONSTANT, 32FC4) 0.306 0.124 2.47 map1_32fc2::TestRemap::(640x480, INTER_LINEAR, BORDER_REPLICATE, 16UC4) 0.327 0.158 2.08 map1_32fc2::TestRemap::(640x480, INTER_LINEAR, BORDER_REPLICATE, 32FC4) 0.308 0.127 2.43 map1_32fc2::TestRemap::(1920x1080, INTER_LINEAR, BORDER_CONSTANT, 16UC4) 2.039 0.948 2.15 map1_32fc2::TestRemap::(1920x1080, INTER_LINEAR, BORDER_CONSTANT, 32FC4) 2.175 1.373 1.58 map1_32fc2::TestRemap::(1920x1080, INTER_LINEAR, BORDER_REPLICATE, 16UC4) 2.065 0.956 2.16 map1_32fc2::TestRemap::(1920x1080, INTER_LINEAR, BORDER_REPLICATE, 32FC4) 2.158 1.372 1.57 ``` Intel i7-12700K: ``` Geometric mean (ms) Name of Test base patch patch vs base (x-factor) WarpAffine::TestWarpAffine::(640x480, INTER_LINEAR, BORDER_CONSTANT, 16UC4) 0.140 0.051 2.77 WarpAffine::TestWarpAffine::(640x480, INTER_LINEAR, BORDER_CONSTANT, 32FC4) 0.140 0.054 2.57 WarpAffine::TestWarpAffine::(640x480, INTER_LINEAR, BORDER_REPLICATE, 16UC4) 0.140 0.050 2.78 WarpAffine::TestWarpAffine::(640x480, INTER_LINEAR, BORDER_REPLICATE, 32FC4) 0.143 0.054 2.64 WarpAffine::TestWarpAffine::(1280x720, INTER_LINEAR, BORDER_CONSTANT, 16UC4) 0.297 0.118 2.51 WarpAffine::TestWarpAffine::(1280x720, INTER_LINEAR, BORDER_CONSTANT, 32FC4) 0.296 0.130 2.28 WarpAffine::TestWarpAffine::(1280x720, INTER_LINEAR, BORDER_REPLICATE, 16UC4) 0.481 0.304 1.58 WarpAffine::TestWarpAffine::(1280x720, INTER_LINEAR, BORDER_REPLICATE, 32FC4) 0.470 0.309 1.52 WarpAffine::TestWarpAffine::(1920x1080, INTER_LINEAR, BORDER_CONSTANT, 16UC4) 0.381 0.184 2.07 WarpAffine::TestWarpAffine::(1920x1080, INTER_LINEAR, BORDER_CONSTANT, 32FC4) 0.811 0.781 1.04 WarpAffine::TestWarpAffine::(1920x1080, INTER_LINEAR, BORDER_REPLICATE, 16UC4) 1.297 1.063 1.22 WarpAffine::TestWarpAffine::(1920x1080, INTER_LINEAR, BORDER_REPLICATE, 32FC4) 1.275 1.171 1.09 WarpPerspective::TestWarpPerspective::(640x480, INTER_LINEAR, BORDER_CONSTANT, 16UC4) 0.135 0.057 2.36 WarpPerspective::TestWarpPerspective::(640x480, INTER_LINEAR, BORDER_CONSTANT, 32FC4) 0.134 0.062 2.16 WarpPerspective::TestWarpPerspective::(640x480, INTER_LINEAR, BORDER_REPLICATE, 16UC4) 0.155 0.076 2.04 WarpPerspective::TestWarpPerspective::(640x480, INTER_LINEAR, BORDER_REPLICATE, 32FC4) 0.150 0.079 1.90 WarpPerspective::TestWarpPerspective::(1280x720, INTER_LINEAR, BORDER_CONSTANT, 16UC4) 0.229 0.114 2.02 WarpPerspective::TestWarpPerspective::(1280x720, INTER_LINEAR, BORDER_CONSTANT, 32FC4) 0.227 0.120 1.89 WarpPerspective::TestWarpPerspective::(1280x720, INTER_LINEAR, BORDER_REPLICATE, 16UC4) 0.560 0.444 1.26 WarpPerspective::TestWarpPerspective::(1280x720, INTER_LINEAR, BORDER_REPLICATE, 32FC4) 0.529 0.442 1.20 WarpPerspective::TestWarpPerspective::(1920x1080, INTER_LINEAR, BORDER_CONSTANT, 16UC4) 0.326 0.192 1.70 WarpPerspective::TestWarpPerspective::(1920x1080, INTER_LINEAR, BORDER_CONSTANT, 32FC4) 0.805 0.762 1.06 WarpPerspective::TestWarpPerspective::(1920x1080, INTER_LINEAR, BORDER_REPLICATE, 16UC4) 1.395 1.255 1.11 WarpPerspective::TestWarpPerspective::(1920x1080, INTER_LINEAR, BORDER_REPLICATE, 32FC4) 1.381 1.306 1.06 map1_32fc1::TestRemap::(640x480, INTER_LINEAR, BORDER_CONSTANT, 16UC4) 0.138 0.049 2.81 map1_32fc1::TestRemap::(640x480, INTER_LINEAR, BORDER_CONSTANT, 32FC4) 0.134 0.053 2.53 map1_32fc1::TestRemap::(640x480, INTER_LINEAR, BORDER_REPLICATE, 16UC4) 0.137 0.049 2.79 map1_32fc1::TestRemap::(640x480, INTER_LINEAR, BORDER_REPLICATE, 32FC4) 0.134 0.053 2.51 map1_32fc1::TestRemap::(1920x1080, INTER_LINEAR, BORDER_CONSTANT, 16UC4) 1.362 1.352 1.01 map1_32fc1::TestRemap::(1920x1080, INTER_LINEAR, BORDER_CONSTANT, 32FC4) 3.124 3.038 1.03 map1_32fc1::TestRemap::(1920x1080, INTER_LINEAR, BORDER_REPLICATE, 16UC4) 1.354 1.351 1.00 map1_32fc1::TestRemap::(1920x1080, INTER_LINEAR, BORDER_REPLICATE, 32FC4) 3.142 3.049 1.03 map1_32fc2::TestRemap::(640x480, INTER_LINEAR, BORDER_CONSTANT, 16UC4) 0.140 0.052 2.70 map1_32fc2::TestRemap::(640x480, INTER_LINEAR, BORDER_CONSTANT, 32FC4) 0.136 0.056 2.43 map1_32fc2::TestRemap::(640x480, INTER_LINEAR, BORDER_REPLICATE, 16UC4) 0.139 0.051 2.70 map1_32fc2::TestRemap::(640x480, INTER_LINEAR, BORDER_REPLICATE, 32FC4) 0.135 0.056 2.41 map1_32fc2::TestRemap::(1920x1080, INTER_LINEAR, BORDER_CONSTANT, 16UC4) 1.335 1.345 0.99 map1_32fc2::TestRemap::(1920x1080, INTER_LINEAR, BORDER_CONSTANT, 32FC4) 3.117 3.024 1.03 map1_32fc2::TestRemap::(1920x1080, INTER_LINEAR, BORDER_REPLICATE, 16UC4) 1.327 1.319 1.01 map1_32fc2::TestRemap::(1920x1080, INTER_LINEAR, BORDER_REPLICATE, 32FC4) 3.126 3.026 1.03 ``` A311D ``` Geometric mean (ms) Name of Test base patch patch vs base (x-factor) WarpAffine::TestWarpAffine::(640x480, INTER_LINEAR, BORDER_CONSTANT, 16UC4) 1.762 1.361 1.29 WarpAffine::TestWarpAffine::(640x480, INTER_LINEAR, BORDER_CONSTANT, 32FC4) 2.390 2.005 1.19 WarpAffine::TestWarpAffine::(640x480, INTER_LINEAR, BORDER_REPLICATE, 16UC4) 1.747 1.238 1.41 WarpAffine::TestWarpAffine::(640x480, INTER_LINEAR, BORDER_REPLICATE, 32FC4) 2.399 2.016 1.19 WarpAffine::TestWarpAffine::(1280x720, INTER_LINEAR, BORDER_CONSTANT, 16UC4) 3.917 3.104 1.26 WarpAffine::TestWarpAffine::(1280x720, INTER_LINEAR, BORDER_CONSTANT, 32FC4) 5.995 5.172 1.16 WarpAffine::TestWarpAffine::(1280x720, INTER_LINEAR, BORDER_REPLICATE, 16UC4) 6.711 5.460 1.23 WarpAffine::TestWarpAffine::(1280x720, INTER_LINEAR, BORDER_REPLICATE, 32FC4) 8.017 6.890 1.16 WarpAffine::TestWarpAffine::(1920x1080, INTER_LINEAR, BORDER_CONSTANT, 16UC4) 6.269 5.596 1.12 WarpAffine::TestWarpAffine::(1920x1080, INTER_LINEAR, BORDER_CONSTANT, 32FC4) 10.301 9.507 1.08 WarpAffine::TestWarpAffine::(1920x1080, INTER_LINEAR, BORDER_REPLICATE, 16UC4) 18.871 17.375 1.09 WarpAffine::TestWarpAffine::(1920x1080, INTER_LINEAR, BORDER_REPLICATE, 32FC4) 20.365 18.227 1.12 WarpPerspective::TestWarpPerspective::(640x480, INTER_LINEAR, BORDER_CONSTANT, 16UC4) 2.083 1.514 1.38 WarpPerspective::TestWarpPerspective::(640x480, INTER_LINEAR, BORDER_CONSTANT, 32FC4) 2.966 2.309 1.28 WarpPerspective::TestWarpPerspective::(640x480, INTER_LINEAR, BORDER_REPLICATE, 16UC4) 2.358 1.715 1.37 WarpPerspective::TestWarpPerspective::(640x480, INTER_LINEAR, BORDER_REPLICATE, 32FC4) 3.220 2.464 1.31 WarpPerspective::TestWarpPerspective::(1280x720, INTER_LINEAR, BORDER_CONSTANT, 16UC4) 3.763 3.014 1.25 WarpPerspective::TestWarpPerspective::(1280x720, INTER_LINEAR, BORDER_CONSTANT, 32FC4) 5.777 4.940 1.17 WarpPerspective::TestWarpPerspective::(1280x720, INTER_LINEAR, BORDER_REPLICATE, 16UC4) 8.791 7.819 1.12 WarpPerspective::TestWarpPerspective::(1280x720, INTER_LINEAR, BORDER_REPLICATE, 32FC4) 10.165 8.426 1.21 WarpPerspective::TestWarpPerspective::(1920x1080, INTER_LINEAR, BORDER_CONSTANT, 16UC4) 6.047 5.293 1.14 WarpPerspective::TestWarpPerspective::(1920x1080, INTER_LINEAR, BORDER_CONSTANT, 32FC4) 9.851 9.023 1.09 WarpPerspective::TestWarpPerspective::(1920x1080, INTER_LINEAR, BORDER_REPLICATE, 16UC4) 31.739 29.323 1.08 WarpPerspective::TestWarpPerspective::(1920x1080, INTER_LINEAR, BORDER_REPLICATE, 32FC4) 32.439 29.236 1.11 map1_32fc1::TestRemap::(640x480, INTER_LINEAR, BORDER_CONSTANT, 16UC4) 1.759 1.441 1.22 map1_32fc1::TestRemap::(640x480, INTER_LINEAR, BORDER_CONSTANT, 32FC4) 2.681 2.270 1.18 map1_32fc1::TestRemap::(640x480, INTER_LINEAR, BORDER_REPLICATE, 16UC4) 1.774 1.425 1.24 map1_32fc1::TestRemap::(640x480, INTER_LINEAR, BORDER_REPLICATE, 32FC4) 2.672 2.252 1.19 map1_32fc1::TestRemap::(1920x1080, INTER_LINEAR, BORDER_CONSTANT, 16UC4) 14.079 9.334 1.51 map1_32fc1::TestRemap::(1920x1080, INTER_LINEAR, BORDER_CONSTANT, 32FC4) 17.770 16.155 1.10 map1_32fc1::TestRemap::(1920x1080, INTER_LINEAR, BORDER_REPLICATE, 16UC4) 15.872 11.192 1.42 map1_32fc1::TestRemap::(1920x1080, INTER_LINEAR, BORDER_REPLICATE, 32FC4) 19.167 15.342 1.25 map1_32fc2::TestRemap::(640x480, INTER_LINEAR, BORDER_CONSTANT, 16UC4) 2.284 1.545 1.48 map1_32fc2::TestRemap::(640x480, INTER_LINEAR, BORDER_CONSTANT, 32FC4) 3.040 2.231 1.36 map1_32fc2::TestRemap::(640x480, INTER_LINEAR, BORDER_REPLICATE, 16UC4) 2.280 1.380 1.65 map1_32fc2::TestRemap::(640x480, INTER_LINEAR, BORDER_REPLICATE, 32FC4) 2.882 2.185 1.32 map1_32fc2::TestRemap::(1920x1080, INTER_LINEAR, BORDER_CONSTANT, 16UC4) 15.877 11.381 1.40 map1_32fc2::TestRemap::(1920x1080, INTER_LINEAR, BORDER_CONSTANT, 32FC4) 19.521 16.106 1.21 map1_32fc2::TestRemap::(1920x1080, INTER_LINEAR, BORDER_REPLICATE, 16UC4) 15.950 11.532 1.38 map1_32fc2::TestRemap::(1920x1080, INTER_LINEAR, BORDER_REPLICATE, 32FC4) 19.699 16.276 1.21 ``` ### Pull Request Readiness Checklist See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request - [x] I agree to contribute to the project under Apache 2 License. - [x] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV - [x] The PR is proposed to the proper branch - [x] There is a reference to the original bug report and related work - [x] There is accuracy test, performance test and test data in opencv_extra repository, if applicable Patch to opencv_extra has the same branch name. - [x] The feature is well documented and sample code can be built with the project CMake
This commit is contained in:
@@ -543,6 +543,40 @@ OPENCV_HAL_IMPL_RVV_LOADSTORE_OP(v_float32, vfloat32m2_t, float, VTraits<v_float
|
||||
OPENCV_HAL_IMPL_RVV_LOADSTORE_OP(v_float64, vfloat64m2_t, double, VTraits<v_float64>::vlanes() / 2, VTraits<v_float64>::vlanes(), 64, f64)
|
||||
#endif
|
||||
|
||||
template <int N = VTraits<v_uint16>::max_nlanes>
|
||||
inline void v_store(ushort* ptr, const v_uint16& a)
|
||||
{
|
||||
ushort buf[VTraits<v_uint16>::max_nlanes];
|
||||
v_store(buf, a);
|
||||
for (int i = 0; i < N; i++) {
|
||||
ptr[i] = buf[i];
|
||||
}
|
||||
}
|
||||
template <> inline void v_store<8>(ushort* ptr, const v_uint16& a)
|
||||
{
|
||||
ushort buf[VTraits<v_uint16>::max_nlanes];
|
||||
v_store(buf, a);
|
||||
ptr[0] = buf[0]; ptr[1] = buf[1]; ptr[2] = buf[2]; ptr[3] = buf[3];
|
||||
ptr[4] = buf[4]; ptr[5] = buf[5]; ptr[6] = buf[6]; ptr[7] = buf[7];
|
||||
}
|
||||
|
||||
template <int N = VTraits<v_float32>::max_nlanes>
|
||||
inline void v_store(float* ptr, const v_float32& a)
|
||||
{
|
||||
float buf[VTraits<v_float32>::max_nlanes];
|
||||
v_store(buf, a);
|
||||
for (int i = 0; i < N; i++) {
|
||||
ptr[i] = buf[i];
|
||||
}
|
||||
}
|
||||
template <> inline void v_store<4>(float* ptr, const v_float32& a)
|
||||
{
|
||||
float buf[VTraits<v_float32>::max_nlanes];
|
||||
v_store(buf, a);
|
||||
ptr[0] = buf[0]; ptr[1] = buf[1];
|
||||
ptr[2] = buf[2]; ptr[3] = buf[3];
|
||||
}
|
||||
|
||||
////////////// Lookup table access ////////////////////
|
||||
#define OPENCV_HAL_IMPL_RVV_LUT(_Tpvec, _Tp, suffix) \
|
||||
inline _Tpvec v_lut(const _Tp* tab, const int* idx) \
|
||||
@@ -1616,6 +1650,42 @@ OPENCV_HAL_IMPL_RVV_EXPAND(short, v_int32, vint32m4_t, v_int16, 16, i32, i16, __
|
||||
OPENCV_HAL_IMPL_RVV_EXPAND(uint, v_uint64, vuint64m4_t, v_uint32, 32, u64, u32, __riscv_vwcvtu_x)
|
||||
OPENCV_HAL_IMPL_RVV_EXPAND(int, v_int64, vint64m4_t, v_int32, 32, i64, i32, __riscv_vwcvt_x)
|
||||
|
||||
template <int N = VTraits<v_float32>::max_nlanes>
|
||||
inline v_float32 v_load(const float* ptr)
|
||||
{
|
||||
float buf[VTraits<v_float32>::max_nlanes];
|
||||
v_store(buf, v_setzero_f32());
|
||||
for (int i = 0; i < N; i++) {
|
||||
buf[i] = ptr[i];
|
||||
}
|
||||
return v_load(buf);
|
||||
}
|
||||
template <> inline v_float32 v_load<4>(const float* ptr)
|
||||
{
|
||||
float buf[VTraits<v_float32>::max_nlanes];
|
||||
v_store(buf, v_setzero_f32());
|
||||
buf[0] = ptr[0]; buf[1] = ptr[1]; buf[2] = ptr[2]; buf[3] = ptr[3];
|
||||
return v_load(buf);
|
||||
}
|
||||
|
||||
template <int N = VTraits<v_uint32>::max_nlanes>
|
||||
inline v_uint32 v_load_expand(const ushort* ptr)
|
||||
{
|
||||
ushort buf[VTraits<v_uint16>::max_nlanes];
|
||||
v_store(buf, v_setzero_u16());
|
||||
for (int i = 0; i < N; i++) {
|
||||
buf[i] = ptr[i];
|
||||
}
|
||||
return v_load_expand(buf);
|
||||
}
|
||||
template <> inline v_uint32 v_load_expand<4>(const ushort* ptr)
|
||||
{
|
||||
ushort buf[VTraits<v_uint16>::max_nlanes];
|
||||
v_store(buf, v_setzero_u16());
|
||||
buf[0] = ptr[0]; buf[1] = ptr[1]; buf[2] = ptr[2]; buf[3] = ptr[3];
|
||||
return v_load_expand(buf);
|
||||
}
|
||||
|
||||
inline v_uint32 v_load_expand_q(const uchar* ptr)
|
||||
{
|
||||
return __riscv_vwcvtu_x(__riscv_vwcvtu_x(__riscv_vle8_v_u8mf2(ptr, VTraits<v_uint32>::vlanes()), VTraits<v_uint32>::vlanes()), VTraits<v_uint32>::vlanes());
|
||||
@@ -1627,16 +1697,16 @@ inline v_int32 v_load_expand_q(const schar* ptr)
|
||||
}
|
||||
|
||||
template <int N = VTraits<v_uint32>::max_nlanes>
|
||||
inline v_uint32 v_load_expand_q(const uchar* ptr, int n = N)
|
||||
inline v_uint32 v_load_expand_q(const uchar* ptr)
|
||||
{
|
||||
uchar buf[VTraits<v_uint8>::max_nlanes];
|
||||
v_store(buf, v_setzero_u8());
|
||||
for (int i = 0; i < n; i++) {
|
||||
for (int i = 0; i < N; i++) {
|
||||
buf[i] = ptr[i];
|
||||
}
|
||||
return v_load_expand_q(buf);
|
||||
}
|
||||
template <> inline v_uint32 v_load_expand_q<4>(const uchar* ptr, int n)
|
||||
template <> inline v_uint32 v_load_expand_q<4>(const uchar* ptr)
|
||||
{
|
||||
uchar buf[VTraits<v_uint8>::max_nlanes];
|
||||
v_store(buf, v_setzero_u8());
|
||||
@@ -1714,19 +1784,48 @@ void v_rshr_pack_u_store(_Tp* ptr, const _wTpvec& a, int n = N) \
|
||||
OPENCV_HAL_IMPL_RVV_PACK_U(v_uint8, uchar, v_int16, short, 8, 16, u8, i16, __riscv_vreinterpret_v_i16m4_u16m4, VTraits<v_int16>::vlanes(), VTraits<v_uint8>::vlanes())
|
||||
OPENCV_HAL_IMPL_RVV_PACK_U(v_uint16, ushort, v_int32, int, 16, 32, u16, i32, __riscv_vreinterpret_v_i32m4_u32m4, VTraits<v_int32>::vlanes(), VTraits<v_uint16>::vlanes())
|
||||
|
||||
template <int N = VTraits<v_uint16>::max_nlanes>
|
||||
inline v_uint16 v_pack_u(const v_int32& a, const v_int32& b)
|
||||
{
|
||||
ushort bufa[N];
|
||||
ushort bufb[N];
|
||||
v_pack_u_store(bufa, a);
|
||||
v_pack_u_store(bufb, b);
|
||||
ushort buf[N];
|
||||
for (int i = 0; i < N; i++) {
|
||||
buf[i] = bufa[i];
|
||||
buf[i+N/2] = bufb[i];
|
||||
}
|
||||
return v_load(buf);
|
||||
}
|
||||
|
||||
template <> inline v_uint16 v_pack_u<4>(const v_int32& a, const v_int32& b)
|
||||
{
|
||||
constexpr int N = VTraits<v_uint16>::max_nlanes;
|
||||
ushort bufa[N];
|
||||
ushort bufb[N];
|
||||
v_pack_u_store(bufa, a);
|
||||
v_pack_u_store(bufb, b);
|
||||
|
||||
ushort buf[N];
|
||||
buf[0] = bufa[0]; buf[1] = bufa[1]; buf[2] = bufa[2]; buf[3] = bufa[3];
|
||||
buf[4] = bufb[0]; buf[5] = bufb[1]; buf[6] = bufb[2]; buf[7] = bufb[3];
|
||||
return v_load(buf);
|
||||
}
|
||||
|
||||
template <int N = VTraits<v_int16>::max_nlanes>
|
||||
inline void v_pack_u_store(uchar* ptr, const v_int16& a, int n = N)
|
||||
inline void v_pack_store(uchar* ptr, const v_uint16& a)
|
||||
{
|
||||
uchar buf[VTraits<v_uint8>::max_nlanes];
|
||||
v_pack_u_store(buf, a);
|
||||
for (int i = 0; i < n; i++) {
|
||||
v_pack_store(buf, a);
|
||||
for (int i = 0; i < N; i++) {
|
||||
ptr[i] = buf[i];
|
||||
}
|
||||
}
|
||||
template <> inline void v_pack_u_store<8>(uchar* ptr, const v_int16& a, int n)
|
||||
template <> inline void v_pack_store<8>(uchar* ptr, const v_uint16& a)
|
||||
{
|
||||
uchar buf[VTraits<v_uint8>::max_nlanes];
|
||||
v_pack_u_store(buf, a);
|
||||
v_pack_store(buf, a);
|
||||
ptr[0] = buf[0]; ptr[1] = buf[1]; ptr[2] = buf[2]; ptr[3] = buf[3];
|
||||
ptr[4] = buf[4]; ptr[5] = buf[5]; ptr[6] = buf[6]; ptr[7] = buf[7];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user