Merge pull request #2033 from ilya-lavrenov:tapi_normalize
This commit is contained in:
@@ -41,6 +41,52 @@
|
||||
//
|
||||
//M*/
|
||||
|
||||
#ifdef COPY_TO_MASK
|
||||
|
||||
#define DEFINE_DATA \
|
||||
int src_index = mad24(y, src_step, x*(int)sizeof(T)*scn + src_offset); \
|
||||
int dst_index = mad24(y, dst_step, x*(int)sizeof(T)*scn + dst_offset); \
|
||||
\
|
||||
__global const T * src = (__global const T *)(srcptr + src_index); \
|
||||
__global T * dst = (__global T *)(dstptr + dst_index)
|
||||
|
||||
__kernel void copyToMask(__global const uchar * srcptr, int src_step, int src_offset,
|
||||
__global const uchar * maskptr, int mask_step, int mask_offset,
|
||||
__global uchar * dstptr, int dst_step, int dst_offset,
|
||||
int dst_rows, int dst_cols)
|
||||
{
|
||||
int x = get_global_id(0);
|
||||
int y = get_global_id(1);
|
||||
|
||||
if (x < dst_cols && y < dst_rows)
|
||||
{
|
||||
int mask_index = mad24(y, mask_step, x * mcn + mask_offset);
|
||||
__global const uchar * mask = (__global const uchar *)(maskptr + mask_index);
|
||||
|
||||
#if mcn == 1
|
||||
if (mask[0])
|
||||
{
|
||||
DEFINE_DATA;
|
||||
|
||||
#pragma unroll
|
||||
for (int c = 0; c < scn; ++c)
|
||||
dst[c] = src[c];
|
||||
}
|
||||
#elif scn == mcn
|
||||
DEFINE_DATA;
|
||||
|
||||
#pragma unroll
|
||||
for (int c = 0; c < scn; ++c)
|
||||
if (mask[c])
|
||||
dst[c] = src[c];
|
||||
#else
|
||||
#error "(mcn == 1 || mcn == scn) should be true"
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
__kernel void setMask(__global const uchar* mask, int maskstep, int maskoffset,
|
||||
__global uchar* dstptr, int dststep, int dstoffset,
|
||||
int rows, int cols, dstT value )
|
||||
@@ -71,3 +117,5 @@ __kernel void set(__global uchar* dstptr, int dststep, int dstoffset,
|
||||
*(__global dstT*)(dstptr + dst_index) = value;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user