2 * gstvaapipostproc.h - VA-API video post processing
4 * Copyright (C) 2012-2014 Intel Corporation
5 * Author: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
7 * This program 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.
12 * This program 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.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this program; if not, write to the Free
19 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20 * Boston, MA 02110-1301 USA
23 #ifndef GST_VAAPIPOSTPROC_H
24 #define GST_VAAPIPOSTPROC_H
26 #include "gstvaapipluginbase.h"
27 #include <gst/vaapi/gstvaapisurface.h>
28 #include <gst/vaapi/gstvaapisurfacepool.h>
29 #include <gst/vaapi/gstvaapifilter.h>
33 #define GST_TYPE_VAAPIPOSTPROC \
34 (gst_vaapipostproc_get_type ())
35 #define GST_VAAPIPOSTPROC(obj) \
36 (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_VAAPIPOSTPROC, GstVaapiPostproc))
37 #define GST_VAAPIPOSTPROC_CLASS(klass) \
38 (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_VAAPIPOSTPROC, \
39 GstVaapiPostprocClass))
40 #define GST_IS_VAAPIPOSTPROC(obj) \
41 (G_TYPE_CHECK_INSTANCE_TYPE((obj), GST_TYPE_VAAPIPOSTPROC))
42 #define GST_IS_VAAPIPOSTPROC_CLASS(klass) \
43 (G_TYPE_CHECK_CLASS_TYPE((klass), GST_TYPE_VAAPIPOSTPROC))
44 #define GST_VAAPIPOSTPROC_GET_CLASS(obj) \
45 (G_TYPE_INSTANCE_GET_CLASS((obj), GST_TYPE_VAAPIPOSTPROC, \
46 GstVaapiPostprocClass))
48 typedef struct _GstVaapiPostproc GstVaapiPostproc;
49 typedef struct _GstVaapiPostprocClass GstVaapiPostprocClass;
50 typedef struct _GstVaapiDeinterlaceState GstVaapiDeinterlaceState;
53 * GstVaapiDeinterlaceMode:
54 * @GST_VAAPI_DEINTERLACE_MODE_AUTO: Auto detect needs for deinterlacing.
55 * @GST_VAAPI_DEINTERLACE_MODE_INTERLACED: Force deinterlacing.
56 * @GST_VAAPI_DEINTERLACE_MODE_DISABLED: Never perform deinterlacing.
60 GST_VAAPI_DEINTERLACE_MODE_AUTO = 0,
61 GST_VAAPI_DEINTERLACE_MODE_INTERLACED,
62 GST_VAAPI_DEINTERLACE_MODE_DISABLED,
63 } GstVaapiDeinterlaceMode;
66 * GST_VAAPI_DEINTERLACE_MAX_REFERENCES:
68 * This represents the maximum number of VA surfaces we could keep as
69 * references for advanced deinterlacing.
71 * Note: if the upstream element is vaapidecode, then the maximum
72 * number of allowed surfaces used as references shall be less than
73 * the actual number of scratch surfaces used for decoding (4).
75 #define GST_VAAPI_DEINTERLACE_MAX_REFERENCES 2
78 * GstVaapiPostprocFlags:
79 * @GST_VAAPI_POSTPROC_FLAG_FORMAT: Pixel format conversion.
80 * @GST_VAAPI_POSTPROC_FLAG_DENOISE: Noise reduction.
81 * @GST_VAAPI_POSTPROC_FLAG_SHARPEN: Sharpening.
82 * @GST_VAAPI_POSTPROC_FLAG_HUE: Change color hue.
83 * @GST_VAAPI_POSTPROC_FLAG_SATURATION: Change saturation.
84 * @GST_VAAPI_POSTPROC_FLAG_BRIGHTNESS: Change brightness.
85 * @GST_VAAPI_POSTPROC_FLAG_CONTRAST: Change contrast.
86 * @GST_VAAPI_POSTPROC_FLAG_DEINTERLACE: Deinterlacing.
87 * @GST_VAAPI_POSTPROC_FLAG_SIZE: Video scaling.
88 * @GST_VAAPI_POSTPROC_FLAG_SCALE: Video scaling mode.
89 * @GST_VAAPI_POSTPROC_FLAG_VIDEO_DIRECTION: Video rotation and flip/mirroring.
90 * @GST_VAAPI_POSTPROC_FLAG_SKINTONE: Skin tone enhancement.
92 * The set of operations that are to be performed for each frame.
96 GST_VAAPI_POSTPROC_FLAG_FORMAT = 1 << GST_VAAPI_FILTER_OP_FORMAT,
97 GST_VAAPI_POSTPROC_FLAG_DENOISE = 1 << GST_VAAPI_FILTER_OP_DENOISE,
98 GST_VAAPI_POSTPROC_FLAG_SHARPEN = 1 << GST_VAAPI_FILTER_OP_SHARPEN,
99 GST_VAAPI_POSTPROC_FLAG_HUE = 1 << GST_VAAPI_FILTER_OP_HUE,
100 GST_VAAPI_POSTPROC_FLAG_SATURATION = 1 << GST_VAAPI_FILTER_OP_SATURATION,
101 GST_VAAPI_POSTPROC_FLAG_BRIGHTNESS = 1 << GST_VAAPI_FILTER_OP_BRIGHTNESS,
102 GST_VAAPI_POSTPROC_FLAG_CONTRAST = 1 << GST_VAAPI_FILTER_OP_CONTRAST,
103 GST_VAAPI_POSTPROC_FLAG_DEINTERLACE = 1 << GST_VAAPI_FILTER_OP_DEINTERLACING,
104 GST_VAAPI_POSTPROC_FLAG_SCALE = 1 << GST_VAAPI_FILTER_OP_SCALING,
105 GST_VAAPI_POSTPROC_FLAG_VIDEO_DIRECTION =
106 1 << GST_VAAPI_FILTER_OP_VIDEO_DIRECTION,
107 GST_VAAPI_POSTPROC_FLAG_CROP = 1 << GST_VAAPI_FILTER_OP_CROP,
108 GST_VAAPI_POSTPROC_FLAG_SKINTONE = 1 << GST_VAAPI_FILTER_OP_SKINTONE,
110 /* Additional custom flags */
111 GST_VAAPI_POSTPROC_FLAG_CUSTOM = 1 << 20,
112 GST_VAAPI_POSTPROC_FLAG_SIZE = GST_VAAPI_POSTPROC_FLAG_CUSTOM,
113 } GstVaapiPostprocFlags;
116 * GstVaapiDeinterlaceState:
117 * @buffers: history buffer, maintained as a cyclic array
118 * @buffers_index: next free slot in the history buffer
119 * @surfaces: array of surfaces used as references
120 * @num_surfaces: number of active surfaces in that array
121 * @deint: flag: previous buffers were interlaced?
122 * @tff: flag: previous buffers were organized as top-field-first?
124 * Context used to maintain deinterlacing state.
126 struct _GstVaapiDeinterlaceState
128 GstBuffer *buffers[GST_VAAPI_DEINTERLACE_MAX_REFERENCES];
130 GstVaapiSurface *surfaces[GST_VAAPI_DEINTERLACE_MAX_REFERENCES];
136 struct _GstVaapiPostproc
139 GstVaapiPluginBase parent_instance;
141 GMutex postproc_lock;
142 GstVaapiFilter *filter;
143 GPtrArray *filter_ops;
144 GstVaapiVideoPool *filter_pool;
145 GstVideoInfo filter_pool_info;
146 GArray *filter_formats;
147 GstVideoFormat format; /* output video format (encoded) */
152 GstCaps *allowed_sinkpad_caps;
153 GstVideoInfo sinkpad_info;
154 GstCaps *allowed_srcpad_caps;
155 GstVideoInfo srcpad_info;
158 GstVaapiDeinterlaceMode deinterlace_mode;
159 GstVaapiDeinterlaceMethod deinterlace_method;
160 GstVaapiDeinterlaceState deinterlace_state;
161 GstClockTime field_duration;
163 /* Basic filter values */
164 gfloat denoise_level;
165 gfloat sharpen_level;
167 GstVaapiScaleMethod scale_method;
169 GstVideoOrientationMethod video_direction;
170 GstVideoOrientationMethod tag_video_direction;
178 /* Color balance filter values */
184 gboolean skintone_enhance;
185 gboolean forward_crop;
187 guint get_va_surfaces:1;
192 /* color balance's channel list */
197 struct _GstVaapiPostprocClass
200 GstVaapiPluginBaseClass parent_class;
204 gst_vaapipostproc_get_type (void) G_GNUC_CONST;
208 #endif /* GST_VAAPIPOSTPROC_H */