diff options
author | Hyunjun Ko <zzoon@igalia.com> | 2018-03-30 11:03:17 -0800 |
---|---|---|
committer | Sreerenj Balachandran <sreerenj.balachandran@intel.com> | 2018-03-30 11:04:28 -0800 |
commit | bd8ffcb29d036ce08b86106d434d41c474badc26 (patch) | |
tree | 92b1e6b53e3708ea4e59a2ffe748e4c67a32f749 | |
parent | c3438b5a0fde3f57b7c0e59243f1cbb8df623c91 (diff) | |
download | gstreamer-plugins-bad-bd8ffcb29d036ce08b86106d434d41c474badc26.tar.gz |
msdk: allocator: get dmabuf handle during allocation if required
https://bugzilla.gnome.org/show_bug.cgi?id=793707
-rw-r--r-- | sys/msdk/gstmsdkallocator.h | 1 | ||||
-rw-r--r-- | sys/msdk/gstmsdkallocator_libva.c | 31 |
2 files changed, 32 insertions, 0 deletions
diff --git a/sys/msdk/gstmsdkallocator.h b/sys/msdk/gstmsdkallocator.h index cbe03e641..4d94b8bce 100644 --- a/sys/msdk/gstmsdkallocator.h +++ b/sys/msdk/gstmsdkallocator.h @@ -46,6 +46,7 @@ struct _GstMsdkMemoryID { #ifndef _WIN32 VASurfaceID *surface; VAImage image; + VABufferInfo info; #else /* TODO: This is just to avoid compile errors on Windows. * Implement handling Windows-specific video-memory. diff --git a/sys/msdk/gstmsdkallocator_libva.c b/sys/msdk/gstmsdkallocator_libva.c index a7fc25389..4566fc17f 100644 --- a/sys/msdk/gstmsdkallocator_libva.c +++ b/sys/msdk/gstmsdkallocator_libva.c @@ -31,6 +31,7 @@ */ #include <va/va.h> +#include <va/va_drmcommon.h> #include "gstmsdkallocator.h" #include "msdk_libva.h" @@ -104,6 +105,31 @@ gst_msdk_frame_alloc (mfxHDL pthis, mfxFrameAllocRequest * req, } for (i = 0; i < surfaces_num; i++) { + /* Get dmabuf handle if MFX_MEMTYPE_EXPORT_FRAME */ + if (req->Type & MFX_MEMTYPE_EXPORT_FRAME) { + msdk_mids[i].info.mem_type = VA_SURFACE_ATTRIB_MEM_TYPE_DRM_PRIME; + va_status = + vaDeriveImage (gst_msdk_context_get_handle (context), surfaces[i], + &msdk_mids[i].image); + status = gst_msdk_get_mfx_status_from_va_status (va_status); + + if (MFX_ERR_NONE != status) { + GST_ERROR ("failed to derive image"); + return status; + } + + va_status = + vaAcquireBufferHandle (gst_msdk_context_get_handle (context), + msdk_mids[i].image.buf, &msdk_mids[i].info); + status = gst_msdk_get_mfx_status_from_va_status (va_status); + + if (MFX_ERR_NONE != status) { + GST_ERROR ("failed to get dmabuf handle"); + vaDestroyImage (gst_msdk_context_get_handle (context), + msdk_mids[i].image.image_id); + } + } + msdk_mids[i].surface = &surfaces[i]; mids[i] = (mfxMemId *) & msdk_mids[i]; } @@ -170,6 +196,11 @@ gst_msdk_frame_free (mfxHDL pthis, mfxFrameAllocResponse * resp) /* Make sure that all the vaImages are destroyed */ for (i = 0; i < resp->NumFrameActual; i++) { GstMsdkMemoryID *mem = resp->mids[i]; + + /* Release dmabuf handle if used */ + if (mem->info.mem_type == VA_SURFACE_ATTRIB_MEM_TYPE_DRM_PRIME) + vaReleaseBufferHandle (dpy, mem->image.buf); + vaDestroyImage (dpy, mem->image.image_id); } |