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:
Hyunjun Ko 2018-03-30 11:03:00 -08:00 committed by Sreerenj Balachandran
parent 762eb97092
commit c3438b5a0f
3 changed files with 27 additions and 18 deletions

View file

@ -253,8 +253,8 @@ gst_msdk_buffer_pool_acquire_buffer (GstBufferPool * pool,
surface = gst_msdk_get_surface_from_buffer (buf);
if (!surface || surface->Data.Locked > 0) {
if (!gst_msdk_video_memory_get_surface_available (GST_MSDK_VIDEO_MEMORY_CAST
(gst_buffer_peek_memory (buf, 0)))) {
if (!gst_msdk_video_memory_get_surface_available (gst_buffer_peek_memory
(buf, 0))) {
GST_WARNING_OBJECT (pool, "failed to get new surface available");
return GST_FLOW_ERROR;
}
@ -278,8 +278,7 @@ gst_msdk_buffer_pool_release_buffer (GstBufferPool * pool, GstBuffer * buf)
if (!surface)
goto done;
gst_msdk_video_memory_release_surface (GST_MSDK_VIDEO_MEMORY_CAST
(gst_buffer_peek_memory (buf, 0)));
gst_msdk_video_memory_release_surface (gst_buffer_peek_memory (buf, 0));
done:
return GST_BUFFER_POOL_CLASS (parent_class)->release_buffer (pool, buf);

View file

@ -61,13 +61,18 @@ gst_msdk_video_allocator_get_surface (GstAllocator * allocator)
}
gboolean
gst_msdk_video_memory_get_surface_available (GstMsdkVideoMemory * mem)
gst_msdk_video_memory_get_surface_available (GstMemory * mem)
{
GstAllocator *allocator;
GstMsdkVideoMemory *msdk_mem;
allocator = GST_MEMORY_CAST (mem)->allocator;
mem->surface = gst_msdk_video_allocator_get_surface (allocator);
return mem->surface ? TRUE : FALSE;
g_return_val_if_fail (mem, FALSE);
g_return_val_if_fail (GST_IS_MSDK_VIDEO_MEMORY (mem), 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.
*/
void
gst_msdk_video_memory_release_surface (GstMsdkVideoMemory * mem)
gst_msdk_video_memory_release_surface (GstMemory * mem)
{
GstMsdkVideoAllocator *msdk_video_allocator;
GstMsdkVideoMemory *msdk_mem;
msdk_video_allocator =
GST_MSDK_VIDEO_ALLOCATOR_CAST (GST_MEMORY_CAST (mem)->allocator);
if (!mem->surface)
g_return_if_fail (mem);
g_return_if_fail (GST_IS_MSDK_VIDEO_MEMORY (mem));
msdk_mem = GST_MSDK_VIDEO_MEMORY_CAST (mem);
msdk_video_allocator = GST_MSDK_VIDEO_ALLOCATOR_CAST (mem->allocator);
if (!msdk_mem->surface)
return;
if (mem->surface->Data.Locked > 0)
if (msdk_mem->surface->Data.Locked > 0)
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
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;
}

View file

@ -73,10 +73,10 @@ GstMemory *
gst_msdk_video_memory_new (GstAllocator * allocator);
gboolean
gst_msdk_video_memory_get_surface_available (GstMsdkVideoMemory * mem);
gst_msdk_video_memory_get_surface_available (GstMemory * mem);
void
gst_msdk_video_memory_release_surface (GstMsdkVideoMemory * mem);
gst_msdk_video_memory_release_surface (GstMemory * mem);
gboolean
gst_video_meta_map_msdk_memory (GstVideoMeta * meta, guint plane,