libs: surface: port to GstMiniObject

GstVaapiMiniObject and GstVaapiObject are deprecated.

This is the first step to remove them by porting GstVaapiSurface as
a GstMiniBuffer descendant.

Signed-off-by: Víctor Manuel Jáquez Leal <vjaquez@igalia.com>
This commit is contained in:
He Junyan 2019-12-19 14:19:10 +01:00 committed by GStreamer Merge Bot
parent e398f2c245
commit 608ce681e5
28 changed files with 205 additions and 150 deletions

View file

@ -24,6 +24,7 @@
#include "gstvaapicompat.h" #include "gstvaapicompat.h"
#include "gstvaapibufferproxy.h" #include "gstvaapibufferproxy.h"
#include "gstvaapibufferproxy_priv.h" #include "gstvaapibufferproxy_priv.h"
#include "gstvaapisurface_priv.h"
#include "gstvaapiutils.h" #include "gstvaapiutils.h"
#include "gstvaapiobject_priv.h" #include "gstvaapiobject_priv.h"
@ -33,6 +34,7 @@
static gboolean static gboolean
gst_vaapi_buffer_proxy_acquire_handle (GstVaapiBufferProxy * proxy) gst_vaapi_buffer_proxy_acquire_handle (GstVaapiBufferProxy * proxy)
{ {
GstVaapiDisplay *display;
const guint mem_type = proxy->va_info.mem_type; const guint mem_type = proxy->va_info.mem_type;
VAStatus va_status; VAStatus va_status;
@ -42,10 +44,13 @@ gst_vaapi_buffer_proxy_acquire_handle (GstVaapiBufferProxy * proxy)
if (!proxy->parent || proxy->va_buf == VA_INVALID_ID) if (!proxy->parent || proxy->va_buf == VA_INVALID_ID)
return FALSE; return FALSE;
GST_VAAPI_OBJECT_LOCK_DISPLAY (proxy->parent); /* @XXX(victor): parent might be not a surface */
va_status = vaAcquireBufferHandle (GST_VAAPI_OBJECT_VADISPLAY (proxy->parent), display = GST_VAAPI_SURFACE_DISPLAY (GST_VAAPI_SURFACE (proxy->parent));
GST_VAAPI_DISPLAY_LOCK (display);
va_status = vaAcquireBufferHandle (GST_VAAPI_DISPLAY_VADISPLAY (display),
proxy->va_buf, &proxy->va_info); proxy->va_buf, &proxy->va_info);
GST_VAAPI_OBJECT_UNLOCK_DISPLAY (proxy->parent); GST_VAAPI_DISPLAY_UNLOCK (display);
if (!vaapi_check_status (va_status, "vaAcquireBufferHandle()")) if (!vaapi_check_status (va_status, "vaAcquireBufferHandle()"))
return FALSE; return FALSE;
if (proxy->va_info.mem_type != mem_type) if (proxy->va_info.mem_type != mem_type)
@ -56,6 +61,7 @@ gst_vaapi_buffer_proxy_acquire_handle (GstVaapiBufferProxy * proxy)
static gboolean static gboolean
gst_vaapi_buffer_proxy_release_handle (GstVaapiBufferProxy * proxy) gst_vaapi_buffer_proxy_release_handle (GstVaapiBufferProxy * proxy)
{ {
GstVaapiDisplay *display;
VAStatus va_status; VAStatus va_status;
if (!proxy->va_info.handle) if (!proxy->va_info.handle)
@ -64,10 +70,13 @@ gst_vaapi_buffer_proxy_release_handle (GstVaapiBufferProxy * proxy)
if (!proxy->parent || proxy->va_buf == VA_INVALID_ID) if (!proxy->parent || proxy->va_buf == VA_INVALID_ID)
return FALSE; return FALSE;
GST_VAAPI_OBJECT_LOCK_DISPLAY (proxy->parent); /* @XXX(victor): parent might be not a surface */
va_status = vaReleaseBufferHandle (GST_VAAPI_OBJECT_VADISPLAY (proxy->parent), display = GST_VAAPI_SURFACE_DISPLAY (GST_VAAPI_SURFACE (proxy->parent));
GST_VAAPI_DISPLAY_LOCK (display);
va_status = vaReleaseBufferHandle (GST_VAAPI_DISPLAY_VADISPLAY (display),
proxy->va_buf); proxy->va_buf);
GST_VAAPI_OBJECT_UNLOCK_DISPLAY (proxy->parent); GST_VAAPI_DISPLAY_UNLOCK (display);
if (!vaapi_check_status (va_status, "vaReleaseBufferHandle()")) if (!vaapi_check_status (va_status, "vaReleaseBufferHandle()"))
return FALSE; return FALSE;
return TRUE; return TRUE;
@ -87,7 +96,7 @@ gst_vaapi_buffer_proxy_finalize (GstVaapiBufferProxy * proxy)
if (proxy->destroy_func) if (proxy->destroy_func)
proxy->destroy_func (proxy->destroy_data); proxy->destroy_func (proxy->destroy_data);
gst_vaapi_object_replace (&proxy->parent, NULL); gst_mini_object_replace ((GstMiniObject **) & proxy->parent, NULL);
} }
static inline const GstVaapiMiniObjectClass * static inline const GstVaapiMiniObjectClass *
@ -138,7 +147,7 @@ error_unsupported_mem_type:
} }
GstVaapiBufferProxy * GstVaapiBufferProxy *
gst_vaapi_buffer_proxy_new_from_object (GstVaapiObject * object, gst_vaapi_buffer_proxy_new_from_object (GstMiniObject * object,
VABufferID buf_id, guint type, GDestroyNotify destroy_func, gpointer data) VABufferID buf_id, guint type, GDestroyNotify destroy_func, gpointer data)
{ {
GstVaapiBufferProxy *proxy; GstVaapiBufferProxy *proxy;
@ -150,7 +159,7 @@ gst_vaapi_buffer_proxy_new_from_object (GstVaapiObject * object,
if (!proxy) if (!proxy)
return NULL; return NULL;
proxy->parent = gst_vaapi_object_ref (object); proxy->parent = gst_mini_object_ref (object);
proxy->destroy_func = destroy_func; proxy->destroy_func = destroy_func;
proxy->destroy_data = data; proxy->destroy_data = data;
proxy->type = type; proxy->type = type;

View file

@ -62,7 +62,7 @@ G_BEGIN_DECLS
struct _GstVaapiBufferProxy { struct _GstVaapiBufferProxy {
/*< private >*/ /*< private >*/
GstVaapiMiniObject parent_instance; GstVaapiMiniObject parent_instance;
GstVaapiObject *parent; GstMiniObject *parent;
GDestroyNotify destroy_func; GDestroyNotify destroy_func;
gpointer destroy_data; gpointer destroy_data;
@ -74,7 +74,7 @@ struct _GstVaapiBufferProxy {
G_GNUC_INTERNAL G_GNUC_INTERNAL
GstVaapiBufferProxy * GstVaapiBufferProxy *
gst_vaapi_buffer_proxy_new_from_object (GstVaapiObject * object, gst_vaapi_buffer_proxy_new_from_object (GstMiniObject * object,
VABufferID buf_id, guint type, GDestroyNotify destroy_func, gpointer data); VABufferID buf_id, guint type, GDestroyNotify destroy_func, gpointer data);
G_GNUC_INTERNAL G_GNUC_INTERNAL

View file

@ -147,7 +147,7 @@ context_create_surfaces (GstVaapiContext * context)
num_surfaces = cip->ref_frames + SCRATCH_SURFACES_COUNT; num_surfaces = cip->ref_frames + SCRATCH_SURFACES_COUNT;
if (!context->surfaces) { if (!context->surfaces) {
context->surfaces = g_ptr_array_new_full (num_surfaces, context->surfaces = g_ptr_array_new_full (num_surfaces,
(GDestroyNotify) gst_vaapi_object_unref); (GDestroyNotify) gst_mini_object_unref);
if (!context->surfaces) if (!context->surfaces)
return FALSE; return FALSE;
} }
@ -188,7 +188,7 @@ context_create (GstVaapiContext * context)
GstVaapiSurface *const surface = g_ptr_array_index (context->surfaces, i); GstVaapiSurface *const surface = g_ptr_array_index (context->surfaces, i);
if (!surface) if (!surface)
goto cleanup; goto cleanup;
surface_id = GST_VAAPI_OBJECT_ID (surface); surface_id = GST_VAAPI_SURFACE_ID (surface);
g_array_append_val (surfaces, surface_id); g_array_append_val (surfaces, surface_id);
} }
g_assert (surfaces->len == context->surfaces->len); g_assert (surfaces->len == context->surfaces->len);

View file

@ -3833,7 +3833,7 @@ create_context_for_enc (GstVaapiEncoder * fei_encoder,
GstVaapiSurface *const surface = g_ptr_array_index (context->surfaces, i); GstVaapiSurface *const surface = g_ptr_array_index (context->surfaces, i);
if (!surface) if (!surface)
goto cleanup; goto cleanup;
surface_id = GST_VAAPI_OBJECT_ID (surface); surface_id = GST_VAAPI_SURFACE_ID (surface);
g_array_append_val (surfaces, surface_id); g_array_append_val (surfaces, surface_id);
} }
g_assert (surfaces->len == context->surfaces->len); g_assert (surfaces->len == context->surfaces->len);

View file

@ -386,7 +386,7 @@ gst_vaapi_enc_picture_create (GstVaapiEncPicture * picture,
if (!picture->surface) if (!picture->surface)
return FALSE; return FALSE;
picture->surface_id = GST_VAAPI_OBJECT_ID (picture->surface); picture->surface_id = GST_VAAPI_SURFACE_ID (picture->surface);
if (picture->surface_id == VA_INVALID_ID) if (picture->surface_id == VA_INVALID_ID)
return FALSE; return FALSE;

View file

@ -1124,7 +1124,7 @@ deint_refs_set (GArray * refs, GstVaapiSurface ** surfaces, guint num_surfaces)
return FALSE; return FALSE;
for (i = 0; i < num_surfaces; i++) for (i = 0; i < num_surfaces; i++)
g_array_append_val (refs, GST_VAAPI_OBJECT_ID (surfaces[i])); g_array_append_val (refs, GST_VAAPI_SURFACE_ID (surfaces[i]));
return TRUE; return TRUE;
} }
@ -1617,7 +1617,7 @@ gst_vaapi_filter_process_unlocked (GstVaapiFilter * filter,
goto error; goto error;
memset (pipeline_param, 0, sizeof (*pipeline_param)); memset (pipeline_param, 0, sizeof (*pipeline_param));
pipeline_param->surface = GST_VAAPI_OBJECT_ID (src_surface); pipeline_param->surface = GST_VAAPI_SURFACE_ID (src_surface);
pipeline_param->surface_region = &src_rect; pipeline_param->surface_region = &src_rect;
pipeline_param->surface_color_standard = VAProcColorStandardNone; pipeline_param->surface_color_standard = VAProcColorStandardNone;
pipeline_param->output_region = &dst_rect; pipeline_param->output_region = &dst_rect;
@ -1662,7 +1662,7 @@ gst_vaapi_filter_process_unlocked (GstVaapiFilter * filter,
vaapi_unmap_buffer (filter->va_display, pipeline_param_buf_id, NULL); vaapi_unmap_buffer (filter->va_display, pipeline_param_buf_id, NULL);
va_status = vaBeginPicture (filter->va_display, filter->va_context, va_status = vaBeginPicture (filter->va_display, filter->va_context,
GST_VAAPI_OBJECT_ID (dst_surface)); GST_VAAPI_SURFACE_ID (dst_surface));
if (!vaapi_check_status (va_status, "vaBeginPicture()")) if (!vaapi_check_status (va_status, "vaBeginPicture()"))
goto error; goto error;

View file

@ -124,7 +124,7 @@ gst_vaapi_pixmap_x11_render (GstVaapiPixmap * pixmap, GstVaapiSurface * surface,
VASurfaceID surface_id; VASurfaceID surface_id;
VAStatus status; VAStatus status;
surface_id = GST_VAAPI_OBJECT_ID (surface); surface_id = GST_VAAPI_SURFACE_ID (surface);
if (surface_id == VA_INVALID_ID) if (surface_id == VA_INVALID_ID)
return FALSE; return FALSE;

View file

@ -34,6 +34,7 @@
#include "gstvaapisurface_priv.h" #include "gstvaapisurface_priv.h"
#include "gstvaapicontext.h" #include "gstvaapicontext.h"
#include "gstvaapiimage.h" #include "gstvaapiimage.h"
#include "gstvaapiimage_priv.h"
#include "gstvaapibufferproxy_priv.h" #include "gstvaapibufferproxy_priv.h"
#define DEBUG 1 #define DEBUG 1
@ -66,13 +67,13 @@ gst_vaapi_surface_destroy_subpictures (GstVaapiSurface * surface)
} }
static void static void
gst_vaapi_surface_destroy (GstVaapiSurface * surface) gst_vaapi_surface_free (GstVaapiSurface * surface)
{ {
GstVaapiDisplay *const display = GST_VAAPI_OBJECT_DISPLAY (surface); GstVaapiDisplay *const display = GST_VAAPI_SURFACE_DISPLAY (surface);
VASurfaceID surface_id; VASurfaceID surface_id;
VAStatus status; VAStatus status;
surface_id = GST_VAAPI_OBJECT_ID (surface); surface_id = GST_VAAPI_SURFACE_ID (surface);
GST_DEBUG ("surface %" GST_VAAPI_ID_FORMAT, GST_VAAPI_ID_ARGS (surface_id)); GST_DEBUG ("surface %" GST_VAAPI_ID_FORMAT, GST_VAAPI_ID_ARGS (surface_id));
gst_vaapi_surface_destroy_subpictures (surface); gst_vaapi_surface_destroy_subpictures (surface);
@ -85,16 +86,19 @@ gst_vaapi_surface_destroy (GstVaapiSurface * surface)
if (!vaapi_check_status (status, "vaDestroySurfaces()")) if (!vaapi_check_status (status, "vaDestroySurfaces()"))
GST_WARNING ("failed to destroy surface %" GST_VAAPI_ID_FORMAT, GST_WARNING ("failed to destroy surface %" GST_VAAPI_ID_FORMAT,
GST_VAAPI_ID_ARGS (surface_id)); GST_VAAPI_ID_ARGS (surface_id));
GST_VAAPI_OBJECT_ID (surface) = VA_INVALID_SURFACE; GST_VAAPI_SURFACE_ID (surface) = VA_INVALID_SURFACE;
} }
gst_vaapi_buffer_proxy_replace (&surface->extbuf_proxy, NULL); gst_vaapi_buffer_proxy_replace (&surface->extbuf_proxy, NULL);
gst_vaapi_display_replace (&GST_VAAPI_SURFACE_DISPLAY (surface), NULL);
g_slice_free1 (sizeof (GstVaapiSurface), surface);
} }
static gboolean static gboolean
gst_vaapi_surface_init (GstVaapiSurface * surface, gst_vaapi_surface_init (GstVaapiSurface * surface,
GstVaapiChromaType chroma_type, guint width, guint height) GstVaapiChromaType chroma_type, guint width, guint height)
{ {
GstVaapiDisplay *const display = GST_VAAPI_OBJECT_DISPLAY (surface); GstVaapiDisplay *const display = GST_VAAPI_SURFACE_DISPLAY (surface);
VASurfaceID surface_id; VASurfaceID surface_id;
VAStatus status; VAStatus status;
guint va_chroma_format; guint va_chroma_format;
@ -116,7 +120,7 @@ gst_vaapi_surface_init (GstVaapiSurface * surface,
GST_VAAPI_SURFACE_HEIGHT (surface) = height; GST_VAAPI_SURFACE_HEIGHT (surface) = height;
GST_DEBUG ("surface %" GST_VAAPI_ID_FORMAT, GST_VAAPI_ID_ARGS (surface_id)); GST_DEBUG ("surface %" GST_VAAPI_ID_FORMAT, GST_VAAPI_ID_ARGS (surface_id));
GST_VAAPI_OBJECT_ID (surface) = surface_id; GST_VAAPI_SURFACE_ID (surface) = surface_id;
return TRUE; return TRUE;
/* ERRORS */ /* ERRORS */
@ -129,7 +133,7 @@ static gboolean
gst_vaapi_surface_init_full (GstVaapiSurface * surface, gst_vaapi_surface_init_full (GstVaapiSurface * surface,
const GstVideoInfo * vip, guint flags) const GstVideoInfo * vip, guint flags)
{ {
GstVaapiDisplay *const display = GST_VAAPI_OBJECT_DISPLAY (surface); GstVaapiDisplay *const display = GST_VAAPI_SURFACE_DISPLAY (surface);
const GstVideoFormat format = GST_VIDEO_INFO_FORMAT (vip); const GstVideoFormat format = GST_VIDEO_INFO_FORMAT (vip);
VASurfaceID surface_id; VASurfaceID surface_id;
VAStatus status; VAStatus status;
@ -207,7 +211,7 @@ gst_vaapi_surface_init_full (GstVaapiSurface * surface,
GST_VAAPI_SURFACE_HEIGHT (surface) = extbuf.height; GST_VAAPI_SURFACE_HEIGHT (surface) = extbuf.height;
GST_DEBUG ("surface %" GST_VAAPI_ID_FORMAT, GST_VAAPI_ID_ARGS (surface_id)); GST_DEBUG ("surface %" GST_VAAPI_ID_FORMAT, GST_VAAPI_ID_ARGS (surface_id));
GST_VAAPI_OBJECT_ID (surface) = surface_id; GST_VAAPI_SURFACE_ID (surface) = surface_id;
return TRUE; return TRUE;
/* ERRORS */ /* ERRORS */
@ -221,7 +225,7 @@ static gboolean
gst_vaapi_surface_init_from_buffer_proxy (GstVaapiSurface * surface, gst_vaapi_surface_init_from_buffer_proxy (GstVaapiSurface * surface,
GstVaapiBufferProxy * proxy, const GstVideoInfo * vip) GstVaapiBufferProxy * proxy, const GstVideoInfo * vip)
{ {
GstVaapiDisplay *const display = GST_VAAPI_OBJECT_DISPLAY (surface); GstVaapiDisplay *const display = GST_VAAPI_SURFACE_DISPLAY (surface);
GstVideoFormat format; GstVideoFormat format;
VASurfaceID surface_id; VASurfaceID surface_id;
VAStatus status; VAStatus status;
@ -292,7 +296,7 @@ gst_vaapi_surface_init_from_buffer_proxy (GstVaapiSurface * surface,
GST_VAAPI_SURFACE_HEIGHT (surface) = height; GST_VAAPI_SURFACE_HEIGHT (surface) = height;
GST_DEBUG ("surface %" GST_VAAPI_ID_FORMAT, GST_VAAPI_ID_ARGS (surface_id)); GST_DEBUG ("surface %" GST_VAAPI_ID_FORMAT, GST_VAAPI_ID_ARGS (surface_id));
GST_VAAPI_OBJECT_ID (surface) = surface_id; GST_VAAPI_SURFACE_ID (surface) = surface_id;
return TRUE; return TRUE;
/* ERRORS */ /* ERRORS */
@ -302,8 +306,41 @@ error_unsupported_format:
return FALSE; return FALSE;
} }
#define gst_vaapi_surface_finalize gst_vaapi_surface_destroy GST_DEFINE_MINI_OBJECT_TYPE (GstVaapiSurface, gst_vaapi_surface);
GST_VAAPI_OBJECT_DEFINE_CLASS (GstVaapiSurface, gst_vaapi_surface);
static GstVaapiSurface *
gst_vaapi_surface_create (GstVaapiDisplay * display)
{
GstVaapiSurface *surface = g_slice_new (GstVaapiSurface);
if (!surface)
return NULL;
gst_mini_object_init (GST_MINI_OBJECT_CAST (surface), 0,
GST_TYPE_VAAPI_SURFACE, NULL, NULL,
(GstMiniObjectFreeFunction) gst_vaapi_surface_free);
GST_VAAPI_SURFACE_DISPLAY (surface) = gst_object_ref (display);
GST_VAAPI_SURFACE_ID (surface) = VA_INVALID_ID;
surface->extbuf_proxy = NULL;
surface->subpictures = NULL;
return surface;
}
/**
* gst_vaapi_surface_get_display:
* @surface: a #GstVaapiSurface
*
* Returns the #GstVaapiDisplay this @surface is bound to.
*
* Return value: the parent #GstVaapiDisplay object
*/
GstVaapiDisplay *
gst_vaapi_surface_get_display (GstVaapiSurface * surface)
{
g_return_val_if_fail (surface != NULL, NULL);
return GST_VAAPI_SURFACE_DISPLAY (surface);
}
/** /**
* gst_vaapi_surface_new_from_formats: * gst_vaapi_surface_new_from_formats:
@ -336,7 +373,7 @@ gst_vaapi_surface_new_from_formats (GstVaapiDisplay * display,
/* Fallback: if there's no format valid for the chroma type let's /* Fallback: if there's no format valid for the chroma type let's
* just use the passed chroma */ * just use the passed chroma */
surface = gst_vaapi_object_new (gst_vaapi_surface_class (), display); surface = gst_vaapi_surface_create (display);
if (!surface) if (!surface)
return NULL; return NULL;
if (!gst_vaapi_surface_init (surface, chroma_type, width, height)) if (!gst_vaapi_surface_init (surface, chroma_type, width, height))
@ -347,7 +384,7 @@ gst_vaapi_surface_new_from_formats (GstVaapiDisplay * display,
/* ERRORS */ /* ERRORS */
error: error:
{ {
gst_vaapi_object_unref (surface); gst_vaapi_surface_unref (surface);
return NULL; return NULL;
} }
} }
@ -372,7 +409,7 @@ gst_vaapi_surface_new (GstVaapiDisplay * display,
GST_DEBUG ("size %ux%u, chroma type 0x%x", width, height, chroma_type); GST_DEBUG ("size %ux%u, chroma type 0x%x", width, height, chroma_type);
surface = gst_vaapi_object_new (gst_vaapi_surface_class (), display); surface = gst_vaapi_surface_create (display);
if (!surface) if (!surface)
return NULL; return NULL;
@ -395,7 +432,7 @@ gst_vaapi_surface_new (GstVaapiDisplay * display,
/* ERRORS */ /* ERRORS */
error: error:
{ {
gst_vaapi_object_unref (surface); gst_vaapi_surface_unref (surface);
return NULL; return NULL;
} }
} }
@ -423,7 +460,7 @@ gst_vaapi_surface_new_full (GstVaapiDisplay * display,
GST_VIDEO_INFO_HEIGHT (vip), GST_VIDEO_INFO_HEIGHT (vip),
gst_vaapi_video_format_to_string (GST_VIDEO_INFO_FORMAT (vip)), flags); gst_vaapi_video_format_to_string (GST_VIDEO_INFO_FORMAT (vip)), flags);
surface = gst_vaapi_object_new (gst_vaapi_surface_class (), display); surface = gst_vaapi_surface_create (display);
if (!surface) if (!surface)
return NULL; return NULL;
@ -434,7 +471,7 @@ gst_vaapi_surface_new_full (GstVaapiDisplay * display,
/* ERRORS */ /* ERRORS */
error: error:
{ {
gst_vaapi_object_unref (surface); gst_vaapi_surface_unref (surface);
return NULL; return NULL;
} }
} }
@ -489,7 +526,7 @@ gst_vaapi_surface_new_from_buffer_proxy (GstVaapiDisplay * display,
g_return_val_if_fail (proxy != NULL, NULL); g_return_val_if_fail (proxy != NULL, NULL);
g_return_val_if_fail (info != NULL, NULL); g_return_val_if_fail (info != NULL, NULL);
surface = gst_vaapi_object_new (gst_vaapi_surface_class (), display); surface = gst_vaapi_surface_create (display);
if (!surface) if (!surface)
return NULL; return NULL;
@ -500,7 +537,7 @@ gst_vaapi_surface_new_from_buffer_proxy (GstVaapiDisplay * display,
/* ERRORS */ /* ERRORS */
error: error:
{ {
gst_vaapi_object_unref (surface); gst_vaapi_surface_unref (surface);
return NULL; return NULL;
} }
} }
@ -518,7 +555,7 @@ gst_vaapi_surface_get_id (GstVaapiSurface * surface)
{ {
g_return_val_if_fail (surface != NULL, VA_INVALID_SURFACE); g_return_val_if_fail (surface != NULL, VA_INVALID_SURFACE);
return GST_VAAPI_OBJECT_ID (surface); return GST_VAAPI_SURFACE_ID (surface);
} }
/** /**
@ -652,13 +689,13 @@ gst_vaapi_surface_derive_image (GstVaapiSurface * surface)
g_return_val_if_fail (surface != NULL, NULL); g_return_val_if_fail (surface != NULL, NULL);
display = GST_VAAPI_OBJECT_DISPLAY (surface); display = GST_VAAPI_SURFACE_DISPLAY (surface);
va_image.image_id = VA_INVALID_ID; va_image.image_id = VA_INVALID_ID;
va_image.buf = VA_INVALID_ID; va_image.buf = VA_INVALID_ID;
GST_VAAPI_DISPLAY_LOCK (display); GST_VAAPI_DISPLAY_LOCK (display);
status = vaDeriveImage (GST_VAAPI_DISPLAY_VADISPLAY (display), status = vaDeriveImage (GST_VAAPI_DISPLAY_VADISPLAY (display),
GST_VAAPI_OBJECT_ID (surface), &va_image); GST_VAAPI_SURFACE_ID (surface), &va_image);
GST_VAAPI_DISPLAY_UNLOCK (display); GST_VAAPI_DISPLAY_UNLOCK (display);
if (!vaapi_check_status (status, "vaDeriveImage()")) if (!vaapi_check_status (status, "vaDeriveImage()"))
return NULL; return NULL;
@ -692,7 +729,7 @@ gst_vaapi_surface_get_image (GstVaapiSurface * surface, GstVaapiImage * image)
g_return_val_if_fail (surface != NULL, FALSE); g_return_val_if_fail (surface != NULL, FALSE);
g_return_val_if_fail (image != NULL, FALSE); g_return_val_if_fail (image != NULL, FALSE);
display = GST_VAAPI_OBJECT_DISPLAY (surface); display = GST_VAAPI_SURFACE_DISPLAY (surface);
if (!display) if (!display)
return FALSE; return FALSE;
@ -708,7 +745,7 @@ gst_vaapi_surface_get_image (GstVaapiSurface * surface, GstVaapiImage * image)
GST_VAAPI_DISPLAY_LOCK (display); GST_VAAPI_DISPLAY_LOCK (display);
status = vaGetImage (GST_VAAPI_DISPLAY_VADISPLAY (display), status = vaGetImage (GST_VAAPI_DISPLAY_VADISPLAY (display),
GST_VAAPI_OBJECT_ID (surface), 0, 0, width, height, image_id); GST_VAAPI_SURFACE_ID (surface), 0, 0, width, height, image_id);
GST_VAAPI_DISPLAY_UNLOCK (display); GST_VAAPI_DISPLAY_UNLOCK (display);
if (!vaapi_check_status (status, "vaGetImage()")) if (!vaapi_check_status (status, "vaGetImage()"))
return FALSE; return FALSE;
@ -737,7 +774,7 @@ gst_vaapi_surface_put_image (GstVaapiSurface * surface, GstVaapiImage * image)
g_return_val_if_fail (surface != NULL, FALSE); g_return_val_if_fail (surface != NULL, FALSE);
g_return_val_if_fail (image != NULL, FALSE); g_return_val_if_fail (image != NULL, FALSE);
display = GST_VAAPI_OBJECT_DISPLAY (surface); display = GST_VAAPI_SURFACE_DISPLAY (surface);
if (!display) if (!display)
return FALSE; return FALSE;
@ -753,8 +790,8 @@ gst_vaapi_surface_put_image (GstVaapiSurface * surface, GstVaapiImage * image)
GST_VAAPI_DISPLAY_LOCK (display); GST_VAAPI_DISPLAY_LOCK (display);
status = vaPutImage (GST_VAAPI_DISPLAY_VADISPLAY (display), status = vaPutImage (GST_VAAPI_DISPLAY_VADISPLAY (display),
GST_VAAPI_OBJECT_ID (surface), image_id, 0, 0, width, height, GST_VAAPI_SURFACE_ID (surface), image_id, 0, 0, width, height, 0, 0,
0, 0, width, height); width, height);
GST_VAAPI_DISPLAY_UNLOCK (display); GST_VAAPI_DISPLAY_UNLOCK (display);
if (!vaapi_check_status (status, "vaPutImage()")) if (!vaapi_check_status (status, "vaPutImage()"))
return FALSE; return FALSE;
@ -823,11 +860,11 @@ _gst_vaapi_surface_associate_subpicture (GstVaapiSurface * surface,
VASurfaceID surface_id; VASurfaceID surface_id;
VAStatus status; VAStatus status;
display = GST_VAAPI_OBJECT_DISPLAY (surface); display = GST_VAAPI_SURFACE_DISPLAY (surface);
if (!display) if (!display)
return FALSE; return FALSE;
surface_id = GST_VAAPI_OBJECT_ID (surface); surface_id = GST_VAAPI_SURFACE_ID (surface);
if (surface_id == VA_INVALID_SURFACE) if (surface_id == VA_INVALID_SURFACE)
return FALSE; return FALSE;
@ -890,7 +927,7 @@ gst_vaapi_surface_deassociate_subpicture (GstVaapiSurface * surface,
GST_DEBUG ("subpicture %" GST_VAAPI_ID_FORMAT " was not bound to " GST_DEBUG ("subpicture %" GST_VAAPI_ID_FORMAT " was not bound to "
"surface %" GST_VAAPI_ID_FORMAT, "surface %" GST_VAAPI_ID_FORMAT,
GST_VAAPI_ID_ARGS (GST_VAAPI_OBJECT_ID (subpicture)), GST_VAAPI_ID_ARGS (GST_VAAPI_OBJECT_ID (subpicture)),
GST_VAAPI_ID_ARGS (GST_VAAPI_OBJECT_ID (surface))); GST_VAAPI_ID_ARGS (GST_VAAPI_SURFACE_ID (surface)));
return TRUE; return TRUE;
} }
@ -907,11 +944,11 @@ _gst_vaapi_surface_deassociate_subpicture (GstVaapiSurface * surface,
VASurfaceID surface_id; VASurfaceID surface_id;
VAStatus status; VAStatus status;
display = GST_VAAPI_OBJECT_DISPLAY (surface); display = GST_VAAPI_SURFACE_DISPLAY (surface);
if (!display) if (!display)
return FALSE; return FALSE;
surface_id = GST_VAAPI_OBJECT_ID (surface); surface_id = GST_VAAPI_SURFACE_ID (surface);
if (surface_id == VA_INVALID_SURFACE) if (surface_id == VA_INVALID_SURFACE)
return FALSE; return FALSE;
@ -942,13 +979,13 @@ gst_vaapi_surface_sync (GstVaapiSurface * surface)
g_return_val_if_fail (surface != NULL, FALSE); g_return_val_if_fail (surface != NULL, FALSE);
display = GST_VAAPI_OBJECT_DISPLAY (surface); display = GST_VAAPI_SURFACE_DISPLAY (surface);
if (!display) if (!display)
return FALSE; return FALSE;
GST_VAAPI_DISPLAY_LOCK (display); GST_VAAPI_DISPLAY_LOCK (display);
status = vaSyncSurface (GST_VAAPI_DISPLAY_VADISPLAY (display), status = vaSyncSurface (GST_VAAPI_DISPLAY_VADISPLAY (display),
GST_VAAPI_OBJECT_ID (surface)); GST_VAAPI_SURFACE_ID (surface));
GST_VAAPI_DISPLAY_UNLOCK (display); GST_VAAPI_DISPLAY_UNLOCK (display);
if (!vaapi_check_status (status, "vaSyncSurface()")) if (!vaapi_check_status (status, "vaSyncSurface()"))
return FALSE; return FALSE;
@ -970,15 +1007,16 @@ gboolean
gst_vaapi_surface_query_status (GstVaapiSurface * surface, gst_vaapi_surface_query_status (GstVaapiSurface * surface,
GstVaapiSurfaceStatus * pstatus) GstVaapiSurfaceStatus * pstatus)
{ {
GstVaapiDisplay *const display = GST_VAAPI_SURFACE_DISPLAY (surface);
VASurfaceStatus surface_status; VASurfaceStatus surface_status;
VAStatus status; VAStatus status;
g_return_val_if_fail (surface != NULL, FALSE); g_return_val_if_fail (surface != NULL, FALSE);
GST_VAAPI_OBJECT_LOCK_DISPLAY (surface); GST_VAAPI_DISPLAY_LOCK (display);
status = vaQuerySurfaceStatus (GST_VAAPI_OBJECT_VADISPLAY (surface), status = vaQuerySurfaceStatus (GST_VAAPI_DISPLAY_VADISPLAY (display),
GST_VAAPI_OBJECT_ID (surface), &surface_status); GST_VAAPI_SURFACE_ID (surface), &surface_status);
GST_VAAPI_OBJECT_UNLOCK_DISPLAY (surface); GST_VAAPI_DISPLAY_UNLOCK (display);
if (!vaapi_check_status (status, "vaQuerySurfaceStatus()")) if (!vaapi_check_status (status, "vaQuerySurfaceStatus()"))
return FALSE; return FALSE;
@ -1007,7 +1045,7 @@ gst_vaapi_surface_set_subpictures_from_composition (GstVaapiSurface * surface,
g_return_val_if_fail (surface != NULL, FALSE); g_return_val_if_fail (surface != NULL, FALSE);
display = GST_VAAPI_OBJECT_DISPLAY (surface); display = GST_VAAPI_SURFACE_DISPLAY (surface);
if (!display) if (!display)
return FALSE; return FALSE;

View file

@ -178,9 +178,34 @@ typedef enum
#define GST_VAAPI_SURFACE(obj) \ #define GST_VAAPI_SURFACE(obj) \
((GstVaapiSurface *)(obj)) ((GstVaapiSurface *)(obj))
#define GST_TYPE_VAAPI_SURFACE (gst_vaapi_surface_get_type ())
#define GST_VAAPI_SURFACE_ID(surface) (gst_vaapi_surface_get_id (surface))
#define GST_VAAPI_SURFACE_DISPLAY(surface) (gst_vaapi_surface_get_display (surface))
typedef struct _GstVaapiSurface GstVaapiSurface; typedef struct _GstVaapiSurface GstVaapiSurface;
typedef struct _GstVaapiSurfaceProxy GstVaapiSurfaceProxy; typedef struct _GstVaapiSurfaceProxy GstVaapiSurfaceProxy;
GType
gst_vaapi_surface_get_type (void) G_GNUC_CONST;
/**
* gst_vaapi_surface_unref: (skip)
* @surface: (transfer full): a #GstVaapiSurface.
*
* Decreases the refcount of the surface. If the refcount reaches 0, the
* surface will be freed.
*/
static inline void gst_vaapi_surface_unref(GstVaapiSurface* surface);
static inline void
gst_vaapi_surface_unref (GstVaapiSurface * surface)
{
gst_mini_object_unref (GST_MINI_OBJECT_CAST (surface));
}
GstVaapiDisplay *
gst_vaapi_surface_get_display (GstVaapiSurface * surface);
GstVaapiSurface * GstVaapiSurface *
gst_vaapi_surface_new_from_formats (GstVaapiDisplay * display, gst_vaapi_surface_new_from_formats (GstVaapiDisplay * display,
GstVaapiChromaType chroma_type, guint width, guint height, GArray * formts); GstVaapiChromaType chroma_type, guint width, guint height, GArray * formts);
@ -256,6 +281,8 @@ gst_vaapi_surface_set_buffer_proxy (GstVaapiSurface * surface,
GstVaapiBufferProxy * GstVaapiBufferProxy *
gst_vaapi_surface_peek_buffer_proxy (GstVaapiSurface * surface); gst_vaapi_surface_peek_buffer_proxy (GstVaapiSurface * surface);
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstVaapiSurface, gst_vaapi_surface_unref)
G_END_DECLS G_END_DECLS
#endif /* GST_VAAPI_SURFACE_H */ #endif /* GST_VAAPI_SURFACE_H */

View file

@ -38,7 +38,7 @@ gst_vaapi_surface_get_drm_buf_handle (GstVaapiSurface * surface, guint type)
/* The proxy takes ownership if the image, even creation failure. */ /* The proxy takes ownership if the image, even creation failure. */
proxy = proxy =
gst_vaapi_buffer_proxy_new_from_object (GST_VAAPI_OBJECT (surface), gst_vaapi_buffer_proxy_new_from_object (GST_MINI_OBJECT_CAST (surface),
image->internal_image.buf, type, (GDestroyNotify) gst_vaapi_image_unref, image->internal_image.buf, type, (GDestroyNotify) gst_vaapi_image_unref,
image); image);
if (!proxy) if (!proxy)

View file

@ -161,7 +161,7 @@ create_surface_from_egl_image (GstVaapiDisplayEGL * display,
if (filter_status != GST_VAAPI_FILTER_STATUS_SUCCESS) if (filter_status != GST_VAAPI_FILTER_STATUS_SUCCESS)
goto error_convert_surface; goto error_convert_surface;
gst_vaapi_object_unref (img_surface); gst_vaapi_surface_unref (img_surface);
gst_object_unref (filter); gst_object_unref (filter);
return out_surface; return out_surface;
@ -179,8 +179,8 @@ error_create_filter:
GST_ERROR ("failed to create video processing filter"); GST_ERROR ("failed to create video processing filter");
// fall-through // fall-through
error_cleanup: error_cleanup:
gst_vaapi_object_replace (&img_surface, NULL); gst_mini_object_replace ((GstMiniObject **) & img_surface, NULL);
gst_vaapi_object_replace (&out_surface, NULL); gst_mini_object_replace ((GstMiniObject **) & out_surface, NULL);
gst_vaapi_filter_replace (&filter, NULL); gst_vaapi_filter_replace (&filter, NULL);
return NULL; return NULL;
} }

View file

@ -23,14 +23,10 @@
#ifndef GST_VAAPI_SURFACE_PRIV_H #ifndef GST_VAAPI_SURFACE_PRIV_H
#define GST_VAAPI_SURFACE_PRIV_H #define GST_VAAPI_SURFACE_PRIV_H
#include <gst/vaapi/gstvaapicontext.h>
#include <gst/vaapi/gstvaapisurface.h> #include <gst/vaapi/gstvaapisurface.h>
#include "gstvaapiobject_priv.h"
G_BEGIN_DECLS G_BEGIN_DECLS
typedef struct _GstVaapiSurfaceClass GstVaapiSurfaceClass;
/** /**
* GstVaapiSurface: * GstVaapiSurface:
* *
@ -39,7 +35,9 @@ typedef struct _GstVaapiSurfaceClass GstVaapiSurfaceClass;
struct _GstVaapiSurface struct _GstVaapiSurface
{ {
/*< private >*/ /*< private >*/
GstVaapiObject parent_instance; GstMiniObject mini_object;
GstVaapiDisplay *display;
GstVaapiID object_id;
GstVaapiBufferProxy *extbuf_proxy; GstVaapiBufferProxy *extbuf_proxy;
GstVideoFormat format; GstVideoFormat format;
@ -50,15 +48,28 @@ struct _GstVaapiSurface
}; };
/** /**
* GstVaapiSurfaceClass: * GST_VAAPI_SURFACE_DISPLAY:
* @surface: a #GstVaapiSurface
* *
* A VA surface wrapper class. * Macro that evaluates to the @surface's display.
*
* This is an internal macro that does not do any run-time type check.
*/ */
struct _GstVaapiSurfaceClass #undef GST_VAAPI_SURFACE_DISPLAY
{ #define GST_VAAPI_SURFACE_DISPLAY(surface) \
/*< private >*/ (GST_VAAPI_SURFACE (surface)->display)
GstVaapiObjectClass parent_class;
}; /**
* GST_VAAPI_SURFACE_ID:
* @surface: a #GstVaapiSurface
*
* Macro that evaluates to the @surface's ID.
*
* This is an internal macro that does not do any run-time type check.
*/
#undef GST_VAAPI_SURFACE_ID
#define GST_VAAPI_SURFACE_ID(surface) \
(GST_VAAPI_SURFACE (surface)->object_id)
/** /**
* GST_VAAPI_SURFACE_CHROMA_TYPE: * GST_VAAPI_SURFACE_CHROMA_TYPE:

View file

@ -41,7 +41,7 @@ gst_vaapi_surface_proxy_finalize (GstVaapiSurfaceProxy * proxy)
if (proxy->surface) { if (proxy->surface) {
if (proxy->pool && !proxy->parent) if (proxy->pool && !proxy->parent)
gst_vaapi_video_pool_put_object (proxy->pool, proxy->surface); gst_vaapi_video_pool_put_object (proxy->pool, proxy->surface);
gst_vaapi_object_unref (proxy->surface); gst_vaapi_surface_unref (proxy->surface);
proxy->surface = NULL; proxy->surface = NULL;
} }
gst_vaapi_video_pool_replace (&proxy->pool, NULL); gst_vaapi_video_pool_replace (&proxy->pool, NULL);
@ -125,7 +125,8 @@ gst_vaapi_surface_proxy_new (GstVaapiSurface * surface)
proxy->parent = NULL; proxy->parent = NULL;
proxy->destroy_func = NULL; proxy->destroy_func = NULL;
proxy->pool = NULL; proxy->pool = NULL;
proxy->surface = gst_vaapi_object_ref (surface); proxy->surface =
(GstVaapiSurface *) gst_mini_object_ref (GST_MINI_OBJECT_CAST (surface));
if (!proxy->surface) if (!proxy->surface)
goto error; goto error;
gst_vaapi_surface_proxy_init_properties (proxy); gst_vaapi_surface_proxy_init_properties (proxy);
@ -168,7 +169,7 @@ gst_vaapi_surface_proxy_new_from_pool (GstVaapiSurfacePool * pool)
proxy->surface = gst_vaapi_video_pool_get_object (proxy->pool); proxy->surface = gst_vaapi_video_pool_get_object (proxy->pool);
if (!proxy->surface) if (!proxy->surface)
goto error; goto error;
gst_vaapi_object_ref (proxy->surface); gst_mini_object_ref (GST_MINI_OBJECT_CAST (proxy->surface));
gst_vaapi_surface_proxy_init_properties (proxy); gst_vaapi_surface_proxy_init_properties (proxy);
return proxy; return proxy;
@ -210,7 +211,8 @@ gst_vaapi_surface_proxy_copy (GstVaapiSurfaceProxy * proxy)
copy->parent = gst_vaapi_surface_proxy_ref (proxy->parent ? copy->parent = gst_vaapi_surface_proxy_ref (proxy->parent ?
proxy->parent : proxy); proxy->parent : proxy);
copy->pool = proxy->pool ? gst_vaapi_video_pool_ref (proxy->pool) : NULL; copy->pool = proxy->pool ? gst_vaapi_video_pool_ref (proxy->pool) : NULL;
copy->surface = gst_vaapi_object_ref (proxy->surface); copy->surface = (GstVaapiSurface *)
gst_mini_object_ref (GST_MINI_OBJECT_CAST (proxy->surface));
copy->view_id = proxy->view_id; copy->view_id = proxy->view_id;
copy->timestamp = proxy->timestamp; copy->timestamp = proxy->timestamp;
copy->duration = proxy->duration; copy->duration = proxy->duration;

View file

@ -86,7 +86,7 @@ struct _GstVaapiSurfaceProxy
*/ */
#undef GST_VAAPI_SURFACE_PROXY_SURFACE_ID #undef GST_VAAPI_SURFACE_PROXY_SURFACE_ID
#define GST_VAAPI_SURFACE_PROXY_SURFACE_ID(proxy) \ #define GST_VAAPI_SURFACE_PROXY_SURFACE_ID(proxy) \
(GST_VAAPI_OBJECT_ID (GST_VAAPI_SURFACE_PROXY (proxy)->surface)) (GST_VAAPI_SURFACE_ID (GST_VAAPI_SURFACE_PROXY (proxy)->surface))
/** /**
* GST_VAAPI_SURFACE_PROXY_VIEW_ID: * GST_VAAPI_SURFACE_PROXY_VIEW_ID:

View file

@ -182,7 +182,7 @@ destroy_objects (GstVaapiTextureEGL * texture)
texture->egl_image); texture->egl_image);
texture->egl_image = EGL_NO_IMAGE_KHR; texture->egl_image = EGL_NO_IMAGE_KHR;
} }
gst_vaapi_object_replace (&texture->surface, NULL); gst_mini_object_replace ((GstMiniObject **) & texture->surface, NULL);
gst_vaapi_filter_replace (&texture->filter, NULL); gst_vaapi_filter_replace (&texture->filter, NULL);
} }

View file

@ -31,6 +31,7 @@
#include "gstvaapitexture.h" #include "gstvaapitexture.h"
#include "gstvaapitexture_glx.h" #include "gstvaapitexture_glx.h"
#include "gstvaapitexture_priv.h" #include "gstvaapitexture_priv.h"
#include "gstvaapisurface_priv.h"
#include "gstvaapicompat.h" #include "gstvaapicompat.h"
#include "gstvaapiutils.h" #include "gstvaapiutils.h"
#include "gstvaapiutils_glx.h" #include "gstvaapiutils_glx.h"
@ -344,7 +345,7 @@ gst_vaapi_texture_glx_put_surface_unlocked (GstVaapiTexture * base_texture,
}; };
status = vaPutSurface (GST_VAAPI_OBJECT_VADISPLAY (texture), status = vaPutSurface (GST_VAAPI_OBJECT_VADISPLAY (texture),
GST_VAAPI_OBJECT_ID (surface), texture->pixo->pixmap, GST_VAAPI_SURFACE_ID (surface), texture->pixo->pixmap,
crop_rect->x, crop_rect->y, crop_rect->width, crop_rect->height, crop_rect->x, crop_rect->y, crop_rect->width, crop_rect->height,
0, 0, base_texture->width, base_texture->height, 0, 0, base_texture->width, base_texture->height,
NULL, 0, from_GstVaapiSurfaceRenderFlags (flags)); NULL, 0, from_GstVaapiSurfaceRenderFlags (flags));

View file

@ -67,21 +67,8 @@ gst_vaapi_video_pool_init (GstVaapiVideoPool * pool, GstVaapiDisplay * display,
void void
gst_vaapi_video_pool_finalize (GstVaapiVideoPool * pool) gst_vaapi_video_pool_finalize (GstVaapiVideoPool * pool)
{ {
if (pool->object_type == GST_VAAPI_VIDEO_POOL_OBJECT_TYPE_IMAGE g_list_free_full (pool->used_objects, (GDestroyNotify) gst_mini_object_unref);
|| pool->object_type == GST_VAAPI_VIDEO_POOL_OBJECT_TYPE_CODED_BUFFER) {
g_list_free_full (pool->used_objects,
(GDestroyNotify) gst_mini_object_unref);
} else {
g_list_free_full (pool->used_objects, gst_vaapi_object_unref);
}
if (pool->object_type == GST_VAAPI_VIDEO_POOL_OBJECT_TYPE_IMAGE
|| pool->object_type == GST_VAAPI_VIDEO_POOL_OBJECT_TYPE_CODED_BUFFER) {
g_queue_foreach (&pool->free_objects, (GFunc) gst_mini_object_unref, NULL); g_queue_foreach (&pool->free_objects, (GFunc) gst_mini_object_unref, NULL);
} else {
g_queue_foreach (&pool->free_objects, (GFunc) gst_vaapi_object_unref, NULL);
}
g_queue_clear (&pool->free_objects); g_queue_clear (&pool->free_objects);
gst_vaapi_display_replace (&pool->display, NULL); gst_vaapi_display_replace (&pool->display, NULL);
g_mutex_clear (&pool->mutex); g_mutex_clear (&pool->mutex);
@ -196,14 +183,7 @@ gst_vaapi_video_pool_get_object_unlocked (GstVaapiVideoPool * pool)
++pool->used_count; ++pool->used_count;
pool->used_objects = g_list_prepend (pool->used_objects, object); pool->used_objects = g_list_prepend (pool->used_objects, object);
return gst_mini_object_ref (object);
if (pool->object_type == GST_VAAPI_VIDEO_POOL_OBJECT_TYPE_IMAGE
|| pool->object_type == GST_VAAPI_VIDEO_POOL_OBJECT_TYPE_CODED_BUFFER) {
object = gst_mini_object_ref (GST_MINI_OBJECT_CAST (object));
} else {
object = gst_vaapi_object_ref (object);
}
return object;
} }
gpointer gpointer
@ -239,13 +219,7 @@ gst_vaapi_video_pool_put_object_unlocked (GstVaapiVideoPool * pool,
if (!elem) if (!elem)
return; return;
if (pool->object_type == GST_VAAPI_VIDEO_POOL_OBJECT_TYPE_IMAGE gst_mini_object_unref (object);
|| pool->object_type == GST_VAAPI_VIDEO_POOL_OBJECT_TYPE_CODED_BUFFER) {
gst_mini_object_unref (GST_MINI_OBJECT_CAST (object));
} else {
gst_vaapi_object_unref (object);
}
--pool->used_count; --pool->used_count;
pool->used_objects = g_list_delete_link (pool->used_objects, elem); pool->used_objects = g_list_delete_link (pool->used_objects, elem);
g_queue_push_tail (&pool->free_objects, object); g_queue_push_tail (&pool->free_objects, object);
@ -277,13 +251,7 @@ static inline gboolean
gst_vaapi_video_pool_add_object_unlocked (GstVaapiVideoPool * pool, gst_vaapi_video_pool_add_object_unlocked (GstVaapiVideoPool * pool,
gpointer object) gpointer object)
{ {
if (pool->object_type == GST_VAAPI_VIDEO_POOL_OBJECT_TYPE_IMAGE g_queue_push_tail (&pool->free_objects, gst_mini_object_ref (object));
|| pool->object_type == GST_VAAPI_VIDEO_POOL_OBJECT_TYPE_CODED_BUFFER) {
g_queue_push_tail (&pool->free_objects,
gst_mini_object_ref (GST_MINI_OBJECT_CAST (object)));
} else {
g_queue_push_tail (&pool->free_objects, gst_vaapi_object_ref (object));
}
return TRUE; return TRUE;
} }

View file

@ -284,7 +284,7 @@ gst_vaapi_window_vpp_convert_internal (GstVaapiWindow * window,
error_process_filter: error_process_filter:
{ {
GST_ERROR ("failed to process surface %" GST_VAAPI_ID_FORMAT " (error %d)", GST_ERROR ("failed to process surface %" GST_VAAPI_ID_FORMAT " (error %d)",
GST_VAAPI_ID_ARGS (GST_VAAPI_OBJECT_ID (surface)), status); GST_VAAPI_ID_ARGS (GST_VAAPI_SURFACE_ID (surface)), status);
gst_vaapi_video_pool_put_object (window->surface_pool, vpp_surface); gst_vaapi_video_pool_put_object (window->surface_pool, vpp_surface);
return NULL; return NULL;
} }

View file

@ -28,7 +28,7 @@
#include "sysdeps.h" #include "sysdeps.h"
#include "gstvaapicompat.h" #include "gstvaapicompat.h"
#include "gstvaapiobject_priv.h" #include "gstvaapisurface_priv.h"
#include "gstvaapiwindow_wayland.h" #include "gstvaapiwindow_wayland.h"
#include "gstvaapiwindow_priv.h" #include "gstvaapiwindow_priv.h"
#include "gstvaapidisplay_wayland.h" #include "gstvaapidisplay_wayland.h"
@ -555,7 +555,7 @@ gst_vaapi_window_wayland_render (GstVaapiWindow * window,
GST_VAAPI_WINDOW_LOCK_DISPLAY (window); GST_VAAPI_WINDOW_LOCK_DISPLAY (window);
va_flags = from_GstVaapiSurfaceRenderFlags (flags); va_flags = from_GstVaapiSurfaceRenderFlags (flags);
status = vaGetSurfaceBufferWl (GST_VAAPI_DISPLAY_VADISPLAY (display), status = vaGetSurfaceBufferWl (GST_VAAPI_DISPLAY_VADISPLAY (display),
GST_VAAPI_OBJECT_ID (surface), GST_VAAPI_SURFACE_ID (surface),
va_flags & (VA_TOP_FIELD | VA_BOTTOM_FIELD), &buffer); va_flags & (VA_TOP_FIELD | VA_BOTTOM_FIELD), &buffer);
GST_VAAPI_WINDOW_UNLOCK_DISPLAY (window); GST_VAAPI_WINDOW_UNLOCK_DISPLAY (window);
if (status == VA_STATUS_ERROR_FLAG_NOT_SUPPORTED || if (status == VA_STATUS_ERROR_FLAG_NOT_SUPPORTED ||
@ -583,7 +583,7 @@ gst_vaapi_window_wayland_render (GstVaapiWindow * window,
GST_VAAPI_WINDOW_LOCK_DISPLAY (window); GST_VAAPI_WINDOW_LOCK_DISPLAY (window);
status = vaGetSurfaceBufferWl (GST_VAAPI_DISPLAY_VADISPLAY (display), status = vaGetSurfaceBufferWl (GST_VAAPI_DISPLAY_VADISPLAY (display),
GST_VAAPI_OBJECT_ID (surface), VA_FRAME_PICTURE, &buffer); GST_VAAPI_SURFACE_ID (surface), VA_FRAME_PICTURE, &buffer);
GST_VAAPI_WINDOW_UNLOCK_DISPLAY (window); GST_VAAPI_WINDOW_UNLOCK_DISPLAY (window);
if (!vaapi_check_status (status, "vaGetSurfaceBufferWl()")) if (!vaapi_check_status (status, "vaGetSurfaceBufferWl()"))
return FALSE; return FALSE;

View file

@ -39,7 +39,6 @@
#include "gstvaapisurface_priv.h" #include "gstvaapisurface_priv.h"
#include "gstvaapiutils.h" #include "gstvaapiutils.h"
#include "gstvaapiutils_x11.h" #include "gstvaapiutils_x11.h"
#include "gstvaapisurface_priv.h"
GST_DEBUG_CATEGORY_EXTERN (gst_debug_vaapi_window); GST_DEBUG_CATEGORY_EXTERN (gst_debug_vaapi_window);
#define GST_CAT_DEFAULT gst_debug_vaapi_window #define GST_CAT_DEFAULT gst_debug_vaapi_window
@ -449,7 +448,7 @@ gst_vaapi_window_x11_render (GstVaapiWindow * window,
GST_VAAPI_WINDOW_X11_GET_PRIVATE (window); GST_VAAPI_WINDOW_X11_GET_PRIVATE (window);
gboolean ret = FALSE; gboolean ret = FALSE;
surface_id = GST_VAAPI_OBJECT_ID (surface); surface_id = GST_VAAPI_SURFACE_ID (surface);
if (surface_id == VA_INVALID_ID) if (surface_id == VA_INVALID_ID)
return FALSE; return FALSE;
@ -476,7 +475,7 @@ conversion:
if (G_LIKELY (vpp_surface)) { if (G_LIKELY (vpp_surface)) {
GstVaapiRectangle vpp_src_rect; GstVaapiRectangle vpp_src_rect;
surface_id = GST_VAAPI_OBJECT_ID (vpp_surface); surface_id = GST_VAAPI_SURFACE_ID (vpp_surface);
vpp_src_rect.x = vpp_src_rect.y = 0; vpp_src_rect.x = vpp_src_rect.y = 0;
vpp_src_rect.width = GST_VAAPI_SURFACE_WIDTH (vpp_surface); vpp_src_rect.width = GST_VAAPI_SURFACE_WIDTH (vpp_surface);
vpp_src_rect.height = GST_VAAPI_SURFACE_HEIGHT (vpp_surface); vpp_src_rect.height = GST_VAAPI_SURFACE_HEIGHT (vpp_surface);

View file

@ -156,7 +156,7 @@ _set_cached_surface (GstBuffer * buf, GstVaapiSurface * surface)
{ {
return gst_mini_object_set_qdata (GST_MINI_OBJECT (buf), return gst_mini_object_set_qdata (GST_MINI_OBJECT (buf),
g_quark_from_static_string ("GstVaapiDMABufSurface"), surface, g_quark_from_static_string ("GstVaapiDMABufSurface"), surface,
(GDestroyNotify) gst_vaapi_object_unref); (GDestroyNotify) gst_vaapi_surface_unref);
} }
static gboolean static gboolean
@ -1387,7 +1387,7 @@ extract_allowed_surface_formats (GstVaapiDisplay * display,
if (!image) { if (!image) {
/* Just reuse the surface if the format is specified */ /* Just reuse the surface if the format is specified */
if (specified_format == GST_VIDEO_FORMAT_UNKNOWN) if (specified_format == GST_VIDEO_FORMAT_UNKNOWN)
gst_vaapi_object_replace (&surface, NULL); gst_mini_object_replace ((GstMiniObject **) & surface, NULL);
continue; continue;
} }
@ -1404,11 +1404,11 @@ extract_allowed_surface_formats (GstVaapiDisplay * display,
gst_vaapi_image_unref (image); gst_vaapi_image_unref (image);
/* Just reuse the surface if the format is specified */ /* Just reuse the surface if the format is specified */
if (specified_format == GST_VIDEO_FORMAT_UNKNOWN) if (specified_format == GST_VIDEO_FORMAT_UNKNOWN)
gst_vaapi_object_replace (&surface, NULL); gst_mini_object_replace ((GstMiniObject **) & surface, NULL);
} }
if (surface) if (surface)
gst_vaapi_object_unref (surface); gst_vaapi_surface_unref (surface);
if (out_formats->len == 0) { if (out_formats->len == 0) {
g_array_unref (out_formats); g_array_unref (out_formats);

View file

@ -789,7 +789,7 @@ allocator_configure_surface_try_specified_format (GstVaapiDisplay * display,
rinfo = *allocation_info; rinfo = *allocation_info;
out: out:
gst_vaapi_object_unref (surface); gst_vaapi_surface_unref (surface);
*ret_surface_info = rinfo; *ret_surface_info = rinfo;
*ret_usage_flag = rflag; *ret_usage_flag = rflag;
@ -820,7 +820,7 @@ allocator_configure_surface_try_other_format (GstVaapiDisplay * display,
surface = gst_vaapi_surface_new_full (display, &sinfo, 0); surface = gst_vaapi_surface_new_full (display, &sinfo, 0);
if (!surface) if (!surface)
goto error_no_surface; goto error_no_surface;
gst_vaapi_object_unref (surface); gst_vaapi_surface_unref (surface);
*ret_surface_info = sinfo; *ret_surface_info = sinfo;
return TRUE; return TRUE;
@ -1061,7 +1061,7 @@ gst_vaapi_dmabuf_memory_new (GstAllocator * base_allocator,
if (needs_surface) { if (needs_surface) {
/* The proxy has incremented the surface ref count. */ /* The proxy has incremented the surface ref count. */
gst_vaapi_object_unref (surface); gst_vaapi_surface_unref (surface);
gst_vaapi_video_meta_set_surface_proxy (meta, proxy); gst_vaapi_video_meta_set_surface_proxy (meta, proxy);
gst_vaapi_surface_proxy_unref (proxy); gst_vaapi_surface_proxy_unref (proxy);
} }
@ -1113,14 +1113,14 @@ error_create_surface:
error_create_surface_proxy: error_create_surface_proxy:
{ {
GST_ERROR ("failed to create VA surface proxy"); GST_ERROR ("failed to create VA surface proxy");
gst_vaapi_object_unref (surface); gst_vaapi_surface_unref (surface);
return NULL; return NULL;
} }
error_create_dmabuf_proxy: error_create_dmabuf_proxy:
{ {
GST_ERROR ("failed to export VA surface to DMABUF"); GST_ERROR ("failed to export VA surface to DMABUF");
if (surface) if (surface)
gst_vaapi_object_unref (surface); gst_vaapi_surface_unref (surface);
if (proxy) if (proxy)
gst_vaapi_surface_proxy_unref (proxy); gst_vaapi_surface_proxy_unref (proxy);
return NULL; return NULL;
@ -1189,7 +1189,7 @@ gst_vaapi_dmabuf_allocator_new (GstVaapiDisplay * display,
goto error_no_surface; goto error_no_surface;
if (!gst_video_info_update_from_surface (&surface_info, surface)) if (!gst_video_info_update_from_surface (&surface_info, surface))
goto fail; goto fail;
gst_vaapi_object_replace (&surface, NULL); gst_mini_object_replace ((GstMiniObject **) & surface, NULL);
gst_allocator_set_vaapi_video_info (base_allocator, &surface_info, gst_allocator_set_vaapi_video_info (base_allocator, &surface_info,
surface_alloc_flags); surface_alloc_flags);
@ -1201,7 +1201,7 @@ gst_vaapi_dmabuf_allocator_new (GstVaapiDisplay * display,
/* ERRORS */ /* ERRORS */
fail: fail:
{ {
gst_vaapi_object_replace (&surface, NULL); gst_mini_object_replace ((GstMiniObject **) & surface, NULL);
gst_object_replace ((GstObject **) & base_allocator, NULL); gst_object_replace ((GstObject **) & base_allocator, NULL);
return NULL; return NULL;
} }

View file

@ -107,7 +107,7 @@ set_surface_proxy (GstVaapiVideoMeta * meta, GstVaapiSurfaceProxy * proxy)
return FALSE; return FALSE;
meta->proxy = gst_vaapi_surface_proxy_ref (proxy); meta->proxy = gst_vaapi_surface_proxy_ref (proxy);
set_display (meta, gst_vaapi_object_get_display (GST_VAAPI_OBJECT (surface))); set_display (meta, gst_vaapi_surface_get_display (surface));
return TRUE; return TRUE;
} }

View file

@ -178,8 +178,7 @@ gst_vaapi_texture_upload (GstVideoGLTextureUploadMeta * meta,
GstVaapiSurfaceProxy *const proxy = GstVaapiSurfaceProxy *const proxy =
gst_vaapi_video_meta_get_surface_proxy (vmeta); gst_vaapi_video_meta_get_surface_proxy (vmeta);
GstVaapiSurface *const surface = gst_vaapi_surface_proxy_get_surface (proxy); GstVaapiSurface *const surface = gst_vaapi_surface_proxy_get_surface (proxy);
GstVaapiDisplay *const dpy = GstVaapiDisplay *const dpy = gst_vaapi_surface_get_display (surface);
gst_vaapi_object_get_display (GST_VAAPI_OBJECT (surface));
GstVaapiTexture *texture = NULL; GstVaapiTexture *texture = NULL;
if (!gst_vaapi_display_has_opengl (dpy)) if (!gst_vaapi_display_has_opengl (dpy))

View file

@ -360,7 +360,7 @@ image_upload (GstVaapiImage * image, GstVaapiSurface * surface)
GstVaapiSubpicture *subpicture; GstVaapiSubpicture *subpicture;
gboolean success; gboolean success;
display = gst_vaapi_object_get_display (GST_VAAPI_OBJECT (surface)); display = gst_vaapi_surface_get_display (surface);
if (!display) if (!display)
return FALSE; return FALSE;

View file

@ -141,7 +141,7 @@ error_cleanup:
if (image) if (image)
gst_vaapi_image_unref (image); gst_vaapi_image_unref (image);
if (surface) if (surface)
gst_vaapi_object_unref (surface); gst_vaapi_surface_unref (surface);
if (error_ptr) if (error_ptr)
*error_ptr = error; *error_ptr = error;
else else
@ -441,8 +441,8 @@ main (int argc, char *argv[])
pause (); pause ();
gst_object_unref (filter); gst_object_unref (filter);
gst_vaapi_object_unref (dst_surface); gst_vaapi_surface_unref (dst_surface);
gst_vaapi_object_unref (src_surface); gst_vaapi_surface_unref (src_surface);
gst_object_unref (window); gst_object_unref (window);
gst_object_unref (display); gst_object_unref (display);
video_output_exit (); video_output_exit ();

View file

@ -57,7 +57,7 @@ main (int argc, char *argv[])
g_print ("created surface %" GST_VAAPI_ID_FORMAT "\n", g_print ("created surface %" GST_VAAPI_ID_FORMAT "\n",
GST_VAAPI_ID_ARGS (surface_id)); GST_VAAPI_ID_ARGS (surface_id));
gst_vaapi_object_unref (surface); gst_vaapi_surface_unref (surface);
pool = gst_vaapi_surface_pool_new (display, GST_VIDEO_FORMAT_ENCODED, pool = gst_vaapi_surface_pool_new (display, GST_VIDEO_FORMAT_ENCODED,
width, height); width, height);
@ -74,7 +74,8 @@ main (int argc, char *argv[])
} }
/* Check the pool doesn't return the last free'd surface */ /* Check the pool doesn't return the last free'd surface */
surface = gst_vaapi_object_ref (surfaces[1]); surface = (GstVaapiSurface *)
gst_mini_object_ref (GST_MINI_OBJECT_CAST (surfaces[1]));
for (i = 0; i < 2; i++) for (i = 0; i < 2; i++)
gst_vaapi_video_pool_put_object (pool, surfaces[i]); gst_vaapi_video_pool_put_object (pool, surfaces[i]);
@ -100,7 +101,7 @@ main (int argc, char *argv[])
/* Unref in random order to check objects are correctly refcounted */ /* Unref in random order to check objects are correctly refcounted */
gst_object_unref (display); gst_object_unref (display);
gst_vaapi_video_pool_unref (pool); gst_vaapi_video_pool_unref (pool);
gst_vaapi_object_unref (surface); gst_vaapi_surface_unref (surface);
video_output_exit (); video_output_exit ();
return 0; return 0;
} }

View file

@ -134,7 +134,7 @@ main (int argc, char *argv[])
gst_object_unref (window); gst_object_unref (window);
} }
gst_vaapi_object_unref (surface); gst_vaapi_surface_unref (surface);
gst_object_unref (display); gst_object_unref (display);
#endif #endif
@ -199,7 +199,7 @@ main (int argc, char *argv[])
XDestroyWindow (dpy, win); XDestroyWindow (dpy, win);
} }
gst_vaapi_object_unref (surface); gst_vaapi_surface_unref (surface);
gst_object_unref (display); gst_object_unref (display);
#endif #endif
@ -229,7 +229,7 @@ main (int argc, char *argv[])
gst_object_unref (window); gst_object_unref (window);
} }
gst_vaapi_object_unref (surface); gst_vaapi_surface_unref (surface);
gst_object_unref (display); gst_object_unref (display);
#endif #endif