46
46
#include "gstvaapidebug.h"
48
48
static const guint g_display_types =
49
(1U << GST_VAAPI_DISPLAY_TYPE_X11) |
50
(1U << GST_VAAPI_DISPLAY_TYPE_GLX);
49
(1U << GST_VAAPI_DISPLAY_TYPE_X11) | (1U << GST_VAAPI_DISPLAY_TYPE_GLX);
52
parse_display_name (const gchar * name, guint * len_ptr, guint * id_ptr,
55
gulong len, id = 0, screen = 0;
58
end = strchr (name, ':');
59
len = end ? end - name : strlen (name);
62
id = strtoul (&end[1], &end, 10);
64
screen = strtoul (&end[1], &end, 10);
79
compare_display_name (gconstpointer a, gconstpointer b)
81
const GstVaapiDisplayInfo *const info = a;
82
const gchar *const cached_name = info->display_name;
83
const gchar *const tested_name = b;
84
guint cached_name_length, cached_id;
85
guint tested_name_length, tested_id;
87
g_return_val_if_fail (cached_name, FALSE);
88
g_return_val_if_fail (tested_name, FALSE);
90
if (!parse_display_name (cached_name, &cached_name_length, &cached_id, NULL))
92
if (!parse_display_name (tested_name, &tested_name_length, &tested_id, NULL))
94
if (cached_name_length != tested_name_length)
96
if (strncmp (cached_name, tested_name, cached_name_length) != 0)
98
if (cached_id != tested_id)
52
103
static inline const gchar *
53
get_default_display_name(void)
55
static const gchar *g_display_name;
58
g_display_name = getenv("DISPLAY");
59
return g_display_name;
63
compare_display_name(gconstpointer a, gconstpointer b)
65
const GstVaapiDisplayInfo * const info = a;
66
const gchar *cached_name = info->display_name, *cached_name_end;
67
const gchar *tested_name = b, *tested_name_end;
68
guint cached_name_length, tested_name_length;
70
g_return_val_if_fail(cached_name, FALSE);
71
g_return_val_if_fail(tested_name, FALSE);
73
cached_name_end = strchr(cached_name, ':');
75
cached_name_length = cached_name_end - cached_name;
77
cached_name_length = strlen(cached_name);
79
tested_name_end = strchr(tested_name, ':');
81
tested_name_length = tested_name_end - tested_name;
83
tested_name_length = strlen(tested_name);
85
if (cached_name_length != tested_name_length)
87
if (strncmp(cached_name, tested_name, cached_name_length) != 0)
90
/* XXX: handle screen number? */
104
get_default_display_name (void)
106
static const gchar *g_display_name;
109
g_display_name = getenv ("DISPLAY");
110
return g_display_name;
94
113
/* Reconstruct a display name without our prefix */
95
114
static const gchar *
96
get_display_name(GstVaapiDisplayX11 *display)
115
get_display_name (GstVaapiDisplayX11 * display)
98
GstVaapiDisplayX11Private * const priv = &display->priv;
99
const gchar *display_name = priv->display_name;
117
GstVaapiDisplayX11Private *const priv = &display->priv;
118
const gchar *display_name = priv->display_name;
101
if (!display_name || *display_name == '\0')
120
if (!display_name || *display_name == '\0')
106
125
/* Mangle display name with our prefix */
108
set_display_name(GstVaapiDisplayX11 *display, const gchar *display_name)
127
set_display_name (GstVaapiDisplayX11 * display, const gchar * display_name)
110
GstVaapiDisplayX11Private * const priv = &display->priv;
112
g_free(priv->display_name);
115
display_name = get_default_display_name();
119
priv->display_name = g_strdup(display_name);
120
return priv->display_name != NULL;
129
GstVaapiDisplayX11Private *const priv = &display->priv;
131
g_free (priv->display_name);
134
display_name = get_default_display_name ();
138
priv->display_name = g_strdup (display_name);
139
return priv->display_name != NULL;
123
142
/* Set synchronous behavious on the underlying X11 display */
125
set_synchronous(GstVaapiDisplayX11 *display, gboolean synchronous)
144
set_synchronous (GstVaapiDisplayX11 * display, gboolean synchronous)
127
GstVaapiDisplayX11Private * const priv = &display->priv;
146
GstVaapiDisplayX11Private *const priv = &display->priv;
129
if (priv->synchronous != synchronous) {
130
priv->synchronous = synchronous;
131
if (priv->x11_display) {
132
GST_VAAPI_DISPLAY_LOCK(display);
133
XSynchronize(priv->x11_display, synchronous);
134
GST_VAAPI_DISPLAY_UNLOCK(display);
148
if (priv->synchronous != synchronous) {
149
priv->synchronous = synchronous;
150
if (priv->x11_display) {
151
GST_VAAPI_DISPLAY_LOCK (display);
152
XSynchronize (priv->x11_display, synchronous);
153
GST_VAAPI_DISPLAY_UNLOCK (display);
139
158
/* Check for display server extensions */
141
check_extensions(GstVaapiDisplayX11 *display)
160
check_extensions (GstVaapiDisplayX11 * display)
143
GstVaapiDisplayX11Private * const priv =
144
GST_VAAPI_DISPLAY_X11_PRIVATE(display);
145
int evt_base, err_base;
162
GstVaapiDisplayX11Private *const priv =
163
GST_VAAPI_DISPLAY_X11_PRIVATE (display);
164
int evt_base, err_base;
147
166
#ifdef HAVE_XRANDR
148
priv->use_xrandr = XRRQueryExtension(priv->x11_display,
149
&evt_base, &err_base);
167
priv->use_xrandr = XRRQueryExtension (priv->x11_display,
168
&evt_base, &err_base);
151
170
#ifdef HAVE_XRENDER
152
priv->has_xrender = XRenderQueryExtension(priv->x11_display,
153
&evt_base, &err_base);
171
priv->has_xrender = XRenderQueryExtension (priv->x11_display,
172
&evt_base, &err_base);
158
gst_vaapi_display_x11_bind_display(GstVaapiDisplay *base_display,
177
gst_vaapi_display_x11_bind_display (GstVaapiDisplay * base_display,
159
178
gpointer native_display)
161
GstVaapiDisplayX11 * const display =
162
GST_VAAPI_DISPLAY_X11_CAST(base_display);
163
GstVaapiDisplayX11Private * const priv = &display->priv;
165
priv->x11_display = native_display;
166
priv->x11_screen = DefaultScreen(native_display);
180
GstVaapiDisplayX11 *const display = GST_VAAPI_DISPLAY_X11_CAST (base_display);
181
GstVaapiDisplayX11Private *const priv = &display->priv;
183
priv->x11_display = native_display;
184
priv->x11_screen = DefaultScreen (native_display);
185
priv->use_foreign_display = TRUE;
187
check_extensions (display);
189
if (!set_display_name (display, XDisplayString (priv->x11_display)))
195
gst_vaapi_display_x11_open_display (GstVaapiDisplay * base_display,
198
GstVaapiDisplayX11 *const display = GST_VAAPI_DISPLAY_X11_CAST (base_display);
199
GstVaapiDisplayX11Private *const priv = &display->priv;
200
GstVaapiDisplayCache *const cache = GST_VAAPI_DISPLAY_GET_CACHE (display);
201
const GstVaapiDisplayInfo *info;
203
if (!set_display_name (display, name))
206
info = gst_vaapi_display_cache_lookup_custom (cache, compare_display_name,
207
priv->display_name, GST_VAAPI_DISPLAY_TYPES (display));
209
priv->x11_display = info->native_display;
167
210
priv->use_foreign_display = TRUE;
169
check_extensions(display);
171
if (!set_display_name(display, XDisplayString(priv->x11_display)))
177
gst_vaapi_display_x11_open_display(GstVaapiDisplay *base_display,
180
GstVaapiDisplayX11 * const display =
181
GST_VAAPI_DISPLAY_X11_CAST(base_display);
182
GstVaapiDisplayX11Private * const priv = &display->priv;
183
GstVaapiDisplayCache *cache;
184
const GstVaapiDisplayInfo *info;
186
cache = gst_vaapi_display_get_cache();
187
g_return_val_if_fail(cache != NULL, FALSE);
189
if (!set_display_name(display, name))
192
info = gst_vaapi_display_cache_lookup_custom(cache, compare_display_name,
193
priv->display_name, GST_VAAPI_DISPLAY_TYPES(display));
195
priv->x11_display = info->native_display;
196
priv->use_foreign_display = TRUE;
199
priv->x11_display = XOpenDisplay(get_display_name(display));
200
if (!priv->x11_display)
202
priv->use_foreign_display = FALSE;
204
priv->x11_screen = DefaultScreen(priv->x11_display);
206
check_extensions(display);
211
gst_vaapi_display_x11_close_display(GstVaapiDisplay *display)
213
GstVaapiDisplayX11Private * const priv =
214
GST_VAAPI_DISPLAY_X11_PRIVATE(display);
216
if (priv->pixmap_formats) {
217
g_array_free(priv->pixmap_formats, TRUE);
218
priv->pixmap_formats = NULL;
221
if (priv->x11_display) {
222
if (!priv->use_foreign_display)
223
XCloseDisplay(priv->x11_display);
224
priv->x11_display = NULL;
227
if (priv->display_name) {
228
g_free(priv->display_name);
229
priv->display_name = NULL;
234
gst_vaapi_display_x11_sync(GstVaapiDisplay *display)
236
GstVaapiDisplayX11Private * const priv =
237
GST_VAAPI_DISPLAY_X11_PRIVATE(display);
239
if (priv->x11_display) {
240
GST_VAAPI_DISPLAY_LOCK(display);
241
XSync(priv->x11_display, False);
242
GST_VAAPI_DISPLAY_UNLOCK(display);
247
gst_vaapi_display_x11_flush(GstVaapiDisplay *display)
249
GstVaapiDisplayX11Private * const priv =
250
GST_VAAPI_DISPLAY_X11_PRIVATE(display);
252
if (priv->x11_display) {
253
GST_VAAPI_DISPLAY_LOCK(display);
254
XFlush(priv->x11_display);
255
GST_VAAPI_DISPLAY_UNLOCK(display);
260
gst_vaapi_display_x11_get_display_info(
261
GstVaapiDisplay *display,
262
GstVaapiDisplayInfo *info
265
GstVaapiDisplayX11Private * const priv =
266
GST_VAAPI_DISPLAY_X11_PRIVATE(display);
267
GstVaapiDisplayCache *cache;
268
const GstVaapiDisplayInfo *cached_info;
270
/* Return any cached info even if child has its own VA display */
271
cache = gst_vaapi_display_get_cache();
274
cached_info = gst_vaapi_display_cache_lookup_by_native_display(
275
cache, priv->x11_display, GST_VAAPI_DISPLAY_TYPES(display));
277
*info = *cached_info;
281
/* Otherwise, create VA display if there is none already */
282
info->native_display = priv->x11_display;
283
info->display_name = priv->display_name;
284
if (!info->va_display) {
285
info->va_display = vaGetDisplay(priv->x11_display);
286
if (!info->va_display)
288
info->display_type = GST_VAAPI_DISPLAY_TYPE_X11;
294
gst_vaapi_display_x11_get_size(
295
GstVaapiDisplay *display,
300
GstVaapiDisplayX11Private * const priv =
301
GST_VAAPI_DISPLAY_X11_PRIVATE(display);
303
if (!priv->x11_display)
307
*pwidth = DisplayWidth(priv->x11_display, priv->x11_screen);
310
*pheight = DisplayHeight(priv->x11_display, priv->x11_screen);
314
gst_vaapi_display_x11_get_size_mm(
315
GstVaapiDisplay *display,
320
GstVaapiDisplayX11Private * const priv =
321
GST_VAAPI_DISPLAY_X11_PRIVATE(display);
322
guint width_mm, height_mm;
324
if (!priv->x11_display)
327
width_mm = DisplayWidthMM(priv->x11_display, priv->x11_screen);
328
height_mm = DisplayHeightMM(priv->x11_display, priv->x11_screen);
212
priv->x11_display = XOpenDisplay (get_display_name (display));
213
if (!priv->x11_display)
215
priv->use_foreign_display = FALSE;
217
priv->x11_screen = DefaultScreen (priv->x11_display);
219
check_extensions (display);
224
gst_vaapi_display_x11_close_display (GstVaapiDisplay * display)
226
GstVaapiDisplayX11Private *const priv =
227
GST_VAAPI_DISPLAY_X11_PRIVATE (display);
229
if (priv->pixmap_formats) {
230
g_array_free (priv->pixmap_formats, TRUE);
231
priv->pixmap_formats = NULL;
234
if (priv->x11_display) {
235
if (!priv->use_foreign_display)
236
XCloseDisplay (priv->x11_display);
237
priv->x11_display = NULL;
240
if (priv->display_name) {
241
g_free (priv->display_name);
242
priv->display_name = NULL;
247
gst_vaapi_display_x11_sync (GstVaapiDisplay * display)
249
GstVaapiDisplayX11Private *const priv =
250
GST_VAAPI_DISPLAY_X11_PRIVATE (display);
252
if (priv->x11_display) {
253
GST_VAAPI_DISPLAY_LOCK (display);
254
XSync (priv->x11_display, False);
255
GST_VAAPI_DISPLAY_UNLOCK (display);
260
gst_vaapi_display_x11_flush (GstVaapiDisplay * display)
262
GstVaapiDisplayX11Private *const priv =
263
GST_VAAPI_DISPLAY_X11_PRIVATE (display);
265
if (priv->x11_display) {
266
GST_VAAPI_DISPLAY_LOCK (display);
267
XFlush (priv->x11_display);
268
GST_VAAPI_DISPLAY_UNLOCK (display);
273
gst_vaapi_display_x11_get_display_info (GstVaapiDisplay * display,
274
GstVaapiDisplayInfo * info)
276
GstVaapiDisplayX11Private *const priv =
277
GST_VAAPI_DISPLAY_X11_PRIVATE (display);
278
GstVaapiDisplayCache *const cache = GST_VAAPI_DISPLAY_GET_CACHE (display);
279
const GstVaapiDisplayInfo *cached_info;
281
/* Return any cached info even if child has its own VA display */
282
cached_info = gst_vaapi_display_cache_lookup_by_native_display (cache,
283
priv->x11_display, GST_VAAPI_DISPLAY_TYPES (display));
285
*info = *cached_info;
289
/* Otherwise, create VA display if there is none already */
290
info->native_display = priv->x11_display;
291
info->display_name = priv->display_name;
292
if (!info->va_display) {
293
info->va_display = vaGetDisplay (priv->x11_display);
294
if (!info->va_display)
296
info->display_type = GST_VAAPI_DISPLAY_TYPE_X11;
302
gst_vaapi_display_x11_get_size (GstVaapiDisplay * display,
303
guint * pwidth, guint * pheight)
305
GstVaapiDisplayX11Private *const priv =
306
GST_VAAPI_DISPLAY_X11_PRIVATE (display);
308
if (!priv->x11_display)
312
*pwidth = DisplayWidth (priv->x11_display, priv->x11_screen);
315
*pheight = DisplayHeight (priv->x11_display, priv->x11_screen);
319
gst_vaapi_display_x11_get_size_mm (GstVaapiDisplay * display,
320
guint * pwidth, guint * pheight)
322
GstVaapiDisplayX11Private *const priv =
323
GST_VAAPI_DISPLAY_X11_PRIVATE (display);
324
guint width_mm, height_mm;
326
if (!priv->x11_display)
329
width_mm = DisplayWidthMM (priv->x11_display, priv->x11_screen);
330
height_mm = DisplayHeightMM (priv->x11_display, priv->x11_screen);
330
332
#ifdef HAVE_XRANDR
331
/* XXX: fix up physical size if the display is rotated */
332
if (priv->use_xrandr) {
333
XRRScreenConfiguration *xrr_config = NULL;
334
XRRScreenSize *xrr_sizes;
336
int num_xrr_sizes, size_id, screen;
340
win = DefaultRootWindow(priv->x11_display);
341
screen = XRRRootToScreen(priv->x11_display, win);
343
xrr_config = XRRGetScreenInfo(priv->x11_display, win);
347
size_id = XRRConfigCurrentConfiguration(xrr_config, &rotation);
348
if (rotation == RR_Rotate_0 || rotation == RR_Rotate_180)
351
xrr_sizes = XRRSizes(priv->x11_display, screen, &num_xrr_sizes);
352
if (!xrr_sizes || size_id >= num_xrr_sizes)
355
width_mm = xrr_sizes[size_id].mheight;
356
height_mm = xrr_sizes[size_id].mwidth;
359
XRRFreeScreenConfigInfo(xrr_config);
333
/* XXX: fix up physical size if the display is rotated */
334
if (priv->use_xrandr) {
335
XRRScreenConfiguration *xrr_config = NULL;
336
XRRScreenSize *xrr_sizes;
338
int num_xrr_sizes, size_id, screen;
342
win = DefaultRootWindow (priv->x11_display);
343
screen = XRRRootToScreen (priv->x11_display, win);
345
xrr_config = XRRGetScreenInfo (priv->x11_display, win);
349
size_id = XRRConfigCurrentConfiguration (xrr_config, &rotation);
350
if (rotation == RR_Rotate_0 || rotation == RR_Rotate_180)
353
xrr_sizes = XRRSizes (priv->x11_display, screen, &num_xrr_sizes);
354
if (!xrr_sizes || size_id >= num_xrr_sizes)
357
width_mm = xrr_sizes[size_id].mheight;
358
height_mm = xrr_sizes[size_id].mwidth;
361
XRRFreeScreenConfigInfo (xrr_config);
367
*pheight = height_mm;
369
*pheight = height_mm;
371
gst_vaapi_display_x11_class_init(GstVaapiDisplayX11Class *klass)
373
gst_vaapi_display_x11_class_init (GstVaapiDisplayX11Class * klass)
373
GstVaapiMiniObjectClass * const object_class =
374
GST_VAAPI_MINI_OBJECT_CLASS(klass);
375
GstVaapiDisplayClass * const dpy_class = GST_VAAPI_DISPLAY_CLASS(klass);
377
gst_vaapi_display_class_init(&klass->parent_class);
379
object_class->size = sizeof(GstVaapiDisplayX11);
380
dpy_class->display_types = g_display_types;
381
dpy_class->bind_display = gst_vaapi_display_x11_bind_display;
382
dpy_class->open_display = gst_vaapi_display_x11_open_display;
383
dpy_class->close_display = gst_vaapi_display_x11_close_display;
384
dpy_class->sync = gst_vaapi_display_x11_sync;
385
dpy_class->flush = gst_vaapi_display_x11_flush;
386
dpy_class->get_display = gst_vaapi_display_x11_get_display_info;
387
dpy_class->get_size = gst_vaapi_display_x11_get_size;
388
dpy_class->get_size_mm = gst_vaapi_display_x11_get_size_mm;
375
GstVaapiMiniObjectClass *const object_class =
376
GST_VAAPI_MINI_OBJECT_CLASS (klass);
377
GstVaapiDisplayClass *const dpy_class = GST_VAAPI_DISPLAY_CLASS (klass);
379
gst_vaapi_display_class_init (&klass->parent_class);
381
object_class->size = sizeof (GstVaapiDisplayX11);
382
dpy_class->display_types = g_display_types;
383
dpy_class->bind_display = gst_vaapi_display_x11_bind_display;
384
dpy_class->open_display = gst_vaapi_display_x11_open_display;
385
dpy_class->close_display = gst_vaapi_display_x11_close_display;
386
dpy_class->sync = gst_vaapi_display_x11_sync;
387
dpy_class->flush = gst_vaapi_display_x11_flush;
388
dpy_class->get_display = gst_vaapi_display_x11_get_display_info;
389
dpy_class->get_size = gst_vaapi_display_x11_get_size;
390
dpy_class->get_size_mm = gst_vaapi_display_x11_get_size_mm;
391
393
static inline const GstVaapiDisplayClass *
392
gst_vaapi_display_x11_class(void)
394
gst_vaapi_display_x11_class (void)
394
static GstVaapiDisplayX11Class g_class;
395
static gsize g_class_init = FALSE;
396
static GstVaapiDisplayX11Class g_class;
397
static gsize g_class_init = FALSE;
397
if (g_once_init_enter(&g_class_init)) {
398
gst_vaapi_display_x11_class_init(&g_class);
399
g_once_init_leave(&g_class_init, TRUE);
401
return GST_VAAPI_DISPLAY_CLASS(&g_class);
399
if (g_once_init_enter (&g_class_init)) {
400
gst_vaapi_display_x11_class_init (&g_class);
401
g_once_init_leave (&g_class_init, TRUE);
403
return GST_VAAPI_DISPLAY_CLASS (&g_class);
486
488
* @synchronous is %FALSE.
489
gst_vaapi_display_x11_set_synchronous(GstVaapiDisplayX11 *display,
491
gst_vaapi_display_x11_set_synchronous (GstVaapiDisplayX11 * display,
490
492
gboolean synchronous)
492
g_return_if_fail(GST_VAAPI_IS_DISPLAY_X11(display));
494
g_return_if_fail (GST_VAAPI_IS_DISPLAY_X11 (display));
494
set_synchronous(display, synchronous);
496
set_synchronous (display, synchronous);
497
499
typedef struct _GstVaapiPixmapFormatX11 GstVaapiPixmapFormatX11;
498
struct _GstVaapiPixmapFormatX11 {
499
GstVideoFormat format;
500
struct _GstVaapiPixmapFormatX11
502
GstVideoFormat format;
504
507
static GstVideoFormat
505
pix_fmt_to_video_format(gint depth, gint bpp)
508
pix_fmt_to_video_format (gint depth, gint bpp)
507
GstVideoFormat format = GST_VIDEO_FORMAT_UNKNOWN;
510
GstVideoFormat format = GST_VIDEO_FORMAT_UNKNOWN;
512
format = GST_VIDEO_FORMAT_RGB15;
513
else if (depth == 16)
514
format = GST_VIDEO_FORMAT_RGB16;
515
format = GST_VIDEO_FORMAT_RGB15;
516
else if (depth == 16)
517
format = GST_VIDEO_FORMAT_RGB16;
518
format = GST_VIDEO_FORMAT_RGB;
521
format = GST_VIDEO_FORMAT_RGB;
521
if (depth == 24 || depth == 32)
522
format = GST_VIDEO_FORMAT_xRGB;
524
if (depth == 24 || depth == 32)
525
format = GST_VIDEO_FORMAT_xRGB;
529
ensure_pix_fmts(GstVaapiDisplayX11 *display)
532
ensure_pix_fmts (GstVaapiDisplayX11 * display)
531
GstVaapiDisplayX11Private * const priv =
532
GST_VAAPI_DISPLAY_X11_PRIVATE(display);
533
XPixmapFormatValues *pix_fmts;
534
int i, n, num_pix_fmts;
536
if (priv->pixmap_formats)
539
GST_VAAPI_DISPLAY_LOCK(display);
540
pix_fmts = XListPixmapFormats(GST_VAAPI_DISPLAY_XDISPLAY(display),
542
GST_VAAPI_DISPLAY_UNLOCK(display);
546
priv->pixmap_formats = g_array_sized_new(FALSE, FALSE,
547
sizeof(GstVaapiPixmapFormatX11), num_pix_fmts);
548
if (!priv->pixmap_formats) {
553
for (i = 0, n = 0; i < num_pix_fmts; i++) {
554
GstVaapiPixmapFormatX11 * const pix_fmt =
555
&g_array_index(priv->pixmap_formats, GstVaapiPixmapFormatX11, n);
557
pix_fmt->depth = pix_fmts[i].depth;
558
pix_fmt->bpp = pix_fmts[i].bits_per_pixel;
559
pix_fmt->format = pix_fmt_to_video_format(pix_fmt->depth, pix_fmt->bpp);
560
if (pix_fmt->format != GST_VIDEO_FORMAT_UNKNOWN)
563
priv->pixmap_formats->len = n;
534
GstVaapiDisplayX11Private *const priv =
535
GST_VAAPI_DISPLAY_X11_PRIVATE (display);
536
XPixmapFormatValues *pix_fmts;
537
int i, n, num_pix_fmts;
539
if (priv->pixmap_formats)
542
GST_VAAPI_DISPLAY_LOCK (display);
543
pix_fmts = XListPixmapFormats (GST_VAAPI_DISPLAY_XDISPLAY (display),
545
GST_VAAPI_DISPLAY_UNLOCK (display);
549
priv->pixmap_formats = g_array_sized_new (FALSE, FALSE,
550
sizeof (GstVaapiPixmapFormatX11), num_pix_fmts);
551
if (!priv->pixmap_formats) {
556
for (i = 0, n = 0; i < num_pix_fmts; i++) {
557
GstVaapiPixmapFormatX11 *const pix_fmt =
558
&g_array_index (priv->pixmap_formats, GstVaapiPixmapFormatX11, n);
560
pix_fmt->depth = pix_fmts[i].depth;
561
pix_fmt->bpp = pix_fmts[i].bits_per_pixel;
562
pix_fmt->format = pix_fmt_to_video_format (pix_fmt->depth, pix_fmt->bpp);
563
if (pix_fmt->format != GST_VIDEO_FORMAT_UNKNOWN)
566
priv->pixmap_formats->len = n;
567
570
/* Determine the GstVideoFormat based on a supported Pixmap depth */
569
gst_vaapi_display_x11_get_pixmap_format(GstVaapiDisplayX11 *display,
572
gst_vaapi_display_x11_get_pixmap_format (GstVaapiDisplayX11 * display,
572
if (ensure_pix_fmts(display)) {
573
GstVaapiDisplayX11Private * const priv =
574
GST_VAAPI_DISPLAY_X11_PRIVATE(display);
575
if (ensure_pix_fmts (display)) {
576
GstVaapiDisplayX11Private *const priv =
577
GST_VAAPI_DISPLAY_X11_PRIVATE (display);
577
for (i = 0; i < priv->pixmap_formats->len; i++) {
578
GstVaapiPixmapFormatX11 * const pix_fmt = &g_array_index(
579
priv->pixmap_formats, GstVaapiPixmapFormatX11, i);
580
if (pix_fmt->depth == depth)
581
return pix_fmt->format;
580
for (i = 0; i < priv->pixmap_formats->len; i++) {
581
GstVaapiPixmapFormatX11 *const pix_fmt =
582
&g_array_index (priv->pixmap_formats, GstVaapiPixmapFormatX11, i);
583
if (pix_fmt->depth == depth)
584
return pix_fmt->format;
584
return GST_VIDEO_FORMAT_UNKNOWN;
587
return GST_VIDEO_FORMAT_UNKNOWN;
587
590
/* Determine the Pixmap depth based on a GstVideoFormat */
589
gst_vaapi_display_x11_get_pixmap_depth(GstVaapiDisplayX11 *display,
592
gst_vaapi_display_x11_get_pixmap_depth (GstVaapiDisplayX11 * display,
590
593
GstVideoFormat format)
592
if (ensure_pix_fmts(display)) {
593
GstVaapiDisplayX11Private * const priv =
594
GST_VAAPI_DISPLAY_X11_PRIVATE(display);
595
if (ensure_pix_fmts (display)) {
596
GstVaapiDisplayX11Private *const priv =
597
GST_VAAPI_DISPLAY_X11_PRIVATE (display);
597
for (i = 0; i < priv->pixmap_formats->len; i++) {
598
GstVaapiPixmapFormatX11 * const pix_fmt = &g_array_index(
599
priv->pixmap_formats, GstVaapiPixmapFormatX11, i);
600
if (pix_fmt->format == format)
601
return pix_fmt->depth;
600
for (i = 0; i < priv->pixmap_formats->len; i++) {
601
GstVaapiPixmapFormatX11 *const pix_fmt =
602
&g_array_index (priv->pixmap_formats, GstVaapiPixmapFormatX11, i);
603
if (pix_fmt->format == format)
604
return pix_fmt->depth;