added hash chain with conditional length
not a success yet
This commit is contained in:
parent
a12cdf00c3
commit
16a4337473
@ -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 */
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user