Tizen 2.0 Release
[framework/multimedia/gst-plugins-good0.10.git] / gst / deinterlace / gstdeinterlace.h
1 /*
2  * GStreamer
3  * Copyright (C) 2005 Martin Eikermann <meiker@upb.de>
4  * Copyright (C) 2008-2010 Sebastian Dröge <slomo@collabora.co.uk>
5  *
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.
10  *
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.
15  *
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.
20  */
21
22 #ifndef __GST_DEINTERLACE_H__
23 #define __GST_DEINTERLACE_H__
24
25 #include <gst/gst.h>
26 #include <gst/video/video.h>
27
28 #include "gstdeinterlacemethod.h"
29
30 G_BEGIN_DECLS
31
32 #define GST_TYPE_DEINTERLACE \
33   (gst_deinterlace_get_type())
34 #define GST_DEINTERLACE(obj) \
35   (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_DEINTERLACE,GstDeinterlace))
36 #define GST_DEINTERLACE_CLASS(klass) \
37   (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_DEINTERLACE,GstDeinterlace))
38 #define GST_IS_DEINTERLACE(obj) \
39   (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_DEINTERLACE))
40 #define GST_IS_DEINTERLACE_CLASS(obj) \
41   (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_DEINTERLACE))
42
43 typedef struct _GstDeinterlace GstDeinterlace;
44 typedef struct _GstDeinterlaceClass GstDeinterlaceClass;
45
46 typedef enum
47 {
48   GST_DEINTERLACE_TOMSMOCOMP,
49   GST_DEINTERLACE_GREEDY_H,
50   GST_DEINTERLACE_GREEDY_L,
51   GST_DEINTERLACE_VFIR,
52   GST_DEINTERLACE_LINEAR,
53   GST_DEINTERLACE_LINEAR_BLEND,
54   GST_DEINTERLACE_SCALER_BOB,
55   GST_DEINTERLACE_WEAVE,
56   GST_DEINTERLACE_WEAVE_TFF,
57   GST_DEINTERLACE_WEAVE_BFF
58 } GstDeinterlaceMethods;
59
60 typedef enum
61 {
62   GST_DEINTERLACE_ALL,         /* All (missing data is interp.) */
63   GST_DEINTERLACE_TF,          /* Top Fields Only */
64   GST_DEINTERLACE_BF           /* Bottom Fields Only */
65 } GstDeinterlaceFields;
66
67 typedef enum
68 {
69   GST_DEINTERLACE_LAYOUT_AUTO,
70   GST_DEINTERLACE_LAYOUT_TFF,
71   GST_DEINTERLACE_LAYOUT_BFF
72 } GstDeinterlaceFieldLayout;
73
74 typedef enum {
75   GST_DEINTERLACE_MODE_AUTO,
76   GST_DEINTERLACE_MODE_INTERLACED,
77   GST_DEINTERLACE_MODE_DISABLED
78 } GstDeinterlaceMode;
79
80 typedef enum
81 {
82   GST_DEINTERLACE_LOCKING_NONE,
83   GST_DEINTERLACE_LOCKING_AUTO,
84   GST_DEINTERLACE_LOCKING_ACTIVE,
85   GST_DEINTERLACE_LOCKING_PASSIVE,
86 } GstDeinterlaceLocking;
87
88 #define GST_DEINTERLACE_MAX_FIELD_HISTORY 10
89 #define GST_DEINTERLACE_MAX_BUFFER_STATE_HISTORY 50
90 /* check max field history is large enough */
91 #if GST_DEINTERLACE_MAX_FIELD_HISTORY < GST_DEINTERLACE_MAX_BUFFER_STATE_HISTORY * 3
92 #undef GST_DEINTERLACE_MAX_FIELD_HISTORY
93 #define GST_DEINTERLACE_MAX_FIELD_HISTORY (GST_DEINTERLACE_MAX_BUFFER_STATE_HISTORY * 3)
94 #endif
95
96 typedef struct _TelecinePattern TelecinePattern;
97 struct _TelecinePattern
98 {
99   const gchar *nick;
100   guint8 length;
101   guint8 ratio_n, ratio_d;
102   guint8 states[GST_DEINTERLACE_MAX_BUFFER_STATE_HISTORY];
103 };
104
105 typedef struct _GstDeinterlaceBufferState GstDeinterlaceBufferState;
106 struct _GstDeinterlaceBufferState
107 {
108   GstClockTime timestamp;
109   GstClockTime duration;
110   guint8 state;
111 };
112
113 struct _GstDeinterlace
114 {
115   GstElement parent;
116
117   GstPad *srcpad, *sinkpad;
118
119   /* <private> */
120   GstDeinterlaceMode mode;
121
122   GstDeinterlaceFieldLayout field_layout;
123
124   GstDeinterlaceFields fields;
125
126   /* current state (differs when flushing/inverse telecine using weave) */
127   GstDeinterlaceMethods method_id;
128   /* property value */
129   GstDeinterlaceMethods user_set_method_id;
130   GstDeinterlaceMethod *method;
131
132   GstVideoFormat format;
133   gint width, height; /* frame width & height */
134   guint frame_size; /* frame size in bytes */
135   gint fps_n, fps_d; /* frame rate */
136   gboolean interlaced; /* is input interlaced? */
137
138   gboolean passthrough;
139
140   GstClockTime field_duration; /* Duration of one field */
141
142   /* The most recent pictures 
143      PictureHistory[0] is always the most recent.
144      Pointers are NULL if the picture in question isn't valid, e.g. because
145      the program just started or a picture was skipped.
146    */
147   GstDeinterlaceField field_history[GST_DEINTERLACE_MAX_FIELD_HISTORY];
148   guint history_count;
149   int cur_field_idx;
150
151   /* Set to TRUE if we're in still frame mode,
152      i.e. just forward all buffers
153    */
154   gboolean still_frame_mode;
155
156   /* Last buffer that was pushed in */
157   GstBuffer *last_buffer;
158
159   /* Current segment */
160   GstSegment segment;
161
162   /* QoS stuff */
163   gdouble proportion;
164   GstClockTime earliest_time;
165
166   GstCaps *request_caps;
167
168   gboolean reconfigure;
169   GstDeinterlaceMode new_mode;
170   GstDeinterlaceFields new_fields;
171
172   GstDeinterlaceLocking locking;
173   gint low_latency;
174   gboolean drop_orphans;
175   gboolean ignore_obscure;
176   gboolean pattern_lock;
177   gboolean pattern_refresh;
178   GstDeinterlaceBufferState buf_states[GST_DEINTERLACE_MAX_BUFFER_STATE_HISTORY];
179   gint state_count;
180   gint pattern;
181   guint8 pattern_phase;
182   guint8 pattern_count;
183   guint8 output_count;
184   GstClockTime pattern_base_ts;
185   GstClockTime pattern_buf_dur;
186
187   gboolean need_more;
188   gboolean have_eos;
189 };
190
191 struct _GstDeinterlaceClass
192 {
193   GstElementClass parent_class;
194 };
195
196 GType gst_deinterlace_get_type (void);
197
198 G_END_DECLS
199
200 #endif /* __GST_DEINTERLACE_H__ */