1 /* LzmaLib.h -- LZMA library interface
2 2013-01-18 : Igor Pavlov : Public domain */
11 #define MY_STDAPI int MY_STD_CALL
13 #define LZMA_PROPS_SIZE 5
16 RAM requirements for LZMA:
17 for compression: (dictSize * 11.5 + 6 MB) + state_size
18 for decompression: dictSize + state_size
19 state_size = (4 + (1.5 << (lc + lp))) KB
20 by default (lc=3, lp=0), state_size = 16 KB.
22 LZMA properties (5 bytes) format
23 Offset Size Description
24 0 1 lc, lp and pb in encoded form.
25 1 4 dictSize (little endian).
33 In: the pointer to the size of outProps buffer; *outPropsSize = LZMA_PROPS_SIZE = 5.
34 Out: the pointer to the size of written properties in outProps buffer; *outPropsSize = LZMA_PROPS_SIZE = 5.
36 LZMA Encoder will use defult values for any parameter, if it is
37 -1 for any from: level, loc, lp, pb, fb, numThreads
40 level - compression level: 0 <= level <= 9;
42 level dictSize algo fb
52 The default value for "level" is 5.
54 algo = 0 means fast method
55 algo = 1 means normal method
57 dictSize - The dictionary size in bytes. The maximum value is
58 128 MB = (1 << 27) bytes for 32-bit version
59 1 GB = (1 << 30) bytes for 64-bit version
60 The default value is 16 MB = (1 << 24) bytes.
61 It's recommended to use the dictionary that is larger than 4 KB and
62 that can be calculated as (1 << N) or (3 << N) sizes.
64 lc - The number of literal context bits (high bits of previous literal).
65 It can be in the range from 0 to 8. The default value is 3.
66 Sometimes lc=4 gives the gain for big files.
68 lp - The number of literal pos bits (low bits of current position for literals).
69 It can be in the range from 0 to 4. The default value is 0.
70 The lp switch is intended for periodical data when the period is equal to 2^lp.
71 For example, for 32-bit (4 bytes) periodical data you can use lp=2. Often it's
72 better to set lc=0, if you change lp switch.
74 pb - The number of pos bits (low bits of current position).
75 It can be in the range from 0 to 4. The default value is 2.
76 The pb switch is intended for periodical data when the period is equal 2^pb.
78 fb - Word size (the number of fast bytes).
79 It can be in the range from 5 to 273. The default value is 32.
80 Usually, a big number gives a little bit better compression ratio and
81 slower compression process.
83 numThreads - The number of thereads. 1 or 2. The default value is 2.
84 Fast mode (algo = 0) can use only 1 thread.
87 destLen - processed output size
90 SZ_ERROR_MEM - Memory allocation error
91 SZ_ERROR_PARAM - Incorrect paramater
92 SZ_ERROR_OUTPUT_EOF - output buffer overflow
93 SZ_ERROR_THREAD - errors in multithreading functions (only for Mt version)
96 MY_STDAPI
LzmaCompress(unsigned char *dest
, size_t *destLen
, const unsigned char *src
, size_t srcLen
,
97 unsigned char *outProps
, size_t *outPropsSize
, /* *outPropsSize must be = 5 */
98 int level
, /* 0 <= level <= 9, default = 5 */
99 unsigned dictSize
, /* default = (1 << 24) */
100 int lc
, /* 0 <= lc <= 8, default = 3 */
101 int lp
, /* 0 <= lp <= 4, default = 0 */
102 int pb
, /* 0 <= pb <= 4, default = 2 */
103 int fb
, /* 5 <= fb <= 273, default = 32 */
104 int numThreads
/* 1 or 2, default = 2 */
112 destLen - output data size
114 srcLen - input data size
116 destLen - processed output size
117 srcLen - processed input size
120 SZ_ERROR_DATA - Data error
121 SZ_ERROR_MEM - Memory allocation arror
122 SZ_ERROR_UNSUPPORTED - Unsupported properties
123 SZ_ERROR_INPUT_EOF - it needs more bytes in input buffer (src)
126 MY_STDAPI
LzmaUncompress(unsigned char *dest
, size_t *destLen
, const unsigned char *src
, SizeT
*srcLen
,
127 const unsigned char *props
, size_t propsSize
);