CVS: rdesktop constants.h,1.42,1.43 mppc.c,1.7,1.8 rdesktop.c,1.127,1.128 rdp.c,1.87,1.88 rdp5.c,1.16,1.17

Jeroen Meijer <[email protected]>
Newsgroups gmane.network.rdesktop.cvs
Message-ID <[email protected]>
Update of /cvsroot/rdesktop/rdesktop
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3558

Modified Files:
	constants.h mppc.c rdesktop.c rdp.c rdp5.c 
Log Message:
Add alternative mppc decompression code with 64kB history buffer from Vahur Sinijärv, and reenable rdp5 (persistent) bitmap cache 2 (64x64)

Index: constants.h
===================================================================
RCS file: /cvsroot/rdesktop/rdesktop/constants.h,v
retrieving revision 1.42
retrieving revision 1.43
diff -C2 -d -r1.42 -r1.43
*** constants.h	14 Mar 2005 17:47:46 -0000	1.42
--- constants.h	17 Apr 2005 23:14:20 -0000	1.43
***************
*** 257,262 ****
  #define RDP_LOGON_AUTO		0x0008
  #define RDP_LOGON_NORMAL	0x0033
! #define RDP_COMPRESSION		0x0080
  #define RDP_LOGON_BLOB		0x0100
  #define RDP_LOGON_LEAVE_AUDIO	0x2000
  
--- 257,263 ----
  #define RDP_LOGON_AUTO		0x0008
  #define RDP_LOGON_NORMAL	0x0033
! #define RDP_LOGON_COMPRESSION	0x0080	/* mppc compression with 8kB histroy buffer */
  #define RDP_LOGON_BLOB		0x0100
+ #define RDP_LOGON_COMPRESSION2	0x0200	/* rdp5 mppc compression with 64kB history buffer */
  #define RDP_LOGON_LEAVE_AUDIO	0x2000
  
***************
*** 270,277 ****
  
  /* compression types */
  #define RDP_MPPC_COMPRESSED	0x20
  #define RDP_MPPC_RESET		0x40
  #define RDP_MPPC_FLUSH		0x80
! #define RDP_MPPC_DICT_SIZE      8192
  
  /* Keymap flags */
--- 271,281 ----
  
  /* compression types */
+ #define RDP_MPPC_BIG		0x01
  #define RDP_MPPC_COMPRESSED	0x20
  #define RDP_MPPC_RESET		0x40
  #define RDP_MPPC_FLUSH		0x80
! #define RDP_MPPC_DICT_SIZE      65536
! 
! #define RDP5_COMPRESSED		0x80
  
  /* Keymap flags */

Index: mppc.c
===================================================================
RCS file: /cvsroot/rdesktop/rdesktop/mppc.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** mppc.c	6 Mar 2005 21:11:17 -0000	1.7
--- mppc.c	17 Apr 2005 23:14:20 -0000	1.8
***************
*** 156,160 ****
  		/* length pair    */
  		walker <<= 1;
! 		if (--walker_len < 2)
  		{
  			if (i >= clen)
--- 156,160 ----
  		/* length pair    */
  		walker <<= 1;
! 		if (--walker_len < (ctype & RDP_MPPC_BIG ? 3 : 2))
  		{
  			if (i >= clen)
***************
*** 163,213 ****
  			walker_len += 8;
  		}
! 		/* offset decoding where offset len is:
! 		   -63: 1111 followed by the lower 6 bits of the value
! 		   64-319: 1110 followed by the lower 8 bits of the value ( value - 64 )
! 		   320-8191: 110 followed by the lower 13 bits of the value ( value - 320 )
! 		 */
! 		switch (((uint32) walker) >> ((uint32) 30))
  		{
! 			case 3:	/* - 63 */
! 				if (walker_len < 8)
! 				{
! 					if (i >= clen)
! 						return -1;
! 					walker |= (data[i++] & 0xff) << (24 - walker_len);
! 					walker_len += 8;
! 				}
! 				walker <<= 2;
! 				match_off = ((uint32) walker) >> ((uint32) 26);
! 				walker <<= 6;
! 				walker_len -= 8;
! 				break;
  
! 			case 2:	/* 64 - 319 */
! 				for (; walker_len < 10; walker_len += 8)
! 				{
! 					if (i >= clen)
! 						return -1;
! 					walker |= (data[i++] & 0xff) << (24 - walker_len);
! 				}
  
! 				walker <<= 2;
! 				match_off = (((uint32) walker) >> ((uint32) 24)) + 64;
! 				walker <<= 8;
! 				walker_len -= 10;
! 				break;
  
! 			default:	/* 320 - 8191 */
! 				for (; walker_len < 14; walker_len += 8)
! 				{
! 					if (i >= clen)
! 						return -1;
! 					walker |= (data[i++] & 0xff) << (24 - walker_len);
! 				}
  
! 				match_off = (walker >> 18) + 320;
! 				walker <<= 14;
! 				walker_len -= 14;
! 				break;
  		}
  		if (walker_len == 0)
--- 163,284 ----
  			walker_len += 8;
  		}
