[gegl] tile-zoom tweak



commit 729378ab91df855b0a11b8f3319f7c26c40a792e
Author: Nicolas Robidoux <nicolas robidoux gmail com>
Date:   Thu Jun 30 11:35:15 2011 -0400

    tile-zoom tweak

 gegl/buffer/gegl-tile-handler-zoom.c |  156 ++++++++++++++++++----------------
 1 files changed, 83 insertions(+), 73 deletions(-)
---
diff --git a/gegl/buffer/gegl-tile-handler-zoom.c b/gegl/buffer/gegl-tile-handler-zoom.c
index 0cf6b8b..25d5be2 100644
--- a/gegl/buffer/gegl-tile-handler-zoom.c
+++ b/gegl/buffer/gegl-tile-handler-zoom.c
@@ -98,100 +98,110 @@ static inline void set_half_nearest (GeglTile *dst_tile,
 }
 
 static inline void
-downscale_float (const gint    components,
-                 const gint    width,
-                 const gint    height,
-                 const gint    rowstride,
-                       guchar *src_data,
-                       guchar *dst_data)
+downscale_float (const          gint    components,
+                 const          gint    width,
+                 const          gint    height,
+                 const          gint    rowstride,
+                 const restrict guchar *src_data,
+                       restrict guchar *dst_data)
 {
   /*
-   * The code assumes that the loop body is executed at least once for
-   * all three of y, x and i.
+   * Do nothing if src and dst are not valid.
    */
-  gint y = 0;
-
-  if (!src_data || !dst_data)
-    return;
-
-  do
+  if (src_data && dst_data)
     {
-      gint x = 0;
-      gfloat *dst = (gfloat *) (dst_data + y * rowstride);
-      gfloat *src = (gfloat *) (src_data + y * (rowstride << 1));
-
+      /*
+       * The code assumes that the loop body is executed at least once
+       * for all three of y, x and i.
+       */
+      gint y = 0;
       do
         {
-          gint i = 0;
+          gfloat *dst = (gfloat *) (dst_data + y * rowstride);
+          gfloat *src = (gfloat *) (src_data + y * (rowstride << 1));
+
+          gint x = 0;
           do
             {
-              dst[i] = (src[i] +
-                        src[i + components] +
-                        src[i + width * components] +
-                        src[i + (width * components + components)])
-                        * (gfloat) 0.25;
-
-              dst += components;
-              src += components << 1;
-            } while (++i < components);
-
-        } while (++x < (width >> 1));
-
-    } while (++y < (height >> 1));
+              gint i = 0;
+              do
+                {
+                  dst[i] = 
+                    (gfloat) 0.25
+                    *
+                    (
+                      src[i] +
+                      src[i + components] +
+                      src[i + width * components] +
+                      src[i + (width * components + components)]
+                    );
+                  
+                  dst += components;
+                  src += components << 1;
+                } while (++i < components);
+              
+            } while (++x < (width >> 1));
+          
+        } while (++y < (height >> 1));
+    }
 }
 
+
 static inline void
-downscale_u8 (const gint    components,
-              const gint    width,
-              const gint    height,
-              const gint    rowstride,
-                    guchar *src_data,
-                    guchar *dst_data)
+downscale_u8 (const          gint    components,
+              const          gint    width,
+              const          gint    height,
+              const          gint    rowstride,
+              const restrict guchar *src_data,
+                    restrict guchar *dst_data)
 {
   /*
-   * The code assumes that the loop body is executed at least once for
-   * all three of y, x and i.
+   * Do nothing if src and dst are not valid.
    */
-  gint y = 0;
-
-  if (!src_data || !dst_data)
-    return;
-
-  do
+  if (src_data && dst_data)
     {
-      gint x = 0;
-      guchar *dst = dst_data + y * rowstride;
-      guchar *src = src_data + y * ( rowstride << 1 );
-
+      /*
+       * The code assumes that the loop body is executed at least once
+       * for all three of y, x and i.
+       */
+      gint y = 0;
       do
         {
-          gint i = 0;
+          guchar *dst = dst_data + y * rowstride;
+          guchar *src = src_data + y * ( rowstride << 1 );
+
+          gint x = 0;
           do
             {
-              /*
-               * The "+ 2" is there to round, with halfway values
-               * rounded up, which appears to be the preferred choice
-               * since it makes things slightly brighter (esp. if
-               * there is transparency).
-               *
-               * If speed is paramount, remove the "+ 2" and get
-               * clamped down instead of rounded values.
-               */
-              dst[i] = (src[i]
-                        + src[i + components]
-                        + src[i + rowstride]
-                        + src[i + ( rowstride + components )]
-                        + 2) >> 2;
-            } while (++i < components);
-
-          dst += components;
-          src += components >> 1;
-
-        } while (++x < (width >> 1));
-
-    } while (++y < (height >> 1));
+              gint i = 0;
+              do
+                {
+                  /*
+                   * The "+ 2" is there to round, with halfway values
+                   * rounded up, which appears to be the preferred
+                   * choice since it makes things slightly brighter
+                   * (esp. if there is transparency).
+                   *
+                   * If speed is paramount, remove the "+ 2" and get
+                   * clamped down instead of rounded values.
+                   */
+                  dst[i] = (src[i]
+                            + src[i + components]
+                            + src[i + rowstride]
+                            + src[i + ( rowstride + components )]
+                            + 2) >> 2;
+                } while (++i < components);
+              
+              dst += components;
+              src += components >> 1;
+              
+            } while (++x < (width >> 1));
+          
+        } while (++y < (height >> 1));
+    }
 }
 
+
 static inline void set_half (GeglTile * dst_tile,
                              GeglTile * src_tile,
                              gint       width,



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