View | Details | Raw Unified | Return to bug 625722 | Differences between
and this patch

Collapse All | Expand All

(-)a/configure.ac (+2 lines)
 Lines 270-275   AG_GST_CHECK_PLUGIN(camerabin) Link Here 
270
AG_GST_CHECK_PLUGIN(legacyresample)
270
AG_GST_CHECK_PLUGIN(legacyresample)
271
AG_GST_CHECK_PLUGIN(bayer)
271
AG_GST_CHECK_PLUGIN(bayer)
272
AG_GST_CHECK_PLUGIN(cdxaparse)
272
AG_GST_CHECK_PLUGIN(cdxaparse)
273
AG_GST_CHECK_PLUGIN(cheeseeffects)
273
AG_GST_CHECK_PLUGIN(dataurisrc)
274
AG_GST_CHECK_PLUGIN(dataurisrc)
274
AG_GST_CHECK_PLUGIN(dccp)
275
AG_GST_CHECK_PLUGIN(dccp)
275
AG_GST_CHECK_PLUGIN(debugutils)
276
AG_GST_CHECK_PLUGIN(debugutils)
 Lines 1677-1682   gst/autoconvert/Makefile Link Here 
1677
gst/bayer/Makefile
1678
gst/bayer/Makefile
1678
gst/camerabin/Makefile
1679
gst/camerabin/Makefile
1679
gst/cdxaparse/Makefile
1680
gst/cdxaparse/Makefile
1681
gst/cheeseeffects/Makefile
1680
gst/dataurisrc/Makefile
1682
gst/dataurisrc/Makefile
1681
gst/dccp/Makefile
1683
gst/dccp/Makefile
1682
gst/debugutils/Makefile
1684
gst/debugutils/Makefile
(-)a/gst/cheeseeffects/Makefile.am (+18 lines)
Line 0    Link Here 
1
plugin_LTLIBRARIES = libgstcheeseeffects.la
2
3
libgstcheeseeffects_la_SOURCES = \
4
	gstplugin.c \
5
	gstcommon.c \
6
	gstsqueeze.c
7
libgstcheeseeffects_la_CFLAGS = \
8
	$(GST_PLUGINS_BASE_CFLAGS) \
9
	$(GST_CFLAGS)
10
libgstcheeseeffects_la_LIBADD = \
11
	$(GST_PLUGINS_BASE_LIBS) -lgstvideo-@GST_MAJORMINOR@ \
12
	$(GST_BASE_LIBS) \
13
	$(GST_LIBS) \
14
	$(LIBM)
15
libgstcheeseeffects_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS)
16
libgstcheeseeffects_la_LIBTOOLFLAGS = --tag=disable-static
17
18
noinst_HEADERS = gstcommon.h gstsqueeze.h
(-)a/gst/cheeseeffects/gstcommon.c (+140 lines)
Line 0    Link Here 
1
/* GStreamer
2
 * Copyright (C) <2010> Filippo Argiolas <filippo.argiolas@gmail.com>
3
 *
4
 * This library is free software; you can redistribute it and/or
5
 * modify it under the terms of the GNU Library General Public
6
 * License as published by the Free Software Foundation; either
7
 * version 2 of the License, or (at your option) any later version.
8
 *
9
 * This library is distributed in the hope that it will be useful,
10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12
 * Library General Public License for more details.
13
 *
14
 * You should have received a copy of the GNU Library General Public
15
 * License along with this library; if not, write to the
16
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17
 * Boston, MA 02111-1307, USA.
18
 */
