gegl r1903 - in trunk: . operations/blur operations/workshop



Author: kcozens
Date: Wed Jan 23 22:40:21 2008
New Revision: 1903
URL: http://svn.gnome.org/viewvc/gegl?rev=1903&view=rev

Log:
	* operations/blur/gaussian_blur.c:
	* operations/workshop/box_max.c:
	* operations/workshop/box_min.c: updated to new chanting API.


Modified:
   trunk/ChangeLog
   trunk/operations/blur/gaussian-blur.c
   trunk/operations/workshop/box-max.c
   trunk/operations/workshop/box-min.c

Modified: trunk/operations/blur/gaussian-blur.c
==============================================================================
--- trunk/operations/blur/gaussian-blur.c	(original)
+++ trunk/operations/blur/gaussian-blur.c	Wed Jan 23 22:40:21 2008
@@ -21,7 +21,7 @@
  *       becomes very inaccurate.
  */
 
-#if GEGL_CHANT_PROPERTIES
+#ifdef GEGL_CHANT_PROPERTIES
 
 gegl_chant_double (std_dev_x, 0.0, 200.0, 4.0,
    "Standard deviation for the horizontal axis. (multiply by ~2 to get radius)")
@@ -32,13 +32,9 @@
 
 #else
 
-#define GEGL_CHANT_NAME            gaussian_blur
-#define GEGL_CHANT_SELF            "gaussian-blur.c"
-#define GEGL_CHANT_DESCRIPTION     "Performs an averaging of neighbouring pixels with the normal distribution as weighting."
-#define GEGL_CHANT_CATEGORIES      "blur"
-
-#define GEGL_CHANT_AREA_FILTER
-#include "gegl-old-chant.h"
+#define GEGL_CHANT_TYPE_AREA_FILTER
+#define GEGL_CHANT_C_FILE       "gaussian-blur.c"
+#include "gegl-chant.h"
 
 #include <math.h>
 #include <stdio.h>
