2 * gstvaapidecoder_priv.h - VA decoder abstraction (private definitions)
4 * Copyright (C) 2010-2011 Splitted-Desktop Systems
5 * Author: Gwenole Beauchesne <gwenole.beauchesne@splitted-desktop.com>
6 * Copyright (C) 2011-2014 Intel Corporation
7 * Author: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public License
11 * as published by the Free Software Foundation; either version 2.1
12 * of the License, or (at your option) any later version.
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with this library; if not, write to the Free
21 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
22 * Boston, MA 02110-1301 USA
25 #ifndef GST_VAAPI_DECODER_PRIV_H
26 #define GST_VAAPI_DECODER_PRIV_H
29 #include <gst/vaapi/gstvaapidecoder.h>
30 #include <gst/vaapi/gstvaapidecoder_unit.h>
31 #include <gst/vaapi/gstvaapicontext.h>
32 #include "gstvaapiminiobject.h"
36 #define GST_VAAPI_DECODER_CAST(decoder) \
37 ((GstVaapiDecoder *)(decoder))
39 #define GST_VAAPI_DECODER_CLASS(klass) \
40 ((GstVaapiDecoderClass *)(klass))
42 #define GST_VAAPI_IS_DECODER_CLASS(klass) \
45 #define GST_VAAPI_DECODER_GET_CLASS(obj) \
46 GST_VAAPI_DECODER_CLASS(GST_VAAPI_MINI_OBJECT_GET_CLASS(obj))
48 typedef struct _GstVaapiDecoderClass GstVaapiDecoderClass;
49 struct _GstVaapiDecoderUnit;
52 * GST_VAAPI_PARSER_STATE:
53 * @decoder: a #GstVaapiDecoder
55 * Macro that evaluates to the #GstVaapiParserState of @decoder.
56 * This is an internal macro that does not do any run-time type check.
58 #undef GST_VAAPI_PARSER_STATE
59 #define GST_VAAPI_PARSER_STATE(decoder) \
60 (&GST_VAAPI_DECODER_CAST(decoder)->parser_state)
63 * GST_VAAPI_DECODER_DISPLAY:
64 * @decoder: a #GstVaapiDecoder
66 * Macro that evaluates to the #GstVaapiDisplay of @decoder.
67 * This is an internal macro that does not do any run-time type check.
69 #undef GST_VAAPI_DECODER_DISPLAY
70 #define GST_VAAPI_DECODER_DISPLAY(decoder) \
71 GST_VAAPI_DECODER_CAST(decoder)->display
74 * GST_VAAPI_DECODER_CONTEXT:
75 * @decoder: a #GstVaapiDecoder
77 * Macro that evaluates to the #GstVaapiContext of @decoder.
78 * This is an internal macro that does not do any run-time type check.
80 #undef GST_VAAPI_DECODER_CONTEXT
81 #define GST_VAAPI_DECODER_CONTEXT(decoder) \
82 GST_VAAPI_DECODER_CAST(decoder)->context
85 * GST_VAAPI_DECODER_CODEC:
86 * @decoder: a #GstVaapiDecoder
88 * Macro that evaluates to the #GstVaapiCodec of @decoder.
89 * This is an internal macro that does not do any run-time type check.
91 #undef GST_VAAPI_DECODER_CODEC
92 #define GST_VAAPI_DECODER_CODEC(decoder) \
93 GST_VAAPI_DECODER_CAST(decoder)->codec
96 * GST_VAAPI_DECODER_CODEC_STATE:
97 * @decoder: a #GstVaapiDecoder
99 * Macro that evaluates to the #GstVideoCodecState holding codec state
101 * This is an internal macro that does not do any run-time type check.
103 #undef GST_VAAPI_DECODER_CODEC_STATE
104 #define GST_VAAPI_DECODER_CODEC_STATE(decoder) \
105 GST_VAAPI_DECODER_CAST(decoder)->codec_state
108 * GST_VAAPI_DECODER_CODEC_DATA:
109 * @decoder: a #GstVaapiDecoder
111 * Macro that evaluates to the #GstBuffer holding optional codec data
113 * This is an internal macro that does not do any run-time type check.
115 #undef GST_VAAPI_DECODER_CODEC_DATA
116 #define GST_VAAPI_DECODER_CODEC_DATA(decoder) \
117 GST_VAAPI_DECODER_CODEC_STATE(decoder)->codec_data
120 * GST_VAAPI_DECODER_CODEC_FRAME:
121 * @decoder: a #GstVaapiDecoder
123 * Macro that evaluates to the #GstVideoCodecFrame holding decoder
124 * units for the current frame.
125 * This is an internal macro that does not do any run-time type check.
127 #undef GST_VAAPI_DECODER_CODEC_FRAME
128 #define GST_VAAPI_DECODER_CODEC_FRAME(decoder) \
129 GST_VAAPI_PARSER_STATE(decoder)->current_frame
132 * GST_VAAPI_DECODER_WIDTH:
133 * @decoder: a #GstVaapiDecoder
135 * Macro that evaluates to the coded width of the picture
136 * This is an internal macro that does not do any run-time type check.
138 #undef GST_VAAPI_DECODER_WIDTH
139 #define GST_VAAPI_DECODER_WIDTH(decoder) \
140 GST_VAAPI_DECODER_CODEC_STATE(decoder)->info.width
143 * GST_VAAPI_DECODER_HEIGHT:
144 * @decoder: a #GstVaapiDecoder
146 * Macro that evaluates to the coded height of the picture
147 * This is an internal macro that does not do any run-time type check.
149 #undef GST_VAAPI_DECODER_HEIGHT
150 #define GST_VAAPI_DECODER_HEIGHT(decoder) \
151 GST_VAAPI_DECODER_CODEC_STATE(decoder)->info.height
153 /* End-of-Stream buffer */
154 #define GST_BUFFER_FLAG_EOS (GST_BUFFER_FLAG_LAST + 0)
156 #define GST_BUFFER_IS_EOS(buffer) \
157 GST_BUFFER_FLAG_IS_SET(buffer, GST_BUFFER_FLAG_EOS)
159 #define GST_VAAPI_DECODER_GET_PRIVATE(obj) \
160 (G_TYPE_INSTANCE_GET_PRIVATE((obj), \
161 GST_VAAPI_TYPE_DECODER, \
162 GstVaapiDecoderPrivate))
165 GST_VAAPI_DECODER_STATUS_DROP_FRAME = -2
166 } GstVaapiDecoderStatusPrivate;
168 typedef struct _GstVaapiParserState GstVaapiParserState;
169 struct _GstVaapiParserState {
170 GstVideoCodecFrame *current_frame;
171 guint32 current_frame_number;
172 GstAdapter *current_adapter;
173 GstAdapter *input_adapter;
176 GstAdapter *output_adapter;
177 GstVaapiDecoderUnit next_unit;
178 guint next_unit_pending : 1;
185 * A VA decoder base instance.
187 struct _GstVaapiDecoder {
189 GstVaapiMiniObject parent_instance;
192 GstVaapiDisplay *display;
193 VADisplay va_display;
194 GstVaapiContext *context;
195 VAContextID va_context;
197 GstVideoCodecState *codec_state;
198 GAsyncQueue *buffers;
200 GstVaapiParserState parser_state;
201 GstVaapiDecoderStateChangedFunc codec_state_changed_func;
202 gpointer codec_state_changed_data;
206 * GstVaapiDecoderClass:
208 * A VA decoder base class.
210 struct _GstVaapiDecoderClass {
212 GstVaapiMiniObjectClass parent_class;
214 gboolean (*create)(GstVaapiDecoder *decoder);
215 void (*destroy)(GstVaapiDecoder *decoder);
216 GstVaapiDecoderStatus (*parse)(GstVaapiDecoder *decoder,
217 GstAdapter *adapter, gboolean at_eos,
218 struct _GstVaapiDecoderUnit *unit);
219 GstVaapiDecoderStatus (*decode)(GstVaapiDecoder *decoder,
220 struct _GstVaapiDecoderUnit *unit);
221 GstVaapiDecoderStatus (*start_frame)(GstVaapiDecoder *decoder,
222 struct _GstVaapiDecoderUnit *unit);
223 GstVaapiDecoderStatus (*end_frame)(GstVaapiDecoder *decoder);
224 GstVaapiDecoderStatus (*flush)(GstVaapiDecoder *decoder);
225 GstVaapiDecoderStatus (*decode_codec_data)(GstVaapiDecoder *decoder,
226 const guchar *buf, guint buf_size);
231 gst_vaapi_decoder_new(const GstVaapiDecoderClass *klass,
232 GstVaapiDisplay *display, GstCaps *caps);
236 gst_vaapi_decoder_finalize(GstVaapiDecoder *decoder);
240 gst_vaapi_decoder_set_picture_size(
241 GstVaapiDecoder *decoder,
248 gst_vaapi_decoder_set_framerate(
249 GstVaapiDecoder *decoder,
256 gst_vaapi_decoder_set_pixel_aspect_ratio(
257 GstVaapiDecoder *decoder,
264 gst_vaapi_decoder_set_interlace_mode(GstVaapiDecoder *decoder,
265 GstVideoInterlaceMode mode);
269 gst_vaapi_decoder_set_interlaced(GstVaapiDecoder *decoder, gboolean interlaced);
273 gst_vaapi_decoder_ensure_context(
274 GstVaapiDecoder *decoder,
275 GstVaapiContextInfo *cip
280 gst_vaapi_decoder_push_frame(GstVaapiDecoder *decoder,
281 GstVideoCodecFrame *frame);
284 GstVaapiDecoderStatus
285 gst_vaapi_decoder_check_status(GstVaapiDecoder *decoder);
288 GstVaapiDecoderStatus
289 gst_vaapi_decoder_decode_codec_data(GstVaapiDecoder *decoder);
293 #endif /* GST_VAAPI_DECODER_PRIV_H */