vaapidecode: Tell the base class about released frames on close
authorOlivier Crete <olivier.crete@collabora.com>
Thu, 16 Apr 2015 16:53:18 +0000 (12:53 -0400)
committerVíctor Manuel Jáquez Leal <vjaquez@igalia.com>
Mon, 20 Apr 2015 10:50:09 +0000 (12:50 +0200)
The base class needs to be informed about frames that were still queued
in the decoder on release, otherwise they are leaked.

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

gst-libs/gst/vaapi/gstvaapidecoder_mpeg2.c
gst/vaapi/gstvaapidecode.c

index 1bb2a22..c186641 100644 (file)
@@ -774,7 +774,8 @@ decode_sequence_end(GstVaapiDecoderMpeg2 *decoder)
 {
     GstVaapiDecoderMpeg2Private * const priv = &decoder->priv;
 
-    gst_vaapi_dpb_flush(priv->dpb);
+    if (priv->dpb)
+        gst_vaapi_dpb_flush(priv->dpb);
     return GST_VAAPI_DECODER_STATUS_SUCCESS;
 }
 
index 276a050..27593ae 100644 (file)
@@ -633,6 +633,19 @@ gst_vaapidecode_create (GstVaapiDecode * decode, GstCaps * caps)
 static void
 gst_vaapidecode_destroy (GstVaapiDecode * decode)
 {
+  GstVideoCodecFrame *out_frame = NULL;
+
+  if (decode->decoder) {
+    gst_vaapi_decoder_flush (decode->decoder);
+
+    /* Purge all decoded frames as we don't need them (e.g. seek) */
+    while (gst_vaapi_decoder_get_frame_with_timeout (decode->decoder,
+            &out_frame, 0) == GST_VAAPI_DECODER_STATUS_SUCCESS) {
+      gst_video_decoder_release_frame (GST_VIDEO_DECODER (decode), out_frame);
+      gst_video_codec_frame_unref (out_frame);
+      out_frame = NULL;
+    }
+  }
   gst_vaapi_decoder_replace (&decode->decoder, NULL);
   gst_caps_replace (&decode->decoder_caps, NULL);
 
@@ -652,24 +665,7 @@ gst_vaapidecode_reset_full (GstVaapiDecode * decode, GstCaps * caps,
   /* Reset tracked frame size */
   decode->current_frame_size = 0;
 
-  /* Reset timers if hard reset was requested (e.g. seek) */
-  if (hard) {
-    GstVideoDecoder *const vdec = GST_VIDEO_DECODER (decode);
-    GstVideoCodecFrame *out_frame = NULL;
-
-    gst_vaapi_decoder_flush (decode->decoder);
-
-    /* Purge all decoded frames as we don't need them (e.g. seek) */
-    while (gst_vaapi_decoder_get_frame_with_timeout (decode->decoder,
-            &out_frame, 0) == GST_VAAPI_DECODER_STATUS_SUCCESS) {
-      gst_video_decoder_drop_frame (vdec, out_frame);
-      gst_video_codec_frame_unref (out_frame);
-      out_frame = NULL;
-    }
-  }
-
-  /* Only reset decoder if codec type changed */
-  else if (decode->decoder && decode->decoder_caps) {
+  if (!hard && decode->decoder && decode->decoder_caps) {
     if (gst_caps_is_always_compatible (caps, decode->decoder_caps))
       return TRUE;
     codec = gst_vaapi_codec_from_caps (caps);