summaryrefslogtreecommitdiff
path: root/gst-libs/gst/vaapi/gstvaapicontext.c
diff options
context:
space:
mode:
authorGwenole Beauchesne <gwenole.beauchesne@intel.com>2013-04-03 11:37:44 +0200
committerGwenole Beauchesne <gwenole.beauchesne@intel.com>2013-04-03 13:34:59 +0200
commite22a863084eff8a6ceaeb2c5a327da17eccbd62f (patch)
tree7852ce2b2b2d95e2f29ea2531cfc75e3b64ab494 /gst-libs/gst/vaapi/gstvaapicontext.c
parente76089f98b139aa46e6eb009d4c5a37114f67786 (diff)
downloadgst-vaapi-e22a863084eff8a6ceaeb2c5a327da17eccbd62f.tar.gz
decoder: simplify acquisition/release of spare surface.
Introduce gst_vaapi_surface_proxy_new_from_pool() to allocate a new surface proxy from the context surface pool. This change also makes sure to retain the parent surface pool in the proxy. Besides, it was also totally useless to attach/detach parent context to VA surface each time we acquire/release it. Since the whole context owns all associated VA surfaces, we can mark this as such only once and for all.
Diffstat (limited to 'gst-libs/gst/vaapi/gstvaapicontext.c')
-rw-r--r--gst-libs/gst/vaapi/gstvaapicontext.c36
1 files changed, 27 insertions, 9 deletions
diff --git a/gst-libs/gst/vaapi/gstvaapicontext.c b/gst-libs/gst/vaapi/gstvaapicontext.c
index 8d5a6d1d..44cafc46 100644
--- a/gst-libs/gst/vaapi/gstvaapicontext.c
+++ b/gst-libs/gst/vaapi/gstvaapicontext.c
@@ -32,6 +32,7 @@
#include "gstvaapisurface.h"
#include "gstvaapisurface_priv.h"
#include "gstvaapisurfacepool.h"
+#include "gstvaapisurfaceproxy.h"
#include "gstvaapiimage.h"
#include "gstvaapisubpicture.h"
#include "gstvaapiminiobject.h"
@@ -503,6 +504,7 @@ gst_vaapi_context_create_surfaces(GstVaapiContext *context)
);
if (!surface)
return FALSE;
+ gst_vaapi_surface_set_parent_context(surface, context);
g_ptr_array_add(priv->surfaces, surface);
if (!gst_vaapi_video_pool_add_object(priv->surfaces_pool, surface))
return FALSE;
@@ -999,6 +1001,30 @@ gst_vaapi_context_get_size(
}
/**
+ * gst_vaapi_context_get_surface_proxy:
+ * @context: a #GstVaapiContext
+ *
+ * Acquires a free surface, wrapped into a #GstVaapiSurfaceProxy. The
+ * returned surface will be automatically released when the proxy is
+ * destroyed. So, it is enough to call gst_vaapi_surface_proxy_unref()
+ * after usage.
+ *
+ * This function returns %NULL if there is no free surface available
+ * in the pool. The surfaces are pre-allocated during context creation
+ * though.
+ *
+ * Return value: a free surface, or %NULL if none is available
+ */
+GstVaapiSurfaceProxy *
+gst_vaapi_context_get_surface_proxy(GstVaapiContext *context)
+{
+ g_return_val_if_fail(GST_VAAPI_IS_CONTEXT(context), NULL);
+
+ return gst_vaapi_surface_proxy_new_from_pool(
+ GST_VAAPI_SURFACE_POOL(context->priv->surfaces_pool));
+}
+
+/**
* gst_vaapi_context_get_surface:
* @context: a #GstVaapiContext
*
@@ -1012,16 +1038,9 @@ gst_vaapi_context_get_size(
GstVaapiSurface *
gst_vaapi_context_get_surface(GstVaapiContext *context)
{
- GstVaapiSurface *surface;
-
g_return_val_if_fail(GST_VAAPI_IS_CONTEXT(context), NULL);
- surface = gst_vaapi_video_pool_get_object(context->priv->surfaces_pool);
- if (!surface)
- return NULL;
-
- gst_vaapi_surface_set_parent_context(surface, context);
- return surface;
+ return gst_vaapi_video_pool_get_object(context->priv->surfaces_pool);
}
/**
@@ -1053,7 +1072,6 @@ gst_vaapi_context_put_surface(GstVaapiContext *context, GstVaapiSurface *surface
g_return_if_fail(GST_VAAPI_IS_CONTEXT(context));
g_return_if_fail(GST_VAAPI_IS_SURFACE(surface));
- gst_vaapi_surface_set_parent_context(surface, NULL);
gst_vaapi_video_pool_put_object(context->priv->surfaces_pool, surface);
}