libxrdp: minor mppc compressor change
This commit is contained in:
parent
98fbca98db
commit
d9a91ca11b
@ -456,7 +456,7 @@ mppc_enc_new(int protocol_type)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
enc->first_pkt = 1;
|
enc->flagsHold = PACKET_AT_FRONT;
|
||||||
enc->historyBuffer = (char *) g_malloc(enc->buf_len, 1);
|
enc->historyBuffer = (char *) g_malloc(enc->buf_len, 1);
|
||||||
|
|
||||||
if (enc->historyBuffer == 0)
|
if (enc->historyBuffer == 0)
|
||||||
@ -574,20 +574,13 @@ compress_rdp_5(struct xrdp_mppc_enc *enc, tui8 *srcData, int len)
|
|||||||
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->historyOffset + len) >= enc->buf_len - 3)
|
||||||
{
|
|
||||||
enc->first_pkt = 0;
|
|
||||||
enc->flagsHold |= PACKET_AT_FRONT;
|
|
||||||
}
|
|
||||||
|
|
||||||
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;
|
||||||
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
|
g_memset(enc->historyBuffer, 0, enc->buf_len); // added
|
||||||
enc->first_pkt = 0;
|
enc->flagsHold |= PACKET_AT_FRONT | PACKET_FLUSHED;
|
||||||
enc->flagsHold |= PACKET_AT_FRONT;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* point to next free byte in historyBuffer */
|
/* point to next free byte in historyBuffer */
|
||||||
@ -970,40 +963,6 @@ compress_rdp_5(struct xrdp_mppc_enc *enc, tui8 *srcData, int len)
|
|||||||
ctr++;
|
ctr++;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* if bits_left == 8, opb_index has already been incremented */
|
|
||||||
if ((bits_left == 8) && (opb_index > len))
|
|
||||||
{
|
|
||||||
/* compressed data longer than uncompressed data */
|
|
||||||
/* give up */
|
|
||||||
enc->historyOffset = 0;
|
|
||||||
g_memset(hash_table, 0, enc->buf_len * 2);
|
|
||||||
g_memset(enc->historyBuffer, 0, enc->buf_len);
|
|
||||||
enc->flagsHold |= PACKET_FLUSHED;
|
|
||||||
enc->first_pkt = 1;
|
|
||||||
|
|
||||||
g_memcpy(enc->outputBuffer, srcData, len);
|
|
||||||
enc->bytes_in_opb = len;
|
|
||||||
enc->flags = 0x81;
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
else if (opb_index + 1 > len)
|
|
||||||
{
|
|
||||||
/* compressed data longer than uncompressed data */
|
|
||||||
/* give up */
|
|
||||||
enc->historyOffset = 0;
|
|
||||||
g_memset(hash_table, 0, enc->buf_len * 2);
|
|
||||||
g_memset(enc->historyBuffer, 0, enc->buf_len);
|
|
||||||
enc->flagsHold |= PACKET_FLUSHED;
|
|
||||||
enc->first_pkt = 1;
|
|
||||||
|
|
||||||
g_memcpy(enc->outputBuffer, srcData, len);
|
|
||||||
enc->bytes_in_opb = len;
|
|
||||||
enc->flags = 0x81;
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* if bits_left != 8, increment opb_index, which is zero indexed */
|
/* if bits_left != 8, increment opb_index, which is zero indexed */
|
||||||
if (bits_left != 8)
|
if (bits_left != 8)
|
||||||
{
|
{
|
||||||
@ -1012,24 +971,21 @@ compress_rdp_5(struct xrdp_mppc_enc *enc, tui8 *srcData, int len)
|
|||||||
|
|
||||||
if (opb_index > len)
|
if (opb_index > len)
|
||||||
{
|
{
|
||||||
|
/* compressed data longer than uncompressed data */
|
||||||
/* 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);
|
g_memset(enc->historyBuffer, 0, enc->buf_len);
|
||||||
enc->flagsHold |= PACKET_FLUSHED;
|
enc->flagsHold |= PACKET_AT_FRONT | PACKET_FLUSHED;
|
||||||
enc->first_pkt = 1;
|
return 0;
|
||||||
|
|
||||||
g_memcpy(enc->outputBuffer, srcData, len);
|
|
||||||
enc->bytes_in_opb = len;
|
|
||||||
enc->flags = 0x81;
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
enc->flags |= PACKET_COMPRESSED;
|
enc->flags |= PACKET_COMPRESSED;
|
||||||
enc->bytes_in_opb = opb_index;
|
enc->bytes_in_opb = opb_index;
|
||||||
|
|
||||||
enc->flags |= enc->flagsHold;
|
enc->flags |= enc->flagsHold;
|
||||||
enc->flagsHold = 0;
|
enc->flagsHold = 0;
|
||||||
|
|
||||||
DLOG(("\n"));
|
DLOG(("\n"));
|
||||||
|
|
||||||
//g_writeln("compression ratio: %f", (float) len / (float) enc->bytes_in_opb);
|
//g_writeln("compression ratio: %f", (float) len / (float) enc->bytes_in_opb);
|
||||||
|
@ -482,7 +482,9 @@ xrdp_rdp_send_data(struct xrdp_rdp *self, struct stream *s,
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
g_writeln("mppc_encode not ok: type %d flags %d", mppc_enc->protocol_type, mppc_enc->flags);
|
LLOGLN(10, ("xrdp_rdp_send_data: mppc_encode not ok "
|
||||||
|
"type %d flags %d", mppc_enc->protocol_type,
|
||||||
|
mppc_enc->flags));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user