Skip to content

Commit

Permalink
cvtColor - optimized index calculations; usage of build-in functions
Browse files Browse the repository at this point in the history
  • Loading branch information
ilya-lavrenov committed Jun 22, 2014
1 parent 6952b90 commit 007593c
Show file tree
Hide file tree
Showing 3 changed files with 524 additions and 392 deletions.
18 changes: 5 additions & 13 deletions modules/imgproc/src/color.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2730,32 +2730,24 @@ struct mRGBA2RGBA

#ifdef HAVE_OPENCL

#define DIVUP(total, grain) (((total) + (grain) - 1) / (grain))

static bool ocl_cvtColor( InputArray _src, OutputArray _dst, int code, int dcn )
{
bool ok = false;
UMat src = _src.getUMat(), dst;
Size sz = src.size(), dstSz = sz;
int scn = src.channels(), depth = src.depth(), bidx;
int dims = 2, stripeSize = 1;
size_t globalsize[] = { src.cols, src.rows };
ocl::Kernel k;

if (depth != CV_8U && depth != CV_16U && depth != CV_32F)
return false;

cv::String opts = format("-D depth=%d -D scn=%d ", depth, scn);

ocl::Device dev = ocl::Device::getDefault();
int pxPerWIy = 1;
if (dev.isIntel() && (dev.type() & ocl::Device::TYPE_GPU) &&
!(code == CV_BGR2Luv || code == CV_RGB2Luv || code == CV_LBGR2Luv || code == CV_LRGB2Luv ||
code == CV_Luv2BGR || code == CV_Luv2RGB || code == CV_Luv2LBGR || code == CV_Luv2LRGB))
pxPerWIy = 4;

globalsize[1] = DIVUP(globalsize[1], pxPerWIy);
opts += format("-D PIX_PER_WI_Y=%d ", pxPerWIy);
int pxPerWIy = dev.isIntel() && (dev.type() & ocl::Device::TYPE_GPU) ? 4 : 1;

size_t globalsize[] = { src.cols, (src.rows + pxPerWIy - 1) / pxPerWIy };
cv::String opts = format("-D depth=%d -D scn=%d -D PIX_PER_WI_Y=%d ",
depth, scn, pxPerWIy);

switch (code)
{
Expand Down
Loading

0 comments on commit 007593c

Please sign in to comment.