4b8aaeac5007897aba7c43af92ef54923b32e37d
[profile/ivi/gstreamer-vaapi.git] / gst-libs / gst / vaapi / gstvaapisurface.h
1 /*
2  *  gstvaapisurface.h - VA surface abstraction
3  *
4  *  Copyright (C) 2010-2011 Splitted-Desktop Systems
5  *  Copyright (C) 2011 Intel Corporation
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_SURFACE_H
24 #define GST_VAAPI_SURFACE_H
25
26 #include <gst/vaapi/gstvaapiobject.h>
27 #include <gst/vaapi/gstvaapidisplay.h>
28 #include <gst/vaapi/gstvaapiimage.h>
29 #include <gst/vaapi/gstvaapisubpicture.h>
30 #include <gst/video/gstsurfacebuffer.h>
31 #include <gst/video/video-overlay-composition.h>
32
33 G_BEGIN_DECLS
34
35 /**
36  * GST_VAAPI_SURFACE_CAPS_NAME:
37  *
38  * Generic caps type for VA surfaces.
39  */
40 #define GST_VAAPI_SURFACE_CAPS_NAME GST_VIDEO_CAPS_SURFACE
41
42 /**
43  * GST_VAAPI_SURFACE_CAPS:
44  *
45  * Generic caps for VA surfaces.
46  */
47 #define GST_VAAPI_SURFACE_CAPS                  \
48     GST_VAAPI_SURFACE_CAPS_NAME ", "            \
49     "type = vaapi, "                            \
50     "opengl = (boolean) { true, false }, "      \
51     "width  = (int) [ 1, MAX ], "               \
52     "height = (int) [ 1, MAX ], "               \
53     "framerate = (fraction) [ 0, MAX ]"
54
55 /**
56  * GstVaapiChromaType:
57  * @GST_VAAPI_CHROMA_TYPE_YUV420: 4:2:0 chroma format
58  * @GST_VAAPI_CHROMA_TYPE_YUV422: 4:2:2 chroma format
59  * @GST_VAAPI_CHROMA_TYPE_YUV444: 4:4:4 chroma format
60  *
61  * The set of all chroma types for #GstVaapiSurface.
62  */
63 typedef enum {
64     GST_VAAPI_CHROMA_TYPE_YUV420 = 1,
65     GST_VAAPI_CHROMA_TYPE_YUV422,
66     GST_VAAPI_CHROMA_TYPE_YUV444
67 } GstVaapiChromaType;
68
69 /**
70  * GstVaapiSurfaceStatus:
71  * @GST_VAAPI_SURFACE_STATUS_IDLE:
72  *   the surface is not being rendered or displayed
73  * @GST_VAAPI_SURFACE_STATUS_RENDERING:
74  *   the surface is used for rendering (decoding to the surface in progress)
75  * @GST_VAAPI_SURFACE_STATUS_DISPLAYING:
76  *   the surface is being displayed to screen
77  * @GST_VAAPI_SURFACE_STATUS_SKIPPED:
78  *   indicates a skipped frame during encode
79  *
80  * The set of all surface status for #GstVaapiSurface.
81  */
82 typedef enum {
83     GST_VAAPI_SURFACE_STATUS_IDLE       = 1 << 0,
84     GST_VAAPI_SURFACE_STATUS_RENDERING  = 1 << 1,
85     GST_VAAPI_SURFACE_STATUS_DISPLAYING = 1 << 2,
86     GST_VAAPI_SURFACE_STATUS_SKIPPED    = 1 << 3
87 } GstVaapiSurfaceStatus;
88
89 /**
90  * GstVaapiSurfaceRenderFlags
91  * @GST_VAAPI_PICTURE_STRUCTURE_TOP_FIELD:
92  *   selects the top field of the surface
93  * @GST_VAAPI_PICTURE_STRUCTURE_BOTTOM_FIELD:
94  *   selects the bottom field of the surface
95  * @GST_VAAPI_PICTURE_STRUCTURE_FRAME:
96  *   selects the entire surface
97  * @GST_VAAPI_COLOR_STANDARD_ITUR_BT_601:
98  *   uses ITU-R BT.601 standard for color space conversion
99  * @GST_VAAPI_COLOR_STANDARD_ITUR_BT_709:
100  *   uses ITU-R BT.709 standard for color space conversion
101  *
102  * The set of all render flags for gst_vaapi_window_put_surface().
103  */
104 typedef enum {
105     GST_VAAPI_PICTURE_STRUCTURE_TOP_FIELD       = 1 << 0,
106     GST_VAAPI_PICTURE_STRUCTURE_BOTTOM_FIELD    = 1 << 1,
107     GST_VAAPI_PICTURE_STRUCTURE_FRAME           =
108     (
109         GST_VAAPI_PICTURE_STRUCTURE_TOP_FIELD |
110         GST_VAAPI_PICTURE_STRUCTURE_BOTTOM_FIELD
111     ),
112     GST_VAAPI_COLOR_STANDARD_ITUR_BT_601        = 1 << 2,
113     GST_VAAPI_COLOR_STANDARD_ITUR_BT_709        = 1 << 3,
114 } GstVaapiSurfaceRenderFlags;
115
116 #define GST_VAAPI_TYPE_SURFACE \
117     (gst_vaapi_surface_get_type())
118
119 #define GST_VAAPI_SURFACE(obj)                          \
120     (G_TYPE_CHECK_INSTANCE_CAST((obj),                  \
121                                 GST_VAAPI_TYPE_SURFACE, \
122                                 GstVaapiSurface))
123
124 #define GST_VAAPI_SURFACE_CLASS(klass)                  \
125     (G_TYPE_CHECK_CLASS_CAST((klass),                   \
126                              GST_VAAPI_TYPE_SURFACE,    \
127                              GstVaapiSurfaceClass))
128
129 #define GST_VAAPI_IS_SURFACE(obj) \
130     (G_TYPE_CHECK_INSTANCE_TYPE((obj), GST_VAAPI_TYPE_SURFACE))
131
132 #define GST_VAAPI_IS_SURFACE_CLASS(klass) \
133     (G_TYPE_CHECK_CLASS_TYPE((klass), GST_VAAPI_TYPE_SURFACE))
134
135 #define GST_VAAPI_SURFACE_GET_CLASS(obj)                \
136     (G_TYPE_INSTANCE_GET_CLASS((obj),                   \
137                                GST_VAAPI_TYPE_SURFACE,  \
138                                GstVaapiSurfaceClass))
139
140 typedef struct _GstVaapiSurface                 GstVaapiSurface;
141 typedef struct _GstVaapiSurfacePrivate          GstVaapiSurfacePrivate;
142 typedef struct _GstVaapiSurfaceClass            GstVaapiSurfaceClass;
143
144 /**
145  * GstVaapiSurface:
146  *
147  * A VA surface wrapper.
148  */
149 struct _GstVaapiSurface {
150     /*< private >*/
151     GstVaapiObject parent_instance;
152
153     GstVaapiSurfacePrivate *priv;
154 };
155
156 /**
157  * GstVaapiSurfaceClass:
158  *
159  * A VA surface wrapper class.
160  */
161 struct _GstVaapiSurfaceClass {
162     /*< private >*/
163     GstVaapiObjectClass parent_class;
164 };
165
166 GType
167 gst_vaapi_surface_get_type(void) G_GNUC_CONST;
168
169 GstVaapiSurface *
170 gst_vaapi_surface_new(
171     GstVaapiDisplay    *display,
172     GstVaapiChromaType  chroma_type,
173     guint               width,
174     guint               height
175 );
176
177 GstVaapiID
178 gst_vaapi_surface_get_id(GstVaapiSurface *surface);
179
180 GstVaapiChromaType
181 gst_vaapi_surface_get_chroma_type(GstVaapiSurface *surface);
182
183 guint
184 gst_vaapi_surface_get_width(GstVaapiSurface *surface);
185
186 guint
187 gst_vaapi_surface_get_height(GstVaapiSurface *surface);
188
189 void
190 gst_vaapi_surface_get_size(
191     GstVaapiSurface *surface,
192     guint           *pwidth,
193     guint           *pheight
194 );
195
196 GstVaapiImage *
197 gst_vaapi_surface_derive_image(GstVaapiSurface *surface);
198
199 gboolean
200 gst_vaapi_surface_get_image(GstVaapiSurface *surface, GstVaapiImage *image);
201
202 gboolean
203 gst_vaapi_surface_put_image(GstVaapiSurface *surface, GstVaapiImage *image);
204
205 gboolean
206 gst_vaapi_surface_associate_subpicture(
207     GstVaapiSurface         *surface,
208     GstVaapiSubpicture      *subpicture,
209     const GstVaapiRectangle *src_rect,
210     const GstVaapiRectangle *dst_rect
211 );
212
213 gboolean
214 gst_vaapi_surface_deassociate_subpicture(
215     GstVaapiSurface         *surface,
216     GstVaapiSubpicture      *subpicture
217 );
218
219 gboolean
220 gst_vaapi_surface_sync(GstVaapiSurface *surface);
221
222 gboolean
223 gst_vaapi_surface_query_status(
224     GstVaapiSurface       *surface,
225     GstVaapiSurfaceStatus *pstatus
226 );
227
228 gboolean
229 gst_vaapi_surface_set_subpictures_from_composition(
230     GstVaapiSurface            *surface,
231     GstVideoOverlayComposition *composition,
232     gboolean                    propagate_context
233 );
234
235 G_END_DECLS
236
237 #endif /* GST_VAAPI_SURFACE_H */