@@ -87,47 +83,46 @@
          GeglBuffer          *output,
          const GeglRectangle *result)
 {
-  GeglChantOperation  *self;
+  GeglChantProperties *properties = GEGL_CHANT_PROPERTIES (operation);
   GeglBuffer          *temp;
+  gdouble              B, b[4];
+  gdouble             *cmatrix;
+  gint                 cmatrix_len;
 
-  self = GEGL_CHANT_OPERATION (operation);
   temp  = gegl_buffer_new (gegl_buffer_get_extent (input),
                            babl_format ("RaGaBaA float"));
 
-  {
-    gdouble B, b[4];
-    gdouble *cmatrix;
-    gint cmatrix_len;
-    gchar *filter = self->filter;
-    gboolean force_iir = filter && !strcmp (filter, "iir");
-    gboolean force_fir = filter && !strcmp (filter, "fir");
+  gchar   *filter = properties->filter;
+  gboolean force_iir = filter && !strcmp (filter, "iir");
+  gboolean force_fir = filter && !strcmp (filter, "fir");
 
-    if ((force_iir || self->std_dev_x > 1.0) && !force_fir)
-      {
-        iir_young_find_constants (self->std_dev_x, &B, b);
-        iir_young_hor_blur (input, temp,   B, b);
-      }
-    else
-      {
-        cmatrix_len =
-            fir_gen_convolve_matrix (self->std_dev_x, &cmatrix);
-        fir_hor_blur (input, temp, cmatrix, cmatrix_len);
-        g_free (cmatrix);
-      }
-    if ((force_iir || self->std_dev_y > 1.0) && !force_fir)
-      {
-        iir_young_find_constants (self->std_dev_y, &B, b);
-        iir_young_ver_blur (temp, output, B, b, self->std_dev_x * RADIUS_SCALE);
-      }
-    else
-      {
-        cmatrix_len =
-            fir_gen_convolve_matrix (self->std_dev_y, &cmatrix);
-        fir_ver_blur (temp, output, cmatrix, cmatrix_len,
-         self->std_dev_x * RADIUS_SCALE, self->std_dev_y * RADIUS_SCALE);
-        g_free (cmatrix);
-      }
-  }
+  if ((force_iir || properties->std_dev_x > 1.0) && !force_fir)
+    {
+      iir_young_find_constants (properties->std_dev_x, &B, b);
+      iir_young_hor_blur (input, temp,   B, b);
+    }
+  else
+    {
+      cmatrix_len =
+          fir_gen_convolve_matrix (properties->std_dev_x, &cmatrix);
+      fir_hor_blur (input, temp, cmatrix, cmatrix_len);
+      g_free (cmatrix);
+    }
+  if ((force_iir || properties->std_dev_y > 1.0) && !force_fir)
+    {
+      iir_young_find_constants (properties->std_dev_y, &B, b);
+      iir_young_ver_blur (temp, output, B, b,
+                          properties->std_dev_x * RADIUS_SCALE);
+    }
+  else
+    {
+      cmatrix_len =
+          fir_gen_convolve_matrix (properties->std_dev_y, &cmatrix);
+      fir_ver_blur (temp, output, cmatrix, cmatrix_len,
+       properties->std_dev_x * RADIUS_SCALE,
+       properties->std_dev_y * RADIUS_SCALE);
+      g_free (cmatrix);
+    }
 
   g_object_unref (temp);
   return  TRUE;
@@ -453,9 +448,28 @@
 static void tickle (GeglOperation *operation)
 {
   GeglOperationAreaFilter *area = GEGL_OPERATION_AREA_FILTER (operation);
-  GeglChantOperation      *blur = GEGL_CHANT_OPERATION (operation);
+  GeglChantProperties     *blur = GEGL_CHANT_PROPERTIES (operation);
   area->left = area->right = ceil (blur->std_dev_x * RADIUS_SCALE);
   area->top = area->bottom = ceil (blur->std_dev_y * RADIUS_SCALE);
 }
 
+
+static void
+operation_class_init (GeglChantOperationClass *klass)
+{
+  GeglOperationClass       *operation_class;
+  GeglOperationFilterClass *filter_class;
+
+  operation_class  = GEGL_OPERATION_CLASS (klass);
+  filter_class     = GEGL_OPERATION_FILTER_CLASS (klass);
+
+  filter_class->process   = process;
+  operation_class->tickle = tickle;
+
+  operation_class->categories = "blur";
+  operation_class->name       = "gaussian-blur";
+  operation_class->description =
+        "Performs an averaging of neighbouring pixels with the normal distribution as weighting.";
+}
+
 #endif

Modified: trunk/operations/workshop/box-max.c
==============================================================================
--- trunk/operations/workshop/box-max.c	(original)
+++ trunk/operations/workshop/box-max.c	Wed Jan 23 22:40:21 2008
@@ -15,22 +15,17 @@
  *
  * Copyright 2006 Ãyvind KolÃs <pippin gimp org>
  */
-#if GEGL_CHANT_PROPERTIES
+#ifdef GEGL_CHANT_PROPERTIES
 
 gegl_chant_double (radius, 0.0, 200.0, 4.0,
-  "Radius of square pixel region, (width and height will be radius*2+1.")
+  "Radius of square pixel region, (width and height will be radius*2+1.)")
 
 #else
 
-#define GEGL_CHANT_NAME            box_max
-#define GEGL_CHANT_SELF            "box-max.c"
-#define GEGL_CHANT_DESCRIPTION     "Sets the target pixel to the value of the maximum value in a box surrounding the pixel."
-#define GEGL_CHANT_CATEGORIES      "misc"
+#define GEGL_CHANT_TYPE_AREA_FILTER
+#define GEGL_CHANT_C_FILE       "box-max.c"
 
