[gegl] operations: optimize and simplify the cpu version of noise-hurl
- From: Téo Mazars <teom src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gegl] operations: optimize and simplify the cpu version of noise-hurl
- Date: Thu, 31 Oct 2013 17:09:07 +0000 (UTC)
commit 6c3daa25aeb6c87c6e340df2eaebfa3b629f03e1
Author: Téo Mazars <teo mazars ensimag fr>
Date: Thu Oct 31 18:07:28 2013 +0100
operations: optimize and simplify the cpu version of noise-hurl
operations/common/noise-hurl.c | 103 +++++++++++++++-------------------------
1 files changed, 39 insertions(+), 64 deletions(-)
---
diff --git a/operations/common/noise-hurl.c b/operations/common/noise-hurl.c
index f2a88a3..f83a57f 100644
--- a/operations/common/noise-hurl.c
+++ b/operations/common/noise-hurl.c
@@ -62,73 +62,48 @@ process (GeglOperation *operation,
gint level)
{
GeglChantO *o = GEGL_CHANT_PROPERTIES (operation);
- gfloat *GEGL_ALIGNED in_pixel;
- gfloat *GEGL_ALIGNED out_pixel;
- gfloat *out_pix;
+ gfloat *in_pix = in_buf;
+ gfloat *out_pix = out_buf;
GeglRectangle *whole_region;
- gint total_size;
- gint i, cnt;
- gint offset;
-
- in_pixel = in_buf;
- out_pixel = out_buf;
- out_pix = out_pixel;
-
- for (i = 0; i < n_pixels * 4; i++)
- {
- *out_pix = *in_pixel;
- out_pix += 1;
- in_pixel += 1;
- }
+ gint total_size, cnt;
+ gint x, y;
whole_region = gegl_operation_source_get_bounding_box (operation, "input");
- total_size = whole_region->width*whole_region->height;
- offset = 0;
-
- for (cnt = 0; cnt < o->repeat; cnt++)
- {
- gint x = roi->x;
- gint y = roi->y;
-
- out_pix = out_pixel;
-
- for (i = 0; i < n_pixels; i++)
- {
- gfloat red, green, blue, alpha;
- gint idx, n;
-
- red = out_pix[0];
- green = out_pix[1];
- blue = out_pix[2];
- alpha = out_pix[3];
-
- idx = x + whole_region->width * y;
- n = 4 * (idx + offset);
-
- if (gegl_random_float_range (o->seed, x, y, 0, n, 0.0, 100.0) <=
- o->pct_random)
- {
- red = gegl_random_float (o->seed, x, y, 0, n+1);
- green = gegl_random_float (o->seed, x, y, 0, n+2);
- blue = gegl_random_float (o->seed, x, y, 0, n+3);
- }
-
- out_pix[0] = red;
- out_pix[1] = green;
- out_pix[2] = blue;
- out_pix[3] = alpha;
-
- out_pix += 4;
-
- x++;
- if (x >= roi->x + roi->width)
- {
- x = roi->x;
- y++;
- }
- }
- offset += total_size;
- }
+ total_size = whole_region->width * whole_region->height;
+
+ for (y = roi->y; y < roi->y + roi->height; y++)
+ for (x = roi->x; x < roi->x + roi->width; x++)
+ {
+ gfloat red, green, blue, alpha;
+ gint idx = x + whole_region->width * y;
+
+ red = in_pix[0];
+ green = in_pix[1];
+ blue = in_pix[2];
+ alpha = in_pix[3];
+
+ for (cnt = o->repeat - 1; cnt >= 0; cnt--)
+ {
+ gint n = 4 * (idx + cnt * total_size);
+
+ if (gegl_random_float_range (o->seed, x, y, 0, n, 0.0, 100.0) <=
+ o->pct_random)
+ {
+ red = gegl_random_float (o->seed, x, y, 0, n+1);
+ green = gegl_random_float (o->seed, x, y, 0, n+2);
+ blue = gegl_random_float (o->seed, x, y, 0, n+3);
+ break;
+ }
+ }
+
+ out_pix[0] = red;
+ out_pix[1] = green;
+ out_pix[2] = blue;
+ out_pix[3] = alpha;
+
+ out_pix += 4;
+ in_pix += 4;
+ }
return TRUE;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]