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>
#include "gstvaapicompat.h"
#include "gstvaapibufferproxy.h"
#include "gstvaapibufferproxy_priv.h"
+#include "gstvaapisurface_priv.h"
#include "gstvaapiutils.h"
#include "gstvaapiobject_priv.h"
static gboolean
gst_vaapi_buffer_proxy_acquire_handle (GstVaapiBufferProxy * proxy)
{
+ GstVaapiDisplay *display;
const guint mem_type = proxy->va_info.mem_type;
VAStatus va_status;
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)
static gboolean
gst_vaapi_buffer_proxy_release_handle (GstVaapiBufferProxy * proxy)
{
+ GstVaapiDisplay *display;
VAStatus va_status;
if (!proxy->va_info.handle)
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;
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 *
}
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;
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;
struct _GstVaapiBufferProxy {
/*< private >*/
GstVaapiMiniObject parent_instance;
- GstVaapiObject *parent;
+ GstMiniObject *parent;
GDestroyNotify destroy_func;
gpointer destroy_data;
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
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;
}
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);
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);
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;
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;
}
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;
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;
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;
#include "gstvaapisurface_priv.h"
#include "gstvaapicontext.h"
#include "gstvaapiimage.h"
+#include "gstvaapiimage_priv.h"
#include "gstvaapibufferproxy_priv.h"
#define DEBUG 1
}
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);
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;
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 */
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;
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 */
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;
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 */
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:
/* 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))
/* ERRORS */
error:
{
- gst_vaapi_object_unref (surface);
+ gst_vaapi_surface_unref (surface);
return NULL;
}
}
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;
/* ERRORS */
error:
{
- gst_vaapi_object_unref (surface);
+ gst_vaapi_surface_unref (surface);
return NULL;
}
}
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;
/* ERRORS */
error:
{
- gst_vaapi_object_unref (surface);
+ gst_vaapi_surface_unref (surface);
return NULL;
}
}
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;
/* ERRORS */
error:
{
- gst_vaapi_object_unref (surface);
+ gst_vaapi_surface_unref (surface);
return NULL;
}
}
{
g_return_val_if_fail (surface != NULL, VA_INVALID_SURFACE);
- return GST_VAAPI_OBJECT_ID (surface);
+ return GST_VAAPI_SURFACE_ID (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;
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;
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;
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;
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;
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;
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;
}
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;
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;
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;
g_return_val_if_fail (surface != NULL, FALSE);
- display = GST_VAAPI_OBJECT_DISPLAY (surface);
+ display = GST_VAAPI_SURFACE_DISPLAY (surface);
if (!display)
return FALSE;
#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);
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 */
/* 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)
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;
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;
}
#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:
*
struct _GstVaapiSurface
{
/*< private >*/
- GstVaapiObject parent_instance;
+ GstMiniObject mini_object;
+ GstVaapiDisplay *display;
+ GstVaapiID object_id;
GstVaapiBufferProxy *extbuf_proxy;
GstVideoFormat format;
};
/**
- * 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:
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);
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);
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;
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;
*/
#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:
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);
}
#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"
};
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));
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);
++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
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);
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;
}
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;
}
#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"
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 ||
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;
#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
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;
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);
{
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
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;
}
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);
rinfo = *allocation_info;
out:
- gst_vaapi_object_unref (surface);
+ gst_vaapi_surface_unref (surface);
*ret_surface_info = rinfo;
*ret_usage_flag = rflag;
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;
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);
}
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;
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);
/* ERRORS */
fail:
{
- gst_vaapi_object_replace (&surface, NULL);
+ gst_mini_object_replace ((GstMiniObject **) & surface, NULL);
gst_object_replace ((GstObject **) & base_allocator, NULL);
return NULL;
}
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;
}
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))
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;
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
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 ();
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);
}
/* 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]);
/* 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;
}
gst_object_unref (window);
}
- gst_vaapi_object_unref (surface);
+ gst_vaapi_surface_unref (surface);
gst_object_unref (display);
#endif
XDestroyWindow (dpy, win);
}
- gst_vaapi_object_unref (surface);
+ gst_vaapi_surface_unref (surface);
gst_object_unref (display);
#endif
gst_object_unref (window);
}
- gst_vaapi_object_unref (surface);
+ gst_vaapi_surface_unref (surface);
gst_object_unref (display);
#endif