a50ecbd07e3eb42955eea330fc5fd45ad78d8329
[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) (
65     GstDeinterlaceMethod *self, const GstDeinterlaceField *history,
66     guint history_count, GstBuffer *outbuf, int cur_field_idx);
67
68 struct _GstDeinterlaceMethod {
69   GstObject parent;
70
71   GstVideoFormat format;
72   gint frame_width, frame_height;
73   gint width[4];
74   gint height[4];
75   gint offset[4];
76   gint row_stride[4];
77   gint pixel_stride[4];
78
79   GstDeinterlaceMethodDeinterlaceFunction deinterlace_frame;
80 };
81
82 struct _GstDeinterlaceMethodClass {
83   GstObjectClass parent_class;
84   guint fields_required;
85   guint latency;
86
87   gboolean (*supported) (GstDeinterlaceMethodClass *klass, GstVideoFormat format, gint width, gint height);
88
89   void (*setup) (GstDeinterlaceMethod *self, GstVideoFormat format, gint width, gint height);
90
91   GstDeinterlaceMethodDeinterlaceFunction deinterlace_frame_yuy2;
92   GstDeinterlaceMethodDeinterlaceFunction deinterlace_frame_yvyu;
93   GstDeinterlaceMethodDeinterlaceFunction deinterlace_frame_uyvy;
94   GstDeinterlaceMethodDeinterlaceFunction deinterlace_frame_i420;
95   GstDeinterlaceMethodDeinterlaceFunction deinterlace_frame_yv12;
96   GstDeinterlaceMethodDeinterlaceFunction deinterlace_frame_y444;
97   GstDeinterlaceMethodDeinterlaceFunction deinterlace_frame_y42b;
98   GstDeinterlaceMethodDeinterlaceFunction deinterlace_frame_y41b;
99   GstDeinterlaceMethodDeinterlaceFunction deinterlace_frame_ayuv;
100   GstDeinterlaceMethodDeinterlaceFunction deinterlace_frame_nv12;
101   GstDeinterlaceMethodDeinterlaceFunction deinterlace_frame_nv21;
102   GstDeinterlaceMethodDeinterlaceFunction deinterlace_frame_argb;
103   GstDeinterlaceMethodDeinterlaceFunction deinterlace_frame_abgr;
104   GstDeinterlaceMethodDeinterlaceFunction deinterlace_frame_rgba;
105   GstDeinterlaceMethodDeinterlaceFunction deinterlace_frame_bgra;
106   GstDeinterlaceMethodDeinterlaceFunction deinterlace_frame_rgb;
107   GstDeinterlaceMethodDeinterlaceFunction deinterlace_frame_bgr;
108
109   const gchar *name;
110   const gchar *nick;
111 };
112
113 GType gst_deinterlace_method_get_type (void);
114
115 gboolean gst_deinterlace_method_supported (GType type, GstVideoFormat format, gint width, gint height);
116 void gst_deinterlace_method_setup (GstDeinterlaceMethod * self, GstVideoFormat format, gint width, gint height);
117 void gst_deinterlace_method_deinterlace_frame (GstDeinterlaceMethod * self, const GstDeinterlaceField * history, guint history_count, GstBuffer * outbuf,
118     int cur_field_idx);
119 gint gst_deinterlace_method_get_fields_required (GstDeinterlaceMethod * self);
120 gint gst_deinterlace_method_get_latency (GstDeinterlaceMethod * self);
121
122 #define GST_TYPE_DEINTERLACE_SIMPLE_METHOD              (gst_deinterlace_simple_method_get_type ())
123 #define GST_IS_DEINTERLACE_SIMPLE_METHOD(obj)           (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_DEINTERLACE_SIMPLE_METHOD))
124 #define GST_IS_DEINTERLACE_SIMPLE_METHOD_CLASS(klass)   (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_DEINTERLACE_SIMPLE_METHOD))
125 #define GST_DEINTERLACE_SIMPLE_METHOD_GET_CLASS(obj)    (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_DEINTERLACE_SIMPLE_METHOD, GstDeinterlaceSimpleMethodClass))
126 #define GST_DEINTERLACE_SIMPLE_METHOD(obj)              (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_DEINTERLACE_SIMPLE_METHOD, GstDeinterlaceSimpleMethod))
127 #define GST_DEINTERLACE_SIMPLE_METHOD_CLASS(klass)      (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_DEINTERLACE_SIMPLE_METHOD, GstDeinterlaceSimpleMethodClass))
128 #define GST_DEINTERLACE_SIMPLE_METHOD_CAST(obj) ((GstDeinterlaceSimpleMethod*)(obj))
129
130 typedef struct _GstDeinterlaceSimpleMethod GstDeinterlaceSimpleMethod;
131 typedef struct _GstDeinterlaceSimpleMethodClass GstDeinterlaceSimpleMethodClass;
132 typedef struct _GstDeinterlaceScanlineData GstDeinterlaceScanlineData;
133
134 /*
135  * This structure defines the simple deinterlacer plugin.
136  */
137
138 struct _GstDeinterlaceScanlineData {
139  const guint8 *ttp, *tp, *mp, *bp, *bbp;
140  const guint8 *tt0, *t0, *m0, *b0, *bb0;
141  const guint8 *tt1, *t1, *m1, *b1, *bb1;
142  const guint8 *tt2, *t2, *m2, *b2, *bb2;
143  gboolean bottom_field;
144 };
145
146 /*
147  * For interpolate_scanline the input is:
148  *
149  * |   t-3       t-2       t-1       t        t+1
150  * | Field 3 | Field 2 | Field 1 | Field 0 | Field -1
151  * |  TT3    |         |   TT1   |         |   TTp
152  * |         |   T2    |         |   T0    |
153  * |   M3    |         |    M1   |         |    Mp
154  * |         |   B2    |         |   B0    |
155  * |  BB3    |         |   BB1   |         |   BBp
156  *
157  * For copy_scanline the input is:
158  *
159  * |   t-3       t-2       t-1       t         t+1
160  * | Field 3 | Field 2 | Field 1 | Field 0 | Field -1
161  * |         |   TT2   |         |  TT0    |
162  * |   T3    |         |   T1    |         |   Tp
163  * |         |    M2   |         |   M0    |
164  * |   B3    |         |   B1    |         |   Bp
165  * |         |   BB2   |         |  BB0    |
166  *
167  * All other values are NULL.
168  */
169
170 typedef void (*GstDeinterlaceSimpleMethodFunction) (GstDeinterlaceSimpleMethod *self, guint8 *out, const GstDeinterlaceScanlineData *scanlines);
171
172 struct _GstDeinterlaceSimpleMethod {
173   GstDeinterlaceMethod parent;
174
175   GstDeinterlaceSimpleMethodFunction interpolate_scanline_packed;
176   GstDeinterlaceSimpleMethodFunction copy_scanline_packed;
177
178   GstDeinterlaceSimpleMethodFunction interpolate_scanline_planar[3];
179   GstDeinterlaceSimpleMethodFunction copy_scanline_planar[3];
180 };
181
182 struct _GstDeinterlaceSimpleMethodClass {
183   GstDeinterlaceMethodClass parent_class;
184
185   /* Packed formats */
186   GstDeinterlaceSimpleMethodFunction interpolate_scanline_yuy2;
187   GstDeinterlaceSimpleMethodFunction copy_scanline_yuy2;
188   GstDeinterlaceSimpleMethodFunction interpolate_scanline_yvyu;
189   GstDeinterlaceSimpleMethodFunction copy_scanline_yvyu;
190   GstDeinterlaceSimpleMethodFunction interpolate_scanline_uyvy;
191   GstDeinterlaceSimpleMethodFunction copy_scanline_uyvy;
192   GstDeinterlaceSimpleMethodFunction interpolate_scanline_ayuv;
193   GstDeinterlaceSimpleMethodFunction copy_scanline_ayuv;
194   GstDeinterlaceSimpleMethodFunction interpolate_scanline_argb;
195   GstDeinterlaceSimpleMethodFunction copy_scanline_argb;
196   GstDeinterlaceSimpleMethodFunction interpolate_scanline_abgr;
197   GstDeinterlaceSimpleMethodFunction copy_scanline_abgr;
198   GstDeinterlaceSimpleMethodFunction interpolate_scanline_rgba;
199   GstDeinterlaceSimpleMethodFunction copy_scanline_rgba;
200   GstDeinterlaceSimpleMethodFunction interpolate_scanline_bgra;
201   GstDeinterlaceSimpleMethodFunction copy_scanline_bgra;
202   GstDeinterlaceSimpleMethodFunction interpolate_scanline_rgb;
203   GstDeinterlaceSimpleMethodFunction copy_scanline_rgb;
204   GstDeinterlaceSimpleMethodFunction interpolate_scanline_bgr;
205   GstDeinterlaceSimpleMethodFunction copy_scanline_bgr;
206
207   /* Semi-planar formats */
208   GstDeinterlaceSimpleMethodFunction interpolate_scanline_nv12;
209   GstDeinterlaceSimpleMethodFunction copy_scanline_nv12;
210   GstDeinterlaceSimpleMethodFunction interpolate_scanline_nv21;
211   GstDeinterlaceSimpleMethodFunction copy_scanline_nv21;
212
213   /* Planar formats */
214   GstDeinterlaceSimpleMethodFunction copy_scanline_planar_y;
215   GstDeinterlaceSimpleMethodFunction interpolate_scanline_planar_y;
216   GstDeinterlaceSimpleMethodFunction copy_scanline_planar_u;
217   GstDeinterlaceSimpleMethodFunction interpolate_scanline_planar_u;
218   GstDeinterlaceSimpleMethodFunction copy_scanline_planar_v;
219   GstDeinterlaceSimpleMethodFunction interpolate_scanline_planar_v;
220 };
221
222 GType gst_deinterlace_simple_method_get_type (void);
223
224 G_END_DECLS
225
226 #endif /* __GST_DEINTERLACE_METHOD_H__ */