diff -r 87b86d16b1d6 -r e84200edc852 components/vnc_server/vnc-server.c --- a/components/vnc_server/vnc-server.c Sun Oct 21 23:12:08 2018 +0200 +++ b/components/vnc_server/vnc-server.c Mon Oct 22 21:43:45 2018 +0200 @@ -574,12 +574,6 @@ break; } } - - if (encoding_type.corre) { - ESP_LOGI(TAG, "SetEncodings use CORRE"); - } else { - ESP_LOGI(TAG, "SetEncodings use RAW"); - } break; case FRAME_BUFFER_UPDATE_REQ: @@ -867,15 +861,6 @@ uint16_t x_pos, y_pos; int i, j; int tile_width, tile_height; - int packet_length; - static vnc_color_t tile_buffer[TILE_SIZE][TILE_SIZE]; /* Buffer to hold tile to be encoded */ - vnc_color_t pixel_colour; - vnc_color_t bg_colour; - int no_of_subrects, subrect_width, subrect_height; - int k, l; - - no_of_subrects = 0; /* Set to no sub-rectangles to start with */ - packet_length = 20-4+(Bits_Per_Pixel/8); /* Set to minimum packet length to start with */ /* Get the X and Y positions of this tile from the packet buffer */ x_pos = packet_buffer[0] * 256 + packet_buffer[1]; @@ -885,137 +870,6 @@ tile_width = packet_buffer[4] * 256 + packet_buffer[5]; tile_height = packet_buffer[6] * 256 + packet_buffer[7]; - /* Set the encoding type to RRE */ - if (!encoding_type.corre) { - /* CoRRE encoding is not supported - just use raw encoding */ - goto use_raw_encoding; - } - - /* Set encoding type to CoRRE encoding in packet buffer */ - packet_buffer[8+0] = 0; - packet_buffer[8+1] = 0; - packet_buffer[8+2] = 0; - packet_buffer[8+3] = 4; - - /* Copy tile from the main frame buffer to the local tile buffer */ - for (i = 0; i < tile_height; i++) { - for (j = 0; j < tile_width; j++) { - tile_buffer[i][j] = frame_buffer[y_pos + i][x_pos + j]; - } - } - - /* Find the background colour */ - /* We just assume the (0, 0) pixel in the tile is the bgcolour */ - /* Its quick!!! */ - bg_colour = frame_buffer[y_pos][x_pos]; - - /* Set the background colour in the packet buffer */ - if (Bits_Per_Pixel == 8) { - packet_buffer[16] = PixelConvert(bg_colour); /* (vnc_color_t) bg_colour; */ - } else { - packet_buffer[16] = COLOUR2BYTE0(bg_colour); - packet_buffer[16+1] = COLOUR2BYTE1(bg_colour); - } - -#ifdef CYGNUM_VNC_SERVER_CORRE_ENCODING_HACK - /* Add an initial sub-rectangle to paint the background the background colour */ - /* This is required because of a known bug in the VNC viewer (x86 version) */ -//#if BITS_PER_PIXEL == 8 - packet_buffer[packet_length] = (vnc_color_t) bg_colour; - packet_length++; -//#endif -//#if BITS_PER_PIXEL == 16 -// packet_buffer[packet_length] = packet_buffer[16]; -// packet_buffer[packet_length+1] = packet_buffer[16+1]; -// packet_length += 2; -//#endif - packet_buffer[packet_length] = (uint8_t) 0; /* Sub-rect x-pos */ - packet_buffer[packet_length+1] = (uint8_t) 0; /* Sub-rect y-pos*/ - packet_buffer[packet_length+2] = (uint8_t) tile_width; /* Sub-rect width*/ - packet_buffer[packet_length+3] = (uint8_t) tile_height; /* Sub-rect height*/ - packet_length += 4; - no_of_subrects++; /* Increment sub-rectangle count */ -#endif - - /* Scan trough tile and find sub-rectangles */ - for (i = 0; i < tile_height; i++) { - for (j = 0; j < tile_width; j++) { - if (tile_buffer[i][j] != bg_colour) { - /* This is a non-background pixel */ - subrect_width = 1; - pixel_colour = tile_buffer[i][j]; - - /* Extend the sub-rectangle to its maximum width */ - for (subrect_width = 1; subrect_width <= tile_width-j-1; subrect_width++) { - if (tile_buffer[i][j+subrect_width] != pixel_colour) { - goto got_subrect_width; - } - } - -got_subrect_width: - - /* Extend the sub-rectangle to its maximum height */ - for (subrect_height=1; subrect_height <= tile_height-i-1; subrect_height++) { - for (k = j; k < j+subrect_width; k++) { - if (tile_buffer[i+subrect_height][k] != pixel_colour) { - goto got_subrect_height; - } - } - } - -got_subrect_height: - - /* Delete the pixels for the sub-rectangle from the sub-rectangle */ - for (k = i; k < i+subrect_height; k++) { - for (l = j; l < j+subrect_width; l++) { - tile_buffer[k][l] = bg_colour; - } - } - - /* Append new sub-rectangle data to the packet buffer */ - if (Bits_Per_Pixel == 8) { - packet_buffer[packet_length] = PixelConvert(pixel_colour); // (vnc_color_t) pixel_colour; - packet_length++; - } else { - packet_buffer[packet_length] = COLOUR2BYTE0(pixel_colour); - packet_buffer[packet_length+1] = COLOUR2BYTE1(pixel_colour); - packet_length += 2; - } - - packet_buffer[packet_length] = (uint8_t) j; /* Sub-rect x-pos */ - packet_length++; - - packet_buffer[packet_length] = (uint8_t) i; /* Sub-rect y-pos*/ - packet_length++; - - packet_buffer[packet_length] = (uint8_t) subrect_width; /* Sub-rect width*/ - packet_length++; - - packet_buffer[packet_length] = (uint8_t) subrect_height; /* Sub-rect height*/ - packet_length++; - - no_of_subrects++; /* Increment sub-rectangle count */ - - if (packet_length >= 12 + tile_height*tile_width*(BITS_PER_PIXEL/8) - 6) { - /* The next sub-rectangle will make the packet size */ - /* larger than a rew encoded packet - so just use raw */ - goto use_raw_encoding; - } - } - } - } - - /* Fill in no_of_sub-rectangles field in packet buffer */ - packet_buffer[12+0] = 0; - packet_buffer[12+1] = 0; - packet_buffer[12+2] = no_of_subrects / 256; - packet_buffer[12+3] = no_of_subrects % 256; - - /* CoRRE data encoding for tile complete */ - return packet_length; - -use_raw_encoding: - /* Create packet data using RAW encoding */ for (i = 0; i < tile_height; i++) { for (j = 0; j < tile_width; j++) {