summaryrefslogtreecommitdiff
path: root/gst/geometrictransform/gstgeometrictransform.c
diff options
context:
space:
mode:
authorThiago Santos <thiago.sousa.santos@collabora.co.uk>2010-06-05 19:20:06 -0300
committerThiago Santos <thiago.sousa.santos@collabora.co.uk>2010-06-06 13:00:44 -0300
commite7d417f4fc0beea53cae36864cd67821a0e0893e (patch)
tree3c4c71fd3c28f438259ae5d26641624294ec9f16 /gst/geometrictransform/gstgeometrictransform.c
parent370a5049ba8b57023f0f40da1d8a801aa60735b1 (diff)
downloadgstreamer-plugins-bad-e7d417f4fc0beea53cae36864cd67821a0e0893e.tar.gz
geometrictransform: Make map precalculation optional
Adds a variable to be set to allow subclasses to enable or disable precalculation of the pixels mapping
Diffstat (limited to 'gst/geometrictransform/gstgeometrictransform.c')
-rw-r--r--gst/geometrictransform/gstgeometrictransform.c45
1 files changed, 32 insertions, 13 deletions
diff --git a/gst/geometrictransform/gstgeometrictransform.c b/gst/geometrictransform/gstgeometrictransform.c
index 56a7cb791..87fe1451e 100644
--- a/gst/geometrictransform/gstgeometrictransform.c
+++ b/gst/geometrictransform/gstgeometrictransform.c
@@ -92,10 +92,6 @@ 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
*/
@@ -130,8 +126,10 @@ gst_geometric_transform_set_caps (GstBaseTransform * btrans, GstCaps * incaps,
gboolean ret;
gint old_width;
gint old_height;
+ GstGeometricTransformClass *klass;
gt = GST_GEOMETRIC_TRANSFORM (btrans);
+ klass = GST_GEOMETRIC_TRANSFORM_GET_CLASS (gt);
old_width = gt->width;
old_height = gt->height;
@@ -145,7 +143,11 @@ gst_geometric_transform_set_caps (GstBaseTransform * btrans, GstCaps * incaps,
/* regenerate the map */
if (old_width == 0 || old_height == 0 || gt->width != old_width ||
gt->height != old_height) {
- gst_geometric_transform_generate_map (gt);
+ if (klass->prepare_func)
+ if (!klass->prepare_func (gt))
+ return FALSE;
+ if (gt->precalc_map)
+ gst_geometric_transform_generate_map (gt);
}
}
return ret;
@@ -199,22 +201,38 @@ gst_geometric_transform_transform (GstBaseTransform * trans, GstBuffer * buf,
GstBuffer * outbuf)
{
GstGeometricTransform *gt;
+ GstGeometricTransformClass *klass;
gint x, y;
GstFlowReturn ret = GST_FLOW_OK;
gdouble *ptr;
gt = GST_GEOMETRIC_TRANSFORM (trans);
-
- g_return_val_if_fail (gt->map, GST_FLOW_ERROR);
+ klass = GST_GEOMETRIC_TRANSFORM_GET_CLASS (gt);
memset (GST_BUFFER_DATA (outbuf), 0, GST_BUFFER_SIZE (outbuf));
- ptr = gt->map;
- for (y = 0; y < gt->height; y++) {
- for (x = 0; x < gt->width; x++) {
- /* do the mapping */
- gst_geometric_transform_do_map (gt, buf, outbuf, x, y, ptr[0], ptr[1]);
- ptr += 2;
+ if (gt->precalc_map) {
+ g_return_val_if_fail (gt->map, GST_FLOW_ERROR);
+ ptr = gt->map;
+ for (y = 0; y < gt->height; y++) {
+ for (x = 0; x < gt->width; x++) {
+ /* do the mapping */
+ gst_geometric_transform_do_map (gt, buf, outbuf, x, y, ptr[0], ptr[1]);
+ ptr += 2;
+ }
+ }
+ } else {
+ for (y = 0; y < gt->height; y++) {
+ for (x = 0; x < gt->width; x++) {
+ gdouble in_x, in_y;
+
+ if (klass->map_func (gt, x, y, &in_x, &in_y)) {
+ gst_geometric_transform_do_map (gt, buf, outbuf, x, y, in_x, in_y);
+ } else {
+ GST_WARNING_OBJECT (gt, "Failed to do mapping for %d %d", x, y);
+ return GST_FLOW_ERROR;
+ }
+ }
}
}
return ret;
@@ -312,6 +330,7 @@ gst_geometric_transform_init (GTypeInstance * instance, gpointer g_class)
GstGeometricTransform *gt = GST_GEOMETRIC_TRANSFORM (instance);
gt->off_edge_pixels = DEFAULT_OFF_EDGE_PIXELS;
+ gt->precalc_map = TRUE;
}
GType