Use 4 pixels for one unit. Some ocl code refactoring
This commit is contained in:
@@ -1547,30 +1547,21 @@ static bool ocl_LUT(InputArray _src, InputArray _lut, OutputArray _dst)
|
||||
int sdepth = _src.depth();
|
||||
|
||||
UMat src = _src.getUMat(), lut = _lut.getUMat();
|
||||
int dtype = CV_MAKETYPE(ddepth, dcn);
|
||||
_dst.create(src.size(), dtype);
|
||||
_dst.create(src.size(), CV_MAKETYPE(ddepth, dcn));
|
||||
UMat dst = _dst.getUMat();
|
||||
|
||||
size_t globalSize[2] = { dst.cols, dst.rows / 2};
|
||||
size_t globalSize[2] = { dst.cols, (dst.rows + 3) / 4};
|
||||
|
||||
cv::String build_opt = format("-D dcn=%d -D lcn=%d -D srcT=%s -D dstT=%s", dcn, lcn,
|
||||
ocl::Kernel k("LUT", ocl::core::lut_oclsrc, format("-D dcn=%d -D lcn=%d -D srcT=%s -D dstT=%s", dcn, lcn,
|
||||
ocl::typeToStr(sdepth), ocl::memopTypeToStr(ddepth)
|
||||
);
|
||||
|
||||
ocl::Kernel kernel;
|
||||
if ((4 == lcn) && (CV_8U == sdepth))
|
||||
kernel.create("LUTC4", ocl::core::lut_oclsrc, build_opt);
|
||||
else if ((3 == lcn) && (CV_8U == sdepth))
|
||||
kernel.create("LUTC3", ocl::core::lut_oclsrc, build_opt);
|
||||
else
|
||||
kernel.create("LUT", ocl::core::lut_oclsrc, build_opt);
|
||||
if (kernel.empty())
|
||||
));
|
||||
if (k.empty())
|
||||
return false;
|
||||
|
||||
kernel.args(ocl::KernelArg::ReadOnlyNoSize(src), ocl::KernelArg::ReadOnlyNoSize(lut),
|
||||
k.args(ocl::KernelArg::ReadOnlyNoSize(src), ocl::KernelArg::ReadOnlyNoSize(lut),
|
||||
ocl::KernelArg::WriteOnly(dst));
|
||||
|
||||
return kernel.run(2, globalSize, NULL, true);
|
||||
return k.run(2, globalSize, NULL, false);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user