1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-30 15:53:03 +04:00

Merge pull request #26505 from fengyuentau:imgproc/new_nearest_inter

imgproc: optimized nearest neighbour interpolation for warpAffine, warpPerspective and remap #26505

PR Description has a limit of 65536 characters. So performance stats are attached below.

### 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:
Yuantao Feng
2024-11-30 15:41:21 +08:00
committed by GitHub
parent b7dacbd5e3
commit b476ed6d06
10 changed files with 4026 additions and 1229 deletions
@@ -1761,6 +1761,35 @@ OPENCV_HAL_IMPL_RVV_PACK(v_int16, short, v_int32, 16, i16, i32, __riscv_vnclip,
OPENCV_HAL_IMPL_RVV_PACK_32(v_uint32, unsigned, v_uint64, 32, u32, u64, __riscv_vnclipu, __riscv_vnsrl)
OPENCV_HAL_IMPL_RVV_PACK_32(v_int32, int, v_int64, 32, i32, i64, __riscv_vnclip, __riscv_vnsra)
template <int N = VTraits<v_uint16>::max_nlanes>
inline v_uint16 v_pack(const v_uint32& a, const v_uint32& b)
{
ushort bufa[N];
ushort bufb[N];
v_pack_store(bufa, a);
v_pack_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<4>(const v_uint32& a, const v_uint32& b)
{
constexpr int N = VTraits<v_uint16>::max_nlanes;
ushort bufa[N];
ushort bufb[N];
v_pack_store(bufa, a);
v_pack_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);
}
#define OPENCV_HAL_IMPL_RVV_PACK_U(_Tpvec, _Tp, _wTpvec, _wTp, hwidth, width, hsuffix, suffix, cast, hvl, vl) \
inline _Tpvec v_pack_u(const _wTpvec& a, const _wTpvec& b) \
{ \