Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
O
opencv
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
opencv
Commits
643c906f
Commit
643c906f
authored
Oct 28, 2014
by
Alexander Karsakov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added optimized loading to YUV2RGB_422 kernel
parent
1466621f
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
4 deletions
+16
-4
color.cpp
modules/imgproc/src/color.cpp
+2
-1
cvtcolor.cl
modules/imgproc/src/opencl/cvtcolor.cl
+14
-3
No files found.
modules/imgproc/src/color.cpp
View file @
643c906f
...
@@ -5060,7 +5060,8 @@ static bool ocl_cvtColor( InputArray _src, OutputArray _dst, int code, int dcn )
...
@@ -5060,7 +5060,8 @@ static bool ocl_cvtColor( InputArray _src, OutputArray _dst, int code, int dcn )
CV_Assert
(
scn
==
2
&&
depth
==
CV_8U
);
CV_Assert
(
scn
==
2
&&
depth
==
CV_8U
);
k
.
create
(
"YUV2RGB_422"
,
ocl
::
imgproc
::
cvtcolor_oclsrc
,
k
.
create
(
"YUV2RGB_422"
,
ocl
::
imgproc
::
cvtcolor_oclsrc
,
opts
+
format
(
"-D dcn=%d -D bidx=%d -D uidx=%d -D yidx=%d"
,
dcn
,
bidx
,
uidx
,
yidx
));
opts
+
format
(
"-D dcn=%d -D bidx=%d -D uidx=%d -D yidx=%d%s"
,
dcn
,
bidx
,
uidx
,
yidx
,
src
.
offset
%
4
==
0
&&
src
.
step
%
4
==
0
?
" -D USE_OPTIMIZED_LOAD"
:
""
));
break
;
break
;
}
}
case
COLOR_BGR2YCrCb
:
case
COLOR_BGR2YCrCb
:
...
...
modules/imgproc/src/opencl/cvtcolor.cl
View file @
643c906f
...
@@ -573,22 +573,33 @@ __kernel void YUV2RGB_422(__global const uchar* srcptr, int src_step, int src_of
...
@@ -573,22 +573,33 @@ __kernel void YUV2RGB_422(__global const uchar* srcptr, int src_step, int src_of
{
{
if (y < rows )
if (y < rows )
{
{
__constant float* coeffs = c_YUV2RGBCoeffs_420;
#ifndef USE_OPTIMIZED_LOAD
float U = ((float) src[uidx]) - HALF_MAX;
float U = ((float) src[uidx]) - HALF_MAX;
float V = ((float) src[(2 + uidx) % 4]) - HALF_MAX;
float V = ((float) src[(2 + uidx) % 4]) - HALF_MAX;
float y00 = max(0.f, ((float) src[yidx]) - 16.f) * coeffs[0];
float y01 = max(0.f, ((float) src[yidx + 2]) - 16.f) * coeffs[0];
#else
int load_src = *((__global int*) src);
float vec_src[4] = { load_src & 0xff, (load_src >> 8) & 0xff, (load_src >> 16) & 0xff, (load_src >> 24) & 0xff};
float U = vec_src[uidx] - HALF_MAX;
float V = vec_src[(2 + uidx) % 4] - HALF_MAX;
float y00 = max(0.f, vec_src[yidx] - 16.f) * coeffs[0];
float y01 = max(0.f, vec_src[yidx + 2] - 16.f) * coeffs[0];
#endif
__constant float* coeffs = c_YUV2RGBCoeffs_420;
float ruv = fma(coeffs[4], V, 0.5f);
float ruv = fma(coeffs[4], V, 0.5f);
float guv = fma(coeffs[3], V, fma(coeffs[2], U, 0.5f));
float guv = fma(coeffs[3], V, fma(coeffs[2], U, 0.5f));
float buv = fma(coeffs[1], U, 0.5f);
float buv = fma(coeffs[1], U, 0.5f);
float y00 = max(0.f, ((float) src[yidx]) - 16.f) * coeffs[0];
dst[2 - bidx] = convert_uchar_sat(y00 + ruv);
dst[2 - bidx] = convert_uchar_sat(y00 + ruv);
dst[1] = convert_uchar_sat(y00 + guv);
dst[1] = convert_uchar_sat(y00 + guv);
dst[bidx] = convert_uchar_sat(y00 + buv);
dst[bidx] = convert_uchar_sat(y00 + buv);
#if dcn == 4
#if dcn == 4
dst[3] = 255;
dst[3] = 255;
#endif
#endif
float y01 = max(0.f, ((float) src[yidx + 2]) - 16.f) * coeffs[0];
dst[dcn + 2 - bidx] = convert_uchar_sat(y01 + ruv);
dst[dcn + 2 - bidx] = convert_uchar_sat(y01 + ruv);
dst[dcn + 1] = convert_uchar_sat(y01 + guv);
dst[dcn + 1] = convert_uchar_sat(y01 + guv);
dst[dcn + bidx] = convert_uchar_sat(y01 + buv);
dst[dcn + bidx] = convert_uchar_sat(y01 + buv);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment