[babl] babl: factor out some branches from path fish dispatch



commit 1fe98f9b59affc49ae56b887238f8f3648001987
Author: Øyvind Kolås <pippin gimp org>
Date:   Sun Jan 14 19:19:30 2018 +0100

    babl: factor out some branches from path fish dispatch

 babl/babl-fish-path.c |   66 ++++++++++++++++++++++++++-----------------------
 babl/babl-fish.h      |   10 ++++---
 2 files changed, 41 insertions(+), 35 deletions(-)
---
diff --git a/babl/babl-fish-path.c b/babl/babl-fish-path.c
index d08db0e..7f2771f 100644
--- a/babl/babl-fish-path.c
+++ b/babl/babl-fish-path.c
@@ -424,6 +424,37 @@ alias_conversion (Babl *babl,
   return 0;
 }
 
+static void
+babl_fish_prepare_bpp (Babl *babl)
+{
+   const Babl *babl_source = babl->fish.source;
+   const Babl *babl_dest = babl->fish.destination;
+
+   switch (babl_source->instance.class_type)
+     {
+       case BABL_FORMAT:
+         babl->fish_path.source_bpp = babl_source->format.bytes_per_pixel;
+         break;
+       case BABL_TYPE:
+         babl->fish_path.source_bpp = babl_source->type.bits / 8;
+         break;
+       default:
+         babl_log ("=eeek{%i}\n", babl_source->instance.class_type - BABL_MAGIC);
+     }
+
+   switch (babl_dest->instance.class_type)
+     {
+       case BABL_FORMAT:
+         babl->fish_path.dest_bpp = babl_dest->format.bytes_per_pixel;
+         break;
+       case BABL_TYPE:
+         babl->fish_path.dest_bpp = babl_dest->type.bits / 8;
+         break;
+       default:
+         babl_log ("-eeek{%i}\n", babl_dest->instance.class_type - BABL_MAGIC);
+     }
+}
+
 
 static Babl *
 babl_fish_path2 (const Babl *source,
@@ -573,6 +604,7 @@ babl_fish_path2 (const Babl *source,
     babl_db_insert (babl_fish_db (), babl);
   }
   babl_mutex_unlock (babl_format_mutex);
+  babl_fish_prepare_bpp (babl);
   return babl;
 }
 
@@ -607,46 +639,18 @@ babl_fish_path (const Babl *source,
   return babl_fish_path2 (source, destination, 0.0);
 }
 
+
 static inline void
 babl_fish_path_process (const Babl *babl,
                         const void *source,
                         void       *destination,
                         long        n)
 {
-   const Babl *babl_source = babl->fish.source;
-   const Babl *babl_dest = babl->fish.destination;
-   int source_bpp = 0;
-   int dest_bpp = 0;
-
-   switch (babl_source->instance.class_type)
-     {
-       case BABL_FORMAT:
-         source_bpp = babl_source->format.bytes_per_pixel;
-         break;
-       case BABL_TYPE:
-         source_bpp = babl_source->type.bits / 8;
-         break;
-       default:
-         babl_log ("=eeek{%i}\n", babl_source->instance.class_type - BABL_MAGIC);
-     }
-
-   switch (babl_dest->instance.class_type)
-     {
-       case BABL_FORMAT:
-         dest_bpp = babl_dest->format.bytes_per_pixel;
-         break;
-       case BABL_TYPE:
-         dest_bpp = babl_dest->type.bits / 8;
-         break;
-       default:
-         babl_log ("-eeek{%i}\n", babl_dest->instance.class_type - BABL_MAGIC);
-     }
-
   process_conversion_path (babl->fish_path.conversion_list,
                            source,
-                           source_bpp,
+                           babl->fish_path.source_bpp,
                            destination,
-                           dest_bpp,
+                           babl->fish_path.dest_bpp,
                            n);
 }
 
diff --git a/babl/babl-fish.h b/babl/babl-fish.h
index 54d670a..954536a 100644
--- a/babl/babl-fish.h
+++ b/babl/babl-fish.h
@@ -31,7 +31,7 @@ typedef struct
   BablInstance    instance;
   const Babl     *source;
   const Babl     *destination;
-
+  void           (*dispatch) (const Babl *babl, const char *src, char *dst, long n);
   double          error;    /* the amount of noise introduced by the fish */
 
   /* instrumentation */
@@ -64,9 +64,11 @@ typedef struct
  */
 typedef struct
 {
-  BablFish         fish;
-  double           cost;   /* number of  ticks *10 + chain_length */
-  BablList         *conversion_list;
+  BablFish   fish;
+  double     cost;   /* number of  ticks *10 + chain_length */
+  int        source_bpp;
+  int        dest_bpp;
+  BablList  *conversion_list;
 } BablFishPath;
 
 /* BablFishReference


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