diff options
author | Yann Collet <Cyan4973@users.noreply.github.com> | 2019-04-12 21:28:44 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-04-12 21:28:44 (GMT) |
commit | 2de183c92ad5dfe227f778dd5e727ef6995e09af (patch) | |
tree | ded0579429ae77fae4957551c4748e63f682ed54 | |
parent | 352bbdb98ef6d8c5518b6c7ec7b48a40245c3a9c (diff) | |
parent | 20c2a5fc946c2ad4a765c57cb9502ba7a8f87116 (diff) | |
download | lz4-2de183c92ad5dfe227f778dd5e727ef6995e09af.zip lz4-2de183c92ad5dfe227f778dd5e727ef6995e09af.tar.gz lz4-2de183c92ad5dfe227f778dd5e727ef6995e09af.tar.bz2 |
Merge pull request #666 from lz4/blockIndep
added command -BI for "Independent Blocks"
-rw-r--r-- | programs/lz4.1 | 6 | ||||
-rw-r--r-- | programs/lz4.1.md | 5 | ||||
-rw-r--r-- | programs/lz4cli.c | 24 | ||||
-rw-r--r-- | tests/Makefile | 2 |
4 files changed, 23 insertions, 14 deletions
diff --git a/programs/lz4.1 b/programs/lz4.1 index d3406a5..1576e45 100644 --- a/programs/lz4.1 +++ b/programs/lz4.1 @@ -159,8 +159,12 @@ Block size [4\-7](default : 7) \fB\-B4\fR= 64KB ; \fB\-B5\fR= 256KB ; \fB\-B6\fR= 1MB ; \fB\-B7\fR= 4MB . .TP +\fB\-BI\fR +Produce independent blocks (default) +. +.TP \fB\-BD\fR -Block Dependency (improves compression ratio on small blocks) +Blocks depend on predecessors (improves compression ratio, more noticeable on small blocks) . .TP \fB\-\-[no\-]frame\-crc\fR diff --git a/programs/lz4.1.md b/programs/lz4.1.md index 2ee40aa..10449a0 100644 --- a/programs/lz4.1.md +++ b/programs/lz4.1.md @@ -172,8 +172,11 @@ only the latest one will be applied. Block size \[4-7\](default : 7)<br/> `-B4`= 64KB ; `-B5`= 256KB ; `-B6`= 1MB ; `-B7`= 4MB +* `-BI`: + Produce independent blocks (default) + * `-BD`: - Block Dependency (improves compression ratio on small blocks) + Blocks depend on predecessors (improves compression ratio, more noticeable on small blocks) * `--[no-]frame-crc`: Select frame checksum (default:enabled) diff --git a/programs/lz4cli.c b/programs/lz4cli.c index 464e43b..9a7aeb4 100644 --- a/programs/lz4cli.c +++ b/programs/lz4cli.c @@ -136,7 +136,8 @@ static int usage_advanced(const char* exeName) DISPLAY( " -l : compress using Legacy format (Linux kernel compression)\n"); DISPLAY( " -B# : cut file into blocks of size # bytes [32+] \n"); DISPLAY( " or predefined block size [4-7] (default: 7) \n"); - DISPLAY( " -BD : Block dependency (improve compression ratio) \n"); + DISPLAY( " -BI : Block Independence (default) \n"); + DISPLAY( " -BD : Block dependency (improves compression ratio) \n"); DISPLAY( " -BX : enable block checksum (default:disabled) \n"); DISPLAY( "--no-frame-crc : disable stream checksum (default:enabled) \n"); DISPLAY( "--content-size : compressed frame includes original size (default:not present)\n"); @@ -250,16 +251,16 @@ static int exeNameMatch(const char* exeName, const char* test) } /*! readU32FromChar() : - @return : unsigned integer value read from input in `char` format - allows and interprets K, KB, KiB, M, MB and MiB suffix. - Will also modify `*stringPtr`, advancing it to position where it stopped reading. - Note : function result can overflow if digit string > MAX_UINT */ + * @return : unsigned integer value read from input in `char` format + * allows and interprets K, KB, KiB, M, MB and MiB suffix. + * Will also modify `*stringPtr`, advancing it to position where it stopped reading. + * Note : function result can overflow if digit string > MAX_UINT */ static unsigned readU32FromChar(const char** stringPtr) { unsigned result = 0; while ((**stringPtr >='0') && (**stringPtr <='9')) { result *= 10; - result += **stringPtr - '0'; + result += (unsigned)(**stringPtr - '0'); (*stringPtr)++ ; } if ((**stringPtr=='K') || (**stringPtr=='M')) { @@ -277,7 +278,7 @@ static unsigned readU32FromChar(const char** stringPtr) * If yes, @return 1 and advances *stringPtr to the position which immediately follows longCommand. * @return 0 and doesn't modify *stringPtr otherwise. */ -static unsigned longCommandWArg(const char** stringPtr, const char* longCommand) +static int longCommandWArg(const char** stringPtr, const char* longCommand) { size_t const comSize = strlen(longCommand); int const result = !strncmp(*stringPtr, longCommand, comSize); @@ -316,7 +317,7 @@ int main(int argc, const char** argv) const char* output_filename= NULL; const char* dictionary_filename = NULL; char* dynNameSpace = NULL; - const char** inFileNames = (const char**) calloc(argc, sizeof(char*)); + const char** inFileNames = (const char**)calloc((size_t)argc, sizeof(char*)); unsigned ifnIdx=0; LZ4IO_prefs_t* const prefs = LZ4IO_defaultPreferences(); const char nullOutput[] = NULL_OUTPUT; @@ -425,7 +426,7 @@ int main(int argc, const char** argv) } if ((*argument>='0') && (*argument<='9')) { - cLevel = readU32FromChar(&argument); + cLevel = (int)readU32FromChar(&argument); argument--; continue; } @@ -440,7 +441,7 @@ int main(int argc, const char** argv) case 'e': argument++; - cLevelLast = readU32FromChar(&argument); + cLevelLast = (int)readU32FromChar(&argument); argument--; break; @@ -498,6 +499,7 @@ int main(int argc, const char** argv) switch(argument[1]) { case 'D': LZ4IO_setBlockMode(prefs, LZ4IO_blockLinked); argument++; break; + case 'I': LZ4IO_setBlockMode(prefs, LZ4IO_blockIndependent); argument++; break; case 'X': LZ4IO_setBlockChecksumMode(prefs, 1); argument ++; break; /* disabled by default */ default : if (argument[1] < '0' || argument[1] > '9') { @@ -696,7 +698,7 @@ int main(int argc, const char** argv) } /* IO Stream/File */ - LZ4IO_setNotificationLevel(displayLevel); + LZ4IO_setNotificationLevel((int)displayLevel); if (ifnIdx == 0) multiple_inputs = 0; if (mode == om_decompress) { if (multiple_inputs) diff --git a/tests/Makefile b/tests/Makefile index 792c22c..8e154f7 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -248,7 +248,7 @@ test-lz4-basic: lz4 datagen unlz4 lz4cat $(DIFF) -q tmp-tlb-dg20k tmp-tlb-dec $(LZ4) --no-frame-crc < tmp-tlb-dg20k | $(LZ4) -d > tmp-tlb-dec $(DIFF) -q tmp-tlb-dg20k tmp-tlb-dec - ./datagen | $(LZ4) | $(LZ4) -t + ./datagen | $(LZ4) -BI | $(LZ4) -t ./datagen -g6M -P99 | $(LZ4) -9BD | $(LZ4) -t ./datagen -g17M | $(LZ4) -9v | $(LZ4) -qt ./datagen -g33M | $(LZ4) --no-frame-crc | $(LZ4) -t |