geometrictransform: make stretch "radius" customizable

https://bugzilla.gnome.org/show_bug.cgi?id=625908
This commit is contained in:
Filippo Argiolas 2010-08-05 12:25:04 +02:00 committed by Sebastian Dröge
parent 629b6ff099
commit 27134c6e38

View file

@ -95,24 +95,16 @@ stretch_map (GstGeometricTransform * gt, gint x, gint y, gdouble * in_x,
norm_x = 2.0 * (x / width - cgt->x_center); norm_x = 2.0 * (x / width - cgt->x_center);
norm_y = 2.0 * (y / height - cgt->y_center); norm_y = 2.0 * (y / height - cgt->y_center);
r = sqrt (norm_x * norm_x + norm_y * norm_y); /* calculate radius, normalize to 1 for future convenience */
r = sqrt (0.5 * (norm_x * norm_x + norm_y * norm_y));
/* TODO: make it customizable, 0.7 is the radius of the stretch
* ellipse, with current way of setting radius (absolute value) it
* would be sqrt(hw*hw + hh*hh)/radius*radius but currently I prefer
* leaving it hardcoded because I don't think absolute radius makes
* any sense: the user either knows the video size and can easily
* calculate the fractional radius and set that or doesn't know the
* size a priori and wants to obtain the same effect no matter of
* the video dimensions */
/* actually "stretch" name is a bit misleading, what the transform /* actually "stretch" name is a bit misleading, what the transform
* really does is shrink the center and gradually return to normal * really does is shrink the center and gradually return to normal
* size while r increases. The shrink thing drags pixels giving * size while r increases. The shrink thing drags pixels giving
* stretching the image around the center */ * stretching the image around the center */
/* 2.0 is the shrink amount. Make it customizable? */ /* 2.0 is the shrink amount. Make it customizable? */
norm_x *= 2.0 - smoothstep (0.0, 0.7, r); norm_x *= 2.0 - smoothstep (0.0, cgt->radius, r);
norm_y *= 2.0 - smoothstep (0.0, 0.7, r); norm_y *= 2.0 - smoothstep (0.0, cgt->radius, r);
/* unnormalize */ /* unnormalize */
*in_x = (0.5 * norm_x + cgt->x_center) * width; *in_x = (0.5 * norm_x + cgt->x_center) * width;