summaryrefslogtreecommitdiffstats
path: root/doc
diff options
context:
space:
mode:
authorYann Collet <cyan@fb.com>2019-06-06 20:20:30 (GMT)
committerYann Collet <cyan@fb.com>2019-06-06 20:20:30 (GMT)
commit1d759576b92a54a29e549bb3a4d42f0660ab4b31 (patch)
tree46b483f5ea2c7bf6092e3d6a9dbb19b2e8a0b2ca /doc
parent3a3639e32dc70cc997f8cf31b5beeceb96c8b5c6 (diff)
downloadlz4-1d759576b92a54a29e549bb3a4d42f0660ab4b31.zip
lz4-1d759576b92a54a29e549bb3a4d42f0660ab4b31.tar.gz
lz4-1d759576b92a54a29e549bb3a4d42f0660ab4b31.tar.bz2
precise again that LZ4 decoder needs metadata
and that such metadata must be provided / sent / saved by the application.
Diffstat (limited to 'doc')
-rw-r--r--doc/lz4_manual.html51
1 files changed, 31 insertions, 20 deletions
diff --git a/doc/lz4_manual.html b/doc/lz4_manual.html
index 1480089..18daa05 100644
--- a/doc/lz4_manual.html
+++ b/doc/lz4_manual.html
@@ -21,7 +21,7 @@
</ol>
<hr>
<a name="Chapter1"></a><h2>Introduction</h2><pre>
- LZ4 is lossless compression algorithm, providing compression speed at 500 MB/s per core,
+ LZ4 is lossless compression algorithm, providing compression speed >500 MB/s per core,
scalable with multi-cores CPU. It features an extremely fast decoder, with speed in
multiple GB/s per core, typically reaching RAM speed limits on multi-core systems.
@@ -33,7 +33,10 @@
- unbounded multiple steps (described as Streaming compression)
lz4.h generates and decodes LZ4-compressed blocks (doc/lz4_Block_format.md).
- Decompressing a block requires additional metadata, such as its compressed size.
+ Decompressing such a compressed block requires additional metadata.
+ Exact metadata depends on exact decompression function.
+ For the typical case of LZ4_decompress_safe(),
+ metadata includes block's compressed size, and maximum bound of decompressed size.
Each application is free to encode and pass such metadata in whichever way it wants.
lz4.h only handle blocks, it can not generate Frames.
@@ -66,27 +69,35 @@
<a name="Chapter4"></a><h2>Simple Functions</h2><pre></pre>
<pre><b>int LZ4_compress_default(const char* src, char* dst, int srcSize, int dstCapacity);
-</b><p> Compresses 'srcSize' bytes from buffer 'src'
- into already allocated 'dst' buffer of size 'dstCapacity'.
- Compression is guaranteed to succeed if 'dstCapacity' >= LZ4_compressBound(srcSize).
- It also runs faster, so it's a recommended setting.
- If the function cannot compress 'src' into a more limited 'dst' budget,
- compression stops *immediately*, and the function result is zero.
- In which case, 'dst' content is undefined (invalid).
- srcSize : max supported value is LZ4_MAX_INPUT_SIZE.
- dstCapacity : size of buffer 'dst' (which must be already allocated)
- @return : the number of bytes written into buffer 'dst' (necessarily <= dstCapacity)
- or 0 if compression fails
- Note : This function is protected against buffer overflow scenarios (never writes outside 'dst' buffer, nor read outside 'source' buffer).
+</b><p> Compresses 'srcSize' bytes from buffer 'src'
+ into already allocated 'dst' buffer of size 'dstCapacity'.
+ Compression is guaranteed to succeed if 'dstCapacity' >= LZ4_compressBound(srcSize).
+ It also runs faster, so it's a recommended setting.
+ If the function cannot compress 'src' into a more limited 'dst' budget,
+ compression stops *immediately*, and the function result is zero.
+ In which case, 'dst' content is undefined (invalid).
+ srcSize : max supported value is LZ4_MAX_INPUT_SIZE.
+ dstCapacity : size of buffer 'dst' (which must be already allocated)
+ @return : the number of bytes written into buffer 'dst' (necessarily <= dstCapacity)
+ or 0 if compression fails
+ Note : This function is protected against buffer overflow scenarios (never writes outside 'dst' buffer, nor read outside 'source' buffer).
+
</p></pre><BR>
<pre><b>int LZ4_decompress_safe (const char* src, char* dst, int compressedSize, int dstCapacity);
-</b><p> compressedSize : is the exact complete size of the compressed block.
- dstCapacity : is the size of destination buffer, which must be already allocated.
- @return : the number of bytes decompressed into destination buffer (necessarily <= dstCapacity)
- If destination buffer is not large enough, decoding will stop and output an error code (negative value).
- If the source stream is detected malformed, the function will stop decoding and return a negative result.
- Note : This function is protected against malicious data packets (never writes outside 'dst' buffer, nor read outside 'source' buffer).
+</b><p> compressedSize : is the exact complete size of the compressed block.
+ dstCapacity : is the size of destination buffer (which must be already allocated), presumed an upper bound of decompressed size.
+ @return : the number of bytes decompressed into destination buffer (necessarily <= dstCapacity)
+ If destination buffer is not large enough, decoding will stop and output an error code (negative value).
+ If the source stream is detected malformed, the function will stop decoding and return a negative result.
+ Note 1 : This function is protected against malicious data packets :
+ it will never writes outside 'dst' buffer, nor read outside 'source' buffer,
+ even if the compressed block is maliciously modified to order the decoder to do these actions.
+ In such case, the decoder stops immediately, and considers the compressed block malformed.
+ Note 2 : compressedSize and dstCapacity must be provided to the function, the compressed block does not contain them.
+ The implementation is free to send / store / derive this information in whichever way is most beneficial.
+ If there is a need for a different format which bundles together both compressed data and its metadata, consider looking at lz4frame.h instead.
+
</p></pre><BR>
<a name="Chapter5"></a><h2>Advanced Functions</h2><pre></pre>