[babl] babl-fish-path: add some specific conversion targeted debug info



commit 66464407749980087f978fae814675aaf653c20c
Author: Øyvind Kolås <pippin gimp org>
Date:   Wed Nov 16 20:34:05 2016 +0100

    babl-fish-path: add some specific conversion targeted debug info

 babl/babl-cache.c     |    3 +++
 babl/babl-fish-path.c |   21 ++++++++++++++++-----
 babl/babl-util.c      |    2 +-
 tools/Makefile.am     |    3 ++-
 4 files changed, 22 insertions(+), 7 deletions(-)
---
diff --git a/babl/babl-cache.c b/babl/babl-cache.c
index 7f06997..4a26db0 100644
--- a/babl/babl-cache.c
+++ b/babl/babl-cache.c
@@ -193,6 +193,9 @@ void babl_init_db (void)
   return;
 #endif
 
+  if (getenv ("BABL_DEBUG_CONVERSIONS"))
+    return;
+
   babl_file_get_contents (path, &contents, &length, NULL);
   if (!contents)
     return;
diff --git a/babl/babl-fish-path.c b/babl/babl-fish-path.c
index 25d3bd1..acad60e 100644
--- a/babl/babl-fish-path.c
+++ b/babl/babl-fish-path.c
@@ -97,6 +97,7 @@ _babl_fish_create_name (char       *buf,
 
 static int max_path_length (void);
 
+static int debug_conversions = 0;
 
 double _babl_legal_error (void)
 {
@@ -111,6 +112,13 @@ double _babl_legal_error (void)
     error = babl_parse_double (env);
   else
     error = BABL_LEGAL_ERROR;
+
+  env = getenv ("BABL_DEBUG_CONVERSIONS");
+  if (env && env[0] != '\0')
+    debug_conversions = 1;
+  else
+    debug_conversions = 0;
+
   return error;
 }
 
@@ -137,7 +145,6 @@ static int max_path_length (void)
   return max_length;
 }
 
-
 /* The task of BablFishPath construction is to compute
  * the shortest path in a graph where formats are the vertices
  * and conversions are the edges. However, there is an additional
@@ -189,6 +196,13 @@ get_conversion_path (PathContext *pc,
           fpi.destination = pc->to_format;
 
           get_path_instrumentation (&fpi, pc->current_path, &path_cost, &ref_cost, &path_error);
+          if(debug_conversions && current_length == 1)
+            fprintf (stderr, "%s  error:%f cost:%f  \n", 
+                 babl_get_name (pc->current_path->items[0]),
+                 /*babl_get_name (pc->fish_path->fish.source),
+                 babl_get_name (pc->fish_path->fish.destination),*/
+                 path_error,
+                 path_cost /*, current_length*/);
 
           if ((path_cost < ref_cost) && /* do not use paths that took longer to compute than reference */
               (path_cost < pc->fish_path->fish_path.cost) &&
@@ -213,7 +227,6 @@ get_conversion_path (PathContext *pc,
       BablList *list;
       int i;
 
-
       list = current_format->format.from_list;
       if (list)
         {
@@ -375,7 +388,6 @@ babl_fish_path_process (Babl       *babl,
                                   destination,
                                   dest_bpp,
                                   n);
-
 }
 
 static long
@@ -421,7 +433,6 @@ babl_fish_process (Babl       *babl,
         ret = -1;
         break;
     }
-
   return ret;
 }
 
@@ -681,7 +692,7 @@ get_path_instrumentation (FishPathInstrumentation *fpi,
 
   *path_error = babl_rel_avg_error (fpi->destination_rgba_double,
                                     fpi->ref_destination_rgba_double,
-                                    fpi->num_test_pixels * 4);
+                                     fpi->num_test_pixels * 4);
 
 #if 0
   fpi->fish_rgba_to_source->fish.processings--;
diff --git a/babl/babl-util.c b/babl/babl-util.c
index f68a684..b9dd1e4 100644
--- a/babl/babl-util.c
+++ b/babl/babl-util.c
@@ -84,7 +84,7 @@ long
 babl_process_cost (long ticks_start,
                    long ticks_end)
 {
-  return (ticks_end - ticks_start) * 10 + 1;
+  return (ticks_end - ticks_start);
 }
 
 double
diff --git a/tools/Makefile.am b/tools/Makefile.am
index ad54455..1d50751 100644
--- a/tools/Makefile.am
+++ b/tools/Makefile.am
@@ -3,7 +3,8 @@ AM_CPPFLAGS = -I$(top_srcdir) -I$(top_srcdir)/babl
 LDADD = $(top_builddir)/babl/libbabl-@BABL_API_VERSION@.la \
        $(MATH_LIB) $(THREAD_LIB)
 
+noinst_PROGRAMS = babl-verify
 if HAVE_SRANDOM
-noinst_PROGRAMS =              \
+noinst_PROGRAMS +=             \
        babl-gen-test-pixels
 endif


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