mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-04 05:22:30 +00:00
Use GstVaapiChromaType abstraction.
This commit is contained in:
parent
ac1243b28c
commit
e284e5e0d0
2 changed files with 76 additions and 44 deletions
|
@ -38,7 +38,7 @@ struct _GstVaapiSurfacePrivate {
|
||||||
VASurfaceID surface_id;
|
VASurfaceID surface_id;
|
||||||
guint width;
|
guint width;
|
||||||
guint height;
|
guint height;
|
||||||
guint format;
|
GstVaapiChromaType chroma_type;
|
||||||
};
|
};
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
|
@ -48,7 +48,7 @@ enum {
|
||||||
PROP_SURFACE_ID,
|
PROP_SURFACE_ID,
|
||||||
PROP_WIDTH,
|
PROP_WIDTH,
|
||||||
PROP_HEIGHT,
|
PROP_HEIGHT,
|
||||||
PROP_FORMAT
|
PROP_CHROMA_TYPE
|
||||||
};
|
};
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -77,12 +77,28 @@ gst_vaapi_surface_create(GstVaapiSurface *surface)
|
||||||
GstVaapiSurfacePrivate * const priv = surface->priv;
|
GstVaapiSurfacePrivate * const priv = surface->priv;
|
||||||
VASurfaceID surface_id;
|
VASurfaceID surface_id;
|
||||||
VAStatus status;
|
VAStatus status;
|
||||||
|
guint format;
|
||||||
|
|
||||||
|
switch (priv->chroma_type) {
|
||||||
|
case GST_VAAPI_CHROMA_TYPE_YUV420:
|
||||||
|
format = VA_RT_FORMAT_YUV420;
|
||||||
|
break;
|
||||||
|
case GST_VAAPI_CHROMA_TYPE_YUV422:
|
||||||
|
format = VA_RT_FORMAT_YUV422;
|
||||||
|
break;
|
||||||
|
case GST_VAAPI_CHROMA_TYPE_YUV444:
|
||||||
|
format = VA_RT_FORMAT_YUV444;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
GST_DEBUG("unsupported chroma-type %u\n", priv->chroma_type);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
status = vaCreateSurfaces(
|
status = vaCreateSurfaces(
|
||||||
gst_vaapi_display_get_display(priv->display),
|
gst_vaapi_display_get_display(priv->display),
|
||||||
priv->width,
|
priv->width,
|
||||||
priv->height,
|
priv->height,
|
||||||
priv->format,
|
format,
|
||||||
1, &surface_id
|
1, &surface_id
|
||||||
);
|
);
|
||||||
if (!vaapi_check_status(status, "vaCreateSurfaces()"))
|
if (!vaapi_check_status(status, "vaCreateSurfaces()"))
|
||||||
|
@ -101,10 +117,12 @@ gst_vaapi_surface_finalize(GObject *object)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gst_vaapi_surface_set_property(GObject *object,
|
gst_vaapi_surface_set_property(
|
||||||
|
GObject *object,
|
||||||
guint prop_id,
|
guint prop_id,
|
||||||
const GValue *value,
|
const GValue *value,
|
||||||
GParamSpec *pspec)
|
GParamSpec *pspec
|
||||||
|
)
|
||||||
{
|
{
|
||||||
GstVaapiSurface * const surface = GST_VAAPI_SURFACE(object);
|
GstVaapiSurface * const surface = GST_VAAPI_SURFACE(object);
|
||||||
GstVaapiSurfacePrivate * const priv = surface->priv;
|
GstVaapiSurfacePrivate * const priv = surface->priv;
|
||||||
|
@ -119,8 +137,8 @@ gst_vaapi_surface_set_property(GObject *object,
|
||||||
case PROP_HEIGHT:
|
case PROP_HEIGHT:
|
||||||
priv->height = g_value_get_uint(value);
|
priv->height = g_value_get_uint(value);
|
||||||
break;
|
break;
|
||||||
case PROP_FORMAT:
|
case PROP_CHROMA_TYPE:
|
||||||
priv->format = g_value_get_uint(value);
|
priv->chroma_type = g_value_get_uint(value);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
|
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
|
||||||
|
@ -129,10 +147,12 @@ gst_vaapi_surface_set_property(GObject *object,
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gst_vaapi_surface_get_property(GObject *object,
|
gst_vaapi_surface_get_property(
|
||||||
|
GObject *object,
|
||||||
guint prop_id,
|
guint prop_id,
|
||||||
GValue *value,
|
GValue *value,
|
||||||
GParamSpec *pspec)
|
GParamSpec *pspec
|
||||||
|
)
|
||||||
{
|
{
|
||||||
GstVaapiSurface * const surface = GST_VAAPI_SURFACE(object);
|
GstVaapiSurface * const surface = GST_VAAPI_SURFACE(object);
|
||||||
|
|
||||||
|
@ -149,8 +169,8 @@ gst_vaapi_surface_get_property(GObject *object,
|
||||||
case PROP_HEIGHT:
|
case PROP_HEIGHT:
|
||||||
g_value_set_uint(value, gst_vaapi_surface_get_height(surface));
|
g_value_set_uint(value, gst_vaapi_surface_get_height(surface));
|
||||||
break;
|
break;
|
||||||
case PROP_FORMAT:
|
case PROP_CHROMA_TYPE:
|
||||||
g_value_set_uint(value, gst_vaapi_surface_get_format(surface));
|
g_value_set_uint(value, gst_vaapi_surface_get_chroma_type(surface));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
|
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
|
||||||
|
@ -221,10 +241,10 @@ gst_vaapi_surface_class_init(GstVaapiSurfaceClass *klass)
|
||||||
|
|
||||||
g_object_class_install_property
|
g_object_class_install_property
|
||||||
(object_class,
|
(object_class,
|
||||||
PROP_FORMAT,
|
PROP_CHROMA_TYPE,
|
||||||
g_param_spec_uint("format",
|
g_param_spec_uint("chroma-type",
|
||||||
"format",
|
"chroma-type",
|
||||||
"VA surface format",
|
"VA surface chroma type",
|
||||||
0, G_MAXUINT32, 0,
|
0, G_MAXUINT32, 0,
|
||||||
G_PARAM_READWRITE|G_PARAM_CONSTRUCT_ONLY));
|
G_PARAM_READWRITE|G_PARAM_CONSTRUCT_ONLY));
|
||||||
}
|
}
|
||||||
|
@ -239,22 +259,24 @@ gst_vaapi_surface_init(GstVaapiSurface *surface)
|
||||||
priv->surface_id = VA_INVALID_SURFACE;
|
priv->surface_id = VA_INVALID_SURFACE;
|
||||||
priv->width = 0;
|
priv->width = 0;
|
||||||
priv->height = 0;
|
priv->height = 0;
|
||||||
priv->format = 0;
|
priv->chroma_type = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
GstVaapiSurface *
|
GstVaapiSurface *
|
||||||
gst_vaapi_surface_new(GstVaapiDisplay *display,
|
gst_vaapi_surface_new(
|
||||||
|
GstVaapiDisplay *display,
|
||||||
|
GstVaapiChromaType chroma_type,
|
||||||
guint width,
|
guint width,
|
||||||
guint height,
|
guint height
|
||||||
guint format)
|
)
|
||||||
{
|
{
|
||||||
GST_DEBUG("size %ux%u, format 0x%x", width, height, format);
|
GST_DEBUG("size %ux%u, chroma type 0x%x", width, height, chroma_type);
|
||||||
|
|
||||||
return g_object_new(GST_VAAPI_TYPE_SURFACE,
|
return g_object_new(GST_VAAPI_TYPE_SURFACE,
|
||||||
"display", display,
|
"display", display,
|
||||||
"width", width,
|
"width", width,
|
||||||
"height", height,
|
"height", height,
|
||||||
"format", format,
|
"chroma-type", chroma_type,
|
||||||
NULL);
|
NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -274,6 +296,14 @@ gst_vaapi_surface_get_display(GstVaapiSurface *surface)
|
||||||
return surface->priv->display;
|
return surface->priv->display;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
GstVaapiChromaType
|
||||||
|
gst_vaapi_surface_get_chroma_type(GstVaapiSurface *surface)
|
||||||
|
{
|
||||||
|
g_return_val_if_fail(GST_VAAPI_IS_SURFACE(surface), 0);
|
||||||
|
|
||||||
|
return surface->priv->chroma_type;
|
||||||
|
}
|
||||||
|
|
||||||
guint
|
guint
|
||||||
gst_vaapi_surface_get_width(GstVaapiSurface *surface)
|
gst_vaapi_surface_get_width(GstVaapiSurface *surface)
|
||||||
{
|
{
|
||||||
|
@ -289,11 +319,3 @@ gst_vaapi_surface_get_height(GstVaapiSurface *surface)
|
||||||
|
|
||||||
return surface->priv->height;
|
return surface->priv->height;
|
||||||
}
|
}
|
||||||
|
|
||||||
guint
|
|
||||||
gst_vaapi_surface_get_format(GstVaapiSurface *surface)
|
|
||||||
{
|
|
||||||
g_return_val_if_fail(GST_VAAPI_IS_SURFACE(surface), 0);
|
|
||||||
|
|
||||||
return surface->priv->format;
|
|
||||||
}
|
|
||||||
|
|
|
@ -25,6 +25,14 @@
|
||||||
|
|
||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
|
typedef enum _GstVaapiChromaType GstVaapiChromaType;
|
||||||
|
|
||||||
|
enum _GstVaapiChromaType {
|
||||||
|
GST_VAAPI_CHROMA_TYPE_YUV420 = 1,
|
||||||
|
GST_VAAPI_CHROMA_TYPE_YUV422,
|
||||||
|
GST_VAAPI_CHROMA_TYPE_YUV444
|
||||||
|
};
|
||||||
|
|
||||||
#define GST_VAAPI_TYPE_SURFACE \
|
#define GST_VAAPI_TYPE_SURFACE \
|
||||||
(gst_vaapi_surface_get_type())
|
(gst_vaapi_surface_get_type())
|
||||||
|
|
||||||
|
@ -69,10 +77,12 @@ GType
|
||||||
gst_vaapi_surface_get_type(void);
|
gst_vaapi_surface_get_type(void);
|
||||||
|
|
||||||
GstVaapiSurface *
|
GstVaapiSurface *
|
||||||
gst_vaapi_surface_new(GstVaapiDisplay *display,
|
gst_vaapi_surface_new(
|
||||||
|
GstVaapiDisplay *display,
|
||||||
|
GstVaapiChromaType chroma_type,
|
||||||
guint width,
|
guint width,
|
||||||
guint height,
|
guint height
|
||||||
guint format);
|
);
|
||||||
|
|
||||||
VASurfaceID
|
VASurfaceID
|
||||||
gst_vaapi_surface_get_id(GstVaapiSurface *surface);
|
gst_vaapi_surface_get_id(GstVaapiSurface *surface);
|
||||||
|
@ -80,15 +90,15 @@ gst_vaapi_surface_get_id(GstVaapiSurface *surface);
|
||||||
GstVaapiDisplay *
|
GstVaapiDisplay *
|
||||||
gst_vaapi_surface_get_display(GstVaapiSurface *surface);
|
gst_vaapi_surface_get_display(GstVaapiSurface *surface);
|
||||||
|
|
||||||
|
GstVaapiChromaType
|
||||||
|
gst_vaapi_surface_get_chroma_type(GstVaapiSurface *surface);
|
||||||
|
|
||||||
guint
|
guint
|
||||||
gst_vaapi_surface_get_width(GstVaapiSurface *surface);
|
gst_vaapi_surface_get_width(GstVaapiSurface *surface);
|
||||||
|
|
||||||
guint
|
guint
|
||||||
gst_vaapi_surface_get_height(GstVaapiSurface *surface);
|
gst_vaapi_surface_get_height(GstVaapiSurface *surface);
|
||||||
|
|
||||||
guint
|
|
||||||
gst_vaapi_surface_get_format(GstVaapiSurface *surface);
|
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
#endif /* GST_VAAPI_SURFACE_H */
|
#endif /* GST_VAAPI_SURFACE_H */
|
||||||
|
|
Loading…
Reference in a new issue