[gegl] Do not rely on input or output buffer extents in ops,
- From: Øyvind Kolås <ok src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gegl] Do not rely on input or output buffer extents in ops,
- Date: Thu, 12 Nov 2009 14:10:40 +0000 (UTC)
commit 0b096b23ee0199f3423a5013b387564eff4d2b09
Author: �yvind Kolås <pippin gimp org>
Date: Thu Nov 12 04:35:23 2009 +0000
Do not rely on input or output buffer extents in ops,
removing the need for GEGL to pass sub-buffers with
the input/output bounding boxes.
gegl/operation/gegl-operation-context.c | 4 +-
operations/common/bilateral-filter.c | 41 ++++----
operations/common/box-blur.c | 72 ++++++++-------
operations/common/c2g.c | 44 +++++----
operations/common/gaussian-blur.c | 152 ++++++++++++++----------------
operations/common/snn-mean.c | 28 +++---
operations/common/stress.c | 34 ++++---
operations/external/text.c | 2 +-
8 files changed, 191 insertions(+), 186 deletions(-)
---
diff --git a/gegl/operation/gegl-operation-context.c b/gegl/operation/gegl-operation-context.c
index a470299..414b377 100644
--- a/gegl/operation/gegl-operation-context.c
+++ b/gegl/operation/gegl-operation-context.c
@@ -314,15 +314,13 @@ gegl_operation_context_get_source (GeglOperationContext *context,
GeglOperation *operation;
GeglBuffer *real_input;
GeglBuffer *input;
- GeglRectangle input_request;
operation = context->operation;
- input_request = gegl_operation_get_required_for_output (operation, padname, &context->need_rect);
real_input = GEGL_BUFFER (gegl_operation_context_get_object (context, padname));
if (!real_input)
return NULL;
- input = gegl_buffer_create_sub_buffer (real_input, &input_request);
+ input = g_object_ref (real_input);
return input;
}
diff --git a/operations/common/bilateral-filter.c b/operations/common/bilateral-filter.c
index 5cbde94..7ee9cbb 100644
--- a/operations/common/bilateral-filter.c
+++ b/operations/common/bilateral-filter.c
@@ -38,10 +38,12 @@ gegl_chant_double (edge_preservation, _("Edge preservation"), 0.0, 70.0, 8.0,
#include <math.h>
static void
-bilateral_filter (GeglBuffer *src,
- GeglBuffer *dst,
- gdouble radius,
- gdouble preserve);
+bilateral_filter (GeglBuffer *src,
+ const GeglRectangle *src_rect,
+ GeglBuffer *dst,
+ const GeglRectangle *dst_rect,
+ gdouble radius,
+ gdouble preserve);
#include <stdio.h>
@@ -62,7 +64,6 @@ process (GeglOperation *operation,
const GeglRectangle *result)
{
GeglChantO *o = GEGL_CHANT_PROPERTIES (operation);
- GeglBuffer *temp_in;
GeglRectangle compute;
compute = gegl_operation_get_required_for_output (operation, "input",result);
@@ -73,19 +74,19 @@ process (GeglOperation *operation,
}
else
{
- temp_in = gegl_buffer_create_sub_buffer (input, &compute);
- bilateral_filter (temp_in, output, o->blur_radius, o->edge_preservation);
- g_object_unref (temp_in);
+ bilateral_filter (input, &compute, output, result, o->blur_radius, o->edge_preservation);
}
return TRUE;
}
static void
-bilateral_filter (GeglBuffer *src,
- GeglBuffer *dst,
- gdouble radius,
- gdouble preserve)
+bilateral_filter (GeglBuffer *src,
+ const GeglRectangle *src_rect,
+ GeglBuffer *dst,
+ const GeglRectangle *dst_rect,
+ gdouble radius,
+ gdouble preserve)
{
gfloat *gauss;
gint x,y;
@@ -94,14 +95,14 @@ bilateral_filter (GeglBuffer *src,
gfloat *dst_buf;
gint width = (gint) radius * 2 + 1;
gint iradius = radius;
- gint src_width = gegl_buffer_get_width (src);
- gint src_height = gegl_buffer_get_height (src);
+ gint src_width = src_rect->width;
+ gint src_height = src_rect->height;
gauss = g_newa (gfloat, width * width);
- src_buf = g_new0 (gfloat, gegl_buffer_get_pixel_count(src) * 4);
- dst_buf = g_new0 (gfloat, gegl_buffer_get_pixel_count(dst) * 4);
+ src_buf = g_new0 (gfloat, src_rect->width * src_rect->height * 4);
+ dst_buf = g_new0 (gfloat, dst_rect->width * dst_rect->height * 4);
- gegl_buffer_get (src, 1.0, NULL, babl_format ("RGBA float"), src_buf, GEGL_AUTO_ROWSTRIDE);
+ gegl_buffer_get (src, 1.0, src_rect, babl_format ("RGBA float"), src_buf, GEGL_AUTO_ROWSTRIDE);
offset = 0;
@@ -112,8 +113,8 @@ bilateral_filter (GeglBuffer *src,
gauss[x+(int)radius + (y+(int)radius)*width] = exp(- 0.5*(POW2(x)+POW2(y))/radius );
}
- for (y=0; y<gegl_buffer_get_height (dst); y++)
- for (x=0; x<gegl_buffer_get_width (dst); x++)
+ for (y=0; y<dst_rect->height; y++)
+ for (x=0; x<dst_rect->width; x++)
{
gint u,v;
gfloat *center_pix = src_buf + ((x+iradius)+((y+iradius) * src_width)) * 4;
@@ -156,7 +157,7 @@ bilateral_filter (GeglBuffer *src,
dst_buf[offset*4+u] = accumulated[u]/count;
offset++;
}
- gegl_buffer_set (dst, NULL, babl_format ("RGBA float"), dst_buf,
+ gegl_buffer_set (dst, dst_rect, babl_format ("RGBA float"), dst_buf,
GEGL_AUTO_ROWSTRIDE);
g_free (src_buf);
g_free (dst_buf);
diff --git a/operations/common/box-blur.c b/operations/common/box-blur.c
index c4360dd..daf2fac 100644
--- a/operations/common/box-blur.c
+++ b/operations/common/box-blur.c
@@ -33,14 +33,6 @@ gegl_chant_double (radius, _("Radius"), 0.0, 200.0, 4.0,
#include <stdio.h>
#include <math.h>
-static void hor_blur (GeglBuffer *src,
- GeglBuffer *dst,
- gint radius);
-
-static void ver_blur (GeglBuffer *src,
- GeglBuffer *dst,
- gint radius);
-
#ifdef USE_DEAD_CODE
static inline float
get_mean_component (gfloat *buf,
@@ -127,9 +119,11 @@ get_mean_components (gfloat *buf,
/* expects src and dst buf to have the same extent */
static void
-hor_blur (GeglBuffer *src,
- GeglBuffer *dst,
- gint radius)
+hor_blur (GeglBuffer *src,
+ const GeglRectangle *src_rect,
+ GeglBuffer *dst,
+ const GeglRectangle *dst_rect,
+ gint radius)
{
gint u,v;
gint offset;
@@ -137,21 +131,21 @@ hor_blur (GeglBuffer *src,
gfloat *dst_buf;
/* src == dst for hor blur */
- src_buf = g_new0 (gfloat, gegl_buffer_get_pixel_count (src) * 4);
- dst_buf = g_new0 (gfloat, gegl_buffer_get_pixel_count (dst) * 4);
+ src_buf = g_new0 (gfloat, src_rect->width * src_rect->height * 4);
+ dst_buf = g_new0 (gfloat, dst_rect->width * dst_rect->height * 4);
- gegl_buffer_get (src, 1.0, NULL, babl_format ("RaGaBaA float"), src_buf, GEGL_AUTO_ROWSTRIDE);
+ gegl_buffer_get (src, 1.0, src_rect, babl_format ("RaGaBaA float"), src_buf, GEGL_AUTO_ROWSTRIDE);
offset = 0;
- for (v=0; v<gegl_buffer_get_height (dst); v++)
- for (u=0; u<gegl_buffer_get_width (dst); u++)
+ for (v=0; v<dst_rect->height; v++)
+ for (u=0; u<dst_rect->width; u++)
{
gint i;
gfloat components[4];
get_mean_components (src_buf,
- gegl_buffer_get_width (src),
- gegl_buffer_get_height (src),
+ src_rect->width,
+ src_rect->height,
u - radius,
v,
1 + radius*2,
@@ -162,7 +156,7 @@ hor_blur (GeglBuffer *src,
dst_buf [offset++] = components[i];
}
- gegl_buffer_set (dst, NULL, babl_format ("RaGaBaA float"), dst_buf, GEGL_AUTO_ROWSTRIDE);
+ gegl_buffer_set (dst, dst_rect, babl_format ("RaGaBaA float"), dst_buf, GEGL_AUTO_ROWSTRIDE);
g_free (src_buf);
g_free (dst_buf);
}
@@ -170,30 +164,32 @@ hor_blur (GeglBuffer *src,
/* expects dst buf to be radius smaller than src buf */
static void
-ver_blur (GeglBuffer *src,
- GeglBuffer *dst,
- gint radius)
+ver_blur (GeglBuffer *src,
+ const GeglRectangle *src_rect,
+ GeglBuffer *dst,
+ const GeglRectangle *dst_rect,
+ gint radius)
{
gint u,v;
gint offset;
gfloat *src_buf;
gfloat *dst_buf;
- src_buf = g_new0 (gfloat, gegl_buffer_get_pixel_count (src) * 4);
- dst_buf = g_new0 (gfloat, gegl_buffer_get_pixel_count (dst) * 4);
+ src_buf = g_new0 (gfloat, src_rect->width * src_rect->height * 4);
+ dst_buf = g_new0 (gfloat, dst_rect->width * dst_rect->height * 4);
- gegl_buffer_get (src, 1.0, NULL, babl_format ("RaGaBaA float"), src_buf, GEGL_AUTO_ROWSTRIDE);
+ gegl_buffer_get (src, 1.0, src_rect, babl_format ("RaGaBaA float"), src_buf, GEGL_AUTO_ROWSTRIDE);
offset=0;
- for (v=0; v<gegl_buffer_get_height (dst); v++)
- for (u=0; u<gegl_buffer_get_width (dst); u++)
+ for (v=0; v<dst_rect->height; v++)
+ for (u=0; u<dst_rect->width; u++)
{
gfloat components[4];
gint c;
get_mean_components (src_buf,
- gegl_buffer_get_width (src),
- gegl_buffer_get_height (src),
+ src_rect->width,
+ src_rect->height,
u + radius, /* 1x radius is the offset between the bufs */
v - radius + radius, /* 1x radius is the offset between the bufs */
1,
@@ -204,7 +200,7 @@ ver_blur (GeglBuffer *src,
dst_buf [offset++] = components[c];
}
- gegl_buffer_set (dst, NULL, babl_format ("RaGaBaA float"), dst_buf, GEGL_AUTO_ROWSTRIDE);
+ gegl_buffer_set (dst, dst_rect, babl_format ("RaGaBaA float"), dst_buf, GEGL_AUTO_ROWSTRIDE);
g_free (src_buf);
g_free (dst_buf);
}
@@ -232,14 +228,24 @@ process (GeglOperation *operation,
GeglBuffer *output,
const GeglRectangle *result)
{
+ GeglRectangle rect;
GeglChantO *o = GEGL_CHANT_PROPERTIES (operation);
GeglBuffer *temp;
+ GeglOperationAreaFilter *op_area;
+ op_area = GEGL_OPERATION_AREA_FILTER (operation);
+
+ rect = *result;
+
+ rect.x-=op_area->left;
+ rect.y-=op_area->top;
+ rect.width+=op_area->left + op_area->right;
+ rect.height+=op_area->top + op_area->bottom;
- temp = gegl_buffer_new (gegl_buffer_get_extent (input),
+ temp = gegl_buffer_new (&rect,
babl_format ("RaGaBaA float"));
- hor_blur (input, temp, o->radius);
- ver_blur (temp, output, o->radius);
+ hor_blur (input, &rect, temp, &rect, o->radius);
+ ver_blur (temp, &rect, output, result, o->radius);
g_object_unref (temp);
return TRUE;
diff --git a/operations/common/c2g.c b/operations/common/c2g.c
index 29a1d71..53d5e4e 100644
--- a/operations/common/c2g.c
+++ b/operations/common/c2g.c
@@ -47,27 +47,29 @@ gegl_chant_double (rgamma, _("Radial Gamma"), 0.0, 8.0, 2.0,
#define RGAMMA 2.0
-static void stress (GeglBuffer *src,
- GeglBuffer *dst,
- gint radius,
- gint samples,
- gint iterations,
- gdouble rgamma)
+static void c2g (GeglBuffer *src,
+ const GeglRectangle *src_rect,
+ GeglBuffer *dst,
+ const GeglRectangle *dst_rect,
+ gint radius,
+ gint samples,
+ gint iterations,
+ gdouble rgamma)
{
gint x,y;
gint dst_offset=0;
gfloat *src_buf;
gfloat *dst_buf;
- gint inw = gegl_buffer_get_width (src);
- gint outw = gegl_buffer_get_width (dst);
- gint inh = gegl_buffer_get_height (src);
+ gint inw = src_rect->width;
+ gint outw = dst_rect->width;
+ gint inh = src_rect->height;
- src_buf = g_new0 (gfloat, gegl_buffer_get_pixel_count (src) * 4);
- dst_buf = g_new0 (gfloat, gegl_buffer_get_pixel_count (dst) * 2);
+ src_buf = g_new0 (gfloat, src_rect->width * src_rect->height * 4);
+ dst_buf = g_new0 (gfloat, dst_rect->width * dst_rect->height * 2);
- gegl_buffer_get (src, 1.0, NULL, babl_format ("RGBA float"), src_buf, GEGL_AUTO_ROWSTRIDE);
+ gegl_buffer_get (src, 1.0, src_rect, babl_format ("RGBA float"), src_buf, GEGL_AUTO_ROWSTRIDE);
- for (y=radius; y<gegl_buffer_get_height (dst)+radius; y++)
+ for (y=radius; y<dst_rect->height+radius; y++)
{
gint src_offset = (inw*y+radius)*4;
for (x=radius; x<outw+radius; x++)
@@ -120,7 +122,7 @@ static void stress (GeglBuffer *src,
}
}
}
- gegl_buffer_set (dst, NULL, babl_format ("YA float"), dst_buf, GEGL_AUTO_ROWSTRIDE);
+ gegl_buffer_set (dst, dst_rect, babl_format ("YA float"), dst_buf, GEGL_AUTO_ROWSTRIDE);
g_free (src_buf);
g_free (dst_buf);
}
@@ -151,12 +153,14 @@ process (GeglOperation *operation,
const GeglRectangle *result)
{
GeglChantO *o = GEGL_CHANT_PROPERTIES (operation);
-
- stress (input, output,
- o->radius,
- o->samples,
- o->iterations,
- /*o->rgamma*/RGAMMA);
+ GeglRectangle compute;
+ compute = gegl_operation_get_required_for_output (operation, "input",result);
+
+ c2g (input, &compute, output, result,
+ o->radius,
+ o->samples,
+ o->iterations,
+ /*o->rgamma*/RGAMMA);
return TRUE;
}
diff --git a/operations/common/gaussian-blur.c b/operations/common/gaussian-blur.c
index 06e59e2..4bb503d 100644
--- a/operations/common/gaussian-blur.c
+++ b/operations/common/gaussian-blur.c
@@ -48,18 +48,6 @@ gegl_chant_string (filter, _("Filter"), "auto",
static void
-iir_young_hor_blur (GeglBuffer *src,
- GeglBuffer *dst,
- gdouble B,
- gdouble *b);
-
-static void
-iir_young_ver_blur (GeglBuffer *src,
- GeglBuffer *dst,
- gdouble B,
- gdouble *b);
-
-static void
iir_young_find_constants (gfloat radius,
gdouble *B,
gdouble *b);
@@ -68,20 +56,6 @@ static gint
fir_gen_convolve_matrix (gdouble sigma,
gdouble **cmatrix_p);
-static void
-fir_hor_blur (GeglBuffer *src,
- GeglBuffer *dst,
- gdouble *cmatrix,
- gint matrix_length,
- gint xoff);
-
-static void
-fir_ver_blur (GeglBuffer *src,
- GeglBuffer *dst,
- gdouble *cmatrix,
- gint matrix_length,
- gint yoff);
-
static void
iir_young_find_constants (gfloat sigma,
@@ -171,10 +145,12 @@ iir_young_blur_1D (gfloat * buf,
/* expects src and dst buf to have the same height and no y-offset */
static void
-iir_young_hor_blur (GeglBuffer *src,
- GeglBuffer *dst,
- gdouble B,
- gdouble *b)
+iir_young_hor_blur (GeglBuffer *src,
+ const GeglRectangle *src_rect,
+ GeglBuffer *dst,
+ const GeglRectangle *dst_rect,
+ gdouble B,
+ gdouble *b)
{
gint v;
gint c;
@@ -182,19 +158,19 @@ iir_young_hor_blur (GeglBuffer *src,
gfloat *buf;
gfloat *w;
- buf = g_new0 (gfloat, gegl_buffer_get_pixel_count (src) * 4);
- w = g_new0 (gfloat, gegl_buffer_get_width (src));
+ buf = g_new0 (gfloat, src_rect->height * src_rect->width * 4);
+ w = g_new0 (gfloat, src_rect->width);
- gegl_buffer_get (src, 1.0, NULL, babl_format ("RaGaBaA float"),
+ gegl_buffer_get (src, 1.0, src_rect, babl_format ("RaGaBaA float"),
buf, GEGL_AUTO_ROWSTRIDE);
- w_len = gegl_buffer_get_width (src);
- for (v=0; v<gegl_buffer_get_height (src); v++)
+ w_len = src_rect->width;
+ for (v=0; v<src_rect->height; v++)
{
for (c = 0; c < 4; c++)
{
iir_young_blur_1D (buf,
- v*gegl_buffer_get_width (src)*4+c,
+ v*src_rect->width*4+c,
4,
B,
b,
@@ -203,7 +179,7 @@ iir_young_hor_blur (GeglBuffer *src,
}
}
- gegl_buffer_set (dst, gegl_buffer_get_extent(src), babl_format ("RaGaBaA float"),
+ gegl_buffer_set (dst, src_rect, babl_format ("RaGaBaA float"),
buf, GEGL_AUTO_ROWSTRIDE);
g_free (buf);
g_free (w);
@@ -211,10 +187,12 @@ iir_young_hor_blur (GeglBuffer *src,
/* expects src and dst buf to have the same width and no x-offset */
static void
-iir_young_ver_blur (GeglBuffer *src,
- GeglBuffer *dst,
- gdouble B,
- gdouble *b)
+iir_young_ver_blur (GeglBuffer *src,
+ const GeglRectangle *src_rect,
+ GeglBuffer *dst,
+ const GeglRectangle *dst_rect,
+ gdouble B,
+ gdouble *b)
{
gint u;
gint c;
@@ -222,19 +200,19 @@ iir_young_ver_blur (GeglBuffer *src,
gfloat *buf;
gfloat *w;
- buf = g_new0 (gfloat, gegl_buffer_get_pixel_count (src) * 4);
- w = g_new0 (gfloat, gegl_buffer_get_height (src));
+ buf = g_new0 (gfloat, src_rect->height * src_rect->width * 4);
+ w = g_new0 (gfloat, src_rect->height);
- gegl_buffer_get (src, 1.0, NULL, babl_format ("RaGaBaA float"), buf, GEGL_AUTO_ROWSTRIDE);
+ gegl_buffer_get (src, 1.0, src_rect, babl_format ("RaGaBaA float"), buf, GEGL_AUTO_ROWSTRIDE);
- w_len = gegl_buffer_get_height (src);
- for (u=0; u<gegl_buffer_get_width (dst); u++)
+ w_len = src_rect->height;
+ for (u=0; u<dst_rect->width; u++)
{
for (c = 0; c < 4; c++)
{
iir_young_blur_1D (buf,
u*4 + c,
- gegl_buffer_get_width (src)*4,
+ src_rect->width*4,
B,
b,
w,
@@ -242,7 +220,7 @@ iir_young_ver_blur (GeglBuffer *src,
}
}
- gegl_buffer_set (dst, gegl_buffer_get_extent (src),
+ gegl_buffer_set (dst, src_rect,
babl_format ("RaGaBaA float"), buf, GEGL_AUTO_ROWSTRIDE);
g_free (buf);
g_free (w);
@@ -324,30 +302,32 @@ fir_get_mean_component_1D (gfloat * buf,
/* expects src and dst buf to have the same height and no y-offset */
static void
-fir_hor_blur (GeglBuffer *src,
- GeglBuffer *dst,
- gdouble *cmatrix,
- gint matrix_length,
- gint xoff) /* offset between src and dst */
+fir_hor_blur (GeglBuffer *src,
+ const GeglRectangle *src_rect,
+ GeglBuffer *dst,
+ const GeglRectangle *dst_rect,
+ gdouble *cmatrix,
+ gint matrix_length,
+ gint xoff) /* offset between src and dst */
{
gint u,v;
gint offset;
gfloat *src_buf;
gfloat *dst_buf;
const gint radius = matrix_length/2;
- const gint src_width = gegl_buffer_get_width (src);
+ const gint src_width = src_rect->width;
g_assert (xoff >= radius);
- src_buf = g_new0 (gfloat, gegl_buffer_get_pixel_count (src) * 4);
- dst_buf = g_new0 (gfloat, gegl_buffer_get_pixel_count (dst) * 4);
+ src_buf = g_new0 (gfloat, src_rect->height * src_rect->width * 4);
+ dst_buf = g_new0 (gfloat, dst_rect->height * dst_rect->width * 4);
- gegl_buffer_get (src, 1.0, NULL, babl_format ("RaGaBaA float"),
+ gegl_buffer_get (src, 1.0, src_rect, babl_format ("RaGaBaA float"),
src_buf, GEGL_AUTO_ROWSTRIDE);
offset = 0;
- for (v=0; v<gegl_buffer_get_height (dst); v++)
- for (u=0; u<gegl_buffer_get_width (dst); u++)
+ for (v=0; v<dst_rect->height; v++)
+ for (u=0; u<dst_rect->width; u++)
{
gint src_offset = (u-radius+xoff + v*src_width) * 4;
gint c;
@@ -359,38 +339,40 @@ fir_hor_blur (GeglBuffer *src,
matrix_length);
}
- gegl_buffer_set (dst, NULL, babl_format ("RaGaBaA float"),
+ gegl_buffer_set (dst, dst_rect, babl_format ("RaGaBaA float"),
dst_buf, GEGL_AUTO_ROWSTRIDE);
g_free (src_buf);
g_free (dst_buf);
}
/* expects src and dst buf to have the same width and no x-offset */
-void
-fir_ver_blur (GeglBuffer *src,
- GeglBuffer *dst,
- gdouble *cmatrix,
- gint matrix_length,
- gint yoff) /* offset between src and dst */
+static void
+fir_ver_blur (GeglBuffer *src,
+ const GeglRectangle *src_rect,
+ GeglBuffer *dst,
+ const GeglRectangle *dst_rect,
+ gdouble *cmatrix,
+ gint matrix_length,
+ gint yoff) /* offset between src and dst */
{
gint u,v;
gint offset;
gfloat *src_buf;
gfloat *dst_buf;
const gint radius = matrix_length/2;
- const gint src_width = gegl_buffer_get_width (src);
+ const gint src_width = src_rect->width;
g_assert (yoff >= radius);
- src_buf = g_new0 (gfloat, gegl_buffer_get_pixel_count (src) * 4);
- dst_buf = g_new0 (gfloat, gegl_buffer_get_pixel_count (dst) * 4);
+ src_buf = g_new0 (gfloat, src_rect->width * src_rect->height * 4);
+ dst_buf = g_new0 (gfloat, dst_rect->width * dst_rect->height * 4);
- gegl_buffer_get (src, 1.0, NULL, babl_format ("RaGaBaA float"),
+ gegl_buffer_get (src, 1.0, src_rect, babl_format ("RaGaBaA float"),
src_buf, GEGL_AUTO_ROWSTRIDE);
offset=0;
- for (v=0; v<gegl_buffer_get_height (dst); v++)
- for (u=0; u<gegl_buffer_get_width (dst); u++)
+ for (v=0; v< dst_rect->height; v++)
+ for (u=0; u< dst_rect->width; u++)
{
gint src_offset = (u + (v-radius+yoff)*src_width) * 4;
gint c;
@@ -436,10 +418,11 @@ process (GeglOperation *operation,
GeglBuffer *output,
const GeglRectangle *result)
{
+ GeglRectangle rect;
+ GeglBuffer *temp;
GeglOperationAreaFilter *op_area = GEGL_OPERATION_AREA_FILTER (operation);
GeglChantO *o = GEGL_CHANT_PROPERTIES (operation);
- GeglBuffer *temp;
GeglRectangle temp_extend;
gdouble B, b[4];
gdouble *cmatrix;
@@ -447,36 +430,43 @@ process (GeglOperation *operation,
gboolean force_iir;
gboolean force_fir;
- temp_extend.x = gegl_buffer_get_x (output);
- temp_extend.width = gegl_buffer_get_width (output);
- temp_extend.y = gegl_buffer_get_y (input);
- temp_extend.height = gegl_buffer_get_height (input);
+ rect.x = result->x - op_area->left;
+ rect.width = result->width + op_area->left + op_area->right;
+ rect.y = result->y - op_area->top;
+ rect.height = result->height + op_area->top + op_area->bottom;
+
+ temp_extend = rect;
+ temp_extend.x = result->x;
+ temp_extend.width = result->width;
temp = gegl_buffer_new (&temp_extend, babl_format ("RaGaBaA float"));
force_iir = o->filter && !strcmp (o->filter, "iir");
force_fir = o->filter && !strcmp (o->filter, "fir");
+ force_fir = TRUE;
+
if ((force_iir || o->std_dev_x > 1.0) && !force_fir)
{
iir_young_find_constants (o->std_dev_x, &B, b);
- iir_young_hor_blur (input, temp, B, b);
+ iir_young_hor_blur (input, &rect, temp, &temp_extend, B, b);
}
else
{
cmatrix_len = fir_gen_convolve_matrix (o->std_dev_x, &cmatrix);
- fir_hor_blur (input, temp, cmatrix, cmatrix_len, op_area->left);
+ fir_hor_blur (input, &rect, temp, &temp_extend, cmatrix, cmatrix_len, op_area->left);
g_free (cmatrix);
}
+
if ((force_iir || o->std_dev_y > 1.0) && !force_fir)
{
iir_young_find_constants (o->std_dev_y, &B, b);
- iir_young_ver_blur (temp, output, B, b);
+ iir_young_ver_blur (temp, &temp_extend, output, result, B, b);
}
else
{
cmatrix_len = fir_gen_convolve_matrix (o->std_dev_y, &cmatrix);
- fir_ver_blur (temp, output, cmatrix, cmatrix_len, op_area->top);
+ fir_ver_blur (temp, &temp_extend, output, result, cmatrix, cmatrix_len, op_area->top);
g_free (cmatrix);
}
diff --git a/operations/common/snn-mean.c b/operations/common/snn-mean.c
index 81cc537..a5f3c5f 100644
--- a/operations/common/snn-mean.c
+++ b/operations/common/snn-mean.c
@@ -37,10 +37,11 @@ gegl_chant_int (pairs, _("Pairs"), 1, 2, 2,
#include <math.h>
static void
-snn_mean (GeglBuffer *src,
- GeglBuffer *dst,
- gdouble radius,
- gint pairs);
+snn_mean (GeglBuffer *src,
+ GeglBuffer *dst,
+ const GeglRectangle *dst_rect,
+ gdouble radius,
+ gint pairs);
static void prepare (GeglOperation *operation)
@@ -74,7 +75,7 @@ process (GeglOperation *operation,
{
temp_in = gegl_buffer_create_sub_buffer (input, &compute);
- snn_mean (temp_in, output, o->radius, o->pairs);
+ snn_mean (temp_in, output, result, o->radius, o->pairs);
g_object_unref (temp_in);
}
@@ -104,10 +105,11 @@ static inline gfloat colordiff (gfloat *pixA,
static void
-snn_mean (GeglBuffer *src,
- GeglBuffer *dst,
- gdouble dradius,
- gint pairs)
+snn_mean (GeglBuffer *src,
+ GeglBuffer *dst,
+ const GeglRectangle *dst_rect,
+ gdouble dradius,
+ gint pairs)
{
gint x,y;
gint offset;
@@ -118,19 +120,19 @@ snn_mean (GeglBuffer *src,
gint src_height = gegl_buffer_get_height (src);
src_buf = g_new0 (gfloat, gegl_buffer_get_pixel_count (src) * 4);
- dst_buf = g_new0 (gfloat, gegl_buffer_get_pixel_count (dst) * 4);
+ dst_buf = g_new0 (gfloat, dst_rect->width * dst_rect->height * 4);
gegl_buffer_get (src, 1.0, NULL, babl_format ("RGBA float"), src_buf, GEGL_AUTO_ROWSTRIDE);
offset = 0;
- for (y=0; y<gegl_buffer_get_height (dst); y++)
+ for (y=0; y<dst_rect->height; y++)
{
gfloat *center_pix;
center_pix = src_buf + ((radius) + (y+radius)* src_width)*4;
- for (x=0; x<gegl_buffer_get_width (dst); x++)
+ for (x=0; x<dst_rect->width; x++)
{
gint u,v;
@@ -199,7 +201,7 @@ snn_mean (GeglBuffer *src,
center_pix += 4;
}
}
- gegl_buffer_set (dst, NULL, babl_format ("RGBA float"), dst_buf,
+ gegl_buffer_set (dst, dst_rect, babl_format ("RGBA float"), dst_buf,
GEGL_AUTO_ROWSTRIDE);
g_free (src_buf);
g_free (dst_buf);
diff --git a/operations/common/stress.c b/operations/common/stress.c
index 19cce68..cd840d4 100644
--- a/operations/common/stress.c
+++ b/operations/common/stress.c
@@ -55,31 +55,33 @@ gegl_chant_double (rgamma, _("Radial Gamma"), 0.0, 8.0, 2.0,
#include <stdlib.h>
#include "envelopes.h"
-static void stress (GeglBuffer *src,
- GeglBuffer *dst,
- gint radius,
- gint samples,
- gint iterations,
- gdouble rgamma)
+static void stress (GeglBuffer *src,
+ const GeglRectangle *src_rect,
+ GeglBuffer *dst,
+ const GeglRectangle *dst_rect,
+ gint radius,
+ gint samples,
+ gint iterations,
+ gdouble rgamma)
{
gint x,y;
gint dst_offset=0;
gfloat *src_buf;
gfloat *dst_buf;
- gint inw = gegl_buffer_get_width (src);
- gint inh = gegl_buffer_get_height (src);
- gint outw = gegl_buffer_get_width (dst);
+ gint inw = src_rect->width;
+ gint inh = src_rect->height;
+ gint outw = dst_rect->width;
/* this use of huge linear buffers should be avoided and
* most probably would lead to great speed ups
*/
- src_buf = g_new0 (gfloat, gegl_buffer_get_pixel_count (src) * 4);
- dst_buf = g_new0 (gfloat, gegl_buffer_get_pixel_count (dst) * 4);
+ src_buf = g_new0 (gfloat, src_rect->width * src_rect->height * 4);
+ dst_buf = g_new0 (gfloat, dst_rect->width * dst_rect->height * 4);
- gegl_buffer_get (src, 1.0, NULL, babl_format ("RGBA float"), src_buf, GEGL_AUTO_ROWSTRIDE);
+ gegl_buffer_get (src, 1.0, src_rect, babl_format ("RGBA float"), src_buf, GEGL_AUTO_ROWSTRIDE);
- for (y=radius; y<gegl_buffer_get_height (dst)+radius; y++)
+ for (y=radius; y<dst_rect->height+radius; y++)
{
gint src_offset = (inw*y+radius)*4;
for (x=radius; x<outw+radius; x++)
@@ -117,7 +119,7 @@ static void stress (GeglBuffer *src,
dst_offset+=4;
}
}
- gegl_buffer_set (dst, NULL, babl_format ("RGBA float"), dst_buf, GEGL_AUTO_ROWSTRIDE);
+ gegl_buffer_set (dst, dst_rect, babl_format ("RGBA float"), dst_buf, GEGL_AUTO_ROWSTRIDE);
g_free (src_buf);
g_free (dst_buf);
}
@@ -150,8 +152,10 @@ process (GeglOperation *operation,
const GeglRectangle *result)
{
GeglChantO *o = GEGL_CHANT_PROPERTIES (operation);
+ GeglRectangle compute;
+ compute = gegl_operation_get_required_for_output (operation, "input",result);
- stress (input, output,
+ stress (input, &compute, output, result,
o->radius,
o->samples,
o->iterations,
diff --git a/operations/external/text.c b/operations/external/text.c
index c653f16..17dfcf9 100644
--- a/operations/external/text.c
+++ b/operations/external/text.c
@@ -188,7 +188,7 @@ process (GeglOperation *operation,
cairo_translate (cr, -result->x, -result->y);
text_layout_text (self, cr, 0, NULL, NULL);
- gegl_buffer_set (output, NULL, babl_format ("B'aG'aR'aA u8"), data,
+ gegl_buffer_set (output, result, babl_format ("B'aG'aR'aA u8"), data,
GEGL_AUTO_ROWSTRIDE);
cairo_destroy (cr);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]