Commit 33ae6420 authored by Ilya Lavrenov's avatar Ilya Lavrenov

color.cpp refactoring: created generic interface for toRGB and fromRGB callers

parent a57030a0
This diff is collapsed.
...@@ -100,7 +100,7 @@ __kernel void RGB2Gray(int cols, int rows, int src_step, int dst_step, ...@@ -100,7 +100,7 @@ __kernel void RGB2Gray(int cols, int rows, int src_step, int dst_step,
} }
} }
__kernel void Gray2RGB(int cols, int rows, int src_step, int dst_step, int channels, __kernel void Gray2RGB(int cols, int rows, int src_step, int dst_step, int channels, int bidx,
__global const DATA_TYPE* src, __global DATA_TYPE* dst, __global const DATA_TYPE* src, __global DATA_TYPE* dst,
int src_offset, int dst_offset) int src_offset, int dst_offset)
{ {
...@@ -203,17 +203,17 @@ __constant int ITUR_BT_601_CVG = 852492; ...@@ -203,17 +203,17 @@ __constant int ITUR_BT_601_CVG = 852492;
__constant int ITUR_BT_601_CVR = 1673527; __constant int ITUR_BT_601_CVR = 1673527;
__constant int ITUR_BT_601_SHIFT = 20; __constant int ITUR_BT_601_SHIFT = 20;
__kernel void YUV2RGBA_NV12(int cols,int rows,int src_step,int dst_step, __kernel void YUV2RGBA_NV12(int cols, int rows, int src_step, int dst_step, int channels,
int bidx, int width, int height, __global const uchar* src, __global uchar* dst, int bidx, __global const uchar* src, __global uchar* dst,
int src_offset, int dst_offset) int src_offset, int dst_offset)
{ {
const int x = get_global_id(0); // max_x = width / 2 const int x = get_global_id(0);
const int y = get_global_id(1); // max_y = height/ 2 const int y = get_global_id(1);
if (y < height / 2 && x < width / 2 ) if (y < rows / 2 && x < cols / 2 )
{ {
__global const uchar* ysrc = src + mad24(y << 1, src_step, (x << 1) + src_offset); __global const uchar* ysrc = src + mad24(y << 1, src_step, (x << 1) + src_offset);
__global const uchar* usrc = src + mad24(height + y, src_step, (x << 1) + src_offset); __global const uchar* usrc = src + mad24(rows + y, src_step, (x << 1) + src_offset);
__global uchar* dst1 = dst + mad24(y << 1, dst_step, (x << 3) + dst_offset); __global uchar* dst1 = dst + mad24(y << 1, dst_step, (x << 3) + dst_offset);
__global uchar* dst2 = dst + mad24((y << 1) + 1, dst_step, (x << 3) + dst_offset); __global uchar* dst2 = dst + mad24((y << 1) + 1, dst_step, (x << 3) + dst_offset);
......
...@@ -116,6 +116,8 @@ PARAM_TEST_CASE(CvtColor, MatDepth, bool) ...@@ -116,6 +116,8 @@ PARAM_TEST_CASE(CvtColor, MatDepth, bool)
#define CVTCODE(name) cv::COLOR_ ## name #define CVTCODE(name) cv::COLOR_ ## name
// RGB <-> Gray
OCL_TEST_P(CvtColor, RGB2GRAY) OCL_TEST_P(CvtColor, RGB2GRAY)
{ {
doTest(3, 1, CVTCODE(RGB2GRAY)); doTest(3, 1, CVTCODE(RGB2GRAY));
...@@ -152,6 +154,7 @@ OCL_TEST_P(CvtColor, GRAY2BGRA) ...@@ -152,6 +154,7 @@ OCL_TEST_P(CvtColor, GRAY2BGRA)
doTest(1, 4, CVTCODE(GRAY2BGRA)); doTest(1, 4, CVTCODE(GRAY2BGRA));
} }
// RGB <-> YUV
OCL_TEST_P(CvtColor, RGB2YUV) OCL_TEST_P(CvtColor, RGB2YUV)
{ {
...@@ -186,6 +189,7 @@ OCL_TEST_P(CvtColor, YUV2BGRA) ...@@ -186,6 +189,7 @@ OCL_TEST_P(CvtColor, YUV2BGRA)
doTest(3, 4, CVTCODE(YUV2BGR)); doTest(3, 4, CVTCODE(YUV2BGR));
} }
// RGB <-> YCrCb
OCL_TEST_P(CvtColor, RGB2YCrCb) OCL_TEST_P(CvtColor, RGB2YCrCb)
{ {
...@@ -220,6 +224,8 @@ OCL_TEST_P(CvtColor, YCrCb2BGRA) ...@@ -220,6 +224,8 @@ OCL_TEST_P(CvtColor, YCrCb2BGRA)
doTest(3, 4, CVTCODE(YCrCb2BGR)); doTest(3, 4, CVTCODE(YCrCb2BGR));
} }
// YUV -> RGBA_NV12
struct CvtColor_YUV420 : struct CvtColor_YUV420 :
public CvtColor public CvtColor
{ {
...@@ -262,7 +268,6 @@ OCL_TEST_P(CvtColor_YUV420, YUV2BGR_NV12) ...@@ -262,7 +268,6 @@ OCL_TEST_P(CvtColor_YUV420, YUV2BGR_NV12)
doTest(1, 3, CV_YUV2BGR_NV12); doTest(1, 3, CV_YUV2BGR_NV12);
} }
INSTANTIATE_TEST_CASE_P(OCL_ImgProc, CvtColor, INSTANTIATE_TEST_CASE_P(OCL_ImgProc, CvtColor,
testing::Combine( testing::Combine(
testing::Values(MatDepth(CV_8U), MatDepth(CV_16U), MatDepth(CV_32F)), testing::Values(MatDepth(CV_8U), MatDepth(CV_16U), MatDepth(CV_32F)),
......
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