lz4.c : corrected compression efficiency issue 97 in 64-bits chained mode (-BD) for streams > 4 GB (thanks Roman Strashkin for reporting)

git-svn-id: https://lz4.googlecode.com/svn/trunk@108 650e7d94-2a16-8b24-b05c-7c0b3f6821cd
This commit is contained in:
yann.collet.73@gmail.com 2013-11-02 12:11:04 +00:00
parent a78db582d3
commit 7a863abfc2
4 changed files with 24 additions and 14 deletions

View File

@ -30,7 +30,7 @@
# fullbench32: Same as fullbench, but forced to compile in 32-bits mode
# ################################################################
RELEASE=r107
RELEASE=r108
DESTDIR=
PREFIX=${DESTDIR}/usr
BINDIR=$(PREFIX)/bin

9
NEWS
View File

@ -1,3 +1,6 @@
r108 :
lz4.c : corrected compression efficiency issue 97 in 64-bits chained mode (-BD) for streams > 4 GB (thanks Roman Strashkin for reporting)
r107 :
Makefile : support DESTDIR for staged installs. Thanks Jorge Aparicio.
Makefile : make install installs both lz4 and lz4c (Jorge Aparicio)
@ -13,11 +16,11 @@ cmake : check for just C compiler (Elan Ruusamae)
r106 :
Makefile : make dist modify text files in the package to respect Unix EoL convention
lz4cli : corrected small display bug in HC mode
lz4cli.c : corrected small display bug in HC mode
r105 :
Makefile : New install script and man page, contributed by Prasad Pandit
lz4cli.c : Minor modifications, for easier extensibility
COPYING : added license file
COPYING : added license file
LZ4_Streaming_Format.odt : modified file name to remove white space characters
exe : .exe suffix now properly added only for Windows target
Makefile : .exe suffix now properly added only for Windows target

22
lz4.c
View File

@ -631,21 +631,27 @@ char* LZ4_slideInputBuffer (void* LZ4_Data)
LZ4_Data_Structure* lz4ds = (LZ4_Data_Structure*)LZ4_Data;
size_t delta = lz4ds->nextBlock - (lz4ds->bufferStart + 64 KB);
if(lz4ds->base - delta > lz4ds->base) // underflow control
if ( (lz4ds->base - delta > lz4ds->base) // underflow control
|| ((size_t)(lz4ds->nextBlock - lz4ds->base) > 0xE0000000) ) // close to 32-bits limit
{
size_t newBaseDelta = (lz4ds->nextBlock - 64 KB) - lz4ds->base;
size_t deltaLimit = (lz4ds->nextBlock - 64 KB) - lz4ds->base;
int nH;
for (nH=0; nH < HASHNBCELLS4; nH++)
{
if (lz4ds->hashTable[nH] < (U32)newBaseDelta) lz4ds->hashTable[nH] = 0;
else lz4ds->hashTable[nH] -= (U32)newBaseDelta;
if ((size_t)(lz4ds->hashTable[nH]) < deltaLimit) lz4ds->hashTable[nH] = 0;
else lz4ds->hashTable[nH] -= (U32)deltaLimit;
}
lz4ds->base += newBaseDelta;
memcpy((void*)(lz4ds->bufferStart), (const void*)(lz4ds->nextBlock - 64 KB), 64 KB);
lz4ds->base = lz4ds->bufferStart;
lz4ds->nextBlock = lz4ds->base + 64 KB;
}
memcpy((void*)(lz4ds->bufferStart), (const void*)(lz4ds->nextBlock - 64 KB), 64 KB);
lz4ds->nextBlock -= delta;
lz4ds->base -= delta;
else
{
memcpy((void*)(lz4ds->bufferStart), (const void*)(lz4ds->nextBlock - 64 KB), 64 KB);
lz4ds->nextBlock -= delta;
lz4ds->base -= delta;
}
return (char*)(lz4ds->nextBlock);
}

View File

@ -49,7 +49,8 @@
#endif
#define _FILE_OFFSET_BITS 64 // Large file support on 32-bits unix
#define _POSIX_SOURCE 1 // for fileno() within <stdio.h> on unix
#define _POSIX_SOURCE 1 // for fileno() within <stdio.h> on unix
//****************************
// Includes
@ -106,7 +107,7 @@
// Constants
//****************************
#define COMPRESSOR_NAME "LZ4 Compression CLI"
#define COMPRESSOR_VERSION "v1.0.7"
#define COMPRESSOR_VERSION "v1.0.8"
#define COMPILED __DATE__
#define AUTHOR "Yann Collet"
#define LZ4_EXTENSION ".lz4"