2 * gstvaapicodec_objects.h - VA codec objects abstraction
4 * Copyright (C) 2010-2011 Splitted-Desktop Systems
5 * Copyright (C) 2011-2012 Intel Corporation
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.
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.
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
23 #ifndef GST_VAAPI_CODEC_COMMON_H
24 #define GST_VAAPI_CODEC_COMMON_H
26 #include <gst/gstminiobject.h>
27 #include <gst/vaapi/gstvaapidecoder.h>
31 typedef gpointer GstVaapiCodecBase;
32 typedef struct _GstVaapiCodecObject GstVaapiCodecObject;
33 typedef struct _GstVaapiCodecObjectClass GstVaapiCodecObjectClass;
34 typedef struct _GstVaapiIqMatrix GstVaapiIqMatrix;
35 typedef struct _GstVaapiIqMatrixClass GstVaapiIqMatrixClass;
36 typedef struct _GstVaapiBitPlane GstVaapiBitPlane;
37 typedef struct _GstVaapiBitPlaneClass GstVaapiBitPlaneClass;
38 typedef struct _GstVaapiHuffmanTable GstVaapiHuffmanTable;
39 typedef struct _GstVaapiHuffmanTableClass GstVaapiHuffmanTableClass;
41 /* ------------------------------------------------------------------------- */
42 /* --- Base Codec Object --- */
43 /* ------------------------------------------------------------------------- */
45 /* XXX: remove when a common base class for decoder and encoder is available */
46 #define GST_VAAPI_CODEC_BASE(obj) \
47 ((GstVaapiCodecBase *)(obj))
49 #define GST_VAAPI_TYPE_CODEC_OBJECT \
50 (gst_vaapi_codec_object_get_type())
52 #define GST_VAAPI_CODEC_OBJECT(obj) \
53 (G_TYPE_CHECK_INSTANCE_CAST((obj), \
54 GST_VAAPI_TYPE_CODEC_OBJECT, \
57 #define GST_VAAPI_CODEC_OBJECT_CLASS(klass) \
58 (G_TYPE_CHECK_CLASS_CAST((klass), \
59 GST_VAAPI_TYPE_CODEC_OBJECT, \
60 GstVaapiCodecObjectClass))
62 #define GST_VAAPI_IS_CODEC_OBJECT(obj) \
63 (G_TYPE_CHECK_INSTANCE_TYPE((obj), GST_VAAPI_TYPE_CODEC_OBJECT))
65 #define GST_VAAPI_IS_CODEC_OBJECT_CLASS(klass) \
66 (G_TYPE_CHECK_CLASS_TYPE((klass), GST_VAAPI_TYPE_CODEC_OBJECT))
68 #define GST_VAAPI_CODEC_OBJECT_GET_CLASS(obj) \
69 (G_TYPE_INSTANCE_GET_CLASS((obj), \
70 GST_VAAPI_TYPE_CODEC_OBJECT, \
71 GstVaapiCodecObjectClass))
74 GST_VAAPI_CODEC_OBJECT_FLAG_CONSTRUCTED = (GST_MINI_OBJECT_FLAG_LAST << 0),
75 GST_VAAPI_CODEC_OBJECT_FLAG_LAST = (GST_MINI_OBJECT_FLAG_LAST << 1)
79 GstVaapiCodecObject *obj;
80 GstVaapiCodecBase *codec;
86 } GstVaapiCodecObjectConstructorArgs;
89 * GstVaapiCodecObject:
91 * A #GstMiniObject holding the base codec object data
93 struct _GstVaapiCodecObject {
95 GstMiniObject parent_instance;
96 GstVaapiCodecBase *codec;
100 * GstVaapiCodecObjectClass:
102 * The #GstVaapiCodecObject base class.
104 struct _GstVaapiCodecObjectClass {
106 GstMiniObjectClass parent_class;
108 gboolean (*construct) (GstVaapiCodecObject *obj,
109 const GstVaapiCodecObjectConstructorArgs *args);
114 gst_vaapi_codec_object_get_type(void) G_GNUC_CONST;
117 GstVaapiCodecObject *
118 gst_vaapi_codec_object_new(
120 GstVaapiCodecBase *codec,
129 gst_vaapi_codec_object_construct(
130 GstVaapiCodecObject *obj,
131 const GstVaapiCodecObjectConstructorArgs *args
134 /* ------------------------------------------------------------------------- */
135 /* --- Inverse Quantization Matrices --- */
136 /* ------------------------------------------------------------------------- */
138 #define GST_VAAPI_TYPE_IQ_MATRIX \
139 (gst_vaapi_iq_matrix_get_type())
141 #define GST_VAAPI_IQ_MATRIX_CAST(obj) \
142 ((GstVaapiIqMatrix *)(obj))
144 #define GST_VAAPI_IQ_MATRIX(obj) \
145 (G_TYPE_CHECK_INSTANCE_CAST((obj), \
146 GST_VAAPI_TYPE_IQ_MATRIX, \
149 #define GST_VAAPI_IQ_MATRIX_CLASS(klass) \
150 (G_TYPE_CHECK_CLASS_CAST((klass), \
151 GST_VAAPI_TYPE_IQ_MATRIX, \
152 GstVaapiIqMatrixClass))
154 #define GST_VAAPI_IS_IQ_MATRIX(obj) \
155 (G_TYPE_CHECK_INSTANCE_TYPE((obj), GST_VAAPI_TYPE_IQ_MATRIX))
157 #define GST_VAAPI_IS_IQ_MATRIX_CLASS(klass) \
158 (G_TYPE_CHECK_CLASS_TYPE((klass), GST_VAAPI_TYPE_IQ_MATRIX))
160 #define GST_VAAPI_IQ_MATRIX_GET_CLASS(obj) \
161 (G_TYPE_INSTANCE_GET_CLASS((obj), \
162 GST_VAAPI_TYPE_IQ_MATRIX, \
163 GstVaapiIqMatrixClass))
168 * A #GstVaapiCodecObject holding an inverse quantization matrix parameter.
170 struct _GstVaapiIqMatrix {
172 GstVaapiCodecObject parent_instance;
180 * GstVaapiIqMatrixClass:
182 * The #GstVaapiIqMatrix base class.
184 struct _GstVaapiIqMatrixClass {
186 GstVaapiCodecObjectClass parent_class;
191 gst_vaapi_iq_matrix_get_type(void) G_GNUC_CONST;
195 gst_vaapi_iq_matrix_new(
196 GstVaapiDecoder *decoder,
201 /* ------------------------------------------------------------------------- */
202 /* --- VC-1 Bit Planes --- */
203 /* ------------------------------------------------------------------------- */
205 #define GST_VAAPI_TYPE_BITPLANE \
206 (gst_vaapi_bitplane_get_type())
208 #define GST_VAAPI_BITPLANE_CAST(obj) \
209 ((GstVaapiBitPlane *)(obj))
211 #define GST_VAAPI_BITPLANE(obj) \
212 (G_TYPE_CHECK_INSTANCE_CAST((obj), \
213 GST_VAAPI_TYPE_BITPLANE, \
216 #define GST_VAAPI_BITPLANE_CLASS(klass) \
217 (G_TYPE_CHECK_CLASS_CAST((klass), \
218 GST_VAAPI_TYPE_BITPLANE, \
219 GstVaapiBitPlaneClass))
221 #define GST_VAAPI_IS_BITPLANE(obj) \
222 (G_TYPE_CHECK_INSTANCE_TYPE((obj), GST_VAAPI_TYPE_BITPLANE))
224 #define GST_VAAPI_IS_BITPLANE_CLASS(klass) \
225 (G_TYPE_CHECK_CLASS_TYPE((klass), GST_VAAPI_TYPE_BITPLANE))
227 #define GST_VAAPI_BITPLANE_GET_CLASS(obj) \
228 (G_TYPE_INSTANCE_GET_CLASS((obj), \
229 GST_VAAPI_TYPE_BITPLANE, \
230 GstVaapiBitPlaneClass))
235 * A #GstVaapiCodecObject holding a VC-1 bit plane parameter.
237 struct _GstVaapiBitPlane {
239 GstVaapiCodecObject parent_instance;
247 * GstVaapiBitPlaneClass:
249 * The #GstVaapiBitPlane base class.
251 struct _GstVaapiBitPlaneClass {
253 GstVaapiCodecObjectClass parent_class;
258 gst_vaapi_bitplane_get_type(void) G_GNUC_CONST;
262 gst_vaapi_bitplane_new(GstVaapiDecoder *decoder, guint8 *data, guint data_size);
264 /* ------------------------------------------------------------------------- */
265 /* --- JPEG Huffman Tables --- */
266 /* ------------------------------------------------------------------------- */
268 #define GST_VAAPI_TYPE_HUFFMAN_TABLE \
269 (gst_vaapi_huffman_table_get_type())
271 #define GST_VAAPI_HUFFMAN_TABLE_CAST(obj) \
272 ((GstVaapiHuffmanTable *)(obj))
274 #define GST_VAAPI_HUFFMAN_TABLE(obj) \
275 (G_TYPE_CHECK_INSTANCE_CAST((obj), \
276 GST_VAAPI_TYPE_HUFFMAN_TABLE, \
277 GstVaapiHuffmanTable))
279 #define GST_VAAPI_HUFFMAN_TABLE_CLASS(klass) \
280 (G_TYPE_CHECK_CLASS_CAST((klass), \
281 GST_VAAPI_TYPE_HUFFMAN_TABLE, \
282 GstVaapiHuffmanTableClass))
284 #define GST_VAAPI_IS_HUFFMAN_TABLE(obj) \
285 (G_TYPE_CHECK_INSTANCE_TYPE((obj), GST_VAAPI_TYPE_HUFFMAN_TABLE))
287 #define GST_VAAPI_IS_HUFFMAN_TABLE_CLASS(klass) \
288 (G_TYPE_CHECK_CLASS_TYPE((klass), GST_VAAPI_TYPE_HUFFMAN_TABLE))
290 #define GST_VAAPI_HUFFMAN_TABLE_GET_CLASS(obj) \
291 (G_TYPE_INSTANCE_GET_CLASS((obj), \
292 GST_VAAPI_TYPE_HUFFMAN_TABLE, \
293 GstVaapiHuffmanTableClass))
296 * GstVaapiHuffmanTable:
298 * A #GstVaapiCodecObject holding huffman table.
300 struct _GstVaapiHuffmanTable {
302 GstVaapiCodecObject parent_instance;
310 * GstVaapiHuffmanTableClass:
312 * The #GstVaapiHuffmanTable base class.
314 struct _GstVaapiHuffmanTableClass {
316 GstVaapiCodecObjectClass parent_class;
321 gst_vaapi_huffman_table_get_type(void) G_GNUC_CONST;
324 GstVaapiHuffmanTable *
325 gst_vaapi_huffman_table_new(
326 GstVaapiDecoder *decoder,
331 /* ------------------------------------------------------------------------- */
332 /* --- Helpers to create codec-dependent objects --- */
333 /* ------------------------------------------------------------------------- */
335 #define GST_VAAPI_CODEC_DEFINE_TYPE(type, prefix, base_type) \
336 G_DEFINE_TYPE(type, prefix, base_type) \
339 prefix##_destroy(type *); \
344 const GstVaapiCodecObjectConstructorArgs *args \
348 prefix##_finalize(GstMiniObject *object) \
350 GstMiniObjectClass *parent_class; \
352 prefix##_destroy((type *)object); \
354 parent_class = GST_MINI_OBJECT_CLASS(prefix##_parent_class); \
355 if (parent_class->finalize) \
356 parent_class->finalize(object); \
360 prefix##_construct( \
361 GstVaapiCodecObject *object, \
362 const GstVaapiCodecObjectConstructorArgs *args \
365 GstVaapiCodecObjectClass *parent_class; \
367 parent_class = GST_VAAPI_CODEC_OBJECT_CLASS(prefix##_parent_class); \
368 if (parent_class->construct) { \
369 if (!parent_class->construct(object, args)) \
372 return prefix##_create((type *)object, args); \
376 prefix##_class_init(type##Class *klass) \
378 GstMiniObjectClass * const object_class = \
379 GST_MINI_OBJECT_CLASS(klass); \
380 GstVaapiCodecObjectClass * const codec_class = \
381 GST_VAAPI_CODEC_OBJECT_CLASS(klass); \
383 object_class->finalize = prefix##_finalize; \
384 codec_class->construct = prefix##_construct; \
387 #define GST_VAAPI_IQ_MATRIX_NEW(codec, decoder) \
388 gst_vaapi_iq_matrix_new(GST_VAAPI_DECODER_CAST(decoder), \
389 NULL, sizeof(VAIQMatrixBuffer##codec))
391 #define GST_VAAPI_BITPLANE_NEW(decoder, size) \
392 gst_vaapi_bitplane_new(GST_VAAPI_DECODER_CAST(decoder), NULL, size)
394 #define GST_VAAPI_HUFFMAN_TABLE_NEW(codec, decoder) \
395 gst_vaapi_huffman_table_new(GST_VAAPI_DECODER_CAST(decoder), \
396 NULL, sizeof(VAHuffmanTableBuffer##codec))
400 #endif /* GST_VAAPI_CODEC_OBJECTS_H */