Restore the gst_vaapi_{surface,image,subpicture}_get_id() interfaces.
[platform/upstream/gstreamer-vaapi.git] / gst-libs / gst / vaapi / gstvaapisurface.h
1 /*
2  *  gstvaapisurface.h - VA surface abstraction
3  *
4  *  gstreamer-vaapi (C) 2010 Splitted-Desktop Systems
5  *
6  *  This program is free software; you can redistribute it and/or modify
7  *  it under the terms of the GNU General Public License as published by
8  *  the Free Software Foundation; either version 2 of the License, or
9  *  (at your option) any later version.
10  *
11  *  This program 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
14  *  GNU General Public License for more details.
15  *
16  *  You should have received a copy of the GNU General Public License
17  *  along with this program; if not, write to the Free Software
18  *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
19  */
20
21 #ifndef GST_VAAPI_SURFACE_H
22 #define GST_VAAPI_SURFACE_H
23
24 #include <gst/vaapi/gstvaapiobject.h>
25 #include <gst/vaapi/gstvaapidisplay.h>
26 #include <gst/vaapi/gstvaapiimage.h>
27 #include <gst/vaapi/gstvaapisubpicture.h>
28
29 G_BEGIN_DECLS
30
31 typedef enum _GstVaapiChromaType                GstVaapiChromaType;
32 typedef enum _GstVaapiSurfaceRenderFlags        GstVaapiSurfaceRenderFlags;
33
34 /**
35  * GstVaapiChromaType:
36  * @GST_VAAPI_CHROMA_TYPE_YUV420: 4:2:0 chroma format
37  * @GST_VAAPI_CHROMA_TYPE_YUV422: 4:2:2 chroma format
38  * @GST_VAAPI_CHROMA_TYPE_YUV444: 4:4:4 chroma format
39  *
40  * The set of all chroma types for #GstVaapiSurface.
41  */
42 enum _GstVaapiChromaType {
43     GST_VAAPI_CHROMA_TYPE_YUV420 = 1,
44     GST_VAAPI_CHROMA_TYPE_YUV422,
45     GST_VAAPI_CHROMA_TYPE_YUV444
46 };
47
48 /**
49  * GstVaapiSurfaceRenderFlags
50  * @GST_VAAPI_PICTURE_STRUCTURE_TOP_FIELD:
51  *   selects the top field of the surface
52  * @GST_VAAPI_PICTURE_STRUCTURE_BOTTOM_FIELD:
53  *   selects the bottom field of the surface
54  * @GST_VAAPI_PICTURE_STRUCTURE_FRAME:
55  *   selects the entire surface
56  * @GST_VAAPI_COLOR_STANDARD_ITUR_BT_601:
57  *   uses ITU-R BT.601 standard for color space conversion
58  * @GST_VAAPI_COLOR_STANDARD_ITUR_BT_709:
59  *   uses ITU-R BT.709 standard for color space conversion
60  *
61  * The set of all render flags for gst_vaapi_window_put_surface().
62  */
63 enum _GstVaapiSurfaceRenderFlags {
64     GST_VAAPI_PICTURE_STRUCTURE_TOP_FIELD       = 1 << 0,
65     GST_VAAPI_PICTURE_STRUCTURE_BOTTOM_FIELD    = 1 << 1,
66     GST_VAAPI_PICTURE_STRUCTURE_FRAME           =
67     (
68         GST_VAAPI_PICTURE_STRUCTURE_TOP_FIELD |
69         GST_VAAPI_PICTURE_STRUCTURE_BOTTOM_FIELD
70     ),
71     GST_VAAPI_COLOR_STANDARD_ITUR_BT_601        = 1 << 2,
72     GST_VAAPI_COLOR_STANDARD_ITUR_BT_709        = 1 << 3,
73 };
74
75 #define GST_VAAPI_TYPE_SURFACE \
76     (gst_vaapi_surface_get_type())
77
78 #define GST_VAAPI_SURFACE(obj)                          \
79     (G_TYPE_CHECK_INSTANCE_CAST((obj),                  \
80                                 GST_VAAPI_TYPE_SURFACE, \
81                                 GstVaapiSurface))
82
83 #define GST_VAAPI_SURFACE_CLASS(klass)                  \
84     (G_TYPE_CHECK_CLASS_CAST((klass),                   \
85                              GST_VAAPI_TYPE_SURFACE,    \
86                              GstVaapiSurfaceClass))
87
88 #define GST_VAAPI_IS_SURFACE(obj) \
89     (G_TYPE_CHECK_INSTANCE_TYPE((obj), GST_VAAPI_TYPE_SURFACE))
90
91 #define GST_VAAPI_IS_SURFACE_CLASS(klass) \
92     (G_TYPE_CHECK_CLASS_TYPE((klass), GST_VAAPI_TYPE_SURFACE))
93
94 #define GST_VAAPI_SURFACE_GET_CLASS(obj)                \
95     (G_TYPE_INSTANCE_GET_CLASS((obj),                   \
96                                GST_VAAPI_TYPE_SURFACE,  \
97                                GstVaapiSurfaceClass))
98
99 typedef struct _GstVaapiSurface                 GstVaapiSurface;
100 typedef struct _GstVaapiSurfacePrivate          GstVaapiSurfacePrivate;
101 typedef struct _GstVaapiSurfaceClass            GstVaapiSurfaceClass;
102
103 /**
104  * GstVaapiSurface:
105  *
106  * A VA surface wrapper.
107  */
108 struct _GstVaapiSurface {
109     /*< private >*/
110     GstVaapiObject parent_instance;
111
112     GstVaapiSurfacePrivate *priv;
113 };
114
115 /**
116  * GstVaapiSurfaceClass:
117  *
118  * A VA surface wrapper class.
119  */
120 struct _GstVaapiSurfaceClass {
121     /*< private >*/
122     GstVaapiObjectClass parent_class;
123 };
124
125 GType
126 gst_vaapi_surface_get_type(void);
127
128 GstVaapiSurface *
129 gst_vaapi_surface_new(
130     GstVaapiDisplay    *display,
131     GstVaapiChromaType  chroma_type,
132     guint               width,
133     guint               height
134 );
135
136 VASurfaceID
137 gst_vaapi_surface_get_id(GstVaapiSurface *surface);
138
139 GstVaapiChromaType
140 gst_vaapi_surface_get_chroma_type(GstVaapiSurface *surface);
141
142 guint
143 gst_vaapi_surface_get_width(GstVaapiSurface *surface);
144
145 guint
146 gst_vaapi_surface_get_height(GstVaapiSurface *surface);
147
148 void
149 gst_vaapi_surface_get_size(
150     GstVaapiSurface *surface,
151     guint           *pwidth,
152     guint           *pheight
153 );
154
155 GstVaapiImage *
156 gst_vaapi_surface_derive_image(GstVaapiSurface *surface);
157
158 gboolean
159 gst_vaapi_surface_get_image(GstVaapiSurface *surface, GstVaapiImage *image);
160
161 gboolean
162 gst_vaapi_surface_put_image(GstVaapiSurface *surface, GstVaapiImage *image);
163
164 gboolean
165 gst_vaapi_surface_associate_subpicture(
166     GstVaapiSurface         *surface,
167     GstVaapiSubpicture      *subpicture,
168     const GstVaapiRectangle *src_rect,
169     const GstVaapiRectangle *dst_rect
170 );
171
172 gboolean
173 gst_vaapi_surface_deassociate_subpicture(
174     GstVaapiSurface         *surface,
175     GstVaapiSubpicture      *subpicture
176 );
177
178 gboolean
179 gst_vaapi_surface_sync(GstVaapiSurface *surface);
180
181 G_END_DECLS
182
183 #endif /* GST_VAAPI_SURFACE_H */