[gegl] gegl: reduce memory fetches in boxfilter u8 nl
- From: Øyvind Kolås <ok src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gegl] gegl: reduce memory fetches in boxfilter u8 nl
- Date: Sun, 28 Jan 2018 20:58:31 +0000 (UTC)
commit 758538a3cad619c9a971a4fc2799dad9556db546
Author: Øyvind Kolås <pippin gimp org>
Date: Fri Jan 26 04:08:18 2018 +0100
gegl: reduce memory fetches in boxfilter u8 nl
Leading to slight performance improvement.
gegl/gegl-algorithms.c | 58 ++++++++++++++++++++--------------------
perf/test-gegl-buffer-access.c | 12 +++++---
2 files changed, 37 insertions(+), 33 deletions(-)
---
diff --git a/gegl/gegl-algorithms.c b/gegl/gegl-algorithms.c
index f71ccde..9c32b5e 100644
--- a/gegl/gegl-algorithms.c
+++ b/gegl/gegl-algorithms.c
@@ -180,7 +180,6 @@ static inline int int_floorf (float x)
return i - ( i > x ); /* convert trunc to floor */
}
-
static void
gegl_boxfilter_u8_nl (guchar *dest_buf,
const guchar *source_buf,
@@ -195,7 +194,7 @@ gegl_boxfilter_u8_nl (guchar *dest_buf,
gint components = bpp / sizeof(uint8_t);
gfloat left_weight[dst_rect->width];
- gfloat center_weight[dst_rect->width];
+ //gfloat center_weight[dst_rect->width];
gfloat right_weight[dst_rect->width];
gint jj[dst_rect->width];
@@ -209,7 +208,7 @@ gegl_boxfilter_u8_nl (guchar *dest_buf,
left_weight[x] = MAX (0.0, left_weight[x]);
right_weight[x] = .5 - scale * ((jj[x] + 1) - sx);
right_weight[x] = MAX (0.0, right_weight[x]);
- center_weight[x] = 1. - left_weight[x] - right_weight[x];
+ //center_weight[x] = 1. - left_weight[x] - right_weight[x];
jj[x] *= components;
}
@@ -233,32 +232,32 @@ gegl_boxfilter_u8_nl (guchar *dest_buf,
case 4:
for (gint x = 0; x < dst_rect->width; x++)
{
- src[4] = (const uint8_t*)src_base + jj[x];
- src[1] = (const uint8_t*)(src_base - s_rowstride) + jj[x];
- src[7] = (const uint8_t*)(src_base + s_rowstride) + jj[x];
- src[2] = src[1] + 4;
- src[5] = src[4] + 4;
- src[8] = src[7] + 4;
- src[0] = src[1] - 4;
- src[3] = src[4] - 4;
- src[6] = src[7] - 4;
-
- if (src[0][3] == 0 && /* XXX: it would be even better to not call this at all for the abyss...
*/
- src[1][3] == 0 &&
- src[2][3] == 0 &&
- src[3][3] == 0 &&
- src[4][3] == 0 &&
- src[5][3] == 0 &&
- src[6][3] == 0 &&
- src[7][3] == 0)
- {
- (*(uint32_t*)(dst)) = 0;
- }
+ src[4] = (const uint8_t*)src_base + jj[x];
+ src[1] = src[4] - s_rowstride;
+ src[7] = src[4] + s_rowstride;
+ src[2] = src[1] + 4;
+ src[5] = src[4] + 4;
+ src[8] = src[7] + 4;
+ src[0] = src[1] - 4;
+ src[3] = src[4] - 4;
+ src[6] = src[7] - 4;
+
+ if (src[0][3] == 0 && /* XXX: it would be even better to not call this at all for the
abyss... */
+ src[1][3] == 0 &&
+ src[2][3] == 0 &&
+ src[3][3] == 0 &&
+ src[4][3] == 0 &&
+ src[5][3] == 0 &&
+ src[6][3] == 0 &&
+ src[7][3] == 0)
+ {
+ (*(uint32_t*)(dst)) = 0;
+ }
else
{
const gfloat l = left_weight[x];
- const gfloat c = center_weight[x];
const gfloat r = right_weight[x];
+ const gfloat c = 1.f - l - r;
const gfloat t = top_weight;
const gfloat m = middle_weight;
@@ -300,8 +299,8 @@ gegl_boxfilter_u8_nl (guchar *dest_buf,
src[6] = src[7] - 3;
{
const gfloat l = left_weight[x];
- const gfloat c = center_weight[x];
const gfloat r = right_weight[x];
+ const gfloat c = 1.f-l-r;
const gfloat t = top_weight;
const gfloat m = middle_weight;
@@ -337,8 +336,8 @@ gegl_boxfilter_u8_nl (guchar *dest_buf,
src[6] = src[7] - 2;
{
const gfloat l = left_weight[x];
- const gfloat c = center_weight[x];
const gfloat r = right_weight[x];
+ const gfloat c = 1.f-l-r;
const gfloat t = top_weight;
const gfloat m = middle_weight;
@@ -370,8 +369,9 @@ gegl_boxfilter_u8_nl (guchar *dest_buf,
src[6] = src[7] - 1;
{
const gfloat l = left_weight[x];
- const gfloat c = center_weight[x];
const gfloat r = right_weight[x];
+ const gfloat c = 1.f-l-r;
+
const gfloat t = top_weight;
const gfloat m = middle_weight;
@@ -399,8 +399,8 @@ gegl_boxfilter_u8_nl (guchar *dest_buf,
src[6] = src[7] - components;
{
const gfloat l = left_weight[x];
- const gfloat c = center_weight[x];
const gfloat r = right_weight[x];
+ const gfloat c = 1.f - l - r;
const gfloat t = top_weight;
const gfloat m = middle_weight;
diff --git a/perf/test-gegl-buffer-access.c b/perf/test-gegl-buffer-access.c
index 1a1d61b..5e10510 100644
--- a/perf/test-gegl-buffer-access.c
+++ b/perf/test-gegl-buffer-access.c
@@ -9,17 +9,21 @@ main (gint argc,
GeglBuffer *buffer;
GeglRectangle bound = {0, 0, 1024, 1024};
const Babl *format;
- gchar *buf;
+ guchar *buf;
gint i;
gegl_init (NULL, NULL);
format = babl_format ("RGBA float");
buf = g_malloc0 (bound.width * bound.height * BPP);
+
+ for (i = 0; i < bound.width * bound.height * BPP;i++)
+ buf[i] = rand() & 0xff;
+
buffer = gegl_buffer_new (&bound, format);
/* pre-initialize */
gegl_buffer_set (buffer, &bound, 0, NULL, buf, GEGL_AUTO_ROWSTRIDE);
-
+#if 0
test_start ();
for (i=0;i<ITERATIONS && converged < BAIL_COUNT;i++)
{
@@ -41,7 +45,6 @@ main (gint argc,
g_object_unref (buffer);
}
test_end ("gegl_buffer_get 0.333", 1.0 * bound.width * bound.height * ITERATIONS * BPP);
-
{
test_start ();
@@ -58,7 +61,7 @@ main (gint argc,
}
}
test_end ("gegl_buffer_get 8bit 0.333", 1.0 * bound.width * bound.height * ITERATIONS * 4);
-
+#endif
{
@@ -77,6 +80,7 @@ main (gint argc,
}
test_end ("gegl_buffer_getC8bit 0.333", 1.0 * bound.width * bound.height * ITERATIONS * 4);
+ exit(0);
test_start ();
for (i=0;i<ITERATIONS && converged < BAIL_COUNT;i++)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]