changed bulk compression logic

ulab-next
Laxmikant Rashinkar 11 years ago
parent f51f9ce679
commit 3a074450d7

@ -573,18 +573,21 @@ compress_rdp_5(struct xrdp_mppc_enc *enc, tui8 *srcData, int len)
outputBuffer = enc->outputBuffer; outputBuffer = enc->outputBuffer;
g_memset(outputBuffer, 0, len); g_memset(outputBuffer, 0, len);
enc->flags = PACKET_COMPR_TYPE_64K; enc->flags = PACKET_COMPR_TYPE_64K;
if (enc->first_pkt) if (enc->first_pkt)
{ {
enc->first_pkt = 0; enc->first_pkt = 0;
enc->flagsHold |= PACKET_AT_FRONT; enc->flagsHold |= PACKET_AT_FRONT;
} }
if ((enc->historyOffset + len) > enc->buf_len) if ((enc->historyOffset + len) >= enc->buf_len)
{ {
/* historyBuffer cannot hold srcData - rewind it */ /* historyBuffer cannot hold srcData - rewind it */
enc->historyOffset = 0; enc->historyOffset = 0;
enc->flagsHold |= PACKET_AT_FRONT;
g_memset(hash_table, 0, enc->buf_len * 2); g_memset(hash_table, 0, enc->buf_len * 2);
g_memset(enc->historyBuffer, 0, enc->buf_len); // added
enc->first_pkt = 0;
enc->flagsHold |= PACKET_AT_FRONT;
} }
/* point to next free byte in historyBuffer */ /* point to next free byte in historyBuffer */
@ -602,7 +605,7 @@ compress_rdp_5(struct xrdp_mppc_enc *enc, tui8 *srcData, int len)
/* first 2 bytes,because minimum LoM is 3 */ /* first 2 bytes,because minimum LoM is 3 */
if (historyOffset == 0) if (historyOffset == 0)
{ {
/* encode first two bytes are literals */ /* encode first two bytes as literals */
for (x = 0; x < 2; x++) for (x = 0; x < 2; x++)
{ {
data = *(historyPointer + x); data = *(historyPointer + x);
@ -974,8 +977,14 @@ compress_rdp_5(struct xrdp_mppc_enc *enc, tui8 *srcData, int len)
/* give up */ /* give up */
enc->historyOffset = 0; enc->historyOffset = 0;
g_memset(hash_table, 0, enc->buf_len * 2); g_memset(hash_table, 0, enc->buf_len * 2);
g_memset(enc->historyBuffer, 0, enc->buf_len);
enc->flagsHold |= PACKET_FLUSHED; enc->flagsHold |= PACKET_FLUSHED;
enc->first_pkt = 1; enc->first_pkt = 1;
g_memcpy(enc->outputBuffer, srcData, len);
enc->bytes_in_opb = len;
enc->flags = 0x81;
return 1; return 1;
} }
else if (opb_index + 1 > len) else if (opb_index + 1 > len)
@ -984,8 +993,14 @@ compress_rdp_5(struct xrdp_mppc_enc *enc, tui8 *srcData, int len)
/* give up */ /* give up */
enc->historyOffset = 0; enc->historyOffset = 0;
g_memset(hash_table, 0, enc->buf_len * 2); g_memset(hash_table, 0, enc->buf_len * 2);
g_memset(enc->historyBuffer, 0, enc->buf_len);
enc->flagsHold |= PACKET_FLUSHED; enc->flagsHold |= PACKET_FLUSHED;
enc->first_pkt = 1; enc->first_pkt = 1;
g_memcpy(enc->outputBuffer, srcData, len);
enc->bytes_in_opb = len;
enc->flags = 0x81;
return 1; return 1;
} }
@ -1000,8 +1015,14 @@ compress_rdp_5(struct xrdp_mppc_enc *enc, tui8 *srcData, int len)
/* give up */ /* give up */
enc->historyOffset = 0; enc->historyOffset = 0;
g_memset(hash_table, 0, enc->buf_len * 2); g_memset(hash_table, 0, enc->buf_len * 2);
g_memset(enc->historyBuffer, 0, enc->buf_len);
enc->flagsHold |= PACKET_FLUSHED; enc->flagsHold |= PACKET_FLUSHED;
enc->first_pkt = 1; enc->first_pkt = 1;
g_memcpy(enc->outputBuffer, srcData, len);
enc->bytes_in_opb = len;
enc->flags = 0x81;
return 1; return 1;
} }
enc->flags |= PACKET_COMPRESSED; enc->flags |= PACKET_COMPRESSED;
@ -1011,6 +1032,8 @@ compress_rdp_5(struct xrdp_mppc_enc *enc, tui8 *srcData, int len)
enc->flagsHold = 0; enc->flagsHold = 0;
DLOG(("\n")); DLOG(("\n"));
//g_writeln("compression ratio: %f", (float) len / (float) enc->bytes_in_opb);
return 1; return 1;
} }

@ -433,29 +433,26 @@ xrdp_rdp_send_data(struct xrdp_rdp *self, struct stream *s,
"tocomplen %d", mppc_enc->flags, mppc_enc->bytes_in_opb, "tocomplen %d", mppc_enc->flags, mppc_enc->bytes_in_opb,
mppc_enc->historyOffset, tocomplen)); mppc_enc->historyOffset, tocomplen));
if (mppc_enc->flags & RDP_MPPC_COMPRESSED) clen = mppc_enc->bytes_in_opb + 18;
{ pdulen = clen;
clen = mppc_enc->bytes_in_opb + 18; ctype = mppc_enc->flags;
pdulen = clen; iso_offset = (int)(s->iso_hdr - s->data);
ctype = mppc_enc->flags; mcs_offset = (int)(s->mcs_hdr - s->data);
iso_offset = (int)(s->iso_hdr - s->data); sec_offset = (int)(s->sec_hdr - s->data);
mcs_offset = (int)(s->mcs_hdr - s->data); rdp_offset = (int)(s->rdp_hdr - s->data);
sec_offset = (int)(s->sec_hdr - s->data);
rdp_offset = (int)(s->rdp_hdr - s->data); /* outputBuffer has 64 bytes preceding it */
ls.data = mppc_enc->outputBuffer - (rdp_offset + 18);
/* outputBuffer has 64 bytes preceding it */ ls.p = ls.data + rdp_offset;
ls.data = mppc_enc->outputBuffer - (rdp_offset + 18); ls.end = ls.p + clen;
ls.p = ls.data + rdp_offset; ls.size = clen;
ls.end = ls.p + clen; ls.iso_hdr = ls.data + iso_offset;
ls.size = clen; ls.mcs_hdr = ls.data + mcs_offset;
ls.iso_hdr = ls.data + iso_offset; ls.sec_hdr = ls.data + sec_offset;
ls.mcs_hdr = ls.data + mcs_offset; ls.rdp_hdr = ls.data + rdp_offset;
ls.sec_hdr = ls.data + sec_offset; ls.channel_hdr = 0;
ls.rdp_hdr = ls.data + rdp_offset; ls.next_packet = 0;
ls.channel_hdr = 0; s = &ls;
ls.next_packet = 0;
s = &ls;
}
} }
else else
{ {

Loading…
Cancel
Save