summaryrefslogtreecommitdiff
path: root/gst
diff options
context:
space:
mode:
authorHe Junyan <junyan.he@hotmail.com>2020-02-16 01:25:37 +0800
committerGStreamer Merge Bot <gitlab-merge-bot@gstreamer-foundation.org>2020-02-21 15:52:43 +0000
commit15e169fbf1d7ea57a122ec0bdbd38d51ba61284f (patch)
tree7f8d19a17d3fdaf2fc0506700874e3efbe2ccecc /gst
parent57e792136c0036e39bcf69011324cf05642b6641 (diff)
videobufferpool: don't reset surface when created internally
The bug fixing, in commit 89f202ea, just considers the case when surface's DMABuf is set through gst_buffer_pool_acquire_buffer(), which is typically a decoder's behavior. But vaapipostproc doesn't provide any surface when calling gst_buffer_pool_acquire_buffer(), thus a surface is created when GstMemory is allocated. If the surface proxy in buffer's meta is reset at buffer_pool_reset_buffer(), that surface will be destroyed and it won't be available anymore. But GstBuffers are cached in the buffer pool and they are reused again, hence only those images are rendered repeatedly. Fixes: #232
Diffstat (limited to 'gst')
-rw-r--r--gst/vaapi/gstvaapivideobufferpool.c5
-rw-r--r--gst/vaapi/gstvaapivideomemory.c11
-rw-r--r--gst/vaapi/gstvaapivideomemory.h4
3 files changed, 19 insertions, 1 deletions
diff --git a/gst/vaapi/gstvaapivideobufferpool.c b/gst/vaapi/gstvaapivideobufferpool.c
index 013766d8..082cf91e 100644
--- a/gst/vaapi/gstvaapivideobufferpool.c
+++ b/gst/vaapi/gstvaapivideobufferpool.c
@@ -480,7 +480,10 @@ gst_vaapi_video_buffer_pool_reset_buffer (GstBufferPool * pool,
/* Release the underlying surface proxy */
if (GST_VAAPI_IS_VIDEO_MEMORY (mem)) {
gst_vaapi_video_memory_reset_surface (GST_VAAPI_VIDEO_MEMORY_CAST (mem));
- } else {
+ } else if (!gst_vaapi_dmabuf_memory_holds_surface (mem)) {
+ /* If mem holds an internally created surface, don't reset it!
+ * While surface is passed, we should clear it to avoid wrong
+ * reference. */
meta = gst_buffer_get_vaapi_video_meta (buffer);
if (meta)
gst_vaapi_video_meta_set_surface_proxy (meta, NULL);
diff --git a/gst/vaapi/gstvaapivideomemory.c b/gst/vaapi/gstvaapivideomemory.c
index 224a7ed2..92e7fe9f 100644
--- a/gst/vaapi/gstvaapivideomemory.c
+++ b/gst/vaapi/gstvaapivideomemory.c
@@ -1007,6 +1007,17 @@ gst_vaapi_buffer_proxy_quark_get (void)
return g_quark;
}
+/* Whether @mem holds an internal VA surface proxy created at
+ * gst_vaapi_dmabuf_memory_new(). */
+gboolean
+gst_vaapi_dmabuf_memory_holds_surface (GstMemory * mem)
+{
+ g_return_val_if_fail (mem != NULL, FALSE);
+
+ return gst_mini_object_get_qdata (GST_MINI_OBJECT_CAST (mem),
+ GST_VAAPI_BUFFER_PROXY_QUARK) != NULL;
+}
+
GstMemory *
gst_vaapi_dmabuf_memory_new (GstAllocator * base_allocator,
GstVaapiVideoMeta * meta)
diff --git a/gst/vaapi/gstvaapivideomemory.h b/gst/vaapi/gstvaapivideomemory.h
index be18bbfe..41a05888 100644
--- a/gst/vaapi/gstvaapivideomemory.h
+++ b/gst/vaapi/gstvaapivideomemory.h
@@ -216,6 +216,10 @@ GstMemory *
gst_vaapi_dmabuf_memory_new (GstAllocator * allocator,
GstVaapiVideoMeta * meta);
+G_GNUC_INTERNAL
+gboolean
+gst_vaapi_dmabuf_memory_holds_surface (GstMemory * mem);
+
/* ------------------------------------------------------------------------ */
/* --- GstVaapiDmaBufAllocator --- */
/* ------------------------------------------------------------------------ */