h264: clear buffers on GST_EVENT_FLUSH_STOP
authorWind Yuan <feng.yuan@intel.com>
Fri, 30 Nov 2012 05:09:40 +0000 (13:09 +0800)
committerzhongcong <congx.zhong@intel.com>
Thu, 28 Feb 2013 08:18:03 +0000 (16:18 +0800)
Change-Id: I4a9978a50bc6f6011f3ca037b9b9e8b295369b86

gst-libs/gst/vaapi/gstvaapidecoder_h264.c

index 78b093d..1d8dea3 100755 (executable)
@@ -26,6 +26,7 @@
 
 #include "sysdeps.h"
 #include <string.h>
+#include <stdlib.h>
 #include <gst/base/gstadapter.h>
 #include <gst/codecparsers/gsth264parser.h>
 #include "gstvaapidecoder_h264.h"
@@ -862,21 +863,33 @@ get_status(GstH264ParserResult result)
 }
 
 static void
-gst_vaapi_decoder_h264_close(GstVaapiDecoderH264 *decoder)
+gst_vaapi_decoder_h264_clear_buffer(GstVaapiDecoder *base)
 {
+    GstVaapiDecoderH264 * const decoder = GST_VAAPI_DECODER_H264(base);
     GstVaapiDecoderH264Private * const priv = decoder->priv;
 
     gst_vaapi_picture_replace(&priv->current_picture, NULL);
 
     dpb_clear(decoder);
 
+    if (priv->adapter) {
+        gst_adapter_clear(priv->adapter);
+    }
+}
+
+static void
+gst_vaapi_decoder_h264_close(GstVaapiDecoderH264 *decoder)
+{
+    GstVaapiDecoderH264Private * const priv = decoder->priv;
+
+    gst_vaapi_decoder_h264_clear_buffer(GST_VAAPI_DECODER_CAST(decoder));
+
     if (priv->parser) {
         gst_h264_nal_parser_free(priv->parser);
         priv->parser = NULL;
     }
 
     if (priv->adapter) {
-        gst_adapter_clear(priv->adapter);
         g_object_unref(priv->adapter);
         priv->adapter = NULL;
     }
@@ -3210,6 +3223,7 @@ gst_vaapi_decoder_h264_class_init(GstVaapiDecoderH264Class *klass)
     object_class->constructed   = gst_vaapi_decoder_h264_constructed;
 
     decoder_class->decode       = gst_vaapi_decoder_h264_decode;
+    decoder_class->clear_buffer = gst_vaapi_decoder_h264_clear_buffer;
 }
 
 static void