diff options
author | yann.collet.73@gmail.com <yann.collet.73@gmail.com@650e7d94-2a16-8b24-b05c-7c0b3f6821cd> | 2012-02-25 19:13:16 (GMT) |
---|---|---|
committer | yann.collet.73@gmail.com <yann.collet.73@gmail.com@650e7d94-2a16-8b24-b05c-7c0b3f6821cd> | 2012-02-25 19:13:16 (GMT) |
commit | 3430ee1bc0d90e32c47a036eb39c3b0d16ba5451 (patch) | |
tree | 1a70977ae69875d7ab9ef7fd0f467bee0b3ff806 /lz4.c | |
parent | ecbce64ac93a81784c23c0cb8fe9ae8ede0866f9 (diff) | |
download | lz4-3430ee1bc0d90e32c47a036eb39c3b0d16ba5451.zip lz4-3430ee1bc0d90e32c47a036eb39c3b0d16ba5451.tar.gz lz4-3430ee1bc0d90e32c47a036eb39c3b0d16ba5451.tar.bz2 |
Added : format description file
Added : new tuning parameter : LZ4_COMPRESSMIN. Thanks to Maciej Adamczyk for suggestion.
changed : macro for bswap16, in order to help GCC intrinsic detection. Thank to Erik Andersen for suggestion.
git-svn-id: https://lz4.googlecode.com/svn/trunk@57 650e7d94-2a16-8b24-b05c-7c0b3f6821cd
Diffstat (limited to 'lz4.c')
-rw-r--r-- | lz4.c | 15 |
1 files changed, 12 insertions, 3 deletions
@@ -45,6 +45,13 @@ // The default value (6) is recommended
#define NOTCOMPRESSIBLE_CONFIRMATION 6
+// LZ4_COMPRESSMIN :
+// Compression function will *fail* if it is not successful at compressing input by at least LZ4_COMPRESSMIN bytes
+// Since the compression function stops working prematurely, it results in a speed gain
+// The output however is unusable. Compression function result will be zero.
+// Default : 0 = disabled
+#define LZ4_COMPRESSMIN 0
+
// BIG_ENDIAN_NATIVE_BUT_INCOMPATIBLE :
// This will provide a boost to performance for big endian cpu, but the resulting compressed stream will be incompatible with little-endian CPU.
// You can set this option to 1 in situations where data will stay within closed environment
@@ -92,13 +99,13 @@ #endif
#ifdef _MSC_VER
-#define inline __forceinline // Visual is not C99, but supports inline
+#define inline __forceinline // Visual is not C99, but supports some kind of inline
#endif
#ifdef _MSC_VER // Visual Studio
-#define bswap16(i) _byteswap_ushort(i)
+#define bswap16(x) _byteswap_ushort(x)
#else
-#define bswap16(i) (((i)>>8) | ((i)<<8))
+#define bswap16(x) ((unsigned short int) ((((x) >> 8) & 0xffu) | (((x) & 0xffu) << 8)))
#endif
@@ -429,6 +436,7 @@ _last_literals: // Encode Last Literals
{
int lastRun = iend - anchor;
+ if ((LZ4_COMPRESSMIN>0) && (((op - (BYTE*)dest) + lastRun + 1 + ((lastRun-15)/255)) > isize - LZ4_COMPRESSMIN)) return 0;
if (lastRun>=(int)RUN_MASK) { *op++=(RUN_MASK<<ML_BITS); lastRun-=RUN_MASK; for(; lastRun > 254 ; lastRun-=255) *op++ = 255; *op++ = (BYTE) lastRun; }
else *op++ = (lastRun<<ML_BITS);
memcpy(op, anchor, iend - anchor);
@@ -570,6 +578,7 @@ _last_literals: // Encode Last Literals
{
int lastRun = iend - anchor;
+ if ((LZ4_COMPRESSMIN>0) && (((op - (BYTE*)dest) + lastRun + 1 + ((lastRun-15)/255)) > isize - LZ4_COMPRESSMIN)) return 0;
if (lastRun>=(int)RUN_MASK) { *op++=(RUN_MASK<<ML_BITS); lastRun-=RUN_MASK; for(; lastRun > 254 ; lastRun-=255) *op++ = 255; *op++ = (BYTE) lastRun; }
else *op++ = (lastRun<<ML_BITS);
memcpy(op, anchor, iend - anchor);
|