vaapidecode: submit the last frame from output adapter to decoder.
authorGuangxin.Xu <Guangxin.Xu@intel.com>
Tue, 30 Jul 2013 06:05:39 +0000 (14:05 +0800)
committerGwenole Beauchesne <gwenole.beauchesne@intel.com>
Thu, 29 Aug 2013 12:47:40 +0000 (14:47 +0200)
If there is no frame delimiter at the end of the stream, e.g. no
end-of-stream or end-of-sequence marker, and that the current frame
was fully parsed correctly, then assume that last frame is complete
and submit it to the decoder.

https://bugzilla.gnome.org/show_bug.cgi?id=705123

Signed-off-by: Guangxin.Xu <Guangxin.Xu@intel.com>
Signed-off-by: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
gst/vaapi/gstvaapidecode.c
gst/vaapi/gstvaapidecode.h

index 29aa4eb..a016b71 100644 (file)
@@ -434,6 +434,11 @@ gst_vaapidecode_finish(GstVideoDecoder *vdec)
     GstVaapiDecode * const decode = GST_VAAPIDECODE(vdec);
     GstVaapiDecoderStatus status;
 
+    /* If there is something in GstVideoDecoder's output adapter, then
+       submit the frame for decoding */
+    if (decode->current_frame_size)
+        gst_video_decoder_have_frame(vdec);
+
     status = gst_vaapi_decoder_flush(decode->decoder);
     if (status != GST_VAAPI_DECODER_STATUS_SUCCESS)
         goto error_flush;
@@ -617,6 +622,9 @@ gst_vaapidecode_reset_full(GstVaapiDecode *decode, GstCaps *caps, gboolean hard)
             return TRUE;
     }
 
+    /* Reset tracked frame size */
+    decode->current_frame_size = 0;
+
     gst_vaapidecode_destroy(decode);
     return gst_vaapidecode_create(decode, caps);
 }
@@ -705,10 +713,14 @@ gst_vaapidecode_parse(GstVideoDecoder *vdec,
 
     switch (status) {
     case GST_VAAPI_DECODER_STATUS_SUCCESS:
-        if (got_unit_size > 0)
+        if (got_unit_size > 0) {
             gst_video_decoder_add_to_frame(vdec, got_unit_size);
-        if (got_frame)
+            decode->current_frame_size += got_unit_size;
+        }
+        if (got_frame) {
             ret = gst_video_decoder_have_frame(vdec);
+            decode->current_frame_size = 0;
+        }
         else
             ret = GST_FLOW_OK;
         break;
@@ -720,10 +732,12 @@ gst_vaapidecode_parse(GstVideoDecoder *vdec,
     case GST_VAAPI_DECODER_STATUS_ERROR_UNSUPPORTED_CHROMA_FORMAT:
         GST_WARNING("parse error %d", status);
         ret = GST_FLOW_NOT_SUPPORTED;
+        decode->current_frame_size = 0;
         break;
     default:
         GST_ERROR("parse error %d", status);
         ret = GST_FLOW_EOS;
+        decode->current_frame_size = 0;
         break;
     }
     return ret;
index 7b0dc61..23991cf 100644 (file)
@@ -78,6 +78,7 @@ struct _GstVaapiDecode {
     GstCaps            *allowed_caps;
     gint64              render_time_base;
     GstClockTime        last_buffer_time;
+    guint               current_frame_size;
 };
 
 struct _GstVaapiDecodeClass {