v4l2videodec: Increase v4l2videodecoder rank
[platform/upstream/gst-plugins-good.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., 51 Franklin St, Fifth Floor,
19  * Boston, MA 02110-1301, 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 #include <gst/video/gstvideopool.h>
28 #include <gst/video/gstvideometa.h>
29
30 #include "gstdeinterlacemethod.h"
31
32 G_BEGIN_DECLS
33
34 #define GST_TYPE_DEINTERLACE \
35   (gst_deinterlace_get_type())
36 #define GST_DEINTERLACE(obj) \
37   (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_DEINTERLACE,GstDeinterlace))
38 #define GST_DEINTERLACE_CLASS(klass) \
39   (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_DEINTERLACE,GstDeinterlace))
40 #define GST_IS_DEINTERLACE(obj) \
41   (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_DEINTERLACE))
42 #define GST_IS_DEINTERLACE_CLASS(obj) \
43   (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_DEINTERLACE))
44
45 typedef struct _GstDeinterlace GstDeinterlace;
46 typedef struct _GstDeinterlaceClass GstDeinterlaceClass;
47
48 typedef enum
49 {
50   GST_DEINTERLACE_TOMSMOCOMP,
51   GST_DEINTERLACE_GREEDY_H,
52   GST_DEINTERLACE_GREEDY_L,
53   GST_DEINTERLACE_VFIR,
54   GST_DEINTERLACE_LINEAR,
55   GST_DEINTERLACE_LINEAR_BLEND,
56   GST_DEINTERLACE_SCALER_BOB,
57   GST_DEINTERLACE_WEAVE,
58   GST_DEINTERLACE_WEAVE_TFF,
59   GST_DEINTERLACE_WEAVE_BFF
60 } GstDeinterlaceMethods;
61
62 typedef enum
63 {
64   GST_DEINTERLACE_ALL,         /* All (missing data is interp.) */
65   GST_DEINTERLACE_TF,          /* Top Fields Only */
66   GST_DEINTERLACE_BF,          /* Bottom Fields Only */
67   GST_DEINTERLACE_FIELDS_AUTO  /* Automatically detect */
68 } GstDeinterlaceFields;
69
70 typedef enum
71 {
72   GST_DEINTERLACE_LAYOUT_AUTO,
73   GST_DEINTERLACE_LAYOUT_TFF,
74   GST_DEINTERLACE_LAYOUT_BFF
75 } GstDeinterlaceFieldLayout;
76
77 typedef enum {
78   GST_DEINTERLACE_MODE_AUTO,
79   GST_DEINTERLACE_MODE_INTERLACED,
80   GST_DEINTERLACE_MODE_DISABLED,
81   GST_DEINTERLACE_MODE_AUTO_STRICT
82 } GstDeinterlaceMode;
83
84 typedef enum
85 {
86   GST_DEINTERLACE_LOCKING_NONE,
87   GST_DEINTERLACE_LOCKING_AUTO,
88   GST_DEINTERLACE_LOCKING_ACTIVE,
89   GST_DEINTERLACE_LOCKING_PASSIVE,
90 } GstDeinterlaceLocking;
91
92 #define GST_DEINTERLACE_MAX_FIELD_HISTORY 10
93 #define GST_DEINTERLACE_MAX_BUFFER_STATE_HISTORY 50
94 /* check max field history is large enough */
95 #if GST_DEINTERLACE_MAX_FIELD_HISTORY < GST_DEINTERLACE_MAX_BUFFER_STATE_HISTORY * 3
96 #undef GST_DEINTERLACE_MAX_FIELD_HISTORY
97 #define GST_DEINTERLACE_MAX_FIELD_HISTORY (GST_DEINTERLACE_MAX_BUFFER_STATE_HISTORY * 3)
98 #endif
99
100 typedef struct _TelecinePattern TelecinePattern;
101 struct _TelecinePattern
102 {
103   const gchar *nick;
104   guint8 length;
105   guint8 ratio_n, ratio_d;
106   guint8 states[GST_DEINTERLACE_MAX_BUFFER_STATE_HISTORY];
107 };
108
109 typedef struct _GstDeinterlaceBufferState GstDeinterlaceBufferState;
110 struct _GstDeinterlaceBufferState
111 {
112   GstClockTime timestamp;
113   GstClockTime duration;
114   guint8 state;
115 };
116
117 struct _GstDeinterlace
118 {
119   GstElement parent;
120
121   GstPad *srcpad, *sinkpad;
122
123   /* <private> */
124   GstDeinterlaceMode mode;
125
126   GstDeinterlaceFieldLayout field_layout;
127
128   GstDeinterlaceFields fields;
129
130   GstDeinterlaceFields user_set_fields;
131
132   /* current state (differs when flushing/inverse telecine using weave) */
133   GstDeinterlaceMethods method_id;
134   /* property value */
135   GstDeinterlaceMethods user_set_method_id;
136   GstDeinterlaceMethod *method;
137
138   GstVideoInfo vinfo;
139   GstBufferPool *pool;
140   GstAllocator *allocator;
141   GstAllocationParams params;
142
143   gboolean passthrough;
144   gboolean discont;
145
146   GstClockTime field_duration; /* Duration of one field */
147
148   /* The most recent pictures 
149      PictureHistory[0] is always the most recent.
150      Pointers are NULL if the picture in question isn't valid, e.g. because
151      the program just started or a picture was skipped.
152    */
153   GstDeinterlaceField field_history[GST_DEINTERLACE_MAX_FIELD_HISTORY];
154   guint history_count;
155   int cur_field_idx;
156
157   /* Set to TRUE if we're in still frame mode,
158      i.e. just forward all buffers
159    */
160   gboolean still_frame_mode;
161
162   /* Last buffer that was pushed in */
163   GstBuffer *last_buffer;
164
165   /* Current segment */
166   GstSegment segment;
167
168   /* QoS stuff */
169   gdouble proportion;
170   GstClockTime earliest_time;
171   gint64 processed;
172   gint64 dropped;
173
174   GstCaps *request_caps;
175
176   gboolean reconfigure;
177   GstDeinterlaceMode new_mode;
178   GstDeinterlaceFields new_fields;
179
180   GstDeinterlaceLocking locking;
181   gint low_latency;
182   gboolean drop_orphans;
183   gboolean ignore_obscure;
184   gboolean pattern_lock;
185   gboolean pattern_refresh;
186   GstDeinterlaceBufferState buf_states[GST_DEINTERLACE_MAX_BUFFER_STATE_HISTORY];
187   gint state_count;
188   gint pattern;
189   guint8 pattern_phase;
190   guint8 pattern_count;
191   guint8 output_count;
192   GstClockTime pattern_base_ts;
193   GstClockTime pattern_buf_dur;
194
195   gboolean need_more;
196   gboolean have_eos;
197   gboolean telecine_tc_warned;
198 };
199
200 struct _GstDeinterlaceClass
201 {
202   GstElementClass parent_class;
203 };
204
205 GType gst_deinterlace_get_type (void);
206
207 G_END_DECLS
208
209 #endif /* __GST_DEINTERLACE_H__ */