vaapisink: retain VA surface until another one is displayed.
authorGwenole Beauchesne <gwenole.beauchesne@intel.com>
Fri, 24 Aug 2012 13:30:33 +0000 (16:30 +0300)
committerGwenole Beauchesne <gwenole.beauchesne@intel.com>
Wed, 29 Aug 2012 10:05:00 +0000 (12:05 +0200)
Keep VA surface proxy associated with the surface that is currently
being displayed. This makes sure that surface is not released back
to the pool of surfaces free to use for decoding. This is necessary
with VA driver implementations that support rendering to an overlay
pipe. Otherwise, there could be cases where we are decoding into a
surface that is being displayed, hence some flickering.

gst/vaapi/gstvaapisink.c
gst/vaapi/gstvaapisink.h

index 4611974f9dbb9680c3c77bd216356c479694ff8a..cacf087b561b222c93eb63e76f4e6e6f07ba20d9 100644 (file)
@@ -223,6 +223,7 @@ gst_vaapisink_xoverlay_iface_init(GstXOverlayClass *iface)
 static void
 gst_vaapisink_destroy(GstVaapiSink *sink)
 {
+    gst_buffer_replace(&sink->video_buffer, NULL);
     g_clear_object(&sink->texture);
     g_clear_object(&sink->display);
 
@@ -468,6 +469,7 @@ gst_vaapisink_stop(GstBaseSink *base_sink)
 {
     GstVaapiSink * const sink = GST_VAAPISINK(base_sink);
 
+    gst_buffer_replace(&sink->video_buffer, NULL);
     g_clear_object(&sink->window);
     g_clear_object(&sink->display);
 
@@ -772,7 +774,12 @@ gst_vaapisink_show_frame(GstBaseSink *base_sink, GstBuffer *buffer)
         success = FALSE;
         break;
     }
-    return success ? GST_FLOW_OK : GST_FLOW_UNEXPECTED;
+    if (!success)
+        return GST_FLOW_UNEXPECTED;
+
+    /* Retain VA surface until the next one is displayed */
+    gst_buffer_replace(&sink->video_buffer, buffer);
+    return GST_FLOW_OK;
 }
 
 static gboolean
@@ -938,6 +945,7 @@ gst_vaapisink_init(GstVaapiSink *sink)
     sink->window_width   = 0;
     sink->window_height  = 0;
     sink->texture        = NULL;
+    sink->video_buffer   = NULL;
     sink->video_width    = 0;
     sink->video_height   = 0;
     sink->video_par_n    = 1;
index 54930463f0145a16eaf9e52f5fa8e5e3af1e3a0f..0e8709f321e232e4093ec78ea9177849554aead1 100644 (file)
@@ -74,6 +74,7 @@ struct _GstVaapiSink {
     guint               window_width;
     guint               window_height;
     GstVaapiTexture    *texture;
+    GstBuffer          *video_buffer;
     guint               video_width;
     guint               video_height;
     gint                video_par_n;