[babl] babl: shuffle some dispatch functions to be inlineable



commit 7459b107621cbc339c41b3cf8b0cb9bf323e4d6e
Author: Øyvind Kolås <pippin gimp org>
Date:   Sun Jan 7 05:37:39 2018 +0100

    babl: shuffle some dispatch functions to be inlineable

 babl/babl-conversion.c |  133 ---------------------------------------------
 babl/babl-conversion.h |    3 +
 babl/babl-internal.h   |  139 ++++++++++++++++++++++++++++++++++++++++++++++--
 3 files changed, 138 insertions(+), 137 deletions(-)
---
diff --git a/babl/babl-conversion.c b/babl/babl-conversion.c
index b9df9af..97955e2 100644
--- a/babl/babl-conversion.c
+++ b/babl/babl-conversion.c
@@ -309,139 +309,6 @@ babl_conversion_new (const void *first_arg,
   return babl;
 }
 
-static void
-babl_conversion_linear_process (BablConversion *conversion,
-                                const void     *source,
-                                void           *destination,
-                                long            n)
-{
-  conversion->function.linear ((void*)conversion, source, destination, n, conversion->data);
-}
-
-static void
-babl_conversion_plane_process (BablConversion *conversion,
-                               const void     *source,
-                               void           *destination,
-                               int             src_pitch,
-                               int             dst_pitch,
-                               long            n)
-{
-  conversion->function.plane ((void*)conversion, source, destination,
-                              src_pitch, dst_pitch,
-                              n,
-                              conversion->data);
-}
-
-static void
-babl_conversion_planar_process (BablConversion *conversion,
-                                BablImage      *source,
-                                BablImage      *destination,
-                                long            n)
-{
-#ifdef USE_ALLOCA
-  const char **src_data = alloca (sizeof (void *) * source->components);
-  char **dst_data = alloca (sizeof (void *) * destination->components);
-#else
-  const char  *src_data[BABL_MAX_COMPONENTS];
-  char  *dst_data[BABL_MAX_COMPONENTS];
-#endif
-
-  memcpy (src_data, source->data, sizeof (void *) * source->components);
-  memcpy (dst_data, destination->data, sizeof (void *) * destination->components);
-  conversion->function.planar ((void*)conversion,
-                                      source->components,
-                                      src_data,
-                                      source->pitch,
-                                      destination->components,
-                                      dst_data,
-                                      destination->pitch,
-                                      n,
-                                      conversion->data);
-}
-
-void
-babl_conversion_process (const Babl *babl,
-                         const char *source,
-                         char       *destination,
-                         long        n)
-{
-  BablConversion *conversion = (BablConversion *) babl;
-
-  babl_assert (BABL_IS_BABL (conversion));
-
-  switch (BABL (conversion)->class_type)
-    {
-      case BABL_CONVERSION_PLANE:
-      {
-        const void *src_data  = NULL;
-        void *dst_data  = NULL;
-        int   src_pitch = 0;
-        int   dst_pitch = 0;
-
-        if (BABL_IS_BABL (source))
-          {
-            BablImage *img;
-
-            img       = (BablImage *) source;
-            src_data  = img->data[0];
-            src_pitch = img->pitch[0];
-          }
-        if (BABL_IS_BABL (destination))
-          {
-            BablImage *img = (BablImage *) destination;
-
-            dst_data  = img->data[0];
-            dst_pitch = img->pitch[0];
-          }
-
-        if (!src_data)
-          src_data = source;
-        if (!src_pitch)
-          src_pitch = BABL (conversion->source)->type.bits / 8;
-        if (!dst_data)
-          dst_data = destination;
-        if (!dst_pitch)
-          dst_pitch = BABL (conversion->destination)->type.bits / 8;
-
-        babl_conversion_plane_process (conversion,
-                                       src_data, dst_data,
-                                       src_pitch, dst_pitch,
-                                       n);
-      }
-        break;
-
-      case BABL_CONVERSION_PLANAR:
-        babl_assert (BABL_IS_BABL (source));
-        babl_assert (BABL_IS_BABL (destination));
-
-        babl_conversion_planar_process (conversion,
-                                        (BablImage *) source,
-                                        (BablImage *) destination,
-                                        n);
-        break;
-
-      case BABL_CONVERSION_LINEAR:
-        /* the assertions relied on a babl_malloc structure
-         *
-         * babl_assert (!BABL_IS_BABL (source));
-           babl_assert (!BABL_IS_BABL (destination));*/
-
-        babl_conversion_linear_process (conversion,
-                                        source,
-                                        destination,
-                                        n);
-        break;
-
-      default:
-        babl_log ("args=(%s, %p, %p, %li) unhandled conversion type: %s",
-                  conversion->instance.name, source, destination, n,
-                  babl_class_name (conversion->instance.class_type));
-        break;
-    }
-
-  conversion->processings++;
-  conversion->pixels += n;
-}
 
 long
 babl_conversion_cost (BablConversion *conversion)
