2 * Copyright (C) 2020 Igalia, S.L.
3 * Author: Víctor Jáquez <vjaquez@igalia.com>
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Library General Public License for more details.
15 * You should have received a copy of the GNU Library General Public
16 * License along with this library; if not, write to the
17 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
18 * Boston, MA 02110-1301, USA.
25 #include "gstvadisplay_priv.h"
27 #include <gst/va/gstvavideoformat.h>
29 #include "gstvaprofile.h"
32 gst_va_display_get_profiles (GstVaDisplay * self, guint32 codec,
33 VAEntrypoint entrypoint)
37 VAEntrypoint *entrypoints;
40 gint i, j, num_entrypoints = 0, num_profiles = 0;
42 g_return_val_if_fail (GST_IS_VA_DISPLAY (self), NULL);
44 dpy = gst_va_display_get_va_dpy (self);
46 num_profiles = vaMaxNumProfiles (dpy);
47 num_entrypoints = vaMaxNumEntrypoints (dpy);
49 profiles = g_new (VAProfile, num_profiles);
50 entrypoints = g_new (VAEntrypoint, num_entrypoints);
52 status = vaQueryConfigProfiles (dpy, profiles, &num_profiles);
53 if (status != VA_STATUS_SUCCESS) {
54 GST_ERROR ("vaQueryConfigProfile: %s", vaErrorStr (status));
58 for (i = 0; i < num_profiles; i++) {
59 if (codec != gst_va_profile_codec (profiles[i]))
62 status = vaQueryConfigEntrypoints (dpy, profiles[i], entrypoints,
64 if (status != VA_STATUS_SUCCESS) {
65 GST_ERROR ("vaQueryConfigEntrypoints: %s", vaErrorStr (status));
69 for (j = 0; j < num_entrypoints; j++) {
70 if (entrypoints[j] == entrypoint) {
72 ret = g_array_new (FALSE, FALSE, sizeof (VAProfile));
73 g_array_append_val (ret, profiles[i]);
86 gst_va_display_get_image_formats (GstVaDisplay * self)
89 GstVideoFormat format;
91 VAImageFormat *va_formats;
95 g_return_val_if_fail (GST_IS_VA_DISPLAY (self), NULL);
97 dpy = gst_va_display_get_va_dpy (self);
99 max = vaMaxNumImageFormats (dpy);
103 va_formats = g_new (VAImageFormat, max);
105 status = vaQueryImageFormats (dpy, va_formats, &num);
107 gst_va_video_format_fix_map (va_formats, num);
109 if (status != VA_STATUS_SUCCESS) {
110 GST_ERROR ("vaQueryImageFormats: %s", vaErrorStr (status));
114 ret = g_array_sized_new (FALSE, FALSE, sizeof (GstVideoFormat), num);
115 for (i = 0; i < num; i++) {
116 format = gst_va_video_format_from_va_image_format (&va_formats[i]);
117 if (format != GST_VIDEO_FORMAT_UNKNOWN)
118 g_array_append_val (ret, format);
132 gst_va_display_has_vpp (GstVaDisplay * self)
135 VAEntrypoint *entrypoints;
138 gboolean found = FALSE;
139 g_return_val_if_fail (GST_IS_VA_DISPLAY (self), FALSE);
141 dpy = gst_va_display_get_va_dpy (self);
143 max = vaMaxNumEntrypoints (dpy);
145 entrypoints = g_new (VAEntrypoint, max);
147 status = vaQueryConfigEntrypoints (dpy, VAProfileNone, entrypoints, &num);
148 if (status != VA_STATUS_SUCCESS) {
149 GST_ERROR ("vaQueryImageFormats: %s", vaErrorStr (status));
153 for (i = 0; i < num; i++) {
154 if (entrypoints[i] == VAEntrypointVideoProc) {
161 g_free (entrypoints);