3 * Copyright (C) 2005 Martin Eikermann <meiker@upb.de>
4 * Copyright (C) 2008-2010 Sebastian Dröge <slomo@collabora.co.uk>
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
16 * You should have received a copy of the GNU Library General Public
17 * License along with this library; if not, write to the
18 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 * Boston, MA 02111-1307, USA.
22 #ifndef __GST_DEINTERLACE_H__
23 #define __GST_DEINTERLACE_H__
26 #include <gst/video/video.h>
28 #include <liboil/liboil.h>
29 #include <liboil/liboilcpu.h>
30 #include <liboil/liboilfunction.h>
33 #if defined(HAVE_CPU_I386) || defined(HAVE_CPU_X86_64)
40 #define GST_TYPE_DEINTERLACE \
41 (gst_deinterlace_get_type())
42 #define GST_DEINTERLACE(obj) \
43 (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_DEINTERLACE,GstDeinterlace))
44 #define GST_DEINTERLACE_CLASS(klass) \
45 (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_DEINTERLACE,GstDeinterlace))
46 #define GST_IS_DEINTERLACE(obj) \
47 (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_DEINTERLACE))
48 #define GST_IS_DEINTERLACE_CLASS(obj) \
49 (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_DEINTERLACE))
51 typedef struct _GstDeinterlace GstDeinterlace;
52 typedef struct _GstDeinterlaceClass GstDeinterlaceClass;
54 #define GST_TYPE_DEINTERLACE_METHOD (gst_deinterlace_method_get_type ())
55 #define GST_IS_DEINTERLACE_METHOD(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_DEINTERLACE_METHOD))
56 #define GST_IS_DEINTERLACE_METHOD_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_DEINTERLACE_METHOD))
57 #define GST_DEINTERLACE_METHOD_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_DEINTERLACE_METHOD, GstDeinterlaceMethodClass))
58 #define GST_DEINTERLACE_METHOD(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_DEINTERLACE_METHOD, GstDeinterlaceMethod))
59 #define GST_DEINTERLACE_METHOD_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_DEINTERLACE_METHOD, GstDeinterlaceMethodClass))
60 #define GST_DEINTERLACE_METHOD_CAST(obj) ((GstDeinterlaceMethod*)(obj))
62 typedef struct _GstDeinterlaceMethod GstDeinterlaceMethod;
63 typedef struct _GstDeinterlaceMethodClass GstDeinterlaceMethodClass;
66 #define PICTURE_PROGRESSIVE 0
67 #define PICTURE_INTERLACED_BOTTOM 1
68 #define PICTURE_INTERLACED_TOP 2
69 #define PICTURE_INTERLACED_MASK (PICTURE_INTERLACED_BOTTOM | PICTURE_INTERLACED_TOP)
73 /* pointer to the start of data for this field */
75 /* see PICTURE_ flags in *.c */
77 } GstDeinterlaceField;
80 * This structure defines the deinterlacer plugin.
84 typedef void (*GstDeinterlaceMethodDeinterlaceFunction) (GstDeinterlaceMethod *self, const GstDeinterlaceField *history, guint history_count, GstBuffer *outbuf);
86 struct _GstDeinterlaceMethod {
89 GstVideoFormat format;
90 gint frame_width, frame_height;
97 GstDeinterlaceMethodDeinterlaceFunction deinterlace_frame;
100 struct _GstDeinterlaceMethodClass {
101 GstObjectClass parent_class;
102 guint fields_required;
105 gboolean (*supported) (GstDeinterlaceMethodClass *klass, GstVideoFormat format, gint width, gint height);
107 void (*setup) (GstDeinterlaceMethod *self, GstVideoFormat format, gint width, gint height);
109 GstDeinterlaceMethodDeinterlaceFunction deinterlace_frame_yuy2;
110 GstDeinterlaceMethodDeinterlaceFunction deinterlace_frame_yvyu;
116 GType gst_deinterlace_method_get_type (void);
118 #define GST_TYPE_DEINTERLACE_SIMPLE_METHOD (gst_deinterlace_simple_method_get_type ())
119 #define GST_IS_DEINTERLACE_SIMPLE_METHOD(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_DEINTERLACE_SIMPLE_METHOD))
120 #define GST_IS_DEINTERLACE_SIMPLE_METHOD_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_DEINTERLACE_SIMPLE_METHOD))
121 #define GST_DEINTERLACE_SIMPLE_METHOD_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_DEINTERLACE_SIMPLE_METHOD, GstDeinterlaceSimpleMethodClass))
122 #define GST_DEINTERLACE_SIMPLE_METHOD(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_DEINTERLACE_SIMPLE_METHOD, GstDeinterlaceSimpleMethod))
123 #define GST_DEINTERLACE_SIMPLE_METHOD_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_DEINTERLACE_SIMPLE_METHOD, GstDeinterlaceSimpleMethodClass))
124 #define GST_DEINTERLACE_SIMPLE_METHOD_CAST(obj) ((GstDeinterlaceSimpleMethod*)(obj))
126 typedef struct _GstDeinterlaceSimpleMethod GstDeinterlaceSimpleMethod;
127 typedef struct _GstDeinterlaceSimpleMethodClass GstDeinterlaceSimpleMethodClass;
128 typedef struct _GstDeinterlaceScanlineData GstDeinterlaceScanlineData;
131 * This structure defines the simple deinterlacer plugin.
134 struct _GstDeinterlaceScanlineData {
135 const guint8 *tt0, *t0, *m0, *b0, *bb0;
136 const guint8 *tt1, *t1, *m1, *b1, *bb1;
137 const guint8 *tt2, *t2, *m2, *b2, *bb2;
138 const guint8 *tt3, *t3, *m3, *b3, *bb3;
139 gboolean bottom_field;
143 * For interpolate_scanline the input is:
146 * | Field 3 | Field 2 | Field 1 | Field 0 |
153 * For copy_scanline the input is:
156 * | Field 3 | Field 2 | Field 1 | Field 0 |
163 * All other values are NULL.
166 typedef void (*GstDeinterlaceSimpleMethodPackedFunction) (GstDeinterlaceSimpleMethod *self, guint8 *out, const GstDeinterlaceScanlineData *scanlines);
168 struct _GstDeinterlaceSimpleMethod {
169 GstDeinterlaceMethod parent;
171 GstDeinterlaceSimpleMethodPackedFunction interpolate_scanline_packed;
172 GstDeinterlaceSimpleMethodPackedFunction copy_scanline_packed;
175 struct _GstDeinterlaceSimpleMethodClass {
176 GstDeinterlaceMethodClass parent_class;
179 GstDeinterlaceSimpleMethodPackedFunction interpolate_scanline_yuy2;
180 GstDeinterlaceSimpleMethodPackedFunction copy_scanline_yuy2;
181 GstDeinterlaceSimpleMethodPackedFunction interpolate_scanline_yvyu;
182 GstDeinterlaceSimpleMethodPackedFunction copy_scanline_yvyu;
185 GType gst_deinterlace_simple_method_get_type (void);
187 #define GST_DEINTERLACE_MAX_FIELD_HISTORY 10
191 GST_DEINTERLACE_TOMSMOCOMP,
192 GST_DEINTERLACE_GREEDY_H,
193 GST_DEINTERLACE_GREEDY_L,
194 GST_DEINTERLACE_VFIR,
195 GST_DEINTERLACE_LINEAR,
196 GST_DEINTERLACE_LINEAR_BLEND,
197 GST_DEINTERLACE_SCALER_BOB,
198 GST_DEINTERLACE_WEAVE,
199 GST_DEINTERLACE_WEAVE_TFF,
200 GST_DEINTERLACE_WEAVE_BFF
201 } GstDeinterlaceMethods;
205 GST_DEINTERLACE_ALL, /* All (missing data is interp.) */
206 GST_DEINTERLACE_TF, /* Top Fields Only */
207 GST_DEINTERLACE_BF /* Bottom Fields Only */
208 } GstDeinterlaceFields;
212 GST_DEINTERLACE_LAYOUT_AUTO,
213 GST_DEINTERLACE_LAYOUT_TFF,
214 GST_DEINTERLACE_LAYOUT_BFF
215 } GstDeinterlaceFieldLayout;
218 GST_DEINTERLACE_MODE_AUTO,
219 GST_DEINTERLACE_MODE_INTERLACED,
220 GST_DEINTERLACE_MODE_DISABLED
221 } GstDeinterlaceMode;
223 struct _GstDeinterlace
227 GstPad *srcpad, *sinkpad;
230 GstDeinterlaceMode mode;
232 GstDeinterlaceFieldLayout field_layout;
234 GstDeinterlaceFields fields;
236 GstDeinterlaceMethods method_id;
237 GstDeinterlaceMethod *method;
239 GstVideoFormat format;
240 gint width, height; /* frame width & height */
241 guint frame_size; /* frame size in bytes */
242 gint fps_n, fps_d; /* frame rate */
243 gboolean interlaced; /* is input interlaced? */
245 gboolean passthrough;
247 GstClockTime field_duration; /* Duration of one field */
249 /* The most recent pictures
250 PictureHistory[0] is always the most recent.
251 Pointers are NULL if the picture in question isn't valid, e.g. because
252 the program just started or a picture was skipped.
254 GstDeinterlaceField field_history[GST_DEINTERLACE_MAX_FIELD_HISTORY];
257 /* Set to TRUE if we're in still frame mode,
258 i.e. just forward all buffers
260 gboolean still_frame_mode;
262 /* Last buffer that was pushed in */
263 GstBuffer *last_buffer;
265 /* Current segment */
270 GstClockTime earliest_time;
272 /* Upstream negotiation stuff */
276 GstCaps *request_caps;
279 struct _GstDeinterlaceClass
281 GstElementClass parent_class;
284 GType gst_deinterlace_get_type (void);
288 #endif /* __GST_DEINTERLACE_H__ */