Blame | Last modification | View Log | RSS feed
/* LzmaLib.h -- LZMA library interface2008-08-05Igor PavlovPublic domain */#ifndef __LZMALIB_H#define __LZMALIB_H#include "Types.h"#ifdef __cplusplus#define MY_EXTERN_C extern "C"#else#define MY_EXTERN_C extern#endif#define MY_STDAPI MY_EXTERN_C int MY_STD_CALL#define LZMA_PROPS_SIZE 5/*RAM requirements for LZMA:for compression: (dictSize * 11.5 + 6 MB) + state_sizefor decompression: dictSize + state_sizestate_size = (4 + (1.5 << (lc + lp))) KBby default (lc=3, lp=0), state_size = 16 KB.LZMA properties (5 bytes) formatOffset Size Description0 1 lc, lp and pb in encoded form.1 4 dictSize (little endian).*//*LzmaCompress------------outPropsSize -In: the pointer to the size of outProps buffer; *outPropsSize = LZMA_PROPS_SIZE = 5.Out: the pointer to the size of written properties in outProps buffer; *outPropsSize = LZMA_PROPS_SIZE = 5.LZMA Encoder will use defult values for any parameter, if it is-1 for any from: level, loc, lp, pb, fb, numThreads0 for dictSizelevel - compression level: 0 <= level <= 9;level dictSize algo fb0: 16 KB 0 321: 64 KB 0 322: 256 KB 0 323: 1 MB 0 324: 4 MB 0 325: 16 MB 1 326: 32 MB 1 327+: 64 MB 1 64The default value for "level" is 5.algo = 0 means fast methodalgo = 1 means normal methoddictSize - The dictionary size in bytes. The maximum value is128 MB = (1 << 27) bytes for 32-bit version1 GB = (1 << 30) bytes for 64-bit versionThe default value is 16 MB = (1 << 24) bytes.It's recommended to use the dictionary that is larger than 4 KB andthat 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.Sometimes lc=4 gives 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'sbetter 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 gives a little bit better compression ratio andslower compression process.numThreads - The number of thereads. 1 or 2. The default value is 2.Fast mode (algo = 0) can use only 1 thread.Out:destLen - processed output sizeReturns:SZ_OK - OKSZ_ERROR_MEM - Memory allocation errorSZ_ERROR_PARAM - Incorrect paramaterSZ_ERROR_OUTPUT_EOF - output buffer overflowSZ_ERROR_THREAD - errors in multithreading functions (only for Mt version)*/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 */);/*LzmaUncompress--------------In:dest - output datadestLen - output data sizesrc - input datasrcLen - input data sizeOut:destLen - processed output sizesrcLen - processed input sizeReturns:SZ_OK - OKSZ_ERROR_DATA - Data errorSZ_ERROR_MEM - Memory allocation arrorSZ_ERROR_UNSUPPORTED - Unsupported propertiesSZ_ERROR_INPUT_EOF - it needs more bytes in input buffer (src)*/MY_STDAPI LzmaUncompress(unsigned char *dest, size_t *destLen, const unsigned char *src, SizeT *srcLen,const unsigned char *props, size_t propsSize);#endif