gegl r2394 - in trunk: . gegl/operation operations/common
- From: ok svn gnome org
- To: svn-commits-list gnome org
- Subject: gegl r2394 - in trunk: . gegl/operation operations/common
- Date: Sun, 8 Jun 2008 16:23:48 +0000 (UTC)
Author: ok
Date: Sun Jun 8 16:23:47 2008
New Revision: 2394
URL: http://svn.gnome.org/viewvc/gegl?rev=2394&view=rev
Log:
Added a new temporal base class, to be used as a base class for
operations operating on video needing access to data from neighbouring
frames.
* gegl/operation/gegl-operation-temporal.c: new file.
* gegl/operation/gegl-operation-temporal.h: new file.
* operations/common/Makefile.am: added new files.
Added:
trunk/gegl/operation/gegl-operation-temporal.c
trunk/gegl/operation/gegl-operation-temporal.h
Modified:
trunk/ChangeLog
trunk/operations/common/Makefile.am
Added: trunk/gegl/operation/gegl-operation-temporal.c
==============================================================================
--- (empty file)
+++ trunk/gegl/operation/gegl-operation-temporal.c Sun Jun 8 16:23:47 2008
@@ -0,0 +1,170 @@
+/* This file is part of GEGL
+ *
+ * GEGL is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * GEGL is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with GEGL; if not, see <http://www.gnu.org/licenses/>.
+ *
+ * Copyright 2008 Ãyvind KolÃs
+ */
+
+#define GEGL_INTERNAL
+
+#include "config.h"
+
+#include <glib-object.h>
+#include <string.h>
+#include "gegl-types.h"
+#include "gegl-operation-temporal.h"
+#include "gegl-utils.h"
+#include "graph/gegl-node.h"
+#include "graph/gegl-connection.h"
+#include "graph/gegl-pad.h"
+#include "buffer/gegl-region.h"
+#include "buffer/gegl-buffer.h"
+
+struct _GeglOperationTemporalPrivate
+{
+ gint count;
+ gint history_length;
+
+ gint width;
+ gint height;
+ gint next_to_write;
+ GeglBuffer *frame_store;
+};
+
+static void gegl_operation_temporal_prepare (GeglOperation *operation);
+
+G_DEFINE_TYPE (GeglOperationTemporal,
+ gegl_operation_temporal,
+ GEGL_TYPE_OPERATION_FILTER)
+
+#define GEGL_OPERATION_TEMPORAL_GET_PRIVATE(obj) \
+ G_TYPE_INSTANCE_GET_PRIVATE (obj, GEGL_TYPE_OPERATION_TEMPORAL, GeglOperationTemporalPrivate)
+
+
+
+GeglBuffer *
+gegl_operation_temporal_get_frame (GeglOperation *op,
+ gint frame)
+{
+ GeglOperationTemporal *temporal= GEGL_OPERATION_TEMPORAL (op);
+ GeglOperationTemporalPrivate *priv = temporal->priv;
+ GeglRectangle rect = {0, 0, priv->width, priv->height};
+ GeglBuffer *buffer;
+
+ if (frame * -1 > priv->count)
+ {
+ g_print ("%i > priv->count(%i), using frame 0", frame*-1, priv->count);
+ frame = 0;
+ }
+ else
+ {
+ frame = (priv->next_to_write - 1 + priv->history_length + frame) % priv->history_length;
+ }
+
+ rect.y = frame * priv->height;
+ buffer = gegl_buffer_create_sub_buffer (priv->frame_store, &rect);
+ return buffer;
+}
+
+static gboolean gegl_operation_temporal_process (GeglOperation *self,
+ GeglBuffer *input,
+ GeglBuffer *output,
+ const GeglRectangle *result)
+{
+ GeglOperationTemporal *temporal = GEGL_OPERATION_TEMPORAL (self);
+ GeglOperationTemporalPrivate *priv = temporal->priv;
+ GeglOperationTemporalClass *temporal_class;
+ GeglBuffer *temp_in;
+ gint pixels = result->width * result->height;
+ gfloat *buf = g_new (gfloat, pixels * 4 * 4);
+
+ temporal_class = GEGL_OPERATION_TEMPORAL_GET_CLASS (self);
+
+ priv->width = result->width;
+ priv->height = result->height;
+
+ temp_in = gegl_buffer_create_sub_buffer (input, result);
+ gegl_buffer_get (temp_in, 1.0, result,
+ babl_format ("RGBA float"), buf, GEGL_AUTO_ROWSTRIDE);
+ g_object_unref (temp_in);
+
+ {
+ GeglRectangle write_rect = *result;
+ write_rect.y = priv->next_to_write * priv->height;
+
+
+ gegl_buffer_set (priv->frame_store, &write_rect,
+ babl_format ("RGBA float"), buf, GEGL_AUTO_ROWSTRIDE);
+ priv->count++;
+ priv->next_to_write++;
+ if (priv->next_to_write >= priv->history_length)
+ priv->next_to_write=0;
+ }
+ g_free (buf);
+
+ if (temporal_class->process)
+ return temporal_class->process (self, input, output, result);
+ return FALSE;
+}
+
+static void gegl_operation_temporal_prepare (GeglOperation *operation)
+{
+ gegl_operation_set_format (operation, "output", babl_format ("RGBA float"));
+ gegl_operation_set_format (operation, "input", babl_format ("RGBA float"));
+}
+
+static void
+gegl_operation_temporal_class_init (GeglOperationTemporalClass *klass)
+{
+ GeglOperationClass *operation_class = GEGL_OPERATION_CLASS (klass);
+ GeglOperationFilterClass *operation_filter_class = GEGL_OPERATION_FILTER_CLASS (klass);
+
+ operation_class->prepare = gegl_operation_temporal_prepare;
+ operation_filter_class->process = gegl_operation_temporal_process;
+}
+
+static void
+gegl_operation_temporal_init (GeglOperationTemporal *self)
+{
+ GeglOperationTemporalPrivate *priv;
+ self->priv = GEGL_OPERATION_TEMPORAL_GET_PRIVATE(self);
+ priv=self->priv;
+ priv->count = 0;
+ priv->history_length = 500;
+ priv->width = 1024;
+ priv->height = 1024;
+ priv->next_to_write = 0;
+
+ /* FIXME: the format used for the frame_store should be autodetected from
+ * input
+ */
+ priv->frame_store =
+ gegl_buffer_new (&((GeglRectangle){0,0,4096,4096*600}), babl_format ("RGBA u8"));
+;
+}
+
+void gegl_operation_temporal_set_history_length (GeglOperation *op,
+ gint history_length)
+{
+ GeglOperationTemporal *self = GEGL_OPERATION_TEMPORAL (op);
+ GeglOperationTemporalPrivate *priv = self->priv;
+ priv->history_length = history_length;
+}
+
+guint gegl_operation_temporal_get_history_length (GeglOperation *op)
+{
+ GeglOperationTemporal *self = GEGL_OPERATION_TEMPORAL (op);
+ GeglOperationTemporalPrivate *priv = self->priv;
+ return priv->history_length;
+}
Added: trunk/gegl/operation/gegl-operation-temporal.h
==============================================================================
--- (empty file)
+++ trunk/gegl/operation/gegl-operation-temporal.h Sun Jun 8 16:23:47 2008
@@ -0,0 +1,65 @@
+/* This file is part of GEGL
+ *
+ * GEGL is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * GEGL is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with GEGL; if not, see <http://www.gnu.org/licenses/>.
+ *
+ * Copyright 2008 Ãyvind KolÃs
+ */
+
+#ifndef __GEGL_OPERATION_TEMPORAL_H__
+#define __GEGL_OPERATION_TEMPORAL_H__
+
+#include "gegl-operation-filter.h"
+
+G_BEGIN_DECLS
+
+#define GEGL_TYPE_OPERATION_TEMPORAL (gegl_operation_temporal_get_type ())
+#define GEGL_OPERATION_TEMPORAL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEGL_TYPE_OPERATION_TEMPORAL, GeglOperationTemporal))
+#define GEGL_OPERATION_TEMPORAL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GEGL_TYPE_OPERATION_TEMPORAL, GeglOperationTemporalClass))
+#define GEGL_IS_OPERATION_TEMPORAL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GEGL_TYPE_OPERATION_TEMPORAL))
+#define GEGL_IS_OPERATION_TEMPORAL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GEGL_TYPE_OPERATION_TEMPORAL))
+#define GEGL_OPERATION_TEMPORAL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GEGL_TYPE_OPERATION_TEMPORAL, GeglOperationTemporalClass))
+
+typedef struct _GeglOperationTemporal GeglOperationTemporal;
+typedef struct _GeglOperationTemporalPrivate GeglOperationTemporalPrivate;
+struct _GeglOperationTemporal
+{
+ GeglOperationFilter parent_instance;
+ GeglOperationTemporalPrivate *priv;
+};
+
+typedef struct _GeglOperationTemporalClass GeglOperationTemporalClass;
+struct _GeglOperationTemporalClass
+{
+ GeglOperationFilterClass parent_class;
+ gboolean (* process) (GeglOperation *self,
+ GeglBuffer *input,
+ GeglBuffer *output,
+ const GeglRectangle *roi);
+};
+
+GType gegl_operation_temporal_get_type (void) G_GNUC_CONST;
+
+void gegl_operation_temporal_set_history_length (GeglOperation *op,
+ gint history_length);
+
+guint gegl_operation_temporal_get_history_length (GeglOperation *op);
+
+/* you need to unref the buffer when you're done with it */
+GeglBuffer *gegl_operation_temporal_get_frame (GeglOperation *op,
+ gint frame);
+
+
+G_END_DECLS
+
+#endif
Modified: trunk/operations/common/Makefile.am
==============================================================================
--- trunk/operations/common/Makefile.am (original)
+++ trunk/operations/common/Makefile.am Sun Jun 8 16:23:47 2008
@@ -1,2 +1,11 @@
SUBDIRS = perlin
include $(top_srcdir)/operations/Makefile-operations.am
+
+all-local: invert-simd.la
+
+plugins += invert-simd.la
+
+invert-simd.la: invert.c $(GEGLHEADERS)
+ $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -DSIMD_COMPILE -c -o $ lo $<
+ $(LIBTOOL) --tag=CC --mode=link $(CC) $(AM_LDFLAGS) $(LDFLAGS) $(CFLAGS) $(LDADD) -o $@ -rpath $(ext_dir) $ lo
+
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]