! 
! 		if (ctype & RDP_MPPC_BIG)
  		{
! 			/* offset decoding where offset len is:
! 			   -63: 11111 followed by the lower 6 bits of the value
! 			   64-319: 11110 followed by the lower 8 bits of the value ( value - 64 )
! 			   320-2367: 1110 followed by lower 11 bits of the value ( value - 320 )
! 			   2368-65535: 110 followed by lower 16 bits of the value ( value - 2368 )
! 			 */
! 			switch (((uint32) walker) >> ((uint32) 29))
! 			{
! 				case 7:	/* - 63 */
! 					for (; walker_len < 9; walker_len += 8)
! 					{
! 						if (i >= clen)
! 							return -1;
! 						walker |= (data[i++] & 0xff) << (24 - walker_len);
! 					}
! 					walker <<= 3;
! 					match_off = ((uint32) walker) >> ((uint32) 26);
! 					walker <<= 6;
! 					walker_len -= 9;
! 					break;
  
! 				case 6:	/* 64 - 319 */
! 					for (; walker_len < 11; walker_len += 8)
! 					{
! 						if (i >= clen)
! 							return -1;
! 						walker |= (data[i++] & 0xff) << (24 - walker_len);
! 					}
  
! 					walker <<= 3;
! 					match_off = (((uint32) walker) >> ((uint32) 24)) + 64;
! 					walker <<= 8;
! 					walker_len -= 11;
! 					break;
  
! 				case 5:
! 				case 4:	/* 320 - 2367 */
! 					for (; walker_len < 13; walker_len += 8)
! 					{
! 						if (i >= clen)
! 							return -1;
! 						walker |= (data[i++] & 0xff) << (24 - walker_len);
! 					}
  
! 					walker <<= 2;
! 					match_off = (((uint32) walker) >> ((uint32) 21)) + 320;
! 					walker <<= 11;
! 					walker_len -= 13;
! 					break;
! 
! 				default:	/* 2368 - 65535 */
! 					for (; walker_len < 17; walker_len += 8)
! 					{
! 						if (i >= clen)
! 							return -1;
! 						walker |= (data[i++] & 0xff) << (24 - walker_len);
! 					}
! 
! 					walker <<= 1;
! 					match_off = (((uint32) walker) >> ((uint32) 16)) + 2368;
! 					walker <<= 16;
! 					walker_len -= 17;
! 					break;
! 			}
! 		}
! 		else
! 		{
! 			/* offset decoding where offset len is:
! 			   -63: 1111 followed by the lower 6 bits of the value
! 			   64-319: 1110 followed by the lower 8 bits of the value ( value - 64 )
! 			   320-8191: 110 followed by the lower 13 bits of the value ( value - 320 )
! 			 */
! 			switch (((uint32) walker) >> ((uint32) 30))
! 			{
! 				case 3:	/* - 63 */
! 					if (walker_len < 8)
! 					{
! 						if (i >= clen)
! 							return -1;
! 						walker |= (data[i++] & 0xff) << (24 - walker_len);
! 						walker_len += 8;
! 					}
! 					walker <<= 2;
! 					match_off = ((uint32) walker) >> ((uint32) 26);
! 					walker <<= 6;
! 					walker_len -= 8;
! 					break;
! 
! 				case 2:	/* 64 - 319 */
! 					for (; walker_len < 10; walker_len += 8)
! 					{
! 						if (i >= clen)
! 							return -1;
! 						walker |= (data[i++] & 0xff) << (24 - walker_len);
! 					}
! 
! 					walker <<= 2;
! 					match_off = (((uint32) walker) >> ((uint32) 24)) + 64;
! 					walker <<= 8;
! 					walker_len -= 10;
! 					break;
! 
! 				default:	/* 320 - 8191 */
! 					for (; walker_len < 14; walker_len += 8)
! 					{
! 						if (i >= clen)
! 							return -1;
! 						walker |= (data[i++] & 0xff) << (24 - walker_len);
! 					}
! 
! 					match_off = (walker >> 18) + 320;
! 					walker <<= 14;
! 					walker_len -= 14;
! 					break;
! 			}
  		}
  		if (walker_len == 0)
***************
*** 290,294 ****
  		}
  		/* memory areas can overlap - meaning we can't use memXXX functions */
! 		k = (next_offset - match_off) & (RDP_MPPC_DICT_SIZE - 1);
  		do
  		{
--- 361,365 ----
  		}
  		/* memory areas can overlap - meaning we can't use memXXX functions */
