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;
56 static GstVaapiDisplayCache *g_display_cache = NULL;
58 static inline GstVaapiDisplayCache *
59 get_display_cache(void)
62 g_display_cache = gst_vaapi_display_cache_new();
63 return g_display_cache;
66 GstVaapiDisplayCache *
67 gst_vaapi_display_get_cache(void)
69 return get_display_cache();
73 free_display_cache(void)
77 if (gst_vaapi_display_cache_get_size(g_display_cache) > 0)
79 gst_vaapi_display_cache_free(g_display_cache);
80 g_display_cache = NULL;
83 /* Append GstVaapiImageFormat to formats array */
85 append_format(GArray *formats, GstVaapiImageFormat format)
87 g_array_append_val(formats, format);
90 /* Append VAImageFormats to formats array */
92 append_formats(GArray *formats, const VAImageFormat *va_formats, guint n)
94 GstVaapiImageFormat format;
95 gboolean has_YV12 = FALSE;
96 gboolean has_I420 = FALSE;
99 for (i = 0; i < n; i++) {
100 const VAImageFormat * const va_format = &va_formats[i];
102 format = gst_vaapi_image_format(va_format);
104 GST_DEBUG("unsupported format %" GST_FOURCC_FORMAT,
105 GST_FOURCC_ARGS(va_format->fourcc));
110 case GST_VAAPI_IMAGE_YV12:
113 case GST_VAAPI_IMAGE_I420:
119 append_format(formats, format);
122 /* Append I420 (resp. YV12) format if YV12 (resp. I420) is not
123 supported by the underlying driver */
124 if (has_YV12 && !has_I420)
125 append_format(formats, GST_VAAPI_IMAGE_I420);
126 else if (has_I420 && !has_YV12)
127 append_format(formats, GST_VAAPI_IMAGE_YV12);
130 /* Sort image formats. Prefer YUV formats first */
132 compare_yuv_formats(gconstpointer a, gconstpointer b)
134 const GstVaapiImageFormat fmt1 = *(GstVaapiImageFormat *)a;
135 const GstVaapiImageFormat fmt2 = *(GstVaapiImageFormat *)b;
137 const gboolean is_fmt1_yuv = gst_vaapi_image_format_is_yuv(fmt1);
138 const gboolean is_fmt2_yuv = gst_vaapi_image_format_is_yuv(fmt2);
140 if (is_fmt1_yuv != is_fmt2_yuv)
141 return is_fmt1_yuv ? -1 : 1;
143 return ((gint)gst_vaapi_image_format_get_score(fmt1) -
144 (gint)gst_vaapi_image_format_get_score(fmt2));
147 /* Sort subpicture formats. Prefer RGB formats first */
149 compare_rgb_formats(gconstpointer a, gconstpointer b)
151 const GstVaapiImageFormat fmt1 = *(GstVaapiImageFormat *)a;
152 const GstVaapiImageFormat fmt2 = *(GstVaapiImageFormat *)b;
154 const gboolean is_fmt1_rgb = gst_vaapi_image_format_is_rgb(fmt1);
155 const gboolean is_fmt2_rgb = gst_vaapi_image_format_is_rgb(fmt2);
157 if (is_fmt1_rgb != is_fmt2_rgb)
158 return is_fmt1_rgb ? -1 : 1;
160 return ((gint)gst_vaapi_image_format_get_score(fmt1) -
161 (gint)gst_vaapi_image_format_get_score(fmt2));
164 /* Check if configs array contains profile at entrypoint */
165 static inline gboolean
168 GstVaapiProfile profile,
169 GstVaapiEntrypoint entrypoint
172 GstVaapiConfig *config;
178 for (i = 0; i < configs->len; i++) {
179 config = &g_array_index(configs, GstVaapiConfig, i);
180 if (config->profile == profile && config->entrypoint == entrypoint)
186 /* HACK: append H.263 Baseline profile if MPEG-4:2 Simple profile is supported */
188 append_h263_config(GArray *configs)
190 GstVaapiConfig *config, tmp_config;
191 GstVaapiConfig *mpeg4_simple_config = NULL;
192 GstVaapiConfig *h263_baseline_config = NULL;
195 if (!WORKAROUND_H263_BASELINE_DECODE_PROFILE)
201 for (i = 0; i < configs->len; i++) {
202 config = &g_array_index(configs, GstVaapiConfig, i);
203 if (config->profile == GST_VAAPI_PROFILE_MPEG4_SIMPLE)
204 mpeg4_simple_config = config;
205 else if (config->profile == GST_VAAPI_PROFILE_H263_BASELINE)
206 h263_baseline_config = config;
209 if (mpeg4_simple_config && !h263_baseline_config) {
210 tmp_config = *mpeg4_simple_config;
211 tmp_config.profile = GST_VAAPI_PROFILE_H263_BASELINE;
212 g_array_append_val(configs, tmp_config);
216 /* Convert configs array to profiles as GstCaps */
218 get_profile_caps(GArray *configs)
220 GstVaapiConfig *config;
221 GstCaps *out_caps, *caps;
227 out_caps = gst_caps_new_empty();
231 for (i = 0; i < configs->len; i++) {
232 config = &g_array_index(configs, GstVaapiConfig, i);
233 caps = gst_vaapi_profile_get_caps(config->profile);
235 gst_caps_merge(out_caps, caps);
240 /* Check if formats array contains format */
241 static inline gboolean
242 find_format(GArray *formats, GstVaapiImageFormat format)
246 for (i = 0; i < formats->len; i++)
247 if (g_array_index(formats, GstVaapiImageFormat, i) == format)
252 /* Convert formats array to GstCaps */
254 get_format_caps(GArray *formats)
256 GstVaapiImageFormat format;
257 GstCaps *out_caps, *caps;
260 out_caps = gst_caps_new_empty();
264 for (i = 0; i < formats->len; i++) {
265 format = g_array_index(formats, GstVaapiImageFormat, i);
266 caps = gst_vaapi_image_format_get_caps(format);
268 gst_caps_append(out_caps, caps);
274 gst_vaapi_display_calculate_pixel_aspect_ratio(GstVaapiDisplay *display)
276 GstVaapiDisplayPrivate * const priv = display->priv;
277 gdouble ratio, delta;
280 static const gint par[][2] = {
281 {1, 1}, /* regular screen */
282 {16, 15}, /* PAL TV */
283 {11, 10}, /* 525 line Rec.601 video */
284 {54, 59}, /* 625 line Rec.601 video */
285 {64, 45}, /* 1280x1024 on 16:9 display */
286 {5, 3}, /* 1280x1024 on 4:3 display */
287 {4, 3} /* 800x600 on 16:9 display */
290 /* First, calculate the "real" ratio based on the X values;
291 * which is the "physical" w/h divided by the w/h in pixels of the
293 if (!priv->width || !priv->height || !priv->width_mm || !priv->height_mm)
296 ratio = (gdouble)(priv->width_mm * priv->height) /
297 (priv->height_mm * priv->width);
298 GST_DEBUG("calculated pixel aspect ratio: %f", ratio);
300 /* Now, find the one from par[][2] with the lowest delta to the real one */
301 #define DELTA(idx) (ABS(ratio - ((gdouble)par[idx][0] / par[idx][1])))
305 for (i = 1; i < G_N_ELEMENTS(par); i++) {
306 const gdouble this_delta = DELTA(i);
307 if (this_delta < delta) {
314 priv->par_n = par[index][0];
315 priv->par_d = par[index][1];
319 gst_vaapi_display_destroy(GstVaapiDisplay *display)
321 GstVaapiDisplayPrivate * const priv = display->priv;
323 if (priv->decoders) {
324 g_array_free(priv->decoders, TRUE);
325 priv->decoders = NULL;
328 if (priv->encoders) {
329 g_array_free(priv->encoders, TRUE);
330 priv->encoders = NULL;
333 if (priv->image_formats) {
334 g_array_free(priv->image_formats, TRUE);
335 priv->image_formats = NULL;
338 if (priv->subpicture_formats) {
339 g_array_free(priv->subpicture_formats, TRUE);
340 priv->subpicture_formats = NULL;
345 vaTerminate(priv->display);
346 priv->display = NULL;
349 if (priv->create_display) {
350 GstVaapiDisplayClass *klass = GST_VAAPI_DISPLAY_GET_CLASS(display);
351 if (klass->close_display)
352 klass->close_display(display);
356 g_object_unref(priv->parent);
360 if (g_display_cache) {
361 gst_vaapi_display_cache_remove(get_display_cache(), display);
362 free_display_cache();
364 g_static_rec_mutex_free(&priv->mutex);
368 gst_vaapi_display_create(GstVaapiDisplay *display)
370 GstVaapiDisplayPrivate * const priv = display->priv;
371 GstVaapiDisplayCache *cache;
372 gboolean has_errors = TRUE;
373 VAProfile *profiles = NULL;
374 VAEntrypoint *entrypoints = NULL;
375 VAImageFormat *formats = NULL;
376 unsigned int *flags = NULL;
377 gint i, j, n, num_entrypoints, major_version, minor_version;
379 GstVaapiDisplayInfo info;
380 const GstVaapiDisplayInfo *cached_info = NULL;
382 memset(&info, 0, sizeof(info));
383 info.display = display;
386 info.va_display = priv->display;
387 else if (priv->create_display) {
388 GstVaapiDisplayClass *klass = GST_VAAPI_DISPLAY_GET_CLASS(display);
389 if (klass->open_display && !klass->open_display(display))
391 if (!klass->get_display || !klass->get_display(display, &info))
393 priv->display = info.va_display;
395 klass->get_size(display, &priv->width, &priv->height);
396 if (klass->get_size_mm)
397 klass->get_size_mm(display, &priv->width_mm, &priv->height_mm);
398 gst_vaapi_display_calculate_pixel_aspect_ratio(display);
403 cache = get_display_cache();
406 cached_info = gst_vaapi_display_cache_lookup_by_va_display(
412 g_object_unref(priv->parent);
413 priv->parent = g_object_ref(cached_info->display);
417 status = vaInitialize(priv->display, &major_version, &minor_version);
418 if (!vaapi_check_status(status, "vaInitialize()"))
420 GST_DEBUG("VA-API version %d.%d", major_version, minor_version);
424 profiles = g_new(VAProfile, vaMaxNumProfiles(priv->display));
427 entrypoints = g_new(VAEntrypoint, vaMaxNumEntrypoints(priv->display));
430 status = vaQueryConfigProfiles(priv->display, profiles, &n);
431 if (!vaapi_check_status(status, "vaQueryConfigProfiles()"))
434 GST_DEBUG("%d profiles", n);
435 for (i = 0; i < n; i++)
436 GST_DEBUG(" %s", string_of_VAProfile(profiles[i]));
438 priv->decoders = g_array_new(FALSE, FALSE, sizeof(GstVaapiConfig));
441 priv->encoders = g_array_new(FALSE, FALSE, sizeof(GstVaapiConfig));
445 for (i = 0; i < n; i++) {
446 GstVaapiConfig config;
448 config.profile = gst_vaapi_profile(profiles[i]);
452 status = vaQueryConfigEntrypoints(
455 entrypoints, &num_entrypoints
457 if (!vaapi_check_status(status, "vaQueryConfigEntrypoints()"))
460 for (j = 0; j < num_entrypoints; j++) {
461 config.entrypoint = gst_vaapi_entrypoint(entrypoints[j]);
462 switch (config.entrypoint) {
463 case GST_VAAPI_ENTRYPOINT_VLD:
464 case GST_VAAPI_ENTRYPOINT_IDCT:
465 case GST_VAAPI_ENTRYPOINT_MOCO:
466 g_array_append_val(priv->decoders, config);
468 case GST_VAAPI_ENTRYPOINT_SLICE_ENCODE:
469 g_array_append_val(priv->encoders, config);
474 append_h263_config(priv->decoders);
476 /* VA image formats */
477 formats = g_new(VAImageFormat, vaMaxNumImageFormats(priv->display));
480 status = vaQueryImageFormats(priv->display, formats, &n);
481 if (!vaapi_check_status(status, "vaQueryImageFormats()"))
484 GST_DEBUG("%d image formats", n);
485 for (i = 0; i < n; i++)
486 GST_DEBUG(" %" GST_FOURCC_FORMAT, GST_FOURCC_ARGS(formats[i].fourcc));
488 priv->image_formats =
489 g_array_new(FALSE, FALSE, sizeof(GstVaapiImageFormat));
490 if (!priv->image_formats)
492 append_formats(priv->image_formats, formats, n);
493 g_array_sort(priv->image_formats, compare_yuv_formats);
495 /* VA subpicture formats */
496 n = vaMaxNumSubpictureFormats(priv->display);
497 formats = g_renew(VAImageFormat, formats, n);
498 flags = g_new(guint, n);
499 if (!formats || !flags)
501 status = vaQuerySubpictureFormats(priv->display, formats, flags, (guint *)&n);
502 if (!vaapi_check_status(status, "vaQuerySubpictureFormats()"))
505 GST_DEBUG("%d subpicture formats", n);
506 for (i = 0; i < n; i++)
507 GST_DEBUG(" %" GST_FOURCC_FORMAT, GST_FOURCC_ARGS(formats[i].fourcc));
509 priv->subpicture_formats =
510 g_array_new(FALSE, FALSE, sizeof(GstVaapiImageFormat));
511 if (!priv->subpicture_formats)
513 append_formats(priv->subpicture_formats, formats, n);
514 g_array_sort(priv->subpicture_formats, compare_rgb_formats);
517 if (!gst_vaapi_display_cache_add(cache, &info))
531 gst_vaapi_display_lock_default(GstVaapiDisplay *display)
533 GstVaapiDisplayPrivate *priv = display->priv;
536 priv = priv->parent->priv;
537 g_static_rec_mutex_lock(&priv->mutex);
541 gst_vaapi_display_unlock_default(GstVaapiDisplay *display)
543 GstVaapiDisplayPrivate *priv = display->priv;
546 priv = priv->parent->priv;
547 g_static_rec_mutex_unlock(&priv->mutex);
551 gst_vaapi_display_finalize(GObject *object)
553 GstVaapiDisplay * const display = GST_VAAPI_DISPLAY(object);
555 gst_vaapi_display_destroy(display);
557 G_OBJECT_CLASS(gst_vaapi_display_parent_class)->finalize(object);
561 gst_vaapi_display_set_property(
568 GstVaapiDisplay * const display = GST_VAAPI_DISPLAY(object);
572 display->priv->display = g_value_get_pointer(value);
575 G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
581 gst_vaapi_display_get_property(
588 GstVaapiDisplay * const display = GST_VAAPI_DISPLAY(object);
592 g_value_set_pointer(value, gst_vaapi_display_get_display(display));
595 g_value_set_uint(value, gst_vaapi_display_get_width(display));
598 g_value_set_uint(value, gst_vaapi_display_get_height(display));
601 G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
607 gst_vaapi_display_constructed(GObject *object)
609 GstVaapiDisplay * const display = GST_VAAPI_DISPLAY(object);
610 GObjectClass *parent_class;
612 display->priv->create_display = display->priv->display == NULL;
613 if (!gst_vaapi_display_create(display))
614 gst_vaapi_display_destroy(display);
616 parent_class = G_OBJECT_CLASS(gst_vaapi_display_parent_class);
617 if (parent_class->constructed)
618 parent_class->constructed(object);
622 gst_vaapi_display_class_init(GstVaapiDisplayClass *klass)
624 GObjectClass * const object_class = G_OBJECT_CLASS(klass);
625 GstVaapiDisplayClass * const dpy_class = GST_VAAPI_DISPLAY_CLASS(klass);
627 GST_DEBUG_CATEGORY_INIT(gst_debug_vaapi, "vaapi", 0, "VA-API helper");
629 g_type_class_add_private(klass, sizeof(GstVaapiDisplayPrivate));
631 object_class->finalize = gst_vaapi_display_finalize;
632 object_class->set_property = gst_vaapi_display_set_property;
633 object_class->get_property = gst_vaapi_display_get_property;
634 object_class->constructed = gst_vaapi_display_constructed;
636 dpy_class->lock = gst_vaapi_display_lock_default;
637 dpy_class->unlock = gst_vaapi_display_unlock_default;
639 g_object_class_install_property
642 g_param_spec_pointer("display",
645 G_PARAM_READWRITE|G_PARAM_CONSTRUCT_ONLY));
647 g_object_class_install_property
650 g_param_spec_uint("width",
656 g_object_class_install_property
659 g_param_spec_uint("height",
661 "The display height",
667 gst_vaapi_display_init(GstVaapiDisplay *display)
669 GstVaapiDisplayPrivate *priv = GST_VAAPI_DISPLAY_GET_PRIVATE(display);
671 display->priv = priv;
673 priv->display = NULL;
680 priv->decoders = NULL;
681 priv->encoders = NULL;
682 priv->image_formats = NULL;
683 priv->subpicture_formats = NULL;
684 priv->create_display = TRUE;
686 g_static_rec_mutex_init(&priv->mutex);
690 * gst_vaapi_display_new_with_display:
691 * @va_display: a #VADisplay
693 * Creates a new #GstVaapiDisplay, using @va_display as the VA
696 * Return value: the newly created #GstVaapiDisplay object
699 gst_vaapi_display_new_with_display(VADisplay va_display)
701 GstVaapiDisplayCache * const cache = get_display_cache();
702 const GstVaapiDisplayInfo *info;
704 g_return_val_if_fail(va_display != NULL, NULL);
705 g_return_val_if_fail(cache != NULL, NULL);
707 info = gst_vaapi_display_cache_lookup_by_va_display(cache, va_display);
709 return g_object_ref(info->display);
711 return g_object_new(GST_VAAPI_TYPE_DISPLAY,
712 "display", va_display,
717 * gst_vaapi_display_lock:
718 * @display: a #GstVaapiDisplay
720 * Locks @display. If @display is already locked by another thread,
721 * the current thread will block until @display is unlocked by the
725 gst_vaapi_display_lock(GstVaapiDisplay *display)
727 GstVaapiDisplayClass *klass;
729 g_return_if_fail(GST_VAAPI_IS_DISPLAY(display));
731 klass = GST_VAAPI_DISPLAY_GET_CLASS(display);
733 klass->lock(display);
737 * gst_vaapi_display_unlock:
738 * @display: a #GstVaapiDisplay
740 * Unlocks @display. If another thread is blocked in a
741 * gst_vaapi_display_lock() call for @display, it will be woken and
742 * can lock @display itself.
745 gst_vaapi_display_unlock(GstVaapiDisplay *display)
747 GstVaapiDisplayClass *klass;
749 g_return_if_fail(GST_VAAPI_IS_DISPLAY(display));
751 klass = GST_VAAPI_DISPLAY_GET_CLASS(display);
753 klass->unlock(display);
757 * gst_vaapi_display_sync:
758 * @display: a #GstVaapiDisplay
760 * Flushes any requests queued for the windowing system and waits until
761 * all requests have been handled. This is often used for making sure
762 * that the display is synchronized with the current state of the program.
764 * This is most useful for X11. On windowing systems where requests are
765 * handled synchronously, this function will do nothing.
768 gst_vaapi_display_sync(GstVaapiDisplay *display)
770 GstVaapiDisplayClass *klass;
772 g_return_if_fail(GST_VAAPI_IS_DISPLAY(display));
774 klass = GST_VAAPI_DISPLAY_GET_CLASS(display);
776 klass->sync(display);
777 else if (klass->flush)
778 klass->flush(display);
782 * gst_vaapi_display_flush:
783 * @display: a #GstVaapiDisplay
785 * Flushes any requests queued for the windowing system.
787 * This is most useful for X11. On windowing systems where requests
788 * are handled synchronously, this function will do nothing.
791 gst_vaapi_display_flush(GstVaapiDisplay *display)
793 GstVaapiDisplayClass *klass;
795 g_return_if_fail(GST_VAAPI_IS_DISPLAY(display));
797 klass = GST_VAAPI_DISPLAY_GET_CLASS(display);
799 klass->flush(display);
803 * gst_vaapi_display_get_display:
804 * @display: a #GstVaapiDisplay
806 * Returns the #VADisplay bound to @display.
808 * Return value: the #VADisplay
811 gst_vaapi_display_get_display(GstVaapiDisplay *display)
813 g_return_val_if_fail(GST_VAAPI_IS_DISPLAY(display), NULL);
815 return display->priv->display;
819 * gst_vaapi_display_get_width:
820 * @display: a #GstVaapiDisplay
822 * Retrieves the width of a #GstVaapiDisplay.
824 * Return value: the width of the @display, in pixels
827 gst_vaapi_display_get_width(GstVaapiDisplay *display)
829 g_return_val_if_fail(GST_VAAPI_IS_DISPLAY(display), 0);
831 return display->priv->width;
835 * gst_vaapi_display_get_height:
836 * @display: a #GstVaapiDisplay
838 * Retrieves the height of a #GstVaapiDisplay
840 * Return value: the height of the @display, in pixels
843 gst_vaapi_display_get_height(GstVaapiDisplay *display)
845 g_return_val_if_fail(GST_VAAPI_IS_DISPLAY(display), 0);
847 return display->priv->height;
851 * gst_vaapi_display_get_size:
852 * @display: a #GstVaapiDisplay
853 * @pwidth: return location for the width, or %NULL
854 * @pheight: return location for the height, or %NULL
856 * Retrieves the dimensions of a #GstVaapiDisplay.
859 gst_vaapi_display_get_size(GstVaapiDisplay *display, guint *pwidth, guint *pheight)
861 g_return_if_fail(GST_VAAPI_DISPLAY(display));
864 *pwidth = display->priv->width;
867 *pheight = display->priv->height;
871 * gst_vaapi_display_get_pixel_aspect_ratio:
872 * @display: a #GstVaapiDisplay
873 * @par_n: return location for the numerator of pixel aspect ratio, or %NULL
874 * @par_d: return location for the denominator of pixel aspect ratio, or %NULL
876 * Retrieves the pixel aspect ratio of a #GstVaapiDisplay.
879 gst_vaapi_display_get_pixel_aspect_ratio(
880 GstVaapiDisplay *display,
885 g_return_if_fail(GST_VAAPI_IS_DISPLAY(display));
888 *par_n = display->priv->par_n;
891 *par_d = display->priv->par_d;
895 * gst_vaapi_display_get_decode_caps:
896 * @display: a #GstVaapiDisplay
898 * Gets the supported profiles for decoding as #GstCaps capabilities.
900 * Return value: a newly allocated #GstCaps object, possibly empty
903 gst_vaapi_display_get_decode_caps(GstVaapiDisplay *display)
905 g_return_val_if_fail(GST_VAAPI_IS_DISPLAY(display), NULL);
907 return get_profile_caps(display->priv->decoders);
911 * gst_vaapi_display_has_decoder:
912 * @display: a #GstVaapiDisplay
913 * @profile: a #VAProfile
914 * @entrypoint: a #GstVaaiEntrypoint
916 * Returns whether VA @display supports @profile for decoding at the
917 * specified @entrypoint.
919 * Return value: %TRUE if VA @display supports @profile for decoding.
922 gst_vaapi_display_has_decoder(
923 GstVaapiDisplay *display,
924 GstVaapiProfile profile,
925 GstVaapiEntrypoint entrypoint
928 g_return_val_if_fail(GST_VAAPI_IS_DISPLAY(display), FALSE);
930 return find_config(display->priv->decoders, profile, entrypoint);
934 * gst_vaapi_display_get_encode_caps:
935 * @display: a #GstVaapiDisplay
937 * Gets the supported profiles for decoding as #GstCaps capabilities.
939 * Return value: a newly allocated #GstCaps object, possibly empty
942 gst_vaapi_display_get_encode_caps(GstVaapiDisplay *display)
944 g_return_val_if_fail(GST_VAAPI_IS_DISPLAY(display), NULL);
946 return get_profile_caps(display->priv->encoders);
950 * gst_vaapi_display_has_encoder:
951 * @display: a #GstVaapiDisplay
952 * @profile: a #VAProfile
953 * @entrypoint: a #GstVaapiEntrypoint
955 * Returns whether VA @display supports @profile for encoding at the
956 * specified @entrypoint.
958 * Return value: %TRUE if VA @display supports @profile for encoding.
961 gst_vaapi_display_has_encoder(
962 GstVaapiDisplay *display,
963 GstVaapiProfile profile,
964 GstVaapiEntrypoint entrypoint
967 g_return_val_if_fail(GST_VAAPI_IS_DISPLAY(display), FALSE);
969 return find_config(display->priv->encoders, profile, entrypoint);
973 * gst_vaapi_display_get_image_caps:
974 * @display: a #GstVaapiDisplay
976 * Gets the supported image formats for gst_vaapi_surface_get_image()
977 * or gst_vaapi_surface_put_image() as #GstCaps capabilities.
979 * Note that this method does not necessarily map image formats
980 * returned by vaQueryImageFormats(). The set of capabilities can be
981 * stripped down, if gstreamer-vaapi does not support the format, or
982 * expanded to cover compatible formats not exposed by the underlying
983 * driver. e.g. I420 can be supported even if the driver only exposes
986 * Return value: a newly allocated #GstCaps object, possibly empty
989 gst_vaapi_display_get_image_caps(GstVaapiDisplay *display)
991 g_return_val_if_fail(GST_VAAPI_IS_DISPLAY(display), NULL);
993 return get_format_caps(display->priv->image_formats);
997 * gst_vaapi_display_has_image_format:
998 * @display: a #GstVaapiDisplay
999 * @format: a #GstVaapiFormat
1001 * Returns whether VA @display supports @format image format.
1003 * Return value: %TRUE if VA @display supports @format image format
1006 gst_vaapi_display_has_image_format(
1007 GstVaapiDisplay *display,
1008 GstVaapiImageFormat format
1011 g_return_val_if_fail(GST_VAAPI_IS_DISPLAY(display), FALSE);
1012 g_return_val_if_fail(format, FALSE);
1014 if (find_format(display->priv->image_formats, format))
1017 /* XXX: try subpicture formats since some drivers could report a
1018 * set of VA image formats that is not a superset of the set of VA
1019 * subpicture formats
1021 return find_format(display->priv->subpicture_formats, format);
1025 * gst_vaapi_display_get_subpicture_caps:
1026 * @display: a #GstVaapiDisplay
1028 * Gets the supported subpicture formats as #GstCaps capabilities.
1030 * Note that this method does not necessarily map subpicture formats
1031 * returned by vaQuerySubpictureFormats(). The set of capabilities can
1032 * be stripped down if gstreamer-vaapi does not support the
1033 * format. e.g. this is the case for paletted formats like IA44.
1035 * Return value: a newly allocated #GstCaps object, possibly empty
1038 gst_vaapi_display_get_subpicture_caps(GstVaapiDisplay *display)
1040 g_return_val_if_fail(GST_VAAPI_IS_DISPLAY(display), NULL);
1042 return get_format_caps(display->priv->subpicture_formats);
1046 * gst_vaapi_display_has_subpicture_format:
1047 * @display: a #GstVaapiDisplay
1048 * @format: a #GstVaapiFormat
1050 * Returns whether VA @display supports @format subpicture format.
1052 * Return value: %TRUE if VA @display supports @format subpicture format
1055 gst_vaapi_display_has_subpicture_format(
1056 GstVaapiDisplay *display,
1057 GstVaapiImageFormat format
1060 g_return_val_if_fail(GST_VAAPI_IS_DISPLAY(display), FALSE);
1061 g_return_val_if_fail(format, FALSE);
1063 return find_format(display->priv->subpicture_formats, format);