Skip to content

Commit

Permalink
updated NEWS
Browse files Browse the repository at this point in the history
reverted lz4hc.c
  • Loading branch information
inikep committed Feb 7, 2017
1 parent 075a2ef commit 0410263
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 41 deletions.
1 change: 1 addition & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ v1.6
- lz5 updated to v2.0
- improved: touch pages in buffer allocations prior to running first algorithm (thanks to travisdowns)
- fixed: check if input name is directory
- fixed: median time (the "-p3" option, thanks to Alexey Tourbin)

v1.5
- added the "-r" option : operate recursively on directories
Expand Down
55 changes: 14 additions & 41 deletions lz4/lz4hc.c
Original file line number Diff line number Diff line change
Expand Up @@ -313,8 +313,6 @@ static int LZ4HC_compress_hashChain (
char* const dest,
int const inputSize,
int const maxOutputSize,
int compressionLevel,
int constLevel,
unsigned maxNbAttempts,
limitedOutput_directive limit
)
Expand Down Expand Up @@ -344,10 +342,7 @@ static int LZ4HC_compress_hashChain (

/* Main Loop */
while (ip < mflimit) {
if (constLevel == 1) ml = LZ4HC_InsertAndFindBestMatch(ctx, ip, matchlimit, &ref, 1);
else if (constLevel == 2) ml = LZ4HC_InsertAndFindBestMatch(ctx, ip, matchlimit, &ref, 2);
else if (constLevel == 3) ml = LZ4HC_InsertAndFindBestMatch(ctx, ip, matchlimit, &ref, 4);
else ml = LZ4HC_InsertAndFindBestMatch(ctx, ip, matchlimit, &ref, maxNbAttempts);
ml = LZ4HC_InsertAndFindBestMatch (ctx, ip, matchlimit, (&ref), maxNbAttempts);
if (!ml) { ip++; continue; }

/* saved, in case we would skip too much */
Expand All @@ -356,12 +351,9 @@ static int LZ4HC_compress_hashChain (
ml0 = ml;

_Search2:
if (ip+ml < mflimit) {
if (constLevel == 1) ml2 = LZ4HC_InsertAndGetWiderMatch(ctx, ip + ml - 2, ip + 0, matchlimit, ml, &ref2, &start2, 1);
else if (constLevel == 2) ml2 = LZ4HC_InsertAndGetWiderMatch(ctx, ip + ml - 2, ip + 0, matchlimit, ml, &ref2, &start2, 2);
else if (constLevel == 3) ml2 = LZ4HC_InsertAndGetWiderMatch(ctx, ip + ml - 2, ip + 0, matchlimit, ml, &ref2, &start2, 4);
else ml2 = LZ4HC_InsertAndGetWiderMatch(ctx, ip + ml - 2, ip + 0, matchlimit, ml, &ref2, &start2, maxNbAttempts);
} else ml2 = ml;
if (ip+ml < mflimit)
ml2 = LZ4HC_InsertAndGetWiderMatch(ctx, ip + ml - 2, ip + 0, matchlimit, ml, &ref2, &start2, maxNbAttempts);
else ml2 = ml;

if (ml2 == ml) { /* No better match */
if (LZ4HC_encodeSequence(&ip, &op, &anchor, ml, ref, limit, oend)) return 0;
Expand Down Expand Up @@ -404,12 +396,9 @@ static int LZ4HC_compress_hashChain (
}
/* Now, we have start2 = ip+new_ml, with new_ml = min(ml, OPTIMAL_ML=18) */

if (start2 + ml2 < mflimit) {
if (constLevel == 1) ml3 = LZ4HC_InsertAndGetWiderMatch(ctx, start2 + ml2 - 3, start2, matchlimit, ml2, &ref3, &start3, 1);
else if (constLevel == 2) ml3 = LZ4HC_InsertAndGetWiderMatch(ctx, start2 + ml2 - 3, start2, matchlimit, ml2, &ref3, &start3, 2);
else if (constLevel == 3) ml3 = LZ4HC_InsertAndGetWiderMatch(ctx, start2 + ml2 - 3, start2, matchlimit, ml2, &ref3, &start3, 4);
else ml3 = LZ4HC_InsertAndGetWiderMatch(ctx, start2 + ml2 - 3, start2, matchlimit, ml2, &ref3, &start3, maxNbAttempts);
} else ml3 = ml2;
if (start2 + ml2 < mflimit)
ml3 = LZ4HC_InsertAndGetWiderMatch(ctx, start2 + ml2 - 3, start2, matchlimit, ml2, &ref3, &start3, maxNbAttempts);
else ml3 = ml2;

if (ml3 == ml2) { /* No better match : 2 sequences to encode */
/* ip & ref are known; Now for ml */
Expand Down Expand Up @@ -536,17 +525,10 @@ int LZ4_compress_HC_extStateHC (void* state, const char* src, char* dst, int src
LZ4HC_CCtx_internal* ctx = &((LZ4_streamHC_t*)state)->internal_donotuse;
if (((size_t)(state)&(sizeof(void*)-1)) != 0) return 0; /* Error : state is not aligned for pointers (32 or 64 bits) */
LZ4HC_init (ctx, (const BYTE*)src);
if (maxDstSize < LZ4_compressBound(srcSize)) {
if (compressionLevel == 1) return LZ4HC_compress_generic (ctx, src, dst, srcSize, maxDstSize, 1, 1, limitedOutput);
else if (compressionLevel == 2) return LZ4HC_compress_generic (ctx, src, dst, srcSize, maxDstSize, 2, 2, limitedOutput);
else if (compressionLevel == 3) return LZ4HC_compress_generic (ctx, src, dst, srcSize, maxDstSize, 3, 3, limitedOutput);
else return LZ4HC_compress_generic (ctx, src, dst, srcSize, maxDstSize, compressionLevel, 0, limitedOutput);
} else {
if (compressionLevel == 1) return LZ4HC_compress_generic (ctx, src, dst, srcSize, maxDstSize, 1, 1, noLimit);
else if (compressionLevel == 2) return LZ4HC_compress_generic (ctx, src, dst, srcSize, maxDstSize, 2, 2, noLimit);
else if (compressionLevel == 3) return LZ4HC_compress_generic (ctx, src, dst, srcSize, maxDstSize, 3, 3, noLimit);
else return LZ4HC_compress_generic (ctx, src, dst, srcSize, maxDstSize, compressionLevel, 0, noLimit);
}
if (maxDstSize < LZ4_compressBound(srcSize))
return LZ4HC_compress_generic (ctx, src, dst, srcSize, maxDstSize, compressionLevel, limitedOutput);
else
return LZ4HC_compress_generic (ctx, src, dst, srcSize, maxDstSize, compressionLevel, noLimit);
}

int LZ4_compress_HC(const char* src, char* dst, int srcSize, int maxDstSize, int compressionLevel)
Expand Down Expand Up @@ -647,10 +629,7 @@ static int LZ4_compressHC_continue_generic (LZ4_streamHC_t* LZ4_streamHCPtr,
}
}

if (ctxPtr->compressionLevel == 1) return LZ4HC_compress_generic(ctxPtr, source, dest, inputSize, maxOutputSize, 1, 1, limit);
else if (ctxPtr->compressionLevel == 2) return LZ4HC_compress_generic(ctxPtr, source, dest, inputSize, maxOutputSize, 2, 2, limit);
else if (ctxPtr->compressionLevel == 3) return LZ4HC_compress_generic(ctxPtr, source, dest, inputSize, maxOutputSize, 3, 3, limit);
else return LZ4HC_compress_generic(ctxPtr, source, dest, inputSize, maxOutputSize, ctxPtr->compressionLevel, 0, limit);
return LZ4HC_compress_generic (ctxPtr, source, dest, inputSize, maxOutputSize, ctxPtr->compressionLevel, limit);
}

int LZ4_compress_HC_continue (LZ4_streamHC_t* LZ4_streamHCPtr, const char* source, char* dest, int inputSize, int maxOutputSize)
Expand Down Expand Up @@ -725,18 +704,12 @@ int LZ4_freeHC (void* LZ4HC_Data) { FREEMEM(LZ4HC_Data); return 0; }

int LZ4_compressHC2_continue (void* LZ4HC_Data, const char* source, char* dest, int inputSize, int compressionLevel)
{
if (compressionLevel == 1) return LZ4HC_compress_generic (&((LZ4_streamHC_t*)LZ4HC_Data)->internal_donotuse, source, dest, inputSize, 0, 1, 1, noLimit);
else if (compressionLevel == 2) return LZ4HC_compress_generic (&((LZ4_streamHC_t*)LZ4HC_Data)->internal_donotuse, source, dest, inputSize, 0, 2, 2, noLimit);
else if (compressionLevel == 3) return LZ4HC_compress_generic (&((LZ4_streamHC_t*)LZ4HC_Data)->internal_donotuse, source, dest, inputSize, 0, 3, 3, noLimit);
return LZ4HC_compress_generic (&((LZ4_streamHC_t*)LZ4HC_Data)->internal_donotuse, source, dest, inputSize, 0, compressionLevel, noLimit, 0);
return LZ4HC_compress_generic (&((LZ4_streamHC_t*)LZ4HC_Data)->internal_donotuse, source, dest, inputSize, 0, compressionLevel, noLimit);
}

int LZ4_compressHC2_limitedOutput_continue (void* LZ4HC_Data, const char* source, char* dest, int inputSize, int maxOutputSize, int compressionLevel)
{
if (compressionLevel == 1) return LZ4HC_compress_generic (&((LZ4_streamHC_t*)LZ4HC_Data)->internal_donotuse, source, dest, inputSize, maxOutputSize, 1, 1, limitedOutput);
else if (compressionLevel == 2) return LZ4HC_compress_generic (&((LZ4_streamHC_t*)LZ4HC_Data)->internal_donotuse, source, dest, inputSize, maxOutputSize, 2, 2, limitedOutput);
else if (compressionLevel == 3) return LZ4HC_compress_generic (&((LZ4_streamHC_t*)LZ4HC_Data)->internal_donotuse, source, dest, inputSize, maxOutputSize, 3, 3, limitedOutput);
else return LZ4HC_compress_generic (&((LZ4_streamHC_t*)LZ4HC_Data)->internal_donotuse, source, dest, inputSize, maxOutputSize, compressionLevel, 0, limitedOutput);
return LZ4HC_compress_generic (&((LZ4_streamHC_t*)LZ4HC_Data)->internal_donotuse, source, dest, inputSize, maxOutputSize, compressionLevel, limitedOutput);
}

char* LZ4_slideInputBufferHC(void* LZ4HC_Data)
Expand Down

0 comments on commit 0410263

Please sign in to comment.