mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-20 00:31:13 +00:00
libs: image: port to GstMiniObject base class
GstVaapiMiniObject and GstVaapiObject are deprecrated. This is the first step to remove them, by porting GstVaapiImage as a GstMiniObject. Signed-off-by: Víctor Manuel Jáquez Leal <vjaquez@igalia.com>
This commit is contained in:
parent
a6289308ee
commit
d56824c05c
16 changed files with 175 additions and 74 deletions
|
@ -32,7 +32,6 @@
|
||||||
#include "gstvaapiutils.h"
|
#include "gstvaapiutils.h"
|
||||||
#include "gstvaapiimage.h"
|
#include "gstvaapiimage.h"
|
||||||
#include "gstvaapiimage_priv.h"
|
#include "gstvaapiimage_priv.h"
|
||||||
#include "gstvaapiobject_priv.h"
|
|
||||||
|
|
||||||
#define DEBUG 1
|
#define DEBUG 1
|
||||||
#include "gstvaapidebug.h"
|
#include "gstvaapidebug.h"
|
||||||
|
@ -114,15 +113,15 @@ vaapi_image_is_linear (const VAImage * va_image)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gst_vaapi_image_destroy (GstVaapiImage * image)
|
gst_vaapi_image_free (GstVaapiImage * image)
|
||||||
{
|
{
|
||||||
GstVaapiDisplay *const display = GST_VAAPI_OBJECT_DISPLAY (image);
|
GstVaapiDisplay *const display = GST_VAAPI_IMAGE_DISPLAY (image);
|
||||||
VAImageID image_id;
|
VAImageID image_id;
|
||||||
VAStatus status;
|
VAStatus status;
|
||||||
|
|
||||||
_gst_vaapi_image_unmap (image);
|
_gst_vaapi_image_unmap (image);
|
||||||
|
|
||||||
image_id = GST_VAAPI_OBJECT_ID (image);
|
image_id = GST_VAAPI_IMAGE_ID (image);
|
||||||
GST_DEBUG ("image %" GST_VAAPI_ID_FORMAT, GST_VAAPI_ID_ARGS (image_id));
|
GST_DEBUG ("image %" GST_VAAPI_ID_FORMAT, GST_VAAPI_ID_ARGS (image_id));
|
||||||
|
|
||||||
if (image_id != VA_INVALID_ID) {
|
if (image_id != VA_INVALID_ID) {
|
||||||
|
@ -132,14 +131,18 @@ gst_vaapi_image_destroy (GstVaapiImage * image)
|
||||||
if (!vaapi_check_status (status, "vaDestroyImage()"))
|
if (!vaapi_check_status (status, "vaDestroyImage()"))
|
||||||
GST_WARNING ("failed to destroy image %" GST_VAAPI_ID_FORMAT,
|
GST_WARNING ("failed to destroy image %" GST_VAAPI_ID_FORMAT,
|
||||||
GST_VAAPI_ID_ARGS (image_id));
|
GST_VAAPI_ID_ARGS (image_id));
|
||||||
GST_VAAPI_OBJECT_ID (image) = VA_INVALID_ID;
|
GST_VAAPI_IMAGE_ID (image) = VA_INVALID_ID;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gst_vaapi_display_replace (&GST_VAAPI_IMAGE_DISPLAY (image), NULL);
|
||||||
|
|
||||||
|
g_slice_free1 (sizeof (GstVaapiImage), image);
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
_gst_vaapi_image_create (GstVaapiImage * image, GstVideoFormat format)
|
_gst_vaapi_image_create (GstVaapiImage * image, GstVideoFormat format)
|
||||||
{
|
{
|
||||||
GstVaapiDisplay *const display = GST_VAAPI_OBJECT_DISPLAY (image);
|
GstVaapiDisplay *const display = GST_VAAPI_IMAGE_DISPLAY (image);
|
||||||
const VAImageFormat *va_format;
|
const VAImageFormat *va_format;
|
||||||
VAStatus status;
|
VAStatus status;
|
||||||
|
|
||||||
|
@ -210,31 +213,44 @@ gst_vaapi_image_create (GstVaapiImage * image, GstVideoFormat format,
|
||||||
image->is_linear = vaapi_image_is_linear (&image->image);
|
image->is_linear = vaapi_image_is_linear (&image->image);
|
||||||
|
|
||||||
GST_DEBUG ("image %" GST_VAAPI_ID_FORMAT, GST_VAAPI_ID_ARGS (image_id));
|
GST_DEBUG ("image %" GST_VAAPI_ID_FORMAT, GST_VAAPI_ID_ARGS (image_id));
|
||||||
GST_VAAPI_OBJECT_ID (image) = image_id;
|
GST_VAAPI_IMAGE_ID (image) = image_id;
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gst_vaapi_image_init (GstVaapiImage * image)
|
gst_vaapi_image_init (GstVaapiImage * image, GstVaapiDisplay * display)
|
||||||
{
|
{
|
||||||
|
/* TODO(victor): implement image copy mechanism, it's almost
|
||||||
|
* there */
|
||||||
|
gst_mini_object_init (GST_MINI_OBJECT_CAST (image), 0,
|
||||||
|
GST_TYPE_VAAPI_IMAGE, NULL, NULL,
|
||||||
|
(GstMiniObjectFreeFunction) gst_vaapi_image_free);
|
||||||
|
|
||||||
|
GST_VAAPI_IMAGE_DISPLAY (image) = gst_object_ref (display);
|
||||||
|
GST_VAAPI_IMAGE_ID (image) = VA_INVALID_ID;
|
||||||
image->internal_image.image_id = VA_INVALID_ID;
|
image->internal_image.image_id = VA_INVALID_ID;
|
||||||
image->internal_image.buf = VA_INVALID_ID;
|
image->internal_image.buf = VA_INVALID_ID;
|
||||||
image->image.image_id = VA_INVALID_ID;
|
image->image.image_id = VA_INVALID_ID;
|
||||||
image->image.buf = VA_INVALID_ID;
|
image->image.buf = VA_INVALID_ID;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
GST_DEFINE_MINI_OBJECT_TYPE (GstVaapiImage, gst_vaapi_image);
|
||||||
gst_vaapi_image_class_init (GstVaapiImageClass * klass)
|
|
||||||
|
/**
|
||||||
|
* gst_vaapi_image_get_display:
|
||||||
|
* @image: a #GstVaapiImage
|
||||||
|
*
|
||||||
|
* Returns the #GstVaapiDisplay this @image is bound to.
|
||||||
|
*
|
||||||
|
* Return value: the parent #GstVaapiDisplay object
|
||||||
|
*/
|
||||||
|
GstVaapiDisplay *
|
||||||
|
gst_vaapi_image_get_display (GstVaapiImage * image)
|
||||||
{
|
{
|
||||||
GstVaapiObjectClass *const object_class = GST_VAAPI_OBJECT_CLASS (klass);
|
g_return_val_if_fail (image != NULL, NULL);
|
||||||
|
return GST_VAAPI_IMAGE_DISPLAY (image);
|
||||||
object_class->init = (GstVaapiObjectInitFunc) gst_vaapi_image_init;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#define gst_vaapi_image_finalize gst_vaapi_image_destroy
|
|
||||||
GST_VAAPI_OBJECT_DEFINE_CLASS_WITH_CODE (GstVaapiImage,
|
|
||||||
gst_vaapi_image, gst_vaapi_image_class_init (&g_class))
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* gst_vaapi_image_new:
|
* gst_vaapi_image_new:
|
||||||
* @display: a #GstVaapiDisplay
|
* @display: a #GstVaapiDisplay
|
||||||
|
@ -247,7 +263,8 @@ GST_VAAPI_OBJECT_DEFINE_CLASS_WITH_CODE (GstVaapiImage,
|
||||||
*
|
*
|
||||||
* Return value: the newly allocated #GstVaapiImage object
|
* Return value: the newly allocated #GstVaapiImage object
|
||||||
*/
|
*/
|
||||||
GstVaapiImage *gst_vaapi_image_new (GstVaapiDisplay * display,
|
GstVaapiImage *
|
||||||
|
gst_vaapi_image_new (GstVaapiDisplay * display,
|
||||||
GstVideoFormat format, guint width, guint height)
|
GstVideoFormat format, guint width, guint height)
|
||||||
{
|
{
|
||||||
GstVaapiImage *image;
|
GstVaapiImage *image;
|
||||||
|
@ -258,10 +275,12 @@ GST_VAAPI_OBJECT_DEFINE_CLASS_WITH_CODE (GstVaapiImage,
|
||||||
GST_DEBUG ("format %s, size %ux%u", gst_vaapi_video_format_to_string (format),
|
GST_DEBUG ("format %s, size %ux%u", gst_vaapi_video_format_to_string (format),
|
||||||
width, height);
|
width, height);
|
||||||
|
|
||||||
image = gst_vaapi_object_new (gst_vaapi_image_class (), display);
|
image = g_slice_new (GstVaapiImage);
|
||||||
if (!image)
|
if (!image)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
gst_vaapi_image_init (image, display);
|
||||||
|
|
||||||
if (!gst_vaapi_image_create (image, format, width, height))
|
if (!gst_vaapi_image_create (image, format, width, height))
|
||||||
goto error;
|
goto error;
|
||||||
return image;
|
return image;
|
||||||
|
@ -269,7 +288,7 @@ GST_VAAPI_OBJECT_DEFINE_CLASS_WITH_CODE (GstVaapiImage,
|
||||||
/* ERRORS */
|
/* ERRORS */
|
||||||
error:
|
error:
|
||||||
{
|
{
|
||||||
gst_vaapi_object_unref (image);
|
gst_vaapi_image_unref (image);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -300,10 +319,12 @@ gst_vaapi_image_new_with_image (GstVaapiDisplay * display, VAImage * va_image)
|
||||||
GST_FOURCC_ARGS (va_image->format.fourcc),
|
GST_FOURCC_ARGS (va_image->format.fourcc),
|
||||||
va_image->width, va_image->height);
|
va_image->width, va_image->height);
|
||||||
|
|
||||||
image = gst_vaapi_object_new (gst_vaapi_image_class (), display);
|
image = g_slice_new (GstVaapiImage);
|
||||||
if (!image)
|
if (!image)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
gst_vaapi_image_init (image, display);
|
||||||
|
|
||||||
if (!_gst_vaapi_image_set_image (image, va_image))
|
if (!_gst_vaapi_image_set_image (image, va_image))
|
||||||
goto error;
|
goto error;
|
||||||
return image;
|
return image;
|
||||||
|
@ -311,7 +332,7 @@ gst_vaapi_image_new_with_image (GstVaapiDisplay * display, VAImage * va_image)
|
||||||
/* ERRORS */
|
/* ERRORS */
|
||||||
error:
|
error:
|
||||||
{
|
{
|
||||||
gst_vaapi_object_unref (image);
|
gst_vaapi_image_unref (image);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -329,7 +350,7 @@ gst_vaapi_image_get_id (GstVaapiImage * image)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail (image != NULL, VA_INVALID_ID);
|
g_return_val_if_fail (image != NULL, VA_INVALID_ID);
|
||||||
|
|
||||||
return GST_VAAPI_OBJECT_ID (image);
|
return GST_VAAPI_IMAGE_ID (image);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -385,7 +406,7 @@ _gst_vaapi_image_set_image (GstVaapiImage * image, const VAImage * va_image)
|
||||||
image->width = va_image->width;
|
image->width = va_image->width;
|
||||||
image->height = va_image->height;
|
image->height = va_image->height;
|
||||||
|
|
||||||
GST_VAAPI_OBJECT_ID (image) = va_image->image_id;
|
GST_VAAPI_IMAGE_ID (image) = va_image->image_id;
|
||||||
|
|
||||||
/* Try to linearize image */
|
/* Try to linearize image */
|
||||||
if (!image->is_linear) {
|
if (!image->is_linear) {
|
||||||
|
@ -554,7 +575,7 @@ _gst_vaapi_image_map (GstVaapiImage * image, GstVaapiImageRaw * raw_image)
|
||||||
if (_gst_vaapi_image_is_mapped (image))
|
if (_gst_vaapi_image_is_mapped (image))
|
||||||
goto map_success;
|
goto map_success;
|
||||||
|
|
||||||
display = GST_VAAPI_OBJECT_DISPLAY (image);
|
display = GST_VAAPI_IMAGE_DISPLAY (image);
|
||||||
if (!display)
|
if (!display)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
|
@ -607,7 +628,7 @@ _gst_vaapi_image_unmap (GstVaapiImage * image)
|
||||||
if (!_gst_vaapi_image_is_mapped (image))
|
if (!_gst_vaapi_image_is_mapped (image))
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
display = GST_VAAPI_OBJECT_DISPLAY (image);
|
display = GST_VAAPI_IMAGE_DISPLAY (image);
|
||||||
if (!display)
|
if (!display)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
|
|
|
@ -59,8 +59,32 @@ G_BEGIN_DECLS
|
||||||
*/
|
*/
|
||||||
#define GST_VAAPI_IMAGE_HEIGHT(image) gst_vaapi_image_get_height(image)
|
#define GST_VAAPI_IMAGE_HEIGHT(image) gst_vaapi_image_get_height(image)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* GST_VAAPI_IMAGE_DISPLAY:
|
||||||
|
* @image: a #GstVaapiImage
|
||||||
|
*
|
||||||
|
* Macro that evaluates to the display of @image
|
||||||
|
*/
|
||||||
|
#define GST_VAAPI_IMAGE_DISPLAY(image) gst_vaapi_image_get_display(image)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* GST_VAAPI_IMAGE_ID:
|
||||||
|
* @image: a #GstVaapiImage
|
||||||
|
*
|
||||||
|
* Macro that evaluates to the ID of @image
|
||||||
|
*/
|
||||||
|
#define GST_VAAPI_IMAGE_ID(image) gst_vaapi_image_get_id(image)
|
||||||
|
|
||||||
|
#define GST_TYPE_VAAPI_IMAGE (gst_vaapi_image_get_type ())
|
||||||
|
|
||||||
typedef struct _GstVaapiImage GstVaapiImage;
|
typedef struct _GstVaapiImage GstVaapiImage;
|
||||||
|
|
||||||
|
GType
|
||||||
|
gst_vaapi_image_get_type (void) G_GNUC_CONST;
|
||||||
|
|
||||||
|
GstVaapiDisplay *
|
||||||
|
gst_vaapi_image_get_display (GstVaapiImage * image);
|
||||||
|
|
||||||
GstVaapiImage *
|
GstVaapiImage *
|
||||||
gst_vaapi_image_new(
|
gst_vaapi_image_new(
|
||||||
GstVaapiDisplay *display,
|
GstVaapiDisplay *display,
|
||||||
|
@ -72,6 +96,20 @@ gst_vaapi_image_new(
|
||||||
GstVaapiImage *
|
GstVaapiImage *
|
||||||
gst_vaapi_image_new_with_image(GstVaapiDisplay *display, VAImage *va_image);
|
gst_vaapi_image_new_with_image(GstVaapiDisplay *display, VAImage *va_image);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* gst_vaapi_image_unref: (skip)
|
||||||
|
* @image: (transfer full): a #GstVaapiImage.
|
||||||
|
*
|
||||||
|
* Decreases the refcount of the image. If the refcount reaches 0, the
|
||||||
|
* image will be freed.
|
||||||
|
*/
|
||||||
|
static inline void gst_vaapi_image_unref(GstVaapiImage* image);
|
||||||
|
static inline void
|
||||||
|
gst_vaapi_image_unref (GstVaapiImage * image)
|
||||||
|
{
|
||||||
|
gst_mini_object_unref (GST_MINI_OBJECT_CAST (image));
|
||||||
|
}
|
||||||
|
|
||||||
GstVaapiID
|
GstVaapiID
|
||||||
gst_vaapi_image_get_id(GstVaapiImage *image);
|
gst_vaapi_image_get_id(GstVaapiImage *image);
|
||||||
|
|
||||||
|
@ -131,6 +169,8 @@ gst_vaapi_image_update_from_buffer(
|
||||||
gboolean
|
gboolean
|
||||||
gst_vaapi_image_copy(GstVaapiImage *dst_image, GstVaapiImage *src_image);
|
gst_vaapi_image_copy(GstVaapiImage *dst_image, GstVaapiImage *src_image);
|
||||||
|
|
||||||
|
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstVaapiImage, gst_vaapi_image_unref)
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
#endif /* GST_VAAPI_IMAGE_H */
|
#endif /* GST_VAAPI_IMAGE_H */
|
||||||
|
|
|
@ -26,11 +26,9 @@
|
||||||
#define GST_VAAPI_IMAGE_PRIV_H
|
#define GST_VAAPI_IMAGE_PRIV_H
|
||||||
|
|
||||||
#include <gst/vaapi/gstvaapiimage.h>
|
#include <gst/vaapi/gstvaapiimage.h>
|
||||||
#include "gstvaapiobject_priv.h"
|
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
typedef struct _GstVaapiImageClass GstVaapiImageClass;
|
|
||||||
typedef struct _GstVaapiImageRaw GstVaapiImageRaw;
|
typedef struct _GstVaapiImageRaw GstVaapiImageRaw;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -40,7 +38,9 @@ typedef struct _GstVaapiImageRaw GstVaapiImageRaw;
|
||||||
*/
|
*/
|
||||||
struct _GstVaapiImage {
|
struct _GstVaapiImage {
|
||||||
/*< private >*/
|
/*< private >*/
|
||||||
GstVaapiObject parent_instance;
|
GstMiniObject mini_object;
|
||||||
|
GstVaapiDisplay *display;
|
||||||
|
GstVaapiID object_id;
|
||||||
|
|
||||||
VAImage internal_image;
|
VAImage internal_image;
|
||||||
VAImage image;
|
VAImage image;
|
||||||
|
@ -52,16 +52,6 @@ struct _GstVaapiImage {
|
||||||
guint is_linear : 1;
|
guint is_linear : 1;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* GstVaapiImageClass:
|
|
||||||
*
|
|
||||||
* A VA image wrapper class
|
|
||||||
*/
|
|
||||||
struct _GstVaapiImageClass {
|
|
||||||
/*< private >*/
|
|
||||||
GstVaapiObjectClass parent_class;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* GstVaapiImageRaw:
|
* GstVaapiImageRaw:
|
||||||
*
|
*
|
||||||
|
@ -107,6 +97,27 @@ struct _GstVaapiImageRaw {
|
||||||
#define GST_VAAPI_IMAGE_HEIGHT(image) \
|
#define GST_VAAPI_IMAGE_HEIGHT(image) \
|
||||||
(GST_VAAPI_IMAGE(image)->height)
|
(GST_VAAPI_IMAGE(image)->height)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* GST_VAAPI_IMAGE_DISPLAY:
|
||||||
|
* @image: a #GstVaapiImage
|
||||||
|
*
|
||||||
|
* Macro that evaluates to the @image's display
|
||||||
|
*/
|
||||||
|
#undef GST_VAAPI_IMAGE_DISPLAY
|
||||||
|
#define GST_VAAPI_IMAGE_DISPLAY(image) \
|
||||||
|
(GST_VAAPI_IMAGE(image)->display)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* GST_VAAPI_IMAGE_ID:
|
||||||
|
* @image: a #GstVaapiImage
|
||||||
|
*
|
||||||
|
* Macro that evaluates to the @image's object ID
|
||||||
|
*/
|
||||||
|
#undef GST_VAAPI_IMAGE_ID
|
||||||
|
#define GST_VAAPI_IMAGE_ID(image) \
|
||||||
|
(GST_VAAPI_IMAGE(image)->object_id)
|
||||||
|
|
||||||
|
|
||||||
G_GNUC_INTERNAL
|
G_GNUC_INTERNAL
|
||||||
gboolean
|
gboolean
|
||||||
gst_vaapi_image_get_raw(
|
gst_vaapi_image_get_raw(
|
||||||
|
|
|
@ -88,7 +88,7 @@ gst_vaapi_subpicture_destroy (GstVaapiSubpicture * subpicture)
|
||||||
}
|
}
|
||||||
GST_VAAPI_OBJECT_ID (subpicture) = VA_INVALID_ID;
|
GST_VAAPI_OBJECT_ID (subpicture) = VA_INVALID_ID;
|
||||||
}
|
}
|
||||||
gst_vaapi_object_replace (&subpicture->image, NULL);
|
gst_mini_object_replace ((GstMiniObject **) & subpicture->image, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
|
@ -101,7 +101,7 @@ gst_vaapi_subpicture_create (GstVaapiSubpicture * subpicture,
|
||||||
|
|
||||||
GST_VAAPI_DISPLAY_LOCK (display);
|
GST_VAAPI_DISPLAY_LOCK (display);
|
||||||
status = vaCreateSubpicture (GST_VAAPI_DISPLAY_VADISPLAY (display),
|
status = vaCreateSubpicture (GST_VAAPI_DISPLAY_VADISPLAY (display),
|
||||||
GST_VAAPI_OBJECT_ID (image), &subpicture_id);
|
GST_VAAPI_IMAGE_ID (image), &subpicture_id);
|
||||||
GST_VAAPI_DISPLAY_UNLOCK (display);
|
GST_VAAPI_DISPLAY_UNLOCK (display);
|
||||||
if (!vaapi_check_status (status, "vaCreateSubpicture()"))
|
if (!vaapi_check_status (status, "vaCreateSubpicture()"))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
@ -109,7 +109,8 @@ gst_vaapi_subpicture_create (GstVaapiSubpicture * subpicture,
|
||||||
GST_DEBUG ("subpicture %" GST_VAAPI_ID_FORMAT,
|
GST_DEBUG ("subpicture %" GST_VAAPI_ID_FORMAT,
|
||||||
GST_VAAPI_ID_ARGS (subpicture_id));
|
GST_VAAPI_ID_ARGS (subpicture_id));
|
||||||
GST_VAAPI_OBJECT_ID (subpicture) = subpicture_id;
|
GST_VAAPI_OBJECT_ID (subpicture) = subpicture_id;
|
||||||
subpicture->image = gst_vaapi_object_ref (image);
|
subpicture->image =
|
||||||
|
(GstVaapiImage *) gst_mini_object_ref (GST_MINI_OBJECT_CAST (image));
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -137,9 +138,9 @@ GST_VAAPI_OBJECT_DEFINE_CLASS (GstVaapiSubpicture, gst_vaapi_subpicture)
|
||||||
g_return_val_if_fail (image != NULL, NULL);
|
g_return_val_if_fail (image != NULL, NULL);
|
||||||
|
|
||||||
GST_DEBUG ("create from image %" GST_VAAPI_ID_FORMAT,
|
GST_DEBUG ("create from image %" GST_VAAPI_ID_FORMAT,
|
||||||
GST_VAAPI_ID_ARGS (GST_VAAPI_OBJECT_ID (image)));
|
GST_VAAPI_ID_ARGS (GST_VAAPI_IMAGE_ID (image)));
|
||||||
|
|
||||||
display = GST_VAAPI_OBJECT_DISPLAY (image);
|
display = GST_VAAPI_IMAGE_DISPLAY (image);
|
||||||
format = GST_VAAPI_IMAGE_FORMAT (image);
|
format = GST_VAAPI_IMAGE_FORMAT (image);
|
||||||
if (!gst_vaapi_display_has_subpicture_format (display, format, &va_flags))
|
if (!gst_vaapi_display_has_subpicture_format (display, format, &va_flags))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
|
@ -34,7 +34,6 @@
|
||||||
#include "gstvaapisurface_priv.h"
|
#include "gstvaapisurface_priv.h"
|
||||||
#include "gstvaapicontext.h"
|
#include "gstvaapicontext.h"
|
||||||
#include "gstvaapiimage.h"
|
#include "gstvaapiimage.h"
|
||||||
#include "gstvaapiimage_priv.h"
|
|
||||||
#include "gstvaapibufferproxy_priv.h"
|
#include "gstvaapibufferproxy_priv.h"
|
||||||
|
|
||||||
#define DEBUG 1
|
#define DEBUG 1
|
||||||
|
@ -558,7 +557,7 @@ gst_vaapi_surface_get_format (GstVaapiSurface * surface)
|
||||||
GstVaapiImage *const image = gst_vaapi_surface_derive_image (surface);
|
GstVaapiImage *const image = gst_vaapi_surface_derive_image (surface);
|
||||||
if (image) {
|
if (image) {
|
||||||
surface->format = GST_VAAPI_IMAGE_FORMAT (image);
|
surface->format = GST_VAAPI_IMAGE_FORMAT (image);
|
||||||
gst_vaapi_object_unref (image);
|
gst_vaapi_image_unref (image);
|
||||||
}
|
}
|
||||||
if (surface->format == GST_VIDEO_FORMAT_UNKNOWN)
|
if (surface->format == GST_VIDEO_FORMAT_UNKNOWN)
|
||||||
surface->format = GST_VIDEO_FORMAT_ENCODED;
|
surface->format = GST_VIDEO_FORMAT_ENCODED;
|
||||||
|
@ -638,7 +637,7 @@ gst_vaapi_surface_get_size (GstVaapiSurface * surface,
|
||||||
* unreferenced when it's no longer needed. The image and image buffer
|
* unreferenced when it's no longer needed. The image and image buffer
|
||||||
* data structures will be destroyed. However, the surface contents
|
* data structures will be destroyed. However, the surface contents
|
||||||
* will remain unchanged until destroyed through the last call to
|
* will remain unchanged until destroyed through the last call to
|
||||||
* gst_vaapi_object_unref().
|
* gst_vaapi_image_unref().
|
||||||
*
|
*
|
||||||
* Return value: the newly allocated #GstVaapiImage object, or %NULL
|
* Return value: the newly allocated #GstVaapiImage object, or %NULL
|
||||||
* on failure
|
* on failure
|
||||||
|
@ -702,7 +701,7 @@ gst_vaapi_surface_get_image (GstVaapiSurface * surface, GstVaapiImage * image)
|
||||||
if (width != surface->width || height != surface->height)
|
if (width != surface->width || height != surface->height)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
image_id = GST_VAAPI_OBJECT_ID (image);
|
image_id = GST_VAAPI_IMAGE_ID (image);
|
||||||
if (image_id == VA_INVALID_ID)
|
if (image_id == VA_INVALID_ID)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
|
@ -746,7 +745,7 @@ gst_vaapi_surface_put_image (GstVaapiSurface * surface, GstVaapiImage * image)
|
||||||
if (width != surface->width || height != surface->height)
|
if (width != surface->width || height != surface->height)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
image_id = GST_VAAPI_OBJECT_ID (image);
|
image_id = GST_VAAPI_IMAGE_ID (image);
|
||||||
if (image_id == VA_INVALID_ID)
|
if (image_id == VA_INVALID_ID)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
|
|
|
@ -39,7 +39,8 @@ gst_vaapi_surface_get_drm_buf_handle (GstVaapiSurface * surface, guint type)
|
||||||
/* The proxy takes ownership if the image, even creation failure. */
|
/* The proxy takes ownership if the image, even creation failure. */
|
||||||
proxy =
|
proxy =
|
||||||
gst_vaapi_buffer_proxy_new_from_object (GST_VAAPI_OBJECT (surface),
|
gst_vaapi_buffer_proxy_new_from_object (GST_VAAPI_OBJECT (surface),
|
||||||
image->internal_image.buf, type, gst_vaapi_object_unref, image);
|
image->internal_image.buf, type, (GDestroyNotify) gst_vaapi_image_unref,
|
||||||
|
image);
|
||||||
if (!proxy)
|
if (!proxy)
|
||||||
goto error_alloc_export_buffer;
|
goto error_alloc_export_buffer;
|
||||||
return proxy;
|
return proxy;
|
||||||
|
|
|
@ -67,8 +67,19 @@ gst_vaapi_video_pool_init (GstVaapiVideoPool * pool, GstVaapiDisplay * display,
|
||||||
void
|
void
|
||||||
gst_vaapi_video_pool_finalize (GstVaapiVideoPool * pool)
|
gst_vaapi_video_pool_finalize (GstVaapiVideoPool * pool)
|
||||||
{
|
{
|
||||||
g_list_free_full (pool->used_objects, gst_vaapi_object_unref);
|
if (pool->object_type == GST_VAAPI_VIDEO_POOL_OBJECT_TYPE_IMAGE) {
|
||||||
g_queue_foreach (&pool->free_objects, (GFunc) gst_vaapi_object_unref, NULL);
|
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) {
|
||||||
|
g_queue_foreach (&pool->free_objects, (GFunc) gst_mini_object_unref, NULL);
|
||||||
|
} else {
|
||||||
|
g_queue_foreach (&pool->free_objects, (GFunc) gst_vaapi_object_unref, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
g_queue_clear (&pool->free_objects);
|
g_queue_clear (&pool->free_objects);
|
||||||
gst_vaapi_display_replace (&pool->display, NULL);
|
gst_vaapi_display_replace (&pool->display, NULL);
|
||||||
g_mutex_clear (&pool->mutex);
|
g_mutex_clear (&pool->mutex);
|
||||||
|
@ -183,7 +194,12 @@ gst_vaapi_video_pool_get_object_unlocked (GstVaapiVideoPool * pool)
|
||||||
|
|
||||||
++pool->used_count;
|
++pool->used_count;
|
||||||
pool->used_objects = g_list_prepend (pool->used_objects, object);
|
pool->used_objects = g_list_prepend (pool->used_objects, object);
|
||||||
return gst_vaapi_object_ref (object);
|
|
||||||
|
if (pool->object_type == GST_VAAPI_VIDEO_POOL_OBJECT_TYPE_IMAGE)
|
||||||
|
object = gst_mini_object_ref (GST_MINI_OBJECT_CAST (object));
|
||||||
|
else
|
||||||
|
object = gst_vaapi_object_ref (object);
|
||||||
|
return object;
|
||||||
}
|
}
|
||||||
|
|
||||||
gpointer
|
gpointer
|
||||||
|
@ -219,7 +235,11 @@ gst_vaapi_video_pool_put_object_unlocked (GstVaapiVideoPool * pool,
|
||||||
if (!elem)
|
if (!elem)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
gst_vaapi_object_unref (object);
|
if (pool->object_type == GST_VAAPI_VIDEO_POOL_OBJECT_TYPE_IMAGE)
|
||||||
|
gst_mini_object_unref (GST_MINI_OBJECT_CAST (object));
|
||||||
|
else
|
||||||
|
gst_vaapi_object_unref (object);
|
||||||
|
|
||||||
--pool->used_count;
|
--pool->used_count;
|
||||||
pool->used_objects = g_list_delete_link (pool->used_objects, elem);
|
pool->used_objects = g_list_delete_link (pool->used_objects, elem);
|
||||||
g_queue_push_tail (&pool->free_objects, object);
|
g_queue_push_tail (&pool->free_objects, object);
|
||||||
|
@ -251,7 +271,12 @@ static inline gboolean
|
||||||
gst_vaapi_video_pool_add_object_unlocked (GstVaapiVideoPool * pool,
|
gst_vaapi_video_pool_add_object_unlocked (GstVaapiVideoPool * pool,
|
||||||
gpointer object)
|
gpointer object)
|
||||||
{
|
{
|
||||||
g_queue_push_tail (&pool->free_objects, gst_vaapi_object_ref (object));
|
if (pool->object_type == GST_VAAPI_VIDEO_POOL_OBJECT_TYPE_IMAGE) {
|
||||||
|
g_queue_push_tail (&pool->free_objects,
|
||||||
|
gst_mini_object_ref (GST_MINI_OBJECT_CAST (object)));
|
||||||
|
} else {
|
||||||
|
g_queue_push_tail (&pool->free_objects, gst_vaapi_object_ref (object));
|
||||||
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -39,6 +39,7 @@
|
||||||
#include "gstvaapisurface_priv.h"
|
#include "gstvaapisurface_priv.h"
|
||||||
#include "gstvaapiutils.h"
|
#include "gstvaapiutils.h"
|
||||||
#include "gstvaapiutils_x11.h"
|
#include "gstvaapiutils_x11.h"
|
||||||
|
#include "gstvaapisurface_priv.h"
|
||||||
|
|
||||||
GST_DEBUG_CATEGORY_EXTERN (gst_debug_vaapi_window);
|
GST_DEBUG_CATEGORY_EXTERN (gst_debug_vaapi_window);
|
||||||
#define GST_CAT_DEFAULT gst_debug_vaapi_window
|
#define GST_CAT_DEFAULT gst_debug_vaapi_window
|
||||||
|
|
|
@ -1401,7 +1401,7 @@ extract_allowed_surface_formats (GstVaapiDisplay * display,
|
||||||
if (res)
|
if (res)
|
||||||
g_array_append_val (out_formats, img_format);
|
g_array_append_val (out_formats, img_format);
|
||||||
|
|
||||||
gst_vaapi_object_unref (image);
|
gst_vaapi_image_unref (image);
|
||||||
/* Just reuse the surface if the format is specified */
|
/* Just reuse the surface if the format is specified */
|
||||||
if (specified_format == GST_VIDEO_FORMAT_UNKNOWN)
|
if (specified_format == GST_VIDEO_FORMAT_UNKNOWN)
|
||||||
gst_vaapi_object_replace (&surface, NULL);
|
gst_vaapi_object_replace (&surface, NULL);
|
||||||
|
|
|
@ -128,7 +128,7 @@ ensure_image (GstVaapiVideoMemory * mem)
|
||||||
reset_image_usage (&mem->usage_flag);
|
reset_image_usage (&mem->usage_flag);
|
||||||
} else if (gst_vaapi_surface_get_format (mem->surface) !=
|
} else if (gst_vaapi_surface_get_format (mem->surface) !=
|
||||||
GST_VIDEO_INFO_FORMAT (mem->image_info)) {
|
GST_VIDEO_INFO_FORMAT (mem->image_info)) {
|
||||||
gst_vaapi_object_replace (&mem->image, NULL);
|
gst_mini_object_replace ((GstMiniObject **) & mem->image, NULL);
|
||||||
reset_image_usage (&mem->usage_flag);
|
reset_image_usage (&mem->usage_flag);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -393,7 +393,7 @@ gst_vaapi_video_memory_reset_image (GstVaapiVideoMemory * mem)
|
||||||
GST_VAAPI_VIDEO_ALLOCATOR_CAST (GST_MEMORY_CAST (mem)->allocator);
|
GST_VAAPI_VIDEO_ALLOCATOR_CAST (GST_MEMORY_CAST (mem)->allocator);
|
||||||
|
|
||||||
if (!use_native_formats (mem->usage_flag))
|
if (!use_native_formats (mem->usage_flag))
|
||||||
gst_vaapi_object_replace (&mem->image, NULL);
|
gst_mini_object_replace ((GstMiniObject **) & mem->image, NULL);
|
||||||
else if (mem->image) {
|
else if (mem->image) {
|
||||||
gst_vaapi_video_pool_put_object (allocator->image_pool, mem->image);
|
gst_vaapi_video_pool_put_object (allocator->image_pool, mem->image);
|
||||||
mem->image = NULL;
|
mem->image = NULL;
|
||||||
|
@ -703,7 +703,7 @@ gst_video_info_update_from_surface (GstVideoInfo * vip,
|
||||||
gst_vaapi_image_unmap (image);
|
gst_vaapi_image_unmap (image);
|
||||||
|
|
||||||
bail:
|
bail:
|
||||||
gst_vaapi_object_unref (image);
|
gst_vaapi_image_unref (image);
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
/* ERRORS */
|
/* ERRORS */
|
||||||
|
@ -912,7 +912,7 @@ allocator_configure_image_info (GstVaapiDisplay * display,
|
||||||
|
|
||||||
bail:
|
bail:
|
||||||
if (image)
|
if (image)
|
||||||
gst_vaapi_object_unref (image);
|
gst_vaapi_image_unref (image);
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
/* ERRORS */
|
/* ERRORS */
|
||||||
|
|
|
@ -78,8 +78,9 @@ set_display (GstVaapiVideoMeta * meta, GstVaapiDisplay * display)
|
||||||
static inline void
|
static inline void
|
||||||
set_image (GstVaapiVideoMeta * meta, GstVaapiImage * image)
|
set_image (GstVaapiVideoMeta * meta, GstVaapiImage * image)
|
||||||
{
|
{
|
||||||
meta->image = gst_vaapi_object_ref (image);
|
meta->image =
|
||||||
set_display (meta, gst_vaapi_object_get_display (GST_VAAPI_OBJECT (image)));
|
(GstVaapiImage *) gst_mini_object_ref (GST_MINI_OBJECT_CAST (image));
|
||||||
|
set_display (meta, gst_vaapi_image_get_display (image));
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
|
@ -131,7 +132,7 @@ gst_vaapi_video_meta_destroy_image (GstVaapiVideoMeta * meta)
|
||||||
if (meta->image) {
|
if (meta->image) {
|
||||||
if (meta->image_pool)
|
if (meta->image_pool)
|
||||||
gst_vaapi_video_pool_put_object (meta->image_pool, meta->image);
|
gst_vaapi_video_pool_put_object (meta->image_pool, meta->image);
|
||||||
gst_vaapi_object_unref (meta->image);
|
gst_vaapi_image_unref (meta->image);
|
||||||
meta->image = NULL;
|
meta->image = NULL;
|
||||||
}
|
}
|
||||||
gst_vaapi_video_pool_replace (&meta->image_pool, NULL);
|
gst_vaapi_video_pool_replace (&meta->image_pool, NULL);
|
||||||
|
@ -228,7 +229,8 @@ gst_vaapi_video_meta_copy (GstVaapiVideoMeta * meta)
|
||||||
copy->ref_count = 1;
|
copy->ref_count = 1;
|
||||||
copy->display = gst_object_ref (meta->display);
|
copy->display = gst_object_ref (meta->display);
|
||||||
copy->image_pool = NULL;
|
copy->image_pool = NULL;
|
||||||
copy->image = meta->image ? gst_vaapi_object_ref (meta->image) : NULL;
|
copy->image = meta->image ? (GstVaapiImage *)
|
||||||
|
gst_mini_object_ref (GST_MINI_OBJECT_CAST (meta->image)) : NULL;
|
||||||
copy->proxy = meta->proxy ? gst_vaapi_surface_proxy_copy (meta->proxy) : NULL;
|
copy->proxy = meta->proxy ? gst_vaapi_surface_proxy_copy (meta->proxy) : NULL;
|
||||||
copy->converter = meta->converter;
|
copy->converter = meta->converter;
|
||||||
copy->render_flags = meta->render_flags;
|
copy->render_flags = meta->render_flags;
|
||||||
|
@ -462,7 +464,7 @@ gst_vaapi_video_meta_get_display (GstVaapiVideoMeta * meta)
|
||||||
*
|
*
|
||||||
* Retrieves the #GstVaapiImage bound to the @meta. The @meta owns
|
* Retrieves the #GstVaapiImage bound to the @meta. The @meta owns
|
||||||
* the #GstVaapiImage so the caller is responsible for calling
|
* the #GstVaapiImage so the caller is responsible for calling
|
||||||
* gst_vaapi_object_ref() when needed.
|
* gst_mini_object_ref() when needed.
|
||||||
*
|
*
|
||||||
* Return value: the #GstVaapiImage bound to the @meta, or %NULL if
|
* Return value: the #GstVaapiImage bound to the @meta, or %NULL if
|
||||||
* there is none
|
* there is none
|
||||||
|
@ -526,7 +528,7 @@ gst_vaapi_video_meta_set_image_from_pool (GstVaapiVideoMeta * meta,
|
||||||
*
|
*
|
||||||
* Retrieves the #GstVaapiSurface bound to the @meta. The @meta
|
* Retrieves the #GstVaapiSurface bound to the @meta. The @meta
|
||||||
* owns the #GstVaapiSurface so the caller is responsible for calling
|
* owns the #GstVaapiSurface so the caller is responsible for calling
|
||||||
* gst_vaapi_object_ref() when needed.
|
* gst_mini_object_ref() when needed.
|
||||||
*
|
*
|
||||||
* Return value: the #GstVaapiSurface bound to the @meta, or %NULL if
|
* Return value: the #GstVaapiSurface bound to the @meta, or %NULL if
|
||||||
* there is none
|
* there is none
|
||||||
|
|
|
@ -87,7 +87,7 @@ image_generate_full (GstVaapiDisplay * display,
|
||||||
return image;
|
return image;
|
||||||
|
|
||||||
error:
|
error:
|
||||||
gst_vaapi_object_unref (image);
|
gst_vaapi_image_unref (image);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -321,7 +321,7 @@ image_draw_rectangle (GstVaapiImage * image,
|
||||||
if (height > image_height - y)
|
if (height > image_height - y)
|
||||||
height = image_height - y;
|
height = image_height - y;
|
||||||
|
|
||||||
display = gst_vaapi_object_get_display (GST_VAAPI_OBJECT (image));
|
display = gst_vaapi_image_get_display (image);
|
||||||
if (!display)
|
if (!display)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
|
@ -374,7 +374,7 @@ image_upload (GstVaapiImage * image, GstVaapiSurface * surface)
|
||||||
surface_image = gst_vaapi_surface_derive_image (surface);
|
surface_image = gst_vaapi_surface_derive_image (surface);
|
||||||
if (surface_image) {
|
if (surface_image) {
|
||||||
success = gst_vaapi_image_copy (surface_image, image);
|
success = gst_vaapi_image_copy (surface_image, image);
|
||||||
gst_vaapi_object_unref (surface_image);
|
gst_vaapi_image_unref (surface_image);
|
||||||
if (success)
|
if (success)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
|
@ -456,7 +456,7 @@ app_run (App * app)
|
||||||
ret = EXIT_SUCCESS;
|
ret = EXIT_SUCCESS;
|
||||||
|
|
||||||
gst_vaapi_video_pool_replace (&pool, NULL);
|
gst_vaapi_video_pool_replace (&pool, NULL);
|
||||||
gst_vaapi_object_unref (image);
|
gst_vaapi_image_unref (image);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -638,7 +638,7 @@ app_run (App * app)
|
||||||
ret = EXIT_SUCCESS;
|
ret = EXIT_SUCCESS;
|
||||||
|
|
||||||
gst_vaapi_video_pool_replace (&pool, NULL);
|
gst_vaapi_video_pool_replace (&pool, NULL);
|
||||||
gst_vaapi_object_unref (image);
|
gst_vaapi_image_unref (image);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -117,7 +117,7 @@ create_test_surface (GstVaapiDisplay * display, guint width, guint height,
|
||||||
if (!image_upload (image, surface))
|
if (!image_upload (image, surface))
|
||||||
goto error_upload_image;
|
goto error_upload_image;
|
||||||
|
|
||||||
gst_vaapi_object_unref (image);
|
gst_vaapi_image_unref (image);
|
||||||
return surface;
|
return surface;
|
||||||
|
|
||||||
/* ERRORS */
|
/* ERRORS */
|
||||||
|
@ -139,7 +139,7 @@ error_upload_image:
|
||||||
goto error_cleanup;
|
goto error_cleanup;
|
||||||
error_cleanup:
|
error_cleanup:
|
||||||
if (image)
|
if (image)
|
||||||
gst_vaapi_object_unref (image);
|
gst_vaapi_image_unref (image);
|
||||||
if (surface)
|
if (surface)
|
||||||
gst_vaapi_object_unref (surface);
|
gst_vaapi_object_unref (surface);
|
||||||
if (error_ptr)
|
if (error_ptr)
|
||||||
|
|
|
@ -89,7 +89,7 @@ create_test_surface (GstVaapiDisplay * display, guint width, guint height)
|
||||||
if (!gst_vaapi_surface_sync (surface))
|
if (!gst_vaapi_surface_sync (surface))
|
||||||
g_error ("could not complete image upload");
|
g_error ("could not complete image upload");
|
||||||
|
|
||||||
gst_vaapi_object_unref (image);
|
gst_vaapi_image_unref (image);
|
||||||
return surface;
|
return surface;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue