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_SKINTONE = 1 << GST_VAAPI_FILTER_OP_SKINTONE,
109 /* Additional custom flags */
110 GST_VAAPI_POSTPROC_FLAG_CUSTOM = 1 << 20,
111 GST_VAAPI_POSTPROC_FLAG_SIZE = GST_VAAPI_POSTPROC_FLAG_CUSTOM,
112 } GstVaapiPostprocFlags;
115 * GstVaapiDeinterlaceState:
116 * @buffers: history buffer, maintained as a cyclic array
117 * @buffers_index: next free slot in the history buffer
118 * @surfaces: array of surfaces used as references
119 * @num_surfaces: number of active surfaces in that array
120 * @deint: flag: previous buffers were interlaced?
121 * @tff: flag: previous buffers were organized as top-field-first?
123 * Context used to maintain deinterlacing state.
125 struct _GstVaapiDeinterlaceState
127 GstBuffer *buffers[GST_VAAPI_DEINTERLACE_MAX_REFERENCES];
129 GstVaapiSurface *surfaces[GST_VAAPI_DEINTERLACE_MAX_REFERENCES];
135 struct _GstVaapiPostproc
138 GstVaapiPluginBase parent_instance;
140 GMutex postproc_lock;
141 GstVaapiFilter *filter;
142 GPtrArray *filter_ops;
143 GstVaapiVideoPool *filter_pool;
144 GstVideoInfo filter_pool_info;
145 GArray *filter_formats;
146 GstVideoFormat format; /* output video format (encoded) */
151 GstCaps *allowed_sinkpad_caps;
152 GstVideoInfo sinkpad_info;
153 GstCaps *allowed_srcpad_caps;
154 GstVideoInfo srcpad_info;
157 GstVaapiDeinterlaceMode deinterlace_mode;
158 GstVaapiDeinterlaceMethod deinterlace_method;
159 GstVaapiDeinterlaceState deinterlace_state;
160 GstClockTime field_duration;
162 /* Basic filter values */
163 gfloat denoise_level;
164 gfloat sharpen_level;
166 GstVaapiScaleMethod scale_method;
168 GstVideoOrientationMethod video_direction;
169 GstVideoOrientationMethod tag_video_direction;
171 /* Color balance filter values */
177 gboolean skintone_enhance;
178 gboolean forward_crop;
180 guint get_va_surfaces:1;
185 /* color balance's channel list */
190 struct _GstVaapiPostprocClass
193 GstVaapiPluginBaseClass parent_class;
197 gst_vaapipostproc_get_type (void) G_GNUC_CONST;
201 #endif /* GST_VAAPIPOSTPROC_H */