Tizen 2.0 Release
[framework/multimedia/gstreamer-vaapi.git] / gst-libs / gst / vaapi / gstvaapiimage.h
1 /*
2  *  gstvaapiimage.h - VA image abstraction
3  *
4  *  Copyright (C) 2010-2011 Splitted-Desktop Systems
5  *  Copyright (C) 2011-2012 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_IMAGE_H
24 #define GST_VAAPI_IMAGE_H
25
26 #include <gst/gstbuffer.h>
27 #include <gst/vaapi/gstvaapiobject.h>
28 #include <gst/vaapi/gstvaapidisplay.h>
29 #include <gst/vaapi/gstvaapiimageformat.h>
30
31 G_BEGIN_DECLS
32
33 #define GST_VAAPI_TYPE_IMAGE \
34     (gst_vaapi_image_get_type())
35
36 #define GST_VAAPI_IMAGE(obj)                            \
37     (G_TYPE_CHECK_INSTANCE_CAST((obj),                  \
38                                 GST_VAAPI_TYPE_IMAGE,   \
39                                 GstVaapiImage))
40
41 #define GST_VAAPI_IMAGE_CLASS(klass)                    \
42     (G_TYPE_CHECK_CLASS_CAST((klass),                   \
43                              GST_VAAPI_TYPE_IMAGE,      \
44                              GstVaapiImageClass))
45
46 #define GST_VAAPI_IS_IMAGE(obj) \
47     (G_TYPE_CHECK_INSTANCE_TYPE((obj), GST_VAAPI_TYPE_IMAGE))
48
49 #define GST_VAAPI_IS_IMAGE_CLASS(klass) \
50     (G_TYPE_CHECK_CLASS_TYPE((klass), GST_VAAPI_TYPE_IMAGE))
51
52 #define GST_VAAPI_IMAGE_GET_CLASS(obj)                  \
53     (G_TYPE_INSTANCE_GET_CLASS((obj),                   \
54                                GST_VAAPI_TYPE_IMAGE,    \
55                                GstVaapiImageClass))
56
57 /**
58  * GST_VAAPI_IMAGE_FORMAT:
59  * @image: a #GstVaapiImage
60  *
61  * Macro that evaluates to the #GstVaapiImageFormat of @image.
62  */
63 #define GST_VAAPI_IMAGE_FORMAT(image)   gst_vaapi_image_get_format(image)
64
65 /**
66  * GST_VAAPI_IMAGE_WIDTH:
67  * @image: a #GstVaapiImage
68  *
69  * Macro that evaluates to the width of @image.
70  */
71 #define GST_VAAPI_IMAGE_WIDTH(image)    gst_vaapi_image_get_width(image)
72
73 /**
74  * GST_VAAPI_IMAGE_HEIGHT:
75  * @image: a #GstVaapiImage
76  *
77  * Macro that evaluates to the height of @image.
78  */
79 #define GST_VAAPI_IMAGE_HEIGHT(image)   gst_vaapi_image_get_height(image)
80
81 typedef struct _GstVaapiImage                   GstVaapiImage;
82 typedef struct _GstVaapiImagePrivate            GstVaapiImagePrivate;
83 typedef struct _GstVaapiImageClass              GstVaapiImageClass;
84 typedef struct _GstVaapiImageRaw                GstVaapiImageRaw;
85
86 /**
87  * GstVaapiImage:
88  *
89  * A VA image wrapper
90  */
91 struct _GstVaapiImage {
92     /*< private >*/
93     GstVaapiObject parent_instance;
94
95     GstVaapiImagePrivate *priv;
96 };
97
98 /**
99  * GstVaapiImageClass:
100  *
101  * A VA image wrapper class
102  */
103 struct _GstVaapiImageClass {
104     /*< private >*/
105     GstVaapiObjectClass parent_class;
106 };
107
108 /**
109  * GstVaapiImageRaw:
110  *
111  * A raw image wrapper. The caller is responsible for initializing all
112  * the fields with sensible values.
113  */
114 struct _GstVaapiImageRaw {
115     GstVaapiImageFormat format;
116     guint               width;
117     guint               height;
118     guint               num_planes;
119     guchar             *pixels[3];
120     guint               stride[3];
121 };
122
123 GType
124 gst_vaapi_image_get_type(void) G_GNUC_CONST;
125
126 GstVaapiImage *
127 gst_vaapi_image_new(
128     GstVaapiDisplay    *display,
129     GstVaapiImageFormat format,
130     guint               width,
131     guint               height
132 );
133
134 GstVaapiImage *
135 gst_vaapi_image_new_with_image(GstVaapiDisplay *display, VAImage *va_image);
136
137 GstVaapiID
138 gst_vaapi_image_get_id(GstVaapiImage *image);
139
140 gboolean
141 gst_vaapi_image_get_image(GstVaapiImage *image, VAImage *va_image);
142
143 GstVaapiImageFormat
144 gst_vaapi_image_get_format(GstVaapiImage *image);
145
146 guint
147 gst_vaapi_image_get_width(GstVaapiImage *image);
148
149 guint
150 gst_vaapi_image_get_height(GstVaapiImage *image);
151
152 void
153 gst_vaapi_image_get_size(GstVaapiImage *image, guint *pwidth, guint *pheight);
154
155 gboolean
156 gst_vaapi_image_is_linear(GstVaapiImage *image);
157
158 gboolean
159 gst_vaapi_image_is_mapped(GstVaapiImage *image);
160
161 gboolean
162 gst_vaapi_image_map(GstVaapiImage *image);
163
164 gboolean
165 gst_vaapi_image_unmap(GstVaapiImage *image);
166
167 gboolean
168 gst_vaapi_image_ensure_mapped_buffer(GstVaapiImage *image);
169
170 guint
171 gst_vaapi_image_get_plane_count(GstVaapiImage *image);
172
173 guchar *
174 gst_vaapi_image_get_plane(GstVaapiImage *image, guint plane);
175
176 guint
177 gst_vaapi_image_get_pitch(GstVaapiImage *image, guint plane);
178
179 guint
180 gst_vaapi_image_get_data_size(GstVaapiImage *image);
181
182 gboolean
183 gst_vaapi_image_get_buffer(
184     GstVaapiImage     *image,
185     GstBuffer         *buffer,
186     GstVaapiRectangle *rect
187 );
188
189 gboolean
190 gst_vaapi_image_get_raw(
191     GstVaapiImage     *image,
192     GstVaapiImageRaw  *dst_image,
193     GstVaapiRectangle *rect
194 );
195
196 gboolean
197 gst_vaapi_image_update_from_buffer(
198     GstVaapiImage     *image,
199     GstBuffer         *buffer,
200     GstVaapiRectangle *rect
201 );
202
203 gboolean
204 gst_vaapi_image_update_from_raw(
205     GstVaapiImage     *image,
206     GstVaapiImageRaw  *src_image,
207     GstVaapiRectangle *rect
208 );
209
210 gboolean
211 gst_vaapi_convert_buffer_to_image(
212     GstVaapiImage *image,
213     GstBuffer *buffer);
214
215 G_END_DECLS
216
217 #endif /* GST_VAAPI_IMAGE_H */