-#define GEGL_CHANT_AREA_FILTER
-#define GEGL_CHANT_PREPARE
-
-#include "gegl-old-chant.h"
+#include "gegl-chant.h"
 
 static void hor_max (GeglBuffer *src,
                      GeglBuffer *dst,
@@ -42,36 +37,22 @@
 
 #include <stdio.h>
 
-static void prepare (GeglOperation *operation)
-{
-  gegl_operation_set_format (operation, "output", babl_format ("RGBA float"));
-}
-
 static gboolean
 process (GeglOperation       *operation,
          GeglBuffer          *input,
          GeglBuffer          *output,
          const GeglRectangle *result)
 {
-  GeglOperationFilter *filter;
-  GeglChantOperation  *self;
+  GeglChantProperties *properties = GEGL_CHANT_PROPERTIES (operation);
+  GeglBuffer          *temp;
 
-  filter = GEGL_OPERATION_FILTER (operation);
-  self   = GEGL_CHANT_OPERATION (operation);
+  temp = gegl_buffer_new (gegl_buffer_get_extent (input),
+                          babl_format ("RGBA float"));
 
-    {
-      GeglBuffer   *temp_in;
-      GeglBuffer   *temp;
-      GeglRectangle compute = gegl_operation_compute_input_request (operation, "input", result);
-
-      temp_in = gegl_buffer_create_sub_buffer (input, &compute);
-      temp   = gegl_buffer_new (&compute, babl_format ("RGBA float"));
-
-      hor_max (temp_in, temp, self->radius);
-      ver_max (temp, output, self->radius);
-      g_object_unref (temp);
-      g_object_unref (temp_in);
-    }
+  hor_max (input, temp,  properties->radius);
+  ver_max (temp, output, properties->radius);
+
+  g_object_unref (temp);
 
   return  TRUE;
 }
@@ -86,9 +67,9 @@
                    gint    height,
                    gint    component)
 {
-  gint    x, y;
+  gint   x, y;
   gfloat max=-1000000000.0;
-  gint    count=0;
+  gint   count=0;
 
   gint offset = (y0 * buf_width + x0) * 4 + component;
 
@@ -142,7 +123,8 @@
                                i);
       }
 
-  gegl_buffer_set (dst, NULL, babl_format ("RGBA float"), dst_buf, GEGL_AUTO_ROWSTRIDE);
+  gegl_buffer_set (dst, NULL, babl_format ("RGBA float"), dst_buf,
+                   GEGL_AUTO_ROWSTRIDE);
   g_free (src_buf);
   g_free (dst_buf);
 }
@@ -181,18 +163,45 @@
                               c);
       }
 
-  gegl_buffer_set (dst, NULL, babl_format ("RGBA float"), dst_buf, GEGL_AUTO_ROWSTRIDE);
+  gegl_buffer_set (dst, NULL, babl_format ("RGBA float"), dst_buf,
+                   GEGL_AUTO_ROWSTRIDE);
   g_free (src_buf);
   g_free (dst_buf);
 }
 
 #include <math.h>
+
 static void tickle (GeglOperation *operation)
 {
   GeglOperationAreaFilter *area = GEGL_OPERATION_AREA_FILTER (operation);
-  GeglChantOperation      *filter = GEGL_CHANT_OPERATION (operation);
+  GeglChantProperties     *properties = GEGL_CHANT_PROPERTIES (operation);
   area->left = area->right = area->top = area->bottom =
-      ceil (filter->radius);
+      ceil (properties->radius);
+}
+
+
+static void prepare (GeglOperation *operation)
+{
+  gegl_operation_set_format (operation, "output", babl_format ("RGBA float"));
+}
+
+static void
+operation_class_init (GeglChantOperationClass *klass)
+{
+  GeglOperationClass       *operation_class;
+  GeglOperationFilterClass *filter_class;
+
+  operation_class  = GEGL_OPERATION_CLASS (klass);
+  filter_class     = GEGL_OPERATION_FILTER_CLASS (klass);
+
+  filter_class->process = process;
+  operation_class->prepare = prepare;
+  operation_class->tickle  = tickle;
+
+  operation_class->name       = "box-max";
+  operation_class->categories = "misc";
+  operation_class->description =
+        "Sets the target pixel to the value of the maximum value in a box surrounding the pixel.";
 }
 
 #endif

Modified: trunk/operations/workshop/box-min.c
==============================================================================
--- trunk/operations/workshop/box-min.c	(original)
+++ trunk/operations/workshop/box-min.c	Wed Jan 23 22:40:21 2008
@@ -15,22 +15,17 @@
  *
  * Copyright 2006 Ãyvind KolÃs <pippin gimp org>
  */
