2 * gstvaapidisplay.c - VA display abstraction
4 * Copyright (C) 2010-2011 Splitted-Desktop Systems
5 * Copyright (C) 2011-2012 Intel Corporation
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public License
9 * as published by the Free Software Foundation; either version 2.1
10 * of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free
19 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20 * Boston, MA 02110-1301 USA
24 * SECTION:gstvaapidisplay
25 * @short_description: VA display abstraction
30 #include "gstvaapiutils.h"
31 #include "gstvaapidisplay.h"
32 #include "gstvaapidisplay_priv.h"
33 #include "gstvaapiworkarounds.h"
36 #include "gstvaapidebug.h"
38 GST_DEBUG_CATEGORY(gst_debug_vaapi);
40 G_DEFINE_TYPE(GstVaapiDisplay, gst_vaapi_display, G_TYPE_OBJECT);
42 typedef struct _GstVaapiConfig GstVaapiConfig;
43 struct _GstVaapiConfig {
44 GstVaapiProfile profile;
45 GstVaapiEntrypoint entrypoint;
57 static GstVaapiDisplayCache *g_display_cache = NULL;
59 static inline GstVaapiDisplayCache *
60 get_display_cache(void)
63 g_display_cache = gst_vaapi_display_cache_new();
64 return g_display_cache;
67 GstVaapiDisplayCache *
68 gst_vaapi_display_get_cache(void)
70 return get_display_cache();
74 free_display_cache(void)
78 if (gst_vaapi_display_cache_get_size(g_display_cache) > 0)
80 gst_vaapi_display_cache_free(g_display_cache);
81 g_display_cache = NULL;
84 /* GstVaapiDisplayType enumerations */
86 gst_vaapi_display_type_get_type(void)
88 static GType g_type = 0;
90 static const GEnumValue display_types[] = {
91 { GST_VAAPI_DISPLAY_TYPE_ANY,
92 "Auto detection", "any" },
94 { GST_VAAPI_DISPLAY_TYPE_X11,
95 "VA/X11 display", "x11" },
98 { GST_VAAPI_DISPLAY_TYPE_GLX,
99 "VA/GLX display", "glx" },
102 { GST_VAAPI_DISPLAY_TYPE_WAYLAND,
103 "VA/Wayland display", "wayland" },
109 g_type = g_enum_register_static("GstVaapiDisplayType", display_types);
113 /* Append GstVaapiImageFormat to formats array */
115 append_format(GArray *formats, GstVaapiImageFormat format)
117 g_array_append_val(formats, format);
120 /* Append VAImageFormats to formats array */
122 append_formats(GArray *formats, const VAImageFormat *va_formats, guint n)
124 GstVaapiImageFormat format;
125 gboolean has_YV12 = FALSE;
126 gboolean has_I420 = FALSE;
129 for (i = 0; i < n; i++) {
130 const VAImageFormat * const va_format = &va_formats[i];
132 format = gst_vaapi_image_format(va_format);
134 GST_DEBUG("unsupported format %" GST_FOURCC_FORMAT,
135 GST_FOURCC_ARGS(va_format->fourcc));
140 case GST_VAAPI_IMAGE_YV12:
143 case GST_VAAPI_IMAGE_I420:
149 append_format(formats, format);
152 /* Append I420 (resp. YV12) format if YV12 (resp. I420) is not
153 supported by the underlying driver */
154 if (has_YV12 && !has_I420)
155 append_format(formats, GST_VAAPI_IMAGE_I420);
156 else if (has_I420 && !has_YV12)
157 append_format(formats, GST_VAAPI_IMAGE_YV12);
160 /* Sort image formats. Prefer YUV formats first */
162 compare_yuv_formats(gconstpointer a, gconstpointer b)
164 const GstVaapiImageFormat fmt1 = *(GstVaapiImageFormat *)a;
165 const GstVaapiImageFormat fmt2 = *(GstVaapiImageFormat *)b;
167 const gboolean is_fmt1_yuv = gst_vaapi_image_format_is_yuv(fmt1);
168 const gboolean is_fmt2_yuv = gst_vaapi_image_format_is_yuv(fmt2);
170 if (is_fmt1_yuv != is_fmt2_yuv)
171 return is_fmt1_yuv ? -1 : 1;
173 return ((gint)gst_vaapi_image_format_get_score(fmt1) -
174 (gint)gst_vaapi_image_format_get_score(fmt2));
177 /* Sort subpicture formats. Prefer RGB formats first */
179 compare_rgb_formats(gconstpointer a, gconstpointer b)
181 const GstVaapiImageFormat fmt1 = *(GstVaapiImageFormat *)a;
182 const GstVaapiImageFormat fmt2 = *(GstVaapiImageFormat *)b;
184 const gboolean is_fmt1_rgb = gst_vaapi_image_format_is_rgb(fmt1);
185 const gboolean is_fmt2_rgb = gst_vaapi_image_format_is_rgb(fmt2);
187 if (is_fmt1_rgb != is_fmt2_rgb)
188 return is_fmt1_rgb ? -1 : 1;
190 return ((gint)gst_vaapi_image_format_get_score(fmt1) -
191 (gint)gst_vaapi_image_format_get_score(fmt2));
194 /* Check if configs array contains profile at entrypoint */
195 static inline gboolean
198 GstVaapiProfile profile,
199 GstVaapiEntrypoint entrypoint
202 GstVaapiConfig *config;
208 for (i = 0; i < configs->len; i++) {
209 config = &g_array_index(configs, GstVaapiConfig, i);
210 if (config->profile == profile && config->entrypoint == entrypoint)
216 /* HACK: append H.263 Baseline profile if MPEG-4:2 Simple profile is supported */
218 append_h263_config(GArray *configs)
220 GstVaapiConfig *config, tmp_config;
221 GstVaapiConfig *mpeg4_simple_config = NULL;
222 GstVaapiConfig *h263_baseline_config = NULL;
225 if (!WORKAROUND_H263_BASELINE_DECODE_PROFILE)
231 for (i = 0; i < configs->len; i++) {
232 config = &g_array_index(configs, GstVaapiConfig, i);
233 if (config->profile == GST_VAAPI_PROFILE_MPEG4_SIMPLE)
234 mpeg4_simple_config = config;
235 else if (config->profile == GST_VAAPI_PROFILE_H263_BASELINE)
236 h263_baseline_config = config;
239 if (mpeg4_simple_config && !h263_baseline_config) {
240 tmp_config = *mpeg4_simple_config;
241 tmp_config.profile = GST_VAAPI_PROFILE_H263_BASELINE;
242 g_array_append_val(configs, tmp_config);
246 /* Convert configs array to profiles as GstCaps */
248 get_profile_caps(GArray *configs)
250 GstVaapiConfig *config;
251 GstCaps *out_caps, *caps;
257 out_caps = gst_caps_new_empty();
261 for (i = 0; i < configs->len; i++) {
262 config = &g_array_index(configs, GstVaapiConfig, i);
263 caps = gst_vaapi_profile_get_caps(config->profile);
265 gst_caps_merge(out_caps, caps);
270 /* Check if formats array contains format */
271 static inline gboolean
272 find_format(GArray *formats, GstVaapiImageFormat format)
276 for (i = 0; i < formats->len; i++)
277 if (g_array_index(formats, GstVaapiImageFormat, i) == format)
282 /* Convert formats array to GstCaps */
284 get_format_caps(GArray *formats)
286 GstVaapiImageFormat format;
287 GstCaps *out_caps, *caps;
290 out_caps = gst_caps_new_empty();
294 for (i = 0; i < formats->len; i++) {
295 format = g_array_index(formats, GstVaapiImageFormat, i);
296 caps = gst_vaapi_image_format_get_caps(format);
298 gst_caps_append(out_caps, caps);
304 gst_vaapi_display_calculate_pixel_aspect_ratio(GstVaapiDisplay *display)
306 GstVaapiDisplayPrivate * const priv = display->priv;
307 gdouble ratio, delta;
310 static const gint par[][2] = {
311 {1, 1}, /* regular screen */
312 {16, 15}, /* PAL TV */
313 {11, 10}, /* 525 line Rec.601 video */
314 {54, 59}, /* 625 line Rec.601 video */
315 {64, 45}, /* 1280x1024 on 16:9 display */
316 {5, 3}, /* 1280x1024 on 4:3 display */
317 {4, 3} /* 800x600 on 16:9 display */
320 /* First, calculate the "real" ratio based on the X values;
321 * which is the "physical" w/h divided by the w/h in pixels of the
323 if (!priv->width || !priv->height || !priv->width_mm || !priv->height_mm)
326 ratio = (gdouble)(priv->width_mm * priv->height) /
327 (priv->height_mm * priv->width);
328 GST_DEBUG("calculated pixel aspect ratio: %f", ratio);
330 /* Now, find the one from par[][2] with the lowest delta to the real one */
331 #define DELTA(idx) (ABS(ratio - ((gdouble)par[idx][0] / par[idx][1])))
335 for (i = 1; i < G_N_ELEMENTS(par); i++) {
336 const gdouble this_delta = DELTA(i);
337 if (this_delta < delta) {
344 priv->par_n = par[index][0];
345 priv->par_d = par[index][1];
349 gst_vaapi_display_destroy(GstVaapiDisplay *display)
351 GstVaapiDisplayPrivate * const priv = display->priv;
353 if (priv->decoders) {
354 g_array_free(priv->decoders, TRUE);
355 priv->decoders = NULL;
358 if (priv->encoders) {
359 g_array_free(priv->encoders, TRUE);
360 priv->encoders = NULL;
363 if (priv->image_formats) {
364 g_array_free(priv->image_formats, TRUE);
365 priv->image_formats = NULL;
368 if (priv->subpicture_formats) {
369 g_array_free(priv->subpicture_formats, TRUE);
370 priv->subpicture_formats = NULL;
375 vaTerminate(priv->display);
376 priv->display = NULL;
379 if (priv->create_display) {
380 GstVaapiDisplayClass *klass = GST_VAAPI_DISPLAY_GET_CLASS(display);
381 if (klass->close_display)
382 klass->close_display(display);
385 g_clear_object(&priv->parent);
387 if (g_display_cache) {
388 gst_vaapi_display_cache_remove(get_display_cache(), display);
389 free_display_cache();
394 gst_vaapi_display_create(GstVaapiDisplay *display)
396 GstVaapiDisplayPrivate * const priv = display->priv;
397 GstVaapiDisplayCache *cache;
398 gboolean has_errors = TRUE;
399 VAProfile *profiles = NULL;
400 VAEntrypoint *entrypoints = NULL;
401 VAImageFormat *formats = NULL;
402 unsigned int *flags = NULL;
403 gint i, j, n, num_entrypoints, major_version, minor_version;
405 GstVaapiDisplayInfo info;
406 const GstVaapiDisplayInfo *cached_info = NULL;
408 memset(&info, 0, sizeof(info));
409 info.display = display;
410 info.display_type = priv->display_type;
413 info.va_display = priv->display;
414 else if (priv->create_display) {
415 GstVaapiDisplayClass *klass = GST_VAAPI_DISPLAY_GET_CLASS(display);
416 if (klass->open_display && !klass->open_display(display))
418 if (!klass->get_display || !klass->get_display(display, &info))
420 priv->display = info.va_display;
421 priv->display_type = info.display_type;
423 klass->get_size(display, &priv->width, &priv->height);
424 if (klass->get_size_mm)
425 klass->get_size_mm(display, &priv->width_mm, &priv->height_mm);
426 gst_vaapi_display_calculate_pixel_aspect_ratio(display);
431 cache = get_display_cache();
434 cached_info = gst_vaapi_display_cache_lookup_by_va_display(
439 g_clear_object(&priv->parent);
440 priv->parent = g_object_ref(cached_info->display);
441 priv->display_type = cached_info->display_type;
445 status = vaInitialize(priv->display, &major_version, &minor_version);
446 if (!vaapi_check_status(status, "vaInitialize()"))
448 GST_DEBUG("VA-API version %d.%d", major_version, minor_version);
452 profiles = g_new(VAProfile, vaMaxNumProfiles(priv->display));
455 entrypoints = g_new(VAEntrypoint, vaMaxNumEntrypoints(priv->display));
458 status = vaQueryConfigProfiles(priv->display, profiles, &n);
459 if (!vaapi_check_status(status, "vaQueryConfigProfiles()"))
462 GST_DEBUG("%d profiles", n);
463 for (i = 0; i < n; i++)
464 GST_DEBUG(" %s", string_of_VAProfile(profiles[i]));
466 priv->decoders = g_array_new(FALSE, FALSE, sizeof(GstVaapiConfig));
469 priv->encoders = g_array_new(FALSE, FALSE, sizeof(GstVaapiConfig));
473 for (i = 0; i < n; i++) {
474 GstVaapiConfig config;
476 config.profile = gst_vaapi_profile(profiles[i]);
480 status = vaQueryConfigEntrypoints(
483 entrypoints, &num_entrypoints
485 if (!vaapi_check_status(status, "vaQueryConfigEntrypoints()"))
488 for (j = 0; j < num_entrypoints; j++) {
489 config.entrypoint = gst_vaapi_entrypoint(entrypoints[j]);
490 switch (config.entrypoint) {
491 case GST_VAAPI_ENTRYPOINT_VLD:
492 case GST_VAAPI_ENTRYPOINT_IDCT:
493 case GST_VAAPI_ENTRYPOINT_MOCO:
494 g_array_append_val(priv->decoders, config);
496 case GST_VAAPI_ENTRYPOINT_SLICE_ENCODE:
497 g_array_append_val(priv->encoders, config);
502 append_h263_config(priv->decoders);
504 /* VA image formats */
505 formats = g_new(VAImageFormat, vaMaxNumImageFormats(priv->display));
508 status = vaQueryImageFormats(priv->display, formats, &n);
509 if (!vaapi_check_status(status, "vaQueryImageFormats()"))
512 GST_DEBUG("%d image formats", n);
513 for (i = 0; i < n; i++)
514 GST_DEBUG(" %" GST_FOURCC_FORMAT, GST_FOURCC_ARGS(formats[i].fourcc));
516 priv->image_formats =
517 g_array_new(FALSE, FALSE, sizeof(GstVaapiImageFormat));
518 if (!priv->image_formats)
520 append_formats(priv->image_formats, formats, n);
521 g_array_sort(priv->image_formats, compare_yuv_formats);
523 /* VA subpicture formats */
524 n = vaMaxNumSubpictureFormats(priv->display);
525 formats = g_renew(VAImageFormat, formats, n);
526 flags = g_new(guint, n);
527 if (!formats || !flags)
529 status = vaQuerySubpictureFormats(priv->display, formats, flags, (guint *)&n);
530 if (!vaapi_check_status(status, "vaQuerySubpictureFormats()"))
533 GST_DEBUG("%d subpicture formats", n);
534 for (i = 0; i < n; i++)
535 GST_DEBUG(" %" GST_FOURCC_FORMAT, GST_FOURCC_ARGS(formats[i].fourcc));
537 priv->subpicture_formats =
538 g_array_new(FALSE, FALSE, sizeof(GstVaapiImageFormat));
539 if (!priv->subpicture_formats)
541 append_formats(priv->subpicture_formats, formats, n);
542 g_array_sort(priv->subpicture_formats, compare_rgb_formats);
545 if (!gst_vaapi_display_cache_add(cache, &info))
559 gst_vaapi_display_lock_default(GstVaapiDisplay *display)
561 GstVaapiDisplayPrivate *priv = display->priv;
564 priv = priv->parent->priv;
565 g_static_rec_mutex_lock(&priv->mutex);
569 gst_vaapi_display_unlock_default(GstVaapiDisplay *display)
571 GstVaapiDisplayPrivate *priv = display->priv;
574 priv = priv->parent->priv;
575 g_static_rec_mutex_unlock(&priv->mutex);
579 gst_vaapi_display_finalize(GObject *object)
581 GstVaapiDisplay * const display = GST_VAAPI_DISPLAY(object);
583 gst_vaapi_display_destroy(display);
585 g_static_rec_mutex_free(&display->priv->mutex);
587 G_OBJECT_CLASS(gst_vaapi_display_parent_class)->finalize(object);
591 gst_vaapi_display_set_property(
598 GstVaapiDisplay * const display = GST_VAAPI_DISPLAY(object);
602 display->priv->display = g_value_get_pointer(value);
604 case PROP_DISPLAY_TYPE:
605 display->priv->display_type = g_value_get_enum(value);
608 G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
614 gst_vaapi_display_get_property(
621 GstVaapiDisplay * const display = GST_VAAPI_DISPLAY(object);
625 g_value_set_pointer(value, gst_vaapi_display_get_display(display));
627 case PROP_DISPLAY_TYPE:
628 g_value_set_enum(value, gst_vaapi_display_get_display_type(display));
631 g_value_set_uint(value, gst_vaapi_display_get_width(display));
634 g_value_set_uint(value, gst_vaapi_display_get_height(display));
637 G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
643 gst_vaapi_display_constructed(GObject *object)
645 GstVaapiDisplay * const display = GST_VAAPI_DISPLAY(object);
646 GObjectClass *parent_class;
648 display->priv->create_display = display->priv->display == NULL;
649 if (!gst_vaapi_display_create(display))
650 gst_vaapi_display_destroy(display);
652 parent_class = G_OBJECT_CLASS(gst_vaapi_display_parent_class);
653 if (parent_class->constructed)
654 parent_class->constructed(object);
658 gst_vaapi_display_class_init(GstVaapiDisplayClass *klass)
660 GObjectClass * const object_class = G_OBJECT_CLASS(klass);
661 GstVaapiDisplayClass * const dpy_class = GST_VAAPI_DISPLAY_CLASS(klass);
663 GST_DEBUG_CATEGORY_INIT(gst_debug_vaapi, "vaapi", 0, "VA-API helper");
665 g_type_class_add_private(klass, sizeof(GstVaapiDisplayPrivate));
667 object_class->finalize = gst_vaapi_display_finalize;
668 object_class->set_property = gst_vaapi_display_set_property;
669 object_class->get_property = gst_vaapi_display_get_property;
670 object_class->constructed = gst_vaapi_display_constructed;
672 dpy_class->lock = gst_vaapi_display_lock_default;
673 dpy_class->unlock = gst_vaapi_display_unlock_default;
675 g_object_class_install_property
678 g_param_spec_pointer("display",
681 G_PARAM_READWRITE|G_PARAM_CONSTRUCT_ONLY));
683 g_object_class_install_property
686 g_param_spec_enum("display-type",
689 GST_VAAPI_TYPE_DISPLAY_TYPE,
690 GST_VAAPI_DISPLAY_TYPE_ANY,
691 G_PARAM_READWRITE|G_PARAM_CONSTRUCT_ONLY));
693 g_object_class_install_property
696 g_param_spec_uint("width",
702 g_object_class_install_property
705 g_param_spec_uint("height",
707 "The display height",
713 gst_vaapi_display_init(GstVaapiDisplay *display)
715 GstVaapiDisplayPrivate *priv = GST_VAAPI_DISPLAY_GET_PRIVATE(display);
717 display->priv = priv;
719 priv->display_type = GST_VAAPI_DISPLAY_TYPE_ANY;
720 priv->display = NULL;
727 priv->decoders = NULL;
728 priv->encoders = NULL;
729 priv->image_formats = NULL;
730 priv->subpicture_formats = NULL;
731 priv->create_display = TRUE;
733 g_static_rec_mutex_init(&priv->mutex);
737 * gst_vaapi_display_new_with_display:
738 * @va_display: a #VADisplay
740 * Creates a new #GstVaapiDisplay, using @va_display as the VA
743 * Return value: the newly created #GstVaapiDisplay object
746 gst_vaapi_display_new_with_display(VADisplay va_display)
748 GstVaapiDisplayCache * const cache = get_display_cache();
749 const GstVaapiDisplayInfo *info;
751 g_return_val_if_fail(va_display != NULL, NULL);
752 g_return_val_if_fail(cache != NULL, NULL);
754 info = gst_vaapi_display_cache_lookup_by_va_display(cache, va_display);
756 return g_object_ref(info->display);
758 return g_object_new(GST_VAAPI_TYPE_DISPLAY,
759 "display", va_display,
764 * gst_vaapi_display_lock:
765 * @display: a #GstVaapiDisplay
767 * Locks @display. If @display is already locked by another thread,
768 * the current thread will block until @display is unlocked by the
772 gst_vaapi_display_lock(GstVaapiDisplay *display)
774 GstVaapiDisplayClass *klass;
776 g_return_if_fail(GST_VAAPI_IS_DISPLAY(display));
778 klass = GST_VAAPI_DISPLAY_GET_CLASS(display);
780 klass->lock(display);
784 * gst_vaapi_display_unlock:
785 * @display: a #GstVaapiDisplay
787 * Unlocks @display. If another thread is blocked in a
788 * gst_vaapi_display_lock() call for @display, it will be woken and
789 * can lock @display itself.
792 gst_vaapi_display_unlock(GstVaapiDisplay *display)
794 GstVaapiDisplayClass *klass;
796 g_return_if_fail(GST_VAAPI_IS_DISPLAY(display));
798 klass = GST_VAAPI_DISPLAY_GET_CLASS(display);
800 klass->unlock(display);
804 * gst_vaapi_display_sync:
805 * @display: a #GstVaapiDisplay
807 * Flushes any requests queued for the windowing system and waits until
808 * all requests have been handled. This is often used for making sure
809 * that the display is synchronized with the current state of the program.
811 * This is most useful for X11. On windowing systems where requests are
812 * handled synchronously, this function will do nothing.
815 gst_vaapi_display_sync(GstVaapiDisplay *display)
817 GstVaapiDisplayClass *klass;
819 g_return_if_fail(GST_VAAPI_IS_DISPLAY(display));
821 klass = GST_VAAPI_DISPLAY_GET_CLASS(display);
823 klass->sync(display);
824 else if (klass->flush)
825 klass->flush(display);
829 * gst_vaapi_display_flush:
830 * @display: a #GstVaapiDisplay
832 * Flushes any requests queued for the windowing system.
834 * This is most useful for X11. On windowing systems where requests
835 * are handled synchronously, this function will do nothing.
838 gst_vaapi_display_flush(GstVaapiDisplay *display)
840 GstVaapiDisplayClass *klass;
842 g_return_if_fail(GST_VAAPI_IS_DISPLAY(display));
844 klass = GST_VAAPI_DISPLAY_GET_CLASS(display);
846 klass->flush(display);
850 * gst_vaapi_display_get_display:
851 * @display: a #GstVaapiDisplay
853 * Returns the #GstVaapiDisplayType bound to @display.
855 * Return value: the #GstVaapiDisplayType
858 gst_vaapi_display_get_display_type(GstVaapiDisplay *display)
860 g_return_val_if_fail(GST_VAAPI_IS_DISPLAY(display),
861 GST_VAAPI_DISPLAY_TYPE_ANY);
863 return display->priv->display_type;
867 * gst_vaapi_display_get_display:
868 * @display: a #GstVaapiDisplay
870 * Returns the #VADisplay bound to @display.
872 * Return value: the #VADisplay
875 gst_vaapi_display_get_display(GstVaapiDisplay *display)
877 g_return_val_if_fail(GST_VAAPI_IS_DISPLAY(display), NULL);
879 return display->priv->display;
883 * gst_vaapi_display_get_width:
884 * @display: a #GstVaapiDisplay
886 * Retrieves the width of a #GstVaapiDisplay.
888 * Return value: the width of the @display, in pixels
891 gst_vaapi_display_get_width(GstVaapiDisplay *display)
893 g_return_val_if_fail(GST_VAAPI_IS_DISPLAY(display), 0);
895 return display->priv->width;
899 * gst_vaapi_display_get_height:
900 * @display: a #GstVaapiDisplay
902 * Retrieves the height of a #GstVaapiDisplay
904 * Return value: the height of the @display, in pixels
907 gst_vaapi_display_get_height(GstVaapiDisplay *display)
909 g_return_val_if_fail(GST_VAAPI_IS_DISPLAY(display), 0);
911 return display->priv->height;
915 * gst_vaapi_display_get_size:
916 * @display: a #GstVaapiDisplay
917 * @pwidth: return location for the width, or %NULL
918 * @pheight: return location for the height, or %NULL
920 * Retrieves the dimensions of a #GstVaapiDisplay.
923 gst_vaapi_display_get_size(GstVaapiDisplay *display, guint *pwidth, guint *pheight)
925 g_return_if_fail(GST_VAAPI_DISPLAY(display));
928 *pwidth = display->priv->width;
931 *pheight = display->priv->height;
935 * gst_vaapi_display_get_pixel_aspect_ratio:
936 * @display: a #GstVaapiDisplay
937 * @par_n: return location for the numerator of pixel aspect ratio, or %NULL
938 * @par_d: return location for the denominator of pixel aspect ratio, or %NULL
940 * Retrieves the pixel aspect ratio of a #GstVaapiDisplay.
943 gst_vaapi_display_get_pixel_aspect_ratio(
944 GstVaapiDisplay *display,
949 g_return_if_fail(GST_VAAPI_IS_DISPLAY(display));
952 *par_n = display->priv->par_n;
955 *par_d = display->priv->par_d;
959 * gst_vaapi_display_get_decode_caps:
960 * @display: a #GstVaapiDisplay
962 * Gets the supported profiles for decoding as #GstCaps capabilities.
964 * Return value: a newly allocated #GstCaps object, possibly empty
967 gst_vaapi_display_get_decode_caps(GstVaapiDisplay *display)
969 g_return_val_if_fail(GST_VAAPI_IS_DISPLAY(display), NULL);
971 return get_profile_caps(display->priv->decoders);
975 * gst_vaapi_display_has_decoder:
976 * @display: a #GstVaapiDisplay
977 * @profile: a #VAProfile
978 * @entrypoint: a #GstVaaiEntrypoint
980 * Returns whether VA @display supports @profile for decoding at the
981 * specified @entrypoint.
983 * Return value: %TRUE if VA @display supports @profile for decoding.
986 gst_vaapi_display_has_decoder(
987 GstVaapiDisplay *display,
988 GstVaapiProfile profile,
989 GstVaapiEntrypoint entrypoint
992 g_return_val_if_fail(GST_VAAPI_IS_DISPLAY(display), FALSE);
994 return find_config(display->priv->decoders, profile, entrypoint);
998 * gst_vaapi_display_get_encode_caps:
999 * @display: a #GstVaapiDisplay
1001 * Gets the supported profiles for decoding as #GstCaps capabilities.
1003 * Return value: a newly allocated #GstCaps object, possibly empty
1006 gst_vaapi_display_get_encode_caps(GstVaapiDisplay *display)
1008 g_return_val_if_fail(GST_VAAPI_IS_DISPLAY(display), NULL);
1010 return get_profile_caps(display->priv->encoders);
1014 * gst_vaapi_display_has_encoder:
1015 * @display: a #GstVaapiDisplay
1016 * @profile: a #VAProfile
1017 * @entrypoint: a #GstVaapiEntrypoint
1019 * Returns whether VA @display supports @profile for encoding at the
1020 * specified @entrypoint.
1022 * Return value: %TRUE if VA @display supports @profile for encoding.
1025 gst_vaapi_display_has_encoder(
1026 GstVaapiDisplay *display,
1027 GstVaapiProfile profile,
1028 GstVaapiEntrypoint entrypoint
1031 g_return_val_if_fail(GST_VAAPI_IS_DISPLAY(display), FALSE);
1033 return find_config(display->priv->encoders, profile, entrypoint);
1037 * gst_vaapi_display_get_image_caps:
1038 * @display: a #GstVaapiDisplay
1040 * Gets the supported image formats for gst_vaapi_surface_get_image()
1041 * or gst_vaapi_surface_put_image() as #GstCaps capabilities.
1043 * Note that this method does not necessarily map image formats
1044 * returned by vaQueryImageFormats(). The set of capabilities can be
1045 * stripped down, if gstreamer-vaapi does not support the format, or
1046 * expanded to cover compatible formats not exposed by the underlying
1047 * driver. e.g. I420 can be supported even if the driver only exposes
1050 * Return value: a newly allocated #GstCaps object, possibly empty
1053 gst_vaapi_display_get_image_caps(GstVaapiDisplay *display)
1055 g_return_val_if_fail(GST_VAAPI_IS_DISPLAY(display), NULL);
1057 return get_format_caps(display->priv->image_formats);
1061 * gst_vaapi_display_has_image_format:
1062 * @display: a #GstVaapiDisplay
1063 * @format: a #GstVaapiFormat
1065 * Returns whether VA @display supports @format image format.
1067 * Return value: %TRUE if VA @display supports @format image format
1070 gst_vaapi_display_has_image_format(
1071 GstVaapiDisplay *display,
1072 GstVaapiImageFormat format
1075 g_return_val_if_fail(GST_VAAPI_IS_DISPLAY(display), FALSE);
1076 g_return_val_if_fail(format, FALSE);
1078 if (find_format(display->priv->image_formats, format))
1081 /* XXX: try subpicture formats since some drivers could report a
1082 * set of VA image formats that is not a superset of the set of VA
1083 * subpicture formats
1085 return find_format(display->priv->subpicture_formats, format);
1089 * gst_vaapi_display_get_subpicture_caps:
1090 * @display: a #GstVaapiDisplay
1092 * Gets the supported subpicture formats as #GstCaps capabilities.
1094 * Note that this method does not necessarily map subpicture formats
1095 * returned by vaQuerySubpictureFormats(). The set of capabilities can
1096 * be stripped down if gstreamer-vaapi does not support the
1097 * format. e.g. this is the case for paletted formats like IA44.
1099 * Return value: a newly allocated #GstCaps object, possibly empty
1102 gst_vaapi_display_get_subpicture_caps(GstVaapiDisplay *display)
1104 g_return_val_if_fail(GST_VAAPI_IS_DISPLAY(display), NULL);
1106 return get_format_caps(display->priv->subpicture_formats);
1110 * gst_vaapi_display_has_subpicture_format:
1111 * @display: a #GstVaapiDisplay
1112 * @format: a #GstVaapiFormat
1114 * Returns whether VA @display supports @format subpicture format.
1116 * Return value: %TRUE if VA @display supports @format subpicture format
1119 gst_vaapi_display_has_subpicture_format(
1120 GstVaapiDisplay *display,
1121 GstVaapiImageFormat format
1124 g_return_val_if_fail(GST_VAAPI_IS_DISPLAY(display), FALSE);
1125 g_return_val_if_fail(format, FALSE);
1127 return find_format(display->priv->subpicture_formats, format);