mirror of
https://github.com/opencv/opencv.git
synced 2026-07-30 15:53:03 +04:00
Merge remote-tracking branch 'upstream/3.4' into merge-3.4
This commit is contained in:
@@ -332,7 +332,7 @@ void cv::accumulate( InputArray _src, InputOutputArray _dst, InputArray _mask )
|
||||
CV_Assert( func != 0 );
|
||||
|
||||
const Mat* arrays[] = {&src, &dst, &mask, 0};
|
||||
uchar* ptrs[3]{};
|
||||
uchar* ptrs[3] = {};
|
||||
NAryMatIterator it(arrays, ptrs);
|
||||
int len = (int)it.size;
|
||||
|
||||
@@ -430,7 +430,7 @@ void cv::accumulateSquare( InputArray _src, InputOutputArray _dst, InputArray _m
|
||||
CV_Assert( func != 0 );
|
||||
|
||||
const Mat* arrays[] = {&src, &dst, &mask, 0};
|
||||
uchar* ptrs[3]{};
|
||||
uchar* ptrs[3] = {};
|
||||
NAryMatIterator it(arrays, ptrs);
|
||||
int len = (int)it.size;
|
||||
|
||||
@@ -533,7 +533,7 @@ void cv::accumulateProduct( InputArray _src1, InputArray _src2,
|
||||
CV_Assert( func != 0 );
|
||||
|
||||
const Mat* arrays[] = {&src1, &src2, &dst, &mask, 0};
|
||||
uchar* ptrs[4]{};
|
||||
uchar* ptrs[4] = {};
|
||||
NAryMatIterator it(arrays, ptrs);
|
||||
int len = (int)it.size;
|
||||
|
||||
@@ -635,7 +635,7 @@ void cv::accumulateWeighted( InputArray _src, InputOutputArray _dst,
|
||||
CV_Assert( func != 0 );
|
||||
|
||||
const Mat* arrays[] = {&src, &dst, &mask, 0};
|
||||
uchar* ptrs[3]{};
|
||||
uchar* ptrs[3] = {};
|
||||
NAryMatIterator it(arrays, ptrs);
|
||||
int len = (int)it.size;
|
||||
|
||||
|
||||
@@ -1123,7 +1123,6 @@ cvFindNextContour( CvContourScanner scanner )
|
||||
#endif
|
||||
{
|
||||
_CvContourInfo *par_info = 0;
|
||||
_CvContourInfo *l_cinfo = 0;
|
||||
CvSeq *seq = 0;
|
||||
int is_hole = 0;
|
||||
CvPoint origin;
|
||||
@@ -1215,6 +1214,7 @@ cvFindNextContour( CvContourScanner scanner )
|
||||
seq->flags |= is_hole ? CV_SEQ_FLAG_HOLE : 0;
|
||||
|
||||
/* initialize header */
|
||||
_CvContourInfo *l_cinfo = 0;
|
||||
if( mode <= 1 )
|
||||
{
|
||||
l_cinfo = &(scanner->cinfo_temp);
|
||||
@@ -1225,10 +1225,8 @@ cvFindNextContour( CvContourScanner scanner )
|
||||
}
|
||||
else
|
||||
{
|
||||
union { _CvContourInfo* ci; CvSetElem* se; } v;
|
||||
v.ci = l_cinfo;
|
||||
cvSetAdd( scanner->cinfo_set, 0, &v.se );
|
||||
l_cinfo = v.ci;
|
||||
cvSetAdd(scanner->cinfo_set, 0, (CvSetElem**)&l_cinfo);
|
||||
CV_Assert(l_cinfo);
|
||||
int lval;
|
||||
|
||||
if( img_i )
|
||||
@@ -1298,16 +1296,16 @@ cvFindNextContour( CvContourScanner scanner )
|
||||
scanner->img = (schar *) img;
|
||||
scanner->nbd = nbd;
|
||||
return l_cinfo->contour;
|
||||
|
||||
resume_scan:
|
||||
|
||||
}
|
||||
resume_scan:
|
||||
{
|
||||
prev = p;
|
||||
/* update lnbd */
|
||||
if( prev & -2 )
|
||||
{
|
||||
lnbd.x = x;
|
||||
}
|
||||
} /* end of prev != p */
|
||||
}
|
||||
} /* end of loop on x */
|
||||
|
||||
lnbd.x = 0;
|
||||
|
||||
@@ -45,7 +45,8 @@ namespace cv
|
||||
{
|
||||
|
||||
static const int DIST_SHIFT = 16;
|
||||
static const int INIT_DIST0 = (INT_MAX >> 2);
|
||||
static const int INIT_DIST0 = INT_MAX;
|
||||
static const int DIST_MAX = (INT_MAX >> 2);
|
||||
#define CV_FLT_TO_FIX(x,n) cvRound((x)*(1<<(n)))
|
||||
|
||||
static void
|
||||
@@ -71,8 +72,8 @@ distanceTransform_3x3( const Mat& _src, Mat& _temp, Mat& _dist, const float* met
|
||||
{
|
||||
const int BORDER = 1;
|
||||
int i, j;
|
||||
const int HV_DIST = CV_FLT_TO_FIX( metrics[0], DIST_SHIFT );
|
||||
const int DIAG_DIST = CV_FLT_TO_FIX( metrics[1], DIST_SHIFT );
|
||||
const unsigned int HV_DIST = CV_FLT_TO_FIX( metrics[0], DIST_SHIFT );
|
||||
const unsigned int DIAG_DIST = CV_FLT_TO_FIX( metrics[1], DIST_SHIFT );
|
||||
const float scale = 1.f/(1 << DIST_SHIFT);
|
||||
|
||||
const uchar* src = _src.ptr();
|
||||
@@ -89,7 +90,7 @@ distanceTransform_3x3( const Mat& _src, Mat& _temp, Mat& _dist, const float* met
|
||||
for( i = 0; i < size.height; i++ )
|
||||
{
|
||||
const uchar* s = src + i*srcstep;
|
||||
int* tmp = (int*)(temp + (i+BORDER)*step) + BORDER;
|
||||
unsigned int* tmp = (unsigned int*)(temp + (i+BORDER)*step) + BORDER;
|
||||
|
||||
for( j = 0; j < BORDER; j++ )
|
||||
tmp[-j-1] = tmp[size.width + j] = INIT_DIST0;
|
||||
@@ -100,8 +101,8 @@ distanceTransform_3x3( const Mat& _src, Mat& _temp, Mat& _dist, const float* met
|
||||
tmp[j] = 0;
|
||||
else
|
||||
{
|
||||
int t0 = tmp[j-step-1] + DIAG_DIST;
|
||||
int t = tmp[j-step] + HV_DIST;
|
||||
unsigned int t0 = tmp[j-step-1] + DIAG_DIST;
|
||||
unsigned int t = tmp[j-step] + HV_DIST;
|
||||
if( t0 > t ) t0 = t;
|
||||
t = tmp[j-step+1] + DIAG_DIST;
|
||||
if( t0 > t ) t0 = t;
|
||||
@@ -116,14 +117,14 @@ distanceTransform_3x3( const Mat& _src, Mat& _temp, Mat& _dist, const float* met
|
||||
for( i = size.height - 1; i >= 0; i-- )
|
||||
{
|
||||
float* d = (float*)(dist + i*dststep);
|
||||
int* tmp = (int*)(temp + (i+BORDER)*step) + BORDER;
|
||||
unsigned int* tmp = (unsigned int*)(temp + (i+BORDER)*step) + BORDER;
|
||||
|
||||
for( j = size.width - 1; j >= 0; j-- )
|
||||
{
|
||||
int t0 = tmp[j];
|
||||
unsigned int t0 = tmp[j];
|
||||
if( t0 > HV_DIST )
|
||||
{
|
||||
int t = tmp[j+step+1] + DIAG_DIST;
|
||||
unsigned int t = tmp[j+step+1] + DIAG_DIST;
|
||||
if( t0 > t ) t0 = t;
|
||||
t = tmp[j+step] + HV_DIST;
|
||||
if( t0 > t ) t0 = t;
|
||||
@@ -133,6 +134,7 @@ distanceTransform_3x3( const Mat& _src, Mat& _temp, Mat& _dist, const float* met
|
||||
if( t0 > t ) t0 = t;
|
||||
tmp[j] = t0;
|
||||
}
|
||||
t0 = (t0 > DIST_MAX) ? DIST_MAX : t0;
|
||||
d[j] = (float)(t0 * scale);
|
||||
}
|
||||
}
|
||||
@@ -144,9 +146,9 @@ distanceTransform_5x5( const Mat& _src, Mat& _temp, Mat& _dist, const float* met
|
||||
{
|
||||
const int BORDER = 2;
|
||||
int i, j;
|
||||
const int HV_DIST = CV_FLT_TO_FIX( metrics[0], DIST_SHIFT );
|
||||
const int DIAG_DIST = CV_FLT_TO_FIX( metrics[1], DIST_SHIFT );
|
||||
const int LONG_DIST = CV_FLT_TO_FIX( metrics[2], DIST_SHIFT );
|
||||
const unsigned int HV_DIST = CV_FLT_TO_FIX( metrics[0], DIST_SHIFT );
|
||||
const unsigned int DIAG_DIST = CV_FLT_TO_FIX( metrics[1], DIST_SHIFT );
|
||||
const unsigned int LONG_DIST = CV_FLT_TO_FIX( metrics[2], DIST_SHIFT );
|
||||
const float scale = 1.f/(1 << DIST_SHIFT);
|
||||
|
||||
const uchar* src = _src.ptr();
|
||||
@@ -163,7 +165,7 @@ distanceTransform_5x5( const Mat& _src, Mat& _temp, Mat& _dist, const float* met
|
||||
for( i = 0; i < size.height; i++ )
|
||||
{
|
||||
const uchar* s = src + i*srcstep;
|
||||
int* tmp = (int*)(temp + (i+BORDER)*step) + BORDER;
|
||||
unsigned int* tmp = (unsigned int*)(temp + (i+BORDER)*step) + BORDER;
|
||||
|
||||
for( j = 0; j < BORDER; j++ )
|
||||
tmp[-j-1] = tmp[size.width + j] = INIT_DIST0;
|
||||
@@ -174,8 +176,8 @@ distanceTransform_5x5( const Mat& _src, Mat& _temp, Mat& _dist, const float* met
|
||||
tmp[j] = 0;
|
||||
else
|
||||
{
|
||||
int t0 = tmp[j-step*2-1] + LONG_DIST;
|
||||
int t = tmp[j-step*2+1] + LONG_DIST;
|
||||
unsigned int t0 = tmp[j-step*2-1] + LONG_DIST;
|
||||
unsigned int t = tmp[j-step*2+1] + LONG_DIST;
|
||||
if( t0 > t ) t0 = t;
|
||||
t = tmp[j-step-2] + LONG_DIST;
|
||||
if( t0 > t ) t0 = t;
|
||||
@@ -198,14 +200,14 @@ distanceTransform_5x5( const Mat& _src, Mat& _temp, Mat& _dist, const float* met
|
||||
for( i = size.height - 1; i >= 0; i-- )
|
||||
{
|
||||
float* d = (float*)(dist + i*dststep);
|
||||
int* tmp = (int*)(temp + (i+BORDER)*step) + BORDER;
|
||||
unsigned int* tmp = (unsigned int*)(temp + (i+BORDER)*step) + BORDER;
|
||||
|
||||
for( j = size.width - 1; j >= 0; j-- )
|
||||
{
|
||||
int t0 = tmp[j];
|
||||
unsigned int t0 = tmp[j];
|
||||
if( t0 > HV_DIST )
|
||||
{
|
||||
int t = tmp[j+step*2+1] + LONG_DIST;
|
||||
unsigned int t = tmp[j+step*2+1] + LONG_DIST;
|
||||
if( t0 > t ) t0 = t;
|
||||
t = tmp[j+step*2-1] + LONG_DIST;
|
||||
if( t0 > t ) t0 = t;
|
||||
@@ -223,6 +225,7 @@ distanceTransform_5x5( const Mat& _src, Mat& _temp, Mat& _dist, const float* met
|
||||
if( t0 > t ) t0 = t;
|
||||
tmp[j] = t0;
|
||||
}
|
||||
t0 = (t0 > DIST_MAX) ? DIST_MAX : t0;
|
||||
d[j] = (float)(t0 * scale);
|
||||
}
|
||||
}
|
||||
@@ -235,9 +238,9 @@ distanceTransformEx_5x5( const Mat& _src, Mat& _temp, Mat& _dist, Mat& _labels,
|
||||
const int BORDER = 2;
|
||||
|
||||
int i, j;
|
||||
const int HV_DIST = CV_FLT_TO_FIX( metrics[0], DIST_SHIFT );
|
||||
const int DIAG_DIST = CV_FLT_TO_FIX( metrics[1], DIST_SHIFT );
|
||||
const int LONG_DIST = CV_FLT_TO_FIX( metrics[2], DIST_SHIFT );
|
||||
const unsigned int HV_DIST = CV_FLT_TO_FIX( metrics[0], DIST_SHIFT );
|
||||
const unsigned int DIAG_DIST = CV_FLT_TO_FIX( metrics[1], DIST_SHIFT );
|
||||
const unsigned int LONG_DIST = CV_FLT_TO_FIX( metrics[2], DIST_SHIFT );
|
||||
const float scale = 1.f/(1 << DIST_SHIFT);
|
||||
|
||||
const uchar* src = _src.ptr();
|
||||
@@ -247,7 +250,7 @@ distanceTransformEx_5x5( const Mat& _src, Mat& _temp, Mat& _dist, Mat& _labels,
|
||||
int srcstep = (int)(_src.step/sizeof(src[0]));
|
||||
int step = (int)(_temp.step/sizeof(temp[0]));
|
||||
int dststep = (int)(_dist.step/sizeof(dist[0]));
|
||||
int lstep = (int)(_labels.step/sizeof(dist[0]));
|
||||
int lstep = (int)(_labels.step/sizeof(labels[0]));
|
||||
Size size = _src.size();
|
||||
|
||||
initTopBottom( _temp, BORDER );
|
||||
@@ -256,7 +259,7 @@ distanceTransformEx_5x5( const Mat& _src, Mat& _temp, Mat& _dist, Mat& _labels,
|
||||
for( i = 0; i < size.height; i++ )
|
||||
{
|
||||
const uchar* s = src + i*srcstep;
|
||||
int* tmp = (int*)(temp + (i+BORDER)*step) + BORDER;
|
||||
unsigned int* tmp = (unsigned int*)(temp + (i+BORDER)*step) + BORDER;
|
||||
int* lls = (int*)(labels + i*lstep);
|
||||
|
||||
for( j = 0; j < BORDER; j++ )
|
||||
@@ -271,7 +274,7 @@ distanceTransformEx_5x5( const Mat& _src, Mat& _temp, Mat& _dist, Mat& _labels,
|
||||
}
|
||||
else
|
||||
{
|
||||
int t0 = INIT_DIST0, t;
|
||||
unsigned int t0 = INIT_DIST0, t;
|
||||
int l0 = 0;
|
||||
|
||||
t = tmp[j-step*2-1] + LONG_DIST;
|
||||
@@ -333,16 +336,16 @@ distanceTransformEx_5x5( const Mat& _src, Mat& _temp, Mat& _dist, Mat& _labels,
|
||||
for( i = size.height - 1; i >= 0; i-- )
|
||||
{
|
||||
float* d = (float*)(dist + i*dststep);
|
||||
int* tmp = (int*)(temp + (i+BORDER)*step) + BORDER;
|
||||
unsigned int* tmp = (unsigned int*)(temp + (i+BORDER)*step) + BORDER;
|
||||
int* lls = (int*)(labels + i*lstep);
|
||||
|
||||
for( j = size.width - 1; j >= 0; j-- )
|
||||
{
|
||||
int t0 = tmp[j];
|
||||
unsigned int t0 = tmp[j];
|
||||
int l0 = lls[j];
|
||||
if( t0 > HV_DIST )
|
||||
{
|
||||
int t = tmp[j+step*2+1] + LONG_DIST;
|
||||
unsigned int t = tmp[j+step*2+1] + LONG_DIST;
|
||||
if( t0 > t )
|
||||
{
|
||||
t0 = t;
|
||||
@@ -393,6 +396,7 @@ distanceTransformEx_5x5( const Mat& _src, Mat& _temp, Mat& _dist, Mat& _labels,
|
||||
tmp[j] = t0;
|
||||
lls[j] = l0;
|
||||
}
|
||||
t0 = (t0 > DIST_MAX) ? DIST_MAX : t0;
|
||||
d[j] = (float)(t0 * scale);
|
||||
}
|
||||
}
|
||||
|
||||
+294
-111
@@ -340,51 +340,199 @@ static void hlineResizeCn(ET* src, int cn, int *ofst, FT* m, FT* dst, int dst_mi
|
||||
hline<ET, FT, n, mulall, cncnt>::ResizeCn(src, cn, ofst, m, dst, dst_min, dst_max, dst_width);
|
||||
};
|
||||
|
||||
#if CV_SIMD512
|
||||
inline void v_load_indexed1(uint8_t* src, int *ofst, v_uint16 &v_src0, v_uint16 &v_src1)
|
||||
{
|
||||
v_expand(v_reinterpret_as_u8(v_uint16(
|
||||
*((uint16_t*)(src + ofst[ 0])), *((uint16_t*)(src + ofst[ 1])), *((uint16_t*)(src + ofst[ 2])), *((uint16_t*)(src + ofst[ 3])),
|
||||
*((uint16_t*)(src + ofst[ 4])), *((uint16_t*)(src + ofst[ 5])), *((uint16_t*)(src + ofst[ 6])), *((uint16_t*)(src + ofst[ 7])),
|
||||
*((uint16_t*)(src + ofst[ 8])), *((uint16_t*)(src + ofst[ 9])), *((uint16_t*)(src + ofst[10])), *((uint16_t*)(src + ofst[11])),
|
||||
*((uint16_t*)(src + ofst[12])), *((uint16_t*)(src + ofst[13])), *((uint16_t*)(src + ofst[14])), *((uint16_t*)(src + ofst[15])),
|
||||
*((uint16_t*)(src + ofst[16])), *((uint16_t*)(src + ofst[17])), *((uint16_t*)(src + ofst[14])), *((uint16_t*)(src + ofst[15])),
|
||||
*((uint16_t*)(src + ofst[20])), *((uint16_t*)(src + ofst[21])), *((uint16_t*)(src + ofst[14])), *((uint16_t*)(src + ofst[15])),
|
||||
*((uint16_t*)(src + ofst[24])), *((uint16_t*)(src + ofst[25])), *((uint16_t*)(src + ofst[14])), *((uint16_t*)(src + ofst[15])),
|
||||
*((uint16_t*)(src + ofst[28])), *((uint16_t*)(src + ofst[29])), *((uint16_t*)(src + ofst[14])), *((uint16_t*)(src + ofst[15])))),
|
||||
v_src0, v_src1);
|
||||
}
|
||||
inline void v_load_indexed2(uint8_t* src, int *ofst, v_uint16 &v_src0, v_uint16 &v_src1)
|
||||
{
|
||||
v_expand(v_reinterpret_as_u8(v_uint32(
|
||||
*((uint32_t*)(src + 2 * ofst[ 0])), *((uint32_t*)(src + 2 * ofst[ 1])), *((uint32_t*)(src + 2 * ofst[ 2])), *((uint32_t*)(src + 2 * ofst[ 3])),
|
||||
*((uint32_t*)(src + 2 * ofst[ 4])), *((uint32_t*)(src + 2 * ofst[ 5])), *((uint32_t*)(src + 2 * ofst[ 6])), *((uint32_t*)(src + 2 * ofst[ 7])),
|
||||
*((uint32_t*)(src + 2 * ofst[ 8])), *((uint32_t*)(src + 2 * ofst[ 9])), *((uint32_t*)(src + 2 * ofst[10])), *((uint32_t*)(src + 2 * ofst[11])),
|
||||
*((uint32_t*)(src + 2 * ofst[12])), *((uint32_t*)(src + 2 * ofst[13])), *((uint32_t*)(src + 2 * ofst[14])), *((uint32_t*)(src + 2 * ofst[15])))),
|
||||
v_src0, v_src1);
|
||||
v_uint32 v_tmp0, v_tmp1, v_tmp2, v_tmp3;
|
||||
v_zip(v_reinterpret_as_u32(v_src0), v_reinterpret_as_u32(v_src1), v_tmp2, v_tmp3);
|
||||
v_zip(v_tmp2, v_tmp3, v_tmp0, v_tmp1);
|
||||
v_zip(v_tmp0, v_tmp1, v_tmp2, v_tmp3);
|
||||
v_zip(v_tmp2, v_tmp3, v_tmp0, v_tmp1);
|
||||
v_zip(v_reinterpret_as_u16(v_tmp0), v_reinterpret_as_u16(v_tmp1), v_src0, v_src1);
|
||||
}
|
||||
inline void v_load_indexed4(uint8_t* src, int *ofst, v_uint16 &v_src0, v_uint16 &v_src1)
|
||||
{
|
||||
v_expand(v_reinterpret_as_u8(v_uint64(
|
||||
*((uint64_t*)(src + 4 * ofst[0])), *((uint64_t*)(src + 4 * ofst[1])), *((uint64_t*)(src + 4 * ofst[2])), *((uint64_t*)(src + 4 * ofst[3])),
|
||||
*((uint64_t*)(src + 4 * ofst[4])), *((uint64_t*)(src + 4 * ofst[5])), *((uint64_t*)(src + 4 * ofst[6])), *((uint64_t*)(src + 4 * ofst[7])))),
|
||||
v_src0, v_src1);
|
||||
v_uint64 v_tmp0, v_tmp1, v_tmp2, v_tmp3;
|
||||
v_zip(v_reinterpret_as_u64(v_src0), v_reinterpret_as_u64(v_src1), v_tmp2, v_tmp3);
|
||||
v_zip(v_tmp2, v_tmp3, v_tmp0, v_tmp1);
|
||||
v_zip(v_tmp0, v_tmp1, v_tmp2, v_tmp3);
|
||||
v_zip(v_reinterpret_as_u16(v_tmp2), v_reinterpret_as_u16(v_tmp3), v_src0, v_src1);
|
||||
}
|
||||
inline void v_load_indexed_deinterleave(uint16_t* src, int *ofst, v_uint32 &v_src0, v_uint32 &v_src1)
|
||||
{
|
||||
v_expand(v_reinterpret_as_u16(v_uint32(
|
||||
*((uint32_t*)(src + ofst[ 0])), *((uint32_t*)(src + ofst[ 1])), *((uint32_t*)(src + ofst[ 2])), *((uint32_t*)(src + ofst[ 3])),
|
||||
*((uint32_t*)(src + ofst[ 4])), *((uint32_t*)(src + ofst[ 5])), *((uint32_t*)(src + ofst[ 6])), *((uint32_t*)(src + ofst[ 7])),
|
||||
*((uint32_t*)(src + ofst[ 8])), *((uint32_t*)(src + ofst[ 9])), *((uint32_t*)(src + ofst[10])), *((uint32_t*)(src + ofst[11])),
|
||||
*((uint32_t*)(src + ofst[12])), *((uint32_t*)(src + ofst[13])), *((uint32_t*)(src + ofst[14])), *((uint32_t*)(src + ofst[15])))),
|
||||
v_src0, v_src1);
|
||||
v_uint32 v_tmp0, v_tmp1;
|
||||
v_zip(v_src0, v_src1, v_tmp0, v_tmp1);
|
||||
v_zip(v_tmp0, v_tmp1, v_src0, v_src1);
|
||||
v_zip(v_src0, v_src1, v_tmp0, v_tmp1);
|
||||
v_zip(v_tmp0, v_tmp1, v_src0, v_src1);
|
||||
}
|
||||
#elif CV_SIMD256
|
||||
inline void v_load_indexed1(uint8_t* src, int *ofst, v_uint16 &v_src0, v_uint16 &v_src1)
|
||||
{
|
||||
v_expand(v_reinterpret_as_u8(v_uint16(
|
||||
*((uint16_t*)(src + ofst[ 0])), *((uint16_t*)(src + ofst[ 1])), *((uint16_t*)(src + ofst[ 2])), *((uint16_t*)(src + ofst[ 3])),
|
||||
*((uint16_t*)(src + ofst[ 4])), *((uint16_t*)(src + ofst[ 5])), *((uint16_t*)(src + ofst[ 6])), *((uint16_t*)(src + ofst[ 7])),
|
||||
*((uint16_t*)(src + ofst[ 8])), *((uint16_t*)(src + ofst[ 9])), *((uint16_t*)(src + ofst[10])), *((uint16_t*)(src + ofst[11])),
|
||||
*((uint16_t*)(src + ofst[12])), *((uint16_t*)(src + ofst[13])), *((uint16_t*)(src + ofst[14])), *((uint16_t*)(src + ofst[15])))),
|
||||
v_src0, v_src1);
|
||||
}
|
||||
inline void v_load_indexed2(uint8_t* src, int *ofst, v_uint16 &v_src0, v_uint16 &v_src1)
|
||||
{
|
||||
v_expand(v_reinterpret_as_u8(v_uint32(
|
||||
*((uint32_t*)(src + 2 * ofst[0])), *((uint32_t*)(src + 2 * ofst[1])), *((uint32_t*)(src + 2 * ofst[2])), *((uint32_t*)(src + 2 * ofst[3])),
|
||||
*((uint32_t*)(src + 2 * ofst[4])), *((uint32_t*)(src + 2 * ofst[5])), *((uint32_t*)(src + 2 * ofst[6])), *((uint32_t*)(src + 2 * ofst[7])))),
|
||||
v_src0, v_src1);
|
||||
v_uint32 v_tmp0, v_tmp1, v_tmp2, v_tmp3;
|
||||
v_zip(v_reinterpret_as_u32(v_src0), v_reinterpret_as_u32(v_src1), v_tmp2, v_tmp3);
|
||||
v_zip(v_tmp2, v_tmp3, v_tmp0, v_tmp1);
|
||||
v_zip(v_tmp0, v_tmp1, v_tmp2, v_tmp3);
|
||||
v_zip(v_reinterpret_as_u16(v_tmp2), v_reinterpret_as_u16(v_tmp3), v_src0, v_src1);
|
||||
}
|
||||
inline void v_load_indexed4(uint8_t* src, int *ofst, v_uint16 &v_src0, v_uint16 &v_src1)
|
||||
{
|
||||
v_expand(v_reinterpret_as_u8(v_uint64(
|
||||
*((uint64_t*)(src + 4 * ofst[0])), *((uint64_t*)(src + 4 * ofst[1])), *((uint64_t*)(src + 4 * ofst[2])), *((uint64_t*)(src + 4 * ofst[3])))),
|
||||
v_src0, v_src1);
|
||||
v_uint64 v_tmp0, v_tmp1, v_tmp2, v_tmp3;
|
||||
v_zip(v_reinterpret_as_u64(v_src0), v_reinterpret_as_u64(v_src1), v_tmp2, v_tmp3);
|
||||
v_zip(v_tmp2, v_tmp3, v_tmp0, v_tmp1);
|
||||
v_zip(v_reinterpret_as_u16(v_tmp0), v_reinterpret_as_u16(v_tmp1), v_src0, v_src1);
|
||||
}
|
||||
inline void v_load_indexed_deinterleave(uint16_t* src, int *ofst, v_uint32 &v_src0, v_uint32 &v_src1)
|
||||
{
|
||||
v_uint32 v_tmp0, v_tmp1;
|
||||
v_expand(v_reinterpret_as_u16(v_uint32(
|
||||
*((uint32_t*)(src + ofst[0])), *((uint32_t*)(src + ofst[1])), *((uint32_t*)(src + ofst[2])), *((uint32_t*)(src + ofst[3])),
|
||||
*((uint32_t*)(src + ofst[4])), *((uint32_t*)(src + ofst[5])), *((uint32_t*)(src + ofst[6])), *((uint32_t*)(src + ofst[7])))),
|
||||
v_tmp0, v_tmp1);
|
||||
v_zip(v_tmp0, v_tmp1, v_src0, v_src1);
|
||||
v_zip(v_src0, v_src1, v_tmp0, v_tmp1);
|
||||
v_zip(v_tmp0, v_tmp1, v_src0, v_src1);
|
||||
}
|
||||
#elif CV_SIMD128
|
||||
inline void v_load_indexed1(uint8_t* src, int *ofst, v_uint16 &v_src0, v_uint16 &v_src1)
|
||||
{
|
||||
uint16_t buf[8];
|
||||
buf[0] = *((uint16_t*)(src + ofst[0]));
|
||||
buf[1] = *((uint16_t*)(src + ofst[1]));
|
||||
buf[2] = *((uint16_t*)(src + ofst[2]));
|
||||
buf[3] = *((uint16_t*)(src + ofst[3]));
|
||||
buf[4] = *((uint16_t*)(src + ofst[4]));
|
||||
buf[5] = *((uint16_t*)(src + ofst[5]));
|
||||
buf[6] = *((uint16_t*)(src + ofst[6]));
|
||||
buf[7] = *((uint16_t*)(src + ofst[7]));
|
||||
v_src0 = vx_load_expand((uint8_t*)buf);
|
||||
v_src1 = vx_load_expand((uint8_t*)buf + 8);
|
||||
}
|
||||
inline void v_load_indexed2(uint8_t* src, int *ofst, v_uint16 &v_src0, v_uint16 &v_src1)
|
||||
{
|
||||
uint32_t buf[4];
|
||||
buf[0] = *((uint32_t*)(src + 2 * ofst[0]));
|
||||
buf[1] = *((uint32_t*)(src + 2 * ofst[1]));
|
||||
buf[2] = *((uint32_t*)(src + 2 * ofst[2]));
|
||||
buf[3] = *((uint32_t*)(src + 2 * ofst[3]));
|
||||
v_uint32 v_tmp0, v_tmp1, v_tmp2, v_tmp3;
|
||||
v_tmp0 = v_reinterpret_as_u32(vx_load_expand((uint8_t*)buf));
|
||||
v_tmp1 = v_reinterpret_as_u32(vx_load_expand((uint8_t*)buf + 8));
|
||||
v_zip(v_tmp0, v_tmp1, v_tmp2, v_tmp3);
|
||||
v_zip(v_tmp2, v_tmp3, v_tmp0, v_tmp1);
|
||||
v_zip(v_reinterpret_as_u16(v_tmp0), v_reinterpret_as_u16(v_tmp1), v_src0, v_src1);
|
||||
}
|
||||
inline void v_load_indexed4(uint8_t* src, int *ofst, v_uint16 &v_src0, v_uint16 &v_src1)
|
||||
{
|
||||
v_uint16 v_tmp0, v_tmp1;
|
||||
v_src0 = vx_load_expand(src + 4 * ofst[0]);
|
||||
v_src1 = vx_load_expand(src + 4 * ofst[1]);
|
||||
v_recombine(v_src0, v_src1, v_tmp0, v_tmp1);
|
||||
v_zip(v_tmp0, v_tmp1, v_src0, v_src1);
|
||||
}
|
||||
inline void v_load_indexed_deinterleave(uint16_t* src, int *ofst, v_uint32 &v_src0, v_uint32 &v_src1)
|
||||
{
|
||||
uint32_t buf[4];
|
||||
buf[0] = *((uint32_t*)(src + ofst[0]));
|
||||
buf[1] = *((uint32_t*)(src + ofst[1]));
|
||||
buf[2] = *((uint32_t*)(src + ofst[2]));
|
||||
buf[3] = *((uint32_t*)(src + ofst[3]));
|
||||
v_src0 = vx_load_expand((uint16_t*)buf);
|
||||
v_src1 = vx_load_expand((uint16_t*)buf + 4);
|
||||
v_uint32 v_tmp0, v_tmp1;
|
||||
v_zip(v_src0, v_src1, v_tmp0, v_tmp1);
|
||||
v_zip(v_tmp0, v_tmp1, v_src0, v_src1);
|
||||
}
|
||||
#endif
|
||||
template <>
|
||||
void hlineResizeCn<uint8_t, ufixedpoint16, 2, true, 1>(uint8_t* src, int, int *ofst, ufixedpoint16* m, ufixedpoint16* dst, int dst_min, int dst_max, int dst_width)
|
||||
{
|
||||
int i = 0;
|
||||
ufixedpoint16 src_0(src[0]);
|
||||
v_uint16x8 v_src_0 = v_setall_u16(*((uint16_t*)&src_0));
|
||||
for (; i < dst_min - 7; i += 8, m += 16, dst += 8) // Points that fall left from src image so became equal to leftmost src point
|
||||
#if CV_SIMD
|
||||
const int VECSZ = v_uint16::nlanes;
|
||||
v_uint16 v_src_0 = vx_setall_u16(*((uint16_t*)&src_0));
|
||||
for (; i <= dst_min - VECSZ; i += VECSZ, m += 2*VECSZ, dst += VECSZ) // Points that fall left from src image so became equal to leftmost src point
|
||||
{
|
||||
v_store((uint16_t*)dst, v_src_0);
|
||||
}
|
||||
#endif
|
||||
for (; i < dst_min; i++, m += 2)
|
||||
{
|
||||
*(dst++) = src_0;
|
||||
}
|
||||
for (; i < dst_max - 7 && ofst[i + 7] + 15 <= ofst[dst_width - 1]; i += 8, m += 16, dst += 8)
|
||||
#if CV_SIMD
|
||||
for (; i <= dst_max - VECSZ; i += VECSZ, m += 2*VECSZ, dst += VECSZ)
|
||||
{
|
||||
v_uint32x4 v_src01 = v_combine_low(v_reinterpret_as_u32(v_load_expand(src + ofst[i ])), v_reinterpret_as_u32(v_load_expand(src + ofst[i + 1])));
|
||||
v_uint32x4 v_src23 = v_combine_low(v_reinterpret_as_u32(v_load_expand(src + ofst[i + 2])), v_reinterpret_as_u32(v_load_expand(src + ofst[i + 3])));
|
||||
v_uint32x4 v_src45 = v_combine_low(v_reinterpret_as_u32(v_load_expand(src + ofst[i + 4])), v_reinterpret_as_u32(v_load_expand(src + ofst[i + 5])));
|
||||
v_uint32x4 v_src67 = v_combine_low(v_reinterpret_as_u32(v_load_expand(src + ofst[i + 6])), v_reinterpret_as_u32(v_load_expand(src + ofst[i + 7])));
|
||||
v_uint16 v_src0, v_src1;
|
||||
v_load_indexed1(src, ofst + i, v_src0, v_src1);
|
||||
|
||||
v_uint32x4 v_zip02, v_zip13, v_zip46, v_zip57;
|
||||
v_zip(v_src01, v_src23, v_zip02, v_zip13);
|
||||
v_zip(v_src45, v_src67, v_zip46, v_zip57);
|
||||
|
||||
v_uint32x4 v_src0, v_src1;
|
||||
v_zip(v_combine_low(v_zip02, v_zip46), v_combine_low(v_zip13, v_zip57), v_src0, v_src1);
|
||||
|
||||
v_int16x8 v_mul0 = v_load((int16_t*)m);
|
||||
v_int16x8 v_mul1 = v_load((int16_t*)m + 8);
|
||||
v_uint32x4 v_res0 = v_reinterpret_as_u32(v_dotprod(v_reinterpret_as_s16(v_src0), v_mul0));
|
||||
v_uint32x4 v_res1 = v_reinterpret_as_u32(v_dotprod(v_reinterpret_as_s16(v_src1), v_mul1));
|
||||
v_int16 v_mul0 = vx_load((int16_t*)m);
|
||||
v_int16 v_mul1 = vx_load((int16_t*)m + VECSZ);
|
||||
v_uint32 v_res0 = v_reinterpret_as_u32(v_dotprod(v_reinterpret_as_s16(v_src0), v_mul0));
|
||||
v_uint32 v_res1 = v_reinterpret_as_u32(v_dotprod(v_reinterpret_as_s16(v_src1), v_mul1));
|
||||
v_store((uint16_t*)dst, v_pack(v_res0, v_res1));
|
||||
}
|
||||
#endif
|
||||
for (; i < dst_max; i += 1, m += 2)
|
||||
{
|
||||
uint8_t* px = src + ofst[i];
|
||||
*(dst++) = m[0] * px[0] + m[1] * px[1];
|
||||
}
|
||||
src_0 = (src + ofst[dst_width - 1])[0];
|
||||
v_src_0 = v_setall_u16(*((uint16_t*)&src_0));
|
||||
for (; i < dst_width - 7; i += 8, dst += 8) // Points that fall left from src image so became equal to leftmost src point
|
||||
#if CV_SIMD
|
||||
v_src_0 = vx_setall_u16(*((uint16_t*)&src_0));
|
||||
for (; i <= dst_width - VECSZ; i += VECSZ, dst += VECSZ) // Points that fall left from src image so became equal to leftmost src point
|
||||
{
|
||||
v_store((uint16_t*)dst, v_src_0);
|
||||
}
|
||||
vx_cleanup();
|
||||
#endif
|
||||
for (; i < dst_width; i++)
|
||||
{
|
||||
*(dst++) = src_0;
|
||||
@@ -394,87 +542,109 @@ template <>
|
||||
void hlineResizeCn<uint8_t, ufixedpoint16, 2, true, 2>(uint8_t* src, int, int *ofst, ufixedpoint16* m, ufixedpoint16* dst, int dst_min, int dst_max, int dst_width)
|
||||
{
|
||||
int i = 0;
|
||||
ufixedpoint16 srccn[8] = { src[0], src[1], src[0], src[1], src[0], src[1], src[0], src[1] };
|
||||
v_uint16x8 v_srccn = v_load((uint16_t*)srccn);
|
||||
for (; i < dst_min - 3; i += 4, m += 8, dst += 8) // Points that fall left from src image so became equal to leftmost src point
|
||||
union {
|
||||
uint32_t d;
|
||||
uint16_t w[2];
|
||||
} srccn;
|
||||
((ufixedpoint16*)(srccn.w))[0] = src[0];
|
||||
((ufixedpoint16*)(srccn.w))[1] = src[1];
|
||||
#if CV_SIMD
|
||||
const int VECSZ = v_uint16::nlanes;
|
||||
v_uint16 v_srccn = v_reinterpret_as_u16(vx_setall_u32(srccn.d));
|
||||
for (; i <= dst_min - VECSZ/2; i += VECSZ/2, m += VECSZ, dst += VECSZ) // Points that fall left from src image so became equal to leftmost src point
|
||||
{
|
||||
v_store((uint16_t*)dst, v_srccn);
|
||||
}
|
||||
#endif
|
||||
for (; i < dst_min; i++, m += 2)
|
||||
{
|
||||
*(dst++) = srccn[0];
|
||||
*(dst++) = srccn[1];
|
||||
*(dst++) = ((ufixedpoint16*)(srccn.w))[0];
|
||||
*(dst++) = ((ufixedpoint16*)(srccn.w))[1];
|
||||
}
|
||||
for (; i < dst_max - 3 && ofst[i + 3] + 7 <= ofst[dst_width - 1]; i += 4, m += 8, dst += 8)
|
||||
#if CV_SIMD
|
||||
for (; i <= dst_max - VECSZ/2; i += VECSZ/2, m += VECSZ, dst += VECSZ)
|
||||
{
|
||||
v_uint32x4 v_src0 = v_combine_low(v_reinterpret_as_u32(v_load_expand(src + 2 * ofst[i ])), v_reinterpret_as_u32(v_load_expand(src + 2 * ofst[i + 1])));
|
||||
v_uint32x4 v_src1 = v_combine_low(v_reinterpret_as_u32(v_load_expand(src + 2 * ofst[i + 2])), v_reinterpret_as_u32(v_load_expand(src + 2 * ofst[i + 3])));
|
||||
v_uint16 v_src0, v_src1;
|
||||
v_load_indexed2(src, ofst + i, v_src0, v_src1);
|
||||
|
||||
v_uint32x4 v_zip0, v_zip1;
|
||||
v_zip(v_src0, v_src1, v_zip0, v_zip1);
|
||||
v_zip(v_zip0, v_zip1, v_src0, v_src1);
|
||||
|
||||
v_int16x8 v_src0123, v_src4567;
|
||||
v_zip(v_reinterpret_as_s16(v_src0), v_reinterpret_as_s16(v_src1), v_src0123, v_src4567);
|
||||
|
||||
v_uint32x4 v_mul = v_load((uint32_t*)m);//AaBbCcDd
|
||||
v_uint32 v_mul = vx_load((uint32_t*)m);//AaBbCcDd
|
||||
v_uint32 v_zip0, v_zip1;
|
||||
v_zip(v_mul, v_mul, v_zip0, v_zip1);//AaAaBbBb CcCcDdDd
|
||||
v_uint32x4 v_res0 = v_reinterpret_as_u32(v_dotprod(v_src0123, v_reinterpret_as_s16(v_zip0)));
|
||||
v_uint32x4 v_res1 = v_reinterpret_as_u32(v_dotprod(v_src4567, v_reinterpret_as_s16(v_zip1)));
|
||||
v_uint32 v_res0 = v_reinterpret_as_u32(v_dotprod(v_reinterpret_as_s16(v_src0), v_reinterpret_as_s16(v_zip0)));
|
||||
v_uint32 v_res1 = v_reinterpret_as_u32(v_dotprod(v_reinterpret_as_s16(v_src1), v_reinterpret_as_s16(v_zip1)));
|
||||
v_store((uint16_t*)dst, v_pack(v_res0, v_res1));//AB1AB2CD1CD2
|
||||
}
|
||||
#endif
|
||||
for (; i < dst_max; i += 1, m += 2)
|
||||
{
|
||||
uint8_t* px = src + 2 * ofst[i];
|
||||
*(dst++) = m[0] * px[0] + m[1] * px[2];
|
||||
*(dst++) = m[0] * px[1] + m[1] * px[3];
|
||||
}
|
||||
srccn[0] = (src + 2 * ofst[dst_width - 1])[0]; srccn[1] = (src + 2 * ofst[dst_width - 1])[1]; srccn[2] = (src + 2 * ofst[dst_width - 1])[0]; srccn[3] = (src + 2 * ofst[dst_width - 1])[1];
|
||||
srccn[4] = (src + 2 * ofst[dst_width - 1])[0]; srccn[5] = (src + 2 * ofst[dst_width - 1])[1]; srccn[6] = (src + 2 * ofst[dst_width - 1])[0]; srccn[7] = (src + 2 * ofst[dst_width - 1])[1];
|
||||
v_srccn = v_load((uint16_t*)srccn);
|
||||
for (; i < dst_width - 3; i += 4, dst += 8) // Points that fall left from src image so became equal to leftmost src point
|
||||
((ufixedpoint16*)(srccn.w))[0] = (src + 2 * ofst[dst_width - 1])[0]; ((ufixedpoint16*)(srccn.w))[1] = (src + 2 * ofst[dst_width - 1])[1];
|
||||
#if CV_SIMD
|
||||
v_srccn = v_reinterpret_as_u16(vx_setall_u32(srccn.d));
|
||||
for (; i <= dst_width - VECSZ/2; i += VECSZ/2, dst += VECSZ) // Points that fall left from src image so became equal to leftmost src point
|
||||
{
|
||||
v_store((uint16_t*)dst, v_srccn);
|
||||
}
|
||||
vx_cleanup();
|
||||
#endif
|
||||
for (; i < dst_width; i++)
|
||||
{
|
||||
*(dst++) = srccn[0];
|
||||
*(dst++) = srccn[1];
|
||||
*(dst++) = ((ufixedpoint16*)(srccn.w))[0];
|
||||
*(dst++) = ((ufixedpoint16*)(srccn.w))[1];
|
||||
}
|
||||
}
|
||||
template <>
|
||||
void hlineResizeCn<uint8_t, ufixedpoint16, 2, true, 4>(uint8_t* src, int, int *ofst, ufixedpoint16* m, ufixedpoint16* dst, int dst_min, int dst_max, int dst_width)
|
||||
{
|
||||
int i = 0;
|
||||
ufixedpoint16 srccn[8] = { src[0], src[1], src[2], src[3], src[0], src[1], src[2], src[3] };
|
||||
v_uint16x8 v_srccn = v_load((uint16_t*)srccn);
|
||||
for (; i < dst_min - 1; i += 2, m += 4, dst += 8) // Points that fall left from src image so became equal to leftmost src point
|
||||
union {
|
||||
uint64_t q;
|
||||
uint16_t w[4];
|
||||
} srccn;
|
||||
((ufixedpoint16*)(srccn.w))[0] = src[0];
|
||||
((ufixedpoint16*)(srccn.w))[1] = src[1];
|
||||
((ufixedpoint16*)(srccn.w))[2] = src[2];
|
||||
((ufixedpoint16*)(srccn.w))[3] = src[3];
|
||||
#if CV_SIMD
|
||||
const int VECSZ = v_uint16::nlanes;
|
||||
v_uint16 v_srccn = v_reinterpret_as_u16(vx_setall_u64(srccn.q));
|
||||
for (; i <= dst_min - VECSZ/4; i += VECSZ/4, m += VECSZ/2, dst += VECSZ) // Points that fall left from src image so became equal to leftmost src point
|
||||
{
|
||||
v_store((uint16_t*)dst, v_srccn);
|
||||
}
|
||||
#endif
|
||||
if (i < dst_min) // Points that fall left from src image so became equal to leftmost src point
|
||||
{
|
||||
*(dst++) = srccn[0];
|
||||
*(dst++) = srccn[1];
|
||||
*(dst++) = srccn[2];
|
||||
*(dst++) = srccn[3];
|
||||
*(dst++) = ((ufixedpoint16*)(srccn.w))[0];
|
||||
*(dst++) = ((ufixedpoint16*)(srccn.w))[1];
|
||||
*(dst++) = ((ufixedpoint16*)(srccn.w))[2];
|
||||
*(dst++) = ((ufixedpoint16*)(srccn.w))[3];
|
||||
i++; m += 2;
|
||||
}
|
||||
for (; i < dst_max - 1 && ofst[i + 1] + 3 <= ofst[dst_width - 1]; i += 2, m += 4, dst += 8)
|
||||
#if CV_SIMD
|
||||
for (; i <= dst_max - VECSZ/2; i += VECSZ/2, m += VECSZ, dst += 2*VECSZ)
|
||||
{
|
||||
v_int16x8 v_src01 = v_reinterpret_as_s16(v_load_expand(src + 4 * ofst[i ]));
|
||||
v_int16x8 v_src23 = v_reinterpret_as_s16(v_load_expand(src + 4 * ofst[i + 1]));
|
||||
v_uint16 v_src0, v_src1, v_src2, v_src3;
|
||||
v_load_indexed4(src, ofst + i, v_src0, v_src1);
|
||||
v_load_indexed4(src, ofst + i + VECSZ/4, v_src2, v_src3);
|
||||
|
||||
v_int16x8 v_tmp0, v_tmp1;
|
||||
v_recombine(v_src01, v_src23, v_tmp0, v_tmp1);
|
||||
v_zip(v_tmp0, v_tmp1, v_src01, v_src23);
|
||||
v_uint32 v_mul0, v_mul1, v_mul2, v_mul3, v_tmp;
|
||||
v_mul0 = vx_load((uint32_t*)m);//AaBbCcDd
|
||||
v_zip(v_mul0, v_mul0, v_mul3, v_tmp );//AaAaBbBb CcCcDdDd
|
||||
v_zip(v_mul3, v_mul3, v_mul0, v_mul1);//AaAaAaAa BbBbBbBb
|
||||
v_zip(v_tmp , v_tmp , v_mul2, v_mul3);//CcCcCcCc DdDdDdDd
|
||||
|
||||
v_int16x8 v_mul01 = v_reinterpret_as_s16(v_setall_u32(((uint32_t*)m)[0]));//AaAaAaAa
|
||||
v_int16x8 v_mul23 = v_reinterpret_as_s16(v_setall_u32(((uint32_t*)m)[1]));//BbBbBbBb
|
||||
v_uint32x4 v_res0 = v_reinterpret_as_u32(v_dotprod(v_src01, v_mul01));
|
||||
v_uint32x4 v_res1 = v_reinterpret_as_u32(v_dotprod(v_src23, v_mul23));
|
||||
v_store((uint16_t*)dst, v_pack(v_res0, v_res1));//AB1AB2CD1CD2
|
||||
v_uint32 v_res0 = v_reinterpret_as_u32(v_dotprod(v_reinterpret_as_s16(v_src0), v_reinterpret_as_s16(v_mul0)));
|
||||
v_uint32 v_res1 = v_reinterpret_as_u32(v_dotprod(v_reinterpret_as_s16(v_src1), v_reinterpret_as_s16(v_mul1)));
|
||||
v_uint32 v_res2 = v_reinterpret_as_u32(v_dotprod(v_reinterpret_as_s16(v_src2), v_reinterpret_as_s16(v_mul2)));
|
||||
v_uint32 v_res3 = v_reinterpret_as_u32(v_dotprod(v_reinterpret_as_s16(v_src3), v_reinterpret_as_s16(v_mul3)));
|
||||
v_store((uint16_t*)dst , v_pack(v_res0, v_res1));
|
||||
v_store((uint16_t*)dst + VECSZ, v_pack(v_res2, v_res3));
|
||||
}
|
||||
#endif
|
||||
for (; i < dst_max; i += 1, m += 2)
|
||||
{
|
||||
uint8_t* px = src + 4 * ofst[i];
|
||||
@@ -483,19 +653,22 @@ void hlineResizeCn<uint8_t, ufixedpoint16, 2, true, 4>(uint8_t* src, int, int *o
|
||||
*(dst++) = m[0] * px[2] + m[1] * px[6];
|
||||
*(dst++) = m[0] * px[3] + m[1] * px[7];
|
||||
}
|
||||
srccn[0] = (src + 4 * ofst[dst_width - 1])[0]; srccn[1] = (src + 4 * ofst[dst_width - 1])[1]; srccn[2] = (src + 4 * ofst[dst_width - 1])[2]; srccn[3] = (src + 4 * ofst[dst_width - 1])[3];
|
||||
srccn[4] = (src + 4 * ofst[dst_width - 1])[0]; srccn[5] = (src + 4 * ofst[dst_width - 1])[1]; srccn[6] = (src + 4 * ofst[dst_width - 1])[2]; srccn[7] = (src + 4 * ofst[dst_width - 1])[3];
|
||||
v_srccn = v_load((uint16_t*)srccn);
|
||||
for (; i < dst_width - 1; i += 2, dst += 8) // Points that fall right from src image so became equal to rightmost src point
|
||||
((ufixedpoint16*)(srccn.w))[0] = (src + 4 * ofst[dst_width - 1])[0]; ((ufixedpoint16*)(srccn.w))[1] = (src + 4 * ofst[dst_width - 1])[1];
|
||||
((ufixedpoint16*)(srccn.w))[2] = (src + 4 * ofst[dst_width - 1])[2]; ((ufixedpoint16*)(srccn.w))[3] = (src + 4 * ofst[dst_width - 1])[3];
|
||||
#if CV_SIMD
|
||||
v_srccn = v_reinterpret_as_u16(vx_setall_u64(srccn.q));
|
||||
for (; i <= dst_width - VECSZ/4; i += VECSZ/4, dst += VECSZ) // Points that fall right from src image so became equal to rightmost src point
|
||||
{
|
||||
v_store((uint16_t*)dst, v_srccn);
|
||||
}
|
||||
vx_cleanup();
|
||||
#endif
|
||||
if (i < dst_width)
|
||||
{
|
||||
*(dst++) = srccn[0];
|
||||
*(dst++) = srccn[1];
|
||||
*(dst++) = srccn[2];
|
||||
*(dst++) = srccn[3];
|
||||
*(dst++) = ((ufixedpoint16*)(srccn.w))[0];
|
||||
*(dst++) = ((ufixedpoint16*)(srccn.w))[1];
|
||||
*(dst++) = ((ufixedpoint16*)(srccn.w))[2];
|
||||
*(dst++) = ((ufixedpoint16*)(srccn.w))[3];
|
||||
}
|
||||
}
|
||||
template <>
|
||||
@@ -503,40 +676,42 @@ void hlineResizeCn<uint16_t, ufixedpoint32, 2, true, 1>(uint16_t* src, int, int
|
||||
{
|
||||
int i = 0;
|
||||
ufixedpoint32 src_0(src[0]);
|
||||
v_uint32x4 v_src_0 = v_setall_u32(*((uint32_t*)&src_0));
|
||||
for (; i < dst_min - 3; i += 4, m += 8, dst += 4) // Points that fall left from src image so became equal to leftmost src point
|
||||
#if CV_SIMD
|
||||
const int VECSZ = v_uint32::nlanes;
|
||||
v_uint32 v_src_0 = vx_setall_u32(*((uint32_t*)&src_0));
|
||||
for (; i <= dst_min - VECSZ; i += VECSZ, m += 2*VECSZ, dst += VECSZ) // Points that fall left from src image so became equal to leftmost src point
|
||||
{
|
||||
v_store((uint32_t*)dst, v_src_0);
|
||||
}
|
||||
#endif
|
||||
for (; i < dst_min; i++, m += 2)
|
||||
{
|
||||
*(dst++) = src_0;
|
||||
}
|
||||
for (; i < dst_max - 3 && ofst[i + 3] + 8 <= ofst[dst_width - 1]; i += 4, m += 8, dst += 4)
|
||||
#if CV_SIMD
|
||||
for (; i <= dst_max - VECSZ; i += VECSZ, m += 2*VECSZ, dst += VECSZ)
|
||||
{
|
||||
v_uint32x4 v_src0 = v_combine_low(v_load_expand(src + ofst[i]), v_load_expand(src + ofst[i + 1]));
|
||||
v_uint32x4 v_mul0 = v_load((uint32_t*)m);
|
||||
v_uint32x4 v_src1 = v_combine_low(v_load_expand(src + ofst[i + 2]), v_load_expand(src + ofst[i + 3]));
|
||||
v_uint32x4 v_mul1 = v_load((uint32_t*)m + 4);
|
||||
v_uint32x4 v_res0 = v_src0 * v_mul0;//a1a2b1b2
|
||||
v_uint32x4 v_res1 = v_src1 * v_mul1;//c1c2d1d2
|
||||
v_uint32x4 v_tmp0, v_tmp1;
|
||||
v_recombine(v_res0, v_res1, v_tmp0, v_tmp1);//a1a2c1c2 b1b2d1d2
|
||||
v_zip(v_tmp0, v_tmp1, v_res0, v_res1);//a1b1a2b2 c1d1c2d2
|
||||
v_recombine(v_res0, v_res1, v_tmp0, v_tmp1);//a1b1c1d1 a2b2c2d2
|
||||
v_store((uint32_t*)dst, v_tmp0 + v_tmp1);//abcd
|
||||
v_uint32 v_src0, v_src1;
|
||||
v_load_indexed_deinterleave(src, ofst + i, v_src0, v_src1);
|
||||
v_uint32 v_mul0, v_mul1;
|
||||
v_load_deinterleave((uint32_t*)m, v_mul0, v_mul1);
|
||||
v_store((uint32_t*)dst, v_src0 * v_mul0 + v_src1 * v_mul1);//abcd
|
||||
}
|
||||
#endif
|
||||
for (; i < dst_max; i += 1, m += 2)
|
||||
{
|
||||
uint16_t* px = src + ofst[i];
|
||||
*(dst++) = m[0] * px[0] + m[1] * px[1];
|
||||
}
|
||||
src_0 = (src + ofst[dst_width - 1])[0];
|
||||
v_src_0 = v_setall_u32(*((uint32_t*)&src_0));
|
||||
for (; i < dst_width - 3; i += 4, dst += 4)
|
||||
#if CV_SIMD
|
||||
v_src_0 = vx_setall_u32(*((uint32_t*)&src_0));
|
||||
for (; i <= dst_width - VECSZ; i += VECSZ, dst += VECSZ)
|
||||
{
|
||||
v_store((uint32_t*)dst, v_src_0);
|
||||
}
|
||||
vx_cleanup();
|
||||
#endif
|
||||
for (; i < dst_width; i++)
|
||||
{
|
||||
*(dst++) = src_0;
|
||||
@@ -552,18 +727,22 @@ void vlineSet(FT* src, ET* dst, int dst_width)
|
||||
template <>
|
||||
void vlineSet<uint8_t, ufixedpoint16>(ufixedpoint16* src, uint8_t* dst, int dst_width)
|
||||
{
|
||||
static const v_uint16x8 v_fixedRound = v_setall_u16((uint16_t)((1U << 8) >> 1));
|
||||
int i = 0;
|
||||
for (; i < dst_width - 15; i += 16, src += 16, dst += 16)
|
||||
#if CV_SIMD
|
||||
const int VECSZ = v_uint8::nlanes;
|
||||
static const v_uint16 v_fixedRound = vx_setall_u16((uint16_t)((1U << 8) >> 1));
|
||||
for (; i <= dst_width - VECSZ; i += VECSZ, src += VECSZ, dst += VECSZ)
|
||||
{
|
||||
v_uint16x8 v_src0 = v_load((uint16_t*)src);
|
||||
v_uint16x8 v_src1 = v_load((uint16_t*)src + 8);
|
||||
v_uint16 v_src0 = vx_load((uint16_t*)src);
|
||||
v_uint16 v_src1 = vx_load((uint16_t*)src + VECSZ/2);
|
||||
|
||||
v_uint16x8 v_res0 = (v_src0 + v_fixedRound) >> 8;
|
||||
v_uint16x8 v_res1 = (v_src1 + v_fixedRound) >> 8;
|
||||
v_uint16 v_res0 = (v_src0 + v_fixedRound) >> 8;
|
||||
v_uint16 v_res1 = (v_src1 + v_fixedRound) >> 8;
|
||||
|
||||
v_store(dst, v_pack(v_res0, v_res1));
|
||||
}
|
||||
vx_cleanup();
|
||||
#endif
|
||||
for (; i < dst_width; i++)
|
||||
*(dst++) = *(src++);
|
||||
}
|
||||
@@ -582,36 +761,40 @@ void vlineResize(FT* src, size_t src_step, FT* m, ET* dst, int dst_width)
|
||||
template <>
|
||||
void vlineResize<uint8_t, ufixedpoint16, 2>(ufixedpoint16* src, size_t src_step, ufixedpoint16* m, uint8_t* dst, int dst_width)
|
||||
{
|
||||
static const v_int32x4 v_fixedRound = v_setall_s32((int32_t)((1 << 16) >> 1));
|
||||
static const v_int16x8 v_128 = v_reinterpret_as_s16(v_setall_u16((uint16_t)1<<15));
|
||||
static const v_int8x16 v_128_16 = v_reinterpret_as_s8 (v_setall_u8 ((uint8_t) 1<<7));
|
||||
|
||||
int i = 0;
|
||||
ufixedpoint16* src1 = src + src_step;
|
||||
v_int16x8 v_mul = v_reinterpret_as_s16(v_setall_u32(((uint32_t*)m)[0]));
|
||||
for (; i < dst_width - 15; i += 16, src += 16, src1 += 16, dst += 16)
|
||||
#if CV_SIMD
|
||||
const int VECSZ = v_uint8::nlanes;
|
||||
static const v_int32 v_fixedRound = vx_setall_s32((int32_t)((1 << 16) >> 1));
|
||||
static const v_int16 v_128 = v_reinterpret_as_s16(vx_setall_u16((uint16_t)1<<15));
|
||||
static const v_int8 v_128_16 = v_reinterpret_as_s8 (vx_setall_u8 ((uint8_t) 1<<7));
|
||||
|
||||
v_int16 v_mul = v_reinterpret_as_s16(vx_setall_u32(((uint32_t*)m)[0]));
|
||||
for (; i <= dst_width - VECSZ; i += VECSZ, src += VECSZ, src1 += VECSZ, dst += VECSZ)
|
||||
{
|
||||
v_int16x8 v_src00 = v_load((int16_t*)src);
|
||||
v_int16x8 v_src10 = v_load((int16_t*)src1);
|
||||
v_int16x8 v_tmp0, v_tmp1;
|
||||
v_int16 v_src00 = vx_load((int16_t*)src);
|
||||
v_int16 v_src10 = vx_load((int16_t*)src1);
|
||||
v_int16 v_tmp0, v_tmp1;
|
||||
v_zip(v_add_wrap(v_src00,v_128), v_add_wrap(v_src10,v_128), v_tmp0, v_tmp1);
|
||||
|
||||
v_int32x4 v_res0 = v_dotprod(v_tmp0, v_mul);
|
||||
v_int32x4 v_res1 = v_dotprod(v_tmp1, v_mul);
|
||||
v_int32 v_res0 = v_dotprod(v_tmp0, v_mul);
|
||||
v_int32 v_res1 = v_dotprod(v_tmp1, v_mul);
|
||||
|
||||
v_int16x8 v_src01 = v_load((int16_t*)src + 8);
|
||||
v_int16x8 v_src11 = v_load((int16_t*)src1 + 8);
|
||||
v_int16 v_src01 = vx_load((int16_t*)src + VECSZ/2);
|
||||
v_int16 v_src11 = vx_load((int16_t*)src1 + VECSZ/2);
|
||||
v_zip(v_add_wrap(v_src01,v_128), v_add_wrap(v_src11,v_128), v_tmp0, v_tmp1);
|
||||
v_int32x4 v_res2 = v_dotprod(v_tmp0, v_mul);
|
||||
v_int32x4 v_res3 = v_dotprod(v_tmp1, v_mul);
|
||||
v_int32 v_res2 = v_dotprod(v_tmp0, v_mul);
|
||||
v_int32 v_res3 = v_dotprod(v_tmp1, v_mul);
|
||||
|
||||
v_int8x16 v_res = v_pack(v_pack((v_res0 + v_fixedRound) >> 16,
|
||||
(v_res1 + v_fixedRound) >> 16),
|
||||
v_pack((v_res2 + v_fixedRound) >> 16,
|
||||
(v_res3 + v_fixedRound) >> 16));
|
||||
v_int8 v_res = v_pack(v_pack((v_res0 + v_fixedRound) >> 16,
|
||||
(v_res1 + v_fixedRound) >> 16),
|
||||
v_pack((v_res2 + v_fixedRound) >> 16,
|
||||
(v_res3 + v_fixedRound) >> 16));
|
||||
|
||||
v_store(dst, v_reinterpret_as_u8(v_sub_wrap(v_res, v_128_16)));
|
||||
}
|
||||
vx_cleanup();
|
||||
#endif
|
||||
for (; i < dst_width; i++)
|
||||
{
|
||||
*(dst++) = (uint8_t)(*(src++) * m[0] + *(src1++) * m[1]);
|
||||
|
||||
@@ -407,27 +407,25 @@ void cv::pyrMeanShiftFiltering( InputArray _src, OutputArray _dst,
|
||||
cv::Size size = src.size();
|
||||
const uchar* sptr = src.ptr();
|
||||
int sstep = (int)src.step;
|
||||
uchar* mask = 0;
|
||||
int mstep = 0;
|
||||
uchar* dptr;
|
||||
int dstep;
|
||||
float sp = (float)(sp0 / (1 << level));
|
||||
sp = MAX( sp, 1 );
|
||||
|
||||
cv::Mat m;
|
||||
if( level < max_level )
|
||||
{
|
||||
cv::Size size1 = dst_pyramid[level+1].size();
|
||||
cv::Mat m( size.height, size.width, CV_8UC1, mask0.ptr() );
|
||||
m = cv::Mat(size.height, size.width, CV_8UC1, mask0.ptr());
|
||||
dstep = (int)dst_pyramid[level+1].step;
|
||||
dptr = dst_pyramid[level+1].ptr() + dstep + cn;
|
||||
mstep = (int)m.step;
|
||||
mask = m.ptr() + mstep;
|
||||
//cvResize( dst_pyramid[level+1], dst_pyramid[level], CV_INTER_CUBIC );
|
||||
cv::pyrUp( dst_pyramid[level+1], dst_pyramid[level], dst_pyramid[level].size() );
|
||||
m.setTo(cv::Scalar::all(0));
|
||||
|
||||
for( i = 1; i < size1.height-1; i++, dptr += dstep - (size1.width-2)*3, mask += mstep*2 )
|
||||
for( i = 1; i < size1.height-1; i++, dptr += dstep - (size1.width-2)*3)
|
||||
{
|
||||
uchar* mask = m.ptr(1 + i * 2);
|
||||
for( j = 1; j < size1.width-1; j++, dptr += cn )
|
||||
{
|
||||
int c0 = dptr[0], c1 = dptr[1], c2 = dptr[2];
|
||||
@@ -437,16 +435,16 @@ void cv::pyrMeanShiftFiltering( InputArray _src, OutputArray _dst,
|
||||
}
|
||||
|
||||
cv::dilate( m, m, cv::Mat() );
|
||||
mask = m.ptr();
|
||||
}
|
||||
|
||||
dptr = dst_pyramid[level].ptr();
|
||||
dstep = (int)dst_pyramid[level].step;
|
||||
|
||||
for( i = 0; i < size.height; i++, sptr += sstep - size.width*3,
|
||||
dptr += dstep - size.width*3,
|
||||
mask += mstep )
|
||||
dptr += dstep - size.width*3
|
||||
)
|
||||
{
|
||||
uchar* mask = m.empty() ? NULL : m.ptr(i);
|
||||
for( j = 0; j < size.width; j++, sptr += 3, dptr += 3 )
|
||||
{
|
||||
int x0 = j, y0 = i, x1, y1, iter;
|
||||
|
||||
+341
-384
@@ -1820,22 +1820,13 @@ template <>
|
||||
void hlineSmooth1N<uint8_t, ufixedpoint16>(const uint8_t* src, int cn, const ufixedpoint16* m, int, ufixedpoint16* dst, int len, int)
|
||||
{
|
||||
int lencn = len*cn;
|
||||
v_uint16x8 v_mul = v_setall_u16(*((uint16_t*)m));
|
||||
int i = 0;
|
||||
for (; i <= lencn - 16; i += 16)
|
||||
{
|
||||
v_uint8x16 v_src = v_load(src + i);
|
||||
v_uint16x8 v_tmp0, v_tmp1;
|
||||
v_expand(v_src, v_tmp0, v_tmp1);
|
||||
v_store((uint16_t*)dst + i, v_mul*v_tmp0);
|
||||
v_store((uint16_t*)dst + i + 8, v_mul*v_tmp1);
|
||||
}
|
||||
if (i <= lencn - 8)
|
||||
{
|
||||
v_uint16x8 v_src = v_load_expand(src + i);
|
||||
v_store((uint16_t*)dst + i, v_mul*v_src);
|
||||
i += 8;
|
||||
}
|
||||
#if CV_SIMD
|
||||
const int VECSZ = v_uint16::nlanes;
|
||||
v_uint16 v_mul = vx_setall_u16(*((uint16_t*)m));
|
||||
for (; i <= lencn - VECSZ; i += VECSZ)
|
||||
v_store((uint16_t*)dst + i, v_mul*vx_load_expand(src + i));
|
||||
#endif
|
||||
for (; i < lencn; i++)
|
||||
dst[i] = m[0] * src[i];
|
||||
}
|
||||
@@ -1850,20 +1841,11 @@ void hlineSmooth1N1<uint8_t, ufixedpoint16>(const uint8_t* src, int cn, const uf
|
||||
{
|
||||
int lencn = len*cn;
|
||||
int i = 0;
|
||||
for (; i <= lencn - 16; i += 16)
|
||||
{
|
||||
v_uint8x16 v_src = v_load(src + i);
|
||||
v_uint16x8 v_tmp0, v_tmp1;
|
||||
v_expand(v_src, v_tmp0, v_tmp1);
|
||||
v_store((uint16_t*)dst + i, v_shl<8>(v_tmp0));
|
||||
v_store((uint16_t*)dst + i + 8, v_shl<8>(v_tmp1));
|
||||
}
|
||||
if (i <= lencn - 8)
|
||||
{
|
||||
v_uint16x8 v_src = v_load_expand(src + i);
|
||||
v_store((uint16_t*)dst + i, v_shl<8>(v_src));
|
||||
i += 8;
|
||||
}
|
||||
#if CV_SIMD
|
||||
const int VECSZ = v_uint16::nlanes;
|
||||
for (; i <= lencn - VECSZ; i += VECSZ)
|
||||
v_store((uint16_t*)dst + i, v_shl<8>(vx_load_expand(src + i)));
|
||||
#endif
|
||||
for (; i < lencn; i++)
|
||||
dst[i] = src[i];
|
||||
}
|
||||
@@ -1926,18 +1908,15 @@ void hlineSmooth3N<uint8_t, ufixedpoint16>(const uint8_t* src, int cn, const ufi
|
||||
|
||||
src += cn; dst += cn;
|
||||
int i = cn, lencn = (len - 1)*cn;
|
||||
v_uint16x8 v_mul0 = v_setall_u16(*((uint16_t*)m));
|
||||
v_uint16x8 v_mul1 = v_setall_u16(*((uint16_t*)(m + 1)));
|
||||
v_uint16x8 v_mul2 = v_setall_u16(*((uint16_t*)(m + 2)));
|
||||
for (; i <= lencn - 16; i += 16, src += 16, dst += 16)
|
||||
{
|
||||
v_uint16x8 v_src00, v_src01, v_src10, v_src11, v_src20, v_src21;
|
||||
v_expand(v_load(src - cn), v_src00, v_src01);
|
||||
v_expand(v_load(src), v_src10, v_src11);
|
||||
v_expand(v_load(src + cn), v_src20, v_src21);
|
||||
v_store((uint16_t*)dst, v_src00 * v_mul0 + v_src10 * v_mul1 + v_src20 * v_mul2);
|
||||
v_store((uint16_t*)dst + 8, v_src01 * v_mul0 + v_src11 * v_mul1 + v_src21 * v_mul2);
|
||||
}
|
||||
#if CV_SIMD
|
||||
const uint16_t* _m = (const uint16_t*)m;
|
||||
const int VECSZ = v_uint16::nlanes;
|
||||
v_uint16 v_mul0 = vx_setall_u16(_m[0]);
|
||||
v_uint16 v_mul1 = vx_setall_u16(_m[1]);
|
||||
v_uint16 v_mul2 = vx_setall_u16(_m[2]);
|
||||
for (; i <= lencn - VECSZ; i += VECSZ, src += VECSZ, dst += VECSZ)
|
||||
v_store((uint16_t*)dst, vx_load_expand(src - cn) * v_mul0 + vx_load_expand(src) * v_mul1 + vx_load_expand(src + cn) * v_mul2);
|
||||
#endif
|
||||
for (; i < lencn; i++, src++, dst++)
|
||||
*dst = m[0] * src[-cn] + m[1] * src[0] + m[2] * src[cn];
|
||||
|
||||
@@ -2017,15 +1996,11 @@ void hlineSmooth3N121<uint8_t, ufixedpoint16>(const uint8_t* src, int cn, const
|
||||
|
||||
src += cn; dst += cn;
|
||||
int i = cn, lencn = (len - 1)*cn;
|
||||
for (; i <= lencn - 16; i += 16, src += 16, dst += 16)
|
||||
{
|
||||
v_uint16x8 v_src00, v_src01, v_src10, v_src11, v_src20, v_src21;
|
||||
v_expand(v_load(src - cn), v_src00, v_src01);
|
||||
v_expand(v_load(src), v_src10, v_src11);
|
||||
v_expand(v_load(src + cn), v_src20, v_src21);
|
||||
v_store((uint16_t*)dst, (v_src00 + v_src20 + (v_src10 << 1)) << 6);
|
||||
v_store((uint16_t*)dst + 8, (v_src01 + v_src21 + (v_src11 << 1)) << 6);
|
||||
}
|
||||
#if CV_SIMD
|
||||
const int VECSZ = v_uint16::nlanes;
|
||||
for (; i <= lencn - VECSZ; i += VECSZ, src += VECSZ, dst += VECSZ)
|
||||
v_store((uint16_t*)dst, (vx_load_expand(src - cn) + vx_load_expand(src + cn) + (vx_load_expand(src) << 1)) << 6);
|
||||
#endif
|
||||
for (; i < lencn; i++, src++, dst++)
|
||||
*((uint16_t*)dst) = (uint16_t(src[-cn]) + uint16_t(src[cn]) + (uint16_t(src[0]) << 1)) << 6;
|
||||
|
||||
@@ -2108,17 +2083,14 @@ void hlineSmooth3Naba<uint8_t, ufixedpoint16>(const uint8_t* src, int cn, const
|
||||
|
||||
src += cn; dst += cn;
|
||||
int i = cn, lencn = (len - 1)*cn;
|
||||
v_uint16x8 v_mul0 = v_setall_u16(*((uint16_t*)m));
|
||||
v_uint16x8 v_mul1 = v_setall_u16(*((uint16_t*)m+1));
|
||||
for (; i <= lencn - 16; i += 16, src += 16, dst += 16)
|
||||
{
|
||||
v_uint16x8 v_src00, v_src01, v_src10, v_src11, v_src20, v_src21;
|
||||
v_expand(v_load(src - cn), v_src00, v_src01);
|
||||
v_expand(v_load(src), v_src10, v_src11);
|
||||
v_expand(v_load(src + cn), v_src20, v_src21);
|
||||
v_store((uint16_t*)dst, (v_src00 + v_src20) * v_mul0 + v_src10 * v_mul1);
|
||||
v_store((uint16_t*)dst + 8, (v_src01 + v_src21) * v_mul0 + v_src11 * v_mul1);
|
||||
}
|
||||
#if CV_SIMD
|
||||
const uint16_t* _m = (const uint16_t*)m;
|
||||
const int VECSZ = v_uint16::nlanes;
|
||||
v_uint16 v_mul0 = vx_setall_u16(_m[0]);
|
||||
v_uint16 v_mul1 = vx_setall_u16(_m[1]);
|
||||
for (; i <= lencn - VECSZ; i += VECSZ, src += VECSZ, dst += VECSZ)
|
||||
v_store((uint16_t*)dst, (vx_load_expand(src - cn) + vx_load_expand(src + cn)) * v_mul0 + vx_load_expand(src) * v_mul1);
|
||||
#endif
|
||||
for (; i < lencn; i++, src++, dst++)
|
||||
*((uint16_t*)dst) = ((uint16_t*)m)[1] * src[0] + ((uint16_t*)m)[0] * ((uint16_t)(src[-cn]) + (uint16_t)(src[cn]));
|
||||
|
||||
@@ -2304,22 +2276,17 @@ void hlineSmooth5N<uint8_t, ufixedpoint16>(const uint8_t* src, int cn, const ufi
|
||||
|
||||
src += 2 * cn; dst += 2 * cn;
|
||||
int i = 2*cn, lencn = (len - 2)*cn;
|
||||
v_uint16x8 v_mul0 = v_setall_u16(*((uint16_t*)m));
|
||||
v_uint16x8 v_mul1 = v_setall_u16(*((uint16_t*)(m + 1)));
|
||||
v_uint16x8 v_mul2 = v_setall_u16(*((uint16_t*)(m + 2)));
|
||||
v_uint16x8 v_mul3 = v_setall_u16(*((uint16_t*)(m + 3)));
|
||||
v_uint16x8 v_mul4 = v_setall_u16(*((uint16_t*)(m + 4)));
|
||||
for (; i <= lencn - 16; i += 16, src += 16, dst += 16)
|
||||
{
|
||||
v_uint16x8 v_src00, v_src01, v_src10, v_src11, v_src20, v_src21, v_src30, v_src31, v_src40, v_src41;
|
||||
v_expand(v_load(src - 2*cn), v_src00, v_src01);
|
||||
v_expand(v_load(src - cn), v_src10, v_src11);
|
||||
v_expand(v_load(src), v_src20, v_src21);
|
||||
v_expand(v_load(src + cn), v_src30, v_src31);
|
||||
v_expand(v_load(src + 2*cn), v_src40, v_src41);
|
||||
v_store((uint16_t*)dst, v_src00 * v_mul0 + v_src10 * v_mul1 + v_src20 * v_mul2 + v_src30 * v_mul3 + v_src40 * v_mul4);
|
||||
v_store((uint16_t*)dst + 8, v_src01 * v_mul0 + v_src11 * v_mul1 + v_src21 * v_mul2 + v_src31 * v_mul3 + v_src41 * v_mul4);
|
||||
}
|
||||
#if CV_SIMD
|
||||
const uint16_t* _m = (const uint16_t*)m;
|
||||
const int VECSZ = v_uint16::nlanes;
|
||||
v_uint16 v_mul0 = vx_setall_u16(_m[0]);
|
||||
v_uint16 v_mul1 = vx_setall_u16(_m[1]);
|
||||
v_uint16 v_mul2 = vx_setall_u16(_m[2]);
|
||||
v_uint16 v_mul3 = vx_setall_u16(_m[3]);
|
||||
v_uint16 v_mul4 = vx_setall_u16(_m[4]);
|
||||
for (; i <= lencn - VECSZ; i += VECSZ, src += VECSZ, dst += VECSZ)
|
||||
v_store((uint16_t*)dst, vx_load_expand(src - 2 * cn) * v_mul0 + vx_load_expand(src - cn) * v_mul1 + vx_load_expand(src) * v_mul2 + vx_load_expand(src + cn) * v_mul3 + vx_load_expand(src + 2 * cn) * v_mul4);
|
||||
#endif
|
||||
for (; i < lencn; i++, src++, dst++)
|
||||
*dst = m[0] * src[-2*cn] + m[1] * src[-cn] + m[2] * src[0] + m[3] * src[cn] + m[4] * src[2*cn];
|
||||
|
||||
@@ -2517,18 +2484,12 @@ void hlineSmooth5N14641<uint8_t, ufixedpoint16>(const uint8_t* src, int cn, cons
|
||||
|
||||
src += 2 * cn; dst += 2 * cn;
|
||||
int i = 2 * cn, lencn = (len - 2)*cn;
|
||||
v_uint16x8 v_6 = v_setall_u16(6);
|
||||
for (; i <= lencn - 16; i += 16, src += 16, dst += 16)
|
||||
{
|
||||
v_uint16x8 v_src00, v_src01, v_src10, v_src11, v_src20, v_src21, v_src30, v_src31, v_src40, v_src41;
|
||||
v_expand(v_load(src - 2*cn), v_src00, v_src01);
|
||||
v_expand(v_load(src - cn), v_src10, v_src11);
|
||||
v_expand(v_load(src), v_src20, v_src21);
|
||||
v_expand(v_load(src + cn), v_src30, v_src31);
|
||||
v_expand(v_load(src + 2*cn), v_src40, v_src41);
|
||||
v_store((uint16_t*)dst, (v_src20 * v_6 + ((v_src10 + v_src30) << 2) + v_src00 + v_src40) << 4);
|
||||
v_store((uint16_t*)dst + 8, (v_src21 * v_6 + ((v_src11 + v_src31) << 2) + v_src01 + v_src41) << 4);
|
||||
}
|
||||
#if CV_SIMD
|
||||
const int VECSZ = v_uint16::nlanes;
|
||||
v_uint16 v_6 = vx_setall_u16(6);
|
||||
for (; i <= lencn - VECSZ; i += VECSZ, src += VECSZ, dst += VECSZ)
|
||||
v_store((uint16_t*)dst, (vx_load_expand(src) * v_6 + ((vx_load_expand(src - cn) + vx_load_expand(src + cn)) << 2) + vx_load_expand(src - 2 * cn) + vx_load_expand(src + 2 * cn)) << 4);
|
||||
#endif
|
||||
for (; i < lencn; i++, src++, dst++)
|
||||
*((uint16_t*)dst) = (uint16_t(src[0]) * 6 + ((uint16_t(src[-cn]) + uint16_t(src[cn])) << 2) + uint16_t(src[-2 * cn]) + uint16_t(src[2 * cn])) << 4;
|
||||
|
||||
@@ -2721,20 +2682,15 @@ void hlineSmooth5Nabcba<uint8_t, ufixedpoint16>(const uint8_t* src, int cn, cons
|
||||
|
||||
src += 2 * cn; dst += 2 * cn;
|
||||
int i = 2 * cn, lencn = (len - 2)*cn;
|
||||
v_uint16x8 v_mul0 = v_setall_u16(*((uint16_t*)m));
|
||||
v_uint16x8 v_mul1 = v_setall_u16(*((uint16_t*)(m + 1)));
|
||||
v_uint16x8 v_mul2 = v_setall_u16(*((uint16_t*)(m + 2)));
|
||||
for (; i <= lencn - 16; i += 16, src += 16, dst += 16)
|
||||
{
|
||||
v_uint16x8 v_src00, v_src01, v_src10, v_src11, v_src20, v_src21, v_src30, v_src31, v_src40, v_src41;
|
||||
v_expand(v_load(src - 2 * cn), v_src00, v_src01);
|
||||
v_expand(v_load(src - cn), v_src10, v_src11);
|
||||
v_expand(v_load(src), v_src20, v_src21);
|
||||
v_expand(v_load(src + cn), v_src30, v_src31);
|
||||
v_expand(v_load(src + 2 * cn), v_src40, v_src41);
|
||||
v_store((uint16_t*)dst, (v_src00 + v_src40) * v_mul0 + (v_src10 + v_src30)* v_mul1 + v_src20 * v_mul2);
|
||||
v_store((uint16_t*)dst + 8, (v_src01 + v_src41) * v_mul0 + (v_src11 + v_src31) * v_mul1 + v_src21 * v_mul2);
|
||||
}
|
||||
#if CV_SIMD
|
||||
const uint16_t* _m = (const uint16_t*)m;
|
||||
const int VECSZ = v_uint16::nlanes;
|
||||
v_uint16 v_mul0 = vx_setall_u16(_m[0]);
|
||||
v_uint16 v_mul1 = vx_setall_u16(_m[1]);
|
||||
v_uint16 v_mul2 = vx_setall_u16(_m[2]);
|
||||
for (; i <= lencn - VECSZ; i += VECSZ, src += VECSZ, dst += VECSZ)
|
||||
v_store((uint16_t*)dst, (vx_load_expand(src - 2 * cn) + vx_load_expand(src + 2 * cn)) * v_mul0 + (vx_load_expand(src - cn) + vx_load_expand(src + cn))* v_mul1 + vx_load_expand(src) * v_mul2);
|
||||
#endif
|
||||
for (; i < lencn; i++, src++, dst++)
|
||||
*((uint16_t*)dst) = ((uint16_t*)m)[0] * ((uint16_t)(src[-2 * cn]) + (uint16_t)(src[2 * cn])) + ((uint16_t*)m)[1] * ((uint16_t)(src[-cn]) + (uint16_t)(src[cn])) + ((uint16_t*)m)[2] * src[0];
|
||||
|
||||
@@ -2844,23 +2800,16 @@ void hlineSmooth<uint8_t, ufixedpoint16>(const uint8_t* src, int cn, const ufixe
|
||||
}
|
||||
i *= cn;
|
||||
int lencn = (len - post_shift + 1)*cn;
|
||||
for (; i <= lencn - 16; i+=16, src+=16, dst+=16)
|
||||
#if CV_SIMD
|
||||
const int VECSZ = v_uint16::nlanes;
|
||||
for (; i <= lencn - VECSZ; i+=VECSZ, src+=VECSZ, dst+=VECSZ)
|
||||
{
|
||||
v_uint16x8 v_src0, v_src1;
|
||||
v_uint16x8 v_mul = v_setall_u16(*((uint16_t*)m));
|
||||
v_expand(v_load(src), v_src0, v_src1);
|
||||
v_uint16x8 v_res0 = v_src0 * v_mul;
|
||||
v_uint16x8 v_res1 = v_src1 * v_mul;
|
||||
v_uint16 v_res0 = vx_load_expand(src) * vx_setall_u16(*((uint16_t*)m));
|
||||
for (int j = 1; j < n; j++)
|
||||
{
|
||||
v_mul = v_setall_u16(*((uint16_t*)(m + j)));
|
||||
v_expand(v_load(src + j * cn), v_src0, v_src1);
|
||||
v_res0 += v_src0 * v_mul;
|
||||
v_res1 += v_src1 * v_mul;
|
||||
}
|
||||
v_res0 += vx_load_expand(src + j * cn) * vx_setall_u16(*((uint16_t*)(m + j)));
|
||||
v_store((uint16_t*)dst, v_res0);
|
||||
v_store((uint16_t*)dst+8, v_res1);
|
||||
}
|
||||
#endif
|
||||
for (; i < lencn; i++, src++, dst++)
|
||||
{
|
||||
*dst = m[0] * src[0];
|
||||
@@ -2970,26 +2919,16 @@ void hlineSmoothONa_yzy_a<uint8_t, ufixedpoint16>(const uint8_t* src, int cn, co
|
||||
}
|
||||
i *= cn;
|
||||
int lencn = (len - post_shift + 1)*cn;
|
||||
for (; i <= lencn - 16; i += 16, src += 16, dst += 16)
|
||||
#if CV_SIMD
|
||||
const int VECSZ = v_uint16::nlanes;
|
||||
for (; i <= lencn - VECSZ; i += VECSZ, src += VECSZ, dst += VECSZ)
|
||||
{
|
||||
v_uint16x8 v_src00, v_src01, v_srcN00, v_srcN01;
|
||||
|
||||
v_uint16x8 v_mul = v_setall_u16(*((uint16_t*)(m + pre_shift)));
|
||||
v_expand(v_load(src + pre_shift * cn), v_src00, v_src01);
|
||||
v_uint16x8 v_res0 = v_src00 * v_mul;
|
||||
v_uint16x8 v_res1 = v_src01 * v_mul;
|
||||
v_uint16 v_res0 = vx_load_expand(src + pre_shift * cn) * vx_setall_u16(*((uint16_t*)(m + pre_shift)));
|
||||
for (int j = 0; j < pre_shift; j ++)
|
||||
{
|
||||
v_mul = v_setall_u16(*((uint16_t*)(m + j)));
|
||||
v_expand(v_load(src + j * cn), v_src00, v_src01);
|
||||
v_expand(v_load(src + (n - 1 - j)*cn), v_srcN00, v_srcN01);
|
||||
v_res0 += (v_src00 + v_srcN00) * v_mul;
|
||||
v_res1 += (v_src01 + v_srcN01) * v_mul;
|
||||
}
|
||||
|
||||
v_res0 += (vx_load_expand(src + j * cn) + vx_load_expand(src + (n - 1 - j)*cn)) * vx_setall_u16(*((uint16_t*)(m + j)));
|
||||
v_store((uint16_t*)dst, v_res0);
|
||||
v_store((uint16_t*)dst + 8, v_res1);
|
||||
}
|
||||
#endif
|
||||
for (; i < lencn; i++, src++, dst++)
|
||||
{
|
||||
*dst = m[pre_shift] * src[pre_shift*cn];
|
||||
@@ -3025,28 +2964,13 @@ template <>
|
||||
void vlineSmooth1N<uint8_t, ufixedpoint16>(const ufixedpoint16* const * src, const ufixedpoint16* m, int, uint8_t* dst, int len)
|
||||
{
|
||||
const ufixedpoint16* src0 = src[0];
|
||||
v_uint16x8 v_mul = v_setall_u16(*((uint16_t*)m));
|
||||
#if CV_SSE2
|
||||
v_uint16x8 v_1 = v_setall_u16(1);
|
||||
v_mul += v_mul;
|
||||
#endif
|
||||
int i = 0;
|
||||
for (; i <= len - 16; i += 16)
|
||||
{
|
||||
v_uint16x8 v_src0 = v_load((uint16_t*)src0 + i);
|
||||
v_uint16x8 v_src1 = v_load((uint16_t*)src0 + i + 8);
|
||||
v_uint8x16 v_res;
|
||||
#if CV_SSE2
|
||||
v_res.val = _mm_packus_epi16(_mm_srli_epi16(_mm_add_epi16(v_1.val, _mm_mulhi_epu16(v_src0.val, v_mul.val)),1),
|
||||
_mm_srli_epi16(_mm_add_epi16(v_1.val, _mm_mulhi_epu16(v_src1.val, v_mul.val)),1));
|
||||
#else
|
||||
v_uint32x4 v_res0, v_res1, v_res2, v_res3;
|
||||
v_mul_expand(v_src0, v_mul, v_res0, v_res1);
|
||||
v_mul_expand(v_src1, v_mul, v_res2, v_res3);
|
||||
v_res = v_pack(v_rshr_pack<16>(v_res0, v_res1), v_rshr_pack<16>(v_res2, v_res3));
|
||||
#if CV_SIMD
|
||||
const int VECSZ = v_uint16::nlanes;
|
||||
v_uint16 v_mul = vx_setall_u16(*((uint16_t*)m)<<1);
|
||||
for (; i <= len - VECSZ; i += VECSZ)
|
||||
v_rshr_pack_store<1>(dst + i, v_mul_hi(vx_load((uint16_t*)src0 + i), v_mul));
|
||||
#endif
|
||||
v_store(dst + i, v_res);
|
||||
}
|
||||
for (; i < len; i++)
|
||||
dst[i] = m[0] * src0[i];
|
||||
}
|
||||
@@ -3062,8 +2986,11 @@ void vlineSmooth1N1<uint8_t, ufixedpoint16>(const ufixedpoint16* const * src, co
|
||||
{
|
||||
const ufixedpoint16* src0 = src[0];
|
||||
int i = 0;
|
||||
for (; i <= len - 8; i += 8)
|
||||
v_rshr_pack_store<8>(dst + i, v_load((uint16_t*)(src0 + i)));
|
||||
#if CV_SIMD
|
||||
const int VECSZ = v_uint16::nlanes;
|
||||
for (; i <= len - VECSZ; i += VECSZ)
|
||||
v_rshr_pack_store<8>(dst + i, vx_load((uint16_t*)(src0 + i)));
|
||||
#endif
|
||||
for (; i < len; i++)
|
||||
dst[i] = src0[i];
|
||||
}
|
||||
@@ -3077,46 +3004,51 @@ template <>
|
||||
void vlineSmooth3N<uint8_t, ufixedpoint16>(const ufixedpoint16* const * src, const ufixedpoint16* m, int, uint8_t* dst, int len)
|
||||
{
|
||||
int i = 0;
|
||||
static const v_int16x8 v_128 = v_reinterpret_as_s16(v_setall_u16((uint16_t)1 << 15));
|
||||
v_int32x4 v_128_4 = v_setall_s32(128 << 16);
|
||||
if (len > 7)
|
||||
#if CV_SIMD
|
||||
static const v_int16 v_128 = v_reinterpret_as_s16(vx_setall_u16((uint16_t)1 << 15));
|
||||
v_int32 v_128_4 = vx_setall_s32(128 << 16);
|
||||
const int VECSZ = v_uint16::nlanes;
|
||||
if (len >= VECSZ)
|
||||
{
|
||||
ufixedpoint32 val[] = { (m[0] + m[1] + m[2]) * ufixedpoint16((uint8_t)128) };
|
||||
v_128_4 = v_setall_s32(*((int32_t*)val));
|
||||
v_128_4 = vx_setall_s32(*((int32_t*)val));
|
||||
}
|
||||
v_int16x8 v_mul01 = v_reinterpret_as_s16(v_setall_u32(*((uint32_t*)m)));
|
||||
v_int16x8 v_mul2 = v_reinterpret_as_s16(v_setall_u16(*((uint16_t*)(m + 2))));
|
||||
for (; i <= len - 32; i += 32)
|
||||
v_int16 v_mul01 = v_reinterpret_as_s16(vx_setall_u32(*((uint32_t*)m)));
|
||||
v_int16 v_mul2 = v_reinterpret_as_s16(vx_setall_u16(*((uint16_t*)(m + 2))));
|
||||
for (; i <= len - 4*VECSZ; i += 4*VECSZ)
|
||||
{
|
||||
v_int16x8 v_src00, v_src10, v_src01, v_src11, v_src02, v_src12, v_src03, v_src13;
|
||||
v_int16x8 v_tmp0, v_tmp1;
|
||||
v_int16 v_src00, v_src10, v_src01, v_src11, v_src02, v_src12, v_src03, v_src13;
|
||||
v_int16 v_tmp0, v_tmp1;
|
||||
|
||||
v_src00 = v_load((int16_t*)(src[0]) + i);
|
||||
v_src01 = v_load((int16_t*)(src[0]) + i + 8);
|
||||
v_src02 = v_load((int16_t*)(src[0]) + i + 16);
|
||||
v_src03 = v_load((int16_t*)(src[0]) + i + 24);
|
||||
v_src10 = v_load((int16_t*)(src[1]) + i);
|
||||
v_src11 = v_load((int16_t*)(src[1]) + i + 8);
|
||||
v_src12 = v_load((int16_t*)(src[1]) + i + 16);
|
||||
v_src13 = v_load((int16_t*)(src[1]) + i + 24);
|
||||
const int16_t* src0 = (const int16_t*)src[0] + i;
|
||||
const int16_t* src1 = (const int16_t*)src[1] + i;
|
||||
v_src00 = vx_load(src0);
|
||||
v_src01 = vx_load(src0 + VECSZ);
|
||||
v_src02 = vx_load(src0 + 2*VECSZ);
|
||||
v_src03 = vx_load(src0 + 3*VECSZ);
|
||||
v_src10 = vx_load(src1);
|
||||
v_src11 = vx_load(src1 + VECSZ);
|
||||
v_src12 = vx_load(src1 + 2*VECSZ);
|
||||
v_src13 = vx_load(src1 + 3*VECSZ);
|
||||
v_zip(v_add_wrap(v_src00, v_128), v_add_wrap(v_src10, v_128), v_tmp0, v_tmp1);
|
||||
v_int32x4 v_res0 = v_dotprod(v_tmp0, v_mul01);
|
||||
v_int32x4 v_res1 = v_dotprod(v_tmp1, v_mul01);
|
||||
v_int32 v_res0 = v_dotprod(v_tmp0, v_mul01);
|
||||
v_int32 v_res1 = v_dotprod(v_tmp1, v_mul01);
|
||||
v_zip(v_add_wrap(v_src01, v_128), v_add_wrap(v_src11, v_128), v_tmp0, v_tmp1);
|
||||
v_int32x4 v_res2 = v_dotprod(v_tmp0, v_mul01);
|
||||
v_int32x4 v_res3 = v_dotprod(v_tmp1, v_mul01);
|
||||
v_int32 v_res2 = v_dotprod(v_tmp0, v_mul01);
|
||||
v_int32 v_res3 = v_dotprod(v_tmp1, v_mul01);
|
||||
v_zip(v_add_wrap(v_src02, v_128), v_add_wrap(v_src12, v_128), v_tmp0, v_tmp1);
|
||||
v_int32x4 v_res4 = v_dotprod(v_tmp0, v_mul01);
|
||||
v_int32x4 v_res5 = v_dotprod(v_tmp1, v_mul01);
|
||||
v_int32 v_res4 = v_dotprod(v_tmp0, v_mul01);
|
||||
v_int32 v_res5 = v_dotprod(v_tmp1, v_mul01);
|
||||
v_zip(v_add_wrap(v_src03, v_128), v_add_wrap(v_src13, v_128), v_tmp0, v_tmp1);
|
||||
v_int32x4 v_res6 = v_dotprod(v_tmp0, v_mul01);
|
||||
v_int32x4 v_res7 = v_dotprod(v_tmp1, v_mul01);
|
||||
v_int32 v_res6 = v_dotprod(v_tmp0, v_mul01);
|
||||
v_int32 v_res7 = v_dotprod(v_tmp1, v_mul01);
|
||||
|
||||
v_int32x4 v_resj0, v_resj1;
|
||||
v_src00 = v_load((int16_t*)(src[2]) + i);
|
||||
v_src01 = v_load((int16_t*)(src[2]) + i + 8);
|
||||
v_src02 = v_load((int16_t*)(src[2]) + i + 16);
|
||||
v_src03 = v_load((int16_t*)(src[2]) + i + 24);
|
||||
v_int32 v_resj0, v_resj1;
|
||||
const int16_t* src2 = (const int16_t*)src[2] + i;
|
||||
v_src00 = vx_load(src2);
|
||||
v_src01 = vx_load(src2 + VECSZ);
|
||||
v_src02 = vx_load(src2 + 2*VECSZ);
|
||||
v_src03 = vx_load(src2 + 3*VECSZ);
|
||||
v_mul_expand(v_add_wrap(v_src00, v_128), v_mul2, v_resj0, v_resj1);
|
||||
v_res0 += v_resj0;
|
||||
v_res1 += v_resj1;
|
||||
@@ -3139,11 +3071,12 @@ void vlineSmooth3N<uint8_t, ufixedpoint16>(const ufixedpoint16* const * src, con
|
||||
v_res6 += v_128_4;
|
||||
v_res7 += v_128_4;
|
||||
|
||||
v_store(dst + i , v_pack(v_reinterpret_as_u16(v_rshr_pack<16>(v_res0, v_res1)),
|
||||
v_reinterpret_as_u16(v_rshr_pack<16>(v_res2, v_res3))));
|
||||
v_store(dst + i + 16, v_pack(v_reinterpret_as_u16(v_rshr_pack<16>(v_res4, v_res5)),
|
||||
v_reinterpret_as_u16(v_rshr_pack<16>(v_res6, v_res7))));
|
||||
v_store(dst + i , v_pack(v_reinterpret_as_u16(v_rshr_pack<16>(v_res0, v_res1)),
|
||||
v_reinterpret_as_u16(v_rshr_pack<16>(v_res2, v_res3))));
|
||||
v_store(dst + i + 2*VECSZ, v_pack(v_reinterpret_as_u16(v_rshr_pack<16>(v_res4, v_res5)),
|
||||
v_reinterpret_as_u16(v_rshr_pack<16>(v_res6, v_res7))));
|
||||
}
|
||||
#endif
|
||||
for (; i < len; i++)
|
||||
dst[i] = m[0] * src[0][i] + m[1] * src[1][i] + m[2] * src[2][i];
|
||||
}
|
||||
@@ -3157,18 +3090,21 @@ template <>
|
||||
void vlineSmooth3N121<uint8_t, ufixedpoint16>(const ufixedpoint16* const * src, const ufixedpoint16*, int, uint8_t* dst, int len)
|
||||
{
|
||||
int i = 0;
|
||||
for (; i <= len - 16; i += 16)
|
||||
#if CV_SIMD
|
||||
const int VECSZ = v_uint16::nlanes;
|
||||
for (; i <= len - 2*VECSZ; i += 2*VECSZ)
|
||||
{
|
||||
v_uint32x4 v_src00, v_src01, v_src02, v_src03, v_src10, v_src11, v_src12, v_src13, v_src20, v_src21, v_src22, v_src23;
|
||||
v_expand(v_load((uint16_t*)(src[0]) + i), v_src00, v_src01);
|
||||
v_expand(v_load((uint16_t*)(src[0]) + i + 8), v_src02, v_src03);
|
||||
v_expand(v_load((uint16_t*)(src[1]) + i), v_src10, v_src11);
|
||||
v_expand(v_load((uint16_t*)(src[1]) + i + 8), v_src12, v_src13);
|
||||
v_expand(v_load((uint16_t*)(src[2]) + i), v_src20, v_src21);
|
||||
v_expand(v_load((uint16_t*)(src[2]) + i + 8), v_src22, v_src23);
|
||||
v_uint32 v_src00, v_src01, v_src02, v_src03, v_src10, v_src11, v_src12, v_src13, v_src20, v_src21, v_src22, v_src23;
|
||||
v_expand(vx_load((uint16_t*)(src[0]) + i), v_src00, v_src01);
|
||||
v_expand(vx_load((uint16_t*)(src[0]) + i + VECSZ), v_src02, v_src03);
|
||||
v_expand(vx_load((uint16_t*)(src[1]) + i), v_src10, v_src11);
|
||||
v_expand(vx_load((uint16_t*)(src[1]) + i + VECSZ), v_src12, v_src13);
|
||||
v_expand(vx_load((uint16_t*)(src[2]) + i), v_src20, v_src21);
|
||||
v_expand(vx_load((uint16_t*)(src[2]) + i + VECSZ), v_src22, v_src23);
|
||||
v_store(dst + i, v_pack(v_rshr_pack<10>(v_src00 + v_src20 + (v_src10 + v_src10), v_src01 + v_src21 + (v_src11 + v_src11)),
|
||||
v_rshr_pack<10>(v_src02 + v_src22 + (v_src12 + v_src12), v_src03 + v_src23 + (v_src13 + v_src13))));
|
||||
}
|
||||
#endif
|
||||
for (; i < len; i++)
|
||||
dst[i] = (((uint32_t)(((uint16_t*)(src[0]))[i]) + (uint32_t)(((uint16_t*)(src[2]))[i]) + ((uint32_t)(((uint16_t*)(src[1]))[i]) << 1)) + (1 << 9)) >> 10;
|
||||
}
|
||||
@@ -3182,95 +3118,102 @@ template <>
|
||||
void vlineSmooth5N<uint8_t, ufixedpoint16>(const ufixedpoint16* const * src, const ufixedpoint16* m, int, uint8_t* dst, int len)
|
||||
{
|
||||
int i = 0;
|
||||
static const v_int16x8 v_128 = v_reinterpret_as_s16(v_setall_u16((uint16_t)1 << 15));
|
||||
v_int32x4 v_128_4 = v_setall_s32(128 << 16);
|
||||
if (len > 7)
|
||||
#if CV_SIMD
|
||||
const int VECSZ = v_uint16::nlanes;
|
||||
if (len >= 4 * VECSZ)
|
||||
{
|
||||
ufixedpoint32 val[] = { (m[0] + m[1] + m[2] + m[3] + m[4]) * ufixedpoint16((uint8_t)128) };
|
||||
v_128_4 = v_setall_s32(*((int32_t*)val));
|
||||
}
|
||||
v_int16x8 v_mul01 = v_reinterpret_as_s16(v_setall_u32(*((uint32_t*)m)));
|
||||
v_int16x8 v_mul23 = v_reinterpret_as_s16(v_setall_u32(*((uint32_t*)(m + 2))));
|
||||
v_int16x8 v_mul4 = v_reinterpret_as_s16(v_setall_u16(*((uint16_t*)(m + 4))));
|
||||
for (; i <= len - 32; i += 32)
|
||||
{
|
||||
v_int16x8 v_src00, v_src10, v_src01, v_src11, v_src02, v_src12, v_src03, v_src13;
|
||||
v_int16x8 v_tmp0, v_tmp1;
|
||||
|
||||
v_src00 = v_load((int16_t*)(src[0]) + i);
|
||||
v_src01 = v_load((int16_t*)(src[0]) + i + 8);
|
||||
v_src02 = v_load((int16_t*)(src[0]) + i + 16);
|
||||
v_src03 = v_load((int16_t*)(src[0]) + i + 24);
|
||||
v_src10 = v_load((int16_t*)(src[1]) + i);
|
||||
v_src11 = v_load((int16_t*)(src[1]) + i + 8);
|
||||
v_src12 = v_load((int16_t*)(src[1]) + i + 16);
|
||||
v_src13 = v_load((int16_t*)(src[1]) + i + 24);
|
||||
v_zip(v_add_wrap(v_src00, v_128), v_add_wrap(v_src10, v_128), v_tmp0, v_tmp1);
|
||||
v_int32x4 v_res0 = v_dotprod(v_tmp0, v_mul01);
|
||||
v_int32x4 v_res1 = v_dotprod(v_tmp1, v_mul01);
|
||||
v_zip(v_add_wrap(v_src01, v_128), v_add_wrap(v_src11, v_128), v_tmp0, v_tmp1);
|
||||
v_int32x4 v_res2 = v_dotprod(v_tmp0, v_mul01);
|
||||
v_int32x4 v_res3 = v_dotprod(v_tmp1, v_mul01);
|
||||
v_zip(v_add_wrap(v_src02, v_128), v_add_wrap(v_src12, v_128), v_tmp0, v_tmp1);
|
||||
v_int32x4 v_res4 = v_dotprod(v_tmp0, v_mul01);
|
||||
v_int32x4 v_res5 = v_dotprod(v_tmp1, v_mul01);
|
||||
v_zip(v_add_wrap(v_src03, v_128), v_add_wrap(v_src13, v_128), v_tmp0, v_tmp1);
|
||||
v_int32x4 v_res6 = v_dotprod(v_tmp0, v_mul01);
|
||||
v_int32x4 v_res7 = v_dotprod(v_tmp1, v_mul01);
|
||||
|
||||
v_src00 = v_load((int16_t*)(src[2]) + i);
|
||||
v_src01 = v_load((int16_t*)(src[2]) + i + 8);
|
||||
v_src02 = v_load((int16_t*)(src[2]) + i + 16);
|
||||
v_src03 = v_load((int16_t*)(src[2]) + i + 24);
|
||||
v_src10 = v_load((int16_t*)(src[3]) + i);
|
||||
v_src11 = v_load((int16_t*)(src[3]) + i + 8);
|
||||
v_src12 = v_load((int16_t*)(src[3]) + i + 16);
|
||||
v_src13 = v_load((int16_t*)(src[3]) + i + 24);
|
||||
v_zip(v_add_wrap(v_src00, v_128), v_add_wrap(v_src10, v_128), v_tmp0, v_tmp1);
|
||||
v_res0 += v_dotprod(v_tmp0, v_mul23);
|
||||
v_res1 += v_dotprod(v_tmp1, v_mul23);
|
||||
v_zip(v_add_wrap(v_src01, v_128), v_add_wrap(v_src11, v_128), v_tmp0, v_tmp1);
|
||||
v_res2 += v_dotprod(v_tmp0, v_mul23);
|
||||
v_res3 += v_dotprod(v_tmp1, v_mul23);
|
||||
v_zip(v_add_wrap(v_src02, v_128), v_add_wrap(v_src12, v_128), v_tmp0, v_tmp1);
|
||||
v_res4 += v_dotprod(v_tmp0, v_mul23);
|
||||
v_res5 += v_dotprod(v_tmp1, v_mul23);
|
||||
v_zip(v_add_wrap(v_src03, v_128), v_add_wrap(v_src13, v_128), v_tmp0, v_tmp1);
|
||||
v_res6 += v_dotprod(v_tmp0, v_mul23);
|
||||
v_res7 += v_dotprod(v_tmp1, v_mul23);
|
||||
|
||||
v_int32x4 v_resj0, v_resj1;
|
||||
v_src00 = v_load((int16_t*)(src[4]) + i);
|
||||
v_src01 = v_load((int16_t*)(src[4]) + i + 8);
|
||||
v_src02 = v_load((int16_t*)(src[4]) + i + 16);
|
||||
v_src03 = v_load((int16_t*)(src[4]) + i + 24);
|
||||
v_mul_expand(v_add_wrap(v_src00, v_128), v_mul4, v_resj0, v_resj1);
|
||||
v_res0 += v_resj0;
|
||||
v_res1 += v_resj1;
|
||||
v_mul_expand(v_add_wrap(v_src01, v_128), v_mul4, v_resj0, v_resj1);
|
||||
v_res2 += v_resj0;
|
||||
v_res3 += v_resj1;
|
||||
v_mul_expand(v_add_wrap(v_src02, v_128), v_mul4, v_resj0, v_resj1);
|
||||
v_res4 += v_resj0;
|
||||
v_res5 += v_resj1;
|
||||
v_mul_expand(v_add_wrap(v_src03, v_128), v_mul4, v_resj0, v_resj1);
|
||||
v_res6 += v_resj0;
|
||||
v_res7 += v_resj1;
|
||||
|
||||
v_res0 += v_128_4;
|
||||
v_res1 += v_128_4;
|
||||
v_res2 += v_128_4;
|
||||
v_res3 += v_128_4;
|
||||
v_res4 += v_128_4;
|
||||
v_res5 += v_128_4;
|
||||
v_res6 += v_128_4;
|
||||
v_res7 += v_128_4;
|
||||
|
||||
v_store(dst + i , v_pack(v_reinterpret_as_u16(v_rshr_pack<16>(v_res0, v_res1)),
|
||||
v_reinterpret_as_u16(v_rshr_pack<16>(v_res2, v_res3))));
|
||||
v_store(dst + i + 16, v_pack(v_reinterpret_as_u16(v_rshr_pack<16>(v_res4, v_res5)),
|
||||
v_reinterpret_as_u16(v_rshr_pack<16>(v_res6, v_res7))));
|
||||
v_int32 v_128_4 = vx_setall_s32(*((int32_t*)val));
|
||||
static const v_int16 v_128 = v_reinterpret_as_s16(vx_setall_u16((uint16_t)1 << 15));
|
||||
v_int16 v_mul01 = v_reinterpret_as_s16(vx_setall_u32(*((uint32_t*)m)));
|
||||
v_int16 v_mul23 = v_reinterpret_as_s16(vx_setall_u32(*((uint32_t*)(m + 2))));
|
||||
v_int16 v_mul4 = v_reinterpret_as_s16(vx_setall_u16(*((uint16_t*)(m + 4))));
|
||||
for (; i <= len - 4*VECSZ; i += 4*VECSZ)
|
||||
{
|
||||
v_int16 v_src00, v_src10, v_src01, v_src11, v_src02, v_src12, v_src03, v_src13;
|
||||
v_int16 v_tmp0, v_tmp1;
|
||||
|
||||
const int16_t* src0 = (const int16_t*)src[0] + i;
|
||||
const int16_t* src1 = (const int16_t*)src[1] + i;
|
||||
v_src00 = vx_load(src0);
|
||||
v_src01 = vx_load(src0 + VECSZ);
|
||||
v_src02 = vx_load(src0 + 2*VECSZ);
|
||||
v_src03 = vx_load(src0 + 3*VECSZ);
|
||||
v_src10 = vx_load(src1);
|
||||
v_src11 = vx_load(src1 + VECSZ);
|
||||
v_src12 = vx_load(src1 + 2*VECSZ);
|
||||
v_src13 = vx_load(src1 + 3*VECSZ);
|
||||
v_zip(v_add_wrap(v_src00, v_128), v_add_wrap(v_src10, v_128), v_tmp0, v_tmp1);
|
||||
v_int32 v_res0 = v_dotprod(v_tmp0, v_mul01);
|
||||
v_int32 v_res1 = v_dotprod(v_tmp1, v_mul01);
|
||||
v_zip(v_add_wrap(v_src01, v_128), v_add_wrap(v_src11, v_128), v_tmp0, v_tmp1);
|
||||
v_int32 v_res2 = v_dotprod(v_tmp0, v_mul01);
|
||||
v_int32 v_res3 = v_dotprod(v_tmp1, v_mul01);
|
||||
v_zip(v_add_wrap(v_src02, v_128), v_add_wrap(v_src12, v_128), v_tmp0, v_tmp1);
|
||||
v_int32 v_res4 = v_dotprod(v_tmp0, v_mul01);
|
||||
v_int32 v_res5 = v_dotprod(v_tmp1, v_mul01);
|
||||
v_zip(v_add_wrap(v_src03, v_128), v_add_wrap(v_src13, v_128), v_tmp0, v_tmp1);
|
||||
v_int32 v_res6 = v_dotprod(v_tmp0, v_mul01);
|
||||
v_int32 v_res7 = v_dotprod(v_tmp1, v_mul01);
|
||||
|
||||
const int16_t* src2 = (const int16_t*)src[2] + i;
|
||||
const int16_t* src3 = (const int16_t*)src[3] + i;
|
||||
v_src00 = vx_load(src2);
|
||||
v_src01 = vx_load(src2 + VECSZ);
|
||||
v_src02 = vx_load(src2 + 2*VECSZ);
|
||||
v_src03 = vx_load(src2 + 3*VECSZ);
|
||||
v_src10 = vx_load(src3);
|
||||
v_src11 = vx_load(src3 + VECSZ);
|
||||
v_src12 = vx_load(src3 + 2*VECSZ);
|
||||
v_src13 = vx_load(src3 + 3*VECSZ);
|
||||
v_zip(v_add_wrap(v_src00, v_128), v_add_wrap(v_src10, v_128), v_tmp0, v_tmp1);
|
||||
v_res0 += v_dotprod(v_tmp0, v_mul23);
|
||||
v_res1 += v_dotprod(v_tmp1, v_mul23);
|
||||
v_zip(v_add_wrap(v_src01, v_128), v_add_wrap(v_src11, v_128), v_tmp0, v_tmp1);
|
||||
v_res2 += v_dotprod(v_tmp0, v_mul23);
|
||||
v_res3 += v_dotprod(v_tmp1, v_mul23);
|
||||
v_zip(v_add_wrap(v_src02, v_128), v_add_wrap(v_src12, v_128), v_tmp0, v_tmp1);
|
||||
v_res4 += v_dotprod(v_tmp0, v_mul23);
|
||||
v_res5 += v_dotprod(v_tmp1, v_mul23);
|
||||
v_zip(v_add_wrap(v_src03, v_128), v_add_wrap(v_src13, v_128), v_tmp0, v_tmp1);
|
||||
v_res6 += v_dotprod(v_tmp0, v_mul23);
|
||||
v_res7 += v_dotprod(v_tmp1, v_mul23);
|
||||
|
||||
v_int32 v_resj0, v_resj1;
|
||||
const int16_t* src4 = (const int16_t*)src[4] + i;
|
||||
v_src00 = vx_load(src4);
|
||||
v_src01 = vx_load(src4 + VECSZ);
|
||||
v_src02 = vx_load(src4 + 2*VECSZ);
|
||||
v_src03 = vx_load(src4 + 3*VECSZ);
|
||||
v_mul_expand(v_add_wrap(v_src00, v_128), v_mul4, v_resj0, v_resj1);
|
||||
v_res0 += v_resj0;
|
||||
v_res1 += v_resj1;
|
||||
v_mul_expand(v_add_wrap(v_src01, v_128), v_mul4, v_resj0, v_resj1);
|
||||
v_res2 += v_resj0;
|
||||
v_res3 += v_resj1;
|
||||
v_mul_expand(v_add_wrap(v_src02, v_128), v_mul4, v_resj0, v_resj1);
|
||||
v_res4 += v_resj0;
|
||||
v_res5 += v_resj1;
|
||||
v_mul_expand(v_add_wrap(v_src03, v_128), v_mul4, v_resj0, v_resj1);
|
||||
v_res6 += v_resj0;
|
||||
v_res7 += v_resj1;
|
||||
|
||||
v_res0 += v_128_4;
|
||||
v_res1 += v_128_4;
|
||||
v_res2 += v_128_4;
|
||||
v_res3 += v_128_4;
|
||||
v_res4 += v_128_4;
|
||||
v_res5 += v_128_4;
|
||||
v_res6 += v_128_4;
|
||||
v_res7 += v_128_4;
|
||||
|
||||
v_store(dst + i , v_pack(v_reinterpret_as_u16(v_rshr_pack<16>(v_res0, v_res1)),
|
||||
v_reinterpret_as_u16(v_rshr_pack<16>(v_res2, v_res3))));
|
||||
v_store(dst + i + 2*VECSZ, v_pack(v_reinterpret_as_u16(v_rshr_pack<16>(v_res4, v_res5)),
|
||||
v_reinterpret_as_u16(v_rshr_pack<16>(v_res6, v_res7))));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
for (; i < len; i++)
|
||||
dst[i] = m[0] * src[0][i] + m[1] * src[1][i] + m[2] * src[2][i] + m[3] * src[3][i] + m[4] * src[4][i];
|
||||
}
|
||||
@@ -3284,28 +3227,31 @@ template <>
|
||||
void vlineSmooth5N14641<uint8_t, ufixedpoint16>(const ufixedpoint16* const * src, const ufixedpoint16*, int, uint8_t* dst, int len)
|
||||
{
|
||||
int i = 0;
|
||||
v_uint32x4 v_6 = v_setall_u32(6);
|
||||
for (; i <= len - 16; i += 16)
|
||||
#if CV_SIMD
|
||||
v_uint32 v_6 = vx_setall_u32(6);
|
||||
const int VECSZ = v_uint16::nlanes;
|
||||
for (; i <= len - 2*VECSZ; i += 2*VECSZ)
|
||||
{
|
||||
v_uint32x4 v_src00, v_src10, v_src20, v_src30, v_src40;
|
||||
v_uint32x4 v_src01, v_src11, v_src21, v_src31, v_src41;
|
||||
v_uint32x4 v_src02, v_src12, v_src22, v_src32, v_src42;
|
||||
v_uint32x4 v_src03, v_src13, v_src23, v_src33, v_src43;
|
||||
v_expand(v_load((uint16_t*)(src[0]) + i), v_src00, v_src01);
|
||||
v_expand(v_load((uint16_t*)(src[0]) + i + 8), v_src02, v_src03);
|
||||
v_expand(v_load((uint16_t*)(src[1]) + i), v_src10, v_src11);
|
||||
v_expand(v_load((uint16_t*)(src[1]) + i + 8), v_src12, v_src13);
|
||||
v_expand(v_load((uint16_t*)(src[2]) + i), v_src20, v_src21);
|
||||
v_expand(v_load((uint16_t*)(src[2]) + i + 8), v_src22, v_src23);
|
||||
v_expand(v_load((uint16_t*)(src[3]) + i), v_src30, v_src31);
|
||||
v_expand(v_load((uint16_t*)(src[3]) + i + 8), v_src32, v_src33);
|
||||
v_expand(v_load((uint16_t*)(src[4]) + i), v_src40, v_src41);
|
||||
v_expand(v_load((uint16_t*)(src[4]) + i + 8), v_src42, v_src43);
|
||||
v_uint32 v_src00, v_src10, v_src20, v_src30, v_src40;
|
||||
v_uint32 v_src01, v_src11, v_src21, v_src31, v_src41;
|
||||
v_uint32 v_src02, v_src12, v_src22, v_src32, v_src42;
|
||||
v_uint32 v_src03, v_src13, v_src23, v_src33, v_src43;
|
||||
v_expand(vx_load((uint16_t*)(src[0]) + i), v_src00, v_src01);
|
||||
v_expand(vx_load((uint16_t*)(src[0]) + i + VECSZ), v_src02, v_src03);
|
||||
v_expand(vx_load((uint16_t*)(src[1]) + i), v_src10, v_src11);
|
||||
v_expand(vx_load((uint16_t*)(src[1]) + i + VECSZ), v_src12, v_src13);
|
||||
v_expand(vx_load((uint16_t*)(src[2]) + i), v_src20, v_src21);
|
||||
v_expand(vx_load((uint16_t*)(src[2]) + i + VECSZ), v_src22, v_src23);
|
||||
v_expand(vx_load((uint16_t*)(src[3]) + i), v_src30, v_src31);
|
||||
v_expand(vx_load((uint16_t*)(src[3]) + i + VECSZ), v_src32, v_src33);
|
||||
v_expand(vx_load((uint16_t*)(src[4]) + i), v_src40, v_src41);
|
||||
v_expand(vx_load((uint16_t*)(src[4]) + i + VECSZ), v_src42, v_src43);
|
||||
v_store(dst + i, v_pack(v_rshr_pack<12>(v_src20*v_6 + ((v_src10 + v_src30) << 2) + v_src00 + v_src40,
|
||||
v_src21*v_6 + ((v_src11 + v_src31) << 2) + v_src01 + v_src41),
|
||||
v_rshr_pack<12>(v_src22*v_6 + ((v_src12 + v_src32) << 2) + v_src02 + v_src42,
|
||||
v_src23*v_6 + ((v_src13 + v_src33) << 2) + v_src03 + v_src43)));
|
||||
}
|
||||
#endif
|
||||
for (; i < len; i++)
|
||||
dst[i] = ((uint32_t)(((uint16_t*)(src[2]))[i]) * 6 +
|
||||
(((uint32_t)(((uint16_t*)(src[1]))[i]) + (uint32_t)(((uint16_t*)(src[3]))[i])) << 2) +
|
||||
@@ -3326,57 +3272,63 @@ template <>
|
||||
void vlineSmooth<uint8_t, ufixedpoint16>(const ufixedpoint16* const * src, const ufixedpoint16* m, int n, uint8_t* dst, int len)
|
||||
{
|
||||
int i = 0;
|
||||
static const v_int16x8 v_128 = v_reinterpret_as_s16(v_setall_u16((uint16_t)1 << 15));
|
||||
v_int32x4 v_128_4 = v_setall_s32(128 << 16);
|
||||
if (len > 7)
|
||||
#if CV_SIMD
|
||||
static const v_int16 v_128 = v_reinterpret_as_s16(vx_setall_u16((uint16_t)1 << 15));
|
||||
v_int32 v_128_4 = vx_setall_s32(128 << 16);
|
||||
const int VECSZ = v_uint16::nlanes;
|
||||
if (len >= VECSZ)
|
||||
{
|
||||
ufixedpoint16 msum = m[0] + m[1];
|
||||
for (int j = 2; j < n; j++)
|
||||
msum = msum + m[j];
|
||||
ufixedpoint32 val[] = { msum * ufixedpoint16((uint8_t)128) };
|
||||
v_128_4 = v_setall_s32(*((int32_t*)val));
|
||||
v_128_4 = vx_setall_s32(*((int32_t*)val));
|
||||
}
|
||||
for (; i <= len - 32; i += 32)
|
||||
for (; i <= len - 4*VECSZ; i += 4*VECSZ)
|
||||
{
|
||||
v_int16x8 v_src00, v_src10, v_src01, v_src11, v_src02, v_src12, v_src03, v_src13;
|
||||
v_int16x8 v_tmp0, v_tmp1;
|
||||
v_int16 v_src00, v_src10, v_src01, v_src11, v_src02, v_src12, v_src03, v_src13;
|
||||
v_int16 v_tmp0, v_tmp1;
|
||||
|
||||
v_int16x8 v_mul = v_reinterpret_as_s16(v_setall_u32(*((uint32_t*)m)));
|
||||
v_int16 v_mul = v_reinterpret_as_s16(vx_setall_u32(*((uint32_t*)m)));
|
||||
|
||||
v_src00 = v_load((int16_t*)(src[0]) + i);
|
||||
v_src01 = v_load((int16_t*)(src[0]) + i + 8);
|
||||
v_src02 = v_load((int16_t*)(src[0]) + i + 16);
|
||||
v_src03 = v_load((int16_t*)(src[0]) + i + 24);
|
||||
v_src10 = v_load((int16_t*)(src[1]) + i);
|
||||
v_src11 = v_load((int16_t*)(src[1]) + i + 8);
|
||||
v_src12 = v_load((int16_t*)(src[1]) + i + 16);
|
||||
v_src13 = v_load((int16_t*)(src[1]) + i + 24);
|
||||
const int16_t* src0 = (const int16_t*)src[0] + i;
|
||||
const int16_t* src1 = (const int16_t*)src[1] + i;
|
||||
v_src00 = vx_load(src0);
|
||||
v_src01 = vx_load(src0 + VECSZ);
|
||||
v_src02 = vx_load(src0 + 2*VECSZ);
|
||||
v_src03 = vx_load(src0 + 3*VECSZ);
|
||||
v_src10 = vx_load(src1);
|
||||
v_src11 = vx_load(src1 + VECSZ);
|
||||
v_src12 = vx_load(src1 + 2*VECSZ);
|
||||
v_src13 = vx_load(src1 + 3*VECSZ);
|
||||
v_zip(v_add_wrap(v_src00, v_128), v_add_wrap(v_src10, v_128), v_tmp0, v_tmp1);
|
||||
v_int32x4 v_res0 = v_dotprod(v_tmp0, v_mul);
|
||||
v_int32x4 v_res1 = v_dotprod(v_tmp1, v_mul);
|
||||
v_int32 v_res0 = v_dotprod(v_tmp0, v_mul);
|
||||
v_int32 v_res1 = v_dotprod(v_tmp1, v_mul);
|
||||
v_zip(v_add_wrap(v_src01, v_128), v_add_wrap(v_src11, v_128), v_tmp0, v_tmp1);
|
||||
v_int32x4 v_res2 = v_dotprod(v_tmp0, v_mul);
|
||||
v_int32x4 v_res3 = v_dotprod(v_tmp1, v_mul);
|
||||
v_int32 v_res2 = v_dotprod(v_tmp0, v_mul);
|
||||
v_int32 v_res3 = v_dotprod(v_tmp1, v_mul);
|
||||
v_zip(v_add_wrap(v_src02, v_128), v_add_wrap(v_src12, v_128), v_tmp0, v_tmp1);
|
||||
v_int32x4 v_res4 = v_dotprod(v_tmp0, v_mul);
|
||||
v_int32x4 v_res5 = v_dotprod(v_tmp1, v_mul);
|
||||
v_int32 v_res4 = v_dotprod(v_tmp0, v_mul);
|
||||
v_int32 v_res5 = v_dotprod(v_tmp1, v_mul);
|
||||
v_zip(v_add_wrap(v_src03, v_128), v_add_wrap(v_src13, v_128), v_tmp0, v_tmp1);
|
||||
v_int32x4 v_res6 = v_dotprod(v_tmp0, v_mul);
|
||||
v_int32x4 v_res7 = v_dotprod(v_tmp1, v_mul);
|
||||
v_int32 v_res6 = v_dotprod(v_tmp0, v_mul);
|
||||
v_int32 v_res7 = v_dotprod(v_tmp1, v_mul);
|
||||
|
||||
int j = 2;
|
||||
for (; j < n - 1; j+=2)
|
||||
{
|
||||
v_mul = v_reinterpret_as_s16(v_setall_u32(*((uint32_t*)(m+j))));
|
||||
v_mul = v_reinterpret_as_s16(vx_setall_u32(*((uint32_t*)(m+j))));
|
||||
|
||||
v_src00 = v_load((int16_t*)(src[j]) + i);
|
||||
v_src01 = v_load((int16_t*)(src[j]) + i + 8);
|
||||
v_src02 = v_load((int16_t*)(src[j]) + i + 16);
|
||||
v_src03 = v_load((int16_t*)(src[j]) + i + 24);
|
||||
v_src10 = v_load((int16_t*)(src[j+1]) + i);
|
||||
v_src11 = v_load((int16_t*)(src[j+1]) + i + 8);
|
||||
v_src12 = v_load((int16_t*)(src[j+1]) + i + 16);
|
||||
v_src13 = v_load((int16_t*)(src[j+1]) + i + 24);
|
||||
const int16_t* srcj0 = (const int16_t*)src[j] + i;
|
||||
const int16_t* srcj1 = (const int16_t*)src[j + 1] + i;
|
||||
v_src00 = vx_load(srcj0);
|
||||
v_src01 = vx_load(srcj0 + VECSZ);
|
||||
v_src02 = vx_load(srcj0 + 2*VECSZ);
|
||||
v_src03 = vx_load(srcj0 + 3*VECSZ);
|
||||
v_src10 = vx_load(srcj1);
|
||||
v_src11 = vx_load(srcj1 + VECSZ);
|
||||
v_src12 = vx_load(srcj1 + 2*VECSZ);
|
||||
v_src13 = vx_load(srcj1 + 3*VECSZ);
|
||||
v_zip(v_add_wrap(v_src00, v_128), v_add_wrap(v_src10, v_128), v_tmp0, v_tmp1);
|
||||
v_res0 += v_dotprod(v_tmp0, v_mul);
|
||||
v_res1 += v_dotprod(v_tmp1, v_mul);
|
||||
@@ -3392,12 +3344,13 @@ void vlineSmooth<uint8_t, ufixedpoint16>(const ufixedpoint16* const * src, const
|
||||
}
|
||||
if(j < n)
|
||||
{
|
||||
v_int32x4 v_resj0, v_resj1;
|
||||
v_mul = v_reinterpret_as_s16(v_setall_u16(*((uint16_t*)(m + j))));
|
||||
v_src00 = v_load((int16_t*)(src[j]) + i);
|
||||
v_src01 = v_load((int16_t*)(src[j]) + i + 8);
|
||||
v_src02 = v_load((int16_t*)(src[j]) + i + 16);
|
||||
v_src03 = v_load((int16_t*)(src[j]) + i + 24);
|
||||
v_int32 v_resj0, v_resj1;
|
||||
v_mul = v_reinterpret_as_s16(vx_setall_u16(*((uint16_t*)(m + j))));
|
||||
const int16_t* srcj = (const int16_t*)src[j] + i;
|
||||
v_src00 = vx_load(srcj);
|
||||
v_src01 = vx_load(srcj + VECSZ);
|
||||
v_src02 = vx_load(srcj + 2*VECSZ);
|
||||
v_src03 = vx_load(srcj + 3*VECSZ);
|
||||
v_mul_expand(v_add_wrap(v_src00, v_128), v_mul, v_resj0, v_resj1);
|
||||
v_res0 += v_resj0;
|
||||
v_res1 += v_resj1;
|
||||
@@ -3420,11 +3373,12 @@ void vlineSmooth<uint8_t, ufixedpoint16>(const ufixedpoint16* const * src, const
|
||||
v_res6 += v_128_4;
|
||||
v_res7 += v_128_4;
|
||||
|
||||
v_store(dst + i , v_pack(v_reinterpret_as_u16(v_rshr_pack<16>(v_res0, v_res1)),
|
||||
v_reinterpret_as_u16(v_rshr_pack<16>(v_res2, v_res3))));
|
||||
v_store(dst + i + 16, v_pack(v_reinterpret_as_u16(v_rshr_pack<16>(v_res4, v_res5)),
|
||||
v_reinterpret_as_u16(v_rshr_pack<16>(v_res6, v_res7))));
|
||||
v_store(dst + i , v_pack(v_reinterpret_as_u16(v_rshr_pack<16>(v_res0, v_res1)),
|
||||
v_reinterpret_as_u16(v_rshr_pack<16>(v_res2, v_res3))));
|
||||
v_store(dst + i + 2*VECSZ, v_pack(v_reinterpret_as_u16(v_rshr_pack<16>(v_res4, v_res5)),
|
||||
v_reinterpret_as_u16(v_rshr_pack<16>(v_res6, v_res7))));
|
||||
}
|
||||
#endif
|
||||
for (; i < len; i++)
|
||||
{
|
||||
ufixedpoint32 val = m[0] * src[0][i];
|
||||
@@ -3450,29 +3404,32 @@ void vlineSmoothONa_yzy_a(const FT* const * src, const FT* m, int n, ET* dst, in
|
||||
template <>
|
||||
void vlineSmoothONa_yzy_a<uint8_t, ufixedpoint16>(const ufixedpoint16* const * src, const ufixedpoint16* m, int n, uint8_t* dst, int len)
|
||||
{
|
||||
int pre_shift = n / 2;
|
||||
int i = 0;
|
||||
static const v_int16x8 v_128 = v_reinterpret_as_s16(v_setall_u16((uint16_t)1 << 15));
|
||||
v_int32x4 v_128_4 = v_setall_s32(128 << 16);
|
||||
if (len > 7)
|
||||
#if CV_SIMD
|
||||
int pre_shift = n / 2;
|
||||
static const v_int16 v_128 = v_reinterpret_as_s16(vx_setall_u16((uint16_t)1 << 15));
|
||||
v_int32 v_128_4 = vx_setall_s32(128 << 16);
|
||||
const int VECSZ = v_uint16::nlanes;
|
||||
if (len >= VECSZ)
|
||||
{
|
||||
ufixedpoint16 msum = m[0] + m[pre_shift] + m[n - 1];
|
||||
for (int j = 1; j < pre_shift; j++)
|
||||
msum = msum + m[j] + m[n - 1 - j];
|
||||
ufixedpoint32 val[] = { msum * ufixedpoint16((uint8_t)128) };
|
||||
v_128_4 = v_setall_s32(*((int32_t*)val));
|
||||
v_128_4 = vx_setall_s32(*((int32_t*)val));
|
||||
}
|
||||
for (; i <= len - 32; i += 32)
|
||||
for (; i <= len - 4*VECSZ; i += 4*VECSZ)
|
||||
{
|
||||
v_int16x8 v_src00, v_src10, v_src20, v_src30, v_src01, v_src11, v_src21, v_src31;
|
||||
v_int32x4 v_res0, v_res1, v_res2, v_res3, v_res4, v_res5, v_res6, v_res7;
|
||||
v_int16x8 v_tmp0, v_tmp1, v_tmp2, v_tmp3, v_tmp4, v_tmp5, v_tmp6, v_tmp7;
|
||||
v_int16 v_src00, v_src10, v_src20, v_src30, v_src01, v_src11, v_src21, v_src31;
|
||||
v_int32 v_res0, v_res1, v_res2, v_res3, v_res4, v_res5, v_res6, v_res7;
|
||||
v_int16 v_tmp0, v_tmp1, v_tmp2, v_tmp3, v_tmp4, v_tmp5, v_tmp6, v_tmp7;
|
||||
|
||||
v_int16x8 v_mul = v_reinterpret_as_s16(v_setall_u16(*((uint16_t*)(m + pre_shift))));
|
||||
v_src00 = v_load((int16_t*)(src[pre_shift]) + i);
|
||||
v_src10 = v_load((int16_t*)(src[pre_shift]) + i + 8);
|
||||
v_src20 = v_load((int16_t*)(src[pre_shift]) + i + 16);
|
||||
v_src30 = v_load((int16_t*)(src[pre_shift]) + i + 24);
|
||||
v_int16 v_mul = v_reinterpret_as_s16(vx_setall_u16(*((uint16_t*)(m + pre_shift))));
|
||||
const int16_t* srcp = (const int16_t*)src[pre_shift] + i;
|
||||
v_src00 = vx_load(srcp);
|
||||
v_src10 = vx_load(srcp + VECSZ);
|
||||
v_src20 = vx_load(srcp + 2*VECSZ);
|
||||
v_src30 = vx_load(srcp + 3*VECSZ);
|
||||
v_mul_expand(v_add_wrap(v_src00, v_128), v_mul, v_res0, v_res1);
|
||||
v_mul_expand(v_add_wrap(v_src10, v_128), v_mul, v_res2, v_res3);
|
||||
v_mul_expand(v_add_wrap(v_src20, v_128), v_mul, v_res4, v_res5);
|
||||
@@ -3481,16 +3438,18 @@ void vlineSmoothONa_yzy_a<uint8_t, ufixedpoint16>(const ufixedpoint16* const * s
|
||||
int j = 0;
|
||||
for (; j < pre_shift; j++)
|
||||
{
|
||||
v_mul = v_reinterpret_as_s16(v_setall_u16(*((uint16_t*)(m + j))));
|
||||
v_mul = v_reinterpret_as_s16(vx_setall_u16(*((uint16_t*)(m + j))));
|
||||
|
||||
v_src00 = v_load((int16_t*)(src[j]) + i);
|
||||
v_src10 = v_load((int16_t*)(src[j]) + i + 8);
|
||||
v_src20 = v_load((int16_t*)(src[j]) + i + 16);
|
||||
v_src30 = v_load((int16_t*)(src[j]) + i + 24);
|
||||
v_src01 = v_load((int16_t*)(src[n - 1 - j]) + i);
|
||||
v_src11 = v_load((int16_t*)(src[n - 1 - j]) + i + 8);
|
||||
v_src21 = v_load((int16_t*)(src[n - 1 - j]) + i + 16);
|
||||
v_src31 = v_load((int16_t*)(src[n - 1 - j]) + i + 24);
|
||||
const int16_t* srcj0 = (const int16_t*)src[j] + i;
|
||||
const int16_t* srcj1 = (const int16_t*)src[n - 1 - j] + i;
|
||||
v_src00 = vx_load(srcj0);
|
||||
v_src10 = vx_load(srcj0 + VECSZ);
|
||||
v_src20 = vx_load(srcj0 + 2*VECSZ);
|
||||
v_src30 = vx_load(srcj0 + 3*VECSZ);
|
||||
v_src01 = vx_load(srcj1);
|
||||
v_src11 = vx_load(srcj1 + VECSZ);
|
||||
v_src21 = vx_load(srcj1 + 2*VECSZ);
|
||||
v_src31 = vx_load(srcj1 + 3*VECSZ);
|
||||
v_zip(v_add_wrap(v_src00, v_128), v_add_wrap(v_src01, v_128), v_tmp0, v_tmp1);
|
||||
v_res0 += v_dotprod(v_tmp0, v_mul);
|
||||
v_res1 += v_dotprod(v_tmp1, v_mul);
|
||||
@@ -3514,11 +3473,12 @@ void vlineSmoothONa_yzy_a<uint8_t, ufixedpoint16>(const ufixedpoint16* const * s
|
||||
v_res6 += v_128_4;
|
||||
v_res7 += v_128_4;
|
||||
|
||||
v_store(dst + i , v_pack(v_reinterpret_as_u16(v_rshr_pack<16>(v_res0, v_res1)),
|
||||
v_reinterpret_as_u16(v_rshr_pack<16>(v_res2, v_res3))));
|
||||
v_store(dst + i + 16, v_pack(v_reinterpret_as_u16(v_rshr_pack<16>(v_res4, v_res5)),
|
||||
v_reinterpret_as_u16(v_rshr_pack<16>(v_res6, v_res7))));
|
||||
v_store(dst + i , v_pack(v_reinterpret_as_u16(v_rshr_pack<16>(v_res0, v_res1)),
|
||||
v_reinterpret_as_u16(v_rshr_pack<16>(v_res2, v_res3))));
|
||||
v_store(dst + i + 2*VECSZ, v_pack(v_reinterpret_as_u16(v_rshr_pack<16>(v_res4, v_res5)),
|
||||
v_reinterpret_as_u16(v_rshr_pack<16>(v_res6, v_res7))));
|
||||
}
|
||||
#endif
|
||||
for (; i < len; i++)
|
||||
{
|
||||
ufixedpoint32 val = m[0] * src[0][i];
|
||||
@@ -3816,8 +3776,8 @@ static void createGaussianKernels( T & kx, T & ky, int type, Size &ksize,
|
||||
if( ksize.height <= 0 && sigma2 > 0 )
|
||||
ksize.height = cvRound(sigma2*(depth == CV_8U ? 3 : 4)*2 + 1)|1;
|
||||
|
||||
CV_Assert( ksize.width > 0 && ksize.width % 2 == 1 &&
|
||||
ksize.height > 0 && ksize.height % 2 == 1 );
|
||||
CV_Assert( ksize.width > 0 && ksize.width % 2 == 1 &&
|
||||
ksize.height > 0 && ksize.height % 2 == 1 );
|
||||
|
||||
sigma1 = std::max( sigma1, 0. );
|
||||
sigma2 = std::max( sigma2, 0. );
|
||||
@@ -4146,20 +4106,6 @@ void cv::GaussianBlur( InputArray _src, OutputArray _dst, Size ksize,
|
||||
|
||||
int sdepth = CV_MAT_DEPTH(type), cn = CV_MAT_CN(type);
|
||||
|
||||
if(sdepth == CV_8U && ((borderType & BORDER_ISOLATED) || !_src.getMat().isSubmatrix()))
|
||||
{
|
||||
std::vector<ufixedpoint16> fkx, fky;
|
||||
createGaussianKernels(fkx, fky, type, ksize, sigma1, sigma2);
|
||||
Mat src = _src.getMat();
|
||||
Mat dst = _dst.getMat();
|
||||
if (src.data == dst.data)
|
||||
src = src.clone();
|
||||
fixedSmoothInvoker<uint8_t, ufixedpoint16> invoker(src.ptr<uint8_t>(), src.step1(), dst.ptr<uint8_t>(), dst.step1(), dst.cols, dst.rows, dst.channels(), &fkx[0], (int)fkx.size(), &fky[0], (int)fky.size(), borderType & ~BORDER_ISOLATED);
|
||||
parallel_for_(Range(0, dst.rows), invoker, std::max(1, std::min(getNumThreads(), getNumberOfCPUs())));
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Mat kx, ky;
|
||||
createGaussianKernels(kx, ky, type, ksize, sigma1, sigma2);
|
||||
|
||||
@@ -4185,6 +4131,17 @@ void cv::GaussianBlur( InputArray _src, OutputArray _dst, Size ksize,
|
||||
|
||||
CV_IPP_RUN_FAST(ipp_GaussianBlur(src, dst, ksize, sigma1, sigma2, borderType));
|
||||
|
||||
if(sdepth == CV_8U && ((borderType & BORDER_ISOLATED) || !_src.getMat().isSubmatrix()))
|
||||
{
|
||||
std::vector<ufixedpoint16> fkx, fky;
|
||||
createGaussianKernels(fkx, fky, type, ksize, sigma1, sigma2);
|
||||
if (src.data == dst.data)
|
||||
src = src.clone();
|
||||
fixedSmoothInvoker<uint8_t, ufixedpoint16> invoker(src.ptr<uint8_t>(), src.step1(), dst.ptr<uint8_t>(), dst.step1(), dst.cols, dst.rows, dst.channels(), &fkx[0], (int)fkx.size(), &fky[0], (int)fky.size(), borderType & ~BORDER_ISOLATED);
|
||||
parallel_for_(Range(0, dst.rows), invoker, std::max(1, std::min(getNumThreads(), getNumberOfCPUs())));
|
||||
return;
|
||||
}
|
||||
|
||||
sepFilter2D(src, dst, sdepth, kx, ky, Point(-1, -1), 0, borderType);
|
||||
}
|
||||
|
||||
|
||||
@@ -758,6 +758,7 @@ void Subdiv2D::getTriangleList(std::vector<Vec6f>& triangleList) const
|
||||
triangleList.clear();
|
||||
int i, total = (int)(qedges.size()*4);
|
||||
std::vector<bool> edgemask(total, false);
|
||||
Rect2f rect(topLeft.x, topLeft.y, bottomRight.x, bottomRight.y);
|
||||
|
||||
for( i = 4; i < total; i += 2 )
|
||||
{
|
||||
@@ -773,7 +774,8 @@ void Subdiv2D::getTriangleList(std::vector<Vec6f>& triangleList) const
|
||||
edge = getEdge(edge, NEXT_AROUND_LEFT);
|
||||
edgeOrg(edge, &c);
|
||||
edgemask[edge] = true;
|
||||
triangleList.push_back(Vec6f(a.x, a.y, b.x, b.y, c.x, c.y));
|
||||
if( rect.contains(a) && rect.contains(b) && rect.contains(c) )
|
||||
triangleList.push_back(Vec6f(a.x, a.y, b.x, b.y, c.x, c.y));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user