! 		k = (next_offset - match_off) & (ctype & RDP_MPPC_BIG ? 65535 : 8191);
  		do
  		{

Index: rdesktop.c
===================================================================
RCS file: /cvsroot/rdesktop/rdesktop/rdesktop.c,v
retrieving revision 1.127
retrieving revision 1.128
diff -C2 -d -r1.127 -r1.128
*** rdesktop.c	16 Apr 2005 11:42:33 -0000	1.127
--- rdesktop.c	17 Apr 2005 23:14:20 -0000	1.128
***************
*** 86,90 ****
  BOOL g_owncolmap = False;
  BOOL g_ownbackstore = True;	/* We can't rely on external BackingStore */
- BOOL g_rdp_compression = False;
  uint32 g_embed_wnd;
  uint32 g_rdp5_performanceflags =
--- 86,89 ----
***************
*** 576,581 ****
  			case 'z':
  				DEBUG(("rdp compression enabled\n"));
! 				flags |= RDP_COMPRESSION;
! 				g_rdp_compression = True;
  				break;
  
--- 575,579 ----
  			case 'z':
  				DEBUG(("rdp compression enabled\n"));
! 				flags |= (RDP_LOGON_COMPRESSION | RDP_LOGON_COMPRESSION2);
  				break;
  

Index: rdp.c
===================================================================
RCS file: /cvsroot/rdesktop/rdesktop/rdp.c,v
retrieving revision 1.87
retrieving revision 1.88
diff -C2 -d -r1.87 -r1.88
*** rdp.c	16 Apr 2005 11:42:34 -0000	1.87
--- rdp.c	17 Apr 2005 23:14:20 -0000	1.88
***************
*** 299,308 ****
  	time_t tzone;
  
- #if 0
- 	/* enable rdp compression */
- 	/* some problems still exist with rdp5 */
- 	flags |= RDP_COMPRESSION;
- #endif
- 
  	if (!g_use_rdp5 || 1 == g_server_rdp_version)
  	{
--- 299,302 ----
***************
*** 661,666 ****
  rdp_out_bmpcache2_caps(STREAM s)
  {
- 	uint16 cellsize;
- 
  	out_uint16_le(s, RDP_CAPSET_BMPCACHE2);
  	out_uint16_le(s, RDP_CAPLEN_BMPCACHE2);
--- 655,658 ----
***************
*** 668,692 ****
  	out_uint16_le(s, g_bitmap_cache_persist_enable ? 2 : 0);	/* version */
  
! 	/* Cellsize:
! 	   01 = 16x16, 02 = 32x32, 03 = 64x64
! 	   log2(cell size) - 3
! 	 */
! 
! 	cellsize = 0x03;
! 
! 	if (g_rdp_compression)
! 	{
! 		switch (g_server_bpp)
! 		{
! 			case 24:
! 			case 16:
! 			case 15:
! 				cellsize = 0x02;
! 				break;
! 		}
! 	}
! 
! 	out_uint16_le(s, (0x0000 | (cellsize << 8)));	/* flags? number of caches? */
  
  	out_uint32_le(s, BMPCACHE2_C0_CELLS);
  	out_uint32_le(s, BMPCACHE2_C1_CELLS);
--- 660,666 ----
  	out_uint16_le(s, g_bitmap_cache_persist_enable ? 2 : 0);	/* version */
  
! 	out_uint16_be(s, 3);	/* number of caches in this set */
  
+ 	/* max cell size for cache 0 is 16x16, 1 = 32x32, 2 = 64x64, etc */
  	out_uint32_le(s, BMPCACHE2_C0_CELLS);
  	out_uint32_le(s, BMPCACHE2_C1_CELLS);

Index: rdp5.c
===================================================================
RCS file: /cvsroot/rdesktop/rdesktop/rdp5.c,v
retrieving revision 1.16
retrieving revision 1.17
diff -C2 -d -r1.16 -r1.17
*** rdp5.c	14 Apr 2005 16:46:13 -0000	1.16
--- rdp5.c	17 Apr 2005 23:14:20 -0000	1.17
***************
*** 46,54 ****
  	{
  		in_uint8(s, type);
! 		if (type & RDP_COMPRESSION)
  		{
  			in_uint8(s, ctype);
  			in_uint16_le(s, length);
! 			type ^= RDP_COMPRESSION;
  		}
  		else
--- 46,54 ----
  	{
  		in_uint8(s, type);
! 		if (type & RDP5_COMPRESSED)
  		{
  			in_uint8(s, ctype);
  			in_uint16_le(s, length);
! 			type ^= RDP5_COMPRESSED;
  		}
  		else
***************
*** 61,66 ****
  		if (ctype & RDP_MPPC_COMPRESSED)
  		{
- 			if (length > RDP_MPPC_DICT_SIZE)
- 				error("error decompressed packet size exceeds max\n");
  			if (mppc_expand(s->p, length, ctype, &roff, &rlen) == -1)
  				error("error while decompressing packet\n");
--- 61,64 ----



-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.