Bug 679527 - Avoid float operation in qcms transforms. r=jrmuizel

This commit is contained in:
Benoit Girard 2012-10-19 18:23:07 -04:00
parent 2f0a721520
commit 7fe23ff866

View File

@ -476,6 +476,10 @@ static void qcms_transform_data_clut(qcms_transform *transform, unsigned char *s
}
*/
static int int_div_ceil(int value, int div) {
return ((value + div - 1) / div);
}
// Using lcms' tetra interpolation algorithm.
static void qcms_transform_data_tetra_clut_rgba(qcms_transform *transform, unsigned char *src, unsigned char *dest, size_t length) {
unsigned int i;
@ -496,12 +500,12 @@ static void qcms_transform_data_tetra_clut_rgba(qcms_transform *transform, unsig
unsigned char in_a = *src++;
float linear_r = in_r/255.0f, linear_g=in_g/255.0f, linear_b = in_b/255.0f;
int x = floorf(linear_r * (transform->grid_size-1));
int y = floorf(linear_g * (transform->grid_size-1));
int z = floorf(linear_b * (transform->grid_size-1));
int x_n = ceilf(linear_r * (transform->grid_size-1));
int y_n = ceilf(linear_g * (transform->grid_size-1));
int z_n = ceilf(linear_b * (transform->grid_size-1));
int x = in_r * (transform->grid_size-1) / 255;
int y = in_g * (transform->grid_size-1) / 255;
int z = in_b * (transform->grid_size-1) / 255;
int x_n = int_div_ceil(in_r * (transform->grid_size-1), 255);
int y_n = int_div_ceil(in_g * (transform->grid_size-1), 255);
int z_n = int_div_ceil(in_b * (transform->grid_size-1), 255);
float rx = linear_r * (transform->grid_size-1) - x;
float ry = linear_g * (transform->grid_size-1) - y;
float rz = linear_b * (transform->grid_size-1) - z;
@ -611,12 +615,12 @@ static void qcms_transform_data_tetra_clut(qcms_transform *transform, unsigned c
unsigned char in_b = *src++;
float linear_r = in_r/255.0f, linear_g=in_g/255.0f, linear_b = in_b/255.0f;
int x = floorf(linear_r * (transform->grid_size-1));
int y = floorf(linear_g * (transform->grid_size-1));
int z = floorf(linear_b * (transform->grid_size-1));
int x_n = ceilf(linear_r * (transform->grid_size-1));
int y_n = ceilf(linear_g * (transform->grid_size-1));
int z_n = ceilf(linear_b * (transform->grid_size-1));
int x = in_r * (transform->grid_size-1) / 255;
int y = in_g * (transform->grid_size-1) / 255;
int z = in_b * (transform->grid_size-1) / 255;
int x_n = int_div_ceil(in_r * (transform->grid_size-1), 255);
int y_n = int_div_ceil(in_g * (transform->grid_size-1), 255);
int z_n = int_div_ceil(in_b * (transform->grid_size-1), 255);
float rx = linear_r * (transform->grid_size-1) - x;
float ry = linear_g * (transform->grid_size-1) - y;
float rz = linear_b * (transform->grid_size-1) - z;