static inline void _dt_Lab_to_XYZ(const float *const Lab, float *const xyz) { const float d50[] = { 0.9642f, 1.0f, 0.8249f }; const float coef[] = { 1.0f / 500.0f, 1.0f / 116.0f, -1.0f / 200.0f }; const float offset = (0.137931034f); float _F[3]; _F[0] = Lab[1]; _F[1] = Lab[0]; _F[2] = Lab[2]; for(int c = 0; c < 3; c++) { _F[c] *= coef[c]; } float _F1[3]; _F1[0] = _F[1]; _F1[1] = 0.0f; _F1[2] = _F[1]; for(int c = 0; c < 3; c++) { const float f = _F[c] + _F1[c] + offset; xyz[c] = d50[c] * lab_f_inv_m(f); } }
static inline __m128 dt_Lab_to_XYZ_SSE(const __m128 Lab) { const __m128 d50 = _mm_set_ps(0.0f, 0.8249f, 1.0f, 0.9642f); const __m128 coef = _mm_set_ps(0.0f,-1.0f/200.0f,1.0f/116.0f,1.0f/500.0f); const __m128 offset = _mm_set1_ps(0.137931034f); // last component ins shuffle taken from 1st component of Lab to make sure it is not nan, so it will become 0.0f in f const __m128 f = _mm_mul_ps(_mm_shuffle_ps(Lab,Lab,_MM_SHUFFLE(0,2,0,1)),coef); return _mm_mul_ps(d50,lab_f_inv_m(_mm_add_ps(_mm_add_ps(f,_mm_shuffle_ps(f,f,_MM_SHUFFLE(1,1,3,1))),offset))); }