mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-26 19:51:11 +00:00
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
This commit is contained in:
parent
6560248be9
commit
8c5360a559
2 changed files with 25 additions and 1 deletions
|
@ -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);
|
||||
|
|
|
@ -58,6 +58,15 @@ typedef struct _GstGeometricTransformClass GstGeometricTransformClass;
|
|||
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:
|
||||
*
|
||||
|
@ -78,6 +87,7 @@ struct _GstGeometricTransformClass {
|
|||
GstVideoFilterClass parent_class;
|
||||
|
||||
GstGeometricTransformMapFunc map_func;
|
||||
GstGeometricTransformPrepareFunc prepare_func;
|
||||
};
|
||||
|
||||
GType gst_geometric_transform_get_type (void);
|
||||
|
|
Loading…
Reference in a new issue