upload tizen1.0 source
[framework/multimedia/gst-plugins-good0.10.git] / gst / deinterlace / gstdeinterlacemethod.h
1 /*
2  * GStreamer
3  * Copyright (C) 2008-2010 Sebastian Dröge <slomo@collabora.co.uk>
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Library General Public
7  * License as published by the Free Software Foundation; either
8  * version 2 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  * Library General Public License for more details.
14  *
15  * You should have received a copy of the GNU Library General Public
16  * License along with this library; if not, write to the
17  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18  * Boston, MA 02111-1307, USA.
19  */
20
21 #ifndef __GST_DEINTERLACE_METHOD_H__
22 #define __GST_DEINTERLACE_METHOD_H__
23
24 #include <gst/gst.h>
25 #include <gst/video/video.h>
26
27 #if defined(HAVE_GCC_ASM) && defined(HAVE_ORC)
28 #if defined(HAVE_CPU_I386) || defined(HAVE_CPU_X86_64)
29 #define BUILD_X86_ASM
30 #endif
31 #endif
32
33 G_BEGIN_DECLS
34
35 #define GST_TYPE_DEINTERLACE_METHOD             (gst_deinterlace_method_get_type ())
36 #define GST_IS_DEINTERLACE_METHOD(obj)          (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_DEINTERLACE_METHOD))
37 #define GST_IS_DEINTERLACE_METHOD_CLASS(klass)  (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_DEINTERLACE_METHOD))
38 #define GST_DEINTERLACE_METHOD_GET_CLASS(obj)   (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_DEINTERLACE_METHOD, GstDeinterlaceMethodClass))
39 #define GST_DEINTERLACE_METHOD(obj)             (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_DEINTERLACE_METHOD, GstDeinterlaceMethod))
40 #define GST_DEINTERLACE_METHOD_CLASS(klass)     (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_DEINTERLACE_METHOD, GstDeinterlaceMethodClass))
41 #define GST_DEINTERLACE_METHOD_CAST(obj)        ((GstDeinterlaceMethod*)(obj))
42
43 typedef struct _GstDeinterlaceMethod GstDeinterlaceMethod;
44 typedef struct _GstDeinterlaceMethodClass GstDeinterlaceMethodClass;
45
46
47 #define PICTURE_PROGRESSIVE 0
48 #define PICTURE_INTERLACED_BOTTOM 1
49 #define PICTURE_INTERLACED_TOP 2
50 #define PICTURE_INTERLACED_MASK (PICTURE_INTERLACED_BOTTOM | PICTURE_INTERLACED_TOP)
51
52 typedef struct
53 {
54   /* pointer to the start of data for this field */
55   GstBuffer *buf;
56   /* see PICTURE_ flags in *.c */
57   guint flags;
58 } GstDeinterlaceField;
59
60 /*
61  * This structure defines the deinterlacer plugin.
62  */
63
64 typedef void (*GstDeinterlaceMethodDeinterlaceFunction) (GstDeinterlaceMethod *self, const GstDeinterlaceField *history, guint history_count, GstBuffer *outbuf);
65
66 struct _GstDeinterlaceMethod {
67   GstObject parent;
68
69   GstVideoFormat format;
70   gint frame_width, frame_height;
71   gint width[4];
72   gint height[4];
73   gint offset[4];
74   gint row_stride[4];
75   gint pixel_stride[4];
76
77   GstDeinterlaceMethodDeinterlaceFunction deinterlace_frame;
78 };
79
80 struct _GstDeinterlaceMethodClass {
81   GstObjectClass parent_class;
82   guint fields_required;
83   guint latency;
84
85   gboolean (*supported) (GstDeinterlaceMethodClass *klass, GstVideoFormat format, gint width, gint height);
86
87   void (*setup) (GstDeinterlaceMethod *self, GstVideoFormat format, gint width, gint height);
88
89   GstDeinterlaceMethodDeinterlaceFunction deinterlace_frame_yuy2;
90   GstDeinterlaceMethodDeinterlaceFunction deinterlace_frame_yvyu;
91   GstDeinterlaceMethodDeinterlaceFunction deinterlace_frame_uyvy;
92   GstDeinterlaceMethodDeinterlaceFunction deinterlace_frame_i420;
93   GstDeinterlaceMethodDeinterlaceFunction deinterlace_frame_yv12;
94   GstDeinterlaceMethodDeinterlaceFunction deinterlace_frame_y444;
95   GstDeinterlaceMethodDeinterlaceFunction deinterlace_frame_y42b;
96   GstDeinterlaceMethodDeinterlaceFunction deinterlace_frame_y41b;
97   GstDeinterlaceMethodDeinterlaceFunction deinterlace_frame_ayuv;
98   GstDeinterlaceMethodDeinterlaceFunction deinterlace_frame_nv12;
99   GstDeinterlaceMethodDeinterlaceFunction deinterlace_frame_nv21;
100   GstDeinterlaceMethodDeinterlaceFunction deinterlace_frame_argb;
101   GstDeinterlaceMethodDeinterlaceFunction deinterlace_frame_abgr;
102   GstDeinterlaceMethodDeinterlaceFunction deinterlace_frame_rgba;
103   GstDeinterlaceMethodDeinterlaceFunction deinterlace_frame_bgra;
104   GstDeinterlaceMethodDeinterlaceFunction deinterlace_frame_rgb;
105   GstDeinterlaceMethodDeinterlaceFunction deinterlace_frame_bgr;
106
107   const gchar *name;
108   const gchar *nick;
109 };
110
111 GType gst_deinterlace_method_get_type (void);
112
113 gboolean gst_deinterlace_method_supported (GType type, GstVideoFormat format, gint width, gint height);
114 void gst_deinterlace_method_setup (GstDeinterlaceMethod * self, GstVideoFormat format, gint width, gint height);
115 void gst_deinterlace_method_deinterlace_frame (GstDeinterlaceMethod * self, const GstDeinterlaceField * history, guint history_count, GstBuffer * outbuf);
116 gint gst_deinterlace_method_get_fields_required (GstDeinterlaceMethod * self);
117 gint gst_deinterlace_method_get_latency (GstDeinterlaceMethod * self);
118
119 #define GST_TYPE_DEINTERLACE_SIMPLE_METHOD              (gst_deinterlace_simple_method_get_type ())
120 #define GST_IS_DEINTERLACE_SIMPLE_METHOD(obj)           (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_DEINTERLACE_SIMPLE_METHOD))
121 #define GST_IS_DEINTERLACE_SIMPLE_METHOD_CLASS(klass)   (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_DEINTERLACE_SIMPLE_METHOD))
122 #define GST_DEINTERLACE_SIMPLE_METHOD_GET_CLASS(obj)    (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_DEINTERLACE_SIMPLE_METHOD, GstDeinterlaceSimpleMethodClass))
123 #define GST_DEINTERLACE_SIMPLE_METHOD(obj)              (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_DEINTERLACE_SIMPLE_METHOD, GstDeinterlaceSimpleMethod))
124 #define GST_DEINTERLACE_SIMPLE_METHOD_CLASS(klass)      (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_DEINTERLACE_SIMPLE_METHOD, GstDeinterlaceSimpleMethodClass))
125 #define GST_DEINTERLACE_SIMPLE_METHOD_CAST(obj) ((GstDeinterlaceSimpleMethod*)(obj))
126
127 typedef struct _GstDeinterlaceSimpleMethod GstDeinterlaceSimpleMethod;
128 typedef struct _GstDeinterlaceSimpleMethodClass GstDeinterlaceSimpleMethodClass;
129 typedef struct _GstDeinterlaceScanlineData GstDeinterlaceScanlineData;
130
131 /*
132  * This structure defines the simple deinterlacer plugin.
133  */
134
135 struct _GstDeinterlaceScanlineData {
136  const guint8 *tt0, *t0, *m0, *b0, *bb0;
137  const guint8 *tt1, *t1, *m1, *b1, *bb1;
138  const guint8 *tt2, *t2, *m2, *b2, *bb2;
139  const guint8 *tt3, *t3, *m3, *b3, *bb3;
140  gboolean bottom_field;
141 };
142
143 /*
144  * For interpolate_scanline the input is:
145  *
146  * |   t-3       t-2       t-1       t
147  * | Field 3 | Field 2 | Field 1 | Field 0 |
148  * |  TT3    |         |   TT1   |         |
149  * |         |   T2    |         |   T0    |
150  * |   M3    |         |    M1   |         |
151  * |         |   B2    |         |   B0    |
152  * |  BB3    |         |   BB1   |         |
153  *
154  * For copy_scanline the input is:
155  *
156  * |   t-3       t-2       t-1       t
157  * | Field 3 | Field 2 | Field 1 | Field 0 |
158  * |         |   TT2   |         |  TT0    |
159  * |   T3    |         |   T1    |         |
160  * |         |    M2   |         |   M0    |
161  * |   B3    |         |   B1    |         |
162  * |         |   BB2   |         |  BB0    |
163  *
164  * All other values are NULL.
165  */
166
167 typedef void (*GstDeinterlaceSimpleMethodFunction) (GstDeinterlaceSimpleMethod *self, guint8 *out, const GstDeinterlaceScanlineData *scanlines);
168
169 struct _GstDeinterlaceSimpleMethod {
170   GstDeinterlaceMethod parent;
171
172   GstDeinterlaceSimpleMethodFunction interpolate_scanline_packed;
173   GstDeinterlaceSimpleMethodFunction copy_scanline_packed;
174
175   GstDeinterlaceSimpleMethodFunction interpolate_scanline_planar[3];
176   GstDeinterlaceSimpleMethodFunction copy_scanline_planar[3];
177 };
178
179 struct _GstDeinterlaceSimpleMethodClass {
180   GstDeinterlaceMethodClass parent_class;
181
182   /* Packed formats */
183   GstDeinterlaceSimpleMethodFunction interpolate_scanline_yuy2;
184   GstDeinterlaceSimpleMethodFunction copy_scanline_yuy2;
185   GstDeinterlaceSimpleMethodFunction interpolate_scanline_yvyu;
186   GstDeinterlaceSimpleMethodFunction copy_scanline_yvyu;
187   GstDeinterlaceSimpleMethodFunction interpolate_scanline_uyvy;
188   GstDeinterlaceSimpleMethodFunction copy_scanline_uyvy;
189   GstDeinterlaceSimpleMethodFunction interpolate_scanline_ayuv;
190   GstDeinterlaceSimpleMethodFunction copy_scanline_ayuv;
191   GstDeinterlaceSimpleMethodFunction interpolate_scanline_argb;
192   GstDeinterlaceSimpleMethodFunction copy_scanline_argb;
193   GstDeinterlaceSimpleMethodFunction interpolate_scanline_abgr;
194   GstDeinterlaceSimpleMethodFunction copy_scanline_abgr;
195   GstDeinterlaceSimpleMethodFunction interpolate_scanline_rgba;
196   GstDeinterlaceSimpleMethodFunction copy_scanline_rgba;
197   GstDeinterlaceSimpleMethodFunction interpolate_scanline_bgra;
198   GstDeinterlaceSimpleMethodFunction copy_scanline_bgra;
199   GstDeinterlaceSimpleMethodFunction interpolate_scanline_rgb;
200   GstDeinterlaceSimpleMethodFunction copy_scanline_rgb;
201   GstDeinterlaceSimpleMethodFunction interpolate_scanline_bgr;
202   GstDeinterlaceSimpleMethodFunction copy_scanline_bgr;
203
204   /* Semi-planar formats */
205   GstDeinterlaceSimpleMethodFunction interpolate_scanline_nv12;
206   GstDeinterlaceSimpleMethodFunction copy_scanline_nv12;
207   GstDeinterlaceSimpleMethodFunction interpolate_scanline_nv21;
208   GstDeinterlaceSimpleMethodFunction copy_scanline_nv21;
209
210   /* Planar formats */
211   GstDeinterlaceSimpleMethodFunction copy_scanline_planar_y;
212   GstDeinterlaceSimpleMethodFunction interpolate_scanline_planar_y;
213   GstDeinterlaceSimpleMethodFunction copy_scanline_planar_u;
214   GstDeinterlaceSimpleMethodFunction interpolate_scanline_planar_u;
215   GstDeinterlaceSimpleMethodFunction copy_scanline_planar_v;
216   GstDeinterlaceSimpleMethodFunction interpolate_scanline_planar_v;
217 };
218
219 GType gst_deinterlace_simple_method_get_type (void);
220
221 G_END_DECLS
222
223 #endif /* __GST_DEINTERLACE_METHOD_H__ */