#include <cafe.h> #include <lzmalib.h> MY_STDAPI LzmaCompress(unsigned char *dest, size_t *destLen, const unsigned char *src, size_t srcLen, unsigned char *outProps, size_t *outPropsSize, /* *outPropsSize must be = 5 */ int level, /* 0 <= level <= 9, default = 5 */ unsigned dictSize, /* default = (1 << 24) */ int lc, /* 0 <= lc <= 8, default = 3 */ int lp, /* 0 <= lp <= 4, default = 0 */ int pb, /* 0 <= pb <= 4, default = 2 */ int fb, /* 5 <= fb <= 273, default = 32 */ int numThreads /* 1 or 2, default = 2 */ );
In: Output data.
Out: Processed output size.
In: Output data size.
Out: Processed output size.
|srcLen||Input data size.|
|outProps||Pointer to a 5-byte buffer that receives the LZMA properties specified in this call.
In: pointer to the size of outProps buffer;
Out: pointer to the size of written properties in outProps buffer;
Compression level: 0 ≤ level ≤ 9. The default value for level is 5.
Algorithm = 1 means normal method
The dictionary size in bytes. The maximum value is:
128 MB = (1 << 27) bytes for 32-bit version
1 GB = (1 << 30) bytes for 64-bit version
The default value is 16 MB = (1 << 24) bytes. It is recommended to use the dictionary that is larger than 4 KB and that can be calculated as (1 << N) or (3 << N) sizes.
|lc||The number of literal context bits (high bits of previous literal). It can be in the range from 0 to 8. The default value is 3. Occasionally lc=4 provides the gain for big files.|
|lp||The number of literal pos bits (low bits of current position for literals). It can be in the range from 0 to 4. The default value is 0. The lp switch is intended for periodical data when the period is equal to 2^lp. For example, for 32-bit (4 bytes) periodical data you can use lp=2. Often it is better to set lc=0, if you change lp switch.|
|pb||The number of pos bits (low bits of current position). It can be in the range from 0 to 4. The default value is 2. The pb switch is intended for periodical data when the period is equal 2^pb.|
|fb||Word size (the number of fast bytes). It can be in the range from 5 to 273. The default value is 32. Usually, a big number provides a little bit better compression ratio and slower compression process.|
|numThreads||The number of threads, 1 or 2. The default value is 2. Fast mode (Algorithm = 0) can use only 1 thread.|
||Memory allocation error.|
||Output buffer overflow.|
||Errors in multithreading functions (only for Mt version).|
Compress the data referenced by src into the buffer referenced by dest using the LZMA compression algorithm from the public domain LZMALIB
version 9.20 that is available at
The LZMA encoder uses default values for any parameter if it is
-1 for any from level, loc, lp,
pb, fb, numThreads; or
0 for dictSize.
For compression, (dictSize * 11.5 + 6 MB) + state_size is required, where state_size = (4 + (1.5 << (lc + lp))) KB. By default (lc=3, lp=0), state_size = 16 KB.
There is a demonstration of the usage of compression and decompression in the demo folder:
A demonstration involving the parsing and extraction from a 7-Zip file created in Windows is in the demo folder:
2014/11/07 Initial version.