cv::resize 16uc1

This commit is contained in:
Ilya Lavrenov
2014-09-25 13:55:52 +00:00
parent c0b702a994
commit 4dd6148646
2 changed files with 67 additions and 6 deletions

View File

@@ -49,6 +49,8 @@
#include "precomp.hpp"
#include "opencl_kernels_imgproc.hpp"
#include <iostream>
#if defined (HAVE_IPP) && (IPP_VERSION_MAJOR >= 7)
static IppStatus sts = ippInit();
#endif
@@ -1384,7 +1386,55 @@ private:
int cn, step;
};
typedef ResizeAreaFastNoVec<ushort, ushort> ResizeAreaFastVec_SIMD_16u;
class ResizeAreaFastVec_SIMD_16u
{
public:
ResizeAreaFastVec_SIMD_16u(int _cn, int _step) :
cn(_cn), step(_step)
{
}
int operator() (const ushort * S, ushort * D, int w) const
{
int dx = 0;
const ushort * S0 = S, * S1 = (const ushort *)((const uchar *)(S0) + step);
uint32x4_t v_2 = vdupq_n_u32(2);
if (cn == 1)
{
for ( ; dx <= w - 8; dx += 8, S0 += 16, S1 += 16, D += 8)
{
uint16x8x2_t v_row0 = vld2q_u16(S0), v_row1 = vld2q_u16(S1);
uint32x4_t v_dst0 = vaddl_u16(vget_low_u16(v_row0.val[0]), vget_low_u16(v_row0.val[1]));
v_dst0 = vaddq_u32(v_dst0, vaddl_u16(vget_low_u16(v_row1.val[0]), vget_low_u16(v_row1.val[1])));
v_dst0 = vshrq_n_u32(vaddq_u32(v_dst0, v_2), 2);
uint32x4_t v_dst1 = vaddl_u16(vget_high_u16(v_row0.val[0]), vget_high_u16(v_row0.val[1]));
v_dst1 = vaddq_u32(v_dst1, vaddl_u16(vget_high_u16(v_row1.val[0]), vget_high_u16(v_row1.val[1])));
v_dst1 = vshrq_n_u32(vaddq_u32(v_dst1, v_2), 2);
vst1q_u16(D, vcombine_u16(vmovn_u32(v_dst0), vmovn_u32(v_dst1)));
}
}
else if (cn == 4)
{
for ( ; dx <= w - 4; dx += 4, S0 += 8, S1 += 8, D += 4)
{
uint16x8_t v_row0 = vld1q_u16(S0), v_row1 = vld1q_u16(S1);
uint32x4_t v_dst = vaddq_u32(vaddl_u16(vget_low_u16(v_row0), vget_high_u16(v_row0)),
vaddl_u16(vget_low_u16(v_row1), vget_high_u16(v_row1)));
vst1_u16(D, vmovn_u32(vshrq_n_u32(vaddq_u32(v_dst, v_2), 2)));
}
}
return dx;
}
private:
int cn, step;
};
#elif CV_SSE2