From cc347cb41e0b79406acb0d70a91768fc5b402d77 Mon Sep 17 00:00:00 2001 From: Gwenole Beauchesne Date: Tue, 15 Jan 2013 16:55:29 +0100 Subject: [PATCH] decoder: make decode_step() return once the frame is decoded. Make sure we always have a free surface left to use for decoding the current frame. This means that decode_step() has to return once a frame gets decoded. If the current adapter contains more buffers with valid frames, they will get parsed and decoded on subsequent iterations. --- gst-libs/gst/vaapi/gstvaapidecoder.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/gst-libs/gst/vaapi/gstvaapidecoder.c b/gst-libs/gst/vaapi/gstvaapidecoder.c index 966d3ea784..4cb18fc0b2 100644 --- a/gst-libs/gst/vaapi/gstvaapidecoder.c +++ b/gst-libs/gst/vaapi/gstvaapidecoder.c @@ -264,13 +264,16 @@ decode_step(GstVaapiDecoder *decoder) GstVaapiParserState * const ps = &priv->parser_state; GstVaapiDecoderStatus status; GstBuffer *buffer; - gboolean at_eos, got_frame; + gboolean got_frame, at_eos = FALSE; guint got_unit_size; status = gst_vaapi_decoder_check_status(decoder); if (status != GST_VAAPI_DECODER_STATUS_SUCCESS) return status; + if (ps->current_frame) + goto parse; + do { buffer = pop_buffer(decoder); if (!buffer) @@ -288,6 +291,7 @@ decode_step(GstVaapiDecoder *decoder) ps->current_frame->ref_count = 1; } + parse: status = do_parse(decoder, ps->current_frame, ps->input_adapter, at_eos, &got_unit_size, &got_frame); GST_DEBUG("parse frame (status = %d)", status); @@ -314,6 +318,7 @@ decode_step(GstVaapiDecoder *decoder) gst_video_codec_frame_unref(ps->current_frame); ps->current_frame = NULL; + break; } } while (status == GST_VAAPI_DECODER_STATUS_SUCCESS && gst_adapter_available(ps->input_adapter) > 0); @@ -634,13 +639,12 @@ gst_vaapi_decoder_get_surface(GstVaapiDecoder *decoder, g_return_val_if_fail(out_proxy_ptr != NULL, GST_VAAPI_DECODER_STATUS_ERROR_INVALID_PARAMETER); - frame = pop_frame(decoder); - if (!frame) { - do { - status = decode_step(decoder); - } while (status == GST_VAAPI_DECODER_STATUS_SUCCESS); + do { frame = pop_frame(decoder); - } + if (frame) + break; + status = decode_step(decoder); + } while (status == GST_VAAPI_DECODER_STATUS_SUCCESS); if (frame) { *out_proxy_ptr = gst_vaapi_surface_proxy_ref(frame->user_data);