[babl] extension/fast-float: gain some speed by ignoring a couple high mantissa bits



commit 0fe05d1e85dda5e2f13cf8c206ff32b9976779e5
Author: Øyvind Kolås <pippin gimp org>
Date:   Sat Nov 19 13:29:36 2016 +0100

    extension/fast-float: gain some speed by ignoring a couple high mantissa bits

 extensions/fast-float.c |   11 ++++++-----
 1 files changed, 6 insertions(+), 5 deletions(-)
---
diff --git a/extensions/fast-float.c b/extensions/fast-float.c
index 392bcb5..bafdcc0 100644
--- a/extensions/fast-float.c
+++ b/extensions/fast-float.c
@@ -28,7 +28,7 @@
 
 #define INLINE inline
 
-#define  LSHIFT 2
+#define  LSHIFT 4
 
 typedef  float (* BablLookupFunction) (float  value,
                                        void  *data);
@@ -92,7 +92,7 @@ babl_lookup (BablLookup *lookup,
   }
 
   {
-    uint32_t bm =u.i & 0b11000000000000000000000000000000;
+    uint32_t bm =u.i & 0b11110000000000000000000000000000;
     ua.i |= bm;
     ub.i |= bm;
   }
@@ -158,6 +158,8 @@ babl_lookup_new (BablLookupFunction function,
   else if (precision <= 0.000649) shift = 15;
   else shift = 16; /* a bit better than 8bit sRGB quality */
 
+  shift = 16;
+
   /* Adjust slightly away from 0.0, saving many entries close to 0, this
    * causes lookups very close to zero to be passed directly to the
    * function instead.
@@ -264,7 +266,6 @@ linear_to_gamma_2_2_lut (float val)
   return babl_lookup (fast_pow, val);
 }
 
-
 static BablLookup *fast_rpow = NULL;
 
 static inline float core_rlookup (float val, void *userdata)
@@ -600,8 +601,8 @@ init (void)
     float a;
 
     /* tweaking the precision - does impact speed.. */
-    fast_pow = babl_lookup_new (core_lookup, NULL, 0.0, 1.0,   0.00033);
-    fast_rpow = babl_lookup_new (core_rlookup, NULL, 0.0, 1.0, 0.00033);
+    fast_pow = babl_lookup_new (core_lookup, NULL, 0.0, 1.0,   0.0033);
+    fast_rpow = babl_lookup_new (core_rlookup, NULL, 0.0, 1.0, 0.0033);
 
     for (f = 0.0; f < 1.0; f+= 0.0000001)
       {


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]