static void vnc_colordepth(DisplayState *ds)

{

    int host_big_endian_flag;

    struct VncState *vs = ds->opaque;



#ifdef WORDS_BIGENDIAN

    host_big_endian_flag = 1;

#else

    host_big_endian_flag = 0;

#endif   

    

    switch (ds_get_bits_per_pixel(ds)) {

        case 8:

            vs->depth = 1;

            vs->server_red_max = 7;

            vs->server_green_max = 7;

            vs->server_blue_max = 3;

            vs->server_red_shift = 5;

            vs->server_green_shift = 2;

            vs->server_blue_shift = 0;

            break;

        case 16:

            vs->depth = 2;

            vs->server_red_max = 31;

            vs->server_green_max = 63;

            vs->server_blue_max = 31;

            vs->server_red_shift = 11;

            vs->server_green_shift = 5;

            vs->server_blue_shift = 0;

            break;

        case 32:

            vs->depth = 4;

            vs->server_red_max = 255;

            vs->server_green_max = 255;

            vs->server_blue_max = 255;

            vs->server_red_shift = 16;

            vs->server_green_shift = 8;

            vs->server_blue_shift = 0;

            break;

        default:

            return;

    }



    if (vs->csock != -1 && vs->has_WMVi) {

        /* Sending a WMVi message to notify the client*/

        vnc_write_u8(vs, 0);  /* msg id */

        vnc_write_u8(vs, 0);

        vnc_write_u16(vs, 1); /* number of rects */

        vnc_framebuffer_update(vs, 0, 0, ds_get_width(ds), ds_get_height(ds), 0x574D5669);

        pixel_format_message(vs);

        vnc_flush(vs);

    } else {

        if (vs->pix_bpp == 4 && vs->depth == 4 &&

                host_big_endian_flag == vs->pix_big_endian &&

                vs->client_red_max == 0xff && vs->client_green_max == 0xff && vs->client_blue_max == 0xff &&

                vs->client_red_shift == 16 && vs->client_green_shift == 8 && vs->client_blue_shift == 0) {

            vs->write_pixels = vnc_write_pixels_copy;

            vs->send_hextile_tile = send_hextile_tile_32;

        } else if (vs->pix_bpp == 2 && vs->depth == 2 &&

                host_big_endian_flag == vs->pix_big_endian &&

                vs->client_red_max == 31 && vs->client_green_max == 63 && vs->client_blue_max == 31 &&

                vs->client_red_shift == 11 && vs->client_green_shift == 5 && vs->client_blue_shift == 0) {

            vs->write_pixels = vnc_write_pixels_copy;

            vs->send_hextile_tile = send_hextile_tile_16;

        } else if (vs->pix_bpp == 1 && vs->depth == 1 &&

                host_big_endian_flag == vs->pix_big_endian &&

                vs->client_red_max == 7 && vs->client_green_max == 7 && vs->client_blue_max == 3 &&

                vs->client_red_shift == 5 && vs->client_green_shift == 2 && vs->client_blue_shift == 0) {

            vs->write_pixels = vnc_write_pixels_copy;

            vs->send_hextile_tile = send_hextile_tile_8;

        } else {

            if (vs->depth == 4) {

                vs->send_hextile_tile = send_hextile_tile_generic_32;

            } else if (vs->depth == 2) {

                vs->send_hextile_tile = send_hextile_tile_generic_16;

            } else {

                vs->send_hextile_tile = send_hextile_tile_generic_8;

            }

            vs->write_pixels = vnc_write_pixels_generic;

        }

    }

}

static void vnc_colordepth(DisplayState *ds)

