Move files from gst-plugins-bad into the "subprojects/gst-plugins-bad/" subdir
[platform/upstream/gstreamer.git] / subprojects / gst-plugins-bad / gst / fieldanalysis / gstfieldanalysis.h
1 /*
2  * GStreamer
3  * Copyright (C) 2010 Robert Swain <robert.swain@collabora.co.uk>
4  *
5  * Permission is hereby granted, free of charge, to any person obtaining a
6  * copy of this software and associated documentation files (the "Software"),
7  * to deal in the Software without restriction, including without limitation
8  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9  * and/or sell copies of the Software, and to permit persons to whom the
10  * Software is furnished to do so, subject to the following conditions:
11  *
12  * The above copyright notice and this permission notice shall be included in
13  * all copies or substantial portions of the Software.
14  *
15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21  * DEALINGS IN THE SOFTWARE.
22  *
23  * Alternatively, the contents of this file may be used under the
24  * GNU Lesser General Public License Version 2.1 (the "LGPL"), in
25  * which case the following provisions apply instead of the ones
26  * mentioned above:
27  *
28  * This library is free software; you can redistribute it and/or
29  * modify it under the terms of the GNU Library General Public
30  * License as published by the Free Software Foundation; either
31  * version 2 of the License, or (at your option) any later version.
32  *
33  * This library is distributed in the hope that it will be useful,
34  * but WITHOUT ANY WARRANTY; without even the implied warranty of
35  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
36  * Library General Public License for more details.
37  *
38  * You should have received a copy of the GNU Library General Public
39  * License along with this library; if not, write to the
40  * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
41  * Boston, MA 02110-1301, USA.
42  */
43
44 #ifndef __GST_FIELDANALYSIS_H__
45 #define __GST_FIELDANALYSIS_H__
46
47 #include <gst/gst.h>
48
49 G_BEGIN_DECLS
50 #define GST_TYPE_FIELDANALYSIS \
51   (gst_field_analysis_get_type())
52 #define GST_FIELDANALYSIS(obj) \
53   (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_FIELDANALYSIS,GstFieldAnalysis))
54 #define GST_FIELDANALYSIS_CLASS(klass) \
55   (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_FIELDANALYSIS,GstFieldAnalysisClass))
56 #define GST_IS_FIELDANALYSIS(obj) \
57   (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_FIELDANALYSIS))
58 #define GST_IS_FIELDANALYSIS_CLASS(klass) \
59   (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_FIELDANALYSIS))
60
61 typedef struct _GstFieldAnalysis GstFieldAnalysis;
62 typedef struct _GstFieldAnalysisClass GstFieldAnalysisClass;
63 typedef struct _FieldAnalysisFields FieldAnalysisFields;
64 typedef struct _FieldAnalysisHistory FieldAnalysisHistory;
65 typedef struct _FieldAnalysis FieldAnalysis;
66
67 typedef enum
68 {
69   FIELD_ANALYSIS_PROGRESSIVE,
70   FIELD_ANALYSIS_INTERLACED,
71   FIELD_ANALYSIS_TELECINE_PROGRESSIVE,
72   FIELD_ANALYSIS_TELECINE_MIXED
73 } FieldAnalysisConclusion;
74
75 enum FieldParity
76 {
77   TOP_FIELD,
78   BOTTOM_FIELD,
79   BOTH_FIELDS
80 };
81
82 struct _FieldAnalysis
83 {
84   /* frame, top, bottom, top with prev bottom, bottom with prev top */
85   gfloat f, t, b, t_b, b_t;
86   FieldAnalysisConclusion conclusion;
87   /* -1 - unknown; 0 - holding none; 1 - top field; 2 - bottom field; 3 - both */
88   gint holding;
89   gboolean drop;
90 };
91
92 struct _FieldAnalysisFields
93 {
94   GstVideoFrame frame;
95   gboolean parity;
96 };
97
98 struct _FieldAnalysisHistory
99 {
100   GstVideoFrame frame;
101   FieldAnalysis results;
102 };
103
104 typedef enum
105 {
106   METHOD_32DETECT,
107   METHOD_IS_COMBED,
108   METHOD_5_TAP
109 } FieldAnalysisCombMethod;
110
111 struct _GstFieldAnalysis
112 {
113   GstElement element;
114
115   GstPad *sinkpad, *srcpad;
116
117   guint nframes;
118   FieldAnalysisHistory frames[2];
119   GstVideoInfo vinfo;
120   gfloat (*same_field) (GstFieldAnalysis *, FieldAnalysisFields (*)[2]);
121   gfloat (*same_frame) (GstFieldAnalysis *, FieldAnalysisFields (*)[2]);
122   guint64 (*block_score_for_row) (GstFieldAnalysis *, FieldAnalysisFields (*)[2], guint8 *, guint8 *);
123   gboolean is_telecine;
124   gboolean first_buffer; /* indicates the first buffer for which a buffer will be output
125                           * after a discont or flushing seek */
126   guint8 *comb_mask;
127   guint *block_scores;
128   gboolean flushing;     /* indicates whether we are flushing or not */
129
130   /* properties */
131   guint32 noise_floor; /* threshold for the result of a metric to be valid */
132   gfloat field_thresh; /* threshold used for the same parity field metric */
133   gfloat frame_thresh; /* threshold used for the opposite parity field metric */
134   gint64 spatial_thresh; /* threshold used spatial comb detection */
135   guint64 block_width, block_height; /* width/height of window used for comb clusted detection */
136   guint64 block_thresh;
137   guint64 ignored_lines;
138 };
139
140 struct _GstFieldAnalysisClass
141 {
142   GstElementClass parent_class;
143 };
144
145 GType gst_field_analysis_get_type (void);
146 GST_ELEMENT_REGISTER_DECLARE (fieldanalysis);
147
148 G_END_DECLS
149 #endif /* __GST_FIELDANALYSIS_H__ */