From 6b1fba14bf3f0d845020d5785c74dbc79775cf09 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Manuel=20J=C3=A1quez=20Leal?= Date: Thu, 30 Nov 2023 14:47:06 +0100 Subject: [PATCH] vaallocator: remove runtime mapping selection The original idea was to select the type of mapping (either using derive images or downloading the image) in runtime, under the assumption that both methods shared the same memory layout (offsets and strides), because a single GstVideoMeta is assigned by the buffer pool at allocation time. Nonetheless, in recent hardware this assumption is invalid, raising memory access errors. This patch removes completely the mapping type selection at runtime, using the method selected when the allocator is configured, synced with the bufferpool allocation. This problem was fixed originally for iHD driver only. But now it makes sense to remove all of it. Original-patch-by: Mengkejiergeli Ba Part-of: --- .../gst-libs/gst/va/gstvaallocator.c | 34 +++---------------- 1 file changed, 4 insertions(+), 30 deletions(-) diff --git a/subprojects/gst-plugins-bad/gst-libs/gst/va/gstvaallocator.c b/subprojects/gst-plugins-bad/gst-libs/gst/va/gstvaallocator.c index d391b569a2..05917defe8 100644 --- a/subprojects/gst-plugins-bad/gst-libs/gst/va/gstvaallocator.c +++ b/subprojects/gst-plugins-bad/gst-libs/gst/va/gstvaallocator.c @@ -1304,7 +1304,7 @@ _clean_mem (GstVaMemory * mem) mem->image.image_id = VA_INVALID_ID; mem->image.buf = VA_INVALID_ID; - mem->is_derived = TRUE; + mem->is_derived = FALSE; mem->is_dirty = FALSE; mem->prev_mapflags = 0; mem->mapped_data = NULL; @@ -1406,10 +1406,8 @@ static gpointer _va_map_unlocked (GstVaMemory * mem, GstMapFlags flags) { GstAllocator *allocator = GST_MEMORY_CAST (mem)->allocator; - GstVideoInfo *info; GstVaAllocator *va_allocator; GstVaDisplay *display; - gboolean use_derived; g_return_val_if_fail (mem->surface != VA_INVALID_ID, NULL); g_return_val_if_fail (GST_IS_VA_ALLOCATOR (allocator), NULL); @@ -1435,36 +1433,12 @@ _va_map_unlocked (GstVaMemory * mem, GstMapFlags flags) goto success; } - if (va_allocator->feat_use_derived == GST_VA_FEATURE_AUTO) { - switch (gst_va_display_get_implementation (display)) { - case GST_VA_IMPLEMENTATION_INTEL_I965: - /* YUV derived images are tiled, so writing them is also - * problematic */ - use_derived = va_allocator->use_derived && !((flags & GST_MAP_READ) - || ((flags & GST_MAP_WRITE) - && GST_VIDEO_INFO_IS_YUV (&va_allocator->info))); - break; - case GST_VA_IMPLEMENTATION_MESA_GALLIUM: - /* Reading RGB derived images, with non-standard resolutions, - * looks like tiled too. TODO(victor): fill a bug in Mesa. */ - use_derived = va_allocator->use_derived && !((flags & GST_MAP_READ) - && GST_VIDEO_INFO_IS_RGB (&va_allocator->info)); - break; - default: - use_derived = va_allocator->use_derived; - break; - } - } else { - use_derived = va_allocator->use_derived; - } + mem->is_derived = va_allocator->use_derived; - info = &va_allocator->info; - - if (!va_ensure_image (display, mem->surface, info, &mem->image, use_derived)) + if (!va_ensure_image (display, mem->surface, &va_allocator->info, &mem->image, + va_allocator->use_derived)) return NULL; - mem->is_derived = use_derived; - if (!mem->is_derived) { if (!va_get_image (display, mem->surface, &mem->image)) goto fail;