mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-26 17:18:15 +00:00
Move "id" down to the GstVaapiObject base.
This commit is contained in:
parent
1a90e11ae5
commit
a91206bbc1
12 changed files with 143 additions and 175 deletions
|
@ -200,6 +200,7 @@ GST_VAAPI_WINDOW_GET_CLASS
|
|||
GstVaapiObject
|
||||
GstVaapiObjectClass
|
||||
gst_vaapi_object_get_display
|
||||
gst_vaapi_object_get_id
|
||||
<SUBSECTION Standard>
|
||||
GST_VAAPI_OBJECT
|
||||
GST_VAAPI_IS_OBJECT
|
||||
|
@ -220,7 +221,6 @@ GstVaapiImage
|
|||
GstVaapiImageClass
|
||||
gst_vaapi_image_new
|
||||
gst_vaapi_image_new_with_image
|
||||
gst_vaapi_image_get_id
|
||||
gst_vaapi_image_get_image
|
||||
gst_vaapi_image_get_format
|
||||
gst_vaapi_image_get_width
|
||||
|
@ -253,7 +253,6 @@ GstVaapiSurfaceRenderFlags
|
|||
GstVaapiSurface
|
||||
GstVaapiSurfaceClass
|
||||
gst_vaapi_surface_new
|
||||
gst_vaapi_surface_get_id
|
||||
gst_vaapi_surface_get_chroma_type
|
||||
gst_vaapi_surface_get_width
|
||||
gst_vaapi_surface_get_height
|
||||
|
@ -280,7 +279,6 @@ GST_VAAPI_SURFACE_GET_CLASS
|
|||
GstVaapiSubpicture
|
||||
GstVaapiSubpictureClass
|
||||
gst_vaapi_subpicture_new
|
||||
gst_vaapi_subpicture_get_id
|
||||
gst_vaapi_subpicture_get_image
|
||||
gst_vaapi_subpicture_set_image
|
||||
<SUBSECTION Standard>
|
||||
|
|
|
@ -56,7 +56,6 @@ enum {
|
|||
PROP_0,
|
||||
|
||||
PROP_IMAGE,
|
||||
PROP_IMAGE_ID,
|
||||
PROP_FORMAT,
|
||||
PROP_WIDTH,
|
||||
PROP_HEIGHT
|
||||
|
@ -147,24 +146,22 @@ static void
|
|||
gst_vaapi_image_destroy(GstVaapiImage *image)
|
||||
{
|
||||
GstVaapiDisplay * const display = GST_VAAPI_OBJECT_GET_DISPLAY(image);
|
||||
GstVaapiImagePrivate * const priv = image->priv;
|
||||
VAImageID image_id;
|
||||
VAStatus status;
|
||||
|
||||
_gst_vaapi_image_unmap(image);
|
||||
|
||||
GST_DEBUG("image 0x%08x", priv->internal_image.image_id);
|
||||
image_id = GST_VAAPI_OBJECT_ID(image);
|
||||
GST_DEBUG("image %" GST_VAAPI_ID_FORMAT, GST_VAAPI_ID_ARGS(image_id));
|
||||
|
||||
if (priv->internal_image.image_id != VA_INVALID_ID) {
|
||||
if (image_id != VA_INVALID_ID) {
|
||||
GST_VAAPI_DISPLAY_LOCK(display);
|
||||
status = vaDestroyImage(
|
||||
GST_VAAPI_DISPLAY_VADISPLAY(display),
|
||||
priv->internal_image.image_id
|
||||
);
|
||||
status = vaDestroyImage(GST_VAAPI_DISPLAY_VADISPLAY(display), image_id);
|
||||
GST_VAAPI_DISPLAY_UNLOCK(display);
|
||||
if (!vaapi_check_status(status, "vaDestroyImage()"))
|
||||
g_warning("failed to destroy image 0x%08x\n",
|
||||
priv->internal_image.image_id);
|
||||
priv->internal_image.image_id = VA_INVALID_ID;
|
||||
g_warning("failed to destroy image %" GST_VAAPI_ID_FORMAT "\n",
|
||||
GST_VAAPI_ID_ARGS(image_id));
|
||||
GST_VAAPI_OBJECT_ID(image) = VA_INVALID_ID;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -206,6 +203,7 @@ gst_vaapi_image_create(GstVaapiImage *image)
|
|||
GstVaapiImagePrivate * const priv = image->priv;
|
||||
GstVaapiImageFormat format = priv->format;
|
||||
const VAImageFormat *va_format;
|
||||
VAImageID image_id;
|
||||
|
||||
if (!priv->create_image)
|
||||
return (priv->image.image_id != VA_INVALID_ID &&
|
||||
|
@ -227,6 +225,7 @@ gst_vaapi_image_create(GstVaapiImage *image)
|
|||
return FALSE;
|
||||
}
|
||||
priv->image = priv->internal_image;
|
||||
image_id = priv->image.image_id;
|
||||
|
||||
if (priv->format != priv->internal_format) {
|
||||
switch (priv->format) {
|
||||
|
@ -243,9 +242,10 @@ gst_vaapi_image_create(GstVaapiImage *image)
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
GST_DEBUG("image 0x%08x", priv->image.image_id);
|
||||
priv->is_linear = vaapi_image_is_linear(&priv->image);
|
||||
|
||||
GST_DEBUG("image %" GST_VAAPI_ID_FORMAT, GST_VAAPI_ID_ARGS(image_id));
|
||||
GST_VAAPI_OBJECT_ID(image) = image_id;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
@ -304,9 +304,6 @@ gst_vaapi_image_get_property(
|
|||
case PROP_IMAGE:
|
||||
g_value_set_boxed(value, &image->priv->image);
|
||||
break;
|
||||
case PROP_IMAGE_ID:
|
||||
g_value_set_uint(value, gst_vaapi_image_get_id(image));
|
||||
break;
|
||||
case PROP_FORMAT:
|
||||
g_value_set_uint(value, gst_vaapi_image_get_format(image));
|
||||
break;
|
||||
|
@ -356,20 +353,6 @@ gst_vaapi_image_class_init(GstVaapiImageClass *klass)
|
|||
VAAPI_TYPE_IMAGE,
|
||||
G_PARAM_READWRITE|G_PARAM_CONSTRUCT_ONLY));
|
||||
|
||||
/**
|
||||
* GstVaapiImage:id:
|
||||
*
|
||||
* The underlying #VAImageID of the image.
|
||||
*/
|
||||
g_object_class_install_property
|
||||
(object_class,
|
||||
PROP_IMAGE_ID,
|
||||
g_param_spec_uint("id",
|
||||
"VA image id",
|
||||
"The underlying VA image id",
|
||||
0, G_MAXUINT32, VA_INVALID_ID,
|
||||
G_PARAM_READABLE));
|
||||
|
||||
g_object_class_install_property
|
||||
(object_class,
|
||||
PROP_WIDTH,
|
||||
|
@ -517,23 +500,6 @@ gst_vaapi_image_new_with_image(GstVaapiDisplay *display, VAImage *va_image)
|
|||
return image;
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_vaapi_image_get_id:
|
||||
* @image: a #GstVaapiImage
|
||||
*
|
||||
* Returns the underlying VAImageID of the @image.
|
||||
*
|
||||
* Return value: the underlying VA image id
|
||||
*/
|
||||
VAImageID
|
||||
gst_vaapi_image_get_id(GstVaapiImage *image)
|
||||
{
|
||||
g_return_val_if_fail(GST_VAAPI_IS_IMAGE(image), VA_INVALID_ID);
|
||||
g_return_val_if_fail(image->priv->is_constructed, VA_INVALID_ID);
|
||||
|
||||
return image->priv->image.image_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_vaapi_image_get_image:
|
||||
* @image: a #GstVaapiImage
|
||||
|
|
|
@ -116,9 +116,6 @@ gst_vaapi_image_new(
|
|||
GstVaapiImage *
|
||||
gst_vaapi_image_new_with_image(GstVaapiDisplay *display, VAImage *va_image);
|
||||
|
||||
VAImageID
|
||||
gst_vaapi_image_get_id(GstVaapiImage *image);
|
||||
|
||||
gboolean
|
||||
gst_vaapi_image_get_image(GstVaapiImage *image, VAImage *va_image);
|
||||
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
#include "config.h"
|
||||
#include "gstvaapiobject.h"
|
||||
#include "gstvaapiobject_priv.h"
|
||||
#include "gstvaapiparamspecs.h"
|
||||
#include "gstvaapimarshal.h"
|
||||
|
||||
#define DEBUG 1
|
||||
|
@ -37,6 +38,7 @@ enum {
|
|||
PROP_0,
|
||||
|
||||
PROP_DISPLAY,
|
||||
PROP_ID
|
||||
};
|
||||
|
||||
enum {
|
||||
|
@ -66,6 +68,8 @@ gst_vaapi_object_finalize(GObject *object)
|
|||
{
|
||||
GstVaapiObjectPrivate * const priv = GST_VAAPI_OBJECT(object)->priv;
|
||||
|
||||
priv->id = VA_INVALID_ID;
|
||||
|
||||
if (priv->display) {
|
||||
g_object_unref(priv->display);
|
||||
priv->display = NULL;
|
||||
|
@ -88,6 +92,9 @@ gst_vaapi_object_set_property(
|
|||
case PROP_DISPLAY:
|
||||
object->priv->display = g_object_ref(g_value_get_object(value));
|
||||
break;
|
||||
case PROP_ID:
|
||||
object->priv->id = gst_vaapi_value_get_id(value);
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID(gobject, prop_id, pspec);
|
||||
break;
|
||||
|
@ -108,6 +115,9 @@ gst_vaapi_object_get_property(
|
|||
case PROP_DISPLAY:
|
||||
g_value_set_object(value, gst_vaapi_object_get_display(object));
|
||||
break;
|
||||
case PROP_ID:
|
||||
gst_vaapi_value_set_id(value, gst_vaapi_object_get_id(object));
|
||||
break;
|
||||
default:
|
||||
G_OBJECT_WARN_INVALID_PROPERTY_ID(gobject, prop_id, pspec);
|
||||
break;
|
||||
|
@ -140,6 +150,20 @@ gst_vaapi_object_class_init(GstVaapiObjectClass *klass)
|
|||
GST_VAAPI_TYPE_DISPLAY,
|
||||
G_PARAM_READWRITE|G_PARAM_CONSTRUCT_ONLY));
|
||||
|
||||
/**
|
||||
* GstVaapiObject:id:
|
||||
*
|
||||
* The #GstVaapiID contained in this object.
|
||||
*/
|
||||
g_object_class_install_property
|
||||
(object_class,
|
||||
PROP_ID,
|
||||
gst_vaapi_param_spec_id("id",
|
||||
"ID",
|
||||
"The GstVaapiID contained in this object",
|
||||
VA_INVALID_ID,
|
||||
G_PARAM_READWRITE|G_PARAM_CONSTRUCT_ONLY));
|
||||
|
||||
/**
|
||||
* GstVaapiObject::destroy:
|
||||
* @object: the object which received the signal
|
||||
|
@ -165,6 +189,7 @@ gst_vaapi_object_init(GstVaapiObject *object)
|
|||
|
||||
object->priv = priv;
|
||||
priv->display = NULL;
|
||||
priv->id = VA_INVALID_ID;
|
||||
priv->is_destroying = FALSE;
|
||||
}
|
||||
|
||||
|
@ -183,3 +208,19 @@ gst_vaapi_object_get_display(GstVaapiObject *object)
|
|||
|
||||
return object->priv->display;
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_vaapi_object_get_id:
|
||||
* @object: a #GstVaapiObject
|
||||
*
|
||||
* Returns the #GstVaapiID contained in the @object.
|
||||
*
|
||||
* Return value: the #GstVaapiID of the @object
|
||||
*/
|
||||
GstVaapiID
|
||||
gst_vaapi_object_get_id(GstVaapiObject *object)
|
||||
{
|
||||
g_return_val_if_fail(GST_VAAPI_IS_OBJECT(object), NULL);
|
||||
|
||||
return object->priv->id;
|
||||
}
|
||||
|
|
|
@ -86,6 +86,9 @@ gst_vaapi_object_get_type(void);
|
|||
GstVaapiDisplay *
|
||||
gst_vaapi_object_get_display(GstVaapiObject *object);
|
||||
|
||||
GstVaapiID
|
||||
gst_vaapi_object_get_id(GstVaapiObject *object);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* GST_VAAPI_OBJECT_H */
|
||||
|
|
|
@ -30,15 +30,27 @@ G_BEGIN_DECLS
|
|||
GST_VAAPI_TYPE_OBJECT, \
|
||||
GstVaapiObjectPrivate))
|
||||
|
||||
#define GST_VAAPI_OBJECT_CAST(object) ((GstVaapiObject *)(object))
|
||||
|
||||
/**
|
||||
* GST_VAAPI_OBJECT_GET_DISPLAY:
|
||||
* @object: a #GstVaapiObject
|
||||
*
|
||||
* Macro that evaluates to the #GstVaapiDisplay @object is bound to.
|
||||
* This is an internal macro that does not do any run-time type checks.
|
||||
* Macro that evaluates to the #GstVaapiDisplay the @object is bound to.
|
||||
* This is an internal macro that does not do any run-time type check.
|
||||
*/
|
||||
#define GST_VAAPI_OBJECT_GET_DISPLAY(object) \
|
||||
(((GstVaapiObject *)(object))->priv->display)
|
||||
GST_VAAPI_OBJECT_CAST(object)->priv->display
|
||||
|
||||
/**
|
||||
* GST_VAAPI_OBJECT_ID:
|
||||
* @object: a #GstVaapiObject
|
||||
*
|
||||
* Macro that evaluates to the #GstVaapiID contained in @object.
|
||||
* This is an internal macro that does not do any run-time type checks.
|
||||
*/
|
||||
#define GST_VAAPI_OBJECT_ID(object) \
|
||||
GST_VAAPI_OBJECT_CAST(object)->priv->id
|
||||
|
||||
/**
|
||||
* GstVaapiObjectPrivate:
|
||||
|
@ -47,6 +59,7 @@ G_BEGIN_DECLS
|
|||
*/
|
||||
struct _GstVaapiObjectPrivate {
|
||||
GstVaapiDisplay *display;
|
||||
GstVaapiID id;
|
||||
guint is_destroying : 1;
|
||||
};
|
||||
|
||||
|
|
|
@ -40,14 +40,12 @@ G_DEFINE_TYPE(GstVaapiSubpicture, gst_vaapi_subpicture, GST_VAAPI_TYPE_OBJECT);
|
|||
GstVaapiSubpicturePrivate))
|
||||
|
||||
struct _GstVaapiSubpicturePrivate {
|
||||
VASubpictureID subpicture_id;
|
||||
GstVaapiImage *image;
|
||||
};
|
||||
|
||||
enum {
|
||||
PROP_0,
|
||||
|
||||
PROP_SUBPICTURE_ID,
|
||||
PROP_IMAGE
|
||||
};
|
||||
|
||||
|
@ -56,23 +54,26 @@ gst_vaapi_subpicture_destroy(GstVaapiSubpicture *subpicture)
|
|||
{
|
||||
GstVaapiDisplay * const display = GST_VAAPI_OBJECT_GET_DISPLAY(subpicture);
|
||||
GstVaapiSubpicturePrivate * const priv = subpicture->priv;
|
||||
VASubpictureID subpicture_id;
|
||||
VAStatus status;
|
||||
|
||||
GST_DEBUG("subpicture 0x%08x", priv->subpicture_id);
|
||||
subpicture_id = GST_VAAPI_OBJECT_ID(subpicture);
|
||||
GST_DEBUG("subpicture %" GST_VAAPI_ID_FORMAT,
|
||||
GST_VAAPI_ID_ARGS(subpicture_id));
|
||||
|
||||
if (priv->subpicture_id != VA_INVALID_ID) {
|
||||
if (subpicture_id != VA_INVALID_ID) {
|
||||
if (display) {
|
||||
GST_VAAPI_DISPLAY_LOCK(display);
|
||||
status = vaDestroySubpicture(
|
||||
GST_VAAPI_DISPLAY_VADISPLAY(display),
|
||||
priv->subpicture_id
|
||||
subpicture_id
|
||||
);
|
||||
GST_VAAPI_DISPLAY_UNLOCK(display);
|
||||
if (!vaapi_check_status(status, "vaDestroySubpicture()"))
|
||||
g_warning("failed to destroy subpicture 0x%08x\n",
|
||||
priv->subpicture_id);
|
||||
g_warning("failed to destroy subpicture %" GST_VAAPI_ID_FORMAT "\n",
|
||||
GST_VAAPI_ID_ARGS(subpicture_id));
|
||||
}
|
||||
priv->subpicture_id = VA_INVALID_ID;
|
||||
GST_VAAPI_OBJECT_ID(subpicture) = VA_INVALID_ID;
|
||||
}
|
||||
|
||||
if (priv->image) {
|
||||
|
@ -95,15 +96,16 @@ gst_vaapi_subpicture_create(GstVaapiSubpicture *subpicture)
|
|||
GST_VAAPI_DISPLAY_LOCK(display);
|
||||
status = vaCreateSubpicture(
|
||||
GST_VAAPI_DISPLAY_VADISPLAY(display),
|
||||
gst_vaapi_image_get_id(priv->image),
|
||||
GST_VAAPI_OBJECT_ID(priv->image),
|
||||
&subpicture_id
|
||||
);
|
||||
GST_VAAPI_DISPLAY_UNLOCK(display);
|
||||
if (!vaapi_check_status(status, "vaCreateSubpicture()"))
|
||||
return FALSE;
|
||||
|
||||
GST_DEBUG("subpicture 0x%08x", subpicture_id);
|
||||
priv->subpicture_id = subpicture_id;
|
||||
GST_DEBUG("subpicture %" GST_VAAPI_ID_FORMAT,
|
||||
GST_VAAPI_ID_ARGS(subpicture_id));
|
||||
GST_VAAPI_OBJECT_ID(subpicture) = subpicture_id;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
@ -146,9 +148,6 @@ gst_vaapi_subpicture_get_property(
|
|||
GstVaapiSubpicture * const subpicture = GST_VAAPI_SUBPICTURE(object);
|
||||
|
||||
switch (prop_id) {
|
||||
case PROP_SUBPICTURE_ID:
|
||||
g_value_set_uint(value, gst_vaapi_subpicture_get_id(subpicture));
|
||||
break;
|
||||
case PROP_IMAGE:
|
||||
g_value_set_object(value, gst_vaapi_subpicture_get_image(subpicture));
|
||||
break;
|
||||
|
@ -169,20 +168,6 @@ gst_vaapi_subpicture_class_init(GstVaapiSubpictureClass *klass)
|
|||
object_class->set_property = gst_vaapi_subpicture_set_property;
|
||||
object_class->get_property = gst_vaapi_subpicture_get_property;
|
||||
|
||||
/**
|
||||
* GstVaapiSubpicture:id:
|
||||
*
|
||||
* The underlying #VASubpictureID of the subpicture.
|
||||
*/
|
||||
g_object_class_install_property
|
||||
(object_class,
|
||||
PROP_SUBPICTURE_ID,
|
||||
g_param_spec_uint("id",
|
||||
"VA subpicture id",
|
||||
"The underlying VA subpicture id",
|
||||
0, G_MAXUINT32, VA_INVALID_ID,
|
||||
G_PARAM_READABLE));
|
||||
|
||||
/**
|
||||
* GstVaapiSubpicture:image:
|
||||
*
|
||||
|
@ -204,7 +189,6 @@ gst_vaapi_subpicture_init(GstVaapiSubpicture *subpicture)
|
|||
GstVaapiSubpicturePrivate *priv = GST_VAAPI_SUBPICTURE_GET_PRIVATE(subpicture);
|
||||
|
||||
subpicture->priv = priv;
|
||||
priv->subpicture_id = VA_INVALID_ID;
|
||||
priv->image = NULL;
|
||||
}
|
||||
|
||||
|
@ -222,7 +206,8 @@ gst_vaapi_subpicture_new(GstVaapiImage *image)
|
|||
{
|
||||
g_return_val_if_fail(GST_VAAPI_IS_IMAGE(image), NULL);
|
||||
|
||||
GST_DEBUG("create from image 0x%08x", gst_vaapi_image_get_id(image));
|
||||
GST_DEBUG("create from image %" GST_VAAPI_ID_FORMAT,
|
||||
GST_VAAPI_ID_ARGS(GST_VAAPI_OBJECT_ID(image)));
|
||||
|
||||
return g_object_new(GST_VAAPI_TYPE_SUBPICTURE,
|
||||
"display", GST_VAAPI_OBJECT_GET_DISPLAY(image),
|
||||
|
@ -230,22 +215,6 @@ gst_vaapi_subpicture_new(GstVaapiImage *image)
|
|||
NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_vaapi_subpicture_get_id:
|
||||
* @subpicture: a #GstVaapiSubpicture
|
||||
*
|
||||
* Returns the underlying VASubpictureID of the @subpicture.
|
||||
*
|
||||
* Return value: the underlying VA subpicture id
|
||||
*/
|
||||
VASubpictureID
|
||||
gst_vaapi_subpicture_get_id(GstVaapiSubpicture *subpicture)
|
||||
{
|
||||
g_return_val_if_fail(GST_VAAPI_IS_SUBPICTURE(subpicture), VA_INVALID_ID);
|
||||
|
||||
return subpicture->priv->subpicture_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_vaapi_subpicture_get_image:
|
||||
* @subpicture: a #GstVaapiSubpicture
|
||||
|
|
|
@ -83,9 +83,6 @@ gst_vaapi_subpicture_get_type(void);
|
|||
GstVaapiSubpicture *
|
||||
gst_vaapi_subpicture_new(GstVaapiImage *image);
|
||||
|
||||
VASubpictureID
|
||||
gst_vaapi_subpicture_get_id(GstVaapiSubpicture *subpicture);
|
||||
|
||||
GstVaapiImage *
|
||||
gst_vaapi_subpicture_get_image(GstVaapiSubpicture *subpicture);
|
||||
|
||||
|
|
|
@ -40,7 +40,6 @@ G_DEFINE_TYPE(GstVaapiSurface, gst_vaapi_surface, GST_VAAPI_TYPE_OBJECT);
|
|||
GstVaapiSurfacePrivate))
|
||||
|
||||
struct _GstVaapiSurfacePrivate {
|
||||
VASurfaceID surface_id;
|
||||
guint width;
|
||||
guint height;
|
||||
GstVaapiChromaType chroma_type;
|
||||
|
@ -50,7 +49,6 @@ struct _GstVaapiSurfacePrivate {
|
|||
enum {
|
||||
PROP_0,
|
||||
|
||||
PROP_SURFACE_ID,
|
||||
PROP_WIDTH,
|
||||
PROP_HEIGHT,
|
||||
PROP_CHROMA_TYPE
|
||||
|
@ -67,20 +65,23 @@ gst_vaapi_surface_destroy(GstVaapiSurface *surface)
|
|||
{
|
||||
GstVaapiDisplay * const display = GST_VAAPI_OBJECT_GET_DISPLAY(surface);
|
||||
GstVaapiSurfacePrivate * const priv = surface->priv;
|
||||
VASurfaceID surface_id;
|
||||
VAStatus status;
|
||||
|
||||
GST_DEBUG("surface 0x%08x", priv->surface_id);
|
||||
surface_id = GST_VAAPI_OBJECT_ID(surface);
|
||||
GST_DEBUG("surface %" GST_VAAPI_ID_FORMAT, GST_VAAPI_ID_ARGS(surface_id));
|
||||
|
||||
if (priv->surface_id != VA_INVALID_SURFACE) {
|
||||
if (surface_id != VA_INVALID_SURFACE) {
|
||||
GST_VAAPI_DISPLAY_LOCK(display);
|
||||
status = vaDestroySurfaces(
|
||||
GST_VAAPI_DISPLAY_VADISPLAY(display),
|
||||
&priv->surface_id, 1
|
||||
&surface_id, 1
|
||||
);
|
||||
GST_VAAPI_DISPLAY_UNLOCK(display);
|
||||
if (!vaapi_check_status(status, "vaDestroySurfaces()"))
|
||||
g_warning("failed to destroy surface 0x%08x\n", priv->surface_id);
|
||||
priv->surface_id = VA_INVALID_SURFACE;
|
||||
g_warning("failed to destroy surface %" GST_VAAPI_ID_FORMAT "\n",
|
||||
GST_VAAPI_ID_ARGS(surface_id));
|
||||
GST_VAAPI_OBJECT_ID(surface) = VA_INVALID_SURFACE;
|
||||
}
|
||||
|
||||
if (priv->subpictures) {
|
||||
|
@ -126,8 +127,8 @@ gst_vaapi_surface_create(GstVaapiSurface *surface)
|
|||
if (!vaapi_check_status(status, "vaCreateSurfaces()"))
|
||||
return FALSE;
|
||||
|
||||
GST_DEBUG("surface 0x%08x", surface_id);
|
||||
priv->surface_id = surface_id;
|
||||
GST_DEBUG("surface %" GST_VAAPI_ID_FORMAT, GST_VAAPI_ID_ARGS(surface_id));
|
||||
GST_VAAPI_OBJECT_ID(surface) = surface_id;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
@ -177,9 +178,6 @@ gst_vaapi_surface_get_property(
|
|||
GstVaapiSurface * const surface = GST_VAAPI_SURFACE(object);
|
||||
|
||||
switch (prop_id) {
|
||||
case PROP_SURFACE_ID:
|
||||
g_value_set_uint(value, gst_vaapi_surface_get_id(surface));
|
||||
break;
|
||||
case PROP_WIDTH:
|
||||
g_value_set_uint(value, gst_vaapi_surface_get_width(surface));
|
||||
break;
|
||||
|
@ -220,20 +218,6 @@ gst_vaapi_surface_class_init(GstVaapiSurfaceClass *klass)
|
|||
object_class->get_property = gst_vaapi_surface_get_property;
|
||||
object_class->constructed = gst_vaapi_surface_constructed;
|
||||
|
||||
/**
|
||||
* GstVaapiSurface:id:
|
||||
*
|
||||
* The underlying #VASurfaceID of the surface.
|
||||
*/
|
||||
g_object_class_install_property
|
||||
(object_class,
|
||||
PROP_SURFACE_ID,
|
||||
g_param_spec_uint("id",
|
||||
"VA surface id",
|
||||
"The underlying VA surface id",
|
||||
0, G_MAXUINT32, VA_INVALID_SURFACE,
|
||||
G_PARAM_READABLE));
|
||||
|
||||
g_object_class_install_property
|
||||
(object_class,
|
||||
PROP_WIDTH,
|
||||
|
@ -268,7 +252,6 @@ gst_vaapi_surface_init(GstVaapiSurface *surface)
|
|||
GstVaapiSurfacePrivate *priv = GST_VAAPI_SURFACE_GET_PRIVATE(surface);
|
||||
|
||||
surface->priv = priv;
|
||||
priv->surface_id = VA_INVALID_SURFACE;
|
||||
priv->width = 0;
|
||||
priv->height = 0;
|
||||
priv->chroma_type = 0;
|
||||
|
@ -305,22 +288,6 @@ gst_vaapi_surface_new(
|
|||
NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_vaapi_surface_get_id:
|
||||
* @surface: a #GstVaapiSurface
|
||||
*
|
||||
* Returns the underlying VASurfaceID of the @surface.
|
||||
*
|
||||
* Return value: the underlying VA surface id
|
||||
*/
|
||||
VASurfaceID
|
||||
gst_vaapi_surface_get_id(GstVaapiSurface *surface)
|
||||
{
|
||||
g_return_val_if_fail(GST_VAAPI_IS_SURFACE(surface), VA_INVALID_SURFACE);
|
||||
|
||||
return surface->priv->surface_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* gst_vaapi_surface_get_chroma_type:
|
||||
* @surface: a #GstVaapiSurface
|
||||
|
@ -433,7 +400,7 @@ gst_vaapi_surface_derive_image(GstVaapiSurface *surface)
|
|||
GST_VAAPI_DISPLAY_LOCK(display);
|
||||
status = vaDeriveImage(
|
||||
GST_VAAPI_DISPLAY_VADISPLAY(display),
|
||||
surface->priv->surface_id,
|
||||
GST_VAAPI_OBJECT_ID(surface),
|
||||
&va_image
|
||||
);
|
||||
GST_VAAPI_DISPLAY_UNLOCK(display);
|
||||
|
@ -474,14 +441,14 @@ gst_vaapi_surface_get_image(GstVaapiSurface *surface, GstVaapiImage *image)
|
|||
if (width != surface->priv->width || height != surface->priv->height)
|
||||
return FALSE;
|
||||
|
||||
image_id = gst_vaapi_image_get_id(image);
|
||||
image_id = GST_VAAPI_OBJECT_ID(image);
|
||||
if (image_id == VA_INVALID_ID)
|
||||
return FALSE;
|
||||
|
||||
GST_VAAPI_DISPLAY_LOCK(display);
|
||||
status = vaGetImage(
|
||||
GST_VAAPI_DISPLAY_VADISPLAY(display),
|
||||
surface->priv->surface_id,
|
||||
GST_VAAPI_OBJECT_ID(surface),
|
||||
0, 0, width, height,
|
||||
image_id
|
||||
);
|
||||
|
@ -521,14 +488,14 @@ gst_vaapi_surface_put_image(GstVaapiSurface *surface, GstVaapiImage *image)
|
|||
if (width != surface->priv->width || height != surface->priv->height)
|
||||
return FALSE;
|
||||
|
||||
image_id = gst_vaapi_image_get_id(image);
|
||||
image_id = GST_VAAPI_OBJECT_ID(image);
|
||||
if (image_id == VA_INVALID_ID)
|
||||
return FALSE;
|
||||
|
||||
GST_VAAPI_DISPLAY_LOCK(display);
|
||||
status = vaPutImage(
|
||||
GST_VAAPI_DISPLAY_VADISPLAY(display),
|
||||
surface->priv->surface_id,
|
||||
GST_VAAPI_OBJECT_ID(surface),
|
||||
image_id,
|
||||
0, 0, width, height,
|
||||
0, 0, width, height
|
||||
|
@ -569,6 +536,7 @@ gst_vaapi_surface_associate_subpicture(
|
|||
GstVaapiDisplay *display;
|
||||
GstVaapiRectangle src_rect_default, dst_rect_default;
|
||||
GstVaapiImage *image;
|
||||
VASurfaceID surface_id;
|
||||
VAStatus status;
|
||||
|
||||
g_return_val_if_fail(GST_VAAPI_IS_SURFACE(surface), FALSE);
|
||||
|
@ -587,6 +555,10 @@ gst_vaapi_surface_associate_subpicture(
|
|||
return FALSE;
|
||||
}
|
||||
|
||||
surface_id = GST_VAAPI_OBJECT_ID(surface);
|
||||
if (surface_id == VA_INVALID_SURFACE)
|
||||
return FALSE;
|
||||
|
||||
if (!src_rect) {
|
||||
image = gst_vaapi_subpicture_get_image(subpicture);
|
||||
if (!image)
|
||||
|
@ -612,8 +584,8 @@ gst_vaapi_surface_associate_subpicture(
|
|||
GST_VAAPI_DISPLAY_LOCK(display);
|
||||
status = vaAssociateSubpicture(
|
||||
GST_VAAPI_DISPLAY_VADISPLAY(display),
|
||||
gst_vaapi_subpicture_get_id(subpicture),
|
||||
&surface->priv->surface_id, 1,
|
||||
GST_VAAPI_OBJECT_ID(subpicture),
|
||||
&surface_id, 1,
|
||||
src_rect->x, src_rect->y, src_rect->width, src_rect->height,
|
||||
dst_rect->x, dst_rect->y, dst_rect->width, dst_rect->height,
|
||||
0
|
||||
|
@ -642,6 +614,7 @@ gst_vaapi_surface_deassociate_subpicture(
|
|||
)
|
||||
{
|
||||
GstVaapiDisplay *display;
|
||||
VASurfaceID surface_id;
|
||||
VAStatus status;
|
||||
|
||||
g_return_val_if_fail(GST_VAAPI_IS_SURFACE(surface), FALSE);
|
||||
|
@ -656,17 +629,22 @@ gst_vaapi_surface_deassociate_subpicture(
|
|||
|
||||
/* First, check subpicture was really associated with this surface */
|
||||
if (!g_ptr_array_remove_fast(surface->priv->subpictures, subpicture)) {
|
||||
GST_DEBUG("subpicture 0x%08x was not bound to surface 0x%08x",
|
||||
gst_vaapi_subpicture_get_id(subpicture),
|
||||
surface->priv->surface_id);
|
||||
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)));
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
surface_id = GST_VAAPI_OBJECT_ID(surface);
|
||||
if (surface_id == VA_INVALID_SURFACE)
|
||||
return FALSE;
|
||||
|
||||
GST_VAAPI_DISPLAY_LOCK(display);
|
||||
status = vaDeassociateSubpicture(
|
||||
GST_VAAPI_DISPLAY_VADISPLAY(display),
|
||||
gst_vaapi_subpicture_get_id(subpicture),
|
||||
&surface->priv->surface_id, 1
|
||||
GST_VAAPI_OBJECT_ID(subpicture),
|
||||
&surface_id, 1
|
||||
);
|
||||
GST_VAAPI_DISPLAY_UNLOCK(display);
|
||||
g_object_unref(subpicture);
|
||||
|
@ -699,7 +677,7 @@ gst_vaapi_surface_sync(GstVaapiSurface *surface)
|
|||
GST_VAAPI_DISPLAY_LOCK(display);
|
||||
status = vaSyncSurface(
|
||||
GST_VAAPI_DISPLAY_VADISPLAY(display),
|
||||
surface->priv->surface_id
|
||||
GST_VAAPI_OBJECT_ID(surface)
|
||||
);
|
||||
GST_VAAPI_DISPLAY_UNLOCK(display);
|
||||
if (!vaapi_check_status(status, "vaSyncSurface()"))
|
||||
|
|
|
@ -133,9 +133,6 @@ gst_vaapi_surface_new(
|
|||
guint height
|
||||
);
|
||||
|
||||
VASurfaceID
|
||||
gst_vaapi_surface_get_id(GstVaapiSurface *surface);
|
||||
|
||||
GstVaapiChromaType
|
||||
gst_vaapi_surface_get_chroma_type(GstVaapiSurface *surface);
|
||||
|
||||
|
|
|
@ -404,7 +404,7 @@ gst_vaapi_window_x11_render(
|
|||
if (!display)
|
||||
return FALSE;
|
||||
|
||||
surface_id = gst_vaapi_surface_get_id(surface);
|
||||
surface_id = GST_VAAPI_OBJECT_ID(surface);
|
||||
if (surface_id == VA_INVALID_ID)
|
||||
return FALSE;
|
||||
|
||||
|
|
|
@ -33,12 +33,13 @@ gst_vaapi_object_destroy_cb(gpointer object, gpointer user_data)
|
|||
int
|
||||
main(int argc, char *argv[])
|
||||
{
|
||||
GstVaapiDisplay *display;
|
||||
GstVaapiSurface *surface;
|
||||
GstVaapiSurface *surfaces[MAX_SURFACES];
|
||||
GstVaapiVideoPool *pool;
|
||||
GstCaps *caps;
|
||||
gint i;
|
||||
GstVaapiDisplay *display;
|
||||
GstVaapiSurface *surface;
|
||||
GstVaapiID surface_id;
|
||||
GstVaapiSurface *surfaces[MAX_SURFACES];
|
||||
GstVaapiVideoPool *pool;
|
||||
GstCaps *caps;
|
||||
gint i;
|
||||
|
||||
static const GstVaapiChromaType chroma_type = GST_VAAPI_CHROMA_TYPE_YUV420;
|
||||
static const guint width = 320;
|
||||
|
@ -53,6 +54,14 @@ main(int argc, char *argv[])
|
|||
surface = gst_vaapi_surface_new(display, chroma_type, width, height);
|
||||
if (!surface)
|
||||
g_error("could not create Gst/VA surface");
|
||||
|
||||
/* This also tests for the GstVaapiParamSpecID */
|
||||
g_object_get(G_OBJECT(surface), "id", &surface_id, NULL);
|
||||
if (surface_id != gst_vaapi_object_get_id(GST_VAAPI_OBJECT(surface)))
|
||||
g_error("could not retrieve the native surface ID");
|
||||
g_print("created surface %" GST_VAAPI_ID_FORMAT "\n",
|
||||
GST_VAAPI_ID_ARGS(surface_id));
|
||||
|
||||
g_object_unref(surface);
|
||||
|
||||
caps = gst_caps_new_simple(
|
||||
|
@ -72,8 +81,8 @@ main(int argc, char *argv[])
|
|||
surface = gst_vaapi_video_pool_get_object(pool);
|
||||
if (!surface)
|
||||
g_error("could not allocate Gst/VA surface from pool");
|
||||
g_print("created surface 0x%08x from pool\n",
|
||||
gst_vaapi_surface_get_id(surface));
|
||||
g_print("created surface %" GST_VAAPI_ID_FORMAT " from pool\n",
|
||||
GST_VAAPI_ID_ARGS(gst_vaapi_object_get_id(GST_VAAPI_OBJECT(surface))));
|
||||
surfaces[i] = surface;
|
||||
}
|
||||
|
||||
|
@ -87,8 +96,8 @@ main(int argc, char *argv[])
|
|||
surfaces[i] = gst_vaapi_video_pool_get_object(pool);
|
||||
if (!surfaces[i])
|
||||
g_error("could not re-allocate Gst/VA surface%d from pool", i);
|
||||
g_print("created surface 0x%08x from pool (realloc)\n",
|
||||
gst_vaapi_surface_get_id(surfaces[i]));
|
||||
g_print("created surface %" GST_VAAPI_ID_FORMAT " from pool (realloc)\n",
|
||||
GST_VAAPI_ID_ARGS(gst_vaapi_object_get_id(GST_VAAPI_OBJECT(surfaces[i]))));
|
||||
}
|
||||
|
||||
if (surface == surfaces[0])
|
||||
|
|
Loading…
Reference in a new issue