diff --git a/babl/babl-conversion.h b/babl/babl-conversion.h
index 1f8f8ab..d3fb09a 100644
--- a/babl/babl-conversion.h
+++ b/babl/babl-conversion.h
@@ -55,4 +55,7 @@ _BablConversion {
   long                   pixels;
 };
 
+
+
+
 #endif
diff --git a/babl/babl-internal.h b/babl/babl-internal.h
index f7d001f..3c08ff2 100644
--- a/babl/babl-internal.h
+++ b/babl/babl-internal.h
@@ -66,10 +66,6 @@ Babl *   babl_conversion_find           (const void     *source,
                                          const void     *destination);
 double   babl_conversion_error          (BablConversion *conversion);
 long     babl_conversion_cost           (BablConversion *conversion);
-void     babl_conversion_process        (const Babl     *conversion,
-                                         const char     *source,
-                                         char           *destination,
-                                         long            n);
 
 Babl   * babl_extension_base            (void);
 
@@ -486,4 +482,139 @@ void babl_space_to_xyz   (const Babl *space, const double *rgb, double *xyz);
  */
 void babl_space_from_xyz (const Babl *space, const double *xyz, double *rgb);
 
+static inline void
+babl_conversion_linear_process (BablConversion *conversion,
+                                const void     *source,
+                                void           *destination,
+                                long            n)
+{
+  conversion->function.linear ((void*)conversion, source, destination, n, conversion->data);
+}
+
+static inline void
+babl_conversion_plane_process (BablConversion *conversion,
+                               const void     *source,
+                               void           *destination,
+                               int             src_pitch,
+                               int             dst_pitch,
+                               long            n)
+{
+  conversion->function.plane ((void*)conversion, source, destination,
+                              src_pitch, dst_pitch,
+                              n,
+                              conversion->data);
+}
+
+static inline void
+babl_conversion_planar_process (BablConversion *conversion,
+                                BablImage      *source,
+                                BablImage      *destination,
+                                long            n)
+{
+#ifdef USE_ALLOCA
+  const char **src_data = alloca (sizeof (void *) * source->components);
+  char **dst_data = alloca (sizeof (void *) * destination->components);
+#else
+  const char  *src_data[BABL_MAX_COMPONENTS];
+  char  *dst_data[BABL_MAX_COMPONENTS];
+#endif
+
+  memcpy (src_data, source->data, sizeof (void *) * source->components);
+  memcpy (dst_data, destination->data, sizeof (void *) * destination->components);
+  conversion->function.planar ((void*)conversion,
+                                      source->components,
+                                      src_data,
+                                      source->pitch,
+                                      destination->components,
+                                      dst_data,
+                                      destination->pitch,
+                                      n,
+                                      conversion->data);
+}
+
+
+static inline void
+babl_conversion_process (const Babl *babl,
+                         const char *source,
+                         char       *destination,
+                         long        n)
+{
+  BablConversion *conversion = (BablConversion *) babl;
+
+  // babl_assert (BABL_IS_BABL (conversion));
+
+  switch (BABL (conversion)->class_type)
+    {
+      case BABL_CONVERSION_PLANE:
+      {
+        const void *src_data  = NULL;
+        void *dst_data  = NULL;
+        int   src_pitch = 0;
+        int   dst_pitch = 0;
+
+        if (BABL_IS_BABL (source))
+          {
+            BablImage *img;
+
+            img       = (BablImage *) source;
+            src_data  = img->data[0];
+            src_pitch = img->pitch[0];
+          }
+        if (BABL_IS_BABL (destination))
+          {
+            BablImage *img = (BablImage *) destination;
+
+            dst_data  = img->data[0];
+            dst_pitch = img->pitch[0];
+          }
+
+        if (!src_data)
+          src_data = source;
+        if (!src_pitch)
+          src_pitch = BABL (conversion->source)->type.bits / 8;
+        if (!dst_data)
+          dst_data = destination;
+        if (!dst_pitch)
+          dst_pitch = BABL (conversion->destination)->type.bits / 8;
+
+        babl_conversion_plane_process (conversion,
+                                       src_data, dst_data,
+                                       src_pitch, dst_pitch,
+                                       n);
+      }
+        break;
+
+      case BABL_CONVERSION_PLANAR:
+        babl_assert (BABL_IS_BABL (source));
+        babl_assert (BABL_IS_BABL (destination));
+
+        babl_conversion_planar_process (conversion,
+                                        (BablImage *) source,
+                                        (BablImage *) destination,
+                                        n);
+        break;
+
+      case BABL_CONVERSION_LINEAR:
+        /* the assertions relied on a babl_malloc structure
+         *
+         * babl_assert (!BABL_IS_BABL (source));
+           babl_assert (!BABL_IS_BABL (destination));*/
+
+        babl_conversion_linear_process (conversion,
+                                        source,
+                                        destination,
+                                        n);
+        break;
+
+      default:
+        babl_log ("args=(%s, %p, %p, %li) unhandled conversion type: %s",
+                  conversion->instance.name, source, destination, n,
+                  babl_class_name (conversion->instance.class_type));
+        break;
+    }
+
+  conversion->processings++;
+  conversion->pixels += n;
+}
+
 #endif


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