Bug 679527 - Use floorf/ceilf in qcms transform function. r=jrmuizel

This commit is contained in:
Benoit Girard 2012-10-19 16:35:36 -04:00
parent f3eedbbb1b
commit 778fa3932c
3 changed files with 38 additions and 38 deletions

View File

@ -138,12 +138,12 @@ static void qcms_transform_module_clut_only(struct qcms_modular_transform *trans
float linear_g = *src++;
float linear_b = *src++;
int x = floor(linear_r * (transform->grid_size-1));
int y = floor(linear_g * (transform->grid_size-1));
int z = floor(linear_b * (transform->grid_size-1));
int x_n = ceil(linear_r * (transform->grid_size-1));
int y_n = ceil(linear_g * (transform->grid_size-1));
int z_n = ceil(linear_b * (transform->grid_size-1));
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));
float x_d = linear_r * (transform->grid_size-1) - x;
float y_d = linear_g * (transform->grid_size-1) - y;
float z_d = linear_b * (transform->grid_size-1) - z;
@ -198,12 +198,12 @@ static void qcms_transform_module_clut(struct qcms_modular_transform *transform,
float linear_b = lut_interp_linear_float(device_b,
transform->input_clut_table_b, transform->input_clut_table_length);
int x = floor(linear_r * (transform->grid_size-1));
int y = floor(linear_g * (transform->grid_size-1));
int z = floor(linear_b * (transform->grid_size-1));
int x_n = ceil(linear_r * (transform->grid_size-1));
int y_n = ceil(linear_g * (transform->grid_size-1));
int z_n = ceil(linear_b * (transform->grid_size-1));
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));
float x_d = linear_r * (transform->grid_size-1) - x;
float y_d = linear_g * (transform->grid_size-1) - y;
float z_d = linear_b * (transform->grid_size-1) - z;
@ -271,12 +271,12 @@ static void qcms_transform_module_tetra_clut(struct qcms_modular_transform *tran
float linear_b = lut_interp_linear_float(device_b,
transform->input_clut_table_b, transform->input_clut_table_length);
int x = floor(linear_r * (transform->grid_size-1));
int y = floor(linear_g * (transform->grid_size-1));
int z = floor(linear_b * (transform->grid_size-1));
int x_n = ceil(linear_r * (transform->grid_size-1));
int y_n = ceil(linear_g * (transform->grid_size-1));
int z_n = ceil(linear_b * (transform->grid_size-1));
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));
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;

View File

@ -435,12 +435,12 @@ static void qcms_transform_data_clut(qcms_transform *transform, unsigned char *s
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 = floor(linear_r * (transform->grid_size-1));
int y = floor(linear_g * (transform->grid_size-1));
int z = floor(linear_b * (transform->grid_size-1));
int x_n = ceil(linear_r * (transform->grid_size-1));
int y_n = ceil(linear_g * (transform->grid_size-1));
int z_n = ceil(linear_b * (transform->grid_size-1));
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));
float x_d = linear_r * (transform->grid_size-1) - x;
float y_d = linear_g * (transform->grid_size-1) - y;
float z_d = linear_b * (transform->grid_size-1) - z;
@ -496,12 +496,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 = floor(linear_r * (transform->grid_size-1));
int y = floor(linear_g * (transform->grid_size-1));
int z = floor(linear_b * (transform->grid_size-1));
int x_n = ceil(linear_r * (transform->grid_size-1));
int y_n = ceil(linear_g * (transform->grid_size-1));
int z_n = ceil(linear_b * (transform->grid_size-1));
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));
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 +611,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 = floor(linear_r * (transform->grid_size-1));
int y = floor(linear_g * (transform->grid_size-1));
int z = floor(linear_b * (transform->grid_size-1));
int x_n = ceil(linear_r * (transform->grid_size-1));
int y_n = ceil(linear_g * (transform->grid_size-1));
int z_n = ceil(linear_b * (transform->grid_size-1));
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));
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;

View File

@ -76,8 +76,8 @@ float lut_interp_linear_float(float value, float *table, int length)
{
int upper, lower;
value = value * (length - 1);
upper = ceil(value);
lower = floor(value);
upper = ceilf(value);
lower = floorf(value);
//XXX: can we be more performant here?
value = table[upper]*(1. - (upper - value)) + table[lower]*(upper - value);
/* scale the value */