Commit 608ce681 authored by He Junyan's avatar He Junyan Committed by GStreamer Merge Bot

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's avatarVíctor Manuel Jáquez Leal <vjaquez@igalia.com>
parent e398f2c2
Pipeline #91094 failed with stages
in 55 minutes and 52 seconds
......@@ -24,6 +24,7 @@
#include "gstvaapicompat.h"
#include "gstvaapibufferproxy.h"
#include "gstvaapibufferproxy_priv.h"
#include "gstvaapisurface_priv.h"
#include "gstvaapiutils.h"
#include "gstvaapiobject_priv.h"
......@@ -33,6 +34,7 @@
static gboolean
gst_vaapi_buffer_proxy_acquire_handle (GstVaapiBufferProxy * proxy)
{
GstVaapiDisplay *display;
const guint mem_type = proxy->va_info.mem_type;
VAStatus va_status;
......@@ -42,10 +44,13 @@ gst_vaapi_buffer_proxy_acquire_handle (GstVaapiBufferProxy * proxy)
if (!proxy->parent || proxy->va_buf == VA_INVALID_ID)
return FALSE;
GST_VAAPI_OBJECT_LOCK_DISPLAY (proxy->parent);
va_status = vaAcquireBufferHandle (GST_VAAPI_OBJECT_VADISPLAY (proxy->parent),
/* @XXX(victor): parent might be not a surface */
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);
GST_VAAPI_OBJECT_UNLOCK_DISPLAY (proxy->parent);
GST_VAAPI_DISPLAY_UNLOCK (display);
if (!vaapi_check_status (va_status, "vaAcquireBufferHandle()"))
return FALSE;
if (proxy->va_info.mem_type != mem_type)
......@@ -56,6 +61,7 @@ gst_vaapi_buffer_proxy_acquire_handle (GstVaapiBufferProxy * proxy)
static gboolean
gst_vaapi_buffer_proxy_release_handle (GstVaapiBufferProxy * proxy)
{
GstVaapiDisplay *display;
VAStatus va_status;
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)
return FALSE;
GST_VAAPI_OBJECT_LOCK_DISPLAY (proxy->parent);
va_status = vaReleaseBufferHandle (GST_VAAPI_OBJECT_VADISPLAY (proxy->parent),
/* @XXX(victor): parent might be not a surface */
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);
GST_VAAPI_OBJECT_UNLOCK_DISPLAY (proxy->parent);
GST_VAAPI_DISPLAY_UNLOCK (display);
if (!vaapi_check_status (va_status, "vaReleaseBufferHandle()"))
return FALSE;
return TRUE;
......@@ -87,7 +96,7 @@ gst_vaapi_buffer_proxy_finalize (GstVaapiBufferProxy * proxy)
if (proxy->destroy_func)
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 *
......@@ -138,7 +147,7 @@ error_unsupported_mem_type:
}
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)
{
GstVaapiBufferProxy *proxy;
......@@ -150,7 +159,7 @@ gst_vaapi_buffer_proxy_new_from_object (GstVaapiObject * object,
if (!proxy)
return NULL;
proxy->parent = gst_vaapi_object_ref (object);
proxy->parent = gst_mini_object_ref (object);
proxy->destroy_func = destroy_func;
proxy->destroy_data = data;
proxy->type = type;
......
......@@ -62,7 +62,7 @@ G_BEGIN_DECLS
struct _GstVaapiBufferProxy {
/*< private >*/
GstVaapiMiniObject parent_instance;
GstVaapiObject *parent;
GstMiniObject *parent;
GDestroyNotify destroy_func;
gpointer destroy_data;
......@@ -74,7 +74,7 @@ struct _GstVaapiBufferProxy {
G_GNUC_INTERNAL
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);
G_GNUC_INTERNAL
......
......@@ -147,7 +147,7 @@ context_create_surfaces (GstVaapiContext * context)
num_surfaces = cip->ref_frames + SCRATCH_SURFACES_COUNT;
if (!context->surfaces) {
context->surfaces = g_ptr_array_new_full (num_surfaces,
(GDestroyNotify) gst_vaapi_object_unref);
(GDestroyNotify) gst_mini_object_unref);
if (!context->surfaces)
return FALSE;
}
......@@ -188,7 +188,7 @@ context_create (GstVaapiContext * context)
GstVaapiSurface *const surface = g_ptr_array_index (context->surfaces, i);
if (!surface)
goto cleanup;
surface_id = GST_VAAPI_OBJECT_ID (surface);
surface_id = GST_VAAPI_SURFACE_ID (surface);
g_array_append_val (surfaces, surface_id);
}
g_assert (surfaces->len == context->surfaces->len);
......
......@@ -3833,7 +3833,7 @@ create_context_for_enc (GstVaapiEncoder * fei_encoder,
GstVaapiSurface *const surface = g_ptr_array_index (context->surfaces, i);
if (!surface)
goto cleanup;
surface_id = GST_VAAPI_OBJECT_ID (surface);
surface_id = GST_VAAPI_SURFACE_ID (surface);
g_array_append_val (surfaces, surface_id);
}
g_assert (surfaces->len == context->surfaces->len);
......
......@@ -386,7 +386,7 @@ gst_vaapi_enc_picture_create (GstVaapiEncPicture * picture,
if (!picture->surface)
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)
return FALSE;
......
......@@ -1124,7 +1124,7 @@ deint_refs_set (GArray * refs, GstVaapiSurface ** surfaces, guint num_surfaces)
return FALSE;
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;
}
......@@ -1617,7 +1617,7 @@ gst_vaapi_filter_process_unlocked (GstVaapiFilter * filter,
goto error;
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_color_standard = VAProcColorStandardNone;
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);
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()"))
goto error;
......
......@@ -124,7 +124,7 @@ gst_vaapi_pixmap_x11_render (GstVaapiPixmap * pixmap, GstVaapiSurface * surface,
VASurfaceID surface_id;
VAStatus status;
surface_id = GST_VAAPI_OBJECT_ID (surface);
surface_id = GST_VAAPI_SURFACE_ID (surface);
if (surface_id == VA_INVALID_ID)
return FALSE;
......
......@@ -34,6 +34,7 @@
#include "gstvaapisurface_priv.h"
#include "gstvaapicontext.h"
#include "gstvaapiimage.h"
#include "gstvaapiimage_priv.h"
#include "gstvaapibufferproxy_priv.h"
#define DEBUG 1
......@@ -66,13 +67,13 @@ gst_vaapi_surface_destroy_subpictures (GstVaapiSurface * surface)
}
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;
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_vaapi_surface_destroy_subpictures (surface);
......@@ -85,16 +86,19 @@ gst_vaapi_surface_destroy (GstVaapiSurface * surface)
if (!vaapi_check_status (status, "vaDestroySurfaces()"))
GST_WARNING ("failed to destroy surface %" GST_VAAPI_ID_FORMAT,
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_display_replace (&GST_VAAPI_SURFACE_DISPLAY (surface), NULL);
g_slice_free1 (sizeof (GstVaapiSurface), surface);
}
static gboolean
gst_vaapi_surface_init (GstVaapiSurface * surface,
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;
VAStatus status;
guint va_chroma_format;
......@@ -116,7 +120,7 @@ gst_vaapi_surface_init (GstVaapiSurface * surface,
GST_VAAPI_SURFACE_HEIGHT (surface) = height;
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;
/* ERRORS */
......@@ -129,7 +133,7 @@ static gboolean
gst_vaapi_surface_init_full (GstVaapiSurface * surface,
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);
VASurfaceID surface_id;
VAStatus status;
......@@ -207,7 +211,7 @@ gst_vaapi_surface_init_full (GstVaapiSurface * surface,
GST_VAAPI_SURFACE_HEIGHT (surface) = extbuf.height;
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;
/* ERRORS */
......@@ -221,7 +225,7 @@ static gboolean
gst_vaapi_surface_init_from_buffer_proxy (GstVaapiSurface * surface,
GstVaapiBufferProxy * proxy, const GstVideoInfo * vip)
{
GstVaapiDisplay *const display = GST_VAAPI_OBJECT_DISPLAY (surface);
GstVaapiDisplay *const display = GST_VAAPI_SURFACE_DISPLAY (surface);
GstVideoFormat format;
VASurfaceID surface_id;
VAStatus status;
......@@ -292,7 +296,7 @@ gst_vaapi_surface_init_from_buffer_proxy (GstVaapiSurface * surface,
GST_VAAPI_SURFACE_HEIGHT (surface) = height;
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;
/* ERRORS */
......@@ -302,8 +306,41 @@ error_unsupported_format:
return FALSE;
}
#define gst_vaapi_surface_finalize gst_vaapi_surface_destroy
GST_VAAPI_OBJECT_DEFINE_CLASS (GstVaapiSurface, gst_vaapi_surface);
GST_DEFINE_MINI_OBJECT_TYPE (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:
......@@ -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
* just use the passed chroma */
surface = gst_vaapi_object_new (gst_vaapi_surface_class (), display);
surface = gst_vaapi_surface_create (display);
if (!surface)
return NULL;
if (!gst_vaapi_surface_init (surface, chroma_type, width, height))
......@@ -347,7 +384,7 @@ gst_vaapi_surface_new_from_formats (GstVaapiDisplay * display,
/* ERRORS */
error:
{
gst_vaapi_object_unref (surface);
gst_vaapi_surface_unref (surface);
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);
surface = gst_vaapi_object_new (gst_vaapi_surface_class (), display);
surface = gst_vaapi_surface_create (display);
if (!surface)
return NULL;
......@@ -395,7 +432,7 @@ gst_vaapi_surface_new (GstVaapiDisplay * display,
/* ERRORS */
error:
{
gst_vaapi_object_unref (surface);
gst_vaapi_surface_unref (surface);
return NULL;
}
}
......@@ -423,7 +460,7 @@ gst_vaapi_surface_new_full (GstVaapiDisplay * display,
GST_VIDEO_INFO_HEIGHT (vip),
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)
return NULL;
......@@ -434,7 +471,7 @@ gst_vaapi_surface_new_full (GstVaapiDisplay * display,
/* ERRORS */
error:
{
gst_vaapi_object_unref (surface);
gst_vaapi_surface_unref (surface);
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 (info != NULL, NULL);
surface = gst_vaapi_object_new (gst_vaapi_surface_class (), display);
surface = gst_vaapi_surface_create (display);
if (!surface)
return NULL;
......@@ -500,7 +537,7 @@ gst_vaapi_surface_new_from_buffer_proxy (GstVaapiDisplay * display,
/* ERRORS */
error:
{
gst_vaapi_object_unref (surface);
gst_vaapi_surface_unref (surface);
return NULL;
}
}
......@@ -518,7 +555,7 @@ gst_vaapi_surface_get_id (GstVaapiSurface * 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);
display = GST_VAAPI_OBJECT_DISPLAY (surface);
display = GST_VAAPI_SURFACE_DISPLAY (surface);
va_image.image_id = VA_INVALID_ID;
va_image.buf = VA_INVALID_ID;
GST_VAAPI_DISPLAY_LOCK (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);
if (!vaapi_check_status (status, "vaDeriveImage()"))
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 (image != NULL, FALSE);
display = GST_VAAPI_OBJECT_DISPLAY (surface);
display = GST_VAAPI_SURFACE_DISPLAY (surface);
if (!display)
return FALSE;
......@@ -708,7 +745,7 @@ gst_vaapi_surface_get_image (GstVaapiSurface * surface, GstVaapiImage * image)
GST_VAAPI_DISPLAY_LOCK (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);
if (!vaapi_check_status (status, "vaGetImage()"))
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 (image != NULL, FALSE);
display = GST_VAAPI_OBJECT_DISPLAY (surface);
display = GST_VAAPI_SURFACE_DISPLAY (surface);
if (!display)
return FALSE;
......@@ -753,8 +790,8 @@ gst_vaapi_surface_put_image (GstVaapiSurface * surface, GstVaapiImage * image)
GST_VAAPI_DISPLAY_LOCK (display);
status = vaPutImage (GST_VAAPI_DISPLAY_VADISPLAY (display),
GST_VAAPI_OBJECT_ID (surface), image_id, 0, 0, width, height,
0, 0, width, height);
GST_VAAPI_SURFACE_ID (surface), image_id, 0, 0, width, height, 0, 0,
width, height);
GST_VAAPI_DISPLAY_UNLOCK (display);
if (!vaapi_check_status (status, "vaPutImage()"))
return FALSE;
......@@ -823,11 +860,11 @@ _gst_vaapi_surface_associate_subpicture (GstVaapiSurface * surface,
VASurfaceID surface_id;
VAStatus status;
display = GST_VAAPI_OBJECT_DISPLAY (surface);
display = GST_VAAPI_SURFACE_DISPLAY (surface);
if (!display)
return FALSE;
surface_id = GST_VAAPI_OBJECT_ID (surface);
surface_id = GST_VAAPI_SURFACE_ID (surface);
if (surface_id == VA_INVALID_SURFACE)
return FALSE;
......@@ -890,7 +927,7 @@ gst_vaapi_surface_deassociate_subpicture (GstVaapiSurface * surface,
GST_DEBUG ("subpicture %" GST_VAAPI_ID_FORMAT " was not bound to "
"surface %" GST_VAAPI_ID_FORMAT,
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;
}
......@@ -907,11 +944,11 @@ _gst_vaapi_surface_deassociate_subpicture (GstVaapiSurface * surface,
VASurfaceID surface_id;
VAStatus status;
display = GST_VAAPI_OBJECT_DISPLAY (surface);
display = GST_VAAPI_SURFACE_DISPLAY (surface);
if (!display)
return FALSE;
surface_id = GST_VAAPI_OBJECT_ID (surface);
surface_id = GST_VAAPI_SURFACE_ID (surface);
if (surface_id == VA_INVALID_SURFACE)
return FALSE;
......@@ -942,13 +979,13 @@ gst_vaapi_surface_sync (GstVaapiSurface * surface)
g_return_val_if_fail (surface != NULL, FALSE);
display = GST_VAAPI_OBJECT_DISPLAY (surface);
display = GST_VAAPI_SURFACE_DISPLAY (surface);
if (!display)
return FALSE;
GST_VAAPI_DISPLAY_LOCK (display);
status = vaSyncSurface (GST_VAAPI_DISPLAY_VADISPLAY (display),
GST_VAAPI_OBJECT_ID (surface));
GST_VAAPI_SURFACE_ID (surface));
GST_VAAPI_DISPLAY_UNLOCK (display);
if (!vaapi_check_status (status, "vaSyncSurface()"))
return FALSE;
......@@ -970,15 +1007,16 @@ gboolean
gst_vaapi_surface_query_status (GstVaapiSurface * surface,
GstVaapiSurfaceStatus * pstatus)
{
GstVaapiDisplay *const display = GST_VAAPI_SURFACE_DISPLAY (surface);
VASurfaceStatus surface_status;
VAStatus status;
g_return_val_if_fail (surface != NULL, FALSE);
GST_VAAPI_OBJECT_LOCK_DISPLAY (surface);
status = vaQuerySurfaceStatus (GST_VAAPI_OBJECT_VADISPLAY (surface),
GST_VAAPI_OBJECT_ID (surface), &surface_status);
GST_VAAPI_OBJECT_UNLOCK_DISPLAY (surface);
GST_VAAPI_DISPLAY_LOCK (display);
status = vaQuerySurfaceStatus (GST_VAAPI_DISPLAY_VADISPLAY (display),
GST_VAAPI_SURFACE_ID (surface), &surface_status);
GST_VAAPI_DISPLAY_UNLOCK (display);
if (!vaapi_check_status (status, "vaQuerySurfaceStatus()"))
return FALSE;
......@@ -1007,7 +1045,7 @@ gst_vaapi_surface_set_subpictures_from_composition (GstVaapiSurface * surface,
g_return_val_if_fail (surface != NULL, FALSE);
display = GST_VAAPI_OBJECT_DISPLAY (surface);
display = GST_VAAPI_SURFACE_DISPLAY (surface);
if (!display)
return FALSE;
......
......@@ -178,9 +178,34 @@ typedef enum
#define GST_VAAPI_SURFACE(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 _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 *
gst_vaapi_surface_new_from_formats (GstVaapiDisplay * display,
GstVaapiChromaType chroma_type, guint width, guint height, GArray * formts);
......@@ -256,6 +281,8 @@ gst_vaapi_surface_set_buffer_proxy (GstVaapiSurface * surface,
GstVaapiBufferProxy *
gst_vaapi_surface_peek_buffer_proxy (GstVaapiSurface * surface);
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstVaapiSurface, gst_vaapi_surface_unref)
G_END_DECLS
#endif /* GST_VAAPI_SURFACE_H */
......@@ -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. */
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);
if (!proxy)
......
......@@ -161,7 +161,7 @@ create_surface_from_egl_image (GstVaapiDisplayEGL * display,
if (filter_status != GST_VAAPI_FILTER_STATUS_SUCCESS)
goto error_convert_surface;
gst_vaapi_object_unref (img_surface);
gst_vaapi_surface_unref (img_surface);
gst_object_unref (filter);
return out_surface;
......@@ -179,8 +179,8 @@ error_create_filter:
GST_ERROR ("failed to create video processing filter");
// fall-through
error_cleanup:
gst_vaapi_object_replace (&img_surface, NULL);
gst_vaapi_object_replace (&out_surface, NULL);
gst_mini_object_replace ((GstMiniObject **) & img_surface, NULL);
gst_mini_object_replace ((GstMiniObject **) & out_surface, NULL);
gst_vaapi_filter_replace (&filter, NULL);
return NULL;
}
......
......@@ -23,14 +23,10 @@
#ifndef GST_VAAPI_SURFACE_PRIV_H
#define GST_VAAPI_SURFACE_PRIV_H
#include <gst/vaapi/gstvaapicontext.h>
#include <gst/vaapi/gstvaapisurface.h>
#include "gstvaapiobject_priv.h"
G_BEGIN_DECLS
typedef struct _GstVaapiSurfaceClass GstVaapiSurfaceClass;
/**
* GstVaapiSurface:
*
......@@ -39,7 +35,9 @@ typedef struct _GstVaapiSurfaceClass GstVaapiSurfaceClass;
struct _GstVaapiSurface
{
/*< private >*/