From 0cc1dccd8495afb16647f63287e1b23d2b790114 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Manuel=20J=C3=A1quez=20Leal?= Date: Mon, 3 Aug 2020 13:44:23 +0200 Subject: [PATCH] va: h264dec: don't copy frames if VAMemory capsfeature is negotiated Otherwise the VASurfaceID is lost. --- sys/va/gstvah264dec.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/sys/va/gstvah264dec.c b/sys/va/gstvah264dec.c index 4773916b04..320f40c483 100644 --- a/sys/va/gstvah264dec.c +++ b/sys/va/gstvah264dec.c @@ -1037,6 +1037,15 @@ _caps_is_dmabuf (GstVaH264Dec * self, GstCaps * caps) & VA_SURFACE_ATTRIB_MEM_TYPE_DRM_PRIME); } +static inline gboolean +_caps_is_va_memory (GstCaps * caps) +{ + GstCapsFeatures *features; + + features = gst_caps_get_features (caps, 0); + return gst_caps_features_contains (features, "memory:VAMemory"); +} + static inline void _shall_copy_frames (GstVaH264Dec * self, GstVideoInfo * info) { @@ -1083,7 +1092,8 @@ _try_allocator (GstVaH264Dec * self, GstAllocator * allocator, GstCaps * caps, } else if (GST_IS_VA_ALLOCATOR (allocator)) { if (!gst_va_allocator_try (allocator, ¶ms)) return FALSE; - _shall_copy_frames (self, ¶ms.info); + if (!_caps_is_va_memory (caps)) + _shall_copy_frames (self, ¶ms.info); } else { return FALSE; } @@ -1191,7 +1201,7 @@ gst_va_h264_dec_decide_allocation (GstVideoDecoder * decoder, GstQuery * query) } else { size = GST_VIDEO_INFO_SIZE (&info); - if (!self->has_videometa) { + if (!self->has_videometa && !_caps_is_va_memory (caps)) { GST_DEBUG_OBJECT (self, "making new other pool for copy"); self->other_pool = gst_video_buffer_pool_new (); config = gst_buffer_pool_get_config (self->other_pool);