From b9b211c1d152e122946f0b9b59cf18a031198ac1 Mon Sep 17 00:00:00 2001 From: He Junyan Date: Fri, 4 Nov 2022 17:12:22 +0800 Subject: [PATCH] va: basetransform: Do not use allocator and pool from other display. Just like the va decoder, the vpp and deinterlace should not use allocator and pool from other display. Also, when importing the input buffer, if it is from other display, we should fallback to memory copy. Fixes: https://gitlab.freedesktop.org/gstreamer/gstreamer/-/issues/1167 Part-of: --- .../gst-plugins-bad/sys/va/gstvabasetransform.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/subprojects/gst-plugins-bad/sys/va/gstvabasetransform.c b/subprojects/gst-plugins-bad/sys/va/gstvabasetransform.c index e69c0ffcb9..ee7aafccea 100644 --- a/subprojects/gst-plugins-bad/sys/va/gstvabasetransform.c +++ b/subprojects/gst-plugins-bad/sys/va/gstvabasetransform.c @@ -331,6 +331,7 @@ gst_va_base_transform_decide_allocation (GstBaseTransform * trans, GstVideoInfo vinfo; guint min, max, size = 0, usage_hint = VA_SURFACE_ATTRIB_USAGE_HINT_VPP_WRITE; gboolean update_pool, update_allocator, has_videometa, copy_frames; + gboolean dont_use_other_pool = FALSE; gst_query_parse_allocation (query, &outcaps, NULL); @@ -343,13 +344,20 @@ gst_va_base_transform_decide_allocation (GstBaseTransform * trans, } if (gst_query_get_n_allocation_params (query) > 0) { + GstVaDisplay *display; + gst_query_parse_nth_allocation_param (query, 0, &allocator, &other_params); - if (allocator && !(GST_IS_VA_DMABUF_ALLOCATOR (allocator) - || GST_IS_VA_ALLOCATOR (allocator))) { + display = gst_va_allocator_peek_display (allocator); + if (!display) { /* save the allocator for the other pool */ other_allocator = allocator; allocator = NULL; + } else if (display != self->display) { + /* The allocator and pool belong to other display, we should not use. */ + gst_clear_object (&allocator); + dont_use_other_pool = TRUE; } + update_allocator = TRUE; } else { update_allocator = FALSE; @@ -364,6 +372,8 @@ gst_va_base_transform_decide_allocation (GstBaseTransform * trans, "may need other pool for copy frames %" GST_PTR_FORMAT, pool); other_pool = pool; pool = NULL; + } else if (dont_use_other_pool) { + gst_clear_object (&pool); } } @@ -800,7 +810,8 @@ _try_import_buffer (GstVaBaseTransform * self, GstBuffer * inbuf) gboolean ret; surface = gst_va_buffer_get_surface (inbuf); - if (surface != VA_INVALID_ID) + if (surface != VA_INVALID_ID && + (gst_va_buffer_peek_display (inbuf) == self->display)) return TRUE; g_rec_mutex_lock (&GST_VA_SHARED_LOCK);