From: Yann Collet Date: Wed, 25 Oct 2017 05:07:08 +0000 (+0200) Subject: added hash chain with conditional length X-Git-Tag: upstream/1.9.3~11^2~25^2~32 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=16a433747309d209c2247c5074ff3ac8783548c7;p=platform%2Fupstream%2Flz4.git added hash chain with conditional length not a success yet --- diff --git a/lib/lz4hc.c b/lib/lz4hc.c index adabd9c..4532ba3 100644 --- a/lib/lz4hc.c +++ b/lib/lz4hc.c @@ -195,12 +195,6 @@ LZ4_FORCE_INLINE int LZ4HC_InsertAndGetWiderMatch ( while ((matchIndex>=lowLimit) && (nbAttempts)) { nbAttempts--; - int trace = 0; - if (nbAttempts==0) { - trace = 1; - DEBUGLOG(2, "reached max nb of attempts ! : %08X => %08X ", - pattern, HASH_FUNCTION(pattern)); - } if (matchIndex >= dictLimit) { const BYTE* const matchPtr = base + matchIndex; if (*(iLowLimit + longest) == *(matchPtr - delta + longest)) { @@ -249,7 +243,6 @@ LZ4_FORCE_INLINE int LZ4HC_InsertAndGetWiderMatch ( { U32 const nextOffset = DELTANEXTU16(chainTable, matchIndex); matchIndex -= nextOffset; if (1 && (nextOffset==1)) { - if (trace) DEBUGLOG(2, "check repeat mode : %u", repeat); /* may be a repeated pattern */ if (repeat == rep_untested) { if ((pattern & 0xFFFF) == (pattern >> 16)) { /* is it enough ? */ @@ -261,13 +254,11 @@ LZ4_FORCE_INLINE int LZ4HC_InsertAndGetWiderMatch ( if ( (repeat == rep_confirmed) /* proven repeated pattern (1-2-4) */ && (matchIndex >= dictLimit) ) { /* same segment only */ const BYTE* const matchPtr = base + matchIndex; - if (trace) DEBUGLOG(2, "search direct pattern position"); if (LZ4_read32(matchPtr) == pattern) { /* good candidate */ size_t const forwardPatternLength = LZ4HC_countPattern(matchPtr+sizeof(pattern), iHighLimit, pattern) + sizeof(pattern); const BYTE* const maxLowPtr = (lowPrefixPtr + MAX_DISTANCE >= ip) ? lowPrefixPtr : ip - MAX_DISTANCE; size_t const backLength = LZ4HC_reverseCountPattern(matchPtr, maxLowPtr, pattern); size_t const currentSegmentLength = backLength + forwardPatternLength; - if (trace) DEBUGLOG(2, "good start position (match == pattern)"); if ( (currentSegmentLength >= srcPatternLength) /* current pattern segment large enough to contain full srcPatternLength */ && (forwardPatternLength <= srcPatternLength) ) { /* haven't reached this position yet */ diff --git a/lib/lz4opt.h b/lib/lz4opt.h index ef7b725..bd956ee 100644 --- a/lib/lz4opt.h +++ b/lib/lz4opt.h @@ -213,7 +213,7 @@ LZ4_FORCE_INLINE int LZ4HC_HashChain_GetAllMatches ( { const BYTE* matchPtr; int matchLength = LZ4HC_FindLongerMatch(ctx, ip, iHighLimit, (int)best_mlen, &matchPtr, ctx->searchNum); - if (matchLength < MINMATCH) return 0; + if ((size_t)matchLength <= best_mlen) return 0; assert(matches != NULL); matches[0].len = matchLength; matches[0].off = (int)(ip-matchPtr); @@ -327,6 +327,7 @@ static int LZ4HC_compress_optimal ( //nb_matches = LZ4HC_BinTree_GetAllMatches(ctx, curPtr, matchlimit, MINMATCH-1, matches, fullUpdate); nb_matches = LZ4HC_HashChain_GetAllMatches(ctx, curPtr, matchlimit, MINMATCH-1, matches, fullUpdate); + //nb_matches = LZ4HC_HashChain_GetAllMatches(ctx, curPtr, matchlimit, last_match_pos - cur + 1, matches, fullUpdate); /* only works if last_match_pos is really the last match pos */ if ((nb_matches > 0) && (size_t)matches[nb_matches-1].len > sufficient_len) { /* immediate encoding */ best_mlen = matches[nb_matches-1].len;