1 /* GStreamer
2  * Copyright (C) <2010> Thiago Santos <thiago.sousa.santos@collabora.co.uk>
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., 51 Franklin St, Fifth Floor,
17  * Boston, MA 02110-1301, USA.
18  */
19 
20 #ifndef __GST_GEOMETRIC_TRANSFORM_H__
21 #define __GST_GEOMETRIC_TRANSFORM_H__
22 
23 #include <gst/video/gstvideofilter.h>
24 #include <gst/video/video.h>
25 
26 G_BEGIN_DECLS
27 
28 #define GST_TYPE_GEOMETRIC_TRANSFORM \
29   (gst_geometric_transform_get_type())
30 #define GST_GEOMETRIC_TRANSFORM(obj) \
31   (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_GEOMETRIC_TRANSFORM,GstGeometricTransform))
32 #define GST_GEOMETRIC_TRANSFORM_CAST(obj) ((GstGeometricTransform *)(obj))
33 #define GST_GEOMETRIC_TRANSFORM_CLASS(klass) \
34   (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_GEOMETRIC_TRANSFORM,GstGeometricTransformClass))
35 #define GST_IS_GEOMETRIC_TRANSFORM(obj) \
36   (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_GEOMETRIC_TRANSFORM))
37 #define GST_IS_GEOMETRIC_TRANSFORM_CLASS(klass) \
38   (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_GEOMETRIC_TRANSFORM))
39 #define GST_GEOMETRIC_TRANSFORM_GET_CLASS(obj) \
40   (G_TYPE_INSTANCE_GET_CLASS((obj),GST_TYPE_GEOMETRIC_TRANSFORM,GstGeometricTransformClass))
41 
42 enum
43 {
44   GST_GT_OFF_EDGES_PIXELS_IGNORE = 0,
45   GST_GT_OFF_EDGES_PIXELS_CLAMP,
46   GST_GT_OFF_EDGES_PIXELS_WRAP
47 };
48 
49 typedef struct _GstGeometricTransform GstGeometricTransform;
50 typedef struct _GstGeometricTransformClass GstGeometricTransformClass;
51 
52 /**
53  * GstGeometricTransformMapFunc:
54  *
55  * Given the output pixel position, this function calculates the input pixel
56  * position. The element using this function will then copy the input pixel
57  * data to the output pixel.
58  *
59  * @gt: The #GstGeometricTransform
60  * @x: The output pixel x coordinate
61  * @y: The output pixel y coordinate
62  * @_input_x: The input pixel x coordinate
63  * @_input_y: The input pixel y coordinate
64  * Returns: True on success, false otherwise
65  */
66 typedef gboolean (*GstGeometricTransformMapFunc) (GstGeometricTransform * gt,
67     gint x, gint y, gdouble * _input_x, gdouble *_input_y);
68 
69 /**
70  * GstGeometricTransformPrepareFunc:
71  *
72  * Called right before starting to calculate the mapping so that
73  * instances might precalculate some values.
74  *
75  * Called with the object lock
76  */
77 typedef gboolean (*GstGeometricTransformPrepareFunc) (
78     GstGeometricTransform * gt);
79 
80 /**
81  * GstGeometricTransform:
82  *
83  * Opaque datastructure.
84  */
85 struct _GstGeometricTransform {
86   GstVideoFilter videofilter;
87 
88   gint width, height;
89   GstVideoFormat format;
90   gint pixel_stride;
91   gint row_stride;
92 
93   /* Must be set on NULL state.
94    * Useful for subclasses that use don't want to use a fixed precalculated
95    * pixel mapping table. Like 'diffuse' that uses random values for each pic.
96    */
97   gboolean precalc_map;
98   gboolean needs_remap;
99 
100   /* properties */
101   gint off_edge_pixels;
102 
103   gdouble *map;
104 };
105 
106 struct _GstGeometricTransformClass {
107   GstVideoFilterClass parent_class;
108 
109   GstGeometricTransformMapFunc map_func;
110   GstGeometricTransformPrepareFunc prepare_func;
111 };
112 
113 GType gst_geometric_transform_get_type (void);
114 
115 void gst_geometric_transform_set_need_remap (GstGeometricTransform * gt);
116 
117 G_END_DECLS
118 
119 #endif /* __GST_GEOMETRIC_TRANSFORM_H__ */
120