Lines Matching +full:ref2 +full:-

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))
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()
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()
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()
144 + (dictLimit - matchIndex); in LZ4HC_InsertAndFindBestMatch()
162 matchIndex -= DELTANEXTU16(matchIndex); in LZ4HC_InsertAndFindBestMatch()
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()
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()
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()
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()
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()
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()
351 const BYTE * const mflimit = iend - MFLIMIT; in LZ4HC_compress_generic()
352 const BYTE * const matchlimit = (iend - LASTLITERALS); in LZ4HC_compress_generic()
361 const BYTE *ref2 = NULL; in LZ4HC_compress_generic() local
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()
395 matchlimit, ml, &ref2, in LZ4HC_compress_generic()
418 if ((start2 - ip) < 3) { in LZ4HC_compress_generic()
422 ref = ref2; 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()
445 ref2 += correction; 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()
473 ml2, ref2, limit, oend)) in LZ4HC_compress_generic()
486 int correction = (int)(ip + ml - start2); in LZ4HC_compress_generic()
489 ref2 += correction; in LZ4HC_compress_generic()
490 ml2 -= correction; in LZ4HC_compress_generic()
493 ref2 = ref3; in LZ4HC_compress_generic()
506 ref0 = ref2; in LZ4HC_compress_generic()
512 ref2 = ref3; 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()
533 ref2 += correction; in LZ4HC_compress_generic()
534 ml2 -= correction; in LZ4HC_compress_generic()
537 ml = (int)(start2 - ip); in LZ4HC_compress_generic()
544 ref = ref2; in LZ4HC_compress_generic()
548 ref2 = ref3; 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()
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()
621 LZ4_streamHCPtr->internal_donotuse.base = NULL; in LZ4_resetStreamHC()
622 LZ4_streamHCPtr->internal_donotuse.compressionLevel = (unsigned int)compressionLevel; in LZ4_resetStreamHC()
630 LZ4HC_CCtx_internal *ctxPtr = &LZ4_streamHCPtr->internal_donotuse; in LZ4_loadDictHC()
633 dictionary += dictSize - 64 * KB; in LZ4_loadDictHC()
638 LZ4HC_Insert(ctxPtr, (const BYTE *)dictionary + (dictSize - 3)); in LZ4_loadDictHC()
639 ctxPtr->end = (const BYTE *)dictionary + dictSize; in LZ4_loadDictHC()
650 if (ctxPtr->end >= ctxPtr->base + 4) { in LZ4HC_setExternalDict()
652 LZ4HC_Insert(ctxPtr, ctxPtr->end - 3); in LZ4HC_setExternalDict()
659 ctxPtr->lowLimit = ctxPtr->dictLimit; in LZ4HC_setExternalDict()
660 ctxPtr->dictLimit = (U32)(ctxPtr->end - ctxPtr->base); in LZ4HC_setExternalDict()
661 ctxPtr->dictBase = ctxPtr->base; in LZ4HC_setExternalDict()
662 ctxPtr->base = newBlock - ctxPtr->dictLimit; in LZ4HC_setExternalDict()
663 ctxPtr->end = newBlock; in LZ4HC_setExternalDict()
665 ctxPtr->nextToUpdate = ctxPtr->dictLimit; in LZ4HC_setExternalDict()
676 LZ4HC_CCtx_internal *ctxPtr = &LZ4_streamHCPtr->internal_donotuse; in LZ4_compressHC_continue_generic()
678 /* auto - init if forgotten */ in LZ4_compressHC_continue_generic()
679 if (ctxPtr->base == NULL) in LZ4_compressHC_continue_generic()
683 if ((size_t)(ctxPtr->end - ctxPtr->base) > 2 * GB) { in LZ4_compressHC_continue_generic()
684 size_t dictSize = (size_t)(ctxPtr->end - ctxPtr->base) in LZ4_compressHC_continue_generic()
685 - ctxPtr->dictLimit; in LZ4_compressHC_continue_generic()
689 (const char *)(ctxPtr->end) - dictSize, (int)dictSize); in LZ4_compressHC_continue_generic()
693 if ((const BYTE *)source != ctxPtr->end) in LZ4_compressHC_continue_generic()
699 const BYTE * const dictBegin = ctxPtr->dictBase + ctxPtr->lowLimit; in LZ4_compressHC_continue_generic()
700 const BYTE * const dictEnd = ctxPtr->dictBase + ctxPtr->dictLimit; in LZ4_compressHC_continue_generic()
706 ctxPtr->lowLimit = (U32)(sourceEnd - ctxPtr->dictBase); in LZ4_compressHC_continue_generic()
708 if (ctxPtr->dictLimit - ctxPtr->lowLimit < 4) in LZ4_compressHC_continue_generic()
709 ctxPtr->lowLimit = ctxPtr->dictLimit; in LZ4_compressHC_continue_generic()
714 inputSize, maxOutputSize, ctxPtr->compressionLevel, limit); in LZ4_compressHC_continue_generic()
740 LZ4HC_CCtx_internal *const streamPtr = &LZ4_streamHCPtr->internal_donotuse; in LZ4_saveDictHC()
741 int const prefixSize = (int)(streamPtr->end in LZ4_saveDictHC()
742 - (streamPtr->base + streamPtr->dictLimit)); in LZ4_saveDictHC()
751 memmove(safeBuffer, streamPtr->end - dictSize, dictSize); in LZ4_saveDictHC()
754 U32 const endIndex = (U32)(streamPtr->end - streamPtr->base); in LZ4_saveDictHC()
756 streamPtr->end = (const BYTE *)safeBuffer + dictSize; in LZ4_saveDictHC()
757 streamPtr->base = streamPtr->end - endIndex; in LZ4_saveDictHC()
758 streamPtr->dictLimit = endIndex - dictSize; in LZ4_saveDictHC()
759 streamPtr->lowLimit = endIndex - dictSize; in LZ4_saveDictHC()
761 if (streamPtr->nextToUpdate < streamPtr->dictLimit) in LZ4_saveDictHC()
762 streamPtr->nextToUpdate = streamPtr->dictLimit; in LZ4_saveDictHC()