[Pkg-gstreamer-commits] [gstreamer-vaapi] 28/176: surfaceproxy: add copy function.

Vincent Cheng vcheng at moszumanska.debian.org
Tue Jun 3 08:09:24 UTC 2014


This is an automated email from the git hooks/post-receive script.

vcheng pushed a commit to branch upstream
in repository gstreamer-vaapi.

commit 5e245ae2c257e331a24984f884d359dea53e20e3
Author: Gwenole Beauchesne <gwenole.beauchesne at intel.com>
Date:   Thu Nov 28 17:25:05 2013 +0100

    surfaceproxy: add copy function.
    
    Add gst_vaapi_surface_proxy_copy() function that creates a new surface
    proxy with the same information from the parent proxy, except that the
    user-defined destroy notify function is not copied over.
    
    The underlying VA surface is pushed back to the video pool only when
    the last reference to the parent surface proxy is released.
---
 docs/reference/libs/libs-sections.txt          |  1 +
 gst-libs/gst/vaapi/gstvaapisurfaceproxy.c      | 57 +++++++++++++++++++++++++-
 gst-libs/gst/vaapi/gstvaapisurfaceproxy.h      |  3 ++
 gst-libs/gst/vaapi/gstvaapisurfaceproxy_priv.h |  1 +
 4 files changed, 61 insertions(+), 1 deletion(-)

diff --git a/docs/reference/libs/libs-sections.txt b/docs/reference/libs/libs-sections.txt
index b503d95..aa7b472 100644
--- a/docs/reference/libs/libs-sections.txt
+++ b/docs/reference/libs/libs-sections.txt
@@ -366,6 +366,7 @@ gst_vaapi_surface_proxy_get_surface
 gst_vaapi_surface_proxy_get_surface_id
 gst_vaapi_surface_proxy_get_timestamp
 gst_vaapi_surface_proxy_new_from_pool
+gst_vaapi_surface_proxy_copy
 gst_vaapi_surface_proxy_ref
 gst_vaapi_surface_proxy_replace
 gst_vaapi_surface_proxy_set_destroy_notify
diff --git a/gst-libs/gst/vaapi/gstvaapisurfaceproxy.c b/gst-libs/gst/vaapi/gstvaapisurfaceproxy.c
index 2d8fcfa..82432f0 100644
--- a/gst-libs/gst/vaapi/gstvaapisurfaceproxy.c
+++ b/gst-libs/gst/vaapi/gstvaapisurfaceproxy.c
@@ -39,12 +39,13 @@ static void
 gst_vaapi_surface_proxy_finalize(GstVaapiSurfaceProxy *proxy)
 {
     if (proxy->surface) {
-        if (proxy->pool)
+        if (proxy->pool && !proxy->parent)
             gst_vaapi_video_pool_put_object(proxy->pool, proxy->surface);
         gst_vaapi_object_unref(proxy->surface);
         proxy->surface = NULL;
     }
     gst_vaapi_video_pool_replace(&proxy->pool, NULL);
+    gst_vaapi_surface_proxy_replace(&proxy->parent, NULL);
 
     /* Notify the user function that the object is now destroyed */
     if (proxy->destroy_func)
@@ -61,6 +62,17 @@ gst_vaapi_surface_proxy_class(void)
     return &GstVaapiSurfaceProxyClass;
 }
 
+/**
+ * gst_vaapi_surface_proxy_new_from_pool:
+ * @pool: a #GstVaapiSurfacePool
+ *
+ * Allocates a new surface from the supplied surface @pool and creates
+ * the wrapped surface proxy object from it. When the last reference
+ * to the proxy object is released, then the underlying VA surface is
+ * pushed back to its parent pool.
+ *
+ * Returns: The same newly allocated @proxy object, or %NULL on error
+ */
 GstVaapiSurfaceProxy *
 gst_vaapi_surface_proxy_new_from_pool(GstVaapiSurfacePool *pool)
 {
@@ -73,6 +85,7 @@ gst_vaapi_surface_proxy_new_from_pool(GstVaapiSurfacePool *pool)
     if (!proxy)
         return NULL;
 
+    proxy->parent = NULL;
     proxy->destroy_func = NULL;
     proxy->pool = gst_vaapi_video_pool_ref(pool);
     proxy->surface = gst_vaapi_video_pool_get_object(proxy->pool);
@@ -89,6 +102,48 @@ error:
     return NULL;
 }
 
