mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-16 11:15:31 +00:00
Simplify GstVaapiDisplay (use GArray).
This commit is contained in:
parent
bb66a7ea4a
commit
a318326f7f
1 changed files with 162 additions and 218 deletions
|
@ -39,13 +39,9 @@ struct _GstVaapiDisplayPrivate {
|
||||||
GStaticMutex mutex;
|
GStaticMutex mutex;
|
||||||
VADisplay display;
|
VADisplay display;
|
||||||
gboolean create_display;
|
gboolean create_display;
|
||||||
VAProfile *profiles;
|
GArray *profiles;
|
||||||
guint num_profiles;
|
GArray *image_formats;
|
||||||
VAImageFormat *image_formats;
|
GArray *subpicture_formats;
|
||||||
guint num_image_formats;
|
|
||||||
VAImageFormat *subpicture_formats;
|
|
||||||
guint *subpicture_flags;
|
|
||||||
guint num_subpicture_formats;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
|
@ -55,80 +51,54 @@ enum {
|
||||||
};
|
};
|
||||||
|
|
||||||
static void
|
static void
|
||||||
append_format(
|
append_formats(GArray *array, const VAImageFormat *va_formats, guint n)
|
||||||
VAImageFormat **pva_formats,
|
|
||||||
guint *pnum_va_formats,
|
|
||||||
GstVaapiImageFormat format
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
const VAImageFormat *va_format;
|
GstVaapiImageFormat format;
|
||||||
VAImageFormat *new_va_formats;
|
|
||||||
|
|
||||||
va_format = gst_vaapi_image_format_get_va_format(format);
|
|
||||||
if (!va_format)
|
|
||||||
return;
|
|
||||||
|
|
||||||
new_va_formats = realloc(
|
|
||||||
*pva_formats,
|
|
||||||
sizeof(new_va_formats[0]) * (1 + *pnum_va_formats)
|
|
||||||
);
|
|
||||||
if (!new_va_formats)
|
|
||||||
return;
|
|
||||||
|
|
||||||
new_va_formats[(*pnum_va_formats)++] = *va_format;
|
|
||||||
*pva_formats = new_va_formats;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
filter_formats(VAImageFormat **pva_formats, guint *pnum_va_formats)
|
|
||||||
{
|
|
||||||
guint i = 0;
|
|
||||||
gboolean has_YV12 = FALSE;
|
gboolean has_YV12 = FALSE;
|
||||||
gboolean has_I420 = FALSE;
|
gboolean has_I420 = FALSE;
|
||||||
|
guint i;
|
||||||
|
|
||||||
while (i < *pnum_va_formats) {
|
for (i = 0; i < n; i++) {
|
||||||
VAImageFormat * const va_format = &(*pva_formats)[i];
|
const VAImageFormat * const va_format = &va_formats[i];
|
||||||
const GstVaapiImageFormat format = gst_vaapi_image_format(va_format);
|
|
||||||
if (format) {
|
format = gst_vaapi_image_format(va_format);
|
||||||
++i;
|
if (!format) {
|
||||||
switch (format) {
|
GST_DEBUG("unsupported format %" GST_FOURCC_FORMAT,
|
||||||
case GST_VAAPI_IMAGE_YV12:
|
GST_FOURCC_ARGS(va_format->fourcc));
|
||||||
has_YV12 = TRUE;
|
continue;
|
||||||
break;
|
|
||||||
case GST_VAAPI_IMAGE_I420:
|
|
||||||
has_I420 = TRUE;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
/* Remove any format that is not supported by libgstvaapi */
|
switch (format) {
|
||||||
GST_DEBUG("unsupported format %c%c%c%c",
|
case GST_VAAPI_IMAGE_YV12:
|
||||||
va_format->fourcc & 0xff,
|
has_YV12 = TRUE;
|
||||||
(va_format->fourcc >> 8) & 0xff,
|
break;
|
||||||
(va_format->fourcc >> 16) & 0xff,
|
case GST_VAAPI_IMAGE_I420:
|
||||||
(va_format->fourcc >> 24) & 0xff);
|
has_I420 = TRUE;
|
||||||
*va_format = (*pva_formats)[--(*pnum_va_formats)];
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
g_array_append_val(array, format);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Append I420 (resp. YV12) format if YV12 (resp. I420) is not
|
/* Append I420 (resp. YV12) format if YV12 (resp. I420) is not
|
||||||
supported by the underlying driver */
|
supported by the underlying driver */
|
||||||
if (has_YV12 && !has_I420)
|
if (has_YV12 && !has_I420) {
|
||||||
append_format(pva_formats, pnum_va_formats, GST_VAAPI_IMAGE_I420);
|
format = GST_VAAPI_IMAGE_I420;
|
||||||
else if (has_I420 && !has_YV12)
|
g_array_append_val(array, format);
|
||||||
append_format(pva_formats, pnum_va_formats, GST_VAAPI_IMAGE_YV12);
|
}
|
||||||
|
else if (has_I420 && !has_YV12) {
|
||||||
|
format = GST_VAAPI_IMAGE_YV12;
|
||||||
|
g_array_append_val(array, format);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Sort image formats. Prefer YUV formats first */
|
/* Sort image formats. Prefer YUV formats first */
|
||||||
static int
|
static gint
|
||||||
compare_yuv_formats(const void *a, const void *b)
|
compare_yuv_formats(gconstpointer a, gconstpointer b)
|
||||||
{
|
{
|
||||||
const GstVaapiImageFormat fmt1 = gst_vaapi_image_format((VAImageFormat *)a);
|
const GstVaapiImageFormat fmt1 = *(GstVaapiImageFormat *)a;
|
||||||
const GstVaapiImageFormat fmt2 = gst_vaapi_image_format((VAImageFormat *)b);
|
const GstVaapiImageFormat fmt2 = *(GstVaapiImageFormat *)b;
|
||||||
|
|
||||||
g_assert(fmt1 && fmt2);
|
|
||||||
|
|
||||||
const gboolean is_fmt1_yuv = gst_vaapi_image_format_is_yuv(fmt1);
|
const gboolean is_fmt1_yuv = gst_vaapi_image_format_is_yuv(fmt1);
|
||||||
const gboolean is_fmt2_yuv = gst_vaapi_image_format_is_yuv(fmt2);
|
const gboolean is_fmt2_yuv = gst_vaapi_image_format_is_yuv(fmt2);
|
||||||
|
@ -136,18 +106,16 @@ compare_yuv_formats(const void *a, const void *b)
|
||||||
if (is_fmt1_yuv != is_fmt2_yuv)
|
if (is_fmt1_yuv != is_fmt2_yuv)
|
||||||
return is_fmt1_yuv ? -1 : 1;
|
return is_fmt1_yuv ? -1 : 1;
|
||||||
|
|
||||||
return ((int)gst_vaapi_image_format_get_score(fmt1) -
|
return ((gint)gst_vaapi_image_format_get_score(fmt1) -
|
||||||
(int)gst_vaapi_image_format_get_score(fmt2));
|
(gint)gst_vaapi_image_format_get_score(fmt2));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Sort subpicture formats. Prefer RGB formats first */
|
/* Sort subpicture formats. Prefer RGB formats first */
|
||||||
static int
|
static gint
|
||||||
compare_rgb_formats(const void *a, const void *b)
|
compare_rgb_formats(gconstpointer a, gconstpointer b)
|
||||||
{
|
{
|
||||||
const GstVaapiImageFormat fmt1 = gst_vaapi_image_format((VAImageFormat *)a);
|
const GstVaapiImageFormat fmt1 = *(GstVaapiImageFormat *)a;
|
||||||
const GstVaapiImageFormat fmt2 = gst_vaapi_image_format((VAImageFormat *)b);
|
const GstVaapiImageFormat fmt2 = *(GstVaapiImageFormat *)b;
|
||||||
|
|
||||||
g_assert(fmt1 && fmt2);
|
|
||||||
|
|
||||||
const gboolean is_fmt1_rgb = gst_vaapi_image_format_is_rgb(fmt1);
|
const gboolean is_fmt1_rgb = gst_vaapi_image_format_is_rgb(fmt1);
|
||||||
const gboolean is_fmt2_rgb = gst_vaapi_image_format_is_rgb(fmt2);
|
const gboolean is_fmt2_rgb = gst_vaapi_image_format_is_rgb(fmt2);
|
||||||
|
@ -155,8 +123,53 @@ compare_rgb_formats(const void *a, const void *b)
|
||||||
if (is_fmt1_rgb != is_fmt2_rgb)
|
if (is_fmt1_rgb != is_fmt2_rgb)
|
||||||
return is_fmt1_rgb ? -1 : 1;
|
return is_fmt1_rgb ? -1 : 1;
|
||||||
|
|
||||||
return ((int)gst_vaapi_image_format_get_score(fmt1) -
|
return ((gint)gst_vaapi_image_format_get_score(fmt1) -
|
||||||
(int)gst_vaapi_image_format_get_score(fmt2));
|
(gint)gst_vaapi_image_format_get_score(fmt2));
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Check if profiles array contains profile */
|
||||||
|
static inline gboolean
|
||||||
|
find_profile(GArray *profiles, VAProfile profile)
|
||||||
|
{
|
||||||
|
guint i;
|
||||||
|
|
||||||
|
for (i = 0; i < profiles->len; i++)
|
||||||
|
if (g_array_index(profiles, VAProfile, i) == profile)
|
||||||
|
return TRUE;
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Check if formats array contains format */
|
||||||
|
static inline gboolean
|
||||||
|
find_format(GArray *formats, GstVaapiImageFormat format)
|
||||||
|
{
|
||||||
|
guint i;
|
||||||
|
|
||||||
|
for (i = 0; i < formats->len; i++)
|
||||||
|
if (g_array_index(formats, GstVaapiImageFormat, i) == format)
|
||||||
|
return TRUE;
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Convert formats array to GstCaps */
|
||||||
|
static GstCaps *
|
||||||
|
get_caps(GArray *formats)
|
||||||
|
{
|
||||||
|
GstVaapiImageFormat format;
|
||||||
|
GstCaps *out_caps, *caps;
|
||||||
|
guint i;
|
||||||
|
|
||||||
|
out_caps = gst_caps_new_empty();
|
||||||
|
if (!out_caps)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
for (i = 0; i < formats->len; i++) {
|
||||||
|
format = g_array_index(formats, GstVaapiImageFormat, i);
|
||||||
|
caps = gst_vaapi_image_format_get_caps(format);
|
||||||
|
if (caps)
|
||||||
|
gst_caps_append(out_caps, caps);
|
||||||
|
}
|
||||||
|
return out_caps;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -165,25 +178,18 @@ gst_vaapi_display_destroy(GstVaapiDisplay *display)
|
||||||
GstVaapiDisplayPrivate * const priv = display->priv;
|
GstVaapiDisplayPrivate * const priv = display->priv;
|
||||||
|
|
||||||
if (priv->profiles) {
|
if (priv->profiles) {
|
||||||
g_free(priv->profiles);
|
g_array_free(priv->profiles, TRUE);
|
||||||
priv->profiles = NULL;
|
priv->profiles = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (priv->image_formats) {
|
if (priv->image_formats) {
|
||||||
g_free(priv->image_formats);
|
g_array_free(priv->image_formats, TRUE);
|
||||||
priv->image_formats = NULL;
|
priv->image_formats = NULL;
|
||||||
priv->num_image_formats = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (priv->subpicture_formats) {
|
if (priv->subpicture_formats) {
|
||||||
g_free(priv->subpicture_formats);
|
g_array_free(priv->subpicture_formats, TRUE);
|
||||||
priv->subpicture_formats = NULL;
|
priv->subpicture_formats = NULL;
|
||||||
priv->num_subpicture_formats = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (priv->subpicture_flags) {
|
|
||||||
g_free(priv->subpicture_flags);
|
|
||||||
priv->subpicture_flags = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (priv->display) {
|
if (priv->display) {
|
||||||
|
@ -202,9 +208,12 @@ static gboolean
|
||||||
gst_vaapi_display_create(GstVaapiDisplay *display)
|
gst_vaapi_display_create(GstVaapiDisplay *display)
|
||||||
{
|
{
|
||||||
GstVaapiDisplayPrivate * const priv = display->priv;
|
GstVaapiDisplayPrivate * const priv = display->priv;
|
||||||
VAStatus status;
|
gboolean has_errors = TRUE;
|
||||||
int major_version, minor_version;
|
VAProfile *profiles = NULL;
|
||||||
guint i;
|
VAImageFormat *formats = NULL;
|
||||||
|
unsigned int *flags = NULL;
|
||||||
|
gint i, n, major_version, minor_version;
|
||||||
|
VAStatus status;
|
||||||
|
|
||||||
if (!priv->display && priv->create_display) {
|
if (!priv->display && priv->create_display) {
|
||||||
GstVaapiDisplayClass *klass = GST_VAAPI_DISPLAY_GET_CLASS(display);
|
GstVaapiDisplayClass *klass = GST_VAAPI_DISPLAY_GET_CLASS(display);
|
||||||
|
@ -218,79 +227,72 @@ gst_vaapi_display_create(GstVaapiDisplay *display)
|
||||||
|
|
||||||
status = vaInitialize(priv->display, &major_version, &minor_version);
|
status = vaInitialize(priv->display, &major_version, &minor_version);
|
||||||
if (!vaapi_check_status(status, "vaInitialize()"))
|
if (!vaapi_check_status(status, "vaInitialize()"))
|
||||||
return FALSE;
|
goto end;
|
||||||
GST_DEBUG("VA-API version %d.%d", major_version, minor_version);
|
GST_DEBUG("VA-API version %d.%d", major_version, minor_version);
|
||||||
|
|
||||||
/* VA profiles */
|
/* VA profiles */
|
||||||
priv->num_profiles = vaMaxNumProfiles(priv->display);
|
profiles = g_new(VAProfile, vaMaxNumProfiles(priv->display));
|
||||||
priv->profiles = g_new(VAProfile, priv->num_profiles);
|
if (!profiles)
|
||||||
if (!priv->profiles)
|
goto end;
|
||||||
return FALSE;
|
status = vaQueryConfigProfiles(priv->display, profiles, &n);
|
||||||
status = vaQueryConfigProfiles(priv->display,
|
|
||||||
priv->profiles,
|
|
||||||
&priv->num_profiles);
|
|
||||||
if (!vaapi_check_status(status, "vaQueryConfigProfiles()"))
|
if (!vaapi_check_status(status, "vaQueryConfigProfiles()"))
|
||||||
return FALSE;
|
goto end;
|
||||||
|
|
||||||
GST_DEBUG("%d profiles", priv->num_profiles);
|
GST_DEBUG("%d profiles", n);
|
||||||
for (i = 0; i < priv->num_profiles; i++)
|
for (i = 0; i < n; i++)
|
||||||
GST_DEBUG(" %s", string_of_VAProfile(priv->profiles[i]));
|
GST_DEBUG(" %s", string_of_VAProfile(profiles[i]));
|
||||||
|
|
||||||
|
priv->profiles = g_array_new(FALSE, FALSE, sizeof(VAProfile));
|
||||||
|
if (!priv->profiles)
|
||||||
|
goto end;
|
||||||
|
g_array_append_vals(priv->profiles, profiles, n);
|
||||||
|
|
||||||
/* VA image formats */
|
/* VA image formats */
|
||||||
priv->num_image_formats = vaMaxNumImageFormats(priv->display);
|
formats = g_new(VAImageFormat, vaMaxNumImageFormats(priv->display));
|
||||||
priv->image_formats = g_new(VAImageFormat, priv->num_image_formats);
|
if (!formats)
|
||||||
if (!priv->image_formats)
|
goto end;
|
||||||
return FALSE;
|
status = vaQueryImageFormats(priv->display, formats, &n);
|
||||||
status = vaQueryImageFormats(
|
|
||||||
priv->display,
|
|
||||||
priv->image_formats,
|
|
||||||
&priv->num_image_formats
|
|
||||||
);
|
|
||||||
if (!vaapi_check_status(status, "vaQueryImageFormats()"))
|
if (!vaapi_check_status(status, "vaQueryImageFormats()"))
|
||||||
return FALSE;
|
goto end;
|
||||||
|
|
||||||
GST_DEBUG("%d image formats", priv->num_image_formats);
|
GST_DEBUG("%d image formats", n);
|
||||||
for (i = 0; i < priv->num_image_formats; i++)
|
for (i = 0; i < n; i++)
|
||||||
GST_DEBUG(" %s", string_of_FOURCC(priv->image_formats[i].fourcc));
|
GST_DEBUG(" %s", string_of_FOURCC(formats[i].fourcc));
|
||||||
|
|
||||||
filter_formats(&priv->image_formats, &priv->num_image_formats);
|
priv->image_formats =
|
||||||
qsort(
|
g_array_new(FALSE, FALSE, sizeof(GstVaapiImageFormat));
|
||||||
priv->image_formats,
|
if (!priv->image_formats)
|
||||||
priv->num_image_formats,
|
goto end;
|
||||||
sizeof(priv->image_formats[0]),
|
append_formats(priv->image_formats, formats, n);
|
||||||
compare_yuv_formats
|
g_array_sort(priv->image_formats, compare_yuv_formats);
|
||||||
);
|
|
||||||
|
|
||||||
/* VA subpicture formats */
|
/* VA subpicture formats */
|
||||||
priv->num_subpicture_formats = vaMaxNumSubpictureFormats(priv->display);
|
n = vaMaxNumSubpictureFormats(priv->display);
|
||||||
priv->subpicture_formats = g_new(VAImageFormat, priv->num_subpicture_formats);
|
formats = g_renew(VAImageFormat, formats, n);
|
||||||
if (!priv->subpicture_formats)
|
flags = g_new(guint, n);
|
||||||
return FALSE;
|
if (!formats || !flags)
|
||||||
priv->subpicture_flags = g_new(guint, priv->num_subpicture_formats);
|
goto end;
|
||||||
if (!priv->subpicture_flags)
|
status = vaQuerySubpictureFormats(priv->display, formats, flags, &n);
|
||||||
return FALSE;
|
|
||||||
status = vaQuerySubpictureFormats(
|
|
||||||
priv->display,
|
|
||||||
priv->subpicture_formats,
|
|
||||||
priv->subpicture_flags,
|
|
||||||
&priv->num_subpicture_formats
|
|
||||||
);
|
|
||||||
if (!vaapi_check_status(status, "vaQuerySubpictureFormats()"))
|
if (!vaapi_check_status(status, "vaQuerySubpictureFormats()"))
|
||||||
return FALSE;
|
goto end;
|
||||||
|
|
||||||
filter_formats(&priv->subpicture_formats, &priv->num_subpicture_formats);
|
GST_DEBUG("%d subpicture formats", n);
|
||||||
qsort(
|
for (i = 0; i < n; i++)
|
||||||
priv->subpicture_formats,
|
GST_DEBUG(" %s", string_of_FOURCC(formats[i].fourcc));
|
||||||
priv->num_subpicture_formats,
|
|
||||||
sizeof(priv->subpicture_formats[0]),
|
|
||||||
compare_rgb_formats
|
|
||||||
);
|
|
||||||
|
|
||||||
GST_DEBUG("%d subpicture formats", priv->num_subpicture_formats);
|
priv->subpicture_formats =
|
||||||
for (i = 0; i < priv->num_subpicture_formats; i++)
|
g_array_new(FALSE, FALSE, sizeof(GstVaapiImageFormat));
|
||||||
GST_DEBUG(" %s", string_of_FOURCC(priv->subpicture_formats[i].fourcc));
|
if (!priv->subpicture_formats)
|
||||||
|
goto end;
|
||||||
|
append_formats(priv->subpicture_formats, formats, n);
|
||||||
|
g_array_sort(priv->subpicture_formats, compare_rgb_formats);
|
||||||
|
|
||||||
return TRUE;
|
has_errors = FALSE;
|
||||||
|
end:
|
||||||
|
g_free(profiles);
|
||||||
|
g_free(formats);
|
||||||
|
g_free(flags);
|
||||||
|
return !has_errors;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -401,16 +403,12 @@ gst_vaapi_display_init(GstVaapiDisplay *display)
|
||||||
{
|
{
|
||||||
GstVaapiDisplayPrivate *priv = GST_VAAPI_DISPLAY_GET_PRIVATE(display);
|
GstVaapiDisplayPrivate *priv = GST_VAAPI_DISPLAY_GET_PRIVATE(display);
|
||||||
|
|
||||||
display->priv = priv;
|
display->priv = priv;
|
||||||
priv->display = NULL;
|
priv->display = NULL;
|
||||||
priv->create_display = TRUE;
|
priv->create_display = TRUE;
|
||||||
priv->profiles = 0;
|
priv->profiles = NULL;
|
||||||
priv->num_profiles = 0;
|
priv->image_formats = NULL;
|
||||||
priv->image_formats = NULL;
|
priv->subpicture_formats = NULL;
|
||||||
priv->num_image_formats = 0;
|
|
||||||
priv->subpicture_formats = NULL;
|
|
||||||
priv->subpicture_flags = NULL;
|
|
||||||
priv->num_subpicture_formats = 0;
|
|
||||||
|
|
||||||
g_static_mutex_init(&priv->mutex);
|
g_static_mutex_init(&priv->mutex);
|
||||||
}
|
}
|
||||||
|
@ -458,57 +456,9 @@ gst_vaapi_display_get_display(GstVaapiDisplay *display)
|
||||||
gboolean
|
gboolean
|
||||||
gst_vaapi_display_has_profile(GstVaapiDisplay *display, VAProfile profile)
|
gst_vaapi_display_has_profile(GstVaapiDisplay *display, VAProfile profile)
|
||||||
{
|
{
|
||||||
guint i;
|
|
||||||
|
|
||||||
g_return_val_if_fail(GST_VAAPI_IS_DISPLAY(display), FALSE);
|
g_return_val_if_fail(GST_VAAPI_IS_DISPLAY(display), FALSE);
|
||||||
|
|
||||||
for (i = 0; i < display->priv->num_profiles; i++)
|
return find_profile(display->priv->profiles, profile);
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
static GstCaps *
|
|
||||||
_gst_vaapi_display_get_caps(
|
|
||||||
GstVaapiDisplay *display,
|
|
||||||
const VAImageFormat *va_formats,
|
|
||||||
guint num_va_formats
|
|
||||||
)
|
|
||||||
{
|
|
||||||
GstCaps *out_caps;
|
|
||||||
guint i;
|
|
||||||
|
|
||||||
out_caps = gst_caps_new_empty();
|
|
||||||
if (!out_caps)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
for (i = 0; i < num_va_formats; i++) {
|
|
||||||
GstVaapiImageFormat format = gst_vaapi_image_format(&va_formats[i]);
|
|
||||||
if (format) {
|
|
||||||
GstCaps * const caps = gst_vaapi_image_format_get_caps(format);
|
|
||||||
if (caps)
|
|
||||||
gst_caps_append(out_caps, caps);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return out_caps;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GstCaps *
|
GstCaps *
|
||||||
|
@ -516,9 +466,7 @@ gst_vaapi_display_get_image_caps(GstVaapiDisplay *display)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail(GST_VAAPI_IS_DISPLAY(display), NULL);
|
g_return_val_if_fail(GST_VAAPI_IS_DISPLAY(display), NULL);
|
||||||
|
|
||||||
return _gst_vaapi_display_get_caps(display,
|
return get_caps(display->priv->image_formats);
|
||||||
display->priv->image_formats,
|
|
||||||
display->priv->num_image_formats);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
|
@ -528,10 +476,9 @@ gst_vaapi_display_has_image_format(
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail(GST_VAAPI_IS_DISPLAY(display), FALSE);
|
g_return_val_if_fail(GST_VAAPI_IS_DISPLAY(display), FALSE);
|
||||||
|
g_return_val_if_fail(format, FALSE);
|
||||||
|
|
||||||
return _gst_vaapi_display_has_format(display, format,
|
return find_format(display->priv->image_formats, format);
|
||||||
display->priv->image_formats,
|
|
||||||
display->priv->num_image_formats);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GstCaps *
|
GstCaps *
|
||||||
|
@ -539,9 +486,7 @@ gst_vaapi_display_get_subpicture_caps(GstVaapiDisplay *display)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail(GST_VAAPI_IS_DISPLAY(display), NULL);
|
g_return_val_if_fail(GST_VAAPI_IS_DISPLAY(display), NULL);
|
||||||
|
|
||||||
return _gst_vaapi_display_get_caps(display,
|
return get_caps(display->priv->subpicture_formats);
|
||||||
display->priv->subpicture_formats,
|
|
||||||
display->priv->num_subpicture_formats);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
|
@ -551,8 +496,7 @@ gst_vaapi_display_has_subpicture_format(
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
g_return_val_if_fail(GST_VAAPI_IS_DISPLAY(display), FALSE);
|
g_return_val_if_fail(GST_VAAPI_IS_DISPLAY(display), FALSE);
|
||||||
|
g_return_val_if_fail(format, FALSE);
|
||||||
|
|
||||||
return _gst_vaapi_display_has_format(display, format,
|
return find_format(display->priv->subpicture_formats, format);
|
||||||
display->priv->subpicture_formats,
|
|
||||||
display->priv->num_subpicture_formats);
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue