mirror of
https://github.com/lz4/lz4.git
synced 2024-11-23 01:43:48 +08:00
update API and man page documentation for v1.10
This commit is contained in:
parent
5f0b1d05d1
commit
36df905aa6
@ -1,10 +1,10 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
||||
<title>1.9.5 Manual</title>
|
||||
<title>1.10.0 Manual</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>1.9.5 Manual</h1>
|
||||
<h1>1.10.0 Manual</h1>
|
||||
<hr>
|
||||
<a name="Contents"></a><h2>Contents</h2>
|
||||
<ol>
|
||||
@ -88,7 +88,8 @@
|
||||
<pre><b>#ifndef LZ4_MEMORY_USAGE
|
||||
# define LZ4_MEMORY_USAGE LZ4_MEMORY_USAGE_DEFAULT
|
||||
#endif
|
||||
</b><p> Memory usage formula : N->2^N Bytes (examples : 10 -> 1KB; 12 -> 4KB ; 16 -> 64KB; 20 -> 1MB)
|
||||
</b><p> Can be selected at compile time, by setting LZ4_MEMORY_USAGE.
|
||||
Memory usage formula : N->2^N Bytes (examples : 10 -> 1KB; 12 -> 4KB ; 16 -> 64KB; 20 -> 1MB)
|
||||
Increasing memory usage improves compression ratio, generally at the cost of speed.
|
||||
Reduced memory usage may improve speed at the cost of ratio, thanks to better cache locality.
|
||||
Default value is 14, for 16KB, which nicely fits into most L1 caches.
|
||||
@ -279,6 +280,51 @@ int LZ4_freeStream (LZ4_stream_t* streamPtr);
|
||||
|
||||
</p></pre><BR>
|
||||
|
||||
<pre><b>int LZ4_loadDictSlow(LZ4_stream_t* streamPtr, const char* dictionary, int dictSize);
|
||||
</b><p> Same as LZ4_loadDict(),
|
||||
but uses a bit more cpu to reference the dictionary content more thoroughly.
|
||||
This is expected to slightly improve compression ratio.
|
||||
The extra-cpu cost is likely worth it if the dictionary is re-used across multiple sessions.
|
||||
@return : loaded dictionary size, in bytes (note: only the last 64 KB are loaded)
|
||||
|
||||
</p></pre><BR>
|
||||
|
||||
<pre><b>void
|
||||
LZ4_attach_dictionary(LZ4_stream_t* workingStream,
|
||||
const LZ4_stream_t* dictionaryStream);
|
||||
</b><p>
|
||||
This allows efficient re-use of a static dictionary multiple times.
|
||||
|
||||
Rather than re-loading the dictionary buffer into a working context before
|
||||
each compression, or copying a pre-loaded dictionary's LZ4_stream_t into a
|
||||
working LZ4_stream_t, this function introduces a no-copy setup mechanism,
|
||||
in which the working stream references @dictionaryStream in-place.
|
||||
|
||||
Several assumptions are made about the state of @dictionaryStream.
|
||||
Currently, only states which have been prepared by LZ4_loadDict() or
|
||||
LZ4_loadDictSlow() should be expected to work.
|
||||
|
||||
Alternatively, the provided @dictionaryStream may be NULL,
|
||||
in which case any existing dictionary stream is unset.
|
||||
|
||||
If a dictionary is provided, it replaces any pre-existing stream history.
|
||||
The dictionary contents are the only history that can be referenced and
|
||||
logically immediately precede the data compressed in the first subsequent
|
||||
compression call.
|
||||
|
||||
The dictionary will only remain attached to the working stream through the
|
||||
first compression call, at the end of which it is cleared.
|
||||
@dictionaryStream stream (and source buffer) must remain in-place / accessible / unchanged
|
||||
through the completion of the compression session.
|
||||
|
||||
Note: there is no equivalent LZ4_attach_*() method on the decompression side
|
||||
because there is no initialization cost, hence no need to share the cost across multiple sessions.
|
||||
To decompress LZ4 blocks using dictionary, attached or not,
|
||||
just employ the regular LZ4_setStreamDecode() for streaming,
|
||||
or the stateless LZ4_decompress_safe_usingDict() for one-shot decompression.
|
||||
|
||||
</p></pre><BR>
|
||||
|
||||
<pre><b>int LZ4_compress_fast_continue (LZ4_stream_t* streamPtr, const char* src, char* dst, int srcSize, int dstCapacity, int acceleration);
|
||||
</b><p> Compress 'src' content using data from previously compressed blocks, for better compression ratio.
|
||||
'dst' buffer must be already allocated.
|
||||
@ -453,36 +499,6 @@ LZ4_decompress_safe_partial_usingDict(const char* src, char* dst,
|
||||
|
||||
</p></pre><BR>
|
||||
|
||||
<pre><b>LZ4LIB_STATIC_API void
|
||||
LZ4_attach_dictionary(LZ4_stream_t* workingStream,
|
||||
const LZ4_stream_t* dictionaryStream);
|
||||
</b><p> This is an experimental API that allows
|
||||
efficient use of a static dictionary many times.
|
||||
|
||||
Rather than re-loading the dictionary buffer into a working context before
|
||||
each compression, or copying a pre-loaded dictionary's LZ4_stream_t into a
|
||||
working LZ4_stream_t, this function introduces a no-copy setup mechanism,
|
||||
in which the working stream references the dictionary stream in-place.
|
||||
|
||||
Several assumptions are made about the state of the dictionary stream.
|
||||
Currently, only streams which have been prepared by LZ4_loadDict() should
|
||||
be expected to work.
|
||||
|
||||
Alternatively, the provided dictionaryStream may be NULL,
|
||||
in which case any existing dictionary stream is unset.
|
||||
|
||||
If a dictionary is provided, it replaces any pre-existing stream history.
|
||||
The dictionary contents are the only history that can be referenced and
|
||||
logically immediately precede the data compressed in the first subsequent
|
||||
compression call.
|
||||
|
||||
The dictionary will only remain attached to the working stream through the
|
||||
first compression call, at the end of which it is cleared. The dictionary
|
||||
stream (and source buffer) must remain in-place / accessible / unchanged
|
||||
through the completion of the first compression call on the stream.
|
||||
|
||||
</p></pre><BR>
|
||||
|
||||
<pre><b></b><p>
|
||||
It's possible to have input and output sharing the same buffer,
|
||||
for highly constrained memory environments.
|
||||
|
@ -1,10 +1,10 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
||||
<title>1.9.5 Manual</title>
|
||||
<title>1.10.0 Manual</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>1.9.5 Manual</h1>
|
||||
<h1>1.10.0 Manual</h1>
|
||||
<hr>
|
||||
<a name="Contents"></a><h2>Contents</h2>
|
||||
<ol>
|
||||
@ -18,9 +18,9 @@
|
||||
<li><a href="#Chapter8">Compression</a></li>
|
||||
<li><a href="#Chapter9">Decompression functions</a></li>
|
||||
<li><a href="#Chapter10">Streaming decompression functions</a></li>
|
||||
<li><a href="#Chapter11">Advanced compression operations</a></li>
|
||||
<li><a href="#Chapter12">Dictionary compression API</a></li>
|
||||
<li><a href="#Chapter13">Bulk processing dictionary API</a></li>
|
||||
<li><a href="#Chapter11">Dictionary compression API</a></li>
|
||||
<li><a href="#Chapter12">Bulk processing dictionary compression</a></li>
|
||||
<li><a href="#Chapter13">Advanced compression operations</a></li>
|
||||
<li><a href="#Chapter14">Custom memory allocation</a></li>
|
||||
</ol>
|
||||
<hr>
|
||||
@ -377,10 +377,85 @@ LZ4F_decompress(LZ4F_dctx* dctx,
|
||||
and start a new one using same context resources.
|
||||
</p></pre><BR>
|
||||
|
||||
<a name="Chapter11"></a><h2>Dictionary compression API</h2><pre></pre>
|
||||
|
||||
<pre><b>size_t
|
||||
LZ4F_compressBegin_usingDict(LZ4F_cctx* cctx,
|
||||
void* dstBuffer, size_t dstCapacity,
|
||||
const void* dictBuffer, size_t dictSize,
|
||||
const LZ4F_preferences_t* prefsPtr);
|
||||
</b><p> Inits dictionary compression streaming, and writes the frame header into dstBuffer.
|
||||
@dstCapacity must be >= LZ4F_HEADER_SIZE_MAX bytes.
|
||||
@prefsPtr is optional : one may provide NULL as argument,
|
||||
however, it's the only way to provide dictID in the frame header.
|
||||
@dictBuffer must outlive the compression session.
|
||||
@return : number of bytes written into dstBuffer for the header,
|
||||
or an error code (which can be tested using LZ4F_isError())
|
||||
NOTE: The LZ4Frame spec allows each independent block to be compressed with the dictionary,
|
||||
but this entry supports a more limited scenario, where only the first block uses the dictionary.
|
||||
This is still useful for small data, which only need one block anyway.
|
||||
For larger inputs, one may be more interested in LZ4F_compressFrame_usingCDict() below.
|
||||
|
||||
</p></pre><BR>
|
||||
|
||||
<pre><b>size_t
|
||||
LZ4F_decompress_usingDict(LZ4F_dctx* dctxPtr,
|
||||
void* dstBuffer, size_t* dstSizePtr,
|
||||
const void* srcBuffer, size_t* srcSizePtr,
|
||||
const void* dict, size_t dictSize,
|
||||
const LZ4F_decompressOptions_t* decompressOptionsPtr);
|
||||
</b><p> Same as LZ4F_decompress(), using a predefined dictionary.
|
||||
Dictionary is used "in place", without any preprocessing.
|
||||
It must remain accessible throughout the entire frame decoding.
|
||||
</p></pre><BR>
|
||||
|
||||
<a name="Chapter12"></a><h2>Bulk processing dictionary compression</h2><pre></pre>
|
||||
|
||||
<pre><b>LZ4F_CDict* LZ4F_createCDict(const void* dictBuffer, size_t dictSize);
|
||||
void LZ4F_freeCDict(LZ4F_CDict* CDict);
|
||||
</b><p> When compressing multiple messages / blocks using the same dictionary, it's recommended to initialize it just once.
|
||||
LZ4_createCDict() will create a digested dictionary, ready to start future compression operations without startup delay.
|
||||
LZ4_CDict can be created once and shared by multiple threads concurrently, since its usage is read-only.
|
||||
@dictBuffer can be released after LZ4_CDict creation, since its content is copied within CDict.
|
||||
</p></pre><BR>
|
||||
|
||||
<pre><b>size_t
|
||||
LZ4F_compressFrame_usingCDict(LZ4F_cctx* cctx,
|
||||
void* dst, size_t dstCapacity,
|
||||
const void* src, size_t srcSize,
|
||||
const LZ4F_CDict* cdict,
|
||||
const LZ4F_preferences_t* preferencesPtr);
|
||||
</b><p> Compress an entire srcBuffer into a valid LZ4 frame using a digested Dictionary.
|
||||
@cctx must point to a context created by LZ4F_createCompressionContext().
|
||||
If @cdict==NULL, compress without a dictionary.
|
||||
@dstBuffer MUST be >= LZ4F_compressFrameBound(srcSize, preferencesPtr).
|
||||
If this condition is not respected, function will fail (@return an errorCode).
|
||||
The LZ4F_preferences_t structure is optional : one may provide NULL as argument,
|
||||
but it's not recommended, as it's the only way to provide @dictID in the frame header.
|
||||
@return : number of bytes written into dstBuffer.
|
||||
or an error code if it fails (can be tested using LZ4F_isError())
|
||||
Note: for larger inputs generating multiple independent blocks,
|
||||
this entry point uses the dictionary for each block.
|
||||
</p></pre><BR>
|
||||
|
||||
<pre><b>size_t
|
||||
LZ4F_compressBegin_usingCDict(LZ4F_cctx* cctx,
|
||||
void* dstBuffer, size_t dstCapacity,
|
||||
const LZ4F_CDict* cdict,
|
||||
const LZ4F_preferences_t* prefsPtr);
|
||||
</b><p> Inits streaming dictionary compression, and writes the frame header into dstBuffer.
|
||||
@dstCapacity must be >= LZ4F_HEADER_SIZE_MAX bytes.
|
||||
@prefsPtr is optional : one may provide NULL as argument,
|
||||
note however that it's the only way to insert a @dictID in the frame header.
|
||||
@cdict must outlive the compression session.
|
||||
@return : number of bytes written into dstBuffer for the header,
|
||||
or an error code, which can be tested using LZ4F_isError().
|
||||
</p></pre><BR>
|
||||
|
||||
<pre><b>typedef enum { LZ4F_LIST_ERRORS(LZ4F_GENERATE_ENUM)
|
||||
_LZ4F_dummy_error_enum_for_c89_never_used } LZ4F_errorCodes;
|
||||
</b></pre><BR>
|
||||
<a name="Chapter11"></a><h2>Advanced compression operations</h2><pre></pre>
|
||||
<a name="Chapter13"></a><h2>Advanced compression operations</h2><pre></pre>
|
||||
|
||||
<pre><b>LZ4FLIB_STATIC_API size_t LZ4F_getBlockSize(LZ4F_blockSizeID_t blockSizeID);
|
||||
</b><p> @return, in scalar format (size_t),
|
||||
@ -407,79 +482,6 @@ LZ4F_uncompressedUpdate(LZ4F_cctx* cctx,
|
||||
|
||||
</p></pre><BR>
|
||||
|
||||
<a name="Chapter12"></a><h2>Dictionary compression API</h2><pre></pre>
|
||||
|
||||
<pre><b>LZ4FLIB_STATIC_API size_t
|
||||
LZ4F_compressBegin_usingDict(LZ4F_cctx* cctx,
|
||||
void* dstBuffer, size_t dstCapacity,
|
||||
const void* dictBuffer, size_t dictSize,
|
||||
const LZ4F_preferences_t* prefsPtr);
|
||||
</b><p> Inits dictionary compression streaming, and writes the frame header into dstBuffer.
|
||||
`dstCapacity` must be >= LZ4F_HEADER_SIZE_MAX bytes.
|
||||
`prefsPtr` is optional : you may provide NULL as argument,
|
||||
however, it's the only way to provide dictID in the frame header.
|
||||
`dictBuffer` must outlive the compression session.
|
||||
@return : number of bytes written into dstBuffer for the header,
|
||||
or an error code (which can be tested using LZ4F_isError())
|
||||
NOTE: this entry point doesn't fully exploit the spec,
|
||||
which allows each independent block to be compressed with the dictionary.
|
||||
Currently, only the first block uses the dictionary.
|
||||
This is still technically compliant, but less efficient for large inputs.
|
||||
|
||||
</p></pre><BR>
|
||||
|
||||
<pre><b>LZ4FLIB_STATIC_API size_t
|
||||
LZ4F_decompress_usingDict(LZ4F_dctx* dctxPtr,
|
||||
void* dstBuffer, size_t* dstSizePtr,
|
||||
const void* srcBuffer, size_t* srcSizePtr,
|
||||
const void* dict, size_t dictSize,
|
||||
const LZ4F_decompressOptions_t* decompressOptionsPtr);
|
||||
</b><p> Same as LZ4F_decompress(), using a predefined dictionary.
|
||||
Dictionary is used "in place", without any preprocessing.
|
||||
It must remain accessible throughout the entire frame decoding.
|
||||
</p></pre><BR>
|
||||
|
||||
<a name="Chapter13"></a><h2>Bulk processing dictionary API</h2><pre></pre>
|
||||
|
||||
<pre><b>LZ4FLIB_STATIC_API LZ4F_CDict* LZ4F_createCDict(const void* dictBuffer, size_t dictSize);
|
||||
LZ4FLIB_STATIC_API void LZ4F_freeCDict(LZ4F_CDict* CDict);
|
||||
</b><p> When compressing multiple messages / blocks using the same dictionary, it's recommended to load it just once.
|
||||
LZ4_createCDict() will create a digested dictionary, ready to start future compression operations without startup delay.
|
||||
LZ4_CDict can be created once and shared by multiple threads concurrently, since its usage is read-only.
|
||||
`dictBuffer` can be released after LZ4_CDict creation, since its content is copied within CDict
|
||||
</p></pre><BR>
|
||||
|
||||
<pre><b>LZ4FLIB_STATIC_API size_t
|
||||
LZ4F_compressFrame_usingCDict(LZ4F_cctx* cctx,
|
||||
void* dst, size_t dstCapacity,
|
||||
const void* src, size_t srcSize,
|
||||
const LZ4F_CDict* cdict,
|
||||
const LZ4F_preferences_t* preferencesPtr);
|
||||
</b><p> Compress an entire srcBuffer into a valid LZ4 frame using a digested Dictionary.
|
||||
cctx must point to a context created by LZ4F_createCompressionContext().
|
||||
If cdict==NULL, compress without a dictionary.
|
||||
dstBuffer MUST be >= LZ4F_compressFrameBound(srcSize, preferencesPtr).
|
||||
If this condition is not respected, function will fail (@return an errorCode).
|
||||
The LZ4F_preferences_t structure is optional : you may provide NULL as argument,
|
||||
but it's not recommended, as it's the only way to provide dictID in the frame header.
|
||||
@return : number of bytes written into dstBuffer.
|
||||
or an error code if it fails (can be tested using LZ4F_isError())
|
||||
</p></pre><BR>
|
||||
|
||||
<pre><b>LZ4FLIB_STATIC_API size_t
|
||||
LZ4F_compressBegin_usingCDict(LZ4F_cctx* cctx,
|
||||
void* dstBuffer, size_t dstCapacity,
|
||||
const LZ4F_CDict* cdict,
|
||||
const LZ4F_preferences_t* prefsPtr);
|
||||
</b><p> Inits streaming dictionary compression, and writes the frame header into dstBuffer.
|
||||
`dstCapacity` must be >= LZ4F_HEADER_SIZE_MAX bytes.
|
||||
`prefsPtr` is optional : you may provide NULL as argument,
|
||||
however, it's the only way to provide dictID in the frame header.
|
||||
`cdict` must outlive the compression session.
|
||||
@return : number of bytes written into dstBuffer for the header,
|
||||
or an error code (which can be tested using LZ4F_isError())
|
||||
</p></pre><BR>
|
||||
|
||||
<a name="Chapter14"></a><h2>Custom memory allocation</h2><pre></pre>
|
||||
|
||||
<pre><b>typedef void* (*LZ4F_AllocFunction) (void* opaqueState, size_t size);
|
||||
|
@ -1,5 +1,5 @@
|
||||
.
|
||||
.TH "LZ4" "1" "December 2023" "lz4 1.9.5" "User Commands"
|
||||
.TH "LZ4" "1" "July 2024" "lz4 1.10.0" "User Commands"
|
||||
.
|
||||
.SH "NAME"
|
||||
\fBlz4\fR \- lz4, unlz4, lz4cat \- Compress or decompress \.lz4 files
|
||||
@ -107,7 +107,7 @@ Benchmark mode, using \fB#\fR compression level\.
|
||||
.
|
||||
.TP
|
||||
\fB\-\-list\fR
|
||||
List information about \.lz4 files\. note : current implementation is limited to single\-frame \.lz4 files\.
|
||||
List information about \.lz4 files\. For detailed information on files with multiple frames, use \fB\-v\fR\. \fB\-\-list\fR automatically triggers \fB\-m\fR modifier\.
|
||||
.
|
||||
.SS "Operation modifiers"
|
||||
.
|
||||
@ -246,6 +246,17 @@ Benchmark multiple compression levels, from b# to e# (included)
|
||||
\fB\-i#\fR
|
||||
Minimum evaluation time in seconds [1\-9] (default : 3)
|
||||
.
|
||||
.SS "Environment Variables"
|
||||
It\'s possible to pass some parameters to \fBlz4\fR via environment variables\. This can be useful in situations where \fBlz4\fR is known to be invoked (from a script for example) but there is no way to pass \fBlz4\fR parameters to influence the compression session\. The environment variable has higher priority than executable default, but lower priority than corresponding runtime command\. When set as global environment variables, it can be a way to enforce personalized defaults different from the executable set ones\.
|
||||
.
|
||||
.TP
|
||||
\fBLZ4_CLEVEL\fR
|
||||
specify a default compression level that \fBlz4\fR employs for compression when no other compression level is specified on command line\. Executable default is generally \fB1\fR\.
|
||||
.
|
||||
.TP
|
||||
\fBLZ4_NBWORKERS\fR
|
||||
specify a default number of threads that \fBlz4\fR will employ for compression\. Executable default is generally \fB0\fR, which means auto\-determined based on local cpu\. This functionality is only relevant when \fBlz4\fR is compiled with multithreading support\. The maximum number of workers is capped at \fBLZ4_NBWORKERS_MAX\fR (\fB200\fR by default)\.
|
||||
.
|
||||
.SH "BUGS"
|
||||
Report bugs at: https://github\.com/lz4/lz4/issues
|
||||
.
|
||||
|
Loading…
Reference in New Issue
Block a user