{

    int host_big_endian_flag;

    struct VncState *vs = ds->opaque;



#ifdef WORDS_BIGENDIAN

    host_big_endian_flag = 1;

#else

    host_big_endian_flag = 0;

#endif   

    

    switch (ds_get_bits_per_pixel(ds)) {

        case 8:

            vs->depth = 1;

            vs->server_red_max = 7;

            vs->server_green_max = 7;

            vs->server_blue_max = 3;

            vs->server_red_shift = 5;

            vs->server_green_shift = 2;

            vs->server_blue_shift = 0;

            break;

        case 16:

            vs->depth = 2;

            vs->server_red_max = 31;

            vs->server_green_max = 63;

            vs->server_blue_max = 31;

            vs->server_red_shift = 11;

            vs->server_green_shift = 5;

            vs->server_blue_shift = 0;

            break;

        case 32:

            vs->depth = 4;

            vs->server_red_max = 255;

            vs->server_green_max = 255;

            vs->server_blue_max = 255;

            vs->server_red_shift = 16;

            vs->server_green_shift = 8;

            vs->server_blue_shift = 0;

            break;

        default:

            return;

    }



    if (vs->csock != -1 && vs->has_WMVi) {

        

        vnc_write_u8(vs, 0);  

        vnc_write_u8(vs, 0);

        vnc_write_u16(vs, 1); 

        vnc_framebuffer_update(vs, 0, 0, ds_get_width(ds), ds_get_height(ds), 0x574D5669);

        pixel_format_message(vs);

        vnc_flush(vs);

    } else {

        if (vs->pix_bpp == 4 && vs->depth == 4 &&

                host_big_endian_flag == vs->pix_big_endian &&

                vs->client_red_max == 0xff && vs->client_green_max == 0xff && vs->client_blue_max == 0xff &&

                vs->client_red_shift == 16 && vs->client_green_shift == 8 && vs->client_blue_shift == 0) {

            vs->write_pixels = vnc_write_pixels_copy;

            vs->send_hextile_tile = send_hextile_tile_32;

        } else if (vs->pix_bpp == 2 && vs->depth == 2 &&

                host_big_endian_flag == vs->pix_big_endian &&

                vs->client_red_max == 31 && vs->client_green_max == 63 && vs->client_blue_max == 31 &&

                vs->client_red_shift == 11 && vs->client_green_shift == 5 && vs->client_blue_shift == 0) {

            vs->write_pixels = vnc_write_pixels_copy;

            vs->send_hextile_tile = send_hextile_tile_16;

        } else if (vs->pix_bpp == 1 && vs->depth == 1 &&

                host_big_endian_flag == vs->pix_big_endian &&

                vs->client_red_max == 7 && vs->client_green_max == 7 && vs->client_blue_max == 3 &&

                vs->client_red_shift == 5 && vs->client_green_shift == 2 && vs->client_blue_shift == 0) {

            vs->write_pixels = vnc_write_pixels_copy;

            vs->send_hextile_tile = send_hextile_tile_8;

        } else {

            if (vs->depth == 4) {

                vs->send_hextile_tile = send_hextile_tile_generic_32;

            } else if (vs->depth == 2) {

                vs->send_hextile_tile = send_hextile_tile_generic_16;

            } else {

                vs->send_hextile_tile = send_hextile_tile_generic_8;

            }

            vs->write_pixels = vnc_write_pixels_generic;

        }

    }

}

    int host_big_endian_flag; #ifdef WORDS_BIGENDIAN     host_big_endian_flag = 1; #else     host_big_endian_flag = 0;         } else {     int host_big_endian_flag; #ifdef WORDS_BIGENDIAN     host_big_endian_flag = 1; #else     host_big_endian_flag = 0; #endif        switch (ds_get_bits_per_pixel(ds)) {         case 8:             vs->depth = 1;             vs->server_red_max = 7;             vs->server_green_max = 7;             vs->server_blue_max = 3;             vs->server_red_shift = 5;             vs->server_green_shift = 2;             vs->server_blue_shift = 0;             break;         case 16:             vs->depth = 2;             vs->server_red_max = 31;             vs->server_green_max = 63;             vs->server_blue_max = 31;             vs->server_red_shift = 11;             vs->server_green_shift = 5;             vs->server_blue_shift = 0;             break;         case 32:             vs->depth = 4;             vs->server_red_max = 255;             vs->server_green_max = 255;             vs->server_blue_max = 255;             vs->server_red_shift = 16;             vs->server_green_shift = 8;             vs->server_blue_shift = 0;             break;         default:         if (vs->pix_bpp == 4 && vs->depth == 4 &&                 host_big_endian_flag == vs->pix_big_endian &&                 vs->client_red_max == 0xff && vs->client_green_max == 0xff && vs->client_blue_max == 0xff &&                 vs->client_red_shift == 16 && vs->client_green_shift == 8 && vs->client_blue_shift == 0) {             vs->write_pixels = vnc_write_pixels_copy;             vs->send_hextile_tile = send_hextile_tile_32;         } else if (vs->pix_bpp == 2 && vs->depth == 2 &&                 host_big_endian_flag == vs->pix_big_endian &&                 vs->client_red_max == 31 && vs->client_green_max == 63 && vs->client_blue_max == 31 &&                 vs->client_red_shift == 11 && vs->client_green_shift == 5 && vs->client_blue_shift == 0) {             vs->write_pixels = vnc_write_pixels_copy;             vs->send_hextile_tile = send_hextile_tile_16;         } else if (vs->pix_bpp == 1 && vs->depth == 1 &&                 host_big_endian_flag == vs->pix_big_endian &&                 vs->client_red_max == 7 && vs->client_green_max == 7 && vs->client_blue_max == 3 &&                 vs->client_red_shift == 5 && vs->client_green_shift == 2 && vs->client_blue_shift == 0) {             vs->write_pixels = vnc_write_pixels_copy;             vs->send_hextile_tile = send_hextile_tile_8;         } else {             if (vs->depth == 4) {                 vs->send_hextile_tile = send_hextile_tile_generic_32;             } else if (vs->depth == 2) {                 vs->send_hextile_tile = send_hextile_tile_generic_16;             } else {                 vs->send_hextile_tile = send_hextile_tile_generic_8;             vs->write_pixels = vnc_write_pixels_generic;
