From fd4a629825e2a0f5d4da4493ac182bc61056bf99 Mon Sep 17 00:00:00 2001 From: Filippo Argiolas Date: Mon, 9 Aug 2010 17:20:11 +0200 Subject: [PATCH] geometrictransform: add a "zoom" parameter to square filter https://bugzilla.gnome.org/show_bug.cgi?id=625908 --- gst/geometrictransform/gstsquare.c | 24 ++++++++++++++++++++++-- gst/geometrictransform/gstsquare.h | 1 + 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/gst/geometrictransform/gstsquare.c b/gst/geometrictransform/gstsquare.c index 5b5db5579c..eda6f43c57 100644 --- a/gst/geometrictransform/gstsquare.c +++ b/gst/geometrictransform/gstsquare.c @@ -58,10 +58,12 @@ enum PROP_0, PROP_WIDTH, PROP_HEIGHT, + PROP_ZOOM }; #define DEFAULT_WIDTH 0.5 #define DEFAULT_HEIGHT 0.5 +#define DEFAULT_ZOOM 2.0 GST_BOILERPLATE (GstSquare, gst_square, GstGeometricTransform, GST_TYPE_GEOMETRIC_TRANSFORM); @@ -95,6 +97,13 @@ gst_square_set_property (GObject * object, guint prop_id, gst_geometric_transform_set_need_remap (gt); } break; + case PROP_ZOOM: + v = g_value_get_double (value); + if (v != square->zoom) { + square->zoom = v; + gst_geometric_transform_set_need_remap (gt); + } + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -119,6 +128,9 @@ gst_square_get_property (GObject * object, guint prop_id, case PROP_HEIGHT: g_value_set_double (value, square->height); break; + case PROP_ZOOM: + g_value_set_double (value, square->zoom); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; @@ -156,10 +168,12 @@ square_map (GstGeometricTransform * gt, gint x, gint y, gdouble * in_x, /* transform */ /* zoom at the center, smoothstep around half quadrant and get back to normal */ norm_x *= - 0.5 * (1.0 + smoothstep (square->width - 0.125, square->width + 0.125, + (1.0 / square->zoom) * (1.0 + (square->zoom - + 1.0) * smoothstep (square->width - 0.125, square->width + 0.125, ABS (norm_x))); norm_y *= - 0.5 * (1.0 + smoothstep (square->height - 0.125, square->height + 0.125, + (1.0 / square->zoom) * (1.0 + (square->zoom - + 1.0) * smoothstep (square->height - 0.125, square->height + 0.125, ABS (norm_y))); /* unnormalize */ @@ -195,6 +209,11 @@ gst_square_class_init (GstSquareClass * klass) "Height of the square, relative to the frame height", 0.0, 1.0, DEFAULT_HEIGHT, GST_PARAM_CONTROLLABLE | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); + g_object_class_install_property (gobject_class, PROP_ZOOM, + g_param_spec_double ("zoom", "Zoom", + "Zoom amount in the center region", + 1.0, 100.0, DEFAULT_ZOOM, + GST_PARAM_CONTROLLABLE | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); gstgt_class->map_func = square_map; } @@ -206,6 +225,7 @@ gst_square_init (GstSquare * filter, GstSquareClass * gclass) filter->width = DEFAULT_WIDTH; filter->height = DEFAULT_HEIGHT; + filter->zoom = DEFAULT_ZOOM; gt->off_edge_pixels = GST_GT_OFF_EDGES_PIXELS_CLAMP; } diff --git a/gst/geometrictransform/gstsquare.h b/gst/geometrictransform/gstsquare.h index c9b3c35dd2..62774291e1 100644 --- a/gst/geometrictransform/gstsquare.h +++ b/gst/geometrictransform/gstsquare.h @@ -70,6 +70,7 @@ struct _GstSquare GstGeometricTransform element; gdouble width, height; + gdouble zoom; }; struct _GstSquareClass