Commit 399d5e40 authored by Kevin Cozens's avatar Kevin Cozens

Minor formatting changes and function re-ordering for consistency with

	* operations/blur/box-blur.c:
	* operations/blur/gaussian-blur.c: Minor formatting changes and
	function re-ordering for consistency with other updated op files.

	* operations/color/brightness-contrast.c:
	* operations/color/contrast-curve.c:
	* operations/color/invert.c:
	* operations/color/levels.c:
	* operations/color/mono-mixer.c:
	* operations/color/stretch-contrast.c:
	* operations/color/threshold.c:
	* operations/color/value-invert.c:
	* operations/color/whitebalance.c: Updated to new chanting API.

svn path=/trunk/; revision=1907
parent 8d23b2ef
2008-01-24 Kevin Cozens <kcozens@cvs.gnome.org>
* operations/blur/box-blur.c:
* operations/blur/gaussian-blur.c: Minor formatting changes and
function re-ordering for consistency with other updated op files.
* operations/color/brightness-contrast.c:
* operations/color/contrast-curve.c:
* operations/color/invert.c:
* operations/color/levels.c:
* operations/color/mono-mixer.c:
* operations/color/stretch-contrast.c:
* operations/color/threshold.c:
* operations/color/value-invert.c:
* operations/color/whitebalance.c: Updated to new chanting API.
2008-01-24 Øyvind Kolås <pippin@gimp.org>
* gegl/gegl-chant.h: fixed mistake in handling of boiler-plate for
......
......@@ -17,12 +17,13 @@
*/
#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.")
gegl_chant_double (radius, 0.0, 200.0, 4.0, "Radius of square pixel region, (width and height will be radius*2+1).")
#else
#define GEGL_CHANT_TYPE_AREA_FILTER
#define GEGL_CHANT_C_FILE "box-blur.c"
#include "gegl-chant.h"
static void hor_blur (GeglBuffer *src,
......@@ -35,6 +36,20 @@ static void ver_blur (GeglBuffer *src,
#include <stdio.h>
static void tickle (GeglOperation *operation)
{
GeglChantO *o;
GeglOperationAreaFilter *op_area;
op_area = GEGL_OPERATION_AREA_FILTER (operation);
o = GEGL_CHANT_PROPERTIES (operation);
op_area->left =
op_area->right =
op_area->top =
op_area->bottom = ceil (o->radius);
}
static gboolean
process (GeglOperation *operation,
GeglBuffer *input,
......@@ -224,20 +239,6 @@ ver_blur (GeglBuffer *src,
#include <math.h>
static void tickle (GeglOperation *operation)
{
GeglChantO *o;
GeglOperationAreaFilter *op_area;
op_area = GEGL_OPERATION_AREA_FILTER (operation);
o = GEGL_CHANT_PROPERTIES (operation);
op_area->left =
op_area->right =
op_area->top =
op_area->bottom = ceil (o->radius);
}
static void
operation_class_init (GeglChantClass *klass)
......
......@@ -77,13 +77,22 @@ fir_ver_blur (GeglBuffer *src,
gint offsetX,
gint offsetY);
static void tickle (GeglOperation *operation)
{
GeglOperationAreaFilter *area = GEGL_OPERATION_AREA_FILTER (operation);
GeglChantO *o = GEGL_CHANT_PROPERTIES (operation);
area->left = area->right = ceil (o->std_dev_x * RADIUS_SCALE);
area->top = area->bottom = ceil (o->std_dev_y * RADIUS_SCALE);
}
static gboolean
process (GeglOperation *operation,
GeglBuffer *input,
GeglBuffer *output,
const GeglRectangle *result)
{
GeglChantO *o= GEGL_CHANT_PROPERTIES (operation);
GeglChantO *o = GEGL_CHANT_PROPERTIES (operation);
GeglBuffer *temp;
gdouble B, b[4];
gdouble *cmatrix;
......@@ -444,14 +453,6 @@ fir_ver_blur (GeglBuffer *src,
#include <math.h>
static void tickle (GeglOperation *operation)
{
GeglOperationAreaFilter *area = GEGL_OPERATION_AREA_FILTER (operation);
GeglChantO *o = GEGL_CHANT_PROPERTIES (operation);
area->left = area->right = ceil (o->std_dev_x * RADIUS_SCALE);
area->top = area->bottom = ceil (o->std_dev_y * RADIUS_SCALE);
}
static void
operation_class_init (GeglChantClass *klass)
......
......@@ -18,15 +18,13 @@
/* Followed by this #if ... */
#if GEGL_CHANT_PROPERTIES
#ifdef GEGL_CHANT_PROPERTIES
/* ... are the properties of the filter, these are all scalar values (doubles),
* the the parameters are:
* property name, min, max, default, "description of property" */
gegl_chant_double (contrast, -5.0, 5.0, 1.0,
"Range scale factor")
gegl_chant_double (brightness, -3.0, 3.0, 0.0,
"Amount to increase brightness")
gegl_chant_double (contrast, -5.0, 5.0, 1.0, "Range scale factor")
gegl_chant_double (brightness, -3.0, 3.0, 0.0, "Amount to increase brightness")
/* this will create the following structure for our use, and register the
* property with the given ranges, default values and a comment for the
......@@ -35,48 +33,22 @@ gegl_chant_double (brightness, -3.0, 3.0, 0.0,
#else
/* Following an else, is then the meta information for this operation */
#define GEGL_CHANT_NAME brightness_contrast
/* The name of the operation (with lower case here, _ and - are interchangeable
* when used by GEGL. */
#define GEGL_CHANT_SELF "brightness-contrast.c"
/* we need to specify the name of the source file for gegl-old-chant.height to
* do it's magic.
*/
#define GEGL_CHANT_POINT_FILTER
#define GEGL_CHANT_TYPE_POINT_FILTER
/* This sets the super class we are deriving from, in this case from the class
* point filter. With a point filter we only need to implement processing for a
* linear buffer
*/
#define GEGL_CHANT_DESCRIPTION "Changes the light level and contrast."
/* This string shows up in the documentation, and perhaps online help/
* operation browser/tooltips or similar.
*/
#define GEGL_CHANT_CATEGORIES "color"
/* A colon seperated list of categories/tags for this operation. */
#define GEGL_CHANT_PREPARE
/* here we specify that we've got our own preparation function, that is
* run during preparations for processing.
#define GEGL_CHANT_C_FILE "brightness-contrast.c"
/* we need to specify the name of the source file for gegl-old-chant.height to
* do it's magic.
*/
/* gegl-chant, uses the properties defined at the top, and the configuration
* in the preceding lines to generate a GObject plug-in.
*/
#include "gegl-old-chant.h"
static void prepare (GeglOperation *operation)
{
/* set the babl format this operation prefers to work on */
gegl_operation_set_format (operation, "input", babl_format ("RGBA float"));
gegl_operation_set_format (operation, "output", babl_format ("RGBA float"));
}
#include "gegl-chant.h"
/* GeglOperationPointFilter gives us a linear buffer to operate on
* in our requested pixel format
......@@ -87,12 +59,11 @@ process (GeglOperation *op,
void *out_buf,
glong n_pixels)
{
GeglChantOperation *self;
gfloat *pixel;
glong i;
GeglChantO *o = GEGL_CHANT_PROPERTIES (op);
gfloat *pixel;
glong i;
self = GEGL_CHANT_OPERATION (op);
pixel = in_buf;
pixel = in_buf;
for (i=0; i<n_pixels; i++)
{
......@@ -100,7 +71,7 @@ process (GeglOperation *op,
for (component=0; component<3; component++)
{
gfloat c = pixel[component];
c = (c - 0.5) * self->contrast + self->brightness + 0.5;
c = (c - 0.5) * o->contrast + o->brightness + 0.5;
pixel[component] = c;
}
pixel += 4;
......@@ -108,4 +79,29 @@ process (GeglOperation *op,
return TRUE;
}
#endif /* closing #if GEGL_CHANT_PROPERTIES ... else ... */
static void prepare (GeglOperation *operation)
{
/* set the babl format this operation prefers to work on */
gegl_operation_set_format (operation, "input", babl_format ("RGBA float"));
gegl_operation_set_format (operation, "output", babl_format ("RGBA float"));
}
static void
operation_class_init (GeglChantClass *klass)
{
GeglOperationClass *operation_class;
GeglOperationPointFilterClass *point_filter_class;
operation_class = GEGL_OPERATION_CLASS (klass);
point_filter_class = GEGL_OPERATION_POINT_FILTER_CLASS (klass);
point_filter_class->process = process;
operation_class->prepare = prepare;
operation_class->name = "brightness-contrast";
operation_class->categories = "color";
operation_class->description = "Changes the light level and contrast.";
}
#endif /* closing #ifdef GEGL_CHANT_PROPERTIES ... else ... */
......@@ -15,22 +15,17 @@
*
* Copyright 2007 Mark Probst <mark.probst@gmail.com>
*/
#if GEGL_CHANT_PROPERTIES
#ifdef GEGL_CHANT_PROPERTIES
gegl_chant_int (sampling_points, 0, 65536, 0, "Number of curve sampling points. 0 for exact calculation.")
gegl_chant_curve (curve, "The contrast curve.")
#else
#define GEGL_CHANT_NAME contrast_curve
#define GEGL_CHANT_SELF "contrast-curve.c"
#define GEGL_CHANT_DESCRIPTION "Adjusts the contrast of the image according to a curve."
#define GEGL_CHANT_CATEGORIES "color"
#define GEGL_CHANT_TYPE_POINT_FILTER
#define GEGL_CHANT_C_FILE "contrast-curve.c"
#define GEGL_CHANT_POINT_FILTER
#define GEGL_CHANT_PREPARE
#include "gegl-old-chant.h"
#include "gegl-chant.h"
static void prepare (GeglOperation *operation)
{
......@@ -46,23 +41,23 @@ process (GeglOperation *op,
void *out_buf,
glong samples)
{
GeglChantOperation *self;
GeglChantO *o = GEGL_CHANT_PROPERTIES (op);
gint num_sampling_points;
GeglCurve *curve;
gint i;
gfloat *in = in_buf;
gfloat *out = out_buf;
gint num_sampling_points;
gfloat *in = in_buf;
gfloat *out = out_buf;
gdouble *xs, *ys;
self = GEGL_CHANT_OPERATION (op);
num_sampling_points = self->sampling_points;
num_sampling_points = o->sampling_points;
curve = o->curve;
if (num_sampling_points > 0)
{
xs = g_new(gdouble, num_sampling_points);
ys = g_new(gdouble, num_sampling_points);
gegl_curve_calc_values(self->curve, 0.0, 1.0, num_sampling_points, xs, ys);
gegl_curve_calc_values(o->curve, 0.0, 1.0, num_sampling_points, xs, ys);
g_free(xs);
......@@ -92,7 +87,7 @@ process (GeglOperation *op,
{
gfloat u = in[0];
out[0] = gegl_curve_calc_value(self->curve, u);
out[0] = gegl_curve_calc_value(curve, u);
out[1]=in[1];
in += 2;
......@@ -102,4 +97,23 @@ process (GeglOperation *op,
return TRUE;
}
static void
operation_class_init (GeglChantClass *klass)
{
GeglOperationClass *operation_class;
GeglOperationPointFilterClass *point_filter_class;
operation_class = GEGL_OPERATION_CLASS (klass);
point_filter_class = GEGL_OPERATION_POINT_FILTER_CLASS (klass);
point_filter_class->process = process;
operation_class->prepare = prepare;
operation_class->name = "contrast-curve";
operation_class->categories = "color";
operation_class->description =
"Adjusts the contrast of the image according to a curve.";
}
#endif
......@@ -16,18 +16,21 @@
* Copyright 2006 Øyvind Kolås <pippin@gimp.org>
*/
#ifdef GEGL_CHANT_PROPERTIES
/* no properties */
#else
#define GEGL_CHANT_C_FILE "invert.c"
#define GEGL_CHANT_TYPE_POINT_FILTER
#define GEGL_CHANT_C_FILE "invert.c"
#include "gegl-chant.h"
static gboolean
process (GeglOperation *op,
void *in_buf,
void *out_buf,
glong samples)
glong samples)
{
glong i;
gfloat *in = in_buf;
......@@ -58,6 +61,7 @@ operation_class_init (GeglChantClass *klass)
operation_class = GEGL_OPERATION_CLASS (klass);
point_filter_class = GEGL_OPERATION_POINT_FILTER_CLASS (klass);
point_filter_class->process = process;
operation_class->name = "invert";
......
......@@ -16,7 +16,8 @@
* Copyright 2006 Øyvind Kolås <pippin@gimp.org>
*/
#if GEGL_CHANT_PROPERTIES
#ifdef GEGL_CHANT_PROPERTIES
gegl_chant_double (in_low, -1.0, 4.0, 0.0,
"Input luminance level to become lowest output")
gegl_chant_double (in_high, -1.0, 4.0, 1.0, "Input luminance level to become white.")
......@@ -25,15 +26,10 @@
#else
#define GEGL_CHANT_NAME levels
#define GEGL_CHANT_SELF "levels.c"
#define GEGL_CHANT_POINT_FILTER
#define GEGL_CHANT_DESCRIPTION "Remaps the intensity range of the image"
#define GEGL_CHANT_CATEGORIES "color"
#define GEGL_CHANT_TYPE_POINT_FILTER
#define GEGL_CHANT_C_FILE "levels.c"
#include "gegl-old-chant.h"
#include "gegl-chant.h"
/* GeglOperationPointFilter gives us a linear buffer to operate on
* in our requested pixel format
......@@ -44,26 +40,25 @@ process (GeglOperation *op,
void *out_buf,
glong n_pixels)
{
GeglChantOperation *self;
gfloat *pixel;
gfloat in_range;
gfloat out_range;
gfloat in_offset;
gfloat out_offset;
gfloat scale;
glong i;
self = GEGL_CHANT_OPERATION (op);
GeglChantO *o = GEGL_CHANT_PROPERTIES (op);
gfloat *pixel;
gfloat in_range;
gfloat out_range;
gfloat in_offset;
gfloat out_offset;
gfloat scale;
glong i;
pixel = in_buf;
in_offset = self->in_low * 1.0;
out_offset = self->out_low * 1.0;
in_range = self->in_high-self->in_low;
out_range = self->out_high-self->out_low;
in_offset = o->in_low * 1.0;
out_offset = o->out_low * 1.0;
in_range = o->in_high-o->in_low;
out_range = o->out_high-o->out_low;
if (in_range == 0.0)
in_range = 0.00000001;
scale = out_range/in_range;
for (i=0; i<n_pixels; i++)
......@@ -76,4 +71,22 @@ process (GeglOperation *op,
return TRUE;
}
static void
operation_class_init (GeglChantClass *klass)
{
GeglOperationClass *operation_class;
GeglOperationPointFilterClass *point_filter_class;
operation_class = GEGL_OPERATION_CLASS (klass);
point_filter_class = GEGL_OPERATION_POINT_FILTER_CLASS (klass);
point_filter_class->process = process;
operation_class->name = "levels";
operation_class->categories = "color";
operation_class->description =
"Remaps the intensity range of the image";
}
#endif
......@@ -17,22 +17,32 @@
*/
#ifdef GEGL_CHANT_PROPERTIES
gegl_chant_double (red, -10.0, 10.0, 0.5, "Amount of red")
gegl_chant_double (green, -10.0, 10.0, 0.25, "Amount of green")
gegl_chant_double (blue, -10.0, 10.0, 0.25, "Amount of blue")
#else
#define GEGL_CHANT_C_FILE "mono-mixer.c"
#define GEGL_CHANT_TYPE_FILTER
#define GEGL_CHANT_C_FILE "mono-mixer.c"
#include "gegl-chant.h"
static void prepare (GeglOperation *operation)
{
/* set the babl format this operation prefers to work on */
gegl_operation_set_format (operation, "input", babl_format ("RGBA float"));
gegl_operation_set_format (operation, "output", babl_format ("YA float"));
}
static gboolean
process (GeglOperation *operation,
GeglBuffer *input,
GeglBuffer *output,
const GeglRectangle *result)
{
GeglChantO *o = GEGL_CHANT_PROPERTIES (operation);
GeglChantO *o = GEGL_CHANT_PROPERTIES (operation);
gfloat red = o->red;
gfloat green = o->green;
......@@ -73,21 +83,14 @@ process (GeglOperation *operation,
return TRUE;
}
static void prepare (GeglOperation *operation)
{
/* set the babl format this operation prefers to work on */
gegl_operation_set_format (operation, "input", babl_format ("RGBA float"));
gegl_operation_set_format (operation, "output", babl_format ("YA float"));
}
static void
operation_class_init (GeglChantClass *klass)
{
GeglOperationClass *operation_class;
GeglOperationFilterClass *filter_class;
operation_class = GEGL_OPERATION_CLASS (klass);
filter_class = GEGL_OPERATION_FILTER_CLASS (klass);
operation_class = GEGL_OPERATION_CLASS (klass);
filter_class = GEGL_OPERATION_FILTER_CLASS (klass);
filter_class->process = process;
operation_class->prepare = prepare;
......
......@@ -15,20 +15,14 @@
*
* Copyright 2006 Øyvind Kolås <pippin@gimp.org>
*/
#if GEGL_CHANT_PROPERTIES
#ifdef GEGL_CHANT_PROPERTIES
#else
#define GEGL_CHANT_FILTER
#define GEGL_CHANT_NAME stretch_contrast
#define GEGL_CHANT_DESCRIPTION "Scales the components of the buffer to be in the 0.0-1.0 range. This improves images that makes poor use of the available contrast (little contrast, very dark, or very bright images)."
#define GEGL_CHANT_TYPE_FILTER
#define GEGL_CHANT_C_FILE "stretch-contrast.c"
#define GEGL_CHANT_SELF "stretch-contrast.c"
#define GEGL_CHANT_CLASS_INIT /*< we need to modify the standard class init
of the super class */
#define GEGL_CHANT_CATEGORIES "color:enhance"
#define GEGL_CHANT_PREPARE
#include "gegl-old-chant.h"
#include "gegl-chant.h"
static gboolean
inner_process (gdouble min,
......@@ -80,6 +74,12 @@ buffer_get_min_max (GeglBuffer *buffer,
*max = tmax;
}
static void prepare (GeglOperation *operation)
{
gegl_operation_set_format (operation, "input", babl_format ("RGBA float"));
gegl_operation_set_format (operation, "output", babl_format ("RGBA float"));
}
static gboolean
process (GeglOperation *operation,
GeglBuffer *input,
......@@ -126,20 +126,29 @@ compute_input_request (GeglOperation *operation,
return result;
}
static void prepare (GeglOperation *operation)
{
gegl_operation_set_format (operation, "input", babl_format ("RGBA float"));
gegl_operation_set_format (operation, "output", babl_format ("RGBA float"));
}
/* This is called at the end of the gobject class_init function, the
* GEGL_CHANT_CLASS_INIT was needed to make this happen
*
* Here we override the standard passthrough options for the rect
* computations.
*/
static void class_init (GeglOperationClass *operation_class)
static void
operation_class_init (GeglChantClass *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->name = "stretch-contrast";
operation_class->categories = "color:enhance";
operation_class->description =
"Scales the components of the buffer to be in the 0.0-1.0 range. This improves images that makes poor use of the available contrast (little contrast, very dark, or very bright images).";
operation_class->compute_input_request = compute_input_request;
}
......
......@@ -15,21 +15,17 @@
*
* Copyright 2006 Øyvind Kolås <pippin@gimp.org>
*/
#if GEGL_CHANT_PROPERTIES
#ifdef GEGL_CHANT_PROPERTIES
gegl_chant_double (value, -10.0, 10.0, 0.5,
"Global threshold level (used when there is no auxiliary input buffer).")
#else
#define GEGL_CHANT_POINT_COMPOSER
#define GEGL_CHANT_NAME threshold
#define GEGL_CHANT_DESCRIPTION "Thresholds the image to white/black based on either the global value set in the value property, or per pixel from the aux input."
#define GEGL_CHANT_SELF "threshold.c"
#define GEGL_CHANT_CATEGORIES "color"
#define GEGL_CHANT_PREPARE
#define GEGL_CHANT_TYPE_POINT_COMPOSER
#define GEGL_CHANT_C_FILE "threshold.c"
#include "gegl-old-chant.h"
#include "gegl-chant.h"
static void prepare (GeglOperation *operation)
{
......@@ -45,15 +41,14 @@ process (GeglOperation *op,
void *out_buf,
glong n_pixels)
{
glong i;
gfloat *in = in_buf;
gfloat *out = out_buf;
gfloat *aux = aux_buf;
glong i;
if (aux == NULL)
{
gfloat value = GEGL_CHANT_OPERATION (op)->value;
gfloat value = GEGL_CHANT_PROPERTIES (op)->value;
for (i=0; i<n_pixels; i++)
{
gfloat c;
......@@ -86,4 +81,24 @@ process (GeglOperation *op,
}
return TRUE;
}
static void
operation_class_init (GeglChantClass *klass)
{
GeglOperationClass *operation_class;
GeglOperationPointComposerClass *point_composer_class;
operation_class = GEGL_OPERATION_CLASS (klass);
point_composer_class = GEGL_OPERATION_POINT_COMPOSER_CLASS (klass);
point_composer_class->process = process;
operation_class->prepare = prepare;
operation_class->name = "threshold";
operation_class->categories = "color";
operation_class->description =
"Thresholds the image to white/black based on either the global value"
" set in the value property, or per pixel from the aux input.";
}
#endif
......@@ -30,17 +30,16 @@
*
*/
#if GEGL_CHANT_PROPERTIES
#ifdef GEGL_CHANT_PROPERTIES
/* no properties */
#else
#define GEGL_CHANT_POINT_FILTER
#define GEGL_CHANT_NAME value_invert
#define GEGL_CHANT_DESCRIPTION "Inverts just the value component, the result is the corresponding `inverted' image."
#define GEGL_CHANT_SELF "value-invert.c"
#define GEGL_CHANT_CATEGORIES "color"
#define GEGL_CHANT_TYPE_POINT_FILTER
#define GEGL_CHANT_C_FILE "value-invert.c"
#include "gegl-old-chant.h"
#include "gegl-chant.h"
static gboolean
process (GeglOperation *op,
......@@ -110,5 +109,23 @@ process (GeglOperation *op,
return TRUE;
}
static void
operation_class_init (GeglChantClass *klass)
{
GeglOperationClass *operation_class;
GeglOperationPointFilterClass *point_filter_class;
operation_class = GEGL_OPERATION_CLASS (klass);
point_filter_class = GEGL_OPERATION_POINT_FILTER_CLASS (klass);
point_filter_class->process = process;
operation_class->name = "value-invert";
operation_class->categories = "color";
operation_class->description =
"Inverts just the value component, the result is the corresponding `inverted' image.";
}
#endif
......@@ -16,7 +16,8 @@
* Copyright 2006 Øyvind Kolås <pippin@gimp.org>
*/
#if GEGL_CHANT_PROPERTIES
#ifdef GEGL_CHANT_PROPERTIES
gegl_chant_double (high_a_delta, -2.0, 2.0, 0.0, "")
gegl_chant_double (high_b_delta, -2.0, 2.0, 0.0, "")
gegl_chant_double (low_a_delta, -2.0, 2.0, 0.0, "")
......@@ -25,16 +26,10 @@
#else
#define GEGL_CHANT_NAME whitebalance
#define GEGL_CHANT_SELF "whitebalance.c"
#define GEGL_CHANT_POINT_FILTER
#define GEGL_CHANT_DESCRIPTION "Allows changing the whitepoint and blackpoint of an image."
#define GEGL_CHANT_CATEGORIES "color"
#define GEGL_CHANT_PREPARE
#define GEGL_CHANT_TYPE_POINT_FILTER
#define GEGL_CHANT_C_FILE "whitebalance.c"
#include "gegl-old-chant.h"
#include "gegl-chant.h"
static void prepare (GeglOperation *operation)
{
......@@ -52,31 +47,49 @@ process (GeglOperation *op,
void *out_buf,
glong n_pixels)
{
GeglChantOperation *self;
gfloat *pixel;
gfloat a_base;
gfloat a_scale;
gfloat b_base;
gfloat b_scale;
glong i;