summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGwenole Beauchesne <gwenole.beauchesne@intel.com>2014-09-15 15:27:50 +0200
committerGwenole Beauchesne <gwenole.beauchesne@intel.com>2015-01-28 17:35:16 +0100
commit797632139ff73bdd6676f94cba043de7a41dd1be (patch)
treed6bb4a314c31a51b60614a04c1864fc2101310b7
parent011f9bd6cbdacc8b4cc8546aa24f505d3fa17a08 (diff)
downloadgst-vaapi-797632139ff73bdd6676f94cba043de7a41dd1be.tar.gz
surface: add support for GEM buffer imports.
Add support for GEM buffer imports. This is useful for VA/EGL interop with legacy Mesa implementations, or when it is desired or required to support outbound textures for instance. https://bugzilla.gnome.org/show_bug.cgi?id=736718
-rw-r--r--gst-libs/gst/vaapi/gstvaapisurface_drm.c38
-rw-r--r--gst-libs/gst/vaapi/gstvaapisurface_drm.h5
2 files changed, 43 insertions, 0 deletions
diff --git a/gst-libs/gst/vaapi/gstvaapisurface_drm.c b/gst-libs/gst/vaapi/gstvaapisurface_drm.c
index d0898a52..1a2ba20d 100644
--- a/gst-libs/gst/vaapi/gstvaapisurface_drm.c
+++ b/gst-libs/gst/vaapi/gstvaapisurface_drm.c
@@ -150,3 +150,41 @@ gst_vaapi_surface_new_with_dma_buf_handle (GstVaapiDisplay * display,
gst_vaapi_buffer_proxy_unref (proxy);
return surface;
}
+
+/**
+ * gst_vaapi_surface_new_with_dma_buf_handle:
+ * @display: a #GstVaapiDisplay
+ * @name: the DRM GEM buffer name
+ * @size: the underlying DRM buffer size
+ * @format: the desired surface format
+ * @width: the desired surface width in pixels
+ * @height: the desired surface height in pixels
+ * @offset: the offsets to each plane
+ * @stride: the pitches for each plane
+ *
+ * Creates a new #GstVaapiSurface with an external DRM GEM buffer
+ * name. The newly created VA surfaces owns the supplied buffer
+ * handle.
+ *
+ * Return value: the newly allocated #GstVaapiSurface object, or %NULL
+ * if creation from DRM PRIME fd failed, or is not supported
+ */
+GstVaapiSurface *
+gst_vaapi_surface_new_with_gem_buf_handle (GstVaapiDisplay * display,
+ guint32 name, guint size, GstVideoFormat format, guint width, guint height,
+ gsize offset[GST_VIDEO_MAX_PLANES], gint stride[GST_VIDEO_MAX_PLANES])
+{
+ GstVaapiBufferProxy *proxy;
+ GstVaapiSurface *surface;
+ GstVideoInfo vi;
+
+ proxy = gst_vaapi_buffer_proxy_new ((guintptr) name,
+ GST_VAAPI_BUFFER_MEMORY_TYPE_GEM_BUF, size, NULL, NULL);
+ if (!proxy)
+ return NULL;
+
+ fill_video_info (&vi, format, width, height, offset, stride);
+ surface = gst_vaapi_surface_new_from_buffer_proxy (display, proxy, &vi);
+ gst_vaapi_buffer_proxy_unref (proxy);
+ return surface;
+}
diff --git a/gst-libs/gst/vaapi/gstvaapisurface_drm.h b/gst-libs/gst/vaapi/gstvaapisurface_drm.h
index eee010c5..5073f556 100644
--- a/gst-libs/gst/vaapi/gstvaapisurface_drm.h
+++ b/gst-libs/gst/vaapi/gstvaapisurface_drm.h
@@ -39,6 +39,11 @@ gst_vaapi_surface_new_with_dma_buf_handle (GstVaapiDisplay * display,
gint fd, guint size, GstVideoFormat format, guint width, guint height,
gsize offset[GST_VIDEO_MAX_PLANES], gint stride[GST_VIDEO_MAX_PLANES]);
+GstVaapiSurface *
+gst_vaapi_surface_new_with_gem_buf_handle (GstVaapiDisplay * display,
+ guint32 name, guint size, GstVideoFormat format, guint width, guint height,
+ gsize offset[GST_VIDEO_MAX_PLANES], gint stride[GST_VIDEO_MAX_PLANES]);
+
G_END_DECLS
#endif /* GST_VAAPI_SURFACE_DRM_H */