[babl/wip/icc-cluts: 5/5] babl: simplify trc inverter



commit 3a7320408fe881d82e1e1b9502670c3e91d4273e
Author: Øyvind Kolås <pippin gimp org>
Date:   Thu Sep 7 19:14:33 2017 +0200

    babl: simplify trc inverter

 babl/babl-trc.c |    8 +++-----
 1 files changed, 3 insertions(+), 5 deletions(-)
---
diff --git a/babl/babl-trc.c b/babl/babl-trc.c
index f6ea69d..c4a40a2 100644
--- a/babl/babl-trc.c
+++ b/babl/babl-trc.c
@@ -561,20 +561,18 @@ babl_trc_new (const char *name,
     for (j = 0; j < n_lut; j++)
     {
       float k;
-      float best_guess = 1.0;
       float best_diff = 1.0;
-      for (k = 0.0; k <= 1.0; k+=0.0001) /* XXX: a binary search would be faster */
+      for (k = 0.0; k <= 1.0; k+=0.0001)
+         /* XXX: binary search would be faster - but it is only once.. */
       {
          float guess = babl_trc_lut_to_linear (BABL(&trc_db[i]), k);
          float diff = fabs (guess - (j / (n_lut-1.0)));
          if (diff < best_diff)
          {
             best_diff = diff;
-            best_guess = k;
+            trc_db[i].inv_lut[j] = guess;
          }
       }
-
-      trc_db[i].inv_lut[j] = best_guess;
     }
   }
 


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