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();
367 gst_vaapi_display_create(GstVaapiDisplay *display)
369 GstVaapiDisplayPrivate * const priv = display->priv;
370 GstVaapiDisplayCache *cache;
371 gboolean has_errors = TRUE;
372 VAProfile *profiles = NULL;
373 VAEntrypoint *entrypoints = NULL;
374 VAImageFormat *formats = NULL;
375 unsigned int *flags = NULL;
376 gint i, j, n, num_entrypoints, major_version, minor_version;
378 GstVaapiDisplayInfo info;
379 const GstVaapiDisplayInfo *cached_info = NULL;
381 memset(&info, 0, sizeof(info));
382 info.display = display;
385 info.va_display = priv->display;
386 else if (priv->create_display) {
387 GstVaapiDisplayClass *klass = GST_VAAPI_DISPLAY_GET_CLASS(display);
388 if (klass->open_display && !klass->open_display(display))
390 if (!klass->get_display || !klass->get_display(display, &info))
392 priv->display = info.va_display;
394 klass->get_size(display, &priv->width, &priv->height);
395 if (klass->get_size_mm)
396 klass->get_size_mm(display, &priv->width_mm, &priv->height_mm);
397 gst_vaapi_display_calculate_pixel_aspect_ratio(display);
402 cache = get_display_cache();
405 cached_info = gst_vaapi_display_cache_lookup_by_va_display(
411 g_object_unref(priv->parent);
412 priv->parent = g_object_ref(cached_info->display);
416 status = vaInitialize(priv->display, &major_version, &minor_version);
417 if (!vaapi_check_status(status, "vaInitialize()"))
419 GST_DEBUG("VA-API version %d.%d", major_version, minor_version);
423 profiles = g_new(VAProfile, vaMaxNumProfiles(priv->display));
426 entrypoints = g_new(VAEntrypoint, vaMaxNumEntrypoints(priv->display));
429 status = vaQueryConfigProfiles(priv->display, profiles, &n);
430 if (!vaapi_check_status(status, "vaQueryConfigProfiles()"))
433 GST_DEBUG("%d profiles", n);
434 for (i = 0; i < n; i++)
435 GST_DEBUG(" %s", string_of_VAProfile(profiles[i]));
437 priv->decoders = g_array_new(FALSE, FALSE, sizeof(GstVaapiConfig));
440 priv->encoders = g_array_new(FALSE, FALSE, sizeof(GstVaapiConfig));
444 for (i = 0; i < n; i++) {
445 GstVaapiConfig config;
447 config.profile = gst_vaapi_profile(profiles[i]);
451 status = vaQueryConfigEntrypoints(
454 entrypoints, &num_entrypoints
456 if (!vaapi_check_status(status, "vaQueryConfigEntrypoints()"))
459 for (j = 0; j < num_entrypoints; j++) {
460 config.entrypoint = gst_vaapi_entrypoint(entrypoints[j]);
461 switch (config.entrypoint) {
462 case GST_VAAPI_ENTRYPOINT_VLD:
463 case GST_VAAPI_ENTRYPOINT_IDCT:
464 case GST_VAAPI_ENTRYPOINT_MOCO:
465 g_array_append_val(priv->decoders, config);
467 case GST_VAAPI_ENTRYPOINT_SLICE_ENCODE:
468 g_array_append_val(priv->encoders, config);
473 append_h263_config(priv->decoders);
475 /* VA image formats */
476 formats = g_new(VAImageFormat, vaMaxNumImageFormats(priv->display));
479 status = vaQueryImageFormats(priv->display, formats, &n);
480 if (!vaapi_check_status(status, "vaQueryImageFormats()"))
483 GST_DEBUG("%d image formats", n);
484 for (i = 0; i < n; i++)
485 GST_DEBUG(" %" GST_FOURCC_FORMAT, GST_FOURCC_ARGS(formats[i].fourcc));
487 priv->image_formats =
488 g_array_new(FALSE, FALSE, sizeof(GstVaapiImageFormat));
489 if (!priv->image_formats)
491 append_formats(priv->image_formats, formats, n);
492 g_array_sort(priv->image_formats, compare_yuv_formats);
494 /* VA subpicture formats */
495 n = vaMaxNumSubpictureFormats(priv->display);
496 formats = g_renew(VAImageFormat, formats, n);
497 flags = g_new(guint, n);
498 if (!formats || !flags)
500 status = vaQuerySubpictureFormats(priv->display, formats, flags, (guint *)&n);
501 if (!vaapi_check_status(status, "vaQuerySubpictureFormats()"))
504 GST_DEBUG("%d subpicture formats", n);
505 for (i = 0; i < n; i++)
506 GST_DEBUG(" %" GST_FOURCC_FORMAT, GST_FOURCC_ARGS(formats[i].fourcc));
508 priv->subpicture_formats =
509 g_array_new(FALSE, FALSE, sizeof(GstVaapiImageFormat));
510 if (!priv->subpicture_formats)
512 append_formats(priv->subpicture_formats, formats, n);
513 g_array_sort(priv->subpicture_formats, compare_rgb_formats);
516 if (!gst_vaapi_display_cache_add(cache, &info))
530 gst_vaapi_display_lock_default(GstVaapiDisplay *display)
532 GstVaapiDisplayPrivate *priv = display->priv;
535 priv = priv->parent->priv;
536 g_static_rec_mutex_lock(&priv->mutex);
540 gst_vaapi_display_unlock_default(GstVaapiDisplay *display)
542 GstVaapiDisplayPrivate *priv = display->priv;
545 priv = priv->parent->priv;
546 g_static_rec_mutex_unlock(&priv->mutex);
550 gst_vaapi_display_finalize(GObject *object)
552 GstVaapiDisplay * const display = GST_VAAPI_DISPLAY(object);
554 gst_vaapi_display_destroy(display);
556 G_OBJECT_CLASS(gst_vaapi_display_parent_class)->finalize(object);
560 gst_vaapi_display_set_property(
567 GstVaapiDisplay * const display = GST_VAAPI_DISPLAY(object);
571 display->priv->display = g_value_get_pointer(value);
574 G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
580 gst_vaapi_display_get_property(
587 GstVaapiDisplay * const display = GST_VAAPI_DISPLAY(object);
591 g_value_set_pointer(value, gst_vaapi_display_get_display(display));
594 g_value_set_uint(value, gst_vaapi_display_get_width(display));
597 g_value_set_uint(value, gst_vaapi_display_get_height(display));
600 G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
606 gst_vaapi_display_constructed(GObject *object)
608 GstVaapiDisplay * const display = GST_VAAPI_DISPLAY(object);
609 GObjectClass *parent_class;
611 display->priv->create_display = display->priv->display == NULL;
612 if (!gst_vaapi_display_create(display))
613 gst_vaapi_display_destroy(display);
615 parent_class = G_OBJECT_CLASS(gst_vaapi_display_parent_class);
616 if (parent_class->constructed)
617 parent_class->constructed(object);
621 gst_vaapi_display_class_init(GstVaapiDisplayClass *klass)
623 GObjectClass * const object_class = G_OBJECT_CLASS(klass);
624 GstVaapiDisplayClass * const dpy_class = GST_VAAPI_DISPLAY_CLASS(klass);
626 GST_DEBUG_CATEGORY_INIT(gst_debug_vaapi, "vaapi", 0, "VA-API helper");
628 g_type_class_add_private(klass, sizeof(GstVaapiDisplayPrivate));
630 object_class->finalize = gst_vaapi_display_finalize;
631 object_class->set_property = gst_vaapi_display_set_property;
632 object_class->get_property = gst_vaapi_display_get_property;
633 object_class->constructed = gst_vaapi_display_constructed;
635 dpy_class->lock = gst_vaapi_display_lock_default;
636 dpy_class->unlock = gst_vaapi_display_unlock_default;
638 g_object_class_install_property
641 g_param_spec_pointer("display",
644 G_PARAM_READWRITE|G_PARAM_CONSTRUCT_ONLY));
646 g_object_class_install_property
649 g_param_spec_uint("width",
655 g_object_class_install_property
658 g_param_spec_uint("height",
660 "The display height",
666 gst_vaapi_display_init(GstVaapiDisplay *display)
668 GstVaapiDisplayPrivate *priv = GST_VAAPI_DISPLAY_GET_PRIVATE(display);
670 display->priv = priv;
672 priv->display = NULL;
679 priv->decoders = NULL;
680 priv->encoders = NULL;
681 priv->image_formats = NULL;
682 priv->subpicture_formats = NULL;
683 priv->create_display = TRUE;
685 g_static_rec_mutex_init(&priv->mutex);
689 * gst_vaapi_display_new_with_display:
690 * @va_display: a #VADisplay
692 * Creates a new #GstVaapiDisplay, using @va_display as the VA
695 * Return value: the newly created #GstVaapiDisplay object
698 gst_vaapi_display_new_with_display(VADisplay va_display)
700 GstVaapiDisplayCache * const cache = get_display_cache();
701 const GstVaapiDisplayInfo *info;
703 g_return_val_if_fail(va_display != NULL, NULL);
704 g_return_val_if_fail(cache != NULL, NULL);
706 info = gst_vaapi_display_cache_lookup_by_va_display(cache, va_display);
708 return g_object_ref(info->display);
710 return g_object_new(GST_VAAPI_TYPE_DISPLAY,
711 "display", va_display,
716 * gst_vaapi_display_lock:
717 * @display: a #GstVaapiDisplay
719 * Locks @display. If @display is already locked by another thread,
720 * the current thread will block until @display is unlocked by the
724 gst_vaapi_display_lock(GstVaapiDisplay *display)
726 GstVaapiDisplayClass *klass;
728 g_return_if_fail(GST_VAAPI_IS_DISPLAY(display));
730 klass = GST_VAAPI_DISPLAY_GET_CLASS(display);
732 klass->lock(display);
736 * gst_vaapi_display_unlock:
737 * @display: a #GstVaapiDisplay
739 * Unlocks @display. If another thread is blocked in a
740 * gst_vaapi_display_lock() call for @display, it will be woken and
741 * can lock @display itself.
744 gst_vaapi_display_unlock(GstVaapiDisplay *display)
746 GstVaapiDisplayClass *klass;
748 g_return_if_fail(GST_VAAPI_IS_DISPLAY(display));
750 klass = GST_VAAPI_DISPLAY_GET_CLASS(display);
752 klass->unlock(display);
756 * gst_vaapi_display_sync:
757 * @display: a #GstVaapiDisplay
759 * Flushes any requests queued for the windowing system and waits until
760 * all requests have been handled. This is often used for making sure
761 * that the display is synchronized with the current state of the program.
763 * This is most useful for X11. On windowing systems where requests are
764 * handled synchronously, this function will do nothing.
767 gst_vaapi_display_sync(GstVaapiDisplay *display)
769 GstVaapiDisplayClass *klass;
771 g_return_if_fail(GST_VAAPI_IS_DISPLAY(display));
773 klass = GST_VAAPI_DISPLAY_GET_CLASS(display);
775 klass->sync(display);
776 else if (klass->flush)
777 klass->flush(display);
781 * gst_vaapi_display_flush:
782 * @display: a #GstVaapiDisplay
784 * Flushes any requests queued for the windowing system.
786 * This is most useful for X11. On windowing systems where requests
787 * are handled synchronously, this function will do nothing.
790 gst_vaapi_display_flush(GstVaapiDisplay *display)
792 GstVaapiDisplayClass *klass;
794 g_return_if_fail(GST_VAAPI_IS_DISPLAY(display));
796 klass = GST_VAAPI_DISPLAY_GET_CLASS(display);
798 klass->flush(display);
802 * gst_vaapi_display_get_display:
803 * @display: a #GstVaapiDisplay
805 * Returns the #VADisplay bound to @display.
807 * Return value: the #VADisplay
810 gst_vaapi_display_get_display(GstVaapiDisplay *display)
812 g_return_val_if_fail(GST_VAAPI_IS_DISPLAY(display), NULL);
814 return display->priv->display;
818 * gst_vaapi_display_get_width:
819 * @display: a #GstVaapiDisplay
821 * Retrieves the width of a #GstVaapiDisplay.
823 * Return value: the width of the @display, in pixels
826 gst_vaapi_display_get_width(GstVaapiDisplay *display)
828 g_return_val_if_fail(GST_VAAPI_IS_DISPLAY(display), 0);
830 return display->priv->width;
834 * gst_vaapi_display_get_height:
835 * @display: a #GstVaapiDisplay
837 * Retrieves the height of a #GstVaapiDisplay
839 * Return value: the height of the @display, in pixels
842 gst_vaapi_display_get_height(GstVaapiDisplay *display)
844 g_return_val_if_fail(GST_VAAPI_IS_DISPLAY(display), 0);
846 return display->priv->height;
850 * gst_vaapi_display_get_size:
851 * @display: a #GstVaapiDisplay
852 * @pwidth: return location for the width, or %NULL
853 * @pheight: return location for the height, or %NULL
855 * Retrieves the dimensions of a #GstVaapiDisplay.
858 gst_vaapi_display_get_size(GstVaapiDisplay *display, guint *pwidth, guint *pheight)
860 g_return_if_fail(GST_VAAPI_DISPLAY(display));
863 *pwidth = display->priv->width;
866 *pheight = display->priv->height;
870 * gst_vaapi_display_get_pixel_aspect_ratio:
871 * @display: a #GstVaapiDisplay
872 * @par_n: return location for the numerator of pixel aspect ratio, or %NULL
873 * @par_d: return location for the denominator of pixel aspect ratio, or %NULL
875 * Retrieves the pixel aspect ratio of a #GstVaapiDisplay.
878 gst_vaapi_display_get_pixel_aspect_ratio(
879 GstVaapiDisplay *display,
884 g_return_if_fail(GST_VAAPI_IS_DISPLAY(display));
887 *par_n = display->priv->par_n;
890 *par_d = display->priv->par_d;
894 * gst_vaapi_display_get_decode_caps:
895 * @display: a #GstVaapiDisplay
897 * Gets the supported profiles for decoding as #GstCaps capabilities.
899 * Return value: a newly allocated #GstCaps object, possibly empty
902 gst_vaapi_display_get_decode_caps(GstVaapiDisplay *display)
904 g_return_val_if_fail(GST_VAAPI_IS_DISPLAY(display), NULL);
906 return get_profile_caps(display->priv->decoders);
910 * gst_vaapi_display_has_decoder:
911 * @display: a #GstVaapiDisplay
912 * @profile: a #VAProfile
913 * @entrypoint: a #GstVaaiEntrypoint
915 * Returns whether VA @display supports @profile for decoding at the
916 * specified @entrypoint.
918 * Return value: %TRUE if VA @display supports @profile for decoding.
921 gst_vaapi_display_has_decoder(
922 GstVaapiDisplay *display,
923 GstVaapiProfile profile,
924 GstVaapiEntrypoint entrypoint
927 g_return_val_if_fail(GST_VAAPI_IS_DISPLAY(display), FALSE);
929 return find_config(display->priv->decoders, profile, entrypoint);
933 * gst_vaapi_display_get_encode_caps:
934 * @display: a #GstVaapiDisplay
936 * Gets the supported profiles for decoding as #GstCaps capabilities.
938 * Return value: a newly allocated #GstCaps object, possibly empty
941 gst_vaapi_display_get_encode_caps(GstVaapiDisplay *display)
943 g_return_val_if_fail(GST_VAAPI_IS_DISPLAY(display), NULL);
945 return get_profile_caps(display->priv->encoders);
949 * gst_vaapi_display_has_encoder:
950 * @display: a #GstVaapiDisplay
951 * @profile: a #VAProfile
952 * @entrypoint: a #GstVaapiEntrypoint
954 * Returns whether VA @display supports @profile for encoding at the
955 * specified @entrypoint.
957 * Return value: %TRUE if VA @display supports @profile for encoding.
960 gst_vaapi_display_has_encoder(
961 GstVaapiDisplay *display,
962 GstVaapiProfile profile,
963 GstVaapiEntrypoint entrypoint
966 g_return_val_if_fail(GST_VAAPI_IS_DISPLAY(display), FALSE);
968 return find_config(display->priv->encoders, profile, entrypoint);
972 * gst_vaapi_display_get_image_caps:
973 * @display: a #GstVaapiDisplay
975 * Gets the supported image formats for gst_vaapi_surface_get_image()
976 * or gst_vaapi_surface_put_image() as #GstCaps capabilities.
978 * Note that this method does not necessarily map image formats
979 * returned by vaQueryImageFormats(). The set of capabilities can be
980 * stripped down, if gstreamer-vaapi does not support the format, or
981 * expanded to cover compatible formats not exposed by the underlying
982 * driver. e.g. I420 can be supported even if the driver only exposes
985 * Return value: a newly allocated #GstCaps object, possibly empty
988 gst_vaapi_display_get_image_caps(GstVaapiDisplay *display)
990 g_return_val_if_fail(GST_VAAPI_IS_DISPLAY(display), NULL);
992 return get_format_caps(display->priv->image_formats);
996 * gst_vaapi_display_has_image_format:
997 * @display: a #GstVaapiDisplay
998 * @format: a #GstVaapiFormat
1000 * Returns whether VA @display supports @format image format.
1002 * Return value: %TRUE if VA @display supports @format image format
1005 gst_vaapi_display_has_image_format(
1006 GstVaapiDisplay *display,
1007 GstVaapiImageFormat format
1010 g_return_val_if_fail(GST_VAAPI_IS_DISPLAY(display), FALSE);
1011 g_return_val_if_fail(format, FALSE);
1013 if (find_format(display->priv->image_formats, format))
1016 /* XXX: try subpicture formats since some drivers could report a
1017 * set of VA image formats that is not a superset of the set of VA
1018 * subpicture formats
1020 return find_format(display->priv->subpicture_formats, format);
1024 * gst_vaapi_display_get_subpicture_caps:
1025 * @display: a #GstVaapiDisplay
1027 * Gets the supported subpicture formats as #GstCaps capabilities.
1029 * Note that this method does not necessarily map subpicture formats
1030 * returned by vaQuerySubpictureFormats(). The set of capabilities can
1031 * be stripped down if gstreamer-vaapi does not support the
1032 * format. e.g. this is the case for paletted formats like IA44.
1034 * Return value: a newly allocated #GstCaps object, possibly empty
1037 gst_vaapi_display_get_subpicture_caps(GstVaapiDisplay *display)
1039 g_return_val_if_fail(GST_VAAPI_IS_DISPLAY(display), NULL);
1041 return get_format_caps(display->priv->subpicture_formats);
1045 * gst_vaapi_display_has_subpicture_format:
1046 * @display: a #GstVaapiDisplay
1047 * @format: a #GstVaapiFormat
1049 * Returns whether VA @display supports @format subpicture format.
1051 * Return value: %TRUE if VA @display supports @format subpicture format
1054 gst_vaapi_display_has_subpicture_format(
1055 GstVaapiDisplay *display,
1056 GstVaapiImageFormat format
1059 g_return_val_if_fail(GST_VAAPI_IS_DISPLAY(display), FALSE);
1060 g_return_val_if_fail(format, FALSE);
1062 return find_format(display->priv->subpicture_formats, format);