3 * Copyright (C) 2005 Martin Eikermann <meiker@upb.de>
4 * Copyright (C) 2008-2009 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>
27 #include <liboil/liboil.h>
28 #include <liboil/liboilcpu.h>
29 #include <liboil/liboilfunction.h>
32 #if defined(HAVE_CPU_I386) || defined(HAVE_CPU_X86_64)
39 #define GST_TYPE_DEINTERLACE \
40 (gst_deinterlace_get_type())
41 #define GST_DEINTERLACE(obj) \
42 (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_DEINTERLACE,GstDeinterlace))
43 #define GST_DEINTERLACE_CLASS(klass) \
44 (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_DEINTERLACE,GstDeinterlace))
45 #define GST_IS_DEINTERLACE(obj) \
46 (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_DEINTERLACE))
47 #define GST_IS_DEINTERLACE_CLASS(obj) \
48 (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_DEINTERLACE))
50 typedef struct _GstDeinterlace GstDeinterlace;
51 typedef struct _GstDeinterlaceClass GstDeinterlaceClass;
53 #define GST_TYPE_DEINTERLACE_METHOD (gst_deinterlace_method_get_type ())
54 #define GST_IS_DEINTERLACE_METHOD(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_DEINTERLACE_METHOD))
55 #define GST_IS_DEINTERLACE_METHOD_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_DEINTERLACE_METHOD))
56 #define GST_DEINTERLACE_METHOD_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_DEINTERLACE_METHOD, GstDeinterlaceMethodClass))
57 #define GST_DEINTERLACE_METHOD(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_DEINTERLACE_METHOD, GstDeinterlaceMethod))
58 #define GST_DEINTERLACE_METHOD_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_DEINTERLACE_METHOD, GstDeinterlaceMethodClass))
59 #define GST_DEINTERLACE_METHOD_CAST(obj) ((GstDeinterlaceMethod*)(obj))
61 typedef struct _GstDeinterlaceMethod GstDeinterlaceMethod;
62 typedef struct _GstDeinterlaceMethodClass GstDeinterlaceMethodClass;
65 * This structure defines the deinterlacer plugin.
68 struct _GstDeinterlaceMethod {
72 struct _GstDeinterlaceMethodClass {
73 GstObjectClass parent_class;
74 guint fields_required;
77 void (*deinterlace_frame) (GstDeinterlaceMethod *self, GstDeinterlace * parent, GstBuffer *outbuf);
83 GType gst_deinterlace_method_get_type (void);
85 #define GST_TYPE_DEINTERLACE_SIMPLE_METHOD (gst_deinterlace_simple_method_get_type ())
86 #define GST_IS_DEINTERLACE_SIMPLE_METHOD(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_DEINTERLACE_SIMPLE_METHOD))
87 #define GST_IS_DEINTERLACE_SIMPLE_METHOD_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_DEINTERLACE_SIMPLE_METHOD))
88 #define GST_DEINTERLACE_SIMPLE_METHOD_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_DEINTERLACE_SIMPLE_METHOD, GstDeinterlaceSimpleMethodClass))
89 #define GST_DEINTERLACE_SIMPLE_METHOD(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_DEINTERLACE_SIMPLE_METHOD, GstDeinterlaceSimpleMethod))
90 #define GST_DEINTERLACE_SIMPLE_METHOD_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_DEINTERLACE_SIMPLE_METHOD, GstDeinterlaceSimpleMethodClass))
91 #define GST_DEINTERLACE_SIMPLE_METHOD_CAST(obj) ((GstDeinterlaceSimpleMethod*)(obj))
93 typedef struct _GstDeinterlaceSimpleMethod GstDeinterlaceSimpleMethod;
94 typedef struct _GstDeinterlaceSimpleMethodClass GstDeinterlaceSimpleMethodClass;
95 typedef struct _GstDeinterlaceScanlineData GstDeinterlaceScanlineData;
98 * This structure defines the simple deinterlacer plugin.
101 struct _GstDeinterlaceScanlineData {
102 guint8 *tt0, *t0, *m0, *b0, *bb0;
103 guint8 *tt1, *t1, *m1, *b1, *bb1;
104 guint8 *tt2, *t2, *m2, *b2, *bb2;
105 guint8 *tt3, *t3, *m3, *b3, *bb3;
106 gboolean bottom_field;
110 * For interpolate_scanline the input is:
113 * | Field 3 | Field 2 | Field 1 | Field 0 |
120 * For copy_scanline the input is:
123 * | Field 3 | Field 2 | Field 1 | Field 0 |
130 * All other values are NULL.
133 struct _GstDeinterlaceSimpleMethod {
134 GstDeinterlaceMethod parent;
137 struct _GstDeinterlaceSimpleMethodClass {
138 GstDeinterlaceMethodClass parent_class;
140 void (*interpolate_scanline) (GstDeinterlaceMethod *self, GstDeinterlace * parent, guint8 *out, GstDeinterlaceScanlineData *scanlines, gint width);
141 void (*copy_scanline) (GstDeinterlaceMethod *self, GstDeinterlace * parent, guint8 *out, GstDeinterlaceScanlineData *scanlines, gint width);
144 GType gst_deinterlace_simple_method_get_type (void);
147 #define GST_DEINTERLACE_MAX_FIELD_HISTORY 10
149 #define PICTURE_PROGRESSIVE 0
150 #define PICTURE_INTERLACED_BOTTOM 1
151 #define PICTURE_INTERLACED_TOP 2
152 #define PICTURE_INTERLACED_MASK (PICTURE_INTERLACED_BOTTOM | PICTURE_INTERLACED_TOP)
156 /* pointer to the start of data for this field */
158 /* see PICTURE_ flags in *.c */
164 GST_DEINTERLACE_TOMSMOCOMP,
165 GST_DEINTERLACE_GREEDY_H,
166 GST_DEINTERLACE_GREEDY_L,
167 GST_DEINTERLACE_VFIR,
168 GST_DEINTERLACE_LINEAR,
169 GST_DEINTERLACE_LINEAR_BLEND,
170 GST_DEINTERLACE_SCALER_BOB,
171 GST_DEINTERLACE_WEAVE,
172 GST_DEINTERLACE_WEAVE_TFF,
173 GST_DEINTERLACE_WEAVE_BFF
174 } GstDeinterlaceMethods;
178 GST_DEINTERLACE_ALL, /* All (missing data is interp.) */
179 GST_DEINTERLACE_TF, /* Top Fields Only */
180 GST_DEINTERLACE_BF /* Bottom Fields Only */
181 } GstDeinterlaceFields;
185 GST_DEINTERLACE_LAYOUT_AUTO,
186 GST_DEINTERLACE_LAYOUT_TFF,
187 GST_DEINTERLACE_LAYOUT_BFF
188 } GstDeinterlaceFieldLayout;
191 GST_DEINTERLACE_MODE_AUTO,
192 GST_DEINTERLACE_MODE_INTERLACED,
193 GST_DEINTERLACE_MODE_DISABLED
194 } GstDeinterlaceMode;
196 struct _GstDeinterlace
200 GstPad *srcpad, *sinkpad;
204 GstDeinterlaceMode mode;
206 GstDeinterlaceFieldLayout field_layout;
208 GstDeinterlaceFields fields;
210 GstDeinterlaceMethods method_id;
211 GstDeinterlaceMethod *method;
214 gint frame_rate_n, frame_rate_d;
217 /* Number of bytes of actual data in each scanline. May be less than
218 OverlayPitch since the overlay's scanlines might have alignment
219 requirements. Generally equal to FrameWidth * 2.
223 /* Number of pixels in each scanline. */
226 /* Number of scanlines per frame. */
229 /* Number of scanlines per field. FrameHeight / 2, mostly for
230 cleanliness so we don't have to keep dividing FrameHeight by 2.
234 /* distance between lines in image
235 need not match the pixel width
239 /* Duration of one field */
240 GstClockTime field_duration;
242 /* The most recent pictures
243 PictureHistory[0] is always the most recent.
244 Pointers are NULL if the picture in question isn't valid, e.g. because
245 the program just started or a picture was skipped.
247 GstPicture field_history[GST_DEINTERLACE_MAX_FIELD_HISTORY];
250 /* Set to TRUE if we're in still frame mode,
251 i.e. just forward all buffers
253 gboolean still_frame_mode;
255 /* Last buffer that was pushed in */
256 GstBuffer *last_buffer;
258 /* Current segment */
263 GstClockTime earliest_time;
265 /* Upstream negotiation stuff */
269 GstCaps *request_caps;
272 struct _GstDeinterlaceClass
274 GstElementClass parent_class;
277 GType gst_deinterlace_get_type (void);
280 #endif /* __GST_DEINTERLACE_H__ */