diff -ru mplayer-head-20060902-orig/libvo/vo_x11.c mplayer-head-20060902/libvo/vo_x11.c --- mplayer-head-20060902-orig/libvo/vo_x11.c Sat Sep 2 19:16:18 2006 +++ mplayer-head-20060902/libvo/vo_x11.c Sun Sep 3 14:18:48 2006 @@ -7,6 +7,7 @@ #include "config.h" #include "video_out.h" #include "video_out_internal.h" +#include "bswap.h" #include @@ -270,7 +271,7 @@ XGCValues xgcv; Colormap theCmap; XSetWindowAttributes xswa; - unsigned long xswamask; + unsigned long xswamask, rmask, gmask, bmask; #ifdef HAVE_XF86VM unsigned int modeline_width, modeline_height; @@ -472,6 +473,23 @@ vo_dheight = vo_screenheight; } +#ifdef WORDS_BIGENDIAN + if (myximage->byte_order != MSBFirst) +#else + if (myximage->byte_order != LSBFirst) +#endif + { + rmask = bswap_32(myximage->red_mask); + gmask = bswap_32(myximage->green_mask); + bmask = bswap_32(myximage->blue_mask); + } + else { + rmask = myximage->red_mask; + gmask = myximage->green_mask; + bmask = myximage->blue_mask; + } + + out_format = 0; switch ((bpp = myximage->bits_per_pixel)) { case 24: @@ -480,7 +498,12 @@ break; case 32: draw_alpha_fnc = draw_alpha_32; - out_format = IMGFMT_BGR32; + if ((rmask == 0xff) && (gmask == 0xff00) && (bmask == 0xff0000)) { + out_format = IMGFMT_RGB32; + } + else if ((rmask == 0xff0000) && (gmask == 0xff00) && (bmask == 0xff0000)) { + out_format = IMGFMT_BGR32; + } break; case 15: case 16: @@ -502,6 +525,13 @@ draw_alpha_fnc = draw_alpha_null; } + if (out_format == 0) + { + mp_msg(MSGT_VO, MSGL_ERR, + "Display XImage format not supported.\n"); + return -1; + } + /* always allocate swsContext as size could change between frames */ swsContext = sws_getContextFromCmdLine(width, height, in_format, width, height, @@ -512,35 +542,6 @@ dst_width = width; //printf( "X11 bpp: %d color mask: R:%lX G:%lX B:%lX\n",bpp,myximage->red_mask,myximage->green_mask,myximage->blue_mask ); - // If we have blue in the lowest bit then obviously RGB - mode = ((myximage->blue_mask & 0x01) != 0) ? MODE_RGB : MODE_BGR; -#ifdef WORDS_BIGENDIAN - if (myximage->byte_order != MSBFirst) -#else - if (myximage->byte_order != LSBFirst) -#endif - { - mode = ((myximage->blue_mask & 0x01) != 0) ? MODE_BGR : MODE_RGB; -// printf( "No support for non-native XImage byte order!\n" ); -// return -1; - } -#ifdef WORDS_BIGENDIAN - if (mode == MODE_BGR && bpp != 32) - { - mp_msg(MSGT_VO, MSGL_ERR, - "BGR%d not supported, please contact the developers\n", - bpp); - return -1; - } -#else - if (mode == MODE_BGR) - { - mp_msg(MSGT_VO, MSGL_ERR, - "BGR not supported, please contact the developers\n"); - return -1; - } -#endif - if (vo_ontop) vo_x11_setlayer(mDisplay, vo_window, vo_ontop);