39
39
#include "gstvaapidebug.h"
42
drop_frame(GstVaapiDecoder *decoder, GstVideoCodecFrame *frame);
42
drop_frame (GstVaapiDecoder * decoder, GstVideoCodecFrame * frame);
45
parser_state_finalize(GstVaapiParserState *ps)
45
parser_state_finalize (GstVaapiParserState * ps)
47
if (ps->input_adapter) {
48
gst_adapter_clear(ps->input_adapter);
49
g_object_unref(ps->input_adapter);
50
ps->input_adapter = NULL;
53
if (ps->output_adapter) {
54
gst_adapter_clear(ps->output_adapter);
55
g_object_unref(ps->output_adapter);
56
ps->output_adapter = NULL;
59
if (ps->next_unit_pending) {
60
gst_vaapi_decoder_unit_clear(&ps->next_unit);
61
ps->next_unit_pending = FALSE;
47
if (ps->input_adapter) {
48
gst_adapter_clear (ps->input_adapter);
49
g_object_unref (ps->input_adapter);
50
ps->input_adapter = NULL;
53
if (ps->output_adapter) {
54
gst_adapter_clear (ps->output_adapter);
55
g_object_unref (ps->output_adapter);
56
ps->output_adapter = NULL;
59
if (ps->next_unit_pending) {
60
gst_vaapi_decoder_unit_clear (&ps->next_unit);
61
ps->next_unit_pending = FALSE;
66
parser_state_init(GstVaapiParserState *ps)
66
parser_state_init (GstVaapiParserState * ps)
68
memset(ps, 0, sizeof(*ps));
70
ps->input_adapter = gst_adapter_new();
71
if (!ps->input_adapter)
74
ps->output_adapter = gst_adapter_new();
75
if (!ps->output_adapter)
68
memset (ps, 0, sizeof (*ps));
70
ps->input_adapter = gst_adapter_new ();
71
if (!ps->input_adapter)
74
ps->output_adapter = gst_adapter_new ();
75
if (!ps->output_adapter)
81
parser_state_prepare(GstVaapiParserState *ps, GstAdapter *adapter)
81
parser_state_prepare (GstVaapiParserState * ps, GstAdapter * adapter)
83
/* XXX: check we really have a continuity from the previous call */
84
if (ps->current_adapter != adapter)
83
/* XXX: check we really have a continuity from the previous call */
84
if (ps->current_adapter != adapter)
89
ps->current_adapter = adapter;
90
ps->input_offset1 = -1;
91
ps->input_offset2 = -1;
89
ps->current_adapter = adapter;
90
ps->input_offset1 = -1;
91
ps->input_offset2 = -1;
95
push_buffer(GstVaapiDecoder *decoder, GstBuffer *buffer)
95
push_buffer (GstVaapiDecoder * decoder, GstBuffer * buffer)
98
buffer = gst_buffer_new();
101
GST_BUFFER_FLAG_SET(buffer, GST_BUFFER_FLAG_EOS);
104
GST_DEBUG("queue encoded data buffer %p (%d bytes)",
105
buffer, gst_buffer_get_size(buffer));
107
g_async_queue_push(decoder->buffers, buffer);
98
buffer = gst_buffer_new ();
101
GST_BUFFER_FLAG_SET (buffer, GST_BUFFER_FLAG_EOS);
104
GST_DEBUG ("queue encoded data buffer %p (%zu bytes)",
105
buffer, gst_buffer_get_size (buffer));
107
g_async_queue_push (decoder->buffers, buffer);
111
111
static GstBuffer *
112
pop_buffer(GstVaapiDecoder *decoder)
112
pop_buffer (GstVaapiDecoder * decoder)
116
buffer = g_async_queue_try_pop(decoder->buffers);
120
GST_DEBUG("dequeue buffer %p for decoding (%d bytes)",
121
buffer, gst_buffer_get_size(buffer));
116
buffer = g_async_queue_try_pop (decoder->buffers);
120
GST_DEBUG ("dequeue buffer %p for decoding (%zu bytes)",
121
buffer, gst_buffer_get_size (buffer));
126
126
static GstVaapiDecoderStatus
127
do_parse(GstVaapiDecoder *decoder,
128
GstVideoCodecFrame *base_frame, GstAdapter *adapter, gboolean at_eos,
129
guint *got_unit_size_ptr, gboolean *got_frame_ptr)
127
do_parse (GstVaapiDecoder * decoder,
128
GstVideoCodecFrame * base_frame, GstAdapter * adapter, gboolean at_eos,
129
guint * got_unit_size_ptr, gboolean * got_frame_ptr)
131
GstVaapiParserState * const ps = &decoder->parser_state;
132
GstVaapiParserFrame *frame;
133
GstVaapiDecoderUnit *unit;
134
GstVaapiDecoderStatus status;
136
*got_unit_size_ptr = 0;
137
*got_frame_ptr = FALSE;
139
frame = gst_video_codec_frame_get_user_data(base_frame);
141
GstVideoCodecState * const codec_state = decoder->codec_state;
142
frame = gst_vaapi_parser_frame_new(codec_state->info.width,
143
codec_state->info.height);
145
return GST_VAAPI_DECODER_STATUS_ERROR_ALLOCATION_FAILED;
146
gst_video_codec_frame_set_user_data(base_frame,
147
frame, (GDestroyNotify)gst_vaapi_mini_object_unref);
150
parser_state_prepare(ps, adapter);
152
unit = &ps->next_unit;
153
if (ps->next_unit_pending) {
154
ps->next_unit_pending = FALSE;
157
gst_vaapi_decoder_unit_init(unit);
159
ps->current_frame = base_frame;
160
status = GST_VAAPI_DECODER_GET_CLASS(decoder)->parse(decoder,
161
adapter, at_eos, unit);
162
if (status != GST_VAAPI_DECODER_STATUS_SUCCESS) {
163
if (at_eos && frame->units->len > 0 &&
164
status == GST_VAAPI_DECODER_STATUS_ERROR_NO_DATA) {
165
/* XXX: assume the frame is complete at <EOS> */
166
*got_frame_ptr = TRUE;
167
return GST_VAAPI_DECODER_STATUS_SUCCESS;
172
if (GST_VAAPI_DECODER_UNIT_IS_FRAME_START(unit) && frame->units->len > 0) {
173
ps->next_unit_pending = TRUE;
174
*got_frame_ptr = TRUE;
175
return GST_VAAPI_DECODER_STATUS_SUCCESS;
131
GstVaapiParserState *const ps = &decoder->parser_state;
132
GstVaapiParserFrame *frame;
133
GstVaapiDecoderUnit *unit;
134
GstVaapiDecoderStatus status;
136
*got_unit_size_ptr = 0;
137
*got_frame_ptr = FALSE;
139
frame = gst_video_codec_frame_get_user_data (base_frame);
141
GstVideoCodecState *const codec_state = decoder->codec_state;
142
frame = gst_vaapi_parser_frame_new (codec_state->info.width,
143
codec_state->info.height);
145
return GST_VAAPI_DECODER_STATUS_ERROR_ALLOCATION_FAILED;
146
gst_video_codec_frame_set_user_data (base_frame,
147
frame, (GDestroyNotify) gst_vaapi_mini_object_unref);
150
parser_state_prepare (ps, adapter);
152
unit = &ps->next_unit;
153
if (ps->next_unit_pending) {
154
ps->next_unit_pending = FALSE;
157
gst_vaapi_decoder_unit_init (unit);
159
ps->current_frame = base_frame;
160
status = GST_VAAPI_DECODER_GET_CLASS (decoder)->parse (decoder,
161
adapter, at_eos, unit);
162
if (status != GST_VAAPI_DECODER_STATUS_SUCCESS) {
163
if (at_eos && frame->units->len > 0 &&
164
status == GST_VAAPI_DECODER_STATUS_ERROR_NO_DATA) {
165
/* XXX: assume the frame is complete at <EOS> */
166
*got_frame_ptr = TRUE;
167
return GST_VAAPI_DECODER_STATUS_SUCCESS;
172
if (GST_VAAPI_DECODER_UNIT_IS_FRAME_START (unit) && frame->units->len > 0) {
173
ps->next_unit_pending = TRUE;
174
*got_frame_ptr = TRUE;
175
return GST_VAAPI_DECODER_STATUS_SUCCESS;
179
gst_vaapi_parser_frame_append_unit(frame, unit);
180
*got_unit_size_ptr = unit->size;
181
*got_frame_ptr = GST_VAAPI_DECODER_UNIT_IS_FRAME_END(unit);
182
return GST_VAAPI_DECODER_STATUS_SUCCESS;
185
static GstVaapiDecoderStatus
186
do_decode_units(GstVaapiDecoder *decoder, GArray *units)
188
GstVaapiDecoderClass * const klass = GST_VAAPI_DECODER_GET_CLASS(decoder);
189
GstVaapiDecoderStatus status;
192
for (i = 0; i < units->len; i++) {
193
GstVaapiDecoderUnit * const unit =
194
&g_array_index(units, GstVaapiDecoderUnit, i);
195
if (GST_VAAPI_DECODER_UNIT_IS_SKIPPED(unit))
197
status = klass->decode(decoder, unit);
198
if (status != GST_VAAPI_DECODER_STATUS_SUCCESS)
201
return GST_VAAPI_DECODER_STATUS_SUCCESS;
204
static GstVaapiDecoderStatus
205
do_decode_1(GstVaapiDecoder *decoder, GstVaapiParserFrame *frame)
207
GstVaapiDecoderClass * const klass = GST_VAAPI_DECODER_GET_CLASS(decoder);
208
GstVaapiDecoderStatus status;
210
if (frame->pre_units->len > 0) {
211
status = do_decode_units(decoder, frame->pre_units);
212
if (status != GST_VAAPI_DECODER_STATUS_SUCCESS)
216
if (frame->units->len > 0) {
217
if (klass->start_frame) {
218
GstVaapiDecoderUnit * const unit =
219
&g_array_index(frame->units, GstVaapiDecoderUnit, 0);
220
status = klass->start_frame(decoder, unit);
221
if (status != GST_VAAPI_DECODER_STATUS_SUCCESS)
225
status = do_decode_units(decoder, frame->units);
226
if (status != GST_VAAPI_DECODER_STATUS_SUCCESS)
229
if (klass->end_frame) {
230
status = klass->end_frame(decoder);
231
if (status != GST_VAAPI_DECODER_STATUS_SUCCESS)
236
if (frame->post_units->len > 0) {
237
status = do_decode_units(decoder, frame->post_units);
238
if (status != GST_VAAPI_DECODER_STATUS_SUCCESS)
242
/* Drop frame if there is no slice data unit in there */
243
if (G_UNLIKELY(frame->units->len == 0))
244
return GST_VAAPI_DECODER_STATUS_DROP_FRAME;
245
return GST_VAAPI_DECODER_STATUS_SUCCESS;
179
gst_vaapi_parser_frame_append_unit (frame, unit);
180
*got_unit_size_ptr = unit->size;
181
*got_frame_ptr = GST_VAAPI_DECODER_UNIT_IS_FRAME_END (unit);
182
return GST_VAAPI_DECODER_STATUS_SUCCESS;
185
static GstVaapiDecoderStatus
186
do_decode_units (GstVaapiDecoder * decoder, GArray * units)
188
GstVaapiDecoderClass *const klass = GST_VAAPI_DECODER_GET_CLASS (decoder);
189
GstVaapiDecoderStatus status;
192
for (i = 0; i < units->len; i++) {
193
GstVaapiDecoderUnit *const unit =
194
&g_array_index (units, GstVaapiDecoderUnit, i);
195
if (GST_VAAPI_DECODER_UNIT_IS_SKIPPED (unit))
197
status = klass->decode (decoder, unit);
198
if (status != GST_VAAPI_DECODER_STATUS_SUCCESS)
201
return GST_VAAPI_DECODER_STATUS_SUCCESS;
204
static GstVaapiDecoderStatus
205
do_decode_1 (GstVaapiDecoder * decoder, GstVaapiParserFrame * frame)
207
GstVaapiDecoderClass *const klass = GST_VAAPI_DECODER_GET_CLASS (decoder);
208
GstVaapiDecoderStatus status;
210
if (frame->pre_units->len > 0) {
211
status = do_decode_units (decoder, frame->pre_units);
212
if (status != GST_VAAPI_DECODER_STATUS_SUCCESS)
216
if (frame->units->len > 0) {
217
if (klass->start_frame) {
218
GstVaapiDecoderUnit *const unit =
219
&g_array_index (frame->units, GstVaapiDecoderUnit, 0);
220
status = klass->start_frame (decoder, unit);
221
if (status != GST_VAAPI_DECODER_STATUS_SUCCESS)
225
status = do_decode_units (decoder, frame->units);
226
if (status != GST_VAAPI_DECODER_STATUS_SUCCESS)
229
if (klass->end_frame) {
230
status = klass->end_frame (decoder);
231
if (status != GST_VAAPI_DECODER_STATUS_SUCCESS)
236
if (frame->post_units->len > 0) {
237
status = do_decode_units (decoder, frame->post_units);
238
if (status != GST_VAAPI_DECODER_STATUS_SUCCESS)
242
/* Drop frame if there is no slice data unit in there */
243
if (G_UNLIKELY (frame->units->len == 0))
244
return GST_VAAPI_DECODER_STATUS_DROP_FRAME;
245
return GST_VAAPI_DECODER_STATUS_SUCCESS;
248
248
static inline GstVaapiDecoderStatus
249
do_decode(GstVaapiDecoder *decoder, GstVideoCodecFrame *base_frame)
249
do_decode (GstVaapiDecoder * decoder, GstVideoCodecFrame * base_frame)
251
GstVaapiParserState * const ps = &decoder->parser_state;
252
GstVaapiParserFrame * const frame = base_frame->user_data;
253
GstVaapiDecoderStatus status;
255
ps->current_frame = base_frame;
257
gst_vaapi_parser_frame_ref(frame);
258
status = do_decode_1(decoder, frame);
259
gst_vaapi_parser_frame_unref(frame);
261
switch ((guint)status) {
251
GstVaapiParserState *const ps = &decoder->parser_state;
252
GstVaapiParserFrame *const frame = base_frame->user_data;
253
GstVaapiDecoderStatus status;
255
ps->current_frame = base_frame;
257
gst_vaapi_parser_frame_ref (frame);
258
status = do_decode_1 (decoder, frame);
259
gst_vaapi_parser_frame_unref (frame);
261
switch ((guint) status) {
262
262
case GST_VAAPI_DECODER_STATUS_DROP_FRAME:
263
drop_frame(decoder, base_frame);
264
status = GST_VAAPI_DECODER_STATUS_SUCCESS;
263
drop_frame (decoder, base_frame);
264
status = GST_VAAPI_DECODER_STATUS_SUCCESS;
270
270
static inline GstVaapiDecoderStatus
271
do_flush(GstVaapiDecoder *decoder)
271
do_flush (GstVaapiDecoder * decoder)
273
GstVaapiDecoderClass * const klass = GST_VAAPI_DECODER_GET_CLASS(decoder);
273
GstVaapiDecoderClass *const klass = GST_VAAPI_DECODER_GET_CLASS (decoder);
276
return klass->flush(decoder);
277
return GST_VAAPI_DECODER_STATUS_SUCCESS;
276
return klass->flush (decoder);
277
return GST_VAAPI_DECODER_STATUS_SUCCESS;
280
280
static GstVaapiDecoderStatus
281
decode_step(GstVaapiDecoder *decoder)
281
decode_step (GstVaapiDecoder * decoder)
283
GstVaapiParserState * const ps = &decoder->parser_state;
284
GstVaapiDecoderStatus status;
287
guint got_unit_size, input_size;
289
status = gst_vaapi_decoder_check_status(decoder);
290
if (status != GST_VAAPI_DECODER_STATUS_SUCCESS)
293
/* Fill adapter with all buffers we have in the queue */
295
buffer = pop_buffer(decoder);
299
ps->at_eos = GST_BUFFER_IS_EOS(buffer);
301
gst_adapter_push(ps->input_adapter, buffer);
304
/* Parse and decode all decode units */
305
input_size = gst_adapter_available(ps->input_adapter);
306
if (input_size == 0) {
308
return GST_VAAPI_DECODER_STATUS_END_OF_STREAM;
309
return GST_VAAPI_DECODER_STATUS_ERROR_NO_DATA;
313
if (!ps->current_frame) {
314
ps->current_frame = g_slice_new0(GstVideoCodecFrame);
315
if (!ps->current_frame)
316
return GST_VAAPI_DECODER_STATUS_ERROR_ALLOCATION_FAILED;
317
ps->current_frame->ref_count = 1;
320
status = do_parse(decoder, ps->current_frame, ps->input_adapter,
321
ps->at_eos, &got_unit_size, &got_frame);
322
GST_DEBUG("parse frame (status = %d)", status);
323
if (status != GST_VAAPI_DECODER_STATUS_SUCCESS) {
324
if (status == GST_VAAPI_DECODER_STATUS_ERROR_NO_DATA && ps->at_eos)
325
status = GST_VAAPI_DECODER_STATUS_END_OF_STREAM;
329
if (got_unit_size > 0) {
330
buffer = gst_adapter_take_buffer(ps->input_adapter, got_unit_size);
331
input_size -= got_unit_size;
333
if (gst_adapter_available(ps->output_adapter) == 0) {
334
ps->current_frame->pts =
335
gst_adapter_prev_timestamp(ps->input_adapter, NULL);
337
gst_adapter_push(ps->output_adapter, buffer);
341
ps->current_frame->input_buffer = gst_adapter_take_buffer(
343
gst_adapter_available(ps->output_adapter));
345
status = do_decode(decoder, ps->current_frame);
346
GST_DEBUG("decode frame (status = %d)", status);
348
gst_video_codec_frame_unref(ps->current_frame);
349
ps->current_frame = NULL;
352
} while (input_size > 0);
283
GstVaapiParserState *const ps = &decoder->parser_state;
284
GstVaapiDecoderStatus status;
287
guint got_unit_size, input_size;
289
status = gst_vaapi_decoder_check_status (decoder);
290
if (status != GST_VAAPI_DECODER_STATUS_SUCCESS)
293
/* Fill adapter with all buffers we have in the queue */
295
buffer = pop_buffer (decoder);
299
ps->at_eos = GST_BUFFER_IS_EOS (buffer);
301
gst_adapter_push (ps->input_adapter, buffer);
304
/* Parse and decode all decode units */
305
input_size = gst_adapter_available (ps->input_adapter);
306
if (input_size == 0) {
308
return GST_VAAPI_DECODER_STATUS_END_OF_STREAM;
309
return GST_VAAPI_DECODER_STATUS_ERROR_NO_DATA;
313
if (!ps->current_frame) {
314
ps->current_frame = g_slice_new0 (GstVideoCodecFrame);
315
if (!ps->current_frame)
316
return GST_VAAPI_DECODER_STATUS_ERROR_ALLOCATION_FAILED;
317
ps->current_frame->ref_count = 1;
318
ps->current_frame->system_frame_number = ps->current_frame_number++;
321
status = do_parse (decoder, ps->current_frame, ps->input_adapter,
322
ps->at_eos, &got_unit_size, &got_frame);
323
GST_DEBUG ("parse frame (status = %d)", status);
324
if (status != GST_VAAPI_DECODER_STATUS_SUCCESS) {
325
if (status == GST_VAAPI_DECODER_STATUS_ERROR_NO_DATA && ps->at_eos)
326
status = GST_VAAPI_DECODER_STATUS_END_OF_STREAM;
330
if (got_unit_size > 0) {
331
buffer = gst_adapter_take_buffer (ps->input_adapter, got_unit_size);
332
input_size -= got_unit_size;
334
if (gst_adapter_available (ps->output_adapter) == 0) {
335
ps->current_frame->pts =
336
gst_adapter_prev_timestamp (ps->input_adapter, NULL);
338
gst_adapter_push (ps->output_adapter, buffer);
342
ps->current_frame->input_buffer =
343
gst_adapter_take_buffer (ps->output_adapter,
344
gst_adapter_available (ps->output_adapter));
346
status = do_decode (decoder, ps->current_frame);
347
GST_DEBUG ("decode frame (status = %d)", status);
349
gst_video_codec_frame_unref (ps->current_frame);
350
ps->current_frame = NULL;
353
} while (input_size > 0);
357
drop_frame(GstVaapiDecoder *decoder, GstVideoCodecFrame *frame)
358
drop_frame (GstVaapiDecoder * decoder, GstVideoCodecFrame * frame)
359
GST_DEBUG("drop frame %d", frame->system_frame_number);
361
/* no surface proxy */
362
gst_video_codec_frame_set_user_data(frame, NULL, NULL);
364
frame->pts = GST_CLOCK_TIME_NONE;
365
GST_VIDEO_CODEC_FRAME_FLAG_SET(frame,
366
GST_VIDEO_CODEC_FRAME_FLAG_DECODE_ONLY);
368
g_async_queue_push(decoder->frames, gst_video_codec_frame_ref(frame));
360
GST_DEBUG ("drop frame %d", frame->system_frame_number);
362
/* no surface proxy */
363
gst_video_codec_frame_set_user_data (frame, NULL, NULL);
365
frame->pts = GST_CLOCK_TIME_NONE;
366
GST_VIDEO_CODEC_FRAME_FLAG_SET (frame,
367
GST_VIDEO_CODEC_FRAME_FLAG_DECODE_ONLY);
369
g_async_queue_push (decoder->frames, gst_video_codec_frame_ref (frame));
371
372
static inline void
372
push_frame(GstVaapiDecoder *decoder, GstVideoCodecFrame *frame)
373
push_frame (GstVaapiDecoder * decoder, GstVideoCodecFrame * frame)
374
GstVaapiSurfaceProxy * const proxy = frame->user_data;
376
GST_DEBUG("queue decoded surface %" GST_VAAPI_ID_FORMAT,
377
GST_VAAPI_ID_ARGS(GST_VAAPI_SURFACE_PROXY_SURFACE_ID(proxy)));
379
g_async_queue_push(decoder->frames, gst_video_codec_frame_ref(frame));
375
GstVaapiSurfaceProxy *const proxy = frame->user_data;
377
GST_DEBUG ("push frame %d (surface 0x%08x)", frame->system_frame_number,
378
(guint32) GST_VAAPI_SURFACE_PROXY_SURFACE_ID (proxy));
380
g_async_queue_push (decoder->frames, gst_video_codec_frame_ref (frame));
382
383
static inline GstVideoCodecFrame *
383
pop_frame(GstVaapiDecoder *decoder, guint64 timeout)
384
pop_frame (GstVaapiDecoder * decoder, guint64 timeout)
385
GstVideoCodecFrame *frame;
386
GstVaapiSurfaceProxy *proxy;
388
if (G_LIKELY(timeout > 0))
389
frame = g_async_queue_timeout_pop(decoder->frames, timeout);
391
frame = g_async_queue_try_pop(decoder->frames);
395
proxy = frame->user_data;
396
GST_DEBUG("dequeue decoded surface %" GST_VAAPI_ID_FORMAT,
397
GST_VAAPI_ID_ARGS(GST_VAAPI_SURFACE_PROXY_SURFACE_ID(proxy)));
386
GstVideoCodecFrame *frame;
387
GstVaapiSurfaceProxy *proxy;
389
if (G_LIKELY (timeout > 0))
390
frame = g_async_queue_timeout_pop (decoder->frames, timeout);
392
frame = g_async_queue_try_pop (decoder->frames);
396
proxy = frame->user_data;
397
GST_DEBUG ("pop frame %d (surface 0x%08x)", frame->system_frame_number,
398
(proxy ? (guint32) GST_VAAPI_SURFACE_PROXY_SURFACE_ID (proxy) :
403
set_caps(GstVaapiDecoder *decoder, const GstCaps *caps)
405
set_caps (GstVaapiDecoder * decoder, const GstCaps * caps)
405
GstVideoCodecState * const codec_state = decoder->codec_state;
406
GstStructure * const structure = gst_caps_get_structure(caps, 0);
407
GstVaapiProfile profile;
408
const GValue *v_codec_data;
410
profile = gst_vaapi_profile_from_caps(caps);
414
decoder->codec = gst_vaapi_profile_get_codec(profile);
418
if (!gst_video_info_from_caps(&codec_state->info, caps))
421
codec_state->caps = gst_caps_copy(caps);
423
v_codec_data = gst_structure_get_value(structure, "codec_data");
425
gst_buffer_replace(&codec_state->codec_data,
426
gst_value_get_buffer(v_codec_data));
407
GstVideoCodecState *const codec_state = decoder->codec_state;
408
GstStructure *const structure = gst_caps_get_structure (caps, 0);
409
GstVaapiProfile profile;
410
const GValue *v_codec_data;
412
profile = gst_vaapi_profile_from_caps (caps);
416
decoder->codec = gst_vaapi_profile_get_codec (profile);
420
if (!gst_video_info_from_caps (&codec_state->info, caps))
423
codec_state->caps = gst_caps_copy (caps);
425
v_codec_data = gst_structure_get_value (structure, "codec_data");
427
gst_buffer_replace (&codec_state->codec_data,
428
gst_value_get_buffer (v_codec_data));
430
432
static inline GstCaps *
431
get_caps(GstVaapiDecoder *decoder)
433
get_caps (GstVaapiDecoder * decoder)
433
return GST_VAAPI_DECODER_CODEC_STATE(decoder)->caps;
435
return GST_VAAPI_DECODER_CODEC_STATE (decoder)->caps;
437
notify_codec_state_changed(GstVaapiDecoder *decoder)
439
notify_codec_state_changed (GstVaapiDecoder * decoder)
439
if (decoder->codec_state_changed_func)
440
decoder->codec_state_changed_func(decoder, decoder->codec_state,
441
decoder->codec_state_changed_data);
441
if (decoder->codec_state_changed_func)
442
decoder->codec_state_changed_func (decoder, decoder->codec_state,
443
decoder->codec_state_changed_data);
445
gst_vaapi_decoder_finalize(GstVaapiDecoder *decoder)
447
gst_vaapi_decoder_finalize (GstVaapiDecoder * decoder)
447
const GstVaapiDecoderClass * const klass =
448
GST_VAAPI_DECODER_GET_CLASS(decoder);
451
klass->destroy(decoder);
453
gst_video_codec_state_unref(decoder->codec_state);
454
decoder->codec_state = NULL;
456
parser_state_finalize(&decoder->parser_state);
458
if (decoder->buffers) {
459
g_async_queue_unref(decoder->buffers);
460
decoder->buffers = NULL;
463
if (decoder->frames) {
464
g_async_queue_unref(decoder->frames);
465
decoder->frames = NULL;
468
gst_vaapi_object_replace(&decoder->context, NULL);
469
decoder->va_context = VA_INVALID_ID;
471
gst_vaapi_display_replace(&decoder->display, NULL);
472
decoder->va_display = NULL;
449
const GstVaapiDecoderClass *const klass =
450
GST_VAAPI_DECODER_GET_CLASS (decoder);
453
klass->destroy (decoder);
455
gst_video_codec_state_unref (decoder->codec_state);
456
decoder->codec_state = NULL;
458
parser_state_finalize (&decoder->parser_state);
460
if (decoder->buffers) {
461
g_async_queue_unref (decoder->buffers);
462
decoder->buffers = NULL;
465
if (decoder->frames) {
466
g_async_queue_unref (decoder->frames);
467
decoder->frames = NULL;
470
gst_vaapi_object_replace (&decoder->context, NULL);
471
decoder->va_context = VA_INVALID_ID;
473
gst_vaapi_display_replace (&decoder->display, NULL);
474
decoder->va_display = NULL;
476
gst_vaapi_decoder_init(GstVaapiDecoder *decoder, GstVaapiDisplay *display,
478
gst_vaapi_decoder_init (GstVaapiDecoder * decoder, GstVaapiDisplay * display,
479
const GstVaapiDecoderClass * const klass =
480
GST_VAAPI_DECODER_GET_CLASS(decoder);
481
GstVideoCodecState *codec_state;
484
parser_state_init(&decoder->parser_state);
486
codec_state = g_slice_new0(GstVideoCodecState);
487
codec_state->ref_count = 1;
488
gst_video_info_init(&codec_state->info);
490
decoder->user_data = NULL;
491
decoder->display = gst_vaapi_display_ref(display);
492
decoder->va_display = GST_VAAPI_DISPLAY_VADISPLAY(display);
493
decoder->context = NULL;
494
decoder->va_context = VA_INVALID_ID;
496
decoder->codec_state = codec_state;
497
decoder->codec_state_changed_func = NULL;
498
decoder->codec_state_changed_data = NULL;
500
decoder->buffers = g_async_queue_new_full((GDestroyNotify)gst_buffer_unref);
501
decoder->frames = g_async_queue_new_full((GDestroyNotify)
502
gst_video_codec_frame_unref);
504
if (!set_caps(decoder, caps))
507
sub_size = GST_VAAPI_MINI_OBJECT_CLASS(klass)->size - sizeof(*decoder);
509
memset(((guchar *)decoder) + sizeof(*decoder), 0, sub_size);
511
if (klass->create && !klass->create(decoder))
481
const GstVaapiDecoderClass *const klass =
482
GST_VAAPI_DECODER_GET_CLASS (decoder);
483
GstVideoCodecState *codec_state;
486
parser_state_init (&decoder->parser_state);
488
codec_state = g_slice_new0 (GstVideoCodecState);
489
codec_state->ref_count = 1;
490
gst_video_info_init (&codec_state->info);
492
decoder->user_data = NULL;
493
decoder->display = gst_vaapi_display_ref (display);
494
decoder->va_display = GST_VAAPI_DISPLAY_VADISPLAY (display);
495
decoder->context = NULL;
496
decoder->va_context = VA_INVALID_ID;
498
decoder->codec_state = codec_state;
499
decoder->codec_state_changed_func = NULL;
500
decoder->codec_state_changed_data = NULL;
502
decoder->buffers = g_async_queue_new_full ((GDestroyNotify) gst_buffer_unref);
503
decoder->frames = g_async_queue_new_full ((GDestroyNotify)
504
gst_video_codec_frame_unref);
506
if (!set_caps (decoder, caps))
509
sub_size = GST_VAAPI_MINI_OBJECT_CLASS (klass)->size - sizeof (*decoder);
511
memset (((guchar *) decoder) + sizeof (*decoder), 0, sub_size);
513
if (klass->create && !klass->create (decoder))
516
518
GstVaapiDecoder *
517
gst_vaapi_decoder_new(const GstVaapiDecoderClass *klass,
518
GstVaapiDisplay *display, GstCaps *caps)
519
gst_vaapi_decoder_new (const GstVaapiDecoderClass * klass,
520
GstVaapiDisplay * display, GstCaps * caps)
520
GstVaapiDecoder *decoder;
522
g_return_val_if_fail(display != NULL, NULL);
523
g_return_val_if_fail(GST_IS_CAPS(caps), NULL);
525
decoder = (GstVaapiDecoder *)
526
gst_vaapi_mini_object_new(GST_VAAPI_MINI_OBJECT_CLASS(klass));
530
if (!gst_vaapi_decoder_init(decoder, display, caps))
522
GstVaapiDecoder *decoder;
524
g_return_val_if_fail (display != NULL, NULL);
525
g_return_val_if_fail (GST_IS_CAPS (caps), NULL);
527
decoder = (GstVaapiDecoder *)
528
gst_vaapi_mini_object_new (GST_VAAPI_MINI_OBJECT_CLASS (klass));
532
if (!gst_vaapi_decoder_init (decoder, display, caps))
535
gst_vaapi_decoder_unref(decoder);
537
gst_vaapi_decoder_unref (decoder);
800
802
* Return value: a #GstVaapiDecoderStatus
802
804
GstVaapiDecoderStatus
803
gst_vaapi_decoder_get_frame_with_timeout(GstVaapiDecoder *decoder,
804
GstVideoCodecFrame **out_frame_ptr, guint64 timeout)
805
gst_vaapi_decoder_get_frame_with_timeout (GstVaapiDecoder * decoder,
806
GstVideoCodecFrame ** out_frame_ptr, guint64 timeout)
806
GstVideoCodecFrame *out_frame;
808
g_return_val_if_fail(decoder != NULL,
809
GST_VAAPI_DECODER_STATUS_ERROR_INVALID_PARAMETER);
810
g_return_val_if_fail(out_frame_ptr != NULL,
811
GST_VAAPI_DECODER_STATUS_ERROR_INVALID_PARAMETER);
813
out_frame = pop_frame(decoder, timeout);
815
return GST_VAAPI_DECODER_STATUS_ERROR_NO_DATA;
808
GstVideoCodecFrame *out_frame;
810
g_return_val_if_fail (decoder != NULL,
811
GST_VAAPI_DECODER_STATUS_ERROR_INVALID_PARAMETER);
812
g_return_val_if_fail (out_frame_ptr != NULL,
813
GST_VAAPI_DECODER_STATUS_ERROR_INVALID_PARAMETER);
815
out_frame = pop_frame (decoder, timeout);
817
return GST_VAAPI_DECODER_STATUS_ERROR_NO_DATA;
817
819
#if !GST_CHECK_VERSION(1,0,0)
818
if (!GST_VIDEO_CODEC_FRAME_IS_DECODE_ONLY(out_frame)) {
819
const guint flags = GST_VAAPI_SURFACE_PROXY_FLAGS(out_frame->user_data);
820
if (!GST_VIDEO_CODEC_FRAME_IS_DECODE_ONLY (out_frame)) {
821
const guint flags = GST_VAAPI_SURFACE_PROXY_FLAGS (out_frame->user_data);
822
if (flags & GST_VAAPI_SURFACE_PROXY_FLAG_TFF)
823
out_flags |= GST_VIDEO_CODEC_FRAME_FLAG_TFF;
824
if (flags & GST_VAAPI_SURFACE_PROXY_FLAG_RFF)
825
out_flags |= GST_VIDEO_CODEC_FRAME_FLAG_RFF;
826
if (flags & GST_VAAPI_SURFACE_PROXY_FLAG_ONEFIELD)
827
out_flags |= GST_VIDEO_CODEC_FRAME_FLAG_ONEFIELD;
828
GST_VIDEO_CODEC_FRAME_FLAG_SET(out_frame, out_flags);
824
if (flags & GST_VAAPI_SURFACE_PROXY_FLAG_TFF)
825
out_flags |= GST_VIDEO_CODEC_FRAME_FLAG_TFF;
826
if (flags & GST_VAAPI_SURFACE_PROXY_FLAG_RFF)
827
out_flags |= GST_VIDEO_CODEC_FRAME_FLAG_RFF;
828
if (flags & GST_VAAPI_SURFACE_PROXY_FLAG_ONEFIELD)
829
out_flags |= GST_VIDEO_CODEC_FRAME_FLAG_ONEFIELD;
830
GST_VIDEO_CODEC_FRAME_FLAG_SET (out_frame, out_flags);
832
*out_frame_ptr = out_frame;
833
return GST_VAAPI_DECODER_STATUS_SUCCESS;
837
gst_vaapi_decoder_set_picture_size(
838
GstVaapiDecoder *decoder,
843
GstVideoCodecState * const codec_state = decoder->codec_state;
844
gboolean size_changed = FALSE;
846
if (codec_state->info.width != width) {
847
GST_DEBUG("picture width changed to %d", width);
848
codec_state->info.width = width;
849
gst_caps_set_simple(codec_state->caps,
850
"width", G_TYPE_INT, width, NULL);
854
if (codec_state->info.height != height) {
855
GST_DEBUG("picture height changed to %d", height);
856
codec_state->info.height = height;
857
gst_caps_set_simple(codec_state->caps,
858
"height", G_TYPE_INT, height, NULL);
863
notify_codec_state_changed(decoder);
867
gst_vaapi_decoder_set_framerate(
868
GstVaapiDecoder *decoder,
873
GstVideoCodecState * const codec_state = decoder->codec_state;
875
if (!fps_n || !fps_d)
878
if (codec_state->info.fps_n != fps_n || codec_state->info.fps_d != fps_d) {
879
GST_DEBUG("framerate changed to %u/%u", fps_n, fps_d);
880
codec_state->info.fps_n = fps_n;
881
codec_state->info.fps_d = fps_d;
882
gst_caps_set_simple(codec_state->caps,
883
"framerate", GST_TYPE_FRACTION, fps_n, fps_d, NULL);
884
notify_codec_state_changed(decoder);
889
gst_vaapi_decoder_set_pixel_aspect_ratio(
890
GstVaapiDecoder *decoder,
895
GstVideoCodecState * const codec_state = decoder->codec_state;
897
if (!par_n || !par_d)
900
if (codec_state->info.par_n != par_n || codec_state->info.par_d != par_d) {
901
GST_DEBUG("pixel-aspect-ratio changed to %u/%u", par_n, par_d);
902
codec_state->info.par_n = par_n;
903
codec_state->info.par_d = par_d;
904
gst_caps_set_simple(codec_state->caps,
905
"pixel-aspect-ratio", GST_TYPE_FRACTION, par_n, par_d, NULL);
906
notify_codec_state_changed(decoder);
834
*out_frame_ptr = out_frame;
835
return GST_VAAPI_DECODER_STATUS_SUCCESS;
839
gst_vaapi_decoder_set_picture_size (GstVaapiDecoder * decoder,
840
guint width, guint height)
842
GstVideoCodecState *const codec_state = decoder->codec_state;
843
gboolean size_changed = FALSE;
845
if (codec_state->info.width != width) {
846
GST_DEBUG ("picture width changed to %d", width);
847
codec_state->info.width = width;
848
gst_caps_set_simple (codec_state->caps, "width", G_TYPE_INT, width, NULL);
852
if (codec_state->info.height != height) {
853
GST_DEBUG ("picture height changed to %d", height);
854
codec_state->info.height = height;
855
gst_caps_set_simple (codec_state->caps, "height", G_TYPE_INT, height, NULL);
860
notify_codec_state_changed (decoder);
864
gst_vaapi_decoder_set_framerate (GstVaapiDecoder * decoder,
865
guint fps_n, guint fps_d)
867
GstVideoCodecState *const codec_state = decoder->codec_state;
869
if (!fps_n || !fps_d)
872
if (codec_state->info.fps_n != fps_n || codec_state->info.fps_d != fps_d) {
873
GST_DEBUG ("framerate changed to %u/%u", fps_n, fps_d);
874
codec_state->info.fps_n = fps_n;
875
codec_state->info.fps_d = fps_d;
876
gst_caps_set_simple (codec_state->caps,
877
"framerate", GST_TYPE_FRACTION, fps_n, fps_d, NULL);
878
notify_codec_state_changed (decoder);
883
gst_vaapi_decoder_set_pixel_aspect_ratio (GstVaapiDecoder * decoder,
884
guint par_n, guint par_d)
886
GstVideoCodecState *const codec_state = decoder->codec_state;
888
if (!par_n || !par_d)
891
if (codec_state->info.par_n != par_n || codec_state->info.par_d != par_d) {
892
GST_DEBUG ("pixel-aspect-ratio changed to %u/%u", par_n, par_d);
893
codec_state->info.par_n = par_n;
894
codec_state->info.par_d = par_d;
895
gst_caps_set_simple (codec_state->caps,
896
"pixel-aspect-ratio", GST_TYPE_FRACTION, par_n, par_d, NULL);
897
notify_codec_state_changed (decoder);
910
901
static const gchar *
911
gst_interlace_mode_to_string(GstVideoInterlaceMode mode)
902
gst_interlace_mode_to_string (GstVideoInterlaceMode mode)
914
case GST_VIDEO_INTERLACE_MODE_PROGRESSIVE: return "progressive";
915
case GST_VIDEO_INTERLACE_MODE_INTERLEAVED: return "interleaved";
916
case GST_VIDEO_INTERLACE_MODE_MIXED: return "mixed";
905
case GST_VIDEO_INTERLACE_MODE_PROGRESSIVE:
906
return "progressive";
907
case GST_VIDEO_INTERLACE_MODE_INTERLEAVED:
908
return "interleaved";
909
case GST_VIDEO_INTERLACE_MODE_MIXED:
922
gst_vaapi_decoder_set_interlace_mode(GstVaapiDecoder *decoder,
916
gst_vaapi_decoder_set_interlace_mode (GstVaapiDecoder * decoder,
923
917
GstVideoInterlaceMode mode)
925
GstVideoCodecState * const codec_state = decoder->codec_state;
919
GstVideoCodecState *const codec_state = decoder->codec_state;
927
if (codec_state->info.interlace_mode != mode) {
928
GST_DEBUG("interlace mode changed to %s",
929
gst_interlace_mode_to_string(mode));
930
codec_state->info.interlace_mode = mode;
931
gst_caps_set_simple(codec_state->caps, "interlaced",
932
G_TYPE_BOOLEAN, mode != GST_VIDEO_INTERLACE_MODE_PROGRESSIVE, NULL);
933
notify_codec_state_changed(decoder);
921
if (codec_state->info.interlace_mode != mode) {
922
GST_DEBUG ("interlace mode changed to %s",
923
gst_interlace_mode_to_string (mode));
924
codec_state->info.interlace_mode = mode;
925
gst_caps_set_simple (codec_state->caps, "interlaced",
926
G_TYPE_BOOLEAN, mode != GST_VIDEO_INTERLACE_MODE_PROGRESSIVE, NULL);
927
notify_codec_state_changed (decoder);
938
gst_vaapi_decoder_set_interlaced(GstVaapiDecoder *decoder, gboolean interlaced)
932
gst_vaapi_decoder_set_interlaced (GstVaapiDecoder * decoder,
940
gst_vaapi_decoder_set_interlace_mode(decoder,
942
GST_VIDEO_INTERLACE_MODE_INTERLEAVED :
943
GST_VIDEO_INTERLACE_MODE_PROGRESSIVE));
935
gst_vaapi_decoder_set_interlace_mode (decoder,
937
GST_VIDEO_INTERLACE_MODE_INTERLEAVED :
938
GST_VIDEO_INTERLACE_MODE_PROGRESSIVE));
947
gst_vaapi_decoder_ensure_context(
948
GstVaapiDecoder *decoder,
949
GstVaapiContextInfo *cip
942
gst_vaapi_decoder_ensure_context (GstVaapiDecoder * decoder,
943
GstVaapiContextInfo * cip)
952
gst_vaapi_decoder_set_picture_size(decoder, cip->width, cip->height);
945
gst_vaapi_decoder_set_picture_size (decoder, cip->width, cip->height);
954
if (decoder->context) {
955
if (!gst_vaapi_context_reset_full(decoder->context, cip))
959
decoder->context = gst_vaapi_context_new_full(decoder->display, cip);
960
if (!decoder->context)
963
decoder->va_context = gst_vaapi_context_get_id(decoder->context);
947
cip->usage = GST_VAAPI_CONTEXT_USAGE_DECODE;
948
if (decoder->context) {
949
if (!gst_vaapi_context_reset (decoder->context, cip))
952
decoder->context = gst_vaapi_context_new (decoder->display, cip);
953
if (!decoder->context)
956
decoder->va_context = gst_vaapi_context_get_id (decoder->context);
968
gst_vaapi_decoder_push_frame(GstVaapiDecoder *decoder,
969
GstVideoCodecFrame *frame)
971
push_frame(decoder, frame);
974
GstVaapiDecoderStatus
975
gst_vaapi_decoder_check_status(GstVaapiDecoder *decoder)
977
if (decoder->context &&
978
gst_vaapi_context_get_surface_count(decoder->context) < 1)
979
return GST_VAAPI_DECODER_STATUS_ERROR_NO_SURFACE;
980
return GST_VAAPI_DECODER_STATUS_SUCCESS;
983
GstVaapiDecoderStatus
984
gst_vaapi_decoder_parse(GstVaapiDecoder *decoder,
985
GstVideoCodecFrame *base_frame, GstAdapter *adapter, gboolean at_eos,
986
guint *got_unit_size_ptr, gboolean *got_frame_ptr)
988
g_return_val_if_fail(decoder != NULL,
989
GST_VAAPI_DECODER_STATUS_ERROR_INVALID_PARAMETER);
990
g_return_val_if_fail(base_frame != NULL,
991
GST_VAAPI_DECODER_STATUS_ERROR_INVALID_PARAMETER);
992
g_return_val_if_fail(adapter != NULL,
993
GST_VAAPI_DECODER_STATUS_ERROR_INVALID_PARAMETER);
994
g_return_val_if_fail(got_unit_size_ptr != NULL,
995
GST_VAAPI_DECODER_STATUS_ERROR_INVALID_PARAMETER);
996
g_return_val_if_fail(got_frame_ptr != NULL,
997
GST_VAAPI_DECODER_STATUS_ERROR_INVALID_PARAMETER);
999
return do_parse(decoder, base_frame, adapter, at_eos,
1000
got_unit_size_ptr, got_frame_ptr);
1003
GstVaapiDecoderStatus
1004
gst_vaapi_decoder_decode(GstVaapiDecoder *decoder, GstVideoCodecFrame *frame)
1006
GstVaapiDecoderStatus status;
1008
g_return_val_if_fail(decoder != NULL,
1009
GST_VAAPI_DECODER_STATUS_ERROR_INVALID_PARAMETER);
1010
g_return_val_if_fail(frame != NULL,
1011
GST_VAAPI_DECODER_STATUS_ERROR_INVALID_PARAMETER);
1012
g_return_val_if_fail(frame->user_data != NULL,
1013
GST_VAAPI_DECODER_STATUS_ERROR_INVALID_PARAMETER);
1015
status = gst_vaapi_decoder_check_status(decoder);
1016
if (status != GST_VAAPI_DECODER_STATUS_SUCCESS)
1018
return do_decode(decoder, frame);
1021
GstVaapiDecoderStatus
1022
gst_vaapi_decoder_flush(GstVaapiDecoder *decoder)
1024
g_return_val_if_fail(decoder != NULL,
1025
GST_VAAPI_DECODER_STATUS_ERROR_INVALID_PARAMETER);
1027
return do_flush(decoder);
1030
GstVaapiDecoderStatus
1031
gst_vaapi_decoder_decode_codec_data(GstVaapiDecoder *decoder)
1033
GstVaapiDecoderClass * const klass = GST_VAAPI_DECODER_GET_CLASS(decoder);
1034
GstBuffer * const codec_data = GST_VAAPI_DECODER_CODEC_DATA(decoder);
1035
GstVaapiDecoderStatus status;
1036
GstMapInfo map_info;
1041
return GST_VAAPI_DECODER_STATUS_SUCCESS;
1043
/* FIXME: add a meaningful error code? */
1044
if (!klass->decode_codec_data)
1045
return GST_VAAPI_DECODER_STATUS_SUCCESS;
1047
if (!gst_buffer_map(codec_data, &map_info, GST_MAP_READ)) {
1048
GST_ERROR("failed to map buffer");
1049
return GST_VAAPI_DECODER_STATUS_ERROR_UNKNOWN;
1052
buf = map_info.data;
1053
buf_size = map_info.size;
1054
if (G_LIKELY(buf && buf_size > 0))
1055
status = klass->decode_codec_data(decoder, buf, buf_size);
1057
status = GST_VAAPI_DECODER_STATUS_SUCCESS;
1058
gst_buffer_unmap(codec_data, &map_info);
961
gst_vaapi_decoder_push_frame (GstVaapiDecoder * decoder,
962
GstVideoCodecFrame * frame)
964
push_frame (decoder, frame);
967
GstVaapiDecoderStatus
968
gst_vaapi_decoder_check_status (GstVaapiDecoder * decoder)
970
if (decoder->context &&
971
gst_vaapi_context_get_surface_count (decoder->context) < 1)
972
return GST_VAAPI_DECODER_STATUS_ERROR_NO_SURFACE;
973
return GST_VAAPI_DECODER_STATUS_SUCCESS;
976
GstVaapiDecoderStatus
977
gst_vaapi_decoder_parse (GstVaapiDecoder * decoder,
978
GstVideoCodecFrame * base_frame, GstAdapter * adapter, gboolean at_eos,
979
guint * got_unit_size_ptr, gboolean * got_frame_ptr)
981
g_return_val_if_fail (decoder != NULL,
982
GST_VAAPI_DECODER_STATUS_ERROR_INVALID_PARAMETER);
983
g_return_val_if_fail (base_frame != NULL,
984
GST_VAAPI_DECODER_STATUS_ERROR_INVALID_PARAMETER);
985
g_return_val_if_fail (adapter != NULL,
986
GST_VAAPI_DECODER_STATUS_ERROR_INVALID_PARAMETER);
987
g_return_val_if_fail (got_unit_size_ptr != NULL,
988
GST_VAAPI_DECODER_STATUS_ERROR_INVALID_PARAMETER);
989
g_return_val_if_fail (got_frame_ptr != NULL,
990
GST_VAAPI_DECODER_STATUS_ERROR_INVALID_PARAMETER);
992
return do_parse (decoder, base_frame, adapter, at_eos,
993
got_unit_size_ptr, got_frame_ptr);
996
GstVaapiDecoderStatus
997
gst_vaapi_decoder_decode (GstVaapiDecoder * decoder, GstVideoCodecFrame * frame)
999
GstVaapiDecoderStatus status;
1001
g_return_val_if_fail (decoder != NULL,
1002
GST_VAAPI_DECODER_STATUS_ERROR_INVALID_PARAMETER);
1003
g_return_val_if_fail (frame != NULL,
1004
GST_VAAPI_DECODER_STATUS_ERROR_INVALID_PARAMETER);
1005
g_return_val_if_fail (frame->user_data != NULL,
1006
GST_VAAPI_DECODER_STATUS_ERROR_INVALID_PARAMETER);
1008
status = gst_vaapi_decoder_check_status (decoder);
1009
if (status != GST_VAAPI_DECODER_STATUS_SUCCESS)
1011
return do_decode (decoder, frame);
1014
GstVaapiDecoderStatus
1015
gst_vaapi_decoder_flush (GstVaapiDecoder * decoder)
1017
g_return_val_if_fail (decoder != NULL,
1018
GST_VAAPI_DECODER_STATUS_ERROR_INVALID_PARAMETER);
1020
return do_flush (decoder);
1023
GstVaapiDecoderStatus
1024
gst_vaapi_decoder_decode_codec_data (GstVaapiDecoder * decoder)
1026
GstVaapiDecoderClass *const klass = GST_VAAPI_DECODER_GET_CLASS (decoder);
1027
GstBuffer *const codec_data = GST_VAAPI_DECODER_CODEC_DATA (decoder);
1028
GstVaapiDecoderStatus status;
1029
GstMapInfo map_info;
1034
return GST_VAAPI_DECODER_STATUS_SUCCESS;
1036
/* FIXME: add a meaningful error code? */
1037
if (!klass->decode_codec_data)
1038
return GST_VAAPI_DECODER_STATUS_SUCCESS;
1040
if (!gst_buffer_map (codec_data, &map_info, GST_MAP_READ)) {
1041
GST_ERROR ("failed to map buffer");
1042
return GST_VAAPI_DECODER_STATUS_ERROR_UNKNOWN;
1045
buf = map_info.data;
1046
buf_size = map_info.size;
1047
if (G_LIKELY (buf && buf_size > 0))
1048
status = klass->decode_codec_data (decoder, buf, buf_size);
1050
status = GST_VAAPI_DECODER_STATUS_SUCCESS;
1051
gst_buffer_unmap (codec_data, &map_info);