mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-26 18:20:44 +00:00
vaapivideomemory: disallow memory shares across buffers, use a copy.
Forbid shares of GstMemory instances, and rather make copy of it. This effectively copies the GstMemory structure and enclosed metadata, but this does not copy the VA surface contents itself. It should though. This fixes preroll and makes sure to not download garbage for the first frame when a SW rendering sink is used.
This commit is contained in:
parent
3a762284a2
commit
e0e869f536
1 changed files with 15 additions and 5 deletions
|
@ -269,8 +269,9 @@ gst_vaapi_video_memory_new(GstAllocator *base_allocator,
|
|||
return NULL;
|
||||
|
||||
vip = &allocator->image_info;
|
||||
gst_memory_init(&mem->parent_instance, 0, gst_object_ref(allocator), NULL,
|
||||
GST_VIDEO_INFO_SIZE(vip), 0, 0, GST_VIDEO_INFO_SIZE(vip));
|
||||
gst_memory_init(&mem->parent_instance, GST_MEMORY_FLAG_NO_SHARE,
|
||||
gst_object_ref(allocator), NULL, GST_VIDEO_INFO_SIZE(vip), 0,
|
||||
0, GST_VIDEO_INFO_SIZE(vip));
|
||||
|
||||
mem->proxy = NULL;
|
||||
mem->surface_info = &allocator->surface_info;
|
||||
|
@ -417,13 +418,22 @@ static GstVaapiVideoMemory *
|
|||
gst_vaapi_video_memory_copy(GstVaapiVideoMemory *mem,
|
||||
gssize offset, gssize size)
|
||||
{
|
||||
GstVaapiVideoMeta *meta;
|
||||
GstMemory *out_mem;
|
||||
gsize maxsize;
|
||||
|
||||
if (offset != 0 || size != -1)
|
||||
/* XXX: this implements a soft-copy, i.e. underlying VA surfaces
|
||||
are not copied */
|
||||
(void)gst_memory_get_sizes(GST_MEMORY_CAST(mem), NULL, &maxsize);
|
||||
if (offset != 0 || (size != -1 && (gsize)size != maxsize))
|
||||
goto error_unsupported;
|
||||
|
||||
out_mem = gst_vaapi_video_memory_new(mem->parent_instance.allocator,
|
||||
mem->meta);
|
||||
meta = gst_vaapi_video_meta_copy(mem->meta);
|
||||
if (!meta)
|
||||
goto error_allocate_memory;
|
||||
|
||||
out_mem = gst_vaapi_video_memory_new(GST_MEMORY_CAST(mem)->allocator, meta);
|
||||
gst_vaapi_video_meta_unref(meta);
|
||||
if (!out_mem)
|
||||
goto error_allocate_memory;
|
||||
return GST_VAAPI_VIDEO_MEMORY_CAST(out_mem);
|
||||
|
|
Loading…
Reference in a new issue