[gegl] even though it apparently makes no difference in the results (in the composition tests, for example)
- From: Nicolas Robidoux <nrobidoux src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gegl] even though it apparently makes no difference in the results (in the composition tests, for example)
- Date: Thu, 22 Nov 2012 05:37:39 +0000 (UTC)
commit 259aa91cc27c402cf661b4bde728f390c243d4fb
Author: Nicolas Robidoux <nrobidoux git gnome org>
Date: Thu Nov 22 00:34:33 2012 -0500
even though it apparently makes no difference in the results (in the composition tests, for example), replace FAST_PSEUDO_FLOOR by floor throughout to make sure that different rounding in the samplers and bounding box computations are not affected by its use
gegl/buffer/gegl-buffer-private.h | 21 ---------------------
gegl/buffer/gegl-sampler-cubic.c | 8 ++++----
gegl/buffer/gegl-sampler-linear.c | 10 ++++++----
gegl/buffer/gegl-sampler-lohalo.c | 9 ++++-----
gegl/buffer/gegl-sampler-nearest.c | 5 +++--
5 files changed, 17 insertions(+), 36 deletions(-)
---
diff --git a/gegl/buffer/gegl-buffer-private.h b/gegl/buffer/gegl-buffer-private.h
index 439f28c..45445a9 100644
--- a/gegl/buffer/gegl-buffer-private.h
+++ b/gegl/buffer/gegl-buffer-private.h
@@ -209,27 +209,6 @@ gboolean gegl_buffer_scan_compatible (GeglBuffer *bufferA,
(divisor) - 1 - ((-((dividend) + 1)) % (divisor)) : \
(dividend) % (divisor))
-/*
- * FAST_PSEUDO_FLOOR is a floor replacement which has been found to be
- * faster. It returns the floor of its argument unless the argument is
- * a negative integer, in which case it returns one less than the
- * floor. For example:
- *
- * FAST_PSEUDO_FLOOR(0.5) = 0
- *
- * FAST_PSEUDO_FLOOR(0.) = 0
- *
- * FAST_PSEUDO_FLOOR(-.5) = -1
- *
- * as expected, but
- *
- * FAST_PSEUDO_FLOOR(-1.) = -2
- *
- * The discontinuities of FAST_PSEUDO_FLOOR are on the right of
- * negative numbers instead of on the left as is the case for floor.
- */
-#define GEGL_FAST_PSEUDO_FLOOR(x) ( (gint) (x) - (gint) ( (gdouble) (x) < 0. ) )
-
#define gegl_tile_offset(coordinate, stride) GEGL_REMAINDER((coordinate), (stride))
/* helper function to compute tile indices and offsets for coordinates
diff --git a/gegl/buffer/gegl-sampler-cubic.c b/gegl/buffer/gegl-sampler-cubic.c
index 54ca3e6..5c96a46 100644
--- a/gegl/buffer/gegl-sampler-cubic.c
+++ b/gegl/buffer/gegl-sampler-cubic.c
@@ -163,11 +163,11 @@ gegl_sampler_cubic_get ( GeglSampler *self,
* index (0,0), to a coordinate system in which the origin is at the
* center of the same pixel.
*/
- const gdouble iabsolute_x = absolute_x - (gdouble) 0.5;
- const gdouble iabsolute_y = absolute_y - (gdouble) 0.5;
+ const double iabsolute_x = (double) absolute_x - 0.5;
+ const double iabsolute_y = (double) absolute_y - 0.5;
- const gint ix = GEGL_FAST_PSEUDO_FLOOR (iabsolute_x);
- const gint iy = GEGL_FAST_PSEUDO_FLOOR (iabsolute_y);
+ const gint ix = floor (iabsolute_x);
+ const gint iy = floor (iabsolute_y);
/*
* x is the x-coordinate of the sampling point relative to the
diff --git a/gegl/buffer/gegl-sampler-linear.c b/gegl/buffer/gegl-sampler-linear.c
index c31a0f4..e155505 100644
--- a/gegl/buffer/gegl-sampler-linear.c
+++ b/gegl/buffer/gegl-sampler-linear.c
@@ -17,6 +17,8 @@
*/
#include "config.h"
+#include <math.h>
+
#include <glib-object.h>
#include <glib/gstdio.h>
#include <glib/gprintf.h>
@@ -79,11 +81,11 @@ gegl_sampler_linear_get ( GeglSampler* restrict self,
* index (0,0), to a coordinate system in which the origin is at the
* center of the same pixel.
*/
- const gdouble iabsolute_x = absolute_x - (gdouble) 0.5;
- const gdouble iabsolute_y = absolute_y - (gdouble) 0.5;
+ const double iabsolute_x = (double) absolute_x - 0.5;
+ const double iabsolute_y = (double) absolute_y - 0.5;
- const gint ix = GEGL_FAST_PSEUDO_FLOOR (iabsolute_x);
- const gint iy = GEGL_FAST_PSEUDO_FLOOR (iabsolute_y);
+ const gint ix = floor (iabsolute_x);
+ const gint iy = floor (iabsolute_y);
/*
* Point the data tile pointer to the first channel of the top_left
diff --git a/gegl/buffer/gegl-sampler-lohalo.c b/gegl/buffer/gegl-sampler-lohalo.c
index 49da984..dd7e75d 100644
--- a/gegl/buffer/gegl-sampler-lohalo.c
+++ b/gegl/buffer/gegl-sampler-lohalo.c
@@ -838,9 +838,8 @@ lbb (const gfloat c00,
* (ix-1,iy+2) (ix,iy+2) (ix+1,iy+2) (ix+2,iy+2)
* = qua_one = qua_two = qua_thr = qua_fou
*
- * where ix is the (pseudo-)floor of the requested left-to-right
- * location ("X"), and iy is the floor of the requested up-to-down
- * location.
+ * where ix is the floor of the requested left-to-right location
+ * ("X"), and iy is the floor of the requested up-to-down location.
*/
/*
@@ -1299,8 +1298,8 @@ gegl_sampler_lohalo_get ( GeglSampler* restrict self,
* of the closest pixel center (one of the closest when there are
* ties) within the GIMP convention.
*/
- const gint ix_0 = GEGL_FAST_PSEUDO_FLOOR (absolute_x);
- const gint iy_0 = GEGL_FAST_PSEUDO_FLOOR (absolute_y);
+ const gint ix_0 = floor ((double) absolute_x);
+ const gint iy_0 = floor ((double) absolute_y);
/*
* This is the pointer we use to pull pixel from "base" mipmap level
diff --git a/gegl/buffer/gegl-sampler-nearest.c b/gegl/buffer/gegl-sampler-nearest.c
index a5b098e..64fa0f7 100644
--- a/gegl/buffer/gegl-sampler-nearest.c
+++ b/gegl/buffer/gegl-sampler-nearest.c
@@ -17,6 +17,7 @@
#include "config.h"
#include <string.h>
+#include <math.h>
#include <glib-object.h>
@@ -71,8 +72,8 @@ gegl_sampler_nearest_get (GeglSampler *self,
gfloat *sampler_bptr;
sampler_bptr = gegl_sampler_get_from_buffer (self,
- GEGL_FAST_PSEUDO_FLOOR (x),
- GEGL_FAST_PSEUDO_FLOOR (y),
+ (gdouble) floor ((double) x),
+ (gdouble) floor ((double) y),
repeat_mode);
babl_process (self->fish, sampler_bptr, output, 1);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]