mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-27 12:11:13 +00:00
msdk: generalize the parameter of msdk video memory functions
There needs to be generalized for the parameter from GstVideoMsdkVideoMemory to GstMemory. Thus we can call these functions if using DMABuf memory. https://bugzilla.gnome.org/show_bug.cgi?id=793707
This commit is contained in:
parent
762eb97092
commit
c3438b5a0f
3 changed files with 27 additions and 18 deletions
|
@ -253,8 +253,8 @@ gst_msdk_buffer_pool_acquire_buffer (GstBufferPool * pool,
|
||||||
|
|
||||||
surface = gst_msdk_get_surface_from_buffer (buf);
|
surface = gst_msdk_get_surface_from_buffer (buf);
|
||||||
if (!surface || surface->Data.Locked > 0) {
|
if (!surface || surface->Data.Locked > 0) {
|
||||||
if (!gst_msdk_video_memory_get_surface_available (GST_MSDK_VIDEO_MEMORY_CAST
|
if (!gst_msdk_video_memory_get_surface_available (gst_buffer_peek_memory
|
||||||
(gst_buffer_peek_memory (buf, 0)))) {
|
(buf, 0))) {
|
||||||
GST_WARNING_OBJECT (pool, "failed to get new surface available");
|
GST_WARNING_OBJECT (pool, "failed to get new surface available");
|
||||||
return GST_FLOW_ERROR;
|
return GST_FLOW_ERROR;
|
||||||
}
|
}
|
||||||
|
@ -278,8 +278,7 @@ gst_msdk_buffer_pool_release_buffer (GstBufferPool * pool, GstBuffer * buf)
|
||||||
if (!surface)
|
if (!surface)
|
||||||
goto done;
|
goto done;
|
||||||
|
|
||||||
gst_msdk_video_memory_release_surface (GST_MSDK_VIDEO_MEMORY_CAST
|
gst_msdk_video_memory_release_surface (gst_buffer_peek_memory (buf, 0));
|
||||||
(gst_buffer_peek_memory (buf, 0)));
|
|
||||||
|
|
||||||
done:
|
done:
|
||||||
return GST_BUFFER_POOL_CLASS (parent_class)->release_buffer (pool, buf);
|
return GST_BUFFER_POOL_CLASS (parent_class)->release_buffer (pool, buf);
|
||||||
|
|
|
@ -61,13 +61,18 @@ gst_msdk_video_allocator_get_surface (GstAllocator * allocator)
|
||||||
}
|
}
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
gst_msdk_video_memory_get_surface_available (GstMsdkVideoMemory * mem)
|
gst_msdk_video_memory_get_surface_available (GstMemory * mem)
|
||||||
{
|
{
|
||||||
GstAllocator *allocator;
|
GstAllocator *allocator;
|
||||||
|
GstMsdkVideoMemory *msdk_mem;
|
||||||
|
|
||||||
allocator = GST_MEMORY_CAST (mem)->allocator;
|
g_return_val_if_fail (mem, FALSE);
|
||||||
mem->surface = gst_msdk_video_allocator_get_surface (allocator);
|
g_return_val_if_fail (GST_IS_MSDK_VIDEO_MEMORY (mem), FALSE);
|
||||||
return mem->surface ? TRUE : FALSE;
|
|
||||||
|
msdk_mem = GST_MSDK_VIDEO_MEMORY_CAST (mem);
|
||||||
|
allocator = mem->allocator;
|
||||||
|
msdk_mem->surface = gst_msdk_video_allocator_get_surface (allocator);
|
||||||
|
return msdk_mem->surface ? TRUE : FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -76,23 +81,28 @@ gst_msdk_video_memory_get_surface_available (GstMsdkVideoMemory * mem)
|
||||||
* Otherwise, we put the surface to the available list.
|
* Otherwise, we put the surface to the available list.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
gst_msdk_video_memory_release_surface (GstMsdkVideoMemory * mem)
|
gst_msdk_video_memory_release_surface (GstMemory * mem)
|
||||||
{
|
{
|
||||||
GstMsdkVideoAllocator *msdk_video_allocator;
|
GstMsdkVideoAllocator *msdk_video_allocator;
|
||||||
|
GstMsdkVideoMemory *msdk_mem;
|
||||||
|
|
||||||
msdk_video_allocator =
|
g_return_if_fail (mem);
|
||||||
GST_MSDK_VIDEO_ALLOCATOR_CAST (GST_MEMORY_CAST (mem)->allocator);
|
g_return_if_fail (GST_IS_MSDK_VIDEO_MEMORY (mem));
|
||||||
if (!mem->surface)
|
|
||||||
|
msdk_mem = GST_MSDK_VIDEO_MEMORY_CAST (mem);
|
||||||
|
msdk_video_allocator = GST_MSDK_VIDEO_ALLOCATOR_CAST (mem->allocator);
|
||||||
|
|
||||||
|
if (!msdk_mem->surface)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (mem->surface->Data.Locked > 0)
|
if (msdk_mem->surface->Data.Locked > 0)
|
||||||
gst_msdk_context_put_surface_locked (msdk_video_allocator->context,
|
gst_msdk_context_put_surface_locked (msdk_video_allocator->context,
|
||||||
msdk_video_allocator->alloc_response, mem->surface);
|
msdk_video_allocator->alloc_response, msdk_mem->surface);
|
||||||
else
|
else
|
||||||
gst_msdk_context_put_surface_available (msdk_video_allocator->context,
|
gst_msdk_context_put_surface_available (msdk_video_allocator->context,
|
||||||
msdk_video_allocator->alloc_response, mem->surface);
|
msdk_video_allocator->alloc_response, msdk_mem->surface);
|
||||||
|
|
||||||
mem->surface = NULL;
|
msdk_mem->surface = NULL;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -73,10 +73,10 @@ GstMemory *
|
||||||
gst_msdk_video_memory_new (GstAllocator * allocator);
|
gst_msdk_video_memory_new (GstAllocator * allocator);
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
gst_msdk_video_memory_get_surface_available (GstMsdkVideoMemory * mem);
|
gst_msdk_video_memory_get_surface_available (GstMemory * mem);
|
||||||
|
|
||||||
void
|
void
|
||||||
gst_msdk_video_memory_release_surface (GstMsdkVideoMemory * mem);
|
gst_msdk_video_memory_release_surface (GstMemory * mem);
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
gst_video_meta_map_msdk_memory (GstVideoMeta * meta, guint plane,
|
gst_video_meta_map_msdk_memory (GstVideoMeta * meta, guint plane,
|
||||||
|
|
Loading…
Reference in a new issue