2
* FreeRDP: A Remote Desktop Protocol Implementation
3
* Implements Microsoft Point to Point Compression (MPPC) protocol
5
* Copyright 2012 Laxmikant Rashinkar <LK.Rashinkar@gmail.com>
6
* Copyright 2012 Jay Sorg <jay.sorg@gmail.com>
8
* Licensed under the Apache License, Version 2.0 (the "License");
9
* you may not use this file except in compliance with the License.
10
* You may obtain a copy of the License at
12
* http://www.apache.org/licenses/LICENSE-2.0
14
* Unless required by applicable law or agreed to in writing, software
15
* distributed under the License is distributed on an "AS IS" BASIS,
16
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
* See the License for the specific language governing permissions and
18
* limitations under the License.
29
#include <winpr/crt.h>
31
#include <freerdp/codec/mppc_dec.h>
32
#include <freerdp/codec/mppc_enc.h>
34
#define MPPC_ENC_DEBUG 0
38
#define RDP_40_HIST_BUF_LEN (1024 * 8) /* RDP 4.0 uses 8K history buf */
39
#define RDP_50_HIST_BUF_LEN (1024 * 64) /* RDP 5.0 uses 64K history buf */
41
#define CRC_INIT 0xFFFF
42
#define CRC(crcval, newchar) crcval = (crcval >> 8) ^ crc_table[(crcval ^ newchar) & 0x00ff]
45
static const UINT16 crc_table[256] =
47
0x0000, 0x1189, 0x2312, 0x329b, 0x4624, 0x57ad, 0x6536, 0x74bf,
48
0x8c48, 0x9dc1, 0xaf5a, 0xbed3, 0xca6c, 0xdbe5, 0xe97e, 0xf8f7,
49
0x1081, 0x0108, 0x3393, 0x221a, 0x56a5, 0x472c, 0x75b7, 0x643e,
50
0x9cc9, 0x8d40, 0xbfdb, 0xae52, 0xdaed, 0xcb64, 0xf9ff, 0xe876,
51
0x2102, 0x308b, 0x0210, 0x1399, 0x6726, 0x76af, 0x4434, 0x55bd,
52
0xad4a, 0xbcc3, 0x8e58, 0x9fd1, 0xeb6e, 0xfae7, 0xc87c, 0xd9f5,
53
0x3183, 0x200a, 0x1291, 0x0318, 0x77a7, 0x662e, 0x54b5, 0x453c,
54
0xbdcb, 0xac42, 0x9ed9, 0x8f50, 0xfbef, 0xea66, 0xd8fd, 0xc974,
55
0x4204, 0x538d, 0x6116, 0x709f, 0x0420, 0x15a9, 0x2732, 0x36bb,
56
0xce4c, 0xdfc5, 0xed5e, 0xfcd7, 0x8868, 0x99e1, 0xab7a, 0xbaf3,
57
0x5285, 0x430c, 0x7197, 0x601e, 0x14a1, 0x0528, 0x37b3, 0x263a,
58
0xdecd, 0xcf44, 0xfddf, 0xec56, 0x98e9, 0x8960, 0xbbfb, 0xaa72,
59
0x6306, 0x728f, 0x4014, 0x519d, 0x2522, 0x34ab, 0x0630, 0x17b9,
60
0xef4e, 0xfec7, 0xcc5c, 0xddd5, 0xa96a, 0xb8e3, 0x8a78, 0x9bf1,
61
0x7387, 0x620e, 0x5095, 0x411c, 0x35a3, 0x242a, 0x16b1, 0x0738,
62
0xffcf, 0xee46, 0xdcdd, 0xcd54, 0xb9eb, 0xa862, 0x9af9, 0x8b70,
63
0x8408, 0x9581, 0xa71a, 0xb693, 0xc22c, 0xd3a5, 0xe13e, 0xf0b7,
64
0x0840, 0x19c9, 0x2b52, 0x3adb, 0x4e64, 0x5fed, 0x6d76, 0x7cff,
65
0x9489, 0x8500, 0xb79b, 0xa612, 0xd2ad, 0xc324, 0xf1bf, 0xe036,
66
0x18c1, 0x0948, 0x3bd3, 0x2a5a, 0x5ee5, 0x4f6c, 0x7df7, 0x6c7e,
67
0xa50a, 0xb483, 0x8618, 0x9791, 0xe32e, 0xf2a7, 0xc03c, 0xd1b5,
68
0x2942, 0x38cb, 0x0a50, 0x1bd9, 0x6f66, 0x7eef, 0x4c74, 0x5dfd,
69
0xb58b, 0xa402, 0x9699, 0x8710, 0xf3af, 0xe226, 0xd0bd, 0xc134,
70
0x39c3, 0x284a, 0x1ad1, 0x0b58, 0x7fe7, 0x6e6e, 0x5cf5, 0x4d7c,
71
0xc60c, 0xd785, 0xe51e, 0xf497, 0x8028, 0x91a1, 0xa33a, 0xb2b3,
72
0x4a44, 0x5bcd, 0x6956, 0x78df, 0x0c60, 0x1de9, 0x2f72, 0x3efb,
73
0xd68d, 0xc704, 0xf59f, 0xe416, 0x90a9, 0x8120, 0xb3bb, 0xa232,
74
0x5ac5, 0x4b4c, 0x79d7, 0x685e, 0x1ce1, 0x0d68, 0x3ff3, 0x2e7a,
75
0xe70e, 0xf687, 0xc41c, 0xd595, 0xa12a, 0xb0a3, 0x8238, 0x93b1,
76
0x6b46, 0x7acf, 0x4854, 0x59dd, 0x2d62, 0x3ceb, 0x0e70, 0x1ff9,
77
0xf78f, 0xe606, 0xd49d, 0xc514, 0xb1ab, 0xa022, 0x92b9, 0x8330,
78
0x7bc7, 0x6a4e, 0x58d5, 0x495c, 0x3de3, 0x2c6a, 0x1ef1, 0x0f78
81
/*****************************************************************************
82
insert 2 bits into outputBuffer
83
******************************************************************************/
84
#define insert_2_bits(_data) \
87
if ((bits_left >= 3) && (bits_left <= 8)) \
90
outputBuffer[opb_index] |= _data << i; \
97
outputBuffer[opb_index++] |= _data >> i; \
98
outputBuffer[opb_index] |= _data << j; \
103
/*****************************************************************************
104
insert 3 bits into outputBuffer
105
******************************************************************************/
106
#define insert_3_bits(_data) \
109
if ((bits_left >= 4) && (bits_left <= 8)) \
112
outputBuffer[opb_index] |= _data << i; \
119
outputBuffer[opb_index++] |= _data >> i; \
120
outputBuffer[opb_index] |= _data << j; \
125
/*****************************************************************************
126
insert 4 bits into outputBuffer
127
******************************************************************************/
128
#define insert_4_bits(_data) \
131
if ((bits_left >= 5) && (bits_left <= 8)) \
134
outputBuffer[opb_index] |= _data << i; \
141
outputBuffer[opb_index++] |= _data >> i; \
142
outputBuffer[opb_index] |= _data << j; \
147
/*****************************************************************************
148
insert 5 bits into outputBuffer
149
******************************************************************************/
150
#define insert_5_bits(_data) \
153
if ((bits_left >= 6) && (bits_left <= 8)) \
156
outputBuffer[opb_index] |= _data << i; \
163
outputBuffer[opb_index++] |= _data >> i; \
164
outputBuffer[opb_index] |= _data << j; \
169
/*****************************************************************************
170
insert 6 bits into outputBuffer
171
******************************************************************************/
172
#define insert_6_bits(_data) \
175
if ((bits_left >= 7) && (bits_left <= 8)) \
178
outputBuffer[opb_index] |= (_data << i); \
185
outputBuffer[opb_index++] |= (_data >> i); \
186
outputBuffer[opb_index] |= (_data << j); \
191
/*****************************************************************************
192
insert 7 bits into outputBuffer
193
******************************************************************************/
194
#define insert_7_bits(_data) \
197
if (bits_left == 8) \
199
outputBuffer[opb_index] |= _data << 1; \
206
outputBuffer[opb_index++] |= _data >> i; \
207
outputBuffer[opb_index] |= _data << j; \
212
/*****************************************************************************
213
insert 8 bits into outputBuffer
214
******************************************************************************/
215
#define insert_8_bits(_data) \
218
if (bits_left == 8) \
220
outputBuffer[opb_index++] |= _data; \
227
outputBuffer[opb_index++] |= _data >> i; \
228
outputBuffer[opb_index] |= _data << j; \
233
/*****************************************************************************
234
insert 9 bits into outputBuffer
235
******************************************************************************/
236
#define insert_9_bits(_data16) \
241
outputBuffer[opb_index++] |= (char) (_data16 >> i); \
242
outputBuffer[opb_index] |= (char) (_data16 << j); \
244
if (bits_left == 0) \
251
/*****************************************************************************
252
insert 10 bits into outputBuffer
253
******************************************************************************/
254
#define insert_10_bits(_data16) \
257
i = 10 - bits_left; \
258
if ((bits_left >= 3) && (bits_left <= 8)) \
261
outputBuffer[opb_index++] |= (char) (_data16 >> i); \
262
outputBuffer[opb_index] |= (char) (_data16 << j); \
269
outputBuffer[opb_index++] |= (char) (_data16 >> i); \
270
outputBuffer[opb_index++] |= (char) (_data16 >> j); \
271
outputBuffer[opb_index] |= (char) (_data16 << k); \
276
/*****************************************************************************
277
insert 11 bits into outputBuffer
278
******************************************************************************/
279
#define insert_11_bits(_data16) \
282
i = 11 - bits_left; \
283
if ((bits_left >= 4) && (bits_left <= 8)) \
286
outputBuffer[opb_index++] |= (char) (_data16 >> i); \
287
outputBuffer[opb_index] |= (char) (_data16 << j); \
294
outputBuffer[opb_index++] |= (char) (_data16 >> i); \
295
outputBuffer[opb_index++] |= (char) (_data16 >> j); \
296
outputBuffer[opb_index] |= (char) (_data16 << k); \
301
/*****************************************************************************
302
insert 12 bits into outputBuffer
303
******************************************************************************/
304
#define insert_12_bits(_data16) \
307
i = 12 - bits_left; \
308
if ((bits_left >= 5) && (bits_left <= 8)) \
311
outputBuffer[opb_index++] |= (char) (_data16 >> i); \
312
outputBuffer[opb_index] |= (char) (_data16 << j); \
319
outputBuffer[opb_index++] |= (char) (_data16 >> i); \
320
outputBuffer[opb_index++] |= (char) (_data16 >> j); \
321
outputBuffer[opb_index] |= (char) (_data16 << k); \
326
/*****************************************************************************
327
insert 13 bits into outputBuffer
328
******************************************************************************/
329
#define insert_13_bits(_data16) \
332
i = 13 - bits_left; \
333
if ((bits_left >= 6) && (bits_left <= 8)) \
336
outputBuffer[opb_index++] |= (char) (_data16 >> i); \
337
outputBuffer[opb_index] |= (char) (_data16 << j); \
344
outputBuffer[opb_index++] |= (char) (_data16 >> i); \
345
outputBuffer[opb_index++] |= (char) (_data16 >> j); \
346
outputBuffer[opb_index] |= (char) (_data16 << k); \
351
/*****************************************************************************
352
insert 14 bits into outputBuffer
353
******************************************************************************/
354
#define insert_14_bits(_data16) \
357
i = 14 - bits_left; \
358
if ((bits_left >= 7) && (bits_left <= 8)) \
361
outputBuffer[opb_index++] |= (char) (_data16 >> i); \
362
outputBuffer[opb_index] |= (char) (_data16 << j); \
369
outputBuffer[opb_index++] |= (char) (_data16 >> i); \
370
outputBuffer[opb_index++] |= (char) (_data16 >> j); \
371
outputBuffer[opb_index] |= (char) (_data16 << k); \
376
/*****************************************************************************
377
insert 15 bits into outputBuffer
378
******************************************************************************/
379
#define insert_15_bits(_data16) \
382
i = 15 - bits_left; \
383
if (bits_left == 8) \
386
outputBuffer[opb_index++] |= (char) (_data16 >> i); \
387
outputBuffer[opb_index] |= (char) (_data16 << j); \
394
outputBuffer[opb_index++] |= (char) (_data16 >> i); \
395
outputBuffer[opb_index++] |= (char) (_data16 >> j); \
396
outputBuffer[opb_index] |= (char) (_data16 << k); \
401
/*****************************************************************************
402
insert 16 bits into outputBuffer
403
******************************************************************************/
404
#define insert_16_bits(_data16) \
407
i = 16 - bits_left; \
410
outputBuffer[opb_index++] |= (char) (_data16 >> i); \
411
outputBuffer[opb_index++] |= (char) (_data16 >> j); \
412
outputBuffer[opb_index] |= (char) (_data16 << k); \
417
#define DLOG(_args) printf _args
419
#define DLOG(_args) do { } while (0)
423
* Initialize mppc_enc structure
425
* @param protocol_type PROTO_RDP_40 or PROTO_RDP_50
427
* @return struct rdp_mppc_enc* or nil on failure
430
struct rdp_mppc_enc* mppc_enc_new(int protocol_type)
432
struct rdp_mppc_enc* enc;
434
enc = (struct rdp_mppc_enc*) malloc(sizeof(struct rdp_mppc_enc));
435
ZeroMemory(enc, sizeof(struct rdp_mppc_enc));
440
switch (protocol_type)
443
enc->protocol_type = PROTO_RDP_40;
444
enc->buf_len = RDP_40_HIST_BUF_LEN;
448
enc->protocol_type = PROTO_RDP_50;
449
enc->buf_len = RDP_50_HIST_BUF_LEN;
458
enc->historyBuffer = (char*) malloc(enc->buf_len);
459
ZeroMemory(enc->historyBuffer, enc->buf_len);
461
if (enc->historyBuffer == NULL)
467
enc->outputBufferPlus = (char*) malloc(enc->buf_len + 64);
468
ZeroMemory(enc->outputBufferPlus, enc->buf_len + 64);
470
if (enc->outputBufferPlus == NULL)
472
free(enc->historyBuffer);
477
enc->outputBuffer = enc->outputBufferPlus + 64;
478
enc->hash_table = (UINT16*) malloc(enc->buf_len * 2);
479
ZeroMemory(enc->hash_table, enc->buf_len * 2);
481
if (enc->hash_table == NULL)
483
free(enc->historyBuffer);
484
free(enc->outputBufferPlus);
493
* deinit mppc_enc structure
495
* @param enc struct to be deinited
498
void mppc_enc_free(struct rdp_mppc_enc* enc)
502
free(enc->historyBuffer);
503
free(enc->outputBufferPlus);
504
free(enc->hash_table);
509
* encode (compress) data
511
* @param enc encoder state info
512
* @param srcData uncompressed data
513
* @param len length of srcData
515
* @return TRUE on success, FALSE on failure
518
BOOL compress_rdp(struct rdp_mppc_enc* enc, BYTE* srcData, int len)
520
if ((enc == NULL) || (srcData == NULL) || (len <= 0) || (len > enc->buf_len))
523
switch (enc->protocol_type)
526
return compress_rdp_4(enc, srcData, len);
530
return compress_rdp_5(enc, srcData, len);
538
* encode (compress) data using RDP 4.0 protocol
540
* @param enc encoder state info
541
* @param srcData uncompressed data
542
* @param len length of srcData
544
* @return TRUE on success, FALSE on failure
547
BOOL compress_rdp_4(struct rdp_mppc_enc* enc, BYTE* srcData, int len)
549
/* RDP 4.0 encoding not yet implemented */
554
* encode (compress) data using RDP 5.0 protocol using hash table
556
* @param enc encoder state info
557
* @param srcData uncompressed data
558
* @param len length of srcData
560
* @return TRUE on success, FALSE on failure
563
BOOL compress_rdp_5(struct rdp_mppc_enc* enc, BYTE* srcData, int len)
565
char* outputBuffer; /* points to enc->outputBuffer */
566
char* hptr_end; /* points to end of history data */
567
char* historyPointer; /* points to first byte of srcData in historyBuffer */
568
char* hbuf_start; /* points to start of history buffer */
571
int opb_index; /* index into outputBuffer */
572
int bits_left; /* unused bits in current byte in outputBuffer */
573
UINT32 copy_offset; /* pattern match starts here... */
574
UINT32 lom; /* ...and matches this many bytes */
575
int last_crc_index; /* don't compute CRC beyond this index */
576
UINT16 *hash_table; /* hash table for pattern matching */
584
UINT32 historyOffset;
595
hash_table = enc->hash_table;
596
hbuf_start = enc->historyBuffer;
597
outputBuffer = enc->outputBuffer;
598
memset(outputBuffer, 0, len);
599
enc->flags = PACKET_COMPR_TYPE_64K;
603
enc->flagsHold |= PACKET_AT_FRONT;
606
if ((enc->historyOffset + len) > enc->buf_len)
608
/* historyBuffer cannot hold srcData - rewind it */
609
enc->historyOffset = 0;
610
enc->flagsHold |= PACKET_AT_FRONT;
611
memset(hash_table, 0, enc->buf_len * 2);
614
/* point to next free byte in historyBuffer */
615
historyOffset = enc->historyOffset;
617
/* add / append new data to historyBuffer */
618
memcpy(&(enc->historyBuffer[historyOffset]), srcData, len);
620
/* point to start of data to be compressed */
621
historyPointer = &(enc->historyBuffer[historyOffset]);
623
ctr = copy_offset = lom = 0;
625
/* if we are at start of history buffer, do not attempt to compress */
626
/* first 2 bytes,because minimum LoM is 3 */
627
if (historyOffset == 0)
629
/* encode first two bytes are literals */
630
for (x = 0; x < 2; x++)
632
data = *(historyPointer + x);
633
DLOG(("%.2x ", (unsigned char) data));
636
/* insert encoded literal */
648
/* store hash for first two entries in historyBuffer */
650
byte_val = enc->historyBuffer[0];
652
byte_val = enc->historyBuffer[1];
654
byte_val = enc->historyBuffer[2];
659
byte_val = enc->historyBuffer[1];
661
byte_val = enc->historyBuffer[2];
663
byte_val = enc->historyBuffer[3];
667
/* first two bytes have already been processed */
671
enc->historyOffset += len;
673
/* point to last byte in new data */
674
hptr_end = &(enc->historyBuffer[enc->historyOffset - 1]);
676
/* do not compute CRC beyond this */
677
last_crc_index = enc->historyOffset - 3;
679
/* do not search for pattern match beyond this */
682
/* start compressing data */
684
while (ctr < data_end)
686
cptr1 = historyPointer + ctr;
691
byte_val = *(cptr1 + 1);
693
byte_val = *(cptr1 + 2);
696
/* cptr2 points to start of pattern match */
697
cptr2 = hbuf_start + hash_table[crc];
698
copy_offset = cptr1 - cptr2;
700
/* save current entry */
701
hash_table[crc] = cptr1 - hbuf_start;
703
/* double check that we have a pattern match */
704
if ((*cptr1 != *cptr2) ||
705
(*(cptr1 + 1) != *(cptr2 + 1)) ||
706
(*(cptr1 + 2) != *(cptr2 + 2)))
708
/* no match found; encode literal byte */
711
DLOG(("%.2x ", (unsigned char) data));
714
/* literal byte < 0x80 */
719
/* literal byte >= 0x80 */
728
/* we have a match - compute Length of Match */
732
while ((cptr1 <= hptr_end) && (*(cptr1++) == *(cptr2++)))
736
saved_ctr = ctr + lom;
737
DLOG(("<%d: %ld,%d> ", (historyPointer + ctr) - hbuf_start, copy_offset, lom));
739
/* compute CRC for matching segment and store in hash table */
741
cptr1 = historyPointer + ctr;
742
if (cptr1 + lom > hbuf_start + last_crc_index)
744
/* we have gone beyond last_crc_index - go back */
745
j = last_crc_index - (cptr1 - hbuf_start);
752
for (i = 0; i < j; i++)
754
cptr1 = historyPointer + ctr;
756
/* compute CRC on triplet */
758
byte_val = *(cptr1++);
760
byte_val = *(cptr1++);
762
byte_val = *(cptr1++);
765
/* save current entry */
766
hash_table[crc] = (cptr1 - 3) - hbuf_start;
768
/* point to next triplet */
773
/* encode copy_offset and insert into output buffer */
775
if (copy_offset <= 63) /* (copy_offset >= 0) is always true */
777
/* insert binary header */
781
/* insert 6 bits of copy_offset */
782
data = (char) (copy_offset & 0x3f);
785
else if ((copy_offset >= 64) && (copy_offset <= 319))
787
/* insert binary header */
791
/* insert 8 bits of copy offset */
792
data = (char) (copy_offset - 64);
795
else if ((copy_offset >= 320) && (copy_offset <= 2367))
797
/* insert binary header */
801
/* insert 11 bits of copy offset */
802
data16 = copy_offset - 320;;
803
insert_11_bits(data16);
807
/* copy_offset is 2368+ */
809
/* insert binary header */
813
/* insert 16 bits of copy offset */
814
data16 = copy_offset - 2368;;
815
insert_16_bits(data16);
818
/* encode length of match and insert into output buffer */
822
/* binary header is 'zero'; since outputBuffer is zero */
823
/* filled, all we have to do is update bits_left */
831
else if ((lom >= 4) && (lom <= 7))
833
/* insert binary header */
837
/* insert lower 2 bits of LoM */
838
data = (char) (lom - 4);
841
else if ((lom >= 8) && (lom <= 15))
843
/* insert binary header */
847
/* insert lower 3 bits of LoM */
848
data = (char) (lom - 8);
851
else if ((lom >= 16) && (lom <= 31))
853
/* insert binary header */
857
/* insert lower 4 bits of LoM */
858
data = (char) (lom - 16);
861
else if ((lom >= 32) && (lom <= 63))
863
/* insert binary header */
867
/* insert lower 5 bits of LoM */
868
data = (char) (lom - 32);
871
else if ((lom >= 64) && (lom <= 127))
873
/* insert binary header */
877
/* insert lower 6 bits of LoM */
878
data = (char) (lom - 64);
881
else if ((lom >= 128) && (lom <= 255))
883
/* insert binary header */
887
/* insert lower 7 bits of LoM */
888
data = (char) (lom - 128);
891
else if ((lom >= 256) && (lom <= 511))
893
/* insert binary header */
897
/* insert lower 8 bits of LoM */
898
data = (char) (lom - 256);
901
else if ((lom >= 512) && (lom <= 1023))
903
/* insert binary header */
905
insert_9_bits(data16);
907
/* insert lower 9 bits of LoM */
909
insert_9_bits(data16);
911
else if ((lom >= 1024) && (lom <= 2047))
913
/* insert binary header */
915
insert_10_bits(data16);
917
/* insert 10 lower bits of LoM */
919
insert_10_bits(data16);
921
else if ((lom >= 2048) && (lom <= 4095))
923
/* insert binary header */
925
insert_11_bits(data16);
927
/* insert 11 lower bits of LoM */
929
insert_11_bits(data16);
931
else if ((lom >= 4096) && (lom <= 8191))
933
/* insert binary header */
935
insert_12_bits(data16);
937
/* insert 12 lower bits of LoM */
939
insert_12_bits(data16);
941
else if ((lom >= 8192) && (lom <= 16383))
943
/* insert binary header */
945
insert_13_bits(data16);
947
/* insert 13 lower bits of LoM */
949
insert_13_bits(data16);
951
else if ((lom >= 16384) && (lom <= 32767))
953
/* insert binary header */
955
insert_14_bits(data16);
957
/* insert 14 lower bits of LoM */
958
data16 = lom - 16384;
959
insert_14_bits(data16);
961
else if ((lom >= 32768) && (lom <= 65535))
963
/* insert binary header */
965
insert_15_bits(data16);
967
/* insert 15 lower bits of LoM */
968
data16 = lom - 32768;
969
insert_15_bits(data16);
971
} /* end while (ctr < data_end) */
973
/* add remaining data to the output */
974
while (len - ctr > 0)
977
DLOG(("%.2x ", (unsigned char) data));
980
/* literal byte < 0x80 */
985
/* literal byte >= 0x80 */
993
/* if bits_left == 8, opb_index has already been incremented */
994
if ((bits_left == 8) && (opb_index > len))
996
/* compressed data longer than uncompressed data */
998
enc->historyOffset = 0;
999
memset(hash_table, 0, enc->buf_len * 2);
1000
enc->flagsHold |= PACKET_FLUSHED;
1004
else if (opb_index + 1 > len)
1006
/* compressed data longer than uncompressed data */
1008
enc->historyOffset = 0;
1009
memset(hash_table, 0, enc->buf_len * 2);
1010
enc->flagsHold |= PACKET_FLUSHED;
1015
/* if bits_left != 8, increment opb_index, which is zero indexed */
1021
if (opb_index > len)
1024
enc->historyOffset = 0;
1025
memset(hash_table, 0, enc->buf_len * 2);
1026
enc->flagsHold |= PACKET_FLUSHED;
1030
enc->flags |= PACKET_COMPRESSED;
1031
enc->bytes_in_opb = opb_index;
1033
enc->flags |= enc->flagsHold;