/* LzmaLib.h -- LZMA library interface12023-04-02 : Igor Pavlov : Public domain */23#ifndef ZIP7_INC_LZMA_LIB_H4#define ZIP7_INC_LZMA_LIB_H56#include "7zTypes.h"78EXTERN_C_BEGIN910#define Z7_STDAPI int Z7_STDCALL1112#define LZMA_PROPS_SIZE 51314/*15RAM requirements for LZMA:16for compression: (dictSize * 11.5 + 6 MB) + state_size17for decompression: dictSize + state_size18state_size = (4 + (1.5 << (lc + lp))) KB19by default (lc=3, lp=0), state_size = 16 KB.2021LZMA properties (5 bytes) format22Offset Size Description230 1 lc, lp and pb in encoded form.241 4 dictSize (little endian).25*/2627/*28LzmaCompress29------------3031outPropsSize -32In: the pointer to the size of outProps buffer; *outPropsSize = LZMA_PROPS_SIZE = 5.33Out: the pointer to the size of written properties in outProps buffer; *outPropsSize = LZMA_PROPS_SIZE = 5.3435LZMA Encoder will use defult values for any parameter, if it is36-1 for any from: level, loc, lp, pb, fb, numThreads370 for dictSize3839level - compression level: 0 <= level <= 9;4041level dictSize algo fb420: 64 KB 0 32431: 256 KB 0 32442: 1 MB 0 32453: 4 MB 0 32464: 16 MB 0 32475: 16 MB 1 32486: 32 MB 1 32497: 32 MB 1 64508: 64 MB 1 64519: 64 MB 1 645253The default value for "level" is 5.5455algo = 0 means fast method56algo = 1 means normal method5758dictSize - The dictionary size in bytes. The maximum value is59128 MB = (1 << 27) bytes for 32-bit version601 GB = (1 << 30) bytes for 64-bit version61The default value is 16 MB = (1 << 24) bytes.62It's recommended to use the dictionary that is larger than 4 KB and63that can be calculated as (1 << N) or (3 << N) sizes.6465lc - The number of literal context bits (high bits of previous literal).66It can be in the range from 0 to 8. The default value is 3.67Sometimes lc=4 gives the gain for big files.6869lp - The number of literal pos bits (low bits of current position for literals).70It can be in the range from 0 to 4. The default value is 0.71The lp switch is intended for periodical data when the period is equal to 2^lp.72For example, for 32-bit (4 bytes) periodical data you can use lp=2. Often it's73better to set lc=0, if you change lp switch.7475pb - The number of pos bits (low bits of current position).76It can be in the range from 0 to 4. The default value is 2.77The pb switch is intended for periodical data when the period is equal 2^pb.7879fb - Word size (the number of fast bytes).80It can be in the range from 5 to 273. The default value is 32.81Usually, a big number gives a little bit better compression ratio and82slower compression process.8384numThreads - The number of thereads. 1 or 2. The default value is 2.85Fast mode (algo = 0) can use only 1 thread.8687In:88dest - output data buffer89destLen - output data buffer size90src - input data91srcLen - input data size92Out:93destLen - processed output size94Returns:95SZ_OK - OK96SZ_ERROR_MEM - Memory allocation error97SZ_ERROR_PARAM - Incorrect paramater98SZ_ERROR_OUTPUT_EOF - output buffer overflow99SZ_ERROR_THREAD - errors in multithreading functions (only for Mt version)100*/101102Z7_STDAPI LzmaCompress(unsigned char *dest, size_t *destLen, const unsigned char *src, size_t srcLen,103unsigned char *outProps, size_t *outPropsSize, /* *outPropsSize must be = 5 */104int level, /* 0 <= level <= 9, default = 5 */105unsigned dictSize, /* default = (1 << 24) */106int lc, /* 0 <= lc <= 8, default = 3 */107int lp, /* 0 <= lp <= 4, default = 0 */108int pb, /* 0 <= pb <= 4, default = 2 */109int fb, /* 5 <= fb <= 273, default = 32 */110int numThreads /* 1 or 2, default = 2 */111);112113/*114LzmaUncompress115--------------116In:117dest - output data buffer118destLen - output data buffer size119src - input data120srcLen - input data size121Out:122destLen - processed output size123srcLen - processed input size124Returns:125SZ_OK - OK126SZ_ERROR_DATA - Data error127SZ_ERROR_MEM - Memory allocation arror128SZ_ERROR_UNSUPPORTED - Unsupported properties129SZ_ERROR_INPUT_EOF - it needs more bytes in input buffer (src)130*/131132Z7_STDAPI LzmaUncompress(unsigned char *dest, size_t *destLen, const unsigned char *src, SizeT *srcLen,133const unsigned char *props, size_t propsSize);134135EXTERN_C_END136137#endif138139140