19
20
#include "gstcommon.h"
21
22
GType
23
gst_cheese_interp_method_get_type (void)
24
{
25
  static GType interp_method_type = 0;
26
27
  static const GEnumValue interp_methods[] = {
28
    {GST_CHEESE_INTERP_NEAREST, "Nearest Neighbour", "nearest-neighbour"},
29
    {GST_CHEESE_INTERP_BILINEAR, "Bilinear", "bilinear"},
30
    {0, NULL, NULL},
31
  };
32
33
  if (!interp_method_type) {
34
    interp_method_type =
35
        g_enum_register_static ("GstCheeseInterpMethod", interp_methods);
36
  }
37
  return interp_method_type;
38
}
39
40
gdouble
41
smoothstep (gdouble edge0, gdouble edge1, gdouble x)
42
{
43
  gdouble t = CLAMP ((x - edge0) / (edge1 - edge0), 0.0, 1.0);
44
  return t * t * (3.0 - 2.0 * t);
45
}
46
47
gdouble
48
length (gdouble x, gdouble y)
49
{
50
  return sqrt (x * x + y * y);
51
}
52
53
/**
54
 * bilerp:
55
 * @tl: top left pixel
56
 * @tr: top right pixel
57
 * @bl: bottom pixel
58
 * @br: bottom right pixel
59
 * @u: fixed point (with 8 bit fractional part) u texture coordinate
60
 * @v: fixed point (with 8 bit fractional part) v texture coordinate
61
 *
62
 * Retrieves pixel color at fractional coordinate (u,v) using known colors from the four given neighbours
63
 *
64
 * Return value: interpolated pixel
65
 */
66
guint32
67
bilerp (guint32 tl, guint32 tr, guint32 bl, guint32 br, guint32 u, guint32 v)
68
{
69
  guint32 f, r;
70
  guint32 du, dv;
71
  guint32 duv, duiv, diuv, diuiv;
72
  guint32 ptr, ptl, pbl, pbr;
73
74
  /* take fractional part from texture coords */
75
  du = u & 0x000000ff;
76
  dv = v & 0x000000ff;
77
78
  /* interpolation coefficients */
79
  duv = du * dv;
80
  duiv = (du << 8) - duv;       /* du * (256 - dv) */
81
  diuv = (dv << 8) - duv;       /* (256 - du) * dv */
82
  diuiv = 65536 - duv - diuv - duiv;    /* (256 - du) * (256 - dv) */
83
84
  /* restore fixed point at 8 */
85
  duv >>= 8;
86
  duiv >>= 8;
87
  diuv >>= 8;
88
  diuiv >>= 8;
89
90
  /* take first color component and convert it to fixed point */
91
  /* ptl = ((tl >> 24) & 0xFF) << 8                           */
92
  /*     = (tl & 0xFF000000) >> (24 - 8)                      */
93
  /*     = tl >> 16                                           */
94
  ptl = tl >> 16;
95
  ptr = tr >> 16;
96
  pbl = bl >> 16;
97
  pbr = br >> 16;
98
99
  /* bilinear interpolation */
100
  r = (ptl * diuiv) + (ptr * duiv)
101
      + (pbl * diuv) + (pbr * duv);
102
103
  /* take integer part, shifted 8 bits to the left after mult, and put
104
   * it in the right place inside the pixel */
105
  r = (r & 0x00ff0000) << 8;
106
107
  /* repeat for the other components */
108
109
  ptl = (tl & 0x00ff0000) >> 8;
110
  ptr = (tr & 0x00ff0000) >> 8;
111
  pbl = (bl & 0x00ff0000) >> 8;
112
  pbr = (br & 0x00ff0000) >> 8;
113
114
  f = (ptl * diuiv) + (ptr * duiv)
115
      + (pbl * diuv) + (pbr * duv);
116
117
  r |= (f & 0x00ff0000);
118
119
  ptl = (tl & 0x0000ff00);
120
  ptr = (tr & 0x0000ff00);
121
  pbl = (bl & 0x0000ff00);
122
  pbr = (br & 0x0000ff00);
123
124
  f = (ptl * diuiv) + (ptr * duiv)
125
      + (pbl * diuv) + (pbr * duv);
126
127
  r |= (f & 0x00ff0000) >> 8;
128
129
  ptl = (tl & 0x000000ff) << 8;
130
  ptr = (tr & 0x000000ff) << 8;
131
  pbl = (bl & 0x000000ff) << 8;
132
  pbr = (br & 0x000000ff) << 8;
133
134
  f = (ptl * diuiv) + (ptr * duiv)
135
      + (pbl * diuv) + (pbr * duv);
136
137
  r |= (f & 0x00ff0000) >> 16;
138
139
  return r;
140
}
(-)a/gst/cheeseeffects/gstcommon.h (+54 lines)
Line 0    Link Here 
1
/* GStreamer
2
 * Copyright (C) <2010> Filippo Argiolas <filippo.argiolas@gmail.com>
3
 *
4
 * This library is free software; you can redistribute it and/or
5
 * modify it under the terms of the GNU Library General Public
6
 * License as published by the Free Software Foundation; either
7
 * version 2 of the License, or (at your option) any later version.
8
 *
9
 * This library is distributed in the hope that it will be useful,
10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12
 * Library General Public License for more details.
13
 *
14
 * You should have received a copy of the GNU Library General Public
15
 * License along with this library; if not, write to the
16
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17
 * Boston, MA 02111-1307, USA.
18
 */
