Commit d3835962 authored by yao's avatar yao

some optimizations to ocl::blend

parent bbe41842
...@@ -72,8 +72,8 @@ void cv::ocl::blendLinear(const oclMat& img1, const oclMat& img2, const oclMat& ...@@ -72,8 +72,8 @@ void cv::ocl::blendLinear(const oclMat& img1, const oclMat& img2, const oclMat&
int depth = img1.depth(); int depth = img1.depth();
int rows = img1.rows; int rows = img1.rows;
int cols = img1.cols; int cols = img1.cols;
int istep = img1.step; int istep = img1.step1();
int wstep = weights1.step; int wstep = weights1.step1();
size_t globalSize[] = {cols * channels, rows, 1}; size_t globalSize[] = {cols * channels, rows, 1};
size_t localSize[] = {16, 16, 1}; size_t localSize[] = {16, 16, 1};
......
...@@ -58,8 +58,8 @@ __kernel void BlendLinear_C1_D0( ...@@ -58,8 +58,8 @@ __kernel void BlendLinear_C1_D0(
int idy = get_global_id(1); int idy = get_global_id(1);
if (idx < cols && idy < rows) if (idx < cols && idy < rows)
{ {
int pos = idy * istep + idx; int pos = mad24(idy,istep,idx);
int wpos = idy * (wstep /sizeof(float)) + idx; int wpos = mad24(idy,wstep,idx);
float w1 = weight1[wpos]; float w1 = weight1[wpos];
float w2 = weight2[wpos]; float w2 = weight2[wpos];
dst[pos] = (img1[pos] * w1 + img2[pos] * w2) / (w1 + w2 + 1e-5f); dst[pos] = (img1[pos] * w1 + img2[pos] * w2) / (w1 + w2 + 1e-5f);
...@@ -85,8 +85,8 @@ __kernel void BlendLinear_C4_D0( ...@@ -85,8 +85,8 @@ __kernel void BlendLinear_C4_D0(
int y = idy; int y = idy;
if (x < cols && y < rows) if (x < cols && y < rows)
{ {
int pos = idy * istep + idx; int pos = mad24(idy,istep,idx);
int wpos = idy * (wstep /sizeof(float)) + x; int wpos = mad24(idy,wstep,x);
float w1 = weight1[wpos]; float w1 = weight1[wpos];
float w2 = weight2[wpos]; float w2 = weight2[wpos];
dst[pos] = (img1[pos] * w1 + img2[pos] * w2) / (w1 + w2 + 1e-5f); dst[pos] = (img1[pos] * w1 + img2[pos] * w2) / (w1 + w2 + 1e-5f);
...@@ -109,8 +109,8 @@ __kernel void BlendLinear_C1_D5( ...@@ -109,8 +109,8 @@ __kernel void BlendLinear_C1_D5(
int idy = get_global_id(1); int idy = get_global_id(1);
if (idx < cols && idy < rows) if (idx < cols && idy < rows)
{ {
int pos = idy * (istep / sizeof(float)) + idx; int pos = mad24(idy,istep,idx);
int wpos = idy * (wstep /sizeof(float)) + idx; int wpos = mad24(idy,wstep,idx);
float w1 = weight1[wpos]; float w1 = weight1[wpos];
float w2 = weight2[wpos]; float w2 = weight2[wpos];
dst[pos] = (img1[pos] * w1 + img2[pos] * w2) / (w1 + w2 + 1e-5f); dst[pos] = (img1[pos] * w1 + img2[pos] * w2) / (w1 + w2 + 1e-5f);
...@@ -135,8 +135,8 @@ __kernel void BlendLinear_C4_D5( ...@@ -135,8 +135,8 @@ __kernel void BlendLinear_C4_D5(
int y = idy; int y = idy;
if (x < cols && y < rows) if (x < cols && y < rows)
{ {
int pos = idy * (istep / sizeof(float)) + idx; int pos = mad24(idy,istep,idx);
int wpos = idy * (wstep /sizeof(float)) + x; int wpos = mad24(idy,wstep,x);
float w1 = weight1[wpos]; float w1 = weight1[wpos];
float w2 = weight2[wpos]; float w2 = weight2[wpos];
dst[pos] = (img1[pos] * w1 + img2[pos] * w2) / (w1 + w2 + 1e-5f); dst[pos] = (img1[pos] * w1 + img2[pos] * w2) / (w1 + w2 + 1e-5f);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment