Fix Luv2RGB function
This commit is contained in:
parent
05164bf713
commit
b724208510
@ -2038,6 +2038,10 @@ struct Luv2RGB_f
|
||||
float G = X*C3 + Y*C4 + Z*C5;
|
||||
float B = X*C6 + Y*C7 + Z*C8;
|
||||
|
||||
R = std::min(std::max(R, 0.f), 1.f);
|
||||
G = std::min(std::max(G, 0.f), 1.f);
|
||||
B = std::min(std::max(B, 0.f), 1.f);
|
||||
|
||||
if( gammaTab )
|
||||
{
|
||||
R = splineInterpolate(R*gscale, gammaTab, GAMMA_TAB_SIZE);
|
||||
|
@ -441,18 +441,18 @@ __kernel void YCrCb2RGB(__global const uchar* src, int src_step, int src_offset,
|
||||
__global DATA_TYPE * dstptr = (__global DATA_TYPE*)(dst + dst_index);
|
||||
|
||||
DATA_TYPE_4 src_pix = vload4(0, srcptr);
|
||||
DATA_TYPE y = src_pix.x, cr = src_pix.y, cb = src_pix.z;
|
||||
DATA_TYPE yp = src_pix.x, cr = src_pix.y, cb = src_pix.z;
|
||||
|
||||
#ifdef DEPTH_5
|
||||
__constant float * coeff = c_YCrCb2RGBCoeffs_f;
|
||||
float r = fma(coeff[0], cr - HALF_MAX, y);
|
||||
float g = fma(coeff[1], cr - HALF_MAX, fma(coeff[2], cb - HALF_MAX, y));
|
||||
float b = fma(coeff[3], cb - HALF_MAX, y);
|
||||
float r = fma(coeff[0], cr - HALF_MAX, yp);
|
||||
float g = fma(coeff[1], cr - HALF_MAX, fma(coeff[2], cb - HALF_MAX, yp));
|
||||
float b = fma(coeff[3], cb - HALF_MAX, yp);
|
||||
#else
|
||||
__constant int * coeff = c_YCrCb2RGBCoeffs_i;
|
||||
int r = y + CV_DESCALE(coeff[0] * (cr - HALF_MAX), yuv_shift);
|
||||
int g = y + CV_DESCALE(mad24(coeff[1], cr - HALF_MAX, coeff[2] * (cb - HALF_MAX)), yuv_shift);
|
||||
int b = y + CV_DESCALE(coeff[3] * (cb - HALF_MAX), yuv_shift);
|
||||
int r = yp + CV_DESCALE(coeff[0] * (cr - HALF_MAX), yuv_shift);
|
||||
int g = yp + CV_DESCALE(mad24(coeff[1], cr - HALF_MAX, coeff[2] * (cb - HALF_MAX)), yuv_shift);
|
||||
int b = yp + CV_DESCALE(coeff[3] * (cb - HALF_MAX), yuv_shift);
|
||||
#endif
|
||||
|
||||
dstptr[(bidx^2)] = SAT_CAST(r);
|
||||
@ -1796,6 +1796,10 @@ __kernel void Luv2BGR(__global const uchar * srcptr, int src_step, int src_offse
|
||||
float G = fma(X, coeffs[3], fma(Y, coeffs[4], Z * coeffs[5]));
|
||||
float B = fma(X, coeffs[6], fma(Y, coeffs[7], Z * coeffs[8]));
|
||||
|
||||
R = min(max(R, 0.f), 1.f);
|
||||
G = min(max(G, 0.f), 1.f);
|
||||
B = min(max(B, 0.f), 1.f);
|
||||
|
||||
#ifdef SRGB
|
||||
R = splineInterpolate(R*GammaTabScale, gammaTab, GAMMA_TAB_SIZE);
|
||||
G = splineInterpolate(G*GammaTabScale, gammaTab, GAMMA_TAB_SIZE);
|
||||
@ -1853,6 +1857,10 @@ __kernel void Luv2BGR(__global const uchar * src, int src_step, int src_offset,
|
||||
float G = fma(X, coeffs[3], fma(Y, coeffs[4], Z * coeffs[5]));
|
||||
float B = fma(X, coeffs[6], fma(Y, coeffs[7], Z * coeffs[8]));
|
||||
|
||||
R = min(max(R, 0.f), 1.f);
|
||||
G = min(max(G, 0.f), 1.f);
|
||||
B = min(max(B, 0.f), 1.f);
|
||||
|
||||
#ifdef SRGB
|
||||
R = splineInterpolate(R*GammaTabScale, gammaTab, GAMMA_TAB_SIZE);
|
||||
G = splineInterpolate(G*GammaTabScale, gammaTab, GAMMA_TAB_SIZE);
|
||||
|
Loading…
x
Reference in New Issue
Block a user