mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-09 07:52:36 +00:00
Add support for GstVaapiSurfaceProxy to GstVaapiVideoBuffer.
This commit is contained in:
parent
0596777703
commit
a1fddf8bcc
2 changed files with 93 additions and 5 deletions
|
@ -39,11 +39,12 @@ G_DEFINE_TYPE(GstVaapiVideoBuffer, gst_vaapi_video_buffer, GST_TYPE_BUFFER);
|
||||||
GstVaapiVideoBufferPrivate))
|
GstVaapiVideoBufferPrivate))
|
||||||
|
|
||||||
struct _GstVaapiVideoBufferPrivate {
|
struct _GstVaapiVideoBufferPrivate {
|
||||||
GstVaapiVideoPool *image_pool;
|
GstVaapiVideoPool *image_pool;
|
||||||
GstVaapiImage *image;
|
GstVaapiImage *image;
|
||||||
GstVaapiVideoPool *surface_pool;
|
GstVaapiVideoPool *surface_pool;
|
||||||
GstVaapiSurface *surface;
|
GstVaapiSurface *surface;
|
||||||
guint flags;
|
GstVaapiSurfaceProxy *proxy;
|
||||||
|
guint flags;
|
||||||
};
|
};
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -70,6 +71,11 @@ gst_vaapi_video_buffer_destroy_surface(GstVaapiVideoBuffer *buffer)
|
||||||
{
|
{
|
||||||
GstVaapiVideoBufferPrivate * const priv = buffer->priv;
|
GstVaapiVideoBufferPrivate * const priv = buffer->priv;
|
||||||
|
|
||||||
|
if (priv->proxy) {
|
||||||
|
g_object_unref(priv->proxy);
|
||||||
|
priv->proxy = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
if (priv->surface) {
|
if (priv->surface) {
|
||||||
if (priv->surface_pool)
|
if (priv->surface_pool)
|
||||||
gst_vaapi_video_pool_put_object(priv->surface_pool, priv->surface);
|
gst_vaapi_video_pool_put_object(priv->surface_pool, priv->surface);
|
||||||
|
@ -119,6 +125,7 @@ gst_vaapi_video_buffer_init(GstVaapiVideoBuffer *buffer)
|
||||||
priv->image = NULL;
|
priv->image = NULL;
|
||||||
priv->surface_pool = NULL;
|
priv->surface_pool = NULL;
|
||||||
priv->surface = NULL;
|
priv->surface = NULL;
|
||||||
|
priv->proxy = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline GstVaapiVideoBuffer *
|
static inline GstVaapiVideoBuffer *
|
||||||
|
@ -215,6 +222,28 @@ gst_vaapi_video_buffer_new_with_surface(GstVaapiSurface *surface)
|
||||||
return GST_BUFFER(buffer);
|
return GST_BUFFER(buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gst_vaapi_video_buffer_new_with_surface_proxy:
|
||||||
|
* @proxy: a #GstVaapiSurfaceProxy
|
||||||
|
*
|
||||||
|
* Creates a #GstBuffer with the specified surface @proxy. The
|
||||||
|
* resulting buffer holds an additional reference to the @proxy.
|
||||||
|
*
|
||||||
|
* Return value: the newly allocated #GstBuffer, or %NULL on error
|
||||||
|
*/
|
||||||
|
GstBuffer *
|
||||||
|
gst_vaapi_video_buffer_new_with_surface_proxy(GstVaapiSurfaceProxy *proxy)
|
||||||
|
{
|
||||||
|
GstVaapiVideoBuffer *buffer;
|
||||||
|
|
||||||
|
g_return_val_if_fail(GST_VAAPI_IS_SURFACE_PROXY(proxy), NULL);
|
||||||
|
|
||||||
|
buffer = gst_vaapi_video_buffer_new();
|
||||||
|
if (buffer)
|
||||||
|
gst_vaapi_video_buffer_set_surface_proxy(buffer, proxy);
|
||||||
|
return GST_BUFFER(buffer);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* gst_vaapi_video_buffer_get_image:
|
* gst_vaapi_video_buffer_get_image:
|
||||||
* @buffer: a #GstVaapiVideoBuffer
|
* @buffer: a #GstVaapiVideoBuffer
|
||||||
|
@ -362,3 +391,49 @@ gst_vaapi_video_buffer_set_surface_from_pool(
|
||||||
}
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gst_vaapi_video_buffer_get_surface_proxy:
|
||||||
|
* @buffer: a #GstVaapiVideoBuffer
|
||||||
|
*
|
||||||
|
* Retrieves the #GstVaapiSurfaceProxy bound to the @buffer. The @buffer
|
||||||
|
* owns the #GstVaapiSurfaceProxy so the caller is responsible for calling
|
||||||
|
* g_object_ref() when needed.
|
||||||
|
*
|
||||||
|
* Return value: the #GstVaapiSurfaceProxy bound to the @buffer, or
|
||||||
|
* %NULL if there is none
|
||||||
|
*/
|
||||||
|
GstVaapiSurfaceProxy *
|
||||||
|
gst_vaapi_video_buffer_get_surface_proxy(GstVaapiVideoBuffer *buffer)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail(GST_VAAPI_IS_VIDEO_BUFFER(buffer), NULL);
|
||||||
|
|
||||||
|
return buffer->priv->proxy;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gst_vaapi_video_buffer_set_surface_proxy:
|
||||||
|
* @buffer: a #GstVaapiVideoBuffer
|
||||||
|
* @proxy: a #GstVaapiSurfaceProxy
|
||||||
|
*
|
||||||
|
* Binds surface @proxy to the @buffer. If the @buffer contains another
|
||||||
|
* surface previously allocated from a pool, it's pushed back to its
|
||||||
|
* parent pool and the pool is also released.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
gst_vaapi_video_buffer_set_surface_proxy(
|
||||||
|
GstVaapiVideoBuffer *buffer,
|
||||||
|
GstVaapiSurfaceProxy *proxy
|
||||||
|
)
|
||||||
|
{
|
||||||
|
g_return_if_fail(GST_VAAPI_IS_VIDEO_BUFFER(buffer));
|
||||||
|
g_return_if_fail(GST_VAAPI_IS_SURFACE_PROXY(proxy));
|
||||||
|
|
||||||
|
gst_vaapi_video_buffer_destroy_surface(buffer);
|
||||||
|
|
||||||
|
if (proxy) {
|
||||||
|
GstVaapiVideoBufferPrivate * const priv = buffer->priv;
|
||||||
|
priv->proxy = g_object_ref(proxy);
|
||||||
|
priv->surface = g_object_ref(GST_VAAPI_SURFACE_PROXY_SURFACE(proxy));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -24,6 +24,7 @@
|
||||||
#include <gst/gstbuffer.h>
|
#include <gst/gstbuffer.h>
|
||||||
#include <gst/vaapi/gstvaapiimage.h>
|
#include <gst/vaapi/gstvaapiimage.h>
|
||||||
#include <gst/vaapi/gstvaapisurface.h>
|
#include <gst/vaapi/gstvaapisurface.h>
|
||||||
|
#include <gst/vaapi/gstvaapisurfaceproxy.h>
|
||||||
#include <gst/vaapi/gstvaapivideopool.h>
|
#include <gst/vaapi/gstvaapivideopool.h>
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
|
@ -90,6 +91,9 @@ gst_vaapi_video_buffer_new_with_image(GstVaapiImage *image);
|
||||||
GstBuffer *
|
GstBuffer *
|
||||||
gst_vaapi_video_buffer_new_with_surface(GstVaapiSurface *surface);
|
gst_vaapi_video_buffer_new_with_surface(GstVaapiSurface *surface);
|
||||||
|
|
||||||
|
GstBuffer *
|
||||||
|
gst_vaapi_video_buffer_new_with_surface_proxy(GstVaapiSurfaceProxy *proxy);
|
||||||
|
|
||||||
GstVaapiImage *
|
GstVaapiImage *
|
||||||
gst_vaapi_video_buffer_get_image(GstVaapiVideoBuffer *buffer);
|
gst_vaapi_video_buffer_get_image(GstVaapiVideoBuffer *buffer);
|
||||||
|
|
||||||
|
@ -120,6 +124,15 @@ gst_vaapi_video_buffer_set_surface_from_pool(
|
||||||
GstVaapiVideoPool *pool
|
GstVaapiVideoPool *pool
|
||||||
);
|
);
|
||||||
|
|
||||||
|
GstVaapiSurfaceProxy *
|
||||||
|
gst_vaapi_video_buffer_get_surface_proxy(GstVaapiVideoBuffer *buffer);
|
||||||
|
|
||||||
|
void
|
||||||
|
gst_vaapi_video_buffer_set_surface_proxy(
|
||||||
|
GstVaapiVideoBuffer *buffer,
|
||||||
|
GstVaapiSurfaceProxy *proxy
|
||||||
|
);
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
#endif /* GST_VAAPI_VIDEO_BUFFER_H */
|
#endif /* GST_VAAPI_VIDEO_BUFFER_H */
|
||||||
|
|
Loading…
Reference in a new issue