mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-24 09:10:36 +00:00
vaapivideomemory: refactor vaapi memory unmapping
There were duplicated code in gst_video_meta_unmap_vaapi_memory() and gst_vaapi_video_memory_unmap() when unmapping. This patch refactors both methods adding the common function unmap_vaapi_memory(). This also ensures, if direct rendering is enabled, it is correctly reset. Additionally, only when mapping flag has the WRITE bit, it set the image as current, which was done in gst_video_meta_map_vaapi_memory() but no in gst_vaapi_video_memory_map(). In order to make this, the mapping flags were required, so instead of overloading mem_unmap() virtual function, mem_unmap_full() is overloaded. https://bugzilla.gnome.org/show_bug.cgi?id=774213
This commit is contained in:
parent
eda03230d9
commit
4ae9428072
1 changed files with 22 additions and 17 deletions
|
@ -274,6 +274,22 @@ error_map_image:
|
|||
}
|
||||
}
|
||||
|
||||
static inline void
|
||||
unmap_vaapi_memory (GstVaapiVideoMemory * mem, GstMapFlags flags)
|
||||
{
|
||||
gst_vaapi_image_unmap (mem->image);
|
||||
|
||||
if (flags & GST_MAP_WRITE) {
|
||||
GST_VAAPI_VIDEO_MEMORY_FLAG_SET (mem,
|
||||
GST_VAAPI_VIDEO_MEMORY_FLAG_IMAGE_IS_CURRENT);
|
||||
}
|
||||
|
||||
if (!use_native_formats (mem->usage_flag)) {
|
||||
gst_vaapi_video_meta_set_image (mem->meta, NULL);
|
||||
gst_vaapi_video_memory_reset_image (mem);
|
||||
}
|
||||
}
|
||||
|
||||
gboolean
|
||||
gst_video_meta_map_vaapi_memory (GstVideoMeta * meta, guint plane,
|
||||
GstMapInfo * info, gpointer * data, gint * stride, GstMapFlags flags)
|
||||
|
@ -330,19 +346,8 @@ gst_video_meta_unmap_vaapi_memory (GstVideoMeta * meta, guint plane,
|
|||
mem->map_type = 0;
|
||||
|
||||
/* Unmap VA image used for read/writes */
|
||||
if (info->flags & GST_MAP_READWRITE) {
|
||||
gst_vaapi_image_unmap (mem->image);
|
||||
|
||||
if (info->flags & GST_MAP_WRITE) {
|
||||
GST_VAAPI_VIDEO_MEMORY_FLAG_SET (mem,
|
||||
GST_VAAPI_VIDEO_MEMORY_FLAG_IMAGE_IS_CURRENT);
|
||||
}
|
||||
|
||||
if (!use_native_formats (mem->usage_flag)) {
|
||||
gst_vaapi_video_meta_set_image (mem->meta, NULL);
|
||||
gst_vaapi_video_memory_reset_image (mem);
|
||||
}
|
||||
}
|
||||
if (info->flags & GST_MAP_READWRITE)
|
||||
unmap_vaapi_memory (mem, info->flags);
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -510,7 +515,7 @@ error_no_image:
|
|||
}
|
||||
|
||||
static void
|
||||
gst_vaapi_video_memory_unmap (GstVaapiVideoMemory * mem)
|
||||
gst_vaapi_video_memory_unmap_full (GstVaapiVideoMemory * mem, GstMapInfo * info)
|
||||
{
|
||||
if (mem->map_count == 1) {
|
||||
switch (mem->map_type) {
|
||||
|
@ -518,7 +523,7 @@ gst_vaapi_video_memory_unmap (GstVaapiVideoMemory * mem)
|
|||
gst_vaapi_surface_proxy_replace (&mem->proxy, NULL);
|
||||
break;
|
||||
case GST_VAAPI_VIDEO_MEMORY_MAP_TYPE_LINEAR:
|
||||
gst_vaapi_image_unmap (mem->image);
|
||||
unmap_vaapi_memory (mem, info->flags);
|
||||
break;
|
||||
default:
|
||||
goto error_incompatible_map;
|
||||
|
@ -652,8 +657,8 @@ gst_vaapi_video_allocator_init (GstVaapiVideoAllocator * allocator)
|
|||
base_allocator->mem_type = GST_VAAPI_VIDEO_MEMORY_NAME;
|
||||
base_allocator->mem_map = (GstMemoryMapFunction)
|
||||
gst_vaapi_video_memory_map;
|
||||
base_allocator->mem_unmap = (GstMemoryUnmapFunction)
|
||||
gst_vaapi_video_memory_unmap;
|
||||
base_allocator->mem_unmap_full = (GstMemoryUnmapFullFunction)
|
||||
gst_vaapi_video_memory_unmap_full;
|
||||
base_allocator->mem_copy = (GstMemoryCopyFunction)
|
||||
gst_vaapi_video_memory_copy;
|
||||
base_allocator->mem_share = (GstMemoryShareFunction)
|
||||
|
|
Loading…
Reference in a new issue