[gst-cvs] gst-plugins-bad: geometrictransform: Adds prepare function and cleanup

Thiago Sousa Santos thiagoss at kemper.freedesktop.org
Fri Jun 4 12:16:40 PDT 2010


Module: gst-plugins-bad
Branch: master
Commit: 8c5360a55968c829b4e267e933fa3ba15ab5f290
URL:    http://cgit.freedesktop.org/gstreamer/gst-plugins-bad/commit/?id=8c5360a55968c829b4e267e933fa3ba15ab5f290

Author: Thiago Santos <thiago.sousa.santos at collabora.co.uk>
Date:   Sun May 30 12:36:08 2010 -0300

geometrictransform: Adds prepare function and cleanup

Adds a prepare function to make subclasses precalculate values
that will be used throughout the mapping functions.

Also adds a missing cleanup to fix a memleak

---

 gst/geometrictransform/gstgeometrictransform.c |   16 +++++++++++++++-
 gst/geometrictransform/gstgeometrictransform.h |   10 ++++++++++
 2 files changed, 25 insertions(+), 1 deletions(-)

diff --git a/gst/geometrictransform/gstgeometrictransform.c b/gst/geometrictransform/gstgeometrictransform.c
index 3d5b0d3..13d3d04 100644
--- a/gst/geometrictransform/gstgeometrictransform.c
+++ b/gst/geometrictransform/gstgeometrictransform.c
@@ -61,6 +61,10 @@ gst_geometric_transform_generate_map (GstGeometricTransform * gt)
   /* subclass must have defined the map_func */
   g_return_val_if_fail (klass->map_func, FALSE);
 
+  if (klass->prepare_func)
+    if (!klass->prepare_func (gt))
+      return FALSE;
+
   /*
    * (x,y) pairs of the inverse mapping
    */
@@ -143,7 +147,6 @@ gst_geometric_transform_transform (GstBaseTransform * trans, GstBuffer * buf,
 
   gt = GST_GEOMETRIC_TRANSFORM (trans);
 
-  /* subclass must have defined the map_func */
   g_return_val_if_fail (gt->map, GST_FLOW_ERROR);
 
   ptr = gt->map;
@@ -157,6 +160,16 @@ gst_geometric_transform_transform (GstBaseTransform * trans, GstBuffer * buf,
   return ret;
 }
 
+static gboolean
+gst_geometric_transform_stop (GstBaseTransform * trans)
+{
+  GstGeometricTransform *gt = GST_GEOMETRIC_TRANSFORM (trans);
+
+  g_free (gt->map);
+
+  return TRUE;
+}
+
 static void
 gst_geometric_transform_base_init (gpointer g_class)
 {
@@ -177,6 +190,7 @@ gst_geometric_transform_class_init (gpointer klass, gpointer class_data)
 
   parent_class = g_type_class_peek_parent (klass);
 
+  trans_class->stop = GST_DEBUG_FUNCPTR (gst_geometric_transform_stop);
   trans_class->set_caps = GST_DEBUG_FUNCPTR (gst_geometric_transform_set_caps);
   trans_class->transform =
       GST_DEBUG_FUNCPTR (gst_geometric_transform_transform);
diff --git a/gst/geometrictransform/gstgeometrictransform.h b/gst/geometrictransform/gstgeometrictransform.h
index 4b9337a..1e8ddc8 100644
--- a/gst/geometrictransform/gstgeometrictransform.h
+++ b/gst/geometrictransform/gstgeometrictransform.h
@@ -59,6 +59,15 @@ typedef gboolean (*GstGeometricTransformMapFunc) (GstGeometricTransform * gt,
     gint x, gint y, gdouble * _input_x, gdouble *_input_y);
 
 /**
+ * GstGeometricTransformPrepareFunc:
+ *
+ * Called right before starting to calculate the mapping so that
+ * instances might precalculate some values.
+ */
+typedef gboolean (*GstGeometricTransformPrepareFunc) (
+    GstGeometricTransform * gt);
+
+/**
  * GstGeometricTransform:
  *
  * Opaque datastructure.
@@ -78,6 +87,7 @@ struct _GstGeometricTransformClass {
   GstVideoFilterClass parent_class;
 
   GstGeometricTransformMapFunc map_func;
+  GstGeometricTransformPrepareFunc prepare_func;
 };
 
 GType gst_geometric_transform_get_type (void);





More information about the Gstreamer-commits mailing list