[gegl] Revert gegl-tile-handler-zoom.c and fix some warnings



commit 36ad17d95d3ccc559ea5c60b32939aacf5c4711f
Author: Adam Turcotte <aturcotte src gnome org>
Date:   Thu Jun 30 15:29:21 2011 -0400

    Revert gegl-tile-handler-zoom.c and fix some warnings

 gegl/buffer/gegl-tile-handler-zoom.c |  143 +++++++++++++---------------------
 1 files changed, 53 insertions(+), 90 deletions(-)
---
diff --git a/gegl/buffer/gegl-tile-handler-zoom.c b/gegl/buffer/gegl-tile-handler-zoom.c
index 25d5be2..c94cb73 100644
--- a/gegl/buffer/gegl-tile-handler-zoom.c
+++ b/gegl/buffer/gegl-tile-handler-zoom.c
@@ -98,110 +98,73 @@ 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,
-                 const restrict guchar *src_data,
-                       restrict guchar *dst_data)
+downscale_float (gint    components,
+                 gint    width,
+                 gint    height,
+                 gint    rowstride,
+                 guchar *src_data,
+                 guchar *dst_data)
 {
-  /*
-   * Do nothing if src and dst are not valid.
-   */
-  if (src_data && dst_data)
+  gint y;
+
+  if (!src_data || !dst_data)
+    return;
+  for (y = 0; y < height / 2; y++)
     {
-      /*
-       * The code assumes that the loop body is executed at least once
-       * for all three of y, x and i.
-       */
-      gint y = 0;
-      do
-        {
-          gfloat *dst = (gfloat *) (dst_data + y * rowstride);
-          gfloat *src = (gfloat *) (src_data + y * (rowstride << 1));
+      gint    x;
+      gfloat *dst = (gfloat *) (dst_data + y * rowstride);
+      gfloat *src = (gfloat *) (src_data + y * 2 * rowstride);
 
-          gint x = 0;
-          do
-            {
-              gint i = 0;
-              do
-                {
-                  dst[i] = 
-                    (gfloat) 0.25
-                    *
-                    (
-                      src[i] +
+      for (x = 0; x < width / 2; x++)
+        {
+          int i;
+          for (i = 0; i < components; i++)
+            dst[i] = (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));
+                      src[i + (width * components)] +
+                      src[i + (width + 1) * components]) /
+                     4.0;
+
+          dst += components;
+          src += components * 2;
+        }
     }
 }
 
-
 static inline void
-downscale_u8 (const          gint    components,
-              const          gint    width,
-              const          gint    height,
-              const          gint    rowstride,
-              const restrict guchar *src_data,
-                    restrict guchar *dst_data)
+downscale_u8 (gint    components,
+              gint    width,
+              gint    height,
+              gint    rowstride,
+              guchar *src_data,
+              guchar *dst_data)
 {
-  /*
-   * Do nothing if src and dst are not valid.
-   */
-  if (src_data && dst_data)
+  gint y;
+
+  if (!src_data || !dst_data)
+    return;
+  for (y = 0; y < height / 2; y++)
     {
-      /*
-       * 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    x;
+      guchar *dst = dst_data + y * rowstride;
+      guchar *src = src_data + y * 2 * rowstride;
+
+      for (x = 0; x < width / 2; x++)
         {
-          guchar *dst = dst_data + y * rowstride;
-          guchar *src = src_data + y * ( rowstride << 1 );
+          int i;
+          for (i = 0; i < components; i++)
+            dst[i] = (src[i] +
+                      src[i + components] +
+                      src[i + rowstride] +
+                      src[i + rowstride + components]) /
+                     4;
 
-          gint x = 0;
-          do
-            {
-              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));
+          dst += components;
+          src += components * 2;
+        }
     }
 }
 
-
 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]