19
20
#ifndef __GST_CHEESECOMMON_H__
21
#define __GST_CHEESECOMMON_H__
22
23
#include <gst/gst.h>
24
25
#include <gst/video/gstvideofilter.h>
26
#include <math.h>
27
28
G_BEGIN_DECLS
29
#define GST_TYPE_CHEESE_INTERP_METHOD (gst_cheese_interp_method_get_type())
30
    GType gst_cheese_interp_method_get_type (void);
31
32
/**
33
 * GstCheeseInterpMethod:
34
 * @GST_CHEESE_INTERP_NEAREST: use nearest neighbour interpolation (fast but jagged).
35
 * @GST_CHEESE_INTERP_BILINEAR: use bilinear interpolation (slow but smooth).
36
 *
37
 * Interpolation method to get correct pixel colors from transformed
38
 * fractional coordinates
39
 */
40
typedef enum
41
{
42
  GST_CHEESE_INTERP_NEAREST,
43
  GST_CHEESE_INTERP_BILINEAR,
44
} GstCheeseInterpMethod;
45
46
#define DEFAULT_INTERP_METHOD GST_CHEESE_INTERP_NEAREST
47
48
gdouble smoothstep (gdouble edge0, gdouble edge1, gdouble x);
49
gdouble length (gdouble x, gdouble y);
50
guint32 bilerp (guint32 tl, guint32 tr, guint32 bl, guint32 br, guint32 u,
51
    guint32 v);
52
53
G_END_DECLS
54
#endif /* __GST_CHEESECOMMON_H__ */
(-)a/gst/cheeseeffects/gstplugin.c (+62 lines)
Line 0    Link Here 
1
/* GStreamer
2
 * Copyright (C) <2010> Filippo Argiolas <filippo.argiolas@gmail.com>
3
 *
4
 * This library is free software; you can redistribute it and/or
5
 * modify it under the terms of the GNU Library General Public
6
 * License as published by the Free Software Foundation; either
7
 * version 2 of the License, or (at your option) any later version.
8
 *
9
 * This library is distributed in the hope that it will be useful,
10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12
 * Library General Public License for more details.
13
 *
14
 * You should have received a copy of the GNU Library General Public
15
 * License along with this library; if not, write to the
16
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17
 * Boston, MA 02111-1307, USA.
18
 */
