Add utilities to check whether a VA-API driver supports specific image or subpicture format. Likewise for VA profile.

This commit is contained in:
gb 2010-03-04 17:41:34 +00:00
parent 5809b63aaf
commit 0b3d5ddd0c
2 changed files with 78 additions and 0 deletions

View file

@ -143,6 +143,8 @@ gst_vaapi_display_get_display(GstVaapiDisplay *display)
{
GstVaapiDisplayPrivate *priv = display->priv;
g_return_val_if_fail(GST_VAAPI_IS_DISPLAY(display), NULL);
return priv->display;
}
@ -238,6 +240,8 @@ gst_vaapi_display_set_display(GstVaapiDisplay *display, VADisplay va_display)
VAStatus status;
int major_version, minor_version;
g_return_if_fail(GST_VAAPI_IS_DISPLAY(display));
if (priv->display) {
gst_vaapi_display_destroy_resources(display);
@ -261,3 +265,61 @@ gst_vaapi_display_set_display(GstVaapiDisplay *display, VADisplay va_display)
}
}
}
gboolean
gst_vaapi_display_has_profile(GstVaapiDisplay *display, VAProfile profile)
{
guint i;
g_return_val_if_fail(GST_VAAPI_IS_DISPLAY(display), FALSE);
for (i = 0; i < display->priv->num_profiles; i++)
if (display->priv->profiles[i] == profile)
return TRUE;
return FALSE;
}
static gboolean
_gst_vaapi_display_has_format(
GstVaapiDisplay *display,
GstVaapiImageFormat format,
const VAImageFormat *va_formats,
guint num_va_formats
)
{
guint i;
g_return_val_if_fail(format != 0, FALSE);
for (i = 0; i < num_va_formats; i++)
if (gst_vaapi_image_format(&va_formats[i]) == format)
return TRUE;
return FALSE;
}
gboolean
gst_vaapi_display_has_image_format(
GstVaapiDisplay *display,
GstVaapiImageFormat format
)
{
g_return_val_if_fail(GST_VAAPI_IS_DISPLAY(display), FALSE);
return _gst_vaapi_display_has_format(display, format,
display->priv->image_formats,
display->priv->num_image_formats);
}
gboolean
gst_vaapi_display_has_subpicture_format(
GstVaapiDisplay *display,
GstVaapiImageFormat format
)
{
g_return_val_if_fail(GST_VAAPI_IS_DISPLAY(display), FALSE);
return _gst_vaapi_display_has_format(display, format,
display->priv->subpicture_formats,
display->priv->num_subpicture_formats);
}

View file

@ -23,6 +23,7 @@
#include <va/va.h>
#include <gst/gst.h>
#include <gst/vaapi/gstvaapiimageformat.h>
G_BEGIN_DECLS
@ -72,6 +73,21 @@ gst_vaapi_display_get_type(void);
VADisplay
gst_vaapi_display_get_display(GstVaapiDisplay *display);
gboolean
gst_vaapi_display_has_profile(GstVaapiDisplay *display, VAProfile profile);
gboolean
gst_vaapi_display_has_image_format(
GstVaapiDisplay *display,
GstVaapiImageFormat format
);
gboolean
gst_vaapi_display_has_subpicture_format(
GstVaapiDisplay *display,
GstVaapiImageFormat format
);
G_END_DECLS
#endif /* GST_VAAPI_DISPLAY_H */