+
+/**
+ * gst_vaapi_surface_proxy_copy:
+ * @proxy: the parent #GstVaapiSurfaceProxy
+ *
+ * Creates are new VA surface proxy object from the supplied parent
+ * @proxy object with the same initial information, e.g. timestamp,
+ * duration.
+ *
+ * Note: the destroy notify function is not copied into the new
+ * surface proxy object.
+ *
+ * Returns: The same newly allocated @proxy object, or %NULL on error
+ */
+GstVaapiSurfaceProxy *
+gst_vaapi_surface_proxy_copy(GstVaapiSurfaceProxy *proxy)
+{
+    GstVaapiSurfaceProxy *copy;
+
+    g_return_val_if_fail(proxy != NULL, NULL);
+
+    copy = (GstVaapiSurfaceProxy *)
+        gst_vaapi_mini_object_new(gst_vaapi_surface_proxy_class());
+    if (!copy)
+        return NULL;
+
+    GST_VAAPI_SURFACE_PROXY_FLAGS(copy) =
+        GST_VAAPI_SURFACE_PROXY_FLAGS(proxy);
+
+    copy->parent = gst_vaapi_surface_proxy_ref(proxy->parent ?
+        proxy->parent : proxy);
+    copy->pool = gst_vaapi_video_pool_ref(proxy->pool);
+    copy->surface = gst_vaapi_object_ref(proxy->surface);
+    copy->timestamp = proxy->timestamp;
+    copy->duration = proxy->duration;
+    copy->destroy_func = NULL;
+    copy->has_crop_rect = proxy->has_crop_rect;
+    if (copy->has_crop_rect)
+        copy->crop_rect = proxy->crop_rect;
+    return copy;
+}
+
 /**
  * gst_vaapi_surface_proxy_ref:
  * @proxy: a #GstVaapiSurfaceProxy
diff --git a/gst-libs/gst/vaapi/gstvaapisurfaceproxy.h b/gst-libs/gst/vaapi/gstvaapisurfaceproxy.h
index c47143b..1b05af0 100644
--- a/gst-libs/gst/vaapi/gstvaapisurfaceproxy.h
+++ b/gst-libs/gst/vaapi/gstvaapisurfaceproxy.h
@@ -91,6 +91,9 @@ GstVaapiSurfaceProxy *
 gst_vaapi_surface_proxy_new_from_pool(GstVaapiSurfacePool *pool);
 
 GstVaapiSurfaceProxy *
+gst_vaapi_surface_proxy_copy(GstVaapiSurfaceProxy *proxy);
+
+GstVaapiSurfaceProxy *
 gst_vaapi_surface_proxy_ref(GstVaapiSurfaceProxy *proxy);
 
 void
diff --git a/gst-libs/gst/vaapi/gstvaapisurfaceproxy_priv.h b/gst-libs/gst/vaapi/gstvaapisurfaceproxy_priv.h
index d3674a7..a74cddf 100644
--- a/gst-libs/gst/vaapi/gstvaapisurfaceproxy_priv.h
+++ b/gst-libs/gst/vaapi/gstvaapisurfaceproxy_priv.h
@@ -36,6 +36,7 @@
 struct _GstVaapiSurfaceProxy {
     /*< private >*/
     GstVaapiMiniObject  parent_instance;
+    GstVaapiSurfaceProxy *parent;
 
     GstVaapiVideoPool  *pool;
     GstVaapiSurface    *surface;

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-gstreamer/gstreamer-vaapi.git



More information about the Pkg-gstreamer-commits mailing list