summaryrefslogtreecommitdiff
path: root/gst
diff options
context:
space:
mode:
authorThiago Santos <thiago.sousa.santos@collabora.co.uk>2010-05-30 12:36:08 -0300
committerThiago Santos <thiago.sousa.santos@collabora.co.uk>2010-06-04 15:31:19 -0300
commit8c5360a55968c829b4e267e933fa3ba15ab5f290 (patch)
tree7afc4bb03a804610839c1548831b85b66e0a4ee1 /gst
parent6560248be99817de88ee4a40987793c1dbbfddb3 (diff)
downloadgstreamer-plugins-bad-8c5360a55968c829b4e267e933fa3ba15ab5f290.tar.gz
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
Diffstat (limited to 'gst')
-rw-r--r--gst/geometrictransform/gstgeometrictransform.c16
-rw-r--r--gst/geometrictransform/gstgeometrictransform.h10
2 files changed, 25 insertions, 1 deletions
diff --git a/gst/geometrictransform/gstgeometrictransform.c b/gst/geometrictransform/gstgeometrictransform.c
index 3d5b0d33d..13d3d0483 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 4b9337ab9..1e8ddc88c 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);