-#if GEGL_CHANT_PROPERTIES
+#ifdef GEGL_CHANT_PROPERTIES
 
 gegl_chant_double (radius, 0.0, 200.0, 4.0,
-  "Radius of square pixel region, (width and height will be radius*2+1.")
+  "Radius of square pixel region, (width and height will be radius*2+1.)")
 
 #else
 
-#define GEGL_CHANT_NAME            box_min
-#define GEGL_CHANT_SELF            "box-min.c"
-#define GEGL_CHANT_DESCRIPTION     "Sets the target pixel to the value of the minimum value in a box surrounding the pixel."
-#define GEGL_CHANT_CATEGORIES      "misc"
+#define GEGL_CHANT_TYPE_AREA_FILTER
+#define GEGL_CHANT_C_FILE       "box-min.c"
 
-#define GEGL_CHANT_AREA_FILTER
-#define GEGL_CHANT_PREPARE
-
-#include "gegl-old-chant.h"
+#include "gegl-chant.h"
 
 static void hor_min (GeglBuffer *src,
                      GeglBuffer *dst,
@@ -42,10 +37,6 @@
 
 #include <stdio.h>
 
-static void prepare (GeglOperation *operation)
-{
-  gegl_operation_set_format (operation, "output", babl_format ("RGBA float"));
-}
 
 static gboolean
 process (GeglOperation       *operation,
@@ -53,26 +44,16 @@
          GeglBuffer          *output,
          const GeglRectangle *result)
 {
-  GeglOperationFilter *filter;
-  GeglChantOperation  *self;
+  GeglChantProperties *properties = GEGL_CHANT_PROPERTIES (operation);
+  GeglBuffer          *temp;
 
-  filter = GEGL_OPERATION_FILTER (operation);
-  self   = GEGL_CHANT_OPERATION (operation);
+  temp = gegl_buffer_new (gegl_buffer_get_extent (input),
+                          babl_format ("RGBA float"));
 
-    {
-      GeglBuffer      *temp_in;
-      GeglBuffer      *temp;
-      GeglRectangle compute  = gegl_operation_compute_input_request (operation, "input", result);
+  hor_min (input, temp,  properties->radius);
+  ver_min (temp, output, properties->radius);
 
-      temp_in = gegl_buffer_create_sub_buffer (input, &compute);
-      temp   = gegl_buffer_new (&compute, babl_format ("RGBA float"));
-
-      hor_min (temp_in, temp,  self->radius);
-      ver_min (temp, output, self->radius);
-
-      g_object_unref (temp);
-      g_object_unref (temp_in);
-    }
+  g_object_unref (temp);
 
   return  TRUE;
 }
@@ -194,9 +175,34 @@
 static void tickle (GeglOperation *operation)
 {
   GeglOperationAreaFilter *area = GEGL_OPERATION_AREA_FILTER (operation);
-  GeglChantOperation      *filter = GEGL_CHANT_OPERATION (operation);
+  GeglChantProperties     *properties = GEGL_CHANT_PROPERTIES (operation);
   area->left = area->right = area->top = area->bottom =
-      ceil (filter->radius);
+      ceil (properties->radius);
+}
+
+
+static void prepare (GeglOperation *operation)
+{
+  gegl_operation_set_format (operation, "output", babl_format ("RGBA float"));
+}
+
+static void
+operation_class_init (GeglChantOperationClass *klass)
+{
+  GeglOperationClass       *operation_class;
+  GeglOperationFilterClass *filter_class;
+
+  operation_class  = GEGL_OPERATION_CLASS (klass);
+  filter_class     = GEGL_OPERATION_FILTER_CLASS (klass);
+
+  filter_class->process = process;
+  operation_class->prepare = prepare;
+  operation_class->tickle  = tickle;
+
+  operation_class->name       = "box-min";
+  operation_class->categories = "misc";
+  operation_class->description =
+        "Sets the target pixel to the value of the minimum value in a box surrounding the pixel.";
 }
 
 #endif



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]