| OLD | NEW |
| (Empty) |
| 1 /* LzmaLib.h -- LZMA library interface | |
| 2 2008-08-05 | |
| 3 Igor Pavlov | |
| 4 Public domain */ | |
| 5 | |
| 6 #ifndef __LZMALIB_H | |
| 7 #define __LZMALIB_H | |
| 8 | |
| 9 #include "Types.h" | |
| 10 | |
| 11 #ifdef __cplusplus | |
| 12 #define MY_EXTERN_C extern "C" | |
| 13 #else | |
| 14 #define MY_EXTERN_C extern | |
| 15 #endif | |
| 16 | |
| 17 #define MY_STDAPI MY_EXTERN_C int MY_STD_CALL | |
| 18 | |
| 19 #define LZMA_PROPS_SIZE 5 | |
| 20 | |
| 21 /* | |
| 22 RAM requirements for LZMA: | |
| 23 for compression: (dictSize * 11.5 + 6 MB) + state_size | |
| 24 for decompression: dictSize + state_size | |
| 25 state_size = (4 + (1.5 << (lc + lp))) KB | |
| 26 by default (lc=3, lp=0), state_size = 16 KB. | |
| 27 | |
| 28 LZMA properties (5 bytes) format | |
| 29 Offset Size Description | |
| 30 0 1 lc, lp and pb in encoded form. | |
| 31 1 4 dictSize (little endian). | |
| 32 */ | |
| 33 | |
| 34 /* | |
| 35 LzmaCompress | |
| 36 ------------ | |
| 37 | |
| 38 outPropsSize - | |
| 39 In: the pointer to the size of outProps buffer; *outPropsSize = LZMA_PROPS
_SIZE = 5. | |
| 40 Out: the pointer to the size of written properties in outProps buffer; *out
PropsSize = LZMA_PROPS_SIZE = 5. | |
| 41 | |
| 42 LZMA Encoder will use defult values for any parameter, if it is | |
| 43 -1 for any from: level, loc, lp, pb, fb, numThreads | |
| 44 0 for dictSize | |
| 45 | |
| 46 level - compression level: 0 <= level <= 9; | |
| 47 | |
| 48 level dictSize algo fb | |
| 49 0: 16 KB 0 32 | |
| 50 1: 64 KB 0 32 | |
| 51 2: 256 KB 0 32 | |
| 52 3: 1 MB 0 32 | |
| 53 4: 4 MB 0 32 | |
| 54 5: 16 MB 1 32 | |
| 55 6: 32 MB 1 32 | |
| 56 7+: 64 MB 1 64 | |
| 57 | |
| 58 The default value for "level" is 5. | |
| 59 | |
| 60 algo = 0 means fast method | |
| 61 algo = 1 means normal method | |
| 62 | |
| 63 dictSize - The dictionary size in bytes. The maximum value is | |
| 64 128 MB = (1 << 27) bytes for 32-bit version | |
| 65 1 GB = (1 << 30) bytes for 64-bit version | |
| 66 The default value is 16 MB = (1 << 24) bytes. | |
| 67 It's recommended to use the dictionary that is larger than 4 KB and | |
| 68 that can be calculated as (1 << N) or (3 << N) sizes. | |
| 69 | |
| 70 lc - The number of literal context bits (high bits of previous literal). | |
| 71 It can be in the range from 0 to 8. The default value is 3. | |
| 72 Sometimes lc=4 gives the gain for big files. | |
| 73 | |
| 74 lp - The number of literal pos bits (low bits of current position for literals). | |
| 75 It can be in the range from 0 to 4. The default value is 0. | |
| 76 The lp switch is intended for periodical data when the period is equal to 2
^lp. | |
| 77 For example, for 32-bit (4 bytes) periodical data you can use lp=2. Often i
t's | |
| 78 better to set lc=0, if you change lp switch. | |
| 79 | |
| 80 pb - The number of pos bits (low bits of current position). | |
| 81 It can be in the range from 0 to 4. The default value is 2. | |
| 82 The pb switch is intended for periodical data when the period is equal 2^pb
. | |
| 83 | |
| 84 fb - Word size (the number of fast bytes). | |
| 85 It can be in the range from 5 to 273. The default value is 32. | |
| 86 Usually, a big number gives a little bit better compression ratio and | |
| 87 slower compression process. | |
| 88 | |
| 89 numThreads - The number of thereads. 1 or 2. The default value is 2. | |
| 90 Fast mode (algo = 0) can use only 1 thread. | |
| 91 | |
| 92 Out: | |
| 93 destLen - processed output size | |
| 94 Returns: | |
| 95 SZ_OK - OK | |
| 96 SZ_ERROR_MEM - Memory allocation error | |
| 97 SZ_ERROR_PARAM - Incorrect paramater | |
| 98 SZ_ERROR_OUTPUT_EOF - output buffer overflow | |
| 99 SZ_ERROR_THREAD - errors in multithreading functions (only for Mt version) | |
| 100 */ | |
| 101 | |
| 102 MY_STDAPI LzmaCompress(unsigned char *dest, size_t *destLen, const unsigned char
*src, size_t srcLen, | |
| 103 unsigned char *outProps, size_t *outPropsSize, /* *outPropsSize must be = 5 */ | |
| 104 int level, /* 0 <= level <= 9, default = 5 */ | |
| 105 unsigned dictSize, /* default = (1 << 24) */ | |
| 106 int lc, /* 0 <= lc <= 8, default = 3 */ | |
| 107 int lp, /* 0 <= lp <= 4, default = 0 */ | |
| 108 int pb, /* 0 <= pb <= 4, default = 2 */ | |
| 109 int fb, /* 5 <= fb <= 273, default = 32 */ | |
| 110 int numThreads /* 1 or 2, default = 2 */ | |
| 111 ); | |
| 112 | |
| 113 /* | |
| 114 LzmaUncompress | |
| 115 -------------- | |
| 116 In: | |
| 117 dest - output data | |
| 118 destLen - output data size | |
| 119 src - input data | |
| 120 srcLen - input data size | |
| 121 Out: | |
| 122 destLen - processed output size | |
| 123 srcLen - processed input size | |
| 124 Returns: | |
| 125 SZ_OK - OK | |
| 126 SZ_ERROR_DATA - Data error | |
| 127 SZ_ERROR_MEM - Memory allocation arror | |
| 128 SZ_ERROR_UNSUPPORTED - Unsupported properties | |
| 129 SZ_ERROR_INPUT_EOF - it needs more bytes in input buffer (src) | |
| 130 */ | |
| 131 | |
| 132 MY_STDAPI LzmaUncompress(unsigned char *dest, size_t *destLen, const unsigned ch
ar *src, SizeT *srcLen, | |
| 133 const unsigned char *props, size_t propsSize); | |
| 134 | |
| 135 #endif | |
| OLD | NEW |