19
20
#ifdef HAVE_CONFIG_H
21
#  include <config.h>
22
#endif
23
24
#include <gst/gst.h>
25
26
#include "gstsqueeze.h"
27
28
#ifndef PACKAGE
29
#define PACKAGE "cheeseeffects"
30
#endif
31
32
struct _elements_entry
33
{
34
  const gchar *name;
35
    GType (*type) (void);
36
};
37
38
static const struct _elements_entry _elements[] = {
39
  {"cheesesqueeze", gst_cheese_squeeze_get_type},
40
  {NULL, 0},
41
};
42
43
static gboolean
44
plugin_init (GstPlugin * plugin)
45
{
46
  gint i = 0;
47
48
  while (_elements[i].name) {
49
    if (!gst_element_register (plugin, _elements[i].name,
50
            GST_RANK_NONE, (_elements[i].type) ()))
51
      return FALSE;
52
    i++;
53
  }
54
55
  return TRUE;
56
}
57
58
GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
59
    GST_VERSION_MINOR,
60
    "cheeseeffects",
61
    "cheese video effects.",
62
    plugin_init, VERSION, "LGPL", "GStreamer", "http://gstreamer.net/")
(-)a/gst/cheeseeffects/gstsqueeze.c (+311 lines)
Line 0    Link Here 
1
/* GStreamer
2
 * Copyright (C) <2010> Filippo Argiolas <filippo.argiolas@gmail.com>
3
 *
4
 * This library is free software; you can redistribute it and/or
5
 * modify it under the terms of the GNU Library General Public
6
 * License as published by the Free Software Foundation; either
7
 * version 2 of the License, or (at your option) any later version.
8
 *
9
 * This library is distributed in the hope that it will be useful,
10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12
 * Library General Public License for more details.
13
 *
14
 * You should have received a copy of the GNU Library General Public
15
 * License along with this library; if not, write to the
16
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17
 * Boston, MA 02111-1307, USA.
18
 */
19
20
/**
21
 * SECTION:element-squeeze
22
 *
23
 * Squeeze applies a transform that diverges at the center of the
24
 * video giving the impression that the video surface is being pinched
25
 *
26
 * <refsect2>
27
 * <title>Example launch line</title>
28
 * |[
29
 * gst-launch -v videotestsrc ! cheesesqueeze ! ffmpegcolorspace ! autovideosink
30
 * ]| This pipeline shows the effect of cheesesqueeze on a test stream.
31
 * </refsect2>
32
 */
33
34
#ifdef HAVE_CONFIG_H
35
#include "config.h"
36
#endif
37
38
#include <gst/video/video.h>
39
#include "gstsqueeze.h"
40
41
enum
42
{
43
  PROP_0,
44
  PROP_METHOD
45
};
46
47
static void gst_cheese_squeeze_set_property (GObject * object, guint prop_id,
48
    const GValue * value, GParamSpec * pspec);
49
static void gst_cheese_squeeze_get_property (GObject * object, guint prop_id,
50
    GValue * value, GParamSpec * pspec);
51
52
53
GST_BOILERPLATE (GstCheeseSqueeze, gst_cheese_squeeze, GstVideoFilter,
54
    GST_TYPE_VIDEO_FILTER);
55
56
static void init_distortion_map (GstCheeseSqueeze * filter);
57
58
static GstStaticPadTemplate gst_cheese_squeeze_src_template =
59
    GST_STATIC_PAD_TEMPLATE ("src",
60
    GST_PAD_SRC,
61
    GST_PAD_ALWAYS,
62
    GST_STATIC_CAPS (GST_VIDEO_CAPS_RGBx ";" GST_VIDEO_CAPS_xRGB ";"
63
        GST_VIDEO_CAPS_BGRx ";" GST_VIDEO_CAPS_xBGR ";"
64
        GST_VIDEO_CAPS_YUV ("AYUV"))
65
    );
66
67
static GstStaticPadTemplate gst_cheese_squeeze_sink_template =
68
    GST_STATIC_PAD_TEMPLATE ("sink",
69
    GST_PAD_SINK,
70
    GST_PAD_ALWAYS,
71
    GST_STATIC_CAPS (GST_VIDEO_CAPS_RGBx ";" GST_VIDEO_CAPS_xRGB ";"
72
        GST_VIDEO_CAPS_BGRx ";" GST_VIDEO_CAPS_xBGR ";"
73
        GST_VIDEO_CAPS_YUV ("AYUV"))
74
    );
