Commit ad9613a7 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

XCB: check/select pixmap format

parent 8e9bd644
...@@ -84,6 +84,7 @@ struct vout_sys_t ...@@ -84,6 +84,7 @@ struct vout_sys_t
xcb_gcontext_t gc; /* context to put images */ xcb_gcontext_t gc; /* context to put images */
bool shm; /* whether to use MIT-SHM */ bool shm; /* whether to use MIT-SHM */
uint8_t bpp; /* bits per pixel */ uint8_t bpp; /* bits per pixel */
uint8_t pad; /* scanline pad */
}; };
static int Init (vout_thread_t *); static int Init (vout_thread_t *);
...@@ -136,6 +137,8 @@ static int Open (vlc_object_t *obj) ...@@ -136,6 +137,8 @@ static int Open (vlc_object_t *obj)
} }
free (display); free (display);
const xcb_setup_t *setup = xcb_get_setup (p_sys->conn);
/* Get the preferred screen */ /* Get the preferred screen */
xcb_screen_t *scr = xcb_aux_get_screen (p_sys->conn, snum); xcb_screen_t *scr = xcb_aux_get_screen (p_sys->conn, snum);
p_sys->screen = scr; p_sys->screen = scr;
...@@ -165,43 +168,63 @@ static int Open (vlc_object_t *obj) ...@@ -165,43 +168,63 @@ static int Open (vlc_object_t *obj)
} }
else else
{ {
vt = xcb_aux_find_visual_by_id (scr, scr->root_visual); msg_Err (vout, "no supported visual class");
assert (vt);
msg_Err (vout, "unsupported visual class %"PRIu8, vt->_class);
goto error; goto error;
} }
p_sys->vid = vt->visual_id; p_sys->vid = vt->visual_id;
/* Determine our input format (normally, done in Init() but X11 /* Determine our input format (normally, done in Init() but X11
* never changes its format) */ * never changes its format) */
p_sys->bpp = scr->root_depth; vout->output.i_chroma = 0;
switch (scr->root_depth) for (const xcb_format_t *fmt = xcb_setup_pixmap_formats (setup),
*end = fmt + xcb_setup_pixmap_formats_length (setup);
fmt < end; fmt++)
{
if (fmt->depth != scr->root_depth)
continue;
switch (fmt->depth)
{ {
case 24: case 24:
p_sys->bpp = 32; if (fmt->bits_per_pixel == 32)
case 32: /* FIXME: untested */
vout->output.i_chroma = VLC_FOURCC ('R', 'V', '3', '2'); vout->output.i_chroma = VLC_FOURCC ('R', 'V', '3', '2');
else if (fmt->bits_per_pixel == 24)
vout->output.i_chroma = VLC_FOURCC ('R', 'V', '2', '4');
else
continue;
break; break;
case 16: case 16:
if (fmt->bits_per_pixel != 16)
continue;
vout->output.i_chroma = VLC_FOURCC ('R', 'V', '1', '6'); vout->output.i_chroma = VLC_FOURCC ('R', 'V', '1', '6');
break; break;
case 15: case 15:
p_sys->bpp = 16; if (fmt->bits_per_pixel != 16)
continue;
vout->output.i_chroma = VLC_FOURCC ('R', 'V', '1', '5'); vout->output.i_chroma = VLC_FOURCC ('R', 'V', '1', '5');
break; break;
case 8:
case 8: /* FIXME: VLC cannot convert */ if (fmt->bits_per_pixel != 8)
continue;
vout->output.i_chroma = gray ? VLC_FOURCC ('G', 'R', 'E', 'Y') vout->output.i_chroma = gray ? VLC_FOURCC ('G', 'R', 'E', 'Y')
: VLC_FOURCC ('R', 'G', 'B', '2'); : VLC_FOURCC ('R', 'G', 'B', '2');
break; break;
}
if ((fmt->bits_per_pixel << 4) % fmt->scanline_pad)
continue; /* VLC pads lines to 16 pixels internally */
p_sys->bpp = fmt->bits_per_pixel;
p_sys->pad = fmt->scanline_pad;
msg_Dbg (vout, "using %"PRIu8" bits per pixels (line pad: %"PRIu8")",
p_sys->bpp, p_sys->pad);
break;
}
default: if (!vout->output.i_chroma)
msg_Err (vout, "unsupported %"PRIu8"-bits screen depth", {
scr->root_depth); msg_Err (vout, "no supported pixmap formats");
goto error; goto error;
} }
vout->fmt_out.i_chroma = vout->output.i_chroma; vout->fmt_out.i_chroma = vout->output.i_chroma;
if (!gray) if (!gray)
{ {
...@@ -337,10 +360,9 @@ static int PictureInit (vout_thread_t *vout, picture_t *pic) ...@@ -337,10 +360,9 @@ static int PictureInit (vout_thread_t *vout, picture_t *pic)
const unsigned real_width = pic->p->i_pitch / (p_sys->bpp >> 3); const unsigned real_width = pic->p->i_pitch / (p_sys->bpp >> 3);
/* FIXME: anyway to getthing more intuitive than that?? */ /* FIXME: anyway to getthing more intuitive than that?? */
/* NOTE: 32-bits scanline_pad assumed, FIXME? (see xdpyinfo) */
xcb_image_t *img; xcb_image_t *img;
img = xcb_image_create (real_width, pic->p->i_lines, img = xcb_image_create (real_width, pic->p->i_lines,
XCB_IMAGE_FORMAT_Z_PIXMAP, 32, XCB_IMAGE_FORMAT_Z_PIXMAP, p_sys->pad,
p_sys->screen->root_depth, p_sys->bpp, p_sys->bpp, p_sys->screen->root_depth, p_sys->bpp, p_sys->bpp,
#ifdef WORDS_BIGENDIAN #ifdef WORDS_BIGENDIAN
XCB_IMAGE_ORDER_MSB_FIRST, XCB_IMAGE_ORDER_MSB_FIRST,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment