mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-10-04 01:32:42 +00:00
geometrictransform: rename gemetric math functions to have their symbols namespaced
Otherwise those symbols can conflict with external libraries when linking everything statically for mobile targets. Use the gst_gm_ prefix, short for gst geometric math. https://bugzilla.gnome.org/show_bug.cgi?id=756882
This commit is contained in:
parent
c2f34b9814
commit
f1ced59ccb
10 changed files with 34 additions and 34 deletions
|
@ -54,7 +54,7 @@
|
||||||
#define B 0x100
|
#define B 0x100
|
||||||
#define BM 0xff
|
#define BM 0xff
|
||||||
|
|
||||||
struct _Noise
|
struct _GstGMNoise
|
||||||
{
|
{
|
||||||
gdouble p[2 * B + 2];
|
gdouble p[2 * B + 2];
|
||||||
gdouble g2[2 * B + 2][2];
|
gdouble g2[2 * B + 2][2];
|
||||||
|
@ -69,10 +69,10 @@ normalize_2 (gdouble * v)
|
||||||
v[1] = v[1] / s;
|
v[1] = v[1] / s;
|
||||||
}
|
}
|
||||||
|
|
||||||
Noise *
|
GstGMNoise *
|
||||||
noise_new (void)
|
gst_gm_noise_new (void)
|
||||||
{
|
{
|
||||||
Noise *noise = g_new0 (Noise, 1);
|
GstGMNoise *noise = g_new0 (GstGMNoise, 1);
|
||||||
gint i, j, k;
|
gint i, j, k;
|
||||||
|
|
||||||
for (i = 0; i < B; i++) {
|
for (i = 0; i < B; i++) {
|
||||||
|
@ -102,7 +102,7 @@ noise_new (void)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
noise_free (Noise * noise)
|
gst_gm_noise_free (GstGMNoise * noise)
|
||||||
{
|
{
|
||||||
g_free (noise);
|
g_free (noise);
|
||||||
}
|
}
|
||||||
|
@ -120,7 +120,7 @@ lerp (gdouble t, gdouble a, gdouble b)
|
||||||
}
|
}
|
||||||
|
|
||||||
gdouble
|
gdouble
|
||||||
noise_2 (Noise * noise, gdouble x, gdouble y)
|
gst_gm_noise_2 (GstGMNoise * noise, gdouble x, gdouble y)
|
||||||
{
|
{
|
||||||
gint bx0, bx1, by0, by1, b00, b10, b01, b11;
|
gint bx0, bx1, by0, by1, b00, b10, b01, b11;
|
||||||
gdouble rx0, rx1, ry0, ry1, sx, sy, a, b, t, u, v;
|
gdouble rx0, rx1, ry0, ry1, sx, sy, a, b, t, u, v;
|
||||||
|
@ -169,7 +169,7 @@ noise_2 (Noise * noise, gdouble x, gdouble y)
|
||||||
* This differs from the % operator with respect to negative numbers
|
* This differs from the % operator with respect to negative numbers
|
||||||
*/
|
*/
|
||||||
gdouble
|
gdouble
|
||||||
mod_float (gdouble a, gdouble b)
|
gst_gm_mod_float (gdouble a, gdouble b)
|
||||||
{
|
{
|
||||||
gint n = (gint) (a / b);
|
gint n = (gint) (a / b);
|
||||||
|
|
||||||
|
@ -183,9 +183,9 @@ mod_float (gdouble a, gdouble b)
|
||||||
* Returns a repeating triangle shape in the range 0..1 with wavelength 1.0
|
* Returns a repeating triangle shape in the range 0..1 with wavelength 1.0
|
||||||
*/
|
*/
|
||||||
gdouble
|
gdouble
|
||||||
geometric_math_triangle (gdouble x)
|
gst_gm_triangle (gdouble x)
|
||||||
{
|
{
|
||||||
gdouble r = mod_float (x, 1.0);
|
gdouble r = gst_gm_mod_float (x, 1.0);
|
||||||
|
|
||||||
return 2.0 * (r < 0.5 ? r : 1 - r);
|
return 2.0 * (r < 0.5 ? r : 1 - r);
|
||||||
}
|
}
|
||||||
|
@ -194,7 +194,7 @@ geometric_math_triangle (gdouble x)
|
||||||
* Hermite interpolation
|
* Hermite interpolation
|
||||||
*/
|
*/
|
||||||
gdouble
|
gdouble
|
||||||
smoothstep (gdouble edge0, gdouble edge1, gdouble x)
|
gst_gm_smoothstep (gdouble edge0, gdouble edge1, gdouble x)
|
||||||
{
|
{
|
||||||
gdouble t = CLAMP ((x - edge0) / (edge1 - edge0), 0.0, 1.0);
|
gdouble t = CLAMP ((x - edge0) / (edge1 - edge0), 0.0, 1.0);
|
||||||
return t * t * (3.0 - 2.0 * t);
|
return t * t * (3.0 - 2.0 * t);
|
||||||
|
|
|
@ -54,16 +54,16 @@
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
typedef struct _Noise Noise;
|
typedef struct _GstGMNoise GstGMNoise;
|
||||||
|
|
||||||
Noise * noise_new (void);
|
GstGMNoise * gst_gm_noise_new (void);
|
||||||
void noise_free (Noise * noise);
|
void gst_gm_noise_free (GstGMNoise * noise);
|
||||||
gdouble noise_2 (Noise * noise, gdouble x, gdouble y);
|
gdouble gst_gm_noise_2 (GstGMNoise * noise, gdouble x, gdouble y);
|
||||||
|
|
||||||
gdouble mod_float (gdouble a, gdouble b);
|
gdouble gst_gm_mod_float (gdouble a, gdouble b);
|
||||||
gdouble geometric_math_triangle (gdouble x);
|
gdouble gst_gm_triangle (gdouble x);
|
||||||
|
|
||||||
gdouble smoothstep (gdouble edge0, gdouble edge1, gdouble x);
|
gdouble gst_gm_smoothstep (gdouble edge0, gdouble edge1, gdouble x);
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
|
|
|
@ -140,8 +140,8 @@ bulge_map (GstGeometricTransform * gt, gint x, gint y, gdouble * in_x,
|
||||||
* zoom is achieved dividing */
|
* zoom is achieved dividing */
|
||||||
|
|
||||||
scale =
|
scale =
|
||||||
1.0 / (bulge->zoom + ((1.0 - bulge->zoom) * smoothstep (0, cgt->radius,
|
1.0 / (bulge->zoom + ((1.0 - bulge->zoom) * gst_gm_smoothstep (0,
|
||||||
r)));
|
cgt->radius, r)));
|
||||||
|
|
||||||
norm_x *= scale;
|
norm_x *= scale;
|
||||||
norm_y *= scale;
|
norm_y *= scale;
|
||||||
|
|
|
@ -158,7 +158,7 @@ circle_map (GstGeometricTransform * gt, gint x, gint y, gdouble * in_x,
|
||||||
distance = sqrt (dx * dx + dy * dy);
|
distance = sqrt (dx * dx + dy * dy);
|
||||||
theta = atan2 (-dy, -dx) + circle->angle;
|
theta = atan2 (-dy, -dx) + circle->angle;
|
||||||
|
|
||||||
theta = mod_float (theta, 2 * G_PI);
|
theta = gst_gm_mod_float (theta, 2 * G_PI);
|
||||||
|
|
||||||
*in_x = gt->width * theta / (circle->spread_angle + 0.0001);
|
*in_x = gt->width * theta / (circle->spread_angle + 0.0001);
|
||||||
*in_y =
|
*in_y =
|
||||||
|
|
|
@ -181,8 +181,8 @@ gst_geometric_transform_do_map (GstGeometricTransform * gt, guint8 * in_data,
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case GST_GT_OFF_EDGES_PIXELS_WRAP:
|
case GST_GT_OFF_EDGES_PIXELS_WRAP:
|
||||||
in_x = mod_float (in_x, gt->width);
|
in_x = gst_gm_mod_float (in_x, gt->width);
|
||||||
in_y = mod_float (in_y, gt->height);
|
in_y = gst_gm_mod_float (in_y, gt->height);
|
||||||
if (in_x < 0)
|
if (in_x < 0)
|
||||||
in_x += gt->width;
|
in_x += gt->width;
|
||||||
if (in_y < 0)
|
if (in_y < 0)
|
||||||
|
|
|
@ -158,12 +158,12 @@ kaleidoscope_map (GstGeometricTransform * gt, gint x, gint y, gdouble * in_x,
|
||||||
distance = sqrt (dx * dx + dy * dy);
|
distance = sqrt (dx * dx + dy * dy);
|
||||||
theta = atan2 (dy, dx) - kaleidoscope->angle - kaleidoscope->angle2;
|
theta = atan2 (dy, dx) - kaleidoscope->angle - kaleidoscope->angle2;
|
||||||
|
|
||||||
theta = geometric_math_triangle (theta / G_PI * kaleidoscope->sides * 0.5);
|
theta = gst_gm_triangle (theta / G_PI * kaleidoscope->sides * 0.5);
|
||||||
|
|
||||||
if (cgt->precalc_radius != 0) {
|
if (cgt->precalc_radius != 0) {
|
||||||
gdouble radiusc = cgt->precalc_radius / cos (theta);
|
gdouble radiusc = cgt->precalc_radius / cos (theta);
|
||||||
|
|
||||||
distance = radiusc * geometric_math_triangle (distance / radiusc);
|
distance = radiusc * gst_gm_triangle (distance / radiusc);
|
||||||
}
|
}
|
||||||
theta += kaleidoscope->angle;
|
theta += kaleidoscope->angle;
|
||||||
|
|
||||||
|
|
|
@ -158,7 +158,7 @@ gst_marble_finalize (GObject * obj)
|
||||||
{
|
{
|
||||||
GstMarble *marble = GST_MARBLE_CAST (obj);
|
GstMarble *marble = GST_MARBLE_CAST (obj);
|
||||||
|
|
||||||
noise_free (marble->noise);
|
gst_gm_noise_free (marble->noise);
|
||||||
g_free (marble->sin_table);
|
g_free (marble->sin_table);
|
||||||
g_free (marble->cos_table);
|
g_free (marble->cos_table);
|
||||||
|
|
||||||
|
@ -172,7 +172,7 @@ marble_prepare (GstGeometricTransform * trans)
|
||||||
gint i;
|
gint i;
|
||||||
|
|
||||||
if (!marble->noise) {
|
if (!marble->noise) {
|
||||||
marble->noise = noise_new ();
|
marble->noise = gst_gm_noise_new ();
|
||||||
}
|
}
|
||||||
|
|
||||||
g_free (marble->sin_table);
|
g_free (marble->sin_table);
|
||||||
|
@ -197,7 +197,7 @@ marble_map (GstGeometricTransform * gt, gint x, gint y, gdouble * in_x,
|
||||||
GstMarble *marble = GST_MARBLE_CAST (gt);
|
GstMarble *marble = GST_MARBLE_CAST (gt);
|
||||||
gint displacement;
|
gint displacement;
|
||||||
|
|
||||||
displacement = 127 * (1 + noise_2 (marble->noise, x / marble->xscale,
|
displacement = 127 * (1 + gst_gm_noise_2 (marble->noise, x / marble->xscale,
|
||||||
y / marble->xscale));
|
y / marble->xscale));
|
||||||
displacement = CLAMP (displacement, 0, 255);
|
displacement = CLAMP (displacement, 0, 255);
|
||||||
|
|
||||||
|
|
|
@ -76,7 +76,7 @@ struct _GstMarble
|
||||||
gdouble turbulence;
|
gdouble turbulence;
|
||||||
gdouble amount;
|
gdouble amount;
|
||||||
|
|
||||||
Noise *noise;
|
GstGMNoise *noise;
|
||||||
gdouble *sin_table;
|
gdouble *sin_table;
|
||||||
gdouble *cos_table;
|
gdouble *cos_table;
|
||||||
};
|
};
|
||||||
|
|
|
@ -157,12 +157,12 @@ square_map (GstGeometricTransform * gt, gint x, gint y, gdouble * in_x,
|
||||||
/* zoom at the center, smoothstep around half quadrant and get back to normal */
|
/* zoom at the center, smoothstep around half quadrant and get back to normal */
|
||||||
norm_x *=
|
norm_x *=
|
||||||
(1.0 / square->zoom) * (1.0 + (square->zoom -
|
(1.0 / square->zoom) * (1.0 + (square->zoom -
|
||||||
1.0) * smoothstep (square->width - 0.125, square->width + 0.125,
|
1.0) * gst_gm_smoothstep (square->width - 0.125,
|
||||||
ABS (norm_x)));
|
square->width + 0.125, ABS (norm_x)));
|
||||||
norm_y *=
|
norm_y *=
|
||||||
(1.0 / square->zoom) * (1.0 + (square->zoom -
|
(1.0 / square->zoom) * (1.0 + (square->zoom -
|
||||||
1.0) * smoothstep (square->height - 0.125, square->height + 0.125,
|
1.0) * gst_gm_smoothstep (square->height - 0.125,
|
||||||
ABS (norm_y)));
|
square->height + 0.125, ABS (norm_y)));
|
||||||
|
|
||||||
/* unnormalize */
|
/* unnormalize */
|
||||||
*in_x = 0.5 * (norm_x + 1.0) * width;
|
*in_x = 0.5 * (norm_x + 1.0) * width;
|
||||||
|
|
|
@ -145,8 +145,8 @@ stretch_map (GstGeometricTransform * gt, gint x, gint y, gdouble * in_x,
|
||||||
a = 1.0 + (MAX_SHRINK_AMOUNT - 1.0) * stretch->intensity;
|
a = 1.0 + (MAX_SHRINK_AMOUNT - 1.0) * stretch->intensity;
|
||||||
b = a - 1.0;
|
b = a - 1.0;
|
||||||
|
|
||||||
norm_x *= a - b * smoothstep (0.0, cgt->radius, r);
|
norm_x *= a - b * gst_gm_smoothstep (0.0, cgt->radius, r);
|
||||||
norm_y *= a - b * smoothstep (0.0, cgt->radius, r);
|
norm_y *= a - b * gst_gm_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;
|
||||||
|
|
Loading…
Reference in a new issue