2 * test-display.c - Test GstVaapiDisplayX11
4 * gstreamer-vaapi (C) 2010 Splitted-Desktop Systems
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
21 #include <gst/video/video.h>
23 #include <gst/vaapi/gstvaapidisplay_x11.h>
26 #include <gst/vaapi/gstvaapidisplay_glx.h>
30 # include <va/va_glx.h>
32 # define vaGetDisplayGLX(dpy) vaGetDisplay(dpy)
36 print_profile_caps(GstCaps *caps, const gchar *name)
38 guint i, n_caps = gst_caps_get_size(caps);
43 g_print("%u %s caps\n", n_caps, name);
45 for (i = 0; i < gst_caps_get_size(caps); i++) {
46 GstStructure * const structure = gst_caps_get_structure(caps, i);
48 g_error("could not get caps structure %d", i);
51 gst_structure_get_int(structure, "version", &version) ||
52 gst_structure_get_int(structure, "mpegversion", &version)
55 g_print(" %s", gst_structure_get_name(structure));
57 g_print("%d", version);
59 profile = gst_structure_get_string(structure, "profile");
61 g_error("could not get structure profile");
62 g_print(": %s profile\n", profile);
67 print_format_caps(GstCaps *caps, const gchar *name)
69 guint i, n_caps = gst_caps_get_size(caps);
71 g_print("%u %s caps\n", n_caps, name);
73 for (i = 0; i < gst_caps_get_size(caps); i++) {
74 GstStructure * const structure = gst_caps_get_structure(caps, i);
76 g_error("could not get caps structure %d", i);
78 g_print(" %s:", gst_structure_get_name(structure));
80 if (gst_structure_has_name(structure, "video/x-raw-yuv")) {
83 gst_structure_get_fourcc(structure, "format", &fourcc);
85 g_print(" fourcc '%c%c%c%c'",
88 (fourcc >> 16) & 0xff,
89 (fourcc >> 24) & 0xff);
92 gint bpp, endian, rmask, gmask, bmask, amask;
95 gst_structure_get_int(structure, "bpp", &bpp);
96 gst_structure_get_int(structure, "endianness", &endian);
97 gst_structure_get_int(structure, "red_mask", &rmask);
98 gst_structure_get_int(structure, "blue_mask", &bmask);
99 gst_structure_get_int(structure, "green_mask", &gmask);
100 has_alpha = gst_structure_get_int(structure, "alpha_mask", &amask);
102 g_print(" %d bits per pixel, %s endian,",
103 bpp, endian == G_BIG_ENDIAN ? "big" : "little");
104 g_print(" %s masks", has_alpha ? "rgba" : "rgb");
105 g_print(" 0x%08x 0x%08x 0x%08x", rmask, gmask, bmask);
107 g_print(" 0x%08x", amask);
114 dump_caps(GstVaapiDisplay *display)
118 caps = gst_vaapi_display_get_decode_caps(display);
120 g_error("could not get VA decode caps");
122 print_profile_caps(caps, "decoders");
123 gst_caps_unref(caps);
125 caps = gst_vaapi_display_get_encode_caps(display);
127 g_error("could not get VA encode caps");
129 print_profile_caps(caps, "encoders");
130 gst_caps_unref(caps);
132 caps = gst_vaapi_display_get_image_caps(display);
134 g_error("could not get VA image caps");
136 print_format_caps(caps, "image");
137 gst_caps_unref(caps);
139 caps = gst_vaapi_display_get_subpicture_caps(display);
141 g_error("could not get VA subpicture caps");
143 print_format_caps(caps, "subpicture");
144 gst_caps_unref(caps);
148 main(int argc, char *argv[])
150 Display *x11_display;
151 VADisplay va_display;
152 GstVaapiDisplay *display;
153 guint width, height, par_n, par_d;
155 gst_init(&argc, &argv);
159 g_print("# Create display with gst_vaapi_display_x11_new()\n");
162 display = gst_vaapi_display_x11_new(NULL);
164 g_error("could not create Gst/VA display");
166 gst_vaapi_display_get_size(display, &width, &height);
167 g_print("Display size: %ux%u\n", width, height);
169 gst_vaapi_display_get_pixel_aspect_ratio(display, &par_n, &par_d);
170 g_print("Pixel aspect ratio: %u/%u\n", par_n, par_d);
173 g_object_unref(display);
178 g_print("# Create display with gst_vaapi_display_x11_new_with_display()\n");
181 x11_display = XOpenDisplay(NULL);
183 g_error("could not create X11 display");
185 display = gst_vaapi_display_x11_new_with_display(x11_display);
187 g_error("could not create Gst/VA display");
190 g_object_unref(display);
191 XCloseDisplay(x11_display);
196 g_print("# Create display with gst_vaapi_display_new_with_display() [vaGetDisplay()]\n");
199 x11_display = XOpenDisplay(NULL);
201 g_error("could not create X11 display");
203 va_display = vaGetDisplay(x11_display);
205 g_error("could not create VA display");
207 display = gst_vaapi_display_new_with_display(va_display);
209 g_error("could not create Gst/VA display");
212 g_object_unref(display);
213 XCloseDisplay(x11_display);
220 g_print("# Create display with gst_vaapi_display_glx_new()\n");
223 display = gst_vaapi_display_glx_new(NULL);
225 g_error("could not create Gst/VA display");
227 gst_vaapi_display_get_size(display, &width, &height);
228 g_print("Display size: %ux%u\n", width, height);
230 gst_vaapi_display_get_pixel_aspect_ratio(display, &par_n, &par_d);
231 g_print("Pixel aspect ratio: %u/%u\n", par_n, par_d);
234 g_object_unref(display);
239 g_print("# Create display with gst_vaapi_display_glx_new_with_display()\n");
242 x11_display = XOpenDisplay(NULL);
244 g_error("could not create X11 display");
246 display = gst_vaapi_display_glx_new_with_display(x11_display);
248 g_error("could not create Gst/VA display");
251 g_object_unref(display);
252 XCloseDisplay(x11_display);
257 g_print("# Create display with gst_vaapi_display_new_with_display() [vaGetDisplayGLX()]\n");
260 x11_display = XOpenDisplay(NULL);
262 g_error("could not create X11 display");
264 va_display = vaGetDisplayGLX(x11_display);
266 g_error("could not create VA display");
268 display = gst_vaapi_display_new_with_display(va_display);
270 g_error("could not create Gst/VA display");
273 g_object_unref(display);
274 XCloseDisplay(x11_display);