static void FUNC_0(DisplayState *VAR_0)

{

    int VAR_1;

    struct VncState *VAR_2 = VAR_0->opaque;



#ifdef WORDS_BIGENDIAN

    VAR_1 = 1;

#else

    VAR_1 = 0;

#endif   

    

    switch (ds_get_bits_per_pixel(VAR_0)) {

        case 8:

            VAR_2->depth = 1;

            VAR_2->server_red_max = 7;

            VAR_2->server_green_max = 7;

            VAR_2->server_blue_max = 3;

            VAR_2->server_red_shift = 5;

            VAR_2->server_green_shift = 2;

            VAR_2->server_blue_shift = 0;

            break;

        case 16:

            VAR_2->depth = 2;

            VAR_2->server_red_max = 31;

            VAR_2->server_green_max = 63;

            VAR_2->server_blue_max = 31;

            VAR_2->server_red_shift = 11;

            VAR_2->server_green_shift = 5;

            VAR_2->server_blue_shift = 0;

            break;

        case 32:

            VAR_2->depth = 4;

            VAR_2->server_red_max = 255;

            VAR_2->server_green_max = 255;

            VAR_2->server_blue_max = 255;

            VAR_2->server_red_shift = 16;

            VAR_2->server_green_shift = 8;

            VAR_2->server_blue_shift = 0;

            break;

        default:

            return;

    }



    if (VAR_2->csock != -1 && VAR_2->has_WMVi) {

        

        vnc_write_u8(VAR_2, 0);  

        vnc_write_u8(VAR_2, 0);

        vnc_write_u16(VAR_2, 1); 

        vnc_framebuffer_update(VAR_2, 0, 0, ds_get_width(VAR_0), ds_get_height(VAR_0), 0x574D5669);

        pixel_format_message(VAR_2);

        vnc_flush(VAR_2);

    } else {

        if (VAR_2->pix_bpp == 4 && VAR_2->depth == 4 &&

                VAR_1 == VAR_2->pix_big_endian &&

                VAR_2->client_red_max == 0xff && VAR_2->client_green_max == 0xff && VAR_2->client_blue_max == 0xff &&

                VAR_2->client_red_shift == 16 && VAR_2->client_green_shift == 8 && VAR_2->client_blue_shift == 0) {

            VAR_2->write_pixels = vnc_write_pixels_copy;

            VAR_2->send_hextile_tile = send_hextile_tile_32;

        } else if (VAR_2->pix_bpp == 2 && VAR_2->depth == 2 &&

                VAR_1 == VAR_2->pix_big_endian &&

                VAR_2->client_red_max == 31 && VAR_2->client_green_max == 63 && VAR_2->client_blue_max == 31 &&

                VAR_2->client_red_shift == 11 && VAR_2->client_green_shift == 5 && VAR_2->client_blue_shift == 0) {

            VAR_2->write_pixels = vnc_write_pixels_copy;

            VAR_2->send_hextile_tile = send_hextile_tile_16;

        } else if (VAR_2->pix_bpp == 1 && VAR_2->depth == 1 &&

                VAR_1 == VAR_2->pix_big_endian &&

                VAR_2->client_red_max == 7 && VAR_2->client_green_max == 7 && VAR_2->client_blue_max == 3 &&

                VAR_2->client_red_shift == 5 && VAR_2->client_green_shift == 2 && VAR_2->client_blue_shift == 0) {

            VAR_2->write_pixels = vnc_write_pixels_copy;

            VAR_2->send_hextile_tile = send_hextile_tile_8;

        } else {

            if (VAR_2->depth == 4) {

                VAR_2->send_hextile_tile = send_hextile_tile_generic_32;

            } else if (VAR_2->depth == 2) {

                VAR_2->send_hextile_tile = send_hextile_tile_generic_16;

            } else {

                VAR_2->send_hextile_tile = send_hextile_tile_generic_8;

            }

            VAR_2->write_pixels = vnc_write_pixels_generic;

        }

    }

}

