3424ba5a6ac7d5908ac3e4e224901a36ea7e04e1
[platform/upstream/gstreamer.git] / gst-libs / gst / vaapi / gstvaapifilter.h
1 /*
2  *  gstvaapifilter.h - Video processing abstraction
3  *
4  *  Copyright (C) 2013 Intel Corporation
5  *    Author: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
6  *
7  *  This library is free software; you can redistribute it and/or
8  *  modify it under the terms of the GNU Lesser General Public License
9  *  as published by the Free Software Foundation; either version 2.1
10  *  of the License, or (at your option) any later version.
11  *
12  *  This library is distributed in the hope that it will be useful,
13  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15  *  Lesser General Public License for more details.
16  *
17  *  You should have received a copy of the GNU Lesser General Public
18  *  License along with this library; if not, write to the Free
19  *  Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20  *  Boston, MA 02110-1301 USA
21  */
22
23 #ifndef GST_VAAPI_FILTER_H
24 #define GST_VAAPI_FILTER_H
25
26 #include <gst/vaapi/gstvaapisurface.h>
27 #include <gst/vaapi/video-format.h>
28
29 G_BEGIN_DECLS
30
31 #define GST_TYPE_VAAPI_FILTER \
32     (gst_vaapi_filter_get_type ())
33 #define GST_VAAPI_FILTER(obj) \
34     (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_VAAPI_FILTER, GstVaapiFilter))
35 #define GST_VAAPI_IS_FILTER(obj) \
36     (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_VAAPI_FILTER))
37
38 typedef struct _GstVaapiFilter                  GstVaapiFilter;
39 typedef struct _GstVaapiFilterOpInfo            GstVaapiFilterOpInfo;
40
41 /**
42  * @GST_VAAPI_FILTER_OP_FORMAT: Force output pixel format (#GstVideoFormat).
43  * @GST_VAAPI_FILTER_OP_CROP: Crop source surface (#GstVaapiRectangle).
44  * @GST_VAAPI_FILTER_OP_DENOISE: Noise reduction (float).
45  * @GST_VAAPI_FILTER_OP_SHARPEN: Sharpening (float).
46  * @GST_VAAPI_FILTER_OP_HUE: Change color hue (float).
47  * @GST_VAAPI_FILTER_OP_SATURATION: Change saturation (float).
48  * @GST_VAAPI_FILTER_OP_BRIGHTNESS: Change brightness (float).
49  * @GST_VAAPI_FILTER_OP_CONTRAST: Change contrast (float).
50  * @GST_VAAPI_FILTER_OP_SCALING: Change scaling method (#GstVaapiScaleMethod).
51  * @GST_VAAPI_FILTER_OP_VIDEO_DIRECTION: Change video direction
52  *   (#GstVideoOrientationMethod).
53  * @GST_VAAPI_FILTER_OP_SKINTONE: Skin tone enhancement (bool).
54  *
55  * The set of operations that could be applied to the filter.
56  */
57 typedef enum {
58   GST_VAAPI_FILTER_OP_FORMAT = 1,
59   GST_VAAPI_FILTER_OP_CROP,
60   GST_VAAPI_FILTER_OP_DENOISE,
61   GST_VAAPI_FILTER_OP_SHARPEN,
62   GST_VAAPI_FILTER_OP_HUE,
63   GST_VAAPI_FILTER_OP_SATURATION,
64   GST_VAAPI_FILTER_OP_BRIGHTNESS,
65   GST_VAAPI_FILTER_OP_CONTRAST,
66   GST_VAAPI_FILTER_OP_DEINTERLACING,
67   GST_VAAPI_FILTER_OP_SCALING,
68   GST_VAAPI_FILTER_OP_VIDEO_DIRECTION,
69   GST_VAAPI_FILTER_OP_SKINTONE,
70 } GstVaapiFilterOp;
71
72 /**
73  * GstVaapiFilterOpInfo:
74  * @operation: the #GstVaapiFilterOp
75  * @pspec: the #GParamSpec describing the associated configurable value
76  *
77  * A #GstVaapiFilterOp descriptor.
78  */
79 struct _GstVaapiFilterOpInfo
80 {
81   const GstVaapiFilterOp op;
82   GParamSpec *const pspec;
83 };
84
85 /**
86  * GstVaapiFilterStatus:
87  * @GST_VAAPI_FILTER_STATUS_SUCCESS: Success.
88  * @GST_VAAPI_FILTER_STATUS_ERROR_ALLOCATION_FAILED: No memory left.
89  * @GST_VAAPI_FILTER_STATUS_ERROR_OPERATION_FAILED: Operation failed.
90  * @GST_VAAPI_FILTER_STATUS_ERROR_INVALID_PARAMETER: Invalid parameter.
91  * @GST_VAAPI_FILTER_STATUS_ERROR_UNSUPPORTED_OPERATION: Unsupported operation.
92  * @GST_VAAPI_FILTER_STATUS_ERROR_UNSUPPORTED_FORMAT: Unsupported target format.
93  *
94  * Video processing status for gst_vaapi_filter_process().
95  */
96 typedef enum {
97   GST_VAAPI_FILTER_STATUS_SUCCESS = 0,
98   GST_VAAPI_FILTER_STATUS_ERROR_ALLOCATION_FAILED,
99   GST_VAAPI_FILTER_STATUS_ERROR_OPERATION_FAILED,
100   GST_VAAPI_FILTER_STATUS_ERROR_INVALID_PARAMETER,
101   GST_VAAPI_FILTER_STATUS_ERROR_UNSUPPORTED_OPERATION,
102   GST_VAAPI_FILTER_STATUS_ERROR_UNSUPPORTED_FORMAT,
103 } GstVaapiFilterStatus;
104
105 /**
106  * GstVaapiScaleMethod:
107  * @GST_VAAPI_SCALE_METHOD_DEFAULT: Default scaling mode.
108  * @GST_VAAPI_SCALE_METHOD_FAST: Fast scaling mode, at the expense of quality.
109  * @GST_VAAPI_SCALE_METHOD_HQ: High quality scaling mode, at the
110  *   expense of speed.
111  *
112  * Scaling algorithms.
113  */
114 typedef enum {
115   GST_VAAPI_SCALE_METHOD_DEFAULT,
116   GST_VAAPI_SCALE_METHOD_FAST,
117   GST_VAAPI_SCALE_METHOD_HQ,
118 } GstVaapiScaleMethod;
119
120 /**
121  * GstVaapiDeinterlaceMethod:
122  * @GST_VAAPI_DEINTERLACE_METHOD_NONE: No deinterlacing.
123  * @GST_VAAPI_DEINTERLACE_METHOD_BOB: Basic bob deinterlacing algorithm.
124  * @GST_VAAPI_DEINTERLACE_METHOD_WEAVE: Weave deinterlacing algorithm.
125  * @GST_VAAPI_DEINTERLACE_METHOD_MOTION_ADAPTIVE: Motion adaptive
126  *   deinterlacing algorithm.
127  * @GST_VAAPI_DEINTERLACE_METHOD_MOTION_COMPENSATED: Motion compensated
128  *   deinterlacing algorithm.
129  *
130  * Deinterlacing algorithms.
131  */
132 typedef enum {
133   GST_VAAPI_DEINTERLACE_METHOD_NONE,
134   GST_VAAPI_DEINTERLACE_METHOD_BOB,
135   GST_VAAPI_DEINTERLACE_METHOD_WEAVE,
136   GST_VAAPI_DEINTERLACE_METHOD_MOTION_ADAPTIVE,
137   GST_VAAPI_DEINTERLACE_METHOD_MOTION_COMPENSATED,
138 } GstVaapiDeinterlaceMethod;
139
140 /**
141  * GstVaapiDeinterlaceFlags:
142  * @GST_VAAPI_DEINTERLACE_FLAG_TFF: Top-field first. If this flag is
143  *   not set, then bottom-field first order is assumed. Note: this
144  *   only affects the way reference frames are organized for advanced
145  *   deinterlacing modes.
146  * @GST_VAAPI_DEINTERLACE_FLAG_ONEFIELD: The input frame represents a
147  *   single field. If this flag is not set, then the whole frame holds
148  *   two interleaved fields.
149  * @GST_VAAPI_DEINTERLACE_FLAG_TOPFIELD: The top field of the input
150  *   frame is to be used for deinterlacing. Otherwise, if this flag is
151  *   not set, then the bottom field of the input frame will be used
152  *   for deinterlacing.
153  *
154  * The set of gst_vaapi_filter_set_deinterlacing() flags.
155  */
156 typedef enum {
157   GST_VAAPI_DEINTERLACE_FLAG_TFF = 1 << 31,
158   GST_VAAPI_DEINTERLACE_FLAG_ONEFIELD = 1 << 30,
159   GST_VAAPI_DEINTERLACE_FLAG_TOPFIELD = 1 << 29,
160 } GstVaapiDeinterlaceFlags;
161
162 #define GST_VAAPI_TYPE_SCALE_METHOD \
163     gst_vaapi_scale_method_get_type()
164
165 #define GST_VAAPI_TYPE_DEINTERLACE_METHOD \
166     gst_vaapi_deinterlace_method_get_type()
167
168 #define GST_VAAPI_TYPE_DEINTERLACE_FLAGS \
169     gst_vaapi_deinterlace_flags_get_type()
170
171 GType
172 gst_vaapiscale_method_get_type (void) G_GNUC_CONST;
173
174 GType
175 gst_vaapi_deinterlace_method_get_type (void) G_GNUC_CONST;
176
177 GType
178 gst_vaapi_deinterlace_flags_get_type (void) G_GNUC_CONST;
179
180 GType
181 gst_vaapi_filter_get_type (void) G_GNUC_CONST;
182
183 GstVaapiFilter *
184 gst_vaapi_filter_new (GstVaapiDisplay * display);
185
186 void
187 gst_vaapi_filter_replace (GstVaapiFilter ** old_filter_ptr,
188     GstVaapiFilter * new_filter);
189
190 GPtrArray *
191 gst_vaapi_filter_get_operations (GstVaapiFilter * filter);
192
193 gboolean
194 gst_vaapi_filter_has_operation (GstVaapiFilter * filter, GstVaapiFilterOp op);
195
196 gboolean
197 gst_vaapi_filter_use_operation (GstVaapiFilter * filter, GstVaapiFilterOp op);
198
199 gboolean
200 gst_vaapi_filter_set_operation (GstVaapiFilter * filter, GstVaapiFilterOp op,
201     const GValue * value);
202
203 GstVaapiFilterStatus
204 gst_vaapi_filter_process (GstVaapiFilter * filter,
205     GstVaapiSurface * src_surface, GstVaapiSurface * dst_surface, guint flags);
206
207 GArray *
208 gst_vaapi_filter_get_formats (GstVaapiFilter * filter);
209
210 gboolean
211 gst_vaapi_filter_set_format (GstVaapiFilter * filter, GstVideoFormat format);
212
213 gboolean
214 gst_vaapi_filter_append_caps (GstVaapiFilter * filter, GstStructure * structure);
215
216 gboolean
217 gst_vaapi_filter_set_cropping_rectangle (GstVaapiFilter * filter,
218     const GstVaapiRectangle * rect);
219
220 gboolean
221 gst_vaapi_filter_set_target_rectangle (GstVaapiFilter * filter,
222     const GstVaapiRectangle * rect);
223
224 gboolean
225 gst_vaapi_filter_set_denoising_level (GstVaapiFilter * filter, gfloat level);
226
227 gboolean
228 gst_vaapi_filter_set_sharpening_level (GstVaapiFilter * filter, gfloat level);
229
230 gboolean
231 gst_vaapi_filter_set_hue (GstVaapiFilter * filter, gfloat value);
232
233 gboolean
234 gst_vaapi_filter_set_saturation (GstVaapiFilter * filter, gfloat value);
235
236 gboolean
237 gst_vaapi_filter_set_brightness (GstVaapiFilter * filter, gfloat value);
238
239 gboolean
240 gst_vaapi_filter_set_contrast (GstVaapiFilter * filter, gfloat value);
241
242 gboolean
243 gst_vaapi_filter_set_deinterlacing (GstVaapiFilter * filter,
244     GstVaapiDeinterlaceMethod method, guint flags);
245
246 gboolean
247 gst_vaapi_filter_set_deinterlacing_references (GstVaapiFilter * filter,
248     GstVaapiSurface ** forward_references, guint num_forward_references,
249     GstVaapiSurface ** backward_references, guint num_backward_references);
250
251 gboolean
252 gst_vaapi_filter_set_scaling (GstVaapiFilter * filter,
253     GstVaapiScaleMethod method);
254
255 gboolean
256 gst_vaapi_filter_set_video_direction (GstVaapiFilter * filter,
257     GstVideoOrientationMethod method);
258
259 GstVideoOrientationMethod
260 gst_vaapi_filter_get_video_direction (GstVaapiFilter * filter);
261
262 gboolean
263 gst_vaapi_filter_set_skintone (GstVaapiFilter * filter,
264     gboolean enhance);
265
266 gfloat
267 gst_vaapi_filter_get_denoising_level_default (GstVaapiFilter * filter);
268
269 gfloat
270 gst_vaapi_filter_get_sharpening_level_default (GstVaapiFilter * filter);
271
272 gfloat
273 gst_vaapi_filter_get_hue_default (GstVaapiFilter * filter);
274
275 gfloat
276 gst_vaapi_filter_get_saturation_default (GstVaapiFilter * filter);
277
278 gfloat
279 gst_vaapi_filter_get_brightness_default (GstVaapiFilter * filter);
280
281 gfloat
282 gst_vaapi_filter_get_contrast_default (GstVaapiFilter * filter);
283
284 GstVaapiScaleMethod
285 gst_vaapi_filter_get_scaling_default (GstVaapiFilter * filter);
286
287 GstVideoOrientationMethod
288 gst_vaapi_filter_get_video_direction_default (GstVaapiFilter * filter);
289
290 gboolean
291 gst_vaapi_filter_get_skintone_default (GstVaapiFilter * filter);
292
293 #ifdef G_DEFINE_AUTOPTR_CLEANUP_FUNC
294 G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstVaapiFilter, gst_object_unref)
295 #endif
296
297 #endif /* GST_VAAPI_FILTER_H */