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

Merge pull request #14916 from terfendail:wsignmask_deprecated

* Avoid using v_signmask universal intrinsic and mark it as deprecated

* Renamed v_find_negative to v_scan_forward
This commit is contained in:
Vitaly Tuzov
2019-07-01 19:53:51 +03:00
committed by Alexander Alekhin
parent 3e4a195b61
commit 9befb7a1d7
13 changed files with 305 additions and 336 deletions
+51 -61
View File
@@ -1139,32 +1139,23 @@ public:
for(; x < numCols; ++x )
{
#if CV_SIMD128
#if CV_SIMD
{
v_uint8x16 v_zero = v_setzero_u8();
v_uint8 v_zero = vx_setzero_u8();
for(; x <= numCols - 32; x += 32) {
v_uint8x16 v_edge1 = v_load(edgeData + x);
v_uint8x16 v_edge2 = v_load(edgeData + x + 16);
for(; x <= numCols - 2*v_uint8::nlanes; x += 2*v_uint8::nlanes) {
v_uint8 v_edge1 = (vx_load(edgeData + x ) != v_zero);
v_uint8 v_edge2 = (vx_load(edgeData + x + v_uint8::nlanes) != v_zero);
v_uint8x16 v_cmp1 = (v_edge1 == v_zero);
v_uint8x16 v_cmp2 = (v_edge2 == v_zero);
unsigned int mask1 = v_signmask(v_cmp1);
unsigned int mask2 = v_signmask(v_cmp2);
mask1 ^= 0x0000ffff;
mask2 ^= 0x0000ffff;
if(mask1)
if(v_check_any(v_edge1))
{
x += trailingZeros32(mask1);
x += v_scan_forward(v_edge1);
goto _next_step;
}
if(mask2)
if(v_check_any(v_edge2))
{
x += trailingZeros32(mask2 << 16);
x += v_uint8::nlanes + v_scan_forward(v_edge2);
goto _next_step;
}
}
@@ -1175,7 +1166,7 @@ public:
if(x == numCols)
continue;
#if CV_SIMD128
#if CV_SIMD
_next_step:
#endif
float vx, vy;
@@ -1506,36 +1497,35 @@ inline int HoughCircleEstimateRadiusInvoker<NZPointList>::filterCircles(const Po
int nzCount = 0;
const Point* nz_ = &nz[0];
int j = 0;
#if CV_SIMD128
#if CV_SIMD
{
const v_float32x4 v_minRadius2 = v_setall_f32(minRadius2);
const v_float32x4 v_maxRadius2 = v_setall_f32(maxRadius2);
const v_float32 v_minRadius2 = vx_setall_f32(minRadius2);
const v_float32 v_maxRadius2 = vx_setall_f32(maxRadius2);
v_float32x4 v_curCenterX = v_setall_f32(curCenter.x);
v_float32x4 v_curCenterY = v_setall_f32(curCenter.y);
v_float32 v_curCenterX = vx_setall_f32(curCenter.x);
v_float32 v_curCenterY = vx_setall_f32(curCenter.y);
float CV_DECL_ALIGNED(16) rbuf[4];
for(; j <= nzSz - 4; j += 4)
float CV_DECL_ALIGNED(CV_SIMD_WIDTH) rbuf[v_float32::nlanes];
int CV_DECL_ALIGNED(CV_SIMD_WIDTH) rmask[v_int32::nlanes];
for(; j <= nzSz - v_float32::nlanes; j += v_float32::nlanes)
{
v_float32x4 v_nzX, v_nzY;
v_float32 v_nzX, v_nzY;
v_load_deinterleave((const float*)&nz_[j], v_nzX, v_nzY); // FIXIT use proper datatype
v_float32x4 v_x = v_cvt_f32(v_reinterpret_as_s32(v_nzX));
v_float32x4 v_y = v_cvt_f32(v_reinterpret_as_s32(v_nzY));
v_float32 v_x = v_cvt_f32(v_reinterpret_as_s32(v_nzX));
v_float32 v_y = v_cvt_f32(v_reinterpret_as_s32(v_nzY));
v_float32x4 v_dx = v_x - v_curCenterX;
v_float32x4 v_dy = v_y - v_curCenterY;
v_float32 v_dx = v_x - v_curCenterX;
v_float32 v_dy = v_y - v_curCenterY;
v_float32x4 v_r2 = (v_dx * v_dx) + (v_dy * v_dy);
v_float32x4 vmask = (v_minRadius2 <= v_r2) & (v_r2 <= v_maxRadius2);
unsigned int mask = v_signmask(vmask);
if (mask)
v_float32 v_r2 = (v_dx * v_dx) + (v_dy * v_dy);
v_float32 vmask = (v_minRadius2 <= v_r2) & (v_r2 <= v_maxRadius2);
if (v_check_any(vmask))
{
v_store_aligned(rmask, v_reinterpret_as_s32(vmask));
v_store_aligned(rbuf, v_r2);
if (mask & 1) ddata[nzCount++] = rbuf[0];
if (mask & 2) ddata[nzCount++] = rbuf[1];
if (mask & 4) ddata[nzCount++] = rbuf[2];
if (mask & 8) ddata[nzCount++] = rbuf[3];
for (int i = 0; i < v_int32::nlanes; ++i)
if (rmask[i]) ddata[nzCount++] = rbuf[i];
}
}
}
@@ -1566,12 +1556,13 @@ inline int HoughCircleEstimateRadiusInvoker<NZPointSet>::filterCircles(const Poi
const Range xOuter = Range(std::max(int(curCenter.x - rOuter), 0), std::min(int(curCenter.x + rOuter), positions.cols));
const Range yOuter = Range(std::max(int(curCenter.y - rOuter), 0), std::min(int(curCenter.y + rOuter), positions.rows));
#if CV_SIMD128
const int numSIMDPoints = 4;
const v_float32x4 v_minRadius2 = v_setall_f32(minRadius2);
const v_float32x4 v_maxRadius2 = v_setall_f32(maxRadius2);
const v_float32x4 v_curCenterX_0123 = v_setall_f32(curCenter.x) - v_float32x4(0.0f, 1.0f, 2.0f, 3.0f);
#if CV_SIMD
float v_seq[v_float32::nlanes];
for (int i = 0; i < v_float32::nlanes; ++i)
v_seq[i] = (float)i;
const v_float32 v_minRadius2 = vx_setall_f32(minRadius2);
const v_float32 v_maxRadius2 = vx_setall_f32(maxRadius2);
const v_float32 v_curCenterX_0123 = vx_setall_f32(curCenter.x) - vx_load(v_seq);
#endif
for (int y = yOuter.start; y < yOuter.end; y++)
@@ -1581,29 +1572,28 @@ inline int HoughCircleEstimateRadiusInvoker<NZPointSet>::filterCircles(const Poi
float dy2 = dy * dy;
int x = xOuter.start;
#if CV_SIMD128
#if CV_SIMD
{
const v_float32x4 v_dy2 = v_setall_f32(dy2);
const v_uint32x4 v_zero_u32 = v_setall_u32(0);
float CV_DECL_ALIGNED(16) rbuf[4];
for (; x <= xOuter.end - 4; x += numSIMDPoints)
const v_float32 v_dy2 = vx_setall_f32(dy2);
const v_uint32 v_zero_u32 = vx_setall_u32(0);
float CV_DECL_ALIGNED(CV_SIMD_WIDTH) rbuf[v_float32::nlanes];
int CV_DECL_ALIGNED(CV_SIMD_WIDTH) rmask[v_int32::nlanes];
for (; x <= xOuter.end - v_float32::nlanes; x += v_float32::nlanes)
{
v_uint32x4 v_mask = v_load_expand_q(ptr + x);
v_uint32 v_mask = vx_load_expand_q(ptr + x);
v_mask = v_mask != v_zero_u32;
v_float32x4 v_x = v_cvt_f32(v_setall_s32(x));
v_float32x4 v_dx = v_x - v_curCenterX_0123;
v_float32 v_x = v_cvt_f32(vx_setall_s32(x));
v_float32 v_dx = v_x - v_curCenterX_0123;
v_float32x4 v_r2 = (v_dx * v_dx) + v_dy2;
v_float32x4 vmask = (v_minRadius2 <= v_r2) & (v_r2 <= v_maxRadius2) & v_reinterpret_as_f32(v_mask);
unsigned int mask = v_signmask(vmask);
if (mask)
v_float32 v_r2 = (v_dx * v_dx) + v_dy2;
v_float32 vmask = (v_minRadius2 <= v_r2) & (v_r2 <= v_maxRadius2) & v_reinterpret_as_f32(v_mask);
if (v_check_any(vmask))
{
v_store_aligned(rmask, v_reinterpret_as_s32(vmask));
v_store_aligned(rbuf, v_r2);
if (mask & 1) ddata[nzCount++] = rbuf[0];
if (mask & 2) ddata[nzCount++] = rbuf[1];
if (mask & 4) ddata[nzCount++] = rbuf[2];
if (mask & 8) ddata[nzCount++] = rbuf[3];
for (int i = 0; i < v_int32::nlanes; ++i)
if (rmask[i]) ddata[nzCount++] = rbuf[i];
}
}
}