Lines Matching +full:64 +full:- +full:byte
2 * LZ4 HC - High Compression Mode of LZ4
3 * Copyright (C) 2011-2015, Yann Collet.
5 * BSD 2 - Clause License (http://www.opensource.org/licenses/bsd - license.php)
27 * - LZ4 homepage : http://www.lz4.org
28 * - LZ4 source repository : https://github.com/lz4/lz4
31 * Sven Schmidt <4sschmid@informatik.uni-hamburg.de>
34 /*-************************************
47 #define OPTIMAL_ML (int)((ML_MASK - 1) + MINMATCH)
50 >> ((MINMATCH*8) - LZ4HC_HASH_LOG))
61 static void LZ4HC_init(LZ4HC_CCtx_internal *hc4, const BYTE *start) in LZ4HC_init()
63 memset((void *)hc4->hashTable, 0, sizeof(hc4->hashTable)); in LZ4HC_init()
64 memset(hc4->chainTable, 0xFF, sizeof(hc4->chainTable)); in LZ4HC_init()
65 hc4->nextToUpdate = 64 * KB; in LZ4HC_init()
66 hc4->base = start - 64 * KB; in LZ4HC_init()
67 hc4->end = start; in LZ4HC_init()
68 hc4->dictBase = start - 64 * KB; in LZ4HC_init()
69 hc4->dictLimit = 64 * KB; in LZ4HC_init()
70 hc4->lowLimit = 64 * KB; in LZ4HC_init()
75 const BYTE *ip) in LZ4HC_Insert()
77 U16 * const chainTable = hc4->chainTable; in LZ4HC_Insert()
78 U32 * const hashTable = hc4->hashTable; in LZ4HC_Insert()
79 const BYTE * const base = hc4->base; in LZ4HC_Insert()
80 U32 const target = (U32)(ip - base); in LZ4HC_Insert()
81 U32 idx = hc4->nextToUpdate; in LZ4HC_Insert()
85 size_t delta = idx - hashTable[h]; in LZ4HC_Insert()
96 hc4->nextToUpdate = target; in LZ4HC_Insert()
101 const BYTE *ip, in LZ4HC_InsertAndFindBestMatch()
102 const BYTE * const iLimit, in LZ4HC_InsertAndFindBestMatch()
103 const BYTE **matchpos, in LZ4HC_InsertAndFindBestMatch()
106 U16 * const chainTable = hc4->chainTable; in LZ4HC_InsertAndFindBestMatch()
107 U32 * const HashTable = hc4->hashTable; in LZ4HC_InsertAndFindBestMatch()
108 const BYTE * const base = hc4->base; in LZ4HC_InsertAndFindBestMatch()
109 const BYTE * const dictBase = hc4->dictBase; in LZ4HC_InsertAndFindBestMatch()
110 const U32 dictLimit = hc4->dictLimit; in LZ4HC_InsertAndFindBestMatch()
111 const U32 lowLimit = (hc4->lowLimit + 64 * KB > (U32)(ip - base)) in LZ4HC_InsertAndFindBestMatch()
112 ? hc4->lowLimit in LZ4HC_InsertAndFindBestMatch()
113 : (U32)(ip - base) - (64 * KB - 1); in LZ4HC_InsertAndFindBestMatch()
124 nbAttempts--; in LZ4HC_InsertAndFindBestMatch()
126 const BYTE * const match = base + matchIndex; in LZ4HC_InsertAndFindBestMatch()
139 const BYTE * const match = dictBase + matchIndex; in LZ4HC_InsertAndFindBestMatch()
143 const BYTE *vLimit = ip in LZ4HC_InsertAndFindBestMatch()
144 + (dictLimit - matchIndex); in LZ4HC_InsertAndFindBestMatch()
162 matchIndex -= DELTANEXTU16(matchIndex); in LZ4HC_InsertAndFindBestMatch()
170 const BYTE * const ip, in LZ4HC_InsertAndGetWiderMatch()
171 const BYTE * const iLowLimit, in LZ4HC_InsertAndGetWiderMatch()
172 const BYTE * const iHighLimit, in LZ4HC_InsertAndGetWiderMatch()
174 const BYTE **matchpos, in LZ4HC_InsertAndGetWiderMatch()
175 const BYTE **startpos, in LZ4HC_InsertAndGetWiderMatch()
178 U16 * const chainTable = hc4->chainTable; in LZ4HC_InsertAndGetWiderMatch()
179 U32 * const HashTable = hc4->hashTable; in LZ4HC_InsertAndGetWiderMatch()
180 const BYTE * const base = hc4->base; in LZ4HC_InsertAndGetWiderMatch()
181 const U32 dictLimit = hc4->dictLimit; in LZ4HC_InsertAndGetWiderMatch()
182 const BYTE * const lowPrefixPtr = base + dictLimit; in LZ4HC_InsertAndGetWiderMatch()
183 const U32 lowLimit = (hc4->lowLimit + 64 * KB > (U32)(ip - base)) in LZ4HC_InsertAndGetWiderMatch()
184 ? hc4->lowLimit in LZ4HC_InsertAndGetWiderMatch()
185 : (U32)(ip - base) - (64 * KB - 1); in LZ4HC_InsertAndGetWiderMatch()
186 const BYTE * const dictBase = hc4->dictBase; in LZ4HC_InsertAndGetWiderMatch()
189 int delta = (int)(ip - iLowLimit); in LZ4HC_InsertAndGetWiderMatch()
197 nbAttempts--; in LZ4HC_InsertAndGetWiderMatch()
199 const BYTE *matchPtr = base + matchIndex; in LZ4HC_InsertAndGetWiderMatch()
202 == *(matchPtr - delta + longest)) { in LZ4HC_InsertAndGetWiderMatch()
212 && (ip[back - 1] == matchPtr[back - 1])) in LZ4HC_InsertAndGetWiderMatch()
213 back--; in LZ4HC_InsertAndGetWiderMatch()
215 mlt -= back; in LZ4HC_InsertAndGetWiderMatch()
225 const BYTE * const matchPtr = dictBase + matchIndex; in LZ4HC_InsertAndGetWiderMatch()
230 const BYTE *vLimit = ip + (dictLimit - matchIndex); in LZ4HC_InsertAndGetWiderMatch()
243 && (ip[back - 1] == matchPtr[back - 1])) in LZ4HC_InsertAndGetWiderMatch()
244 back--; in LZ4HC_InsertAndGetWiderMatch()
246 mlt -= back; in LZ4HC_InsertAndGetWiderMatch()
256 matchIndex -= DELTANEXTU16(matchIndex); in LZ4HC_InsertAndGetWiderMatch()
263 const BYTE **ip, in LZ4HC_encodeSequence()
264 BYTE **op, in LZ4HC_encodeSequence()
265 const BYTE **anchor, in LZ4HC_encodeSequence()
267 const BYTE * const match, in LZ4HC_encodeSequence()
269 BYTE *oend) in LZ4HC_encodeSequence()
272 BYTE *token; in LZ4HC_encodeSequence()
275 length = (int)(*ip - *anchor); in LZ4HC_encodeSequence()
288 len = length - RUN_MASK; in LZ4HC_encodeSequence()
289 for (; len > 254 ; len -= 255) in LZ4HC_encodeSequence()
291 *(*op)++ = (BYTE)len; in LZ4HC_encodeSequence()
293 *token = (BYTE)(length<<ML_BITS); in LZ4HC_encodeSequence()
300 LZ4_writeLE16(*op, (U16)(*ip - match)); in LZ4HC_encodeSequence()
304 length = (int)(matchLength - MINMATCH); in LZ4HC_encodeSequence()
315 length -= ML_MASK; in LZ4HC_encodeSequence()
317 for (; length > 509 ; length -= 510) { in LZ4HC_encodeSequence()
323 length -= 255; in LZ4HC_encodeSequence()
327 *(*op)++ = (BYTE)length; in LZ4HC_encodeSequence()
329 *token += (BYTE)(length); in LZ4HC_encodeSequence()
348 const BYTE *ip = (const BYTE *) source; in LZ4HC_compress_generic()
349 const BYTE *anchor = ip; in LZ4HC_compress_generic()
350 const BYTE * const iend = ip + inputSize; in LZ4HC_compress_generic()
351 const BYTE * const mflimit = iend - MFLIMIT; in LZ4HC_compress_generic()
352 const BYTE * const matchlimit = (iend - LASTLITERALS); in LZ4HC_compress_generic()
354 BYTE *op = (BYTE *) dest; in LZ4HC_compress_generic()
355 BYTE * const oend = op + maxOutputSize; in LZ4HC_compress_generic()
359 const BYTE *ref = NULL; in LZ4HC_compress_generic()
360 const BYTE *start2 = NULL; in LZ4HC_compress_generic()
361 const BYTE *ref2 = NULL; in LZ4HC_compress_generic()
362 const BYTE *start3 = NULL; in LZ4HC_compress_generic()
363 const BYTE *ref3 = NULL; in LZ4HC_compress_generic()
364 const BYTE *start0; in LZ4HC_compress_generic()
365 const BYTE *ref0; in LZ4HC_compress_generic()
372 maxNbAttempts = 1 << (compressionLevel - 1); in LZ4HC_compress_generic()
373 ctx->end += inputSize; in LZ4HC_compress_generic()
394 ip + ml - 2, ip + 0, in LZ4HC_compress_generic()
418 if ((start2 - ip) < 3) { in LZ4HC_compress_generic()
432 if ((start2 - ip) < OPTIMAL_ML) { in LZ4HC_compress_generic()
438 if (ip + new_ml > start2 + ml2 - MINMATCH) in LZ4HC_compress_generic()
439 new_ml = (int)(start2 - ip) + ml2 - MINMATCH; in LZ4HC_compress_generic()
441 correction = new_ml - (int)(start2 - ip); in LZ4HC_compress_generic()
446 ml2 -= correction; in LZ4HC_compress_generic()
456 start2 + ml2 - 3, start2, in LZ4HC_compress_generic()
466 ml = (int)(start2 - ip); in LZ4HC_compress_generic()
486 int correction = (int)(ip + ml - start2); in LZ4HC_compress_generic()
490 ml2 -= correction; in LZ4HC_compress_generic()
523 if ((start2 - ip) < (int)ML_MASK) { in LZ4HC_compress_generic()
528 if (ip + ml > start2 + ml2 - MINMATCH) in LZ4HC_compress_generic()
529 ml = (int)(start2 - ip) + ml2 - MINMATCH; in LZ4HC_compress_generic()
530 correction = ml - (int)(start2 - ip); in LZ4HC_compress_generic()
534 ml2 -= correction; in LZ4HC_compress_generic()
537 ml = (int)(start2 - ip); in LZ4HC_compress_generic()
556 int lastRun = (int)(iend - anchor); in LZ4HC_compress_generic()
559 && (((char *)op - dest) + lastRun + 1 in LZ4HC_compress_generic()
560 + ((lastRun + 255 - RUN_MASK)/255) in LZ4HC_compress_generic()
567 lastRun -= RUN_MASK; in LZ4HC_compress_generic()
568 for (; lastRun > 254 ; lastRun -= 255) in LZ4HC_compress_generic()
570 *op++ = (BYTE) lastRun; in LZ4HC_compress_generic()
572 *op++ = (BYTE)(lastRun<<ML_BITS); in LZ4HC_compress_generic()
573 LZ4_memcpy(op, anchor, iend - anchor); in LZ4HC_compress_generic()
574 op += iend - anchor; in LZ4HC_compress_generic()
578 return (int) (((char *)op) - dest); in LZ4HC_compress_generic()
589 LZ4HC_CCtx_internal *ctx = &((LZ4_streamHC_t *)state)->internal_donotuse; in LZ4_compress_HC_extStateHC()
591 if (((size_t)(state)&(sizeof(void *) - 1)) != 0) { in LZ4_compress_HC_extStateHC()
593 * for pointers (32 or 64 bits) in LZ4_compress_HC_extStateHC()
598 LZ4HC_init(ctx, (const BYTE *)src); in LZ4_compress_HC_extStateHC()
621 LZ4_streamHCPtr->internal_donotuse.base = NULL; in LZ4_resetStreamHC()
622 LZ4_streamHCPtr->internal_donotuse.compressionLevel = (unsigned int)compressionLevel; in LZ4_resetStreamHC()
629 LZ4HC_CCtx_internal *ctxPtr = &LZ4_streamHCPtr->internal_donotuse; in LZ4_loadDictHC()
631 if (dictSize > 64 * KB) { in LZ4_loadDictHC()
632 dictionary += dictSize - 64 * KB; in LZ4_loadDictHC()
633 dictSize = 64 * KB; in LZ4_loadDictHC()
635 LZ4HC_init(ctxPtr, (const BYTE *)dictionary); in LZ4_loadDictHC()
637 LZ4HC_Insert(ctxPtr, (const BYTE *)dictionary + (dictSize - 3)); in LZ4_loadDictHC()
638 ctxPtr->end = (const BYTE *)dictionary + dictSize; in LZ4_loadDictHC()
647 const BYTE *newBlock) in LZ4HC_setExternalDict()
649 if (ctxPtr->end >= ctxPtr->base + 4) { in LZ4HC_setExternalDict()
651 LZ4HC_Insert(ctxPtr, ctxPtr->end - 3); in LZ4HC_setExternalDict()
658 ctxPtr->lowLimit = ctxPtr->dictLimit; in LZ4HC_setExternalDict()
659 ctxPtr->dictLimit = (U32)(ctxPtr->end - ctxPtr->base); in LZ4HC_setExternalDict()
660 ctxPtr->dictBase = ctxPtr->base; in LZ4HC_setExternalDict()
661 ctxPtr->base = newBlock - ctxPtr->dictLimit; in LZ4HC_setExternalDict()
662 ctxPtr->end = newBlock; in LZ4HC_setExternalDict()
664 ctxPtr->nextToUpdate = ctxPtr->dictLimit; in LZ4HC_setExternalDict()
675 LZ4HC_CCtx_internal *ctxPtr = &LZ4_streamHCPtr->internal_donotuse; in LZ4_compressHC_continue_generic()
677 /* auto - init if forgotten */ in LZ4_compressHC_continue_generic()
678 if (ctxPtr->base == NULL) in LZ4_compressHC_continue_generic()
679 LZ4HC_init(ctxPtr, (const BYTE *) source); in LZ4_compressHC_continue_generic()
682 if ((size_t)(ctxPtr->end - ctxPtr->base) > 2 * GB) { in LZ4_compressHC_continue_generic()
683 size_t dictSize = (size_t)(ctxPtr->end - ctxPtr->base) in LZ4_compressHC_continue_generic()
684 - ctxPtr->dictLimit; in LZ4_compressHC_continue_generic()
685 if (dictSize > 64 * KB) in LZ4_compressHC_continue_generic()
686 dictSize = 64 * KB; in LZ4_compressHC_continue_generic()
688 (const char *)(ctxPtr->end) - dictSize, (int)dictSize); in LZ4_compressHC_continue_generic()
692 if ((const BYTE *)source != ctxPtr->end) in LZ4_compressHC_continue_generic()
693 LZ4HC_setExternalDict(ctxPtr, (const BYTE *)source); in LZ4_compressHC_continue_generic()
697 const BYTE *sourceEnd = (const BYTE *) source + inputSize; in LZ4_compressHC_continue_generic()
698 const BYTE * const dictBegin = ctxPtr->dictBase + ctxPtr->lowLimit; in LZ4_compressHC_continue_generic()
699 const BYTE * const dictEnd = ctxPtr->dictBase + ctxPtr->dictLimit; in LZ4_compressHC_continue_generic()
702 && ((const BYTE *)source < dictEnd)) { in LZ4_compressHC_continue_generic()
705 ctxPtr->lowLimit = (U32)(sourceEnd - ctxPtr->dictBase); in LZ4_compressHC_continue_generic()
707 if (ctxPtr->dictLimit - ctxPtr->lowLimit < 4) in LZ4_compressHC_continue_generic()
708 ctxPtr->lowLimit = ctxPtr->dictLimit; in LZ4_compressHC_continue_generic()
713 inputSize, maxOutputSize, ctxPtr->compressionLevel, limit); in LZ4_compressHC_continue_generic()
739 LZ4HC_CCtx_internal *const streamPtr = &LZ4_streamHCPtr->internal_donotuse; in LZ4_saveDictHC()
740 int const prefixSize = (int)(streamPtr->end in LZ4_saveDictHC()
741 - (streamPtr->base + streamPtr->dictLimit)); in LZ4_saveDictHC()
743 if (dictSize > 64 * KB) in LZ4_saveDictHC()
744 dictSize = 64 * KB; in LZ4_saveDictHC()
750 memmove(safeBuffer, streamPtr->end - dictSize, dictSize); in LZ4_saveDictHC()
753 U32 const endIndex = (U32)(streamPtr->end - streamPtr->base); in LZ4_saveDictHC()
755 streamPtr->end = (const BYTE *)safeBuffer + dictSize; in LZ4_saveDictHC()
756 streamPtr->base = streamPtr->end - endIndex; in LZ4_saveDictHC()
757 streamPtr->dictLimit = endIndex - dictSize; in LZ4_saveDictHC()
758 streamPtr->lowLimit = endIndex - dictSize; in LZ4_saveDictHC()
760 if (streamPtr->nextToUpdate < streamPtr->dictLimit) in LZ4_saveDictHC()
761 streamPtr->nextToUpdate = streamPtr->dictLimit; in LZ4_saveDictHC()