[gegl] map-{absolute,relative}: minor performance improvements
- From: N/A <ell src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gegl] map-{absolute,relative}: minor performance improvements
- Date: Mon, 22 May 2017 20:06:02 +0000 (UTC)
commit 38f5e31d2800c47c72b6ffff9d6ddeed76916c82
Author: Ell <ell_se yahoo com>
Date: Sun May 21 17:15:50 2017 -0400
map-{absolute,relative}: minor performance improvements
Pedantic, really, but marginally faster :)
Also, fix map-absolute sampling shortcut to test for center-of-
pixels, instead of corner-of-pixels.
operations/common/map-absolute.c | 56 +++++++++++++++++----------------
operations/common/map-relative.c | 64 ++++++++++++++++++-------------------
2 files changed, 60 insertions(+), 60 deletions(-)
---
diff --git a/operations/common/map-absolute.c b/operations/common/map-absolute.c
index d1d1721..e25c04c 100644
--- a/operations/common/map-absolute.c
+++ b/operations/common/map-absolute.c
@@ -92,41 +92,43 @@ process (GeglOperation *operation,
while (gegl_buffer_iterator_next (it))
{
- gint i;
- gint n_pixels = it->length;
- gint x = it->roi->x; /* initial x */
- gint y = it->roi->y; /* and y coordinates */
+ gint w;
+ gint h;
+ gfloat x;
+ gfloat y;
gfloat *in = it->data[index_in];
gfloat *out = it->data[index_out];
gfloat *coords = it->data[index_coords];
- for (i=0; i<n_pixels; i++)
- {
- /* if the coordinate asked is an exact pixel, we fetch it directly, to avoid the blur of
sampling */
- if (coords[0] == x && coords[1] == y)
- {
- out[0] = in[0];
- out[1] = in[1];
- out[2] = in[2];
- out[3] = in[3];
- }
- else
- {
- gegl_sampler_get (sampler, coords[0], coords[1], NULL, out, o->abyss_policy);
- }
+ y = it->roi->y + 0.5; /* initial y coordinate */
- coords += 2;
- in += 4;
- out += 4;
+ for (h = it->roi->height; h; h--, y++)
+ {
+ x = it->roi->x + 0.5; /* initial x coordinate */
- /* update x and y coordinates */
- x++;
- if (x >= (it->roi->x + it->roi->width))
+ for (w = it->roi->width; w; w--, x++)
{
- x = it->roi->x;
- y++;
+ /* if the coordinate asked is an exact pixel, we fetch it
+ * directly, to avoid the blur of sampling */
+ if (coords[0] == x && coords[1] == y)
+ {
+ out[0] = in[0];
+ out[1] = in[1];
+ out[2] = in[2];
+ out[3] = in[3];
+ }
+ else
+ {
+ gegl_sampler_get (sampler, coords[0],
+ coords[1],
+ NULL, out,
+ o->abyss_policy);
+ }
+
+ coords += 2;
+ in += 4;
+ out += 4;
}
-
}
}
}
diff --git a/operations/common/map-relative.c b/operations/common/map-relative.c
index a32a55e..7fa4dbb 100644
--- a/operations/common/map-relative.c
+++ b/operations/common/map-relative.c
@@ -83,7 +83,7 @@ process (GeglOperation *operation,
sampler = gegl_buffer_sampler_new_at_level (input, format_io, o->sampler_type, level);
- if (aux != NULL)
+ if (aux != NULL && o->scaling != 0.0)
{
it = gegl_buffer_iterator_new (output, result, level, format_io,
GEGL_ACCESS_WRITE, GEGL_ABYSS_NONE);
@@ -96,46 +96,44 @@ process (GeglOperation *operation,
while (gegl_buffer_iterator_next (it))
{
- gint i;
- gint n_pixels = it->length;
- gint x = it->roi->x; /* initial x */
- gint y = it->roi->y; /* and y coordinates */
- gdouble scaling = GEGL_PROPERTIES (operation)->scaling;
+ gint w;
+ gint h;
+ gfloat x;
+ gfloat y;
+ gfloat scaling = GEGL_PROPERTIES (operation)->scaling;
gfloat *in = it->data[index_in];
gfloat *out = it->data[index_out];
gfloat *coords = it->data[index_coords];
- for (i=0; i<n_pixels; i++)
- {
- /* if the coordinate asked is an exact pixel, we fetch it
- * directly, to avoid the blur of sampling */
- if (coords[0] == 0 && coords[1] == 0)
- {
- out[0] = in[0];
- out[1] = in[1];
- out[2] = in[2];
- out[3] = in[3];
- }
- else
- {
- gegl_sampler_get (sampler, x + coords[0] * scaling + 0.5,
- y + coords[1] * scaling + 0.5,
- NULL, out,
- o->abyss_policy);
- }
+ y = it->roi->y + 0.5; /* initial y coordinate */
- coords += 2;
- in += 4;
- out += 4;
+ for (h = it->roi->height; h; h--, y++)
+ {
+ x = it->roi->x + 0.5; /* initial x coordinate */
- /* update x and y coordinates */
- x++;
- if (x >= (it->roi->x + it->roi->width))
+ for (w = it->roi->width; w; w--, x++)
{
- x = it->roi->x;
- y++;
+ /* if the coordinate asked is an exact pixel, we fetch it
+ * directly, to avoid the blur of sampling */
+ if (coords[0] == 0.0f && coords[1] == 0.0f)
+ {
+ out[0] = in[0];
+ out[1] = in[1];
+ out[2] = in[2];
+ out[3] = in[3];
+ }
+ else
+ {
+ gegl_sampler_get (sampler, x + coords[0] * scaling,
+ y + coords[1] * scaling,
+ NULL, out,
+ o->abyss_policy);
+ }
+
+ coords += 2;
+ in += 4;
+ out += 4;
}
-
}
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]