iplab2rgb.cc: speedup for copyAndClamp(), #5964

This commit is contained in:
Ingo Weyrich
2020-10-25 13:46:34 +01:00
parent fd9f3246f0
commit b4f68adb64
3 changed files with 97 additions and 66 deletions

View File

@@ -1015,23 +1015,6 @@ void Color::xyz2r (float x, float y, float z, float &r, const double rgb_xyz[3][
r = ((rgb_xyz[0][0] * x + rgb_xyz[0][1] * y + rgb_xyz[0][2] * z)) ;
}
// same for float
void Color::xyz2rgb (float x, float y, float z, float &r, float &g, float &b, const float rgb_xyz[3][3])
{
r = ((rgb_xyz[0][0] * x + rgb_xyz[0][1] * y + rgb_xyz[0][2] * z)) ;
g = ((rgb_xyz[1][0] * x + rgb_xyz[1][1] * y + rgb_xyz[1][2] * z)) ;
b = ((rgb_xyz[2][0] * x + rgb_xyz[2][1] * y + rgb_xyz[2][2] * z)) ;
}
#ifdef __SSE2__
void Color::xyz2rgb (vfloat x, vfloat y, vfloat z, vfloat &r, vfloat &g, vfloat &b, const vfloat rgb_xyz[3][3])
{
r = ((rgb_xyz[0][0] * x + rgb_xyz[0][1] * y + rgb_xyz[0][2] * z)) ;
g = ((rgb_xyz[1][0] * x + rgb_xyz[1][1] * y + rgb_xyz[1][2] * z)) ;
b = ((rgb_xyz[2][0] * x + rgb_xyz[2][1] * y + rgb_xyz[2][2] * z)) ;
}
#endif // __SSE2__
#ifdef __SSE2__
void Color::trcGammaBW (float &r, float &g, float &b, float gammabwr, float gammabwg, float gammabwb)
{
@@ -1646,19 +1629,6 @@ void Color::gammanf2lut (LUTf &gammacurve, float gamma, float divisor, float fac
#endif
}
void Color::Lab2XYZ(float L, float a, float b, float &x, float &y, float &z)
{
float LL = L / 327.68f;
float aa = a / 327.68f;
float bb = b / 327.68f;
float fy = (c1By116 * LL) + c16By116; // (L+16)/116
float fx = (0.002f * aa) + fy;
float fz = fy - (0.005f * bb);
x = 65535.0f * f2xyz(fx) * D50x;
z = 65535.0f * f2xyz(fz) * D50z;
y = (LL > epskap) ? 65535.0f * fy * fy * fy : 65535.0f * LL / kappa;
}
float Color::L2Y(float L)
{
const float LL = L / 327.68f;
@@ -1676,27 +1646,6 @@ void Color::L2XYZ(float L, float &x, float &y, float &z) // for black & white
y = (LL > epskap) ? 65535.0f * fy * fy * fy : 65535.0f * LL / kappa;
}
#ifdef __SSE2__
void Color::Lab2XYZ(vfloat L, vfloat a, vfloat b, vfloat &x, vfloat &y, vfloat &z)
{
vfloat c327d68 = F2V(327.68f);
L /= c327d68;
a /= c327d68;
b /= c327d68;
vfloat fy = F2V(c1By116) * L + F2V(c16By116);
vfloat fx = F2V(0.002f) * a + fy;
vfloat fz = fy - (F2V(0.005f) * b);
vfloat c65535 = F2V(65535.f);
x = c65535 * f2xyz(fx) * F2V(D50x);
z = c65535 * f2xyz(fz) * F2V(D50z);
vfloat res1 = fy * fy * fy;
vfloat res2 = L / F2V(kappa);
y = vself(vmaskf_gt(L, F2V(epskap)), res1, res2);
y *= c65535;
}
#endif // __SSE2__
inline float Color::computeXYZ2Lab(float f)
{
if (f < 0.f) {