decoder: fix check for end-of-stream in raw API mode.
authorGwenole Beauchesne <gwenole.beauchesne@intel.com>
Tue, 15 Jan 2013 16:21:50 +0000 (17:21 +0100)
committerGwenole Beauchesne <gwenole.beauchesne@intel.com>
Thu, 17 Jan 2013 17:39:22 +0000 (18:39 +0100)
Make sure to immediately return GST_VAAPI_DECODER_STATUS_END_OF_STREAM
if the end-of-stream was already reached at the previous iteration.

gst-libs/gst/vaapi/gstvaapidecoder.c
gst-libs/gst/vaapi/gstvaapidecoder_priv.h

index 4cb18fc0b2a68613a9bd8910ceed4c2436ceb3dd..5abdfc5fd56f063359b2b5616d523c44b9638d34 100644 (file)
@@ -264,9 +264,12 @@ decode_step(GstVaapiDecoder *decoder)
     GstVaapiParserState * const ps = &priv->parser_state;
     GstVaapiDecoderStatus status;
     GstBuffer *buffer;
-    gboolean got_frame, at_eos = FALSE;
+    gboolean got_frame;
     guint got_unit_size;
 
+    if (G_UNLIKELY(ps->at_eos))
+        return GST_VAAPI_DECODER_STATUS_END_OF_STREAM;
+
     status = gst_vaapi_decoder_check_status(decoder);
     if (status != GST_VAAPI_DECODER_STATUS_SUCCESS)
         return status;
@@ -279,8 +282,8 @@ decode_step(GstVaapiDecoder *decoder)
         if (!buffer)
             return GST_VAAPI_DECODER_STATUS_ERROR_NO_DATA;
 
-        at_eos = GST_BUFFER_IS_EOS(buffer);
-        if (!at_eos)
+        ps->at_eos = GST_BUFFER_IS_EOS(buffer);
+        if (!ps->at_eos)
             gst_adapter_push(ps->input_adapter, buffer);
 
         do {
@@ -293,7 +296,7 @@ decode_step(GstVaapiDecoder *decoder)
 
         parse:
             status = do_parse(decoder, ps->current_frame,
-                ps->input_adapter, at_eos, &got_unit_size, &got_frame);
+                ps->input_adapter, ps->at_eos, &got_unit_size, &got_frame);
             GST_DEBUG("parse frame (status = %d)", status);
             if (status != GST_VAAPI_DECODER_STATUS_SUCCESS)
                 break;
index 968f49a46f4d66bd0f41f9cd1c6bab873fbea0d5..1887ee4cbd3527cedc3719a46fb5a868c4243875 100644 (file)
@@ -153,7 +153,8 @@ struct _GstVaapiParserState {
     gint                input_offset2;
     GstAdapter         *output_adapter;
     GstVaapiDecoderUnit next_unit;
-    gboolean            next_unit_pending;
+    guint               next_unit_pending       : 1;
+    guint               at_eos                  : 1;
 };
 
 struct _GstVaapiDecoderPrivate {