ESCALE(R * coeffs[3] + G * coeffs[4] + B * coeffs[5], xyz_shift);
const int4 zi = CV_DESCALE(R * coeffs[6] + G * coeffs[7] + B * coeffs[8], xyz_shift);
const VECTOR4 X = SAT_CAST4(xi);
const VECTOR4 Y = SAT_CAST4(yi);
const VECTOR4 Z = SAT_CAST4(zi);
vstore16((VECTOR16)(X.s0, Y.s0, Z.s0, 0, X.s1, Y.s1, Z.s1, 0, X.s2, Y.s2, Z.s2, 0, X.s3, Y.s3, Z.s3, 0), 0, dst_ptr);
#endif
}
#endif
}
}
__kernel void XYZ2RGB(int cols, int rows, int src_step, int dst_step,
__global const DATA_TYPE* src, __global DATA_TYPE* dst,
int src_offset, int dst_offset, __constant COEFF_TYPE * coeffs)
{
int dx = get_global_id(0) * pixels_per_work_item;
int dy = get_global_id(1);
if (dy < rows && dx < cols)
{
dx <<= 2;
int src_idx = mad24(dy, src_step, src_offset + dx);
int dst_idx = mad24(dy, dst_step, dst_offset + dx);
global DATA_TYPE *src_ptr = (global DATA_TYPE *)(src + src_idx);
global DATA_TYPE *dst_ptr = (global DATA_TYPE *)(dst + dst_idx);
#if (1 == pixels_per_work_item)
{
const DATA_TYPE X = src_ptr[0], Y = src_ptr[1], Z = src_ptr[2];
#ifdef DEPTH_5
float B = X * coeffs[0] + Y * coeffs[1] + Z * coeffs[2];
float G = X * coeffs[3] + Y * coeffs[4] + Z * coeffs[5];
float R = X * coeffs[6] + Y * coeffs[7] + Z * coeffs[8];
#else
int B = CV_DESCALE(X * coeffs[0] + Y * coeffs[1] + Z * coeffs[2], xyz_shift);
int G = CV_DESCALE(X * coeffs[3] + Y * coeffs[4] + Z * coeffs[5], xyz_shift);
int R = CV_DESCALE(X * coeffs[6] + Y * coeffs[7] + Z * coeffs[8], xyz_shift);
#endif
dst_ptr[0] = SAT_CAST( B );
dst_ptr[1] = SAT_CAST( G );
dst_ptr[2] = SAT_CAST( R );
#if dcn == 4
dst_ptr[3] = MAX_NUM;
#endif
}
#elif (2 == pixels_per_work_item)
{
const VECTOR8 r0 = vload8(0, src_ptr);
#ifdef DEPTH_5
const float2 X = r0.s04;
const float2 Y = r0.s15;
const float2 Z = r0.s26;
float2 B = X * coeffs[0] + Y * coeffs[1] + Z * coeffs[2];
float2 G = X * coeffs[3] + Y * coeffs[4] + Z * coeffs[5];
float2 R = X * coeffs[6] + Y * coeffs[7] + Z * coeffs[8];
#else
const int2 xi = convert_int2(r0.s04);
const int2 yi = convert_int2(r0.s15);
const int2 zi = convert_int2(r0.s26);
const int2 bi = CV_DESCALE(xi * coeffs[0] + yi * coeffs[1] + zi * coeffs[2], xyz_shift);
const int2 gi = CV_DESCALE(xi * coeffs[3] + yi * coeffs[4] + zi * coeffs[5], xyz_shift);
const int2 ri = CV_DESCALE(xi * coeffs[6] + yi * coeffs[7] + zi * coeffs[8], xyz_shift);
const VECTOR2 R = SAT_CAST2(ri);
const VECTOR2 G = SAT_CAST2(gi);
const VECTOR2 B = SAT_CAST2(bi);
#endif
#if dcn == 4
vstore8((VECTOR8)(B.s0, G.s0, R.s0, MAX_NUM, B.s1, G.s1, R.s1, MAX_NUM), 0, dst_ptr);
#else
vstore8((VECTOR8)(B.s0, G.s0, R.s0, 0, B.s1, G.s1, R.s1, 0), 0, dst_ptr);
#endif
}
#elif (4 == pixels_per_work_item)
{
#ifndef DEPTH_5
const VECTOR16 r0 = vload16(0, src_ptr);
const int4 xi = convert_int4(r0.s048c);
const int4 yi = convert_int4(r0.s159d);
const int4 zi = convert_int4(r0.s26ae);
const int4 bi = CV_DESCALE(xi * coeffs[0] + yi * coeffs[1] + zi * coeffs[2], xyz_shift);
const int4 gi = CV_DESCALE(xi * coeffs[3] + yi * coeffs[4] + zi * coeffs[5], xyz_shift);
const int4 ri = CV_DESCALE(xi * coeffs[6] + yi * coeffs[7] + zi * coeffs[8], xyz_shift);
const VECTOR4 R = SAT_CAST4(ri);
const VECTOR4 G = SAT_CAST4(gi);
const VECTOR4 B = SAT_CAST4(bi);
#if dcn == 4
vstore16((VECTOR16)(B.s0, G.s0, R.s0, MAX_NUM, B.s1, G.s1, R.s1, MAX_NUM, B.s2, G.s2, R.s2, MAX_NUM, B.s3, G.s3, R.s3, MAX_NUM), 0, dst_ptr);
#else
vstore16((VECTOR16)(B.s0, G.s0, R.s0, 0, B.s1, G.s1, R.s1, 0, B.s2, G.s2, R.s2, 0, B.s3, G.s3, R.s3, 0), 0, dst_ptr);
#endif
#endif
}
#endif
}
}
__kernel void RGB(int cols, int rows, int src_step, int dst_step,
__global const DATA_TY