filter: allow specification of render target regions.
[vaapi:gstreamer-vaapi.git] / gst-libs / gst / vaapi / gstvaapifilter.h
1 /*
2  *  gstvaapifilter.h - Video processing abstraction
3  *
4  *  Copyright (C) 2013 Intel Corporation
5  *
6  *  This library is free software; you can redistribute it and/or
7  *  modify it under the terms of the GNU Lesser General Public License
8  *  as published by the Free Software Foundation; either version 2.1
9  *  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  *  Lesser General Public License for more details.
15  *
16  *  You should have received a copy of the GNU Lesser General Public
17  *  License along with this library; if not, write to the Free
18  *  Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19  *  Boston, MA 02110-1301 USA
20  */
21
22 #ifndef GST_VAAPI_FILTER_H
23 #define GST_VAAPI_FILTER_H
24
25 #include <gst/vaapi/gstvaapisurface.h>
26 #include <gst/vaapi/video-format.h>
27
28 G_BEGIN_DECLS
29
30 typedef struct _GstVaapiFilter                  GstVaapiFilter;
31 typedef struct _GstVaapiFilterOpInfo            GstVaapiFilterOpInfo;
32
33 /**
34  * @GST_VAAPI_FILTER_OP_FORMAT: Force output pixel format (#GstVideoFormat).
35  * @GST_VAAPI_FILTER_OP_CROP: Crop source surface (#GstVaapiRectangle).
36  * @GST_VAAPI_FILTER_OP_DENOISE: Noise reduction (float).
37  * @GST_VAAPI_FILTER_OP_SHARPEN: Sharpening (float).
38  * @GST_VAAPI_FILTER_OP_HUE: Change color hue (float).
39  * @GST_VAAPI_FILTER_OP_SATURATION: Change saturation (float).
40  * @GST_VAAPI_FILTER_OP_BRIGHTNESS: Change brightness (float).
41  * @GST_VAAPI_FILTER_OP_CONTRAST: Change contrast (float).
42  *
43  * The set of operations that could be applied to the filter.
44  */
45 typedef enum {
46     GST_VAAPI_FILTER_OP_FORMAT = 1,
47     GST_VAAPI_FILTER_OP_CROP,
48     GST_VAAPI_FILTER_OP_DENOISE,
49     GST_VAAPI_FILTER_OP_SHARPEN,
50     GST_VAAPI_FILTER_OP_HUE,
51     GST_VAAPI_FILTER_OP_SATURATION,
52     GST_VAAPI_FILTER_OP_BRIGHTNESS,
53     GST_VAAPI_FILTER_OP_CONTRAST,
54     GST_VAAPI_FILTER_OP_DEINTERLACING,
55 } GstVaapiFilterOp;
56
57 /**
58  * GstVaapiFilterOpInfo:
59  * @operation: the #GstVaapiFilterOp
60  * @pspec: the #GParamSpec describing the associated configurable value
61  *
62  * A #GstVaapiFilterOp descriptor.
63  */
64 struct _GstVaapiFilterOpInfo {
65     const GstVaapiFilterOp      op;
66     GParamSpec * const          pspec;
67 };
68
69 /**
70  * GstVaapiFilterStatus:
71  * @GST_VAAPI_FILTER_STATUS_SUCCESS: Success.
72  * @GST_VAAPI_FILTER_STATUS_ERROR_ALLOCATION_FAILED: No memory left.
73  * @GST_VAAPI_FILTER_STATUS_ERROR_OPERATION_FAILED: Operation failed.
74  * @GST_VAAPI_FILTER_STATUS_ERROR_INVALID_PARAMETER: Invalid parameter.
75  * @GST_VAAPI_FILTER_STATUS_ERROR_UNSUPPORTED_OPERATION: Unsupported operation.
76  * @GST_VAAPI_FILTER_STATUS_ERROR_UNSUPPORTED_FORMAT: Unsupported target format.
77  *
78  * Video processing status for gst_vaapi_filter_process().
79  */
80 typedef enum {
81     GST_VAAPI_FILTER_STATUS_SUCCESS = 0,
82     GST_VAAPI_FILTER_STATUS_ERROR_ALLOCATION_FAILED,
83     GST_VAAPI_FILTER_STATUS_ERROR_OPERATION_FAILED,
84     GST_VAAPI_FILTER_STATUS_ERROR_INVALID_PARAMETER,
85     GST_VAAPI_FILTER_STATUS_ERROR_UNSUPPORTED_OPERATION,
86     GST_VAAPI_FILTER_STATUS_ERROR_UNSUPPORTED_FORMAT,
87 } GstVaapiFilterStatus;
88
89 /**
90  * GstVaapiDeinterlaceMethod:
91  * @GST_VAAPI_DEINTERLACE_METHOD_NONE: No deinterlacing.
92  * @GST_VAAPI_DEINTERLACE_METHOD_BOB: Basic bob deinterlacing algorithm.
93  * @GST_VAAPI_DEINTERLACE_METHOD_WEAVE: Weave deinterlacing algorithm.
94  * @GST_VAAPI_DEINTERLACE_METHOD_MOTION_ADAPTIVE: Motion adaptive
95  *   deinterlacing algorithm.
96  * @GST_VAAPI_DEINTERLACE_METHOD_MOTION_COMPENSATED: Motion compensated
97  *   deinterlacing algorithm.
98  *
99  * Deinterlacing algorithms.
100  */
101 typedef enum {
102     GST_VAAPI_DEINTERLACE_METHOD_NONE,
103     GST_VAAPI_DEINTERLACE_METHOD_BOB,
104     GST_VAAPI_DEINTERLACE_METHOD_WEAVE,
105     GST_VAAPI_DEINTERLACE_METHOD_MOTION_ADAPTIVE,
106     GST_VAAPI_DEINTERLACE_METHOD_MOTION_COMPENSATED,
107 } GstVaapiDeinterlaceMethod;
108
109 /**
110  * GstVaapiDeinterlaceFlags:
111  * @GST_VAAPI_DEINTERLACE_FLAG_TFF: Top-field first. If this flag is
112  *   not set, then bottom-field first order is assumed.
113  * @GST_VAAPI_DEINTERLACE_FLAG_ONEFIELD: The input frame represents a
114  *   single field. If this flag is not set, then the whole frame holds
115  *   two fields.
116  *
117  * The set of gst_vaapi_filter_set_deinterlacing() flags.
118  */
119 typedef enum {
120     GST_VAAPI_DEINTERLACE_FLAG_TFF      = 1 << 31,
121     GST_VAAPI_DEINTERLACE_FLAG_ONEFIELD = 1 << 30,
122 } GstVaapiDeinterlaceFlags;
123
124 #define GST_VAAPI_TYPE_DEINTERLACE_METHOD \
125     gst_vaapi_deinterlace_method_get_type()
126
127 #define GST_VAAPI_TYPE_DEINTERLACE_FLAGS \
128     gst_vaapi_deinterlace_flags_get_type()
129
130 GType
131 gst_vaapi_deinterlace_method_get_type(void) G_GNUC_CONST;
132
133 GType
134 gst_vaapi_deinterlace_flags_get_type(void) G_GNUC_CONST;
135
136 GstVaapiFilter *
137 gst_vaapi_filter_new(GstVaapiDisplay *display);
138
139 GstVaapiFilter *
140 gst_vaapi_filter_ref(GstVaapiFilter *filter);
141
142 void
143 gst_vaapi_filter_unref(GstVaapiFilter *filter);
144
145 void
146 gst_vaapi_filter_replace(GstVaapiFilter **old_filter_ptr,
147     GstVaapiFilter *new_filter);
148
149 GPtrArray *
150 gst_vaapi_filter_get_operations(GstVaapiFilter *filter);
151
152 gboolean
153 gst_vaapi_filter_set_operation(GstVaapiFilter *filter, GstVaapiFilterOp op,
154     const GValue *value);
155
156 GstVaapiFilterStatus
157 gst_vaapi_filter_process(GstVaapiFilter *filter, GstVaapiSurface *src_surface,
158     GstVaapiSurface *dst_surface, guint flags);
159
160 GArray *
161 gst_vaapi_filter_get_formats(GstVaapiFilter *filter);
162
163 gboolean
164 gst_vaapi_filter_set_format(GstVaapiFilter *filter, GstVideoFormat format);
165
166 gboolean
167 gst_vaapi_filter_set_cropping_rectangle(GstVaapiFilter *filter,
168     const GstVaapiRectangle *rect);
169
170 gboolean
171 gst_vaapi_filter_set_target_rectangle(GstVaapiFilter *filter,
172     const GstVaapiRectangle *rect);
173
174 gboolean
175 gst_vaapi_filter_set_denoising_level(GstVaapiFilter *filter, gfloat level);
176
177 gboolean
178 gst_vaapi_filter_set_sharpening_level(GstVaapiFilter *filter, gfloat level);
179
180 gboolean
181 gst_vaapi_filter_set_hue(GstVaapiFilter *filter, gfloat value);
182
183 gboolean
184 gst_vaapi_filter_set_saturation(GstVaapiFilter *filter, gfloat value);
185
186 gboolean
187 gst_vaapi_filter_set_brightness(GstVaapiFilter *filter, gfloat value);
188
189 gboolean
190 gst_vaapi_filter_set_contrast(GstVaapiFilter *filter, gfloat value);
191
192 gboolean
193 gst_vaapi_filter_set_deinterlacing(GstVaapiFilter *filter,
194     GstVaapiDeinterlaceMethod method, guint flags);
195
196 #endif /* GST_VAAPI_FILTER_H */