diff options
author | He Junyan <junyan.he@hotmail.com> | 2019-12-19 14:19:10 +0100 |
---|---|---|
committer | GStreamer Merge Bot <gitlab-merge-bot@gstreamer-foundation.org> | 2019-12-20 05:01:08 +0000 |
commit | 608ce681e5dd51460c2fe5ff0be110fc40a4618a (patch) | |
tree | bced9b025c03316ab7a93231433b9d8f6f069746 | |
parent | e398f2c24571fdc5c4a8256fddedbee2d26e515f (diff) |
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>
28 files changed, 205 insertions, 150 deletions
diff --git a/gst-libs/gst/vaapi/gstvaapibufferproxy.c b/gst-libs/gst/vaapi/gstvaapibufferproxy.c index c177cebc..c8fe234b 100644 --- a/gst-libs/gst/vaapi/gstvaapibufferproxy.c +++ b/gst-libs/gst/vaapi/gstvaapibufferproxy.c @@ -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; diff --git a/gst-libs/gst/vaapi/gstvaapibufferproxy_priv.h b/gst-libs/gst/vaapi/gstvaapibufferproxy_priv.h index d0fb9a23..66bfeb4d 100644 --- a/gst-libs/gst/vaapi/gstvaapibufferproxy_priv.h +++ b/gst-libs/gst/vaapi/gstvaapibufferproxy_priv.h @@ -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 diff --git a/gst-libs/gst/vaapi/gstvaapicontext.c b/gst-libs/gst/vaapi/gstvaapicontext.c index 358fddec..b26bb52f 100644 --- a/gst-libs/gst/vaapi/gstvaapicontext.c +++ b/gst-libs/gst/vaapi/gstvaapicontext.c @@ -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); diff --git a/gst-libs/gst/vaapi/gstvaapiencoder_h264_fei.c b/gst-libs/gst/vaapi/gstvaapiencoder_h264_fei.c index 04927450..838c782e 100644 --- a/gst-libs/gst/vaapi/gstvaapiencoder_h264_fei.c +++ b/gst-libs/gst/vaapi/gstvaapiencoder_h264_fei.c @@ -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); diff --git a/gst-libs/gst/vaapi/gstvaapiencoder_objects.c b/gst-libs/gst/vaapi/gstvaapiencoder_objects.c index 3227607c..09fcc18a 100644 --- a/gst-libs/gst/vaapi/gstvaapiencoder_objects.c +++ b/gst-libs/gst/vaapi/gstvaapiencoder_objects.c @@ -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; diff --git a/gst-libs/gst/vaapi/gstvaapifilter.c b/gst-libs/gst/vaapi/gstvaapifilter.c index eabcedf6..180804b1 100644 --- a/gst-libs/gst/vaapi/gstvaapifilter.c +++ b/gst-libs/gst/vaapi/gstvaapifilter.c @@ -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; diff --git a/gst-libs/gst/vaapi/gstvaapipixmap_x11.c b/gst-libs/gst/vaapi/gstvaapipixmap_x11.c index 9ffccd9d..7bdbf5ec 100644 --- a/gst-libs/gst/vaapi/gstvaapipixmap_x11.c +++ b/gst-libs/gst/vaapi/gstvaapipixmap_x11.c @@ -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; diff --git a/gst-libs/gst/vaapi/gstvaapisurface.c b/gst-libs/gst/vaapi/gstvaapisurface.c index e206229d..5e2e63f6 100644 --- a/gst-libs/gst/vaapi/gstvaapisurface.c +++ b/gst-libs/gst/vaapi/gstvaapisurface.c @@ -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; diff --git a/gst-libs/gst/vaapi/gstvaapisurface.h b/gst-libs/gst/vaapi/gstvaapisurface.h index c62f7bb8..08e5d7de 100644 --- a/gst-libs/gst/vaapi/gstvaapisurface.h +++ b/gst-libs/gst/vaapi/gstvaapisurface.h @@ -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 */ diff --git a/gst-libs/gst/vaapi/gstvaapisurface_drm.c b/gst-libs/gst/vaapi/gstvaapisurface_drm.c index a7e33e01..7587553a 100644 --- a/gst-libs/gst/vaapi/gstvaapisurface_drm.c +++ b/gst-libs/gst/vaapi/gstvaapisurface_drm.c @@ -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) diff --git a/gst-libs/gst/vaapi/gstvaapisurface_egl.c b/gst-libs/gst/vaapi/gstvaapisurface_egl.c index 338cfaf9..02997434 100644 --- a/gst-libs/gst/vaapi/gstvaapisurface_egl.c +++ b/gst-libs/gst/vaapi/gstvaapisurface_egl.c @@ -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; } diff --git a/gst-libs/gst/vaapi/gstvaapisurface_priv.h b/gst-libs/gst/vaapi/gstvaapisurface_priv.h index 48fcf43a..f0e8ce78 100644 --- a/gst-libs/gst/vaapi/gstvaapisurface_priv.h +++ b/gst-libs/gst/vaapi/gstvaapisurface_priv.h @@ -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 >*/ - GstVaapiObject parent_instance; + GstMiniObject mini_object; + GstVaapiDisplay *display; + GstVaapiID object_id; GstVaapiBufferProxy *extbuf_proxy; 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 -{ - /*< private >*/ - GstVaapiObjectClass parent_class; -}; +#undef GST_VAAPI_SURFACE_DISPLAY +#define GST_VAAPI_SURFACE_DISPLAY(surface) \ + (GST_VAAPI_SURFACE (surface)->display) + +/** + * 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: diff --git a/gst-libs/gst/vaapi/gstvaapisurfaceproxy.c b/gst-libs/gst/vaapi/gstvaapisurfaceproxy.c index 4e2b686f..b34afed0 100644 --- a/gst-libs/gst/vaapi/gstvaapisurfaceproxy.c +++ b/gst-libs/gst/vaapi/gstvaapisurfaceproxy.c @@ -41,7 +41,7 @@ gst_vaapi_surface_proxy_finalize (GstVaapiSurfaceProxy * proxy) if (proxy->surface) { if (proxy->pool && !proxy->parent) 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; } gst_vaapi_video_pool_replace (&proxy->pool, NULL); @@ -125,7 +125,8 @@ gst_vaapi_surface_proxy_new (GstVaapiSurface * surface) proxy->parent = NULL; proxy->destroy_func = 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) goto error; 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); if (!proxy->surface) 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); return proxy; @@ -210,7 +211,8 @@ gst_vaapi_surface_proxy_copy (GstVaapiSurfaceProxy * proxy) copy->parent = gst_vaapi_surface_proxy_ref (proxy->parent ? proxy->parent : proxy); 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->timestamp = proxy->timestamp; copy->duration = proxy->duration; diff --git a/gst-libs/gst/vaapi/gstvaapisurfaceproxy_priv.h b/gst-libs/gst/vaapi/gstvaapisurfaceproxy_priv.h index 1540c7cb..e43ecbc0 100644 --- a/gst-libs/gst/vaapi/gstvaapisurfaceproxy_priv.h +++ b/gst-libs/gst/vaapi/gstvaapisurfaceproxy_priv.h @@ -86,7 +86,7 @@ struct _GstVaapiSurfaceProxy */ #undef GST_VAAPI_SURFACE_PROXY_SURFACE_ID #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: diff --git a/gst-libs/gst/vaapi/gstvaapitexture_egl.c b/gst-libs/gst/vaapi/gstvaapitexture_egl.c index efeced4a..e0eb3183 100644 --- a/gst-libs/gst/vaapi/gstvaapitexture_egl.c +++ b/gst-libs/gst/vaapi/gstvaapitexture_egl.c @@ -182,7 +182,7 @@ destroy_objects (GstVaapiTextureEGL * texture) texture->egl_image); 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); } diff --git a/gst-libs/gst/vaapi/gstvaapitexture_glx.c b/gst-libs/gst/vaapi/gstvaapitexture_glx.c index b1e641bf..dab6ebe8 100644 --- a/gst-libs/gst/vaapi/gstvaapitexture_glx.c +++ b/gst-libs/gst/vaapi/gstvaapitexture_glx.c @@ -31,6 +31,7 @@ #include "gstvaapitexture.h" #include "gstvaapitexture_glx.h" #include "gstvaapitexture_priv.h" +#include "gstvaapisurface_priv.h" #include "gstvaapicompat.h" #include "gstvaapiutils.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), - 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, 0, 0, base_texture->width, base_texture->height, NULL, 0, from_GstVaapiSurfaceRenderFlags (flags)); diff --git a/gst-libs/gst/vaapi/gstvaapivideopool.c b/gst-libs/gst/vaapi/gstvaapivideopool.c index 9e79b951..faba3677 100644 --- a/gst-libs/gst/vaapi/gstvaapivideopool.c +++ b/gst-libs/gst/vaapi/gstvaapivideopool.c @@ -67,21 +67,8 @@ gst_vaapi_video_pool_init (GstVaapiVideoPool * pool, GstVaapiDisplay * display, void gst_vaapi_video_pool_finalize (GstVaapiVideoPool * pool) { - if (pool->object_type == GST_VAAPI_VIDEO_POOL_OBJECT_TYPE_IMAGE - || 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); - } else { - g_queue_foreach (&pool->free_objects, (GFunc) gst_vaapi_object_unref, NULL); - } - + g_list_free_full (pool->used_objects, (GDestroyNotify) gst_mini_object_unref); + g_queue_foreach (&pool->free_objects, (GFunc) gst_mini_object_unref, NULL); g_queue_clear (&pool->free_objects); gst_vaapi_display_replace (&pool->display, NULL); g_mutex_clear (&pool->mutex); @@ -196,14 +183,7 @@ gst_vaapi_video_pool_get_object_unlocked (GstVaapiVideoPool * pool) ++pool->used_count; pool->used_objects = g_list_prepend (pool->used_objects, 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; + return gst_mini_object_ref (object); } gpointer @@ -239,13 +219,7 @@ gst_vaapi_video_pool_put_object_unlocked (GstVaapiVideoPool * pool, if (!elem) return; - if (pool->object_type == GST_VAAPI_VIDEO_POOL_OBJECT_TYPE_IMAGE - || 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); - } - + gst_mini_object_unref (object); --pool->used_count; pool->used_objects = g_list_delete_link (pool->used_objects, elem); g_queue_push_tail (&pool->free_objects, object); @@ -277,13 +251,7 @@ static inline gboolean gst_vaapi_video_pool_add_object_unlocked (GstVaapiVideoPool * pool, gpointer object) { - if (pool->object_type == GST_VAAPI_VIDEO_POOL_OBJECT_TYPE_IMAGE - || 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)); - } + g_queue_push_tail (&pool->free_objects, gst_mini_object_ref (object)); return TRUE; } diff --git a/gst-libs/gst/vaapi/gstvaapiwindow.c b/gst-libs/gst/vaapi/gstvaapiwindow.c index ed01f5ea..75b9e0e6 100644 --- a/gst-libs/gst/vaapi/gstvaapiwindow.c +++ b/gst-libs/gst/vaapi/gstvaapiwindow.c @@ -284,7 +284,7 @@ gst_vaapi_window_vpp_convert_internal (GstVaapiWindow * window, error_process_filter: { 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); return NULL; } diff --git a/gst-libs/gst/vaapi/gstvaapiwindow_wayland.c b/gst-libs/gst/vaapi/gstvaapiwindow_wayland.c index 39a5e026..8e091523 100644 --- a/gst-libs/gst/vaapi/gstvaapiwindow_wayland.c +++ b/gst-libs/gst/vaapi/gstvaapiwindow_wayland.c @@ -28,7 +28,7 @@ #include "sysdeps.h" #include "gstvaapicompat.h" -#include "gstvaapiobject_priv.h" +#include "gstvaapisurface_priv.h" #include "gstvaapiwindow_wayland.h" #include "gstvaapiwindow_priv.h" #include "gstvaapidisplay_wayland.h" @@ -555,7 +555,7 @@ gst_vaapi_window_wayland_render (GstVaapiWindow * window, GST_VAAPI_WINDOW_LOCK_DISPLAY (window); va_flags = from_GstVaapiSurfaceRenderFlags (flags); 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); GST_VAAPI_WINDOW_UNLOCK_DISPLAY (window); 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); 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); if (!vaapi_check_status (status, "vaGetSurfaceBufferWl()")) return FALSE; diff --git a/gst-libs/gst/vaapi/gstvaapiwindow_x11.c b/gst-libs/gst/vaapi/gstvaapiwindow_x11.c index fd3b0451..bf0b65b3 100644 --- a/gst-libs/gst/vaapi/gstvaapiwindow_x11.c +++ b/gst-libs/gst/vaapi/gstvaapiwindow_x11.c @@ -39,7 +39,6 @@ #include "gstvaapisurface_priv.h" #include "gstvaapiutils.h" #include "gstvaapiutils_x11.h" -#include "gstvaapisurface_priv.h" GST_DEBUG_CATEGORY_EXTERN (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); gboolean ret = FALSE; - surface_id = GST_VAAPI_OBJECT_ID (surface); + surface_id = GST_VAAPI_SURFACE_ID (surface); if (surface_id == VA_INVALID_ID) return FALSE; @@ -476,7 +475,7 @@ conversion: if (G_LIKELY (vpp_surface)) { 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.width = GST_VAAPI_SURFACE_WIDTH (vpp_surface); vpp_src_rect.height = GST_VAAPI_SURFACE_HEIGHT (vpp_surface); diff --git a/gst/vaapi/gstvaapipluginbase.c b/gst/vaapi/gstvaapipluginbase.c index db088be9..eba6efd7 100644 --- a/gst/vaapi/gstvaapipluginbase.c +++ b/gst/vaapi/gstvaapipluginbase.c @@ -156,7 +156,7 @@ _set_cached_surface (GstBuffer * buf, GstVaapiSurface * surface) { return gst_mini_object_set_qdata (GST_MINI_OBJECT (buf), g_quark_from_static_string ("GstVaapiDMABufSurface"), surface, - (GDestroyNotify) gst_vaapi_object_unref); + (GDestroyNotify) gst_vaapi_surface_unref); } static gboolean @@ -1387,7 +1387,7 @@ extract_allowed_surface_formats (GstVaapiDisplay * display, if (!image) { /* Just reuse the surface if the format is specified */ if (specified_format == GST_VIDEO_FORMAT_UNKNOWN) - gst_vaapi_object_replace (&surface, NULL); + gst_mini_object_replace ((GstMiniObject **) & surface, NULL); continue; } @@ -1404,11 +1404,11 @@ extract_allowed_surface_formats (GstVaapiDisplay * display, gst_vaapi_image_unref (image); /* Just reuse the surface if the format is specified */ if (specified_format == GST_VIDEO_FORMAT_UNKNOWN) - gst_vaapi_object_replace (&surface, NULL); + gst_mini_object_replace ((GstMiniObject **) & surface, NULL); } if (surface) - gst_vaapi_object_unref (surface); + gst_vaapi_surface_unref (surface); if (out_formats->len == 0) { g_array_unref (out_formats); diff --git a/gst/vaapi/gstvaapivideomemory.c b/gst/vaapi/gstvaapivideomemory.c index c6af52c4..224a7ed2 100644 --- a/gst/vaapi/gstvaapivideomemory.c +++ b/gst/vaapi/gstvaapivideomemory.c @@ -789,7 +789,7 @@ allocator_configure_surface_try_specified_format (GstVaapiDisplay * display, rinfo = *allocation_info; out: - gst_vaapi_object_unref (surface); + gst_vaapi_surface_unref (surface); *ret_surface_info = rinfo; *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); if (!surface) goto error_no_surface; - gst_vaapi_object_unref (surface); + gst_vaapi_surface_unref (surface); *ret_surface_info = sinfo; return TRUE; @@ -1061,7 +1061,7 @@ gst_vaapi_dmabuf_memory_new (GstAllocator * base_allocator, if (needs_surface) { /* 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_surface_proxy_unref (proxy); } @@ -1113,14 +1113,14 @@ error_create_surface: error_create_surface_proxy: { GST_ERROR ("failed to create VA surface proxy"); - gst_vaapi_object_unref (surface); + gst_vaapi_surface_unref (surface); return NULL; } error_create_dmabuf_proxy: { GST_ERROR ("failed to export VA surface to DMABUF"); if (surface) - gst_vaapi_object_unref (surface); + gst_vaapi_surface_unref (surface); if (proxy) gst_vaapi_surface_proxy_unref (proxy); return NULL; @@ -1189,7 +1189,7 @@ gst_vaapi_dmabuf_allocator_new (GstVaapiDisplay * display, goto error_no_surface; if (!gst_video_info_update_from_surface (&surface_info, surface)) 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, surface_alloc_flags); @@ -1201,7 +1201,7 @@ gst_vaapi_dmabuf_allocator_new (GstVaapiDisplay * display, /* ERRORS */ fail: { - gst_vaapi_object_replace (&surface, NULL); + gst_mini_object_replace ((GstMiniObject **) & surface, NULL); gst_object_replace ((GstObject **) & base_allocator, NULL); return NULL; } diff --git a/gst/vaapi/gstvaapivideometa.c b/gst/vaapi/gstvaapivideometa.c index 3a0d3133..68ee20e0 100644 --- a/gst/vaapi/gstvaapivideometa.c +++ b/gst/vaapi/gstvaapivideometa.c @@ -107,7 +107,7 @@ set_surface_proxy (GstVaapiVideoMeta * meta, GstVaapiSurfaceProxy * proxy) return FALSE; 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; } diff --git a/gst/vaapi/gstvaapivideometa_texture.c b/gst/vaapi/gstvaapivideometa_texture.c index e3f5f1b5..68da63f0 100644 --- a/gst/vaapi/gstvaapivideometa_texture.c +++ b/gst/vaapi/gstvaapivideometa_texture.c @@ -178,8 +178,7 @@ gst_vaapi_texture_upload (GstVideoGLTextureUploadMeta * meta, GstVaapiSurfaceProxy *const proxy = gst_vaapi_video_meta_get_surface_proxy (vmeta); GstVaapiSurface *const surface = gst_vaapi_surface_proxy_get_surface (proxy); - GstVaapiDisplay *const dpy = - gst_vaapi_object_get_display (GST_VAAPI_OBJECT (surface)); + GstVaapiDisplay *const dpy = gst_vaapi_surface_get_display (surface); GstVaapiTexture *texture = NULL; if (!gst_vaapi_display_has_opengl (dpy)) diff --git a/tests/internal/image.c b/tests/internal/image.c index aba0b145..30256cb7 100644 --- a/tests/internal/image.c +++ b/tests/internal/image.c @@ -360,7 +360,7 @@ image_upload (GstVaapiImage * image, GstVaapiSurface * surface) GstVaapiSubpicture *subpicture; gboolean success; - display = gst_vaapi_object_get_display (GST_VAAPI_OBJECT (surface)); + display = gst_vaapi_surface_get_display (surface); if (!display) return FALSE; diff --git a/tests/internal/test-filter.c b/tests/internal/test-filter.c index 926fe7f5..fcdd95c2 100644 --- a/tests/internal/test-filter.c +++ b/tests/internal/test-filter.c @@ -141,7 +141,7 @@ error_cleanup: if (image) gst_vaapi_image_unref (image); if (surface) - gst_vaapi_object_unref (surface); + gst_vaapi_surface_unref (surface); if (error_ptr) *error_ptr = error; else @@ -441,8 +441,8 @@ main (int argc, char *argv[]) pause (); gst_object_unref (filter); - gst_vaapi_object_unref (dst_surface); - gst_vaapi_object_unref (src_surface); + gst_vaapi_surface_unref (dst_surface); + gst_vaapi_surface_unref (src_surface); gst_object_unref (window); gst_object_unref (display); video_output_exit (); diff --git a/tests/internal/test-surfaces.c b/tests/internal/test-surfaces.c index 2f9a90fa..d0fbfaf4 100644 --- a/tests/internal/test-surfaces.c +++ b/tests/internal/test-surfaces.c @@ -57,7 +57,7 @@ main (int argc, char *argv[]) g_print ("created surface %" GST_VAAPI_ID_FORMAT "\n", 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, width, height); @@ -74,7 +74,8 @@ main (int argc, char *argv[]) } /* 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++) 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 */ gst_object_unref (display); gst_vaapi_video_pool_unref (pool); - gst_vaapi_object_unref (surface); + gst_vaapi_surface_unref (surface); video_output_exit (); return 0; } diff --git a/tests/internal/test-windows.c b/tests/internal/test-windows.c index 5b185ecb..b9c9ad17 100644 --- a/tests/internal/test-windows.c +++ b/tests/internal/test-windows.c @@ -134,7 +134,7 @@ main (int argc, char *argv[]) gst_object_unref (window); } - gst_vaapi_object_unref (surface); + gst_vaapi_surface_unref (surface); gst_object_unref (display); #endif @@ -199,7 +199,7 @@ main (int argc, char *argv[]) XDestroyWindow (dpy, win); } - gst_vaapi_object_unref (surface); + gst_vaapi_surface_unref (surface); gst_object_unref (display); #endif @@ -229,7 +229,7 @@ main (int argc, char *argv[]) gst_object_unref (window); } - gst_vaapi_object_unref (surface); + gst_vaapi_surface_unref (surface); gst_object_unref (display); #endif |