|
Packit Service |
2781ba |
/* This file is an image processing operation for GEGL
|
|
Packit Service |
2781ba |
*
|
|
Packit Service |
2781ba |
* GEGL is free software; you can redistribute it and/or
|
|
Packit Service |
2781ba |
* modify it under the terms of the GNU Lesser General Public
|
|
Packit Service |
2781ba |
* License as published by the Free Software Foundation; either
|
|
Packit Service |
2781ba |
* version 3 of the License, or (at your option) any later version.
|
|
Packit Service |
2781ba |
*
|
|
Packit Service |
2781ba |
* GEGL is distributed in the hope that it will be useful,
|
|
Packit Service |
2781ba |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit Service |
2781ba |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Packit Service |
2781ba |
* Lesser General Public License for more details.
|
|
Packit Service |
2781ba |
*
|
|
Packit Service |
2781ba |
* You should have received a copy of the GNU Lesser General Public
|
|
Packit Service |
2781ba |
* License along with GEGL; if not, see <http://www.gnu.org/licenses/>.
|
|
Packit Service |
2781ba |
*
|
|
Packit Service |
2781ba |
* Copyright 2006 Øyvind Kolås <pippin@gimp.org>
|
|
Packit Service |
2781ba |
*/
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
#include "config.h"
|
|
Packit Service |
2781ba |
#include <glib/gi18n-lib.h>
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
#ifdef GEGL_CHANT_PROPERTIES
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
gegl_chant_double (dampness, _("Dampness"), 0.0, 1.0, 0.95,
|
|
Packit Service |
2781ba |
_("The value represents the contribution of the past to the new frame."))
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
#else
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
#define GEGL_CHANT_TYPE_FILTER
|
|
Packit Service |
2781ba |
#define GEGL_CHANT_C_FILE "mblur.c"
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
#include "gegl-chant.h"
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
typedef struct
|
|
Packit Service |
2781ba |
{
|
|
Packit Service |
2781ba |
GeglBuffer *acc;
|
|
Packit Service |
2781ba |
} Priv;
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
static void
|
|
Packit Service |
2781ba |
init (GeglChantO *o)
|
|
Packit Service |
2781ba |
{
|
|
Packit Service |
2781ba |
Priv *priv = (Priv*)o->chant_data;
|
|
Packit Service |
2781ba |
GeglRectangle extent = {0,0,1024,1024};
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
g_assert (priv == NULL);
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
priv = g_new0 (Priv, 1);
|
|
Packit Service |
2781ba |
o->chant_data = (void*) priv;
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
priv->acc = gegl_buffer_new (&extent, babl_format ("RGBA float"));
|
|
Packit Service |
2781ba |
}
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
static void prepare (GeglOperation *operation)
|
|
Packit Service |
2781ba |
{
|
|
Packit Service |
2781ba |
gegl_operation_set_format (operation, "output", babl_format ("RGBA float"));
|
|
Packit Service |
2781ba |
}
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
static gboolean
|
|
Packit Service |
2781ba |
process (GeglOperation *operation,
|
|
Packit Service |
2781ba |
GeglBuffer *input,
|
|
Packit Service |
2781ba |
GeglBuffer *output,
|
|
Packit Service |
2781ba |
const GeglRectangle *result,
|
|
Packit Service |
2781ba |
gint level)
|
|
Packit Service |
2781ba |
{
|
|
Packit Service |
2781ba |
GeglChantO *o;
|
|
Packit Service |
2781ba |
Priv *p;
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
o = GEGL_CHANT_PROPERTIES (operation);
|
|
Packit Service |
2781ba |
p = (Priv*)o->chant_data;
|
|
Packit Service |
2781ba |
if (p == NULL)
|
|
Packit Service |
2781ba |
init (o);
|
|
Packit Service |
2781ba |
p = (Priv*)o->chant_data;
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
{
|
|
Packit Service |
2781ba |
GeglBuffer *temp_in;
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
temp_in = gegl_buffer_create_sub_buffer (input, result);
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
{
|
|
Packit Service |
2781ba |
gint pixels = result->width * result->height;
|
|
Packit Service |
2781ba |
gfloat *buf = g_new (gfloat, pixels * 4);
|
|
Packit Service |
2781ba |
gfloat *acc = g_new (gfloat, pixels * 4);
|
|
Packit Service |
2781ba |
gfloat dampness;
|
|
Packit Service |
2781ba |
gint i;
|
|
Packit Service |
2781ba |
gegl_buffer_get (p->acc, result, 1.0, babl_format ("RGBA float"), acc, GEGL_AUTO_ROWSTRIDE, GEGL_ABYSS_NONE);
|
|
Packit Service |
2781ba |
gegl_buffer_get (temp_in, result, 1.0, babl_format ("RGBA float"), buf, GEGL_AUTO_ROWSTRIDE, GEGL_ABYSS_NONE);
|
|
Packit Service |
2781ba |
dampness = o->dampness;
|
|
Packit Service |
2781ba |
for (i=0;i
|
|
Packit Service |
2781ba |
{
|
|
Packit Service |
2781ba |
gint c;
|
|
Packit Service |
2781ba |
for (c=0;c<4;c++)
|
|
Packit Service |
2781ba |
acc[i*4+c]=acc[i*4+c]*dampness + buf[i*4+c]*(1.0-dampness);
|
|
Packit Service |
2781ba |
}
|
|
Packit Service |
2781ba |
gegl_buffer_set (p->acc, result, 0, babl_format ("RGBA float"), acc, GEGL_AUTO_ROWSTRIDE);
|
|
Packit Service |
2781ba |
gegl_buffer_set (output, result, 0, babl_format ("RGBA float"), acc, GEGL_AUTO_ROWSTRIDE);
|
|
Packit Service |
2781ba |
g_free (buf);
|
|
Packit Service |
2781ba |
g_free (acc);
|
|
Packit Service |
2781ba |
}
|
|
Packit Service |
2781ba |
g_object_unref (temp_in);
|
|
Packit Service |
2781ba |
}
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
return TRUE;
|
|
Packit Service |
2781ba |
}
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
static void
|
|
Packit Service |
2781ba |
finalize (GObject *object)
|
|
Packit Service |
2781ba |
{
|
|
Packit Service |
2781ba |
GeglChantO *o = GEGL_CHANT_PROPERTIES (object);
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
if (o->chant_data)
|
|
Packit Service |
2781ba |
{
|
|
Packit Service |
2781ba |
Priv *p = (Priv*)o->chant_data;
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
g_object_unref (p->acc);
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
g_free (o->chant_data);
|
|
Packit Service |
2781ba |
o->chant_data = NULL;
|
|
Packit Service |
2781ba |
}
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
G_OBJECT_CLASS (gegl_chant_parent_class)->finalize (object);
|
|
Packit Service |
2781ba |
}
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
static void
|
|
Packit Service |
2781ba |
gegl_chant_class_init (GeglChantClass *klass)
|
|
Packit Service |
2781ba |
{
|
|
Packit Service |
2781ba |
GeglOperationClass *operation_class;
|
|
Packit Service |
2781ba |
GeglOperationFilterClass *filter_class;
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
G_OBJECT_CLASS (klass)->finalize = finalize;
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
operation_class = GEGL_OPERATION_CLASS (klass);
|
|
Packit Service |
2781ba |
filter_class = GEGL_OPERATION_FILTER_CLASS (klass);
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
filter_class->process = process;
|
|
Packit Service |
2781ba |
operation_class->prepare = prepare;
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
gegl_operation_class_set_keys (operation_class,
|
|
Packit Service |
2781ba |
"name" , "gegl:mblur",
|
|
Packit Service |
2781ba |
"categories" , "blur:video",
|
|
Packit Service |
2781ba |
"description", _("Accumulating motion blur"),
|
|
Packit Service |
2781ba |
NULL);
|
|
Packit Service |
2781ba |
}
|
|
Packit Service |
2781ba |
|
|
Packit Service |
2781ba |
#endif
|