static void FUNC_0(DisplayState *VAR_0)
{ int VAR_1; struct VncState *VAR_2 = VAR_0->opaque; #ifdef WORDS_BIGENDIAN
VAR_1 = 1; #else
VAR_1 = 0; #endif
switch (ds_get_bits_per_pixel(VAR_0)) { case 8:
VAR_2->depth = 1; VAR_2->server_red_max = 7; VAR_2->server_green_max = 7; VAR_2->server_blue_max = 3; VAR_2->server_red_shift = 5; VAR_2->server_green_shift = 2; VAR_2->server_blue_shift = 0; break; case 16:
VAR_2->depth = 2; VAR_2->server_red_max = 31; VAR_2->server_green_max = 63; VAR_2->server_blue_max = 31; VAR_2->server_red_shift = 11; VAR_2->server_green_shift = 5; VAR_2->server_blue_shift = 0; break; case 32:
VAR_2->depth = 4; VAR_2->server_red_max = 255; VAR_2->server_green_max = 255; VAR_2->server_blue_max = 255; VAR_2->server_red_shift = 16; VAR_2->server_green_shift = 8; VAR_2->server_blue_shift = 0; break; default:
return; } if (VAR_2->csock != -1 && VAR_2->has_WMVi) { vnc_write_u8(VAR_2, 0); vnc_write_u8(VAR_2, 0); vnc_write_u16(VAR_2, 1); vnc_framebuffer_update(VAR_2, 0, 0, ds_get_width(VAR_0), ds_get_height(VAR_0), 0x574D5669); pixel_format_message(VAR_2); vnc_flush(VAR_2); } else { if (VAR_2->pix_bpp == 4 && VAR_2->depth == 4 &&
VAR_1 == VAR_2->pix_big_endian &&
VAR_2->client_red_max == 0xff && VAR_2->client_green_max == 0xff && VAR_2->client_blue_max == 0xff &&
VAR_2->client_red_shift == 16 && VAR_2->client_green_shift == 8 && VAR_2->client_blue_shift == 0) { VAR_2->write_pixels = vnc_write_pixels_copy; VAR_2->send_hextile_tile = send_hextile_tile_32; } else if (VAR_2->pix_bpp == 2 && VAR_2->depth == 2 && VAR_1 == VAR_2->pix_big_endian &&
VAR_2->client_red_max == 31 && VAR_2->client_green_max == 63 && VAR_2->client_blue_max == 31 &&
VAR_2->client_red_shift == 11 && VAR_2->client_green_shift == 5 && VAR_2->client_blue_shift == 0) { VAR_2->write_pixels = vnc_write_pixels_copy; VAR_2->send_hextile_tile = send_hextile_tile_16; } else if (VAR_2->pix_bpp == 1 && VAR_2->depth == 1 && VAR_1 == VAR_2->pix_big_endian &&
VAR_2->client_red_max == 7 && VAR_2->client_green_max == 7 && VAR_2->client_blue_max == 3 &&
VAR_2->client_red_shift == 5 && VAR_2->client_green_shift == 2 && VAR_2->client_blue_shift == 0) { VAR_2->write_pixels = vnc_write_pixels_copy; VAR_2->send_hextile_tile = send_hextile_tile_8; } else { if (VAR_2->depth == 4) { VAR_2->send_hextile_tile = send_hextile_tile_generic_32; } else if (VAR_2->depth == 2) { VAR_2->send_hextile_tile = send_hextile_tile_generic_16; } else { VAR_2->send_hextile_tile = send_hextile_tile_generic_8; } VAR_2->write_pixels = vnc_write_pixels_generic; } } }