3 * Copyright (C) 2008-2010 Sebastian Dröge <slomo@collabora.co.uk>
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.
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.
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., 51 Franklin St, Fifth Floor,
18 * Boston, MA 02110-1301, USA.
21 #ifndef __GST_DEINTERLACE_METHOD_H__
22 #define __GST_DEINTERLACE_METHOD_H__
25 #include <gst/video/video.h>
27 #if defined(HAVE_GCC_ASM) && defined(HAVE_ORC)
28 #if defined(HAVE_CPU_I386) || defined(HAVE_CPU_X86_64)
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))
43 typedef struct _GstDeinterlaceMethod GstDeinterlaceMethod;
44 typedef struct _GstDeinterlaceMethodClass GstDeinterlaceMethodClass;
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)
55 /* see PICTURE_ flags in *.c */
57 } GstDeinterlaceField;
60 * This structure defines the deinterlacer plugin.
63 typedef void (*GstDeinterlaceMethodDeinterlaceFunction) (
64 GstDeinterlaceMethod *self, const GstDeinterlaceField *history,
65 guint history_count, GstVideoFrame *outframe, int cur_field_idx);
67 struct _GstDeinterlaceMethod {
72 GstDeinterlaceMethodDeinterlaceFunction deinterlace_frame;
75 struct _GstDeinterlaceMethodClass {
76 GstObjectClass parent_class;
77 guint fields_required;
80 gboolean (*supported) (GstDeinterlaceMethodClass *klass, GstVideoFormat format, gint width, gint height);
82 void (*setup) (GstDeinterlaceMethod *self, GstVideoInfo * vinfo);
84 GstDeinterlaceMethodDeinterlaceFunction deinterlace_frame_yuy2;
85 GstDeinterlaceMethodDeinterlaceFunction deinterlace_frame_yvyu;
86 GstDeinterlaceMethodDeinterlaceFunction deinterlace_frame_uyvy;
87 GstDeinterlaceMethodDeinterlaceFunction deinterlace_frame_i420;
88 GstDeinterlaceMethodDeinterlaceFunction deinterlace_frame_yv12;
89 GstDeinterlaceMethodDeinterlaceFunction deinterlace_frame_y444;
90 GstDeinterlaceMethodDeinterlaceFunction deinterlace_frame_y42b;
91 GstDeinterlaceMethodDeinterlaceFunction deinterlace_frame_y41b;
92 GstDeinterlaceMethodDeinterlaceFunction deinterlace_frame_ayuv;
93 GstDeinterlaceMethodDeinterlaceFunction deinterlace_frame_nv12;
94 GstDeinterlaceMethodDeinterlaceFunction deinterlace_frame_nv21;
95 GstDeinterlaceMethodDeinterlaceFunction deinterlace_frame_argb;
96 GstDeinterlaceMethodDeinterlaceFunction deinterlace_frame_abgr;
97 GstDeinterlaceMethodDeinterlaceFunction deinterlace_frame_rgba;
98 GstDeinterlaceMethodDeinterlaceFunction deinterlace_frame_bgra;
99 GstDeinterlaceMethodDeinterlaceFunction deinterlace_frame_rgb;
100 GstDeinterlaceMethodDeinterlaceFunction deinterlace_frame_bgr;
106 GType gst_deinterlace_method_get_type (void);
108 gboolean gst_deinterlace_method_supported (GType type, GstVideoFormat format, gint width, gint height);
109 void gst_deinterlace_method_setup (GstDeinterlaceMethod * self, GstVideoInfo * vinfo);
110 void gst_deinterlace_method_deinterlace_frame (GstDeinterlaceMethod * self, const GstDeinterlaceField * history, guint history_count, GstVideoFrame * outframe,
112 gint gst_deinterlace_method_get_fields_required (GstDeinterlaceMethod * self);
113 gint gst_deinterlace_method_get_latency (GstDeinterlaceMethod * self);
115 #define GST_TYPE_DEINTERLACE_SIMPLE_METHOD (gst_deinterlace_simple_method_get_type ())
116 #define GST_IS_DEINTERLACE_SIMPLE_METHOD(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_DEINTERLACE_SIMPLE_METHOD))
117 #define GST_IS_DEINTERLACE_SIMPLE_METHOD_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_DEINTERLACE_SIMPLE_METHOD))
118 #define GST_DEINTERLACE_SIMPLE_METHOD_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_DEINTERLACE_SIMPLE_METHOD, GstDeinterlaceSimpleMethodClass))
119 #define GST_DEINTERLACE_SIMPLE_METHOD(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_DEINTERLACE_SIMPLE_METHOD, GstDeinterlaceSimpleMethod))
120 #define GST_DEINTERLACE_SIMPLE_METHOD_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_DEINTERLACE_SIMPLE_METHOD, GstDeinterlaceSimpleMethodClass))
121 #define GST_DEINTERLACE_SIMPLE_METHOD_CAST(obj) ((GstDeinterlaceSimpleMethod*)(obj))
123 typedef struct _GstDeinterlaceSimpleMethod GstDeinterlaceSimpleMethod;
124 typedef struct _GstDeinterlaceSimpleMethodClass GstDeinterlaceSimpleMethodClass;
125 typedef struct _GstDeinterlaceScanlineData GstDeinterlaceScanlineData;
128 * This structure defines the simple deinterlacer plugin.
131 struct _GstDeinterlaceScanlineData {
132 const guint8 *ttp, *tp, *mp, *bp, *bbp;
133 const guint8 *tt0, *t0, *m0, *b0, *bb0;
134 const guint8 *tt1, *t1, *m1, *b1, *bb1;
135 const guint8 *tt2, *t2, *m2, *b2, *bb2;
136 gboolean bottom_field;
140 * For interpolate_scanline the input is:
142 * | t-3 t-2 t-1 t t+1
143 * | Field 3 | Field 2 | Field 1 | Field 0 | Field -1
144 * | TT3 | | TT1 | | TTp
148 * | BB3 | | BB1 | | BBp
150 * For copy_scanline the input is:
152 * | t-3 t-2 t-1 t t+1
153 * | Field 3 | Field 2 | Field 1 | Field 0 | Field -1
160 * All other values are NULL.
163 typedef void (*GstDeinterlaceSimpleMethodFunction) (GstDeinterlaceSimpleMethod *self, guint8 *out, const GstDeinterlaceScanlineData *scanlines, guint size);
165 struct _GstDeinterlaceSimpleMethod {
166 GstDeinterlaceMethod parent;
168 GstDeinterlaceSimpleMethodFunction interpolate_scanline_packed;
169 GstDeinterlaceSimpleMethodFunction copy_scanline_packed;
171 GstDeinterlaceSimpleMethodFunction interpolate_scanline_planar[3];
172 GstDeinterlaceSimpleMethodFunction copy_scanline_planar[3];
175 struct _GstDeinterlaceSimpleMethodClass {
176 GstDeinterlaceMethodClass parent_class;
179 GstDeinterlaceSimpleMethodFunction interpolate_scanline_yuy2;
180 GstDeinterlaceSimpleMethodFunction copy_scanline_yuy2;
181 GstDeinterlaceSimpleMethodFunction interpolate_scanline_yvyu;
182 GstDeinterlaceSimpleMethodFunction copy_scanline_yvyu;
183 GstDeinterlaceSimpleMethodFunction interpolate_scanline_uyvy;
184 GstDeinterlaceSimpleMethodFunction copy_scanline_uyvy;
185 GstDeinterlaceSimpleMethodFunction interpolate_scanline_ayuv;
186 GstDeinterlaceSimpleMethodFunction copy_scanline_ayuv;
187 GstDeinterlaceSimpleMethodFunction interpolate_scanline_argb;
188 GstDeinterlaceSimpleMethodFunction copy_scanline_argb;
189 GstDeinterlaceSimpleMethodFunction interpolate_scanline_abgr;
190 GstDeinterlaceSimpleMethodFunction copy_scanline_abgr;
191 GstDeinterlaceSimpleMethodFunction interpolate_scanline_rgba;
192 GstDeinterlaceSimpleMethodFunction copy_scanline_rgba;
193 GstDeinterlaceSimpleMethodFunction interpolate_scanline_bgra;
194 GstDeinterlaceSimpleMethodFunction copy_scanline_bgra;
195 GstDeinterlaceSimpleMethodFunction interpolate_scanline_rgb;
196 GstDeinterlaceSimpleMethodFunction copy_scanline_rgb;
197 GstDeinterlaceSimpleMethodFunction interpolate_scanline_bgr;
198 GstDeinterlaceSimpleMethodFunction copy_scanline_bgr;
200 /* Semi-planar formats */
201 GstDeinterlaceSimpleMethodFunction interpolate_scanline_nv12;
202 GstDeinterlaceSimpleMethodFunction copy_scanline_nv12;
203 GstDeinterlaceSimpleMethodFunction interpolate_scanline_nv21;
204 GstDeinterlaceSimpleMethodFunction copy_scanline_nv21;
207 GstDeinterlaceSimpleMethodFunction copy_scanline_planar_y;
208 GstDeinterlaceSimpleMethodFunction interpolate_scanline_planar_y;
209 GstDeinterlaceSimpleMethodFunction copy_scanline_planar_u;
210 GstDeinterlaceSimpleMethodFunction interpolate_scanline_planar_u;
211 GstDeinterlaceSimpleMethodFunction copy_scanline_planar_v;
212 GstDeinterlaceSimpleMethodFunction interpolate_scanline_planar_v;
215 GType gst_deinterlace_simple_method_get_type (void);
219 #endif /* __GST_DEINTERLACE_METHOD_H__ */