75
76
static gboolean
77
gst_cheese_squeeze_set_caps (GstBaseTransform * btrans, GstCaps * incaps,
78
    GstCaps * outcaps)
79
{
80
  GstCheeseSqueeze *filter = GST_CHEESE_SQUEEZE (btrans);
81
  GstStructure *structure;
82
  gboolean ret = FALSE;
83
84
  structure = gst_caps_get_structure (incaps, 0);
85
  GST_OBJECT_LOCK (filter);
86
  if (gst_structure_get_int (structure, "width", &filter->width) &&
87
      gst_structure_get_int (structure, "height", &filter->height)) {
88
89
    g_free (filter->map);
90
91
    filter->map =
92
        g_malloc (2 * filter->width * filter->height * sizeof (guint32));
93
94
    init_distortion_map (filter);
95
96
    ret = TRUE;
97
  }
98
  GST_OBJECT_UNLOCK (filter);
99
100
  return ret;
101
}
102
103
static GstFlowReturn
104
gst_cheese_squeeze_transform (GstBaseTransform * trans, GstBuffer * in,
105
    GstBuffer * out)
106
{
107
  GstCheeseSqueeze *filter = GST_CHEESE_SQUEEZE (trans);
108
  guint32 *src = (guint32 *) GST_BUFFER_DATA (in);
109
  guint32 *dest = (guint32 *) GST_BUFFER_DATA (out);
110
  gint width, height;
111
  gint x, y;
112
  guint32 newx, newy;
113
  guint32 u, v;
114
  guint32 idx;
115
  guint32 tlidx;
116
  guint32 tridx;
117
  guint32 blidx;
118
  guint32 bridx;
119
120
  GstFlowReturn ret = GST_FLOW_OK;
121
122
  GST_OBJECT_LOCK (filter);
123
  width = filter->width;
124
  height = filter->height;
125
126
  for (y = 0; y < height; y++) {
127
    for (x = 0; x < width; x++) {
128
      /* may be worth to precalculate offsets in an outer loop like
129
         warptv does */
130
      idx = 2 * (x + y * width);
131
      /* u, v, fixed point coordinates */
132
      u = filter->map[idx];
133
      v = filter->map[idx + 1];
134
135
      switch (filter->method) {
136
        case GST_CHEESE_INTERP_NEAREST:
137
          newx = (u + 128) >> 8;        /* nearbyint (newx) */
138
          newy = (v + 128) >> 8;        /* nearbyint (newy) */
139
140
          dest[x + y * width] = src[newx + newy * width];
141
          break;
142
        case GST_CHEESE_INTERP_BILINEAR:
143
          newx = u >> 8;        /* floor (newx) */
144
          newy = v >> 8;        /* floor (newy) */
145
146
          /* do not try to interpolate with out of bound pixels */
147
          /* is there a better way to do this? */
148
          tlidx = newx + newy * width;
149
          tridx = (CLAMP (newx + 1, 0, width - 1)) + newy * width;
150
          blidx = newx + (CLAMP (newy + 1, 0, height - 1)) * width;
151
          bridx =
152
              (CLAMP (newx + 1, 0, width - 1)) + (CLAMP (newy + 1, 0,
153
                  height - 1)) * width;
154
155
          dest[x + y * width] = bilerp (src[tlidx], src[tridx],
156
              src[blidx], src[bridx], u, v);
157
          break;
158
        default:
159
          g_assert_not_reached ();
160
      }
161
    }
162
  }
163
164
  GST_OBJECT_UNLOCK (filter);
165
166
  return ret;
167
}
168
169
static void
170
gst_cheese_squeeze_set_property (GObject * object, guint prop_id,
171
    const GValue * value, GParamSpec * pspec)
172
{
173
  GstCheeseSqueeze *filter = GST_CHEESE_SQUEEZE (object);
174
175
  switch (prop_id) {
176
    case PROP_METHOD:
177
      GST_OBJECT_LOCK (filter);
178
      filter->method = g_value_get_enum (value);
179
      GST_OBJECT_UNLOCK (filter);
180
      break;
181
    default:
182
      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
183
      break;
184
  }
185
}
186
187
static void
188
gst_cheese_squeeze_get_property (GObject * object, guint prop_id,
189
    GValue * value, GParamSpec * pspec)
190
{
191
  GstCheeseSqueeze *filter = GST_CHEESE_SQUEEZE (object);
192
193
  switch (prop_id) {
194
    case PROP_METHOD:
195
      GST_OBJECT_LOCK (filter);
196
      g_value_set_enum (value, filter->method);
197
      GST_OBJECT_UNLOCK (filter);
198
      break;
199
    default:
200
      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
201
      break;
202
  }
203
}
204
205
static void
206
gst_cheese_squeeze_finalize (GObject * object)
207
{
208
  GstCheeseSqueeze *filter = GST_CHEESE_SQUEEZE (object);
209
210
  g_free (filter->map);
211
212
  G_OBJECT_CLASS (parent_class)->finalize (object);
213
}
214
215
static void
216
gst_cheese_squeeze_base_init (gpointer g_class)
217
{
218
  GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
219
220
  gst_element_class_set_details_simple (element_class, "Squeeze effect",
221
      "Filter/Effect/Video",
222
      "Squeeze the video input",
223
      "Filippo Argiolas <filippo.argiolas@gmail.com>");
224
225
  gst_element_class_add_pad_template (element_class,
226
      gst_static_pad_template_get (&gst_cheese_squeeze_sink_template));
227
  gst_element_class_add_pad_template (element_class,
228
      gst_static_pad_template_get (&gst_cheese_squeeze_src_template));
229
}
230
231
static void
232
gst_cheese_squeeze_class_init (GstCheeseSqueezeClass * klass)
233
{
234
  GObjectClass *gobject_class = (GObjectClass *) klass;
235
  GstBaseTransformClass *trans_class = (GstBaseTransformClass *) klass;
236
237
  gobject_class->finalize = gst_cheese_squeeze_finalize;
238
  gobject_class->set_property = gst_cheese_squeeze_set_property;
239
  gobject_class->get_property = gst_cheese_squeeze_get_property;
240
241
  g_object_class_install_property (gobject_class, PROP_METHOD,
242
      g_param_spec_enum ("interp-method", "interp-method",
243
          "How to calculate the color of transformed fractional coordinates",
244
          GST_TYPE_CHEESE_INTERP_METHOD, DEFAULT_INTERP_METHOD,
245
          G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
246
247
  trans_class->set_caps = GST_DEBUG_FUNCPTR (gst_cheese_squeeze_set_caps);
248
  trans_class->transform = GST_DEBUG_FUNCPTR (gst_cheese_squeeze_transform);
249
}
250
251
static void
252
gst_cheese_squeeze_init (GstCheeseSqueeze * filter,
253
    GstCheeseSqueezeClass * klass)
254
{
255
  filter->map = NULL;
256
  gst_pad_use_fixed_caps (GST_BASE_TRANSFORM_SRC_PAD (filter));
257
  gst_pad_use_fixed_caps (GST_BASE_TRANSFORM_SINK_PAD (filter));
258
}
259
260
static void
261
init_distortion_map (GstCheeseSqueeze * filter)
262
{
263
  gint x, y;
264
  gdouble newx, newy;
265
  gdouble norm_x;
266
  gdouble norm_y;
267
  gdouble r;
268
269
  gint width = filter->width;
270
  gint height = filter->height;
271
272
  gdouble hw = (width - 1.0) / 2.0;
273
  gdouble hh = (height - 1.0) / 2.0;
274
275
  /* this is run once at set_caps so it's optimized for readability
276
   * and math clarity, not for performance */
277
278
  for (y = 0; y < height; y++) {
279
    for (x = 0; x < width; x++) {
280
      /* normalize in ((-1.0, -1.0), (1.0, 1.0) */
281
      norm_x = x / hw - 1.0;
282
      norm_y = y / hh - 1.0;
283
284
      /* work on r to have circular simmetry around center */
285
      r = length (norm_x, norm_y);
286
287
      /* transform */
288
      /* the power of r is the amount of squeezing, the lower it is
289
       * the smoother will be the squeeze. */
290
      /* the multiplicative factor is the zooming amount (given the
291
       * squeezing moves everything to the center a little zoom can be
292
       * nice) */
293
      if (r > 0)
294
        norm_x /= pow (r, 0.4) * 1.2;
295
296
      /* ensure transform doesn't give us out of bound coordinates */
297
      norm_x = CLAMP (norm_x, -1.0, 1.0);
298
      norm_y = CLAMP (norm_y, -1.0, 1.0);
299
300
      /* unnormalize */
301
      newx = (norm_x + 1.0) * hw;
302
      newy = (norm_y + 1.0) * hh;
303
304
      /* store new coordinates in fixed point (32 bits with 8 bits for
305
         the fractional part) */
306
      /* transformed x and y are stored in the map next to each other */
307
      filter->map[(2 * x) + y * 2 * width] = newx * 256;
308
      filter->map[(2 * x + 1) + y * 2 * width] = newy * 256;
309
    }
310
  }
311
}
(-)a/gst/cheeseeffects/gstsqueeze.h (+62 lines)
Line 0    Link Here 
1
/* GStreamer
2
 * Copyright (C) <2010> Filippo Argiolas <filippo.argiolas@gmail.com>
3
 *
4
 * This library is free software; you can redistribute it and/or
5
 * modify it under the terms of the GNU Library General Public
6
 * License as published by the Free Software Foundation; either
7
 * version 2 of the License, or (at your option) any later version.
8
 *
9
 * This library is distributed in the hope that it will be useful,
10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12
 * Library General Public License for more details.
13
 *
14
 * You should have received a copy of the GNU Library General Public
15
 * License along with this library; if not, write to the
16
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17
 * Boston, MA 02111-1307, USA.
18
 */
19
20
#ifndef __GST_CHEESE_SQUEEZE_H__
21
#define __GST_CHEESE_SQUEEZE_H__
22
23
#include <gst/gst.h>
24
25
#include <gst/video/gstvideofilter.h>
26
#include "gstcommon.h"
27
28
G_BEGIN_DECLS
29
#define GST_TYPE_CHEESE_SQUEEZE \
30
  (gst_cheese_squeeze_get_type())
31
#define GST_CHEESE_SQUEEZE(obj) \
32
  (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_CHEESE_SQUEEZE,GstCheeseSqueeze))
33
#define GST_CHEESE_SQUEEZE_CLASS(klass) \
34
  (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_CHEESE_SQUEEZE,GstCheeseSqueezeClass))
35
#define GST_IS_CHEESE_SQUEEZE(obj) \
36
  (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_CHEESE_SQUEEZE))
37
#define GST_IS_CHEESE_SQUEEZE_CLASS(klass) \
38
  (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_CHEESE_SQUEEZE))
39
typedef struct _GstCheeseSqueeze GstCheeseSqueeze;
40
typedef struct _GstCheeseSqueezeClass GstCheeseSqueezeClass;
41
42
struct _GstCheeseSqueeze
43
{
44
  GstVideoFilter videofilter;
45
46
  /* < private > */
47
48
  GstCheeseInterpMethod method;
49
50
  gint width, height;
51
  guint32 *map;
52
};
53
54
struct _GstCheeseSqueezeClass
55
{
56
  GstVideoFilterClass parent_class;
57
};
58
59
GType gst_cheese_squeeze_get_type (void);
60
61
G_END_DECLS
62
#endif /* __GST_CHEESE_SQUEEZE_H__ */

Return to bug 625722