Bug 679527 - Prefer floorf over floor in qcms. r=jrmuizel
authorBenoit Girard <b56girard@gmail.com>
Fri, 19 Oct 2012 16:35:24 -0400
changeset 112330 cf7582f6cde94b531148c75c933c4dcf91eebb95
parent 112329 e4aa33c6ae53c602e1dc3df46a690a8b25456f7b
child 112331 017a34f07d4aec06bdd9078643e1f1b2fd3558c2
push id23812
push useremorley@mozilla.com
push dateTue, 06 Nov 2012 14:01:34 +0000
treeherdermozilla-central@f4aeed115e54 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjrmuizel
bugs679527
milestone19.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 679527 - Prefer floorf over floor in qcms. r=jrmuizel
gfx/qcms/iccread.c
gfx/qcms/transform_util.c
gfx/qcms/transform_util.h
--- a/gfx/qcms/iccread.c
+++ b/gfx/qcms/iccread.c
@@ -831,17 +831,17 @@ static struct curveType *curve_from_tabl
 
 static uint16_t float_to_u8Fixed8Number(float a)
 {
 	if (a > (255.f + 255.f/256))
 		return 0xffff;
 	else if (a < 0.f)
 		return 0;
 	else
-		return floor(a*256.f + .5f);
+		return floorf(a*256.f + .5f);
 }
 
 static struct curveType *curve_from_gamma(float gamma)
 {
 	struct curveType *curve;
 	int num_entries = 1;
 	curve = malloc(sizeof(struct curveType) + sizeof(uInt16Number)*num_entries);
 	if (!curve)
--- a/gfx/qcms/transform_util.c
+++ b/gfx/qcms/transform_util.c
@@ -184,56 +184,16 @@ void compute_curve_gamma_table_type_para
 void compute_curve_gamma_table_type0(float gamma_table[256])
 {
 	unsigned int i;
 	for (i = 0; i < 256; i++) {
 		gamma_table[i] = i/255.;
 	}
 }
 
-float clamp_float(float a)
-{
-	/* One would naturally write this function as the following:
-	if (a > 1.)
-		return 1.;
-	else if (a < 0)
-		return 0;
-	else
-		return a;
-
-	However, that version will let NaNs pass through which is undesirable
-	for most consumers.
-	*/
-
-	if (a > 1.)
-		return 1.;
-	else if (a >= 0)
-		return a;
-	else // a < 0 or a is NaN
-		return 0;
-}
-
-unsigned char clamp_u8(float v)
-{
-	if (v > 255.)
-		return 255;
-	else if (v < 0)
-		return 0;
-	else
-		return floor(v+.5);
-}
-
-float u8Fixed8Number_to_float(uint16_t x)
-{
-	// 0x0000 = 0.
-	// 0x0100 = 1.
-	// 0xffff = 255  + 255/256
-	return x/256.;
-}
-
 float *build_input_gamma_table(struct curveType *TRC)
 {
 	float *gamma_table;
 
 	if (!TRC) return NULL;
 	gamma_table = malloc(sizeof(float)*256);
 	if (gamma_table) {
 		if (TRC->type == PARAMETRIC_CURVE_TYPE) {
--- a/gfx/qcms/transform_util.h
+++ b/gfx/qcms/transform_util.h
@@ -36,21 +36,55 @@ float lut_interp_linear_float(float valu
 uint16_t lut_interp_linear16(uint16_t input_value, uint16_t *table, int length);
 
 
 static inline float lerp(float a, float b, float t)
 {
         return a*(1.f-t) + b*t;
 }
 
-unsigned char clamp_u8(float v);
-float clamp_float(float a);
+static inline unsigned char clamp_u8(float v)
+{
+  if (v > 255.)
+    return 255;
+  else if (v < 0)
+    return 0;
+  else
+    return floorf(v+.5);
+}
+
+static inline float clamp_float(float a)
+{
+  /* One would naturally write this function as the following:
+  if (a > 1.)
+    return 1.;
+  else if (a < 0)
+    return 0;
+  else
+    return a;
 
-float u8Fixed8Number_to_float(uint16_t x);
+  However, that version will let NaNs pass through which is undesirable
+  for most consumers.
+  */
 
+  if (a > 1.)
+    return 1.;
+  else if (a >= 0)
+    return a;
+  else // a < 0 or a is NaN
+    return 0;
+}
+
+static inline float u8Fixed8Number_to_float(uint16_t x)
+{
+  // 0x0000 = 0.
+  // 0x0100 = 1.
+  // 0xffff = 255  + 255/256
+  return x/256.;
+}
 
 float *build_input_gamma_table(struct curveType *TRC);
 struct matrix build_colorant_matrix(qcms_profile *p);
 void build_output_lut(struct curveType *trc,
                       uint16_t **output_gamma_lut, size_t *output_gamma_lut_length);
 
 struct matrix matrix_invert(struct matrix mat);
 qcms_bool compute_precache(struct curveType *trc, uint8_t *output);