summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulien Isorce <j.isorce@samsung.com>2016-10-19 15:07:31 +0100
committerVíctor Manuel Jáquez Leal <victorx.jaquez@intel.com>2017-02-02 20:33:36 +0100
commit7fc1b70ff65bc5a78181e1faa23b4e5e510f8c3b (patch)
treeae5f982b8b5366dbf95b317c376874d0c6156107
parentbc97987ffb5a5d5699fcb53a9413f9e8b4e525f2 (diff)
libs: bufferproxy: gst_vaapi_buffer_proxy_{set,peek}_mem()
This patch adds a GstMemory as a variable member of the buffer proxy, because we will need to associate the buffer proxy with the memory which exposes it. Later, we will know which memory, in the video buffer pool, is attached to the processed surface. https://bugzilla.gnome.org/show_bug.cgi?id=755072
-rw-r--r--gst-libs/gst/vaapi/gstvaapibufferproxy.c40
-rw-r--r--gst-libs/gst/vaapi/gstvaapibufferproxy.h6
-rw-r--r--gst-libs/gst/vaapi/gstvaapibufferproxy_priv.h1
3 files changed, 47 insertions, 0 deletions
diff --git a/gst-libs/gst/vaapi/gstvaapibufferproxy.c b/gst-libs/gst/vaapi/gstvaapibufferproxy.c
index 75cbe929..44c61261 100644
--- a/gst-libs/gst/vaapi/gstvaapibufferproxy.c
+++ b/gst-libs/gst/vaapi/gstvaapibufferproxy.c
@@ -128,6 +128,11 @@ gst_vaapi_buffer_proxy_finalize (GstVaapiBufferProxy * proxy)
{
gst_vaapi_buffer_proxy_release_handle (proxy);
+ if (proxy->mem) {
+ gst_memory_unref (proxy->mem);
+ proxy->mem = NULL;
+ }
+
/* Notify the user function that the object is now destroyed */
if (proxy->destroy_func)
proxy->destroy_func (proxy->destroy_data);
@@ -171,6 +176,7 @@ gst_vaapi_buffer_proxy_new (guintptr handle, guint type, gsize size,
proxy->va_info.type = VAImageBufferType;
proxy->va_info.mem_type = from_GstVaapiBufferMemoryType (proxy->type);
proxy->va_info.mem_size = size;
+ proxy->mem = NULL;
if (!proxy->va_info.mem_type)
goto error_unsupported_mem_type;
return proxy;
@@ -206,6 +212,7 @@ gst_vaapi_buffer_proxy_new_from_object (GstVaapiObject * object,
proxy->destroy_data = data;
proxy->type = type;
proxy->va_buf = buf_id;
+ proxy->mem = NULL;
memset (&proxy->va_info, 0, sizeof (proxy->va_info));
proxy->va_info.mem_type = from_GstVaapiBufferMemoryType (proxy->type);
if (!proxy->va_info.mem_type)
@@ -355,3 +362,36 @@ gst_vaapi_buffer_proxy_release_data (GstVaapiBufferProxy * proxy)
proxy->destroy_data = NULL;
}
}
+
+/**
+ * gst_vaapi_buffer_proxy_set_mem:
+ * @proxy: a #GstVaapiBufferProxy
+ * @mem: a #GstMemory
+ *
+ * Relates @mem with @proxy, hence we later will know which memory
+ * correspond to processed surface.
+ *
+ * This is useful when a dmabuf-based memory is instantiated and
+ * associated with a surface.
+ **/
+void
+gst_vaapi_buffer_proxy_set_mem (GstVaapiBufferProxy * proxy, GstMemory * mem)
+{
+ gst_mini_object_replace ((GstMiniObject **) & proxy->mem,
+ GST_MINI_OBJECT (mem));
+}
+
+/**
+ * gst_vaapi_buffer_proxy_peek_mem:
+ * @proxy: a #GstVaapiBufferProxy
+ *
+ * This is useful when a dmabuf-based memory is instantiated and
+ * associated with a surface.
+ *
+ * Returns: (transfer none): the assigned #GstMemory to the @proxy.
+ **/
+GstMemory *
+gst_vaapi_buffer_proxy_peek_mem (GstVaapiBufferProxy * proxy)
+{
+ return proxy->mem;
+}
diff --git a/gst-libs/gst/vaapi/gstvaapibufferproxy.h b/gst-libs/gst/vaapi/gstvaapibufferproxy.h
index 7d611cf3..872af2f7 100644
--- a/gst-libs/gst/vaapi/gstvaapibufferproxy.h
+++ b/gst-libs/gst/vaapi/gstvaapibufferproxy.h
@@ -95,6 +95,12 @@ gst_vaapi_buffer_proxy_get_size (GstVaapiBufferProxy * proxy);
void
gst_vaapi_buffer_proxy_release_data (GstVaapiBufferProxy * proxy);
+void
+gst_vaapi_buffer_proxy_set_mem (GstVaapiBufferProxy * proxy, GstMemory * mem);
+
+GstMemory *
+gst_vaapi_buffer_proxy_peek_mem (GstVaapiBufferProxy * proxy);
+
G_END_DECLS
#endif /* GST_VAAPI_BUFFER_PROXY_H */
diff --git a/gst-libs/gst/vaapi/gstvaapibufferproxy_priv.h b/gst-libs/gst/vaapi/gstvaapibufferproxy_priv.h
index 833e22ce..2cbbbf9c 100644
--- a/gst-libs/gst/vaapi/gstvaapibufferproxy_priv.h
+++ b/gst-libs/gst/vaapi/gstvaapibufferproxy_priv.h
@@ -71,6 +71,7 @@ struct _GstVaapiBufferProxy {
#if VA_CHECK_VERSION (0,36,0)
VABufferInfo va_info;
#endif
+ GstMemory *mem;
};
G_GNUC_INTERNAL