Merge pull request #4210 from wangyan42164:ocl_umat_convert
This commit is contained in:
commit
c94945f892
@ -53,7 +53,10 @@
|
|||||||
|
|
||||||
__kernel void convertTo(__global const uchar * srcptr, int src_step, int src_offset,
|
__kernel void convertTo(__global const uchar * srcptr, int src_step, int src_offset,
|
||||||
__global uchar * dstptr, int dst_step, int dst_offset, int dst_rows, int dst_cols,
|
__global uchar * dstptr, int dst_step, int dst_offset, int dst_rows, int dst_cols,
|
||||||
WT alpha, WT beta, int rowsPerWI)
|
#ifndef NO_SCALE
|
||||||
|
WT alpha, WT beta,
|
||||||
|
#endif
|
||||||
|
int rowsPerWI)
|
||||||
{
|
{
|
||||||
int x = get_global_id(0);
|
int x = get_global_id(0);
|
||||||
int y0 = get_global_id(1) * rowsPerWI;
|
int y0 = get_global_id(1) * rowsPerWI;
|
||||||
@ -68,7 +71,11 @@ __kernel void convertTo(__global const uchar * srcptr, int src_step, int src_off
|
|||||||
__global const srcT * src = (__global const srcT *)(srcptr + src_index);
|
__global const srcT * src = (__global const srcT *)(srcptr + src_index);
|
||||||
__global dstT * dst = (__global dstT *)(dstptr + dst_index);
|
__global dstT * dst = (__global dstT *)(dstptr + dst_index);
|
||||||
|
|
||||||
|
#ifdef NO_SCALE
|
||||||
|
dst[0] = convertToDT(src[0]);
|
||||||
|
#else
|
||||||
dst[0] = convertToDT(fma(convertToWT(src[0]), alpha, beta));
|
dst[0] = convertToDT(fma(convertToWT(src[0]), alpha, beta));
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -746,7 +746,7 @@ void UMat::convertTo(OutputArray _dst, int _type, double alpha, double beta) con
|
|||||||
ocl::typeToStr(sdepth), ocl::typeToStr(wdepth), ocl::typeToStr(ddepth),
|
ocl::typeToStr(sdepth), ocl::typeToStr(wdepth), ocl::typeToStr(ddepth),
|
||||||
ocl::convertTypeStr(sdepth, wdepth, 1, cvt[0]),
|
ocl::convertTypeStr(sdepth, wdepth, 1, cvt[0]),
|
||||||
ocl::convertTypeStr(wdepth, ddepth, 1, cvt[1]),
|
ocl::convertTypeStr(wdepth, ddepth, 1, cvt[1]),
|
||||||
doubleSupport ? " -D DOUBLE_SUPPORT" : ""));
|
doubleSupport ? " -D DOUBLE_SUPPORT" : "", noScale ? " -D NO_SCALE" : ""));
|
||||||
if (!k.empty())
|
if (!k.empty())
|
||||||
{
|
{
|
||||||
UMat src = *this;
|
UMat src = *this;
|
||||||
@ -757,7 +757,9 @@ void UMat::convertTo(OutputArray _dst, int _type, double alpha, double beta) con
|
|||||||
ocl::KernelArg srcarg = ocl::KernelArg::ReadOnlyNoSize(src),
|
ocl::KernelArg srcarg = ocl::KernelArg::ReadOnlyNoSize(src),
|
||||||
dstarg = ocl::KernelArg::WriteOnly(dst, cn);
|
dstarg = ocl::KernelArg::WriteOnly(dst, cn);
|
||||||
|
|
||||||
if (wdepth == CV_32F)
|
if (noScale)
|
||||||
|
k.args(srcarg, dstarg, rowsPerWI);
|
||||||
|
else if (wdepth == CV_32F)
|
||||||
k.args(srcarg, dstarg, alphaf, betaf, rowsPerWI);
|
k.args(srcarg, dstarg, alphaf, betaf, rowsPerWI);
|
||||||
else
|
else
|
||||||
k.args(srcarg, dstarg, alpha, beta, rowsPerWI);
|
k.args(srcarg, dstarg, alpha, beta, rowsPerWI);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user