[babl] babl: add babl_process_rows api



commit 5082e78704f990db6543d844713b1d880d30e459
Author: Øyvind Kolås <pippin gimp org>
Date:   Sun Jan 7 01:10:54 2018 +0100

    babl: add babl_process_rows api
    
    Useful when fetching buffers smaller than a tile or partial tiles in APIs like
    gegl_buffer_get.

 babl/babl-fish-path.c |   64 ++++++++++++++++++++++++++++++++++++++++++------
 babl/babl.h           |    9 +++++++
 export-symbols        |    1 +
 3 files changed, 66 insertions(+), 8 deletions(-)
---
diff --git a/babl/babl-fish-path.c b/babl/babl-fish-path.c
index 2d8bd9e..d08db0e 100644
--- a/babl/babl-fish-path.c
+++ b/babl/babl-fish-path.c
@@ -74,7 +74,7 @@ get_path_instrumentation (FishPathInstrumentation *fpi,
                           double                  *path_error);
 
 
-static void
+static inline void
 process_conversion_path (BablList   *path,
                          const void *source_buffer,
                          int         source_bpp,
@@ -607,7 +607,7 @@ babl_fish_path (const Babl *source,
   return babl_fish_path2 (source, destination, 0.0);
 }
 
-static void
+static inline void
 babl_fish_path_process (const Babl *babl,
                         const void *source,
                         void       *destination,
@@ -713,12 +713,9 @@ babl_process (const Babl *cbabl,
               long        n)
 {
   Babl *babl = (Babl*)cbabl;
-  babl_assert (babl && BABL_IS_BABL (babl));
-  babl_assert (source);
-  babl_assert (destination);
-  if (n == 0)
+  babl_assert (babl && BABL_IS_BABL (babl) && source && destination);
+  if (n <= 0)
     return 0;
-  babl_assert (n > 0);
 
   /* first check if it is a fish since that is our fast path */
   if (babl->class_type >= BABL_FISH &&
@@ -742,6 +739,57 @@ babl_process (const Babl *cbabl,
   return -1;
 }
 
+long
+babl_process_rows (const Babl *fish,
+                   const void *source,
+                   int         source_stride,
+                   void       *dest,
+                   int         dest_stride,
+                   long        n,
+                   int         rows)
+{
+  Babl          *babl = (Babl*)fish;
+  const uint8_t *src  = source;
+  uint8_t       *dst  = dest;
+  int            row;
+
+  babl_assert (babl && BABL_IS_BABL (babl) && source && dest);
+
+  if (n <= 0)
+    return 0;
+
+  /* first check if it is a fish since that is our fast path */
+  if (babl->class_type >= BABL_FISH &&
+      babl->class_type <= BABL_FISH_PATH)
+    {
+      babl->fish.processings++;
+      babl->fish.pixels += n * rows;
+      for (row = 0; row < rows; row++)
+        {
+          _babl_fish_process (babl, src, dst, n);
+          src += source_stride;
+          dst += dest_stride;
+        }
+      return n * rows;
+    }
+
+  /* matches all conversion classes */
+  if (babl->class_type >= BABL_CONVERSION &&
+      babl->class_type <= BABL_CONVERSION_PLANAR)
+  {
+    for (row = 0; row < rows; row++)
+    {
+      babl_conversion_process (babl, (void*)src, (void*)dst, n);
+      src += source_stride;
+      dst += dest_stride;
+    }
+    return n * rows;
+  }
+
+  babl_fatal ("eek");
+  return -1;
+}
+
 #include <stdint.h>
 
 #define BABL_ALIGN 16
@@ -752,7 +800,7 @@ static void inline *align_16 (unsigned char *ret)
   return ret;
 }
 
-static void
+static inline void
 process_conversion_path (BablList   *path,
                          const void *source_buffer,
                          int         source_bpp,
diff --git a/babl/babl.h b/babl/babl.h
index a45de42..39cb097 100644
--- a/babl/babl.h
+++ b/babl/babl.h
@@ -226,6 +226,15 @@ long         babl_process   (const Babl *babl_fish,
                              long  n);
 
 
+long         babl_process_rows (const Babl *babl_fish,
+                                const void *source,
+                                int         source_stride,
+                                void       *dest,
+                                int         dest_stride,
+                                long        n,
+                                int         rows);
+
+
 /**
  * babl_get_name:
  *
diff --git a/export-symbols b/export-symbols
index d229698..46c7b5b 100644
--- a/export-symbols
+++ b/export-symbols
@@ -36,6 +36,7 @@ babl_new_palette
 babl_palette_reset
 babl_palette_set_palette
 babl_process
+babl_process_rows
 babl_fish_process
 babl_sampling
 babl_set_user_data


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