goat3d
diff libs/openctm/liblzma/LzmaLib.h @ 14:188c697b3b49
- added a document describing the goat3d file format chunk hierarchy
- started an alternative XML-based file format
- added the openctm library
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Thu, 26 Sep 2013 04:47:05 +0300 |
parents | |
children |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/libs/openctm/liblzma/LzmaLib.h Thu Sep 26 04:47:05 2013 +0300 1.3 @@ -0,0 +1,136 @@ 1.4 +/* LzmaLib.h -- LZMA library interface 1.5 +2008-08-05 1.6 +Igor Pavlov 1.7 +Public domain */ 1.8 + 1.9 +#ifndef __LZMALIB_H 1.10 +#define __LZMALIB_H 1.11 + 1.12 +#include "Types.h" 1.13 + 1.14 +#ifdef __cplusplus 1.15 + #define MY_EXTERN_C extern "C" 1.16 +#else 1.17 + #define MY_EXTERN_C extern 1.18 +#endif 1.19 + 1.20 +#define MY_STDAPI MY_EXTERN_C int MY_STD_CALL 1.21 + 1.22 +#define LZMA_PROPS_SIZE 5 1.23 + 1.24 +/* 1.25 +RAM requirements for LZMA: 1.26 + for compression: (dictSize * 11.5 + 6 MB) + state_size 1.27 + for decompression: dictSize + state_size 1.28 + state_size = (4 + (1.5 << (lc + lp))) KB 1.29 + by default (lc=3, lp=0), state_size = 16 KB. 1.30 + 1.31 +LZMA properties (5 bytes) format 1.32 + Offset Size Description 1.33 + 0 1 lc, lp and pb in encoded form. 1.34 + 1 4 dictSize (little endian). 1.35 +*/ 1.36 + 1.37 +/* 1.38 +LzmaCompress 1.39 +------------ 1.40 + 1.41 +outPropsSize - 1.42 + In: the pointer to the size of outProps buffer; *outPropsSize = LZMA_PROPS_SIZE = 5. 1.43 + Out: the pointer to the size of written properties in outProps buffer; *outPropsSize = LZMA_PROPS_SIZE = 5. 1.44 + 1.45 + LZMA Encoder will use defult values for any parameter, if it is 1.46 + -1 for any from: level, loc, lp, pb, fb, numThreads 1.47 + 0 for dictSize 1.48 + 1.49 +level - compression level: 0 <= level <= 9; 1.50 + 1.51 + level dictSize algo fb 1.52 + 0: 16 KB 0 32 1.53 + 1: 64 KB 0 32 1.54 + 2: 256 KB 0 32 1.55 + 3: 1 MB 0 32 1.56 + 4: 4 MB 0 32 1.57 + 5: 16 MB 1 32 1.58 + 6: 32 MB 1 32 1.59 + 7+: 64 MB 1 64 1.60 + 1.61 + The default value for "level" is 5. 1.62 + 1.63 + algo = 0 means fast method 1.64 + algo = 1 means normal method 1.65 + 1.66 +dictSize - The dictionary size in bytes. The maximum value is 1.67 + 128 MB = (1 << 27) bytes for 32-bit version 1.68 + 1 GB = (1 << 30) bytes for 64-bit version 1.69 + The default value is 16 MB = (1 << 24) bytes. 1.70 + It's recommended to use the dictionary that is larger than 4 KB and 1.71 + that can be calculated as (1 << N) or (3 << N) sizes. 1.72 + 1.73 +lc - The number of literal context bits (high bits of previous literal). 1.74 + It can be in the range from 0 to 8. The default value is 3. 1.75 + Sometimes lc=4 gives the gain for big files. 1.76 + 1.77 +lp - The number of literal pos bits (low bits of current position for literals). 1.78 + It can be in the range from 0 to 4. The default value is 0. 1.79 + The lp switch is intended for periodical data when the period is equal to 2^lp. 1.80 + For example, for 32-bit (4 bytes) periodical data you can use lp=2. Often it's 1.81 + better to set lc=0, if you change lp switch. 1.82 + 1.83 +pb - The number of pos bits (low bits of current position). 1.84 + It can be in the range from 0 to 4. The default value is 2. 1.85 + The pb switch is intended for periodical data when the period is equal 2^pb. 1.86 + 1.87 +fb - Word size (the number of fast bytes). 1.88 + It can be in the range from 5 to 273. The default value is 32. 1.89 + Usually, a big number gives a little bit better compression ratio and 1.90 + slower compression process. 1.91 + 1.92 +numThreads - The number of thereads. 1 or 2. The default value is 2. 1.93 + Fast mode (algo = 0) can use only 1 thread. 1.94 + 1.95 +Out: 1.96 + destLen - processed output size 1.97 +Returns: 1.98 + SZ_OK - OK 1.99 + SZ_ERROR_MEM - Memory allocation error 1.100 + SZ_ERROR_PARAM - Incorrect paramater 1.101 + SZ_ERROR_OUTPUT_EOF - output buffer overflow 1.102 + SZ_ERROR_THREAD - errors in multithreading functions (only for Mt version) 1.103 +*/ 1.104 + 1.105 +MY_STDAPI LzmaCompress(unsigned char *dest, size_t *destLen, const unsigned char *src, size_t srcLen, 1.106 + unsigned char *outProps, size_t *outPropsSize, /* *outPropsSize must be = 5 */ 1.107 + int level, /* 0 <= level <= 9, default = 5 */ 1.108 + unsigned dictSize, /* default = (1 << 24) */ 1.109 + int lc, /* 0 <= lc <= 8, default = 3 */ 1.110 + int lp, /* 0 <= lp <= 4, default = 0 */ 1.111 + int pb, /* 0 <= pb <= 4, default = 2 */ 1.112 + int fb, /* 5 <= fb <= 273, default = 32 */ 1.113 + int numThreads, /* 1 or 2, default = 2 */ 1.114 + int algo /* 0 = fast, 1 = normal, default = 0 for level < 5, 1 for level >= 5 */ 1.115 + ); 1.116 + 1.117 +/* 1.118 +LzmaUncompress 1.119 +-------------- 1.120 +In: 1.121 + dest - output data 1.122 + destLen - output data size 1.123 + src - input data 1.124 + srcLen - input data size 1.125 +Out: 1.126 + destLen - processed output size 1.127 + srcLen - processed input size 1.128 +Returns: 1.129 + SZ_OK - OK 1.130 + SZ_ERROR_DATA - Data error 1.131 + SZ_ERROR_MEM - Memory allocation arror 1.132 + SZ_ERROR_UNSUPPORTED - Unsupported properties 1.133 + SZ_ERROR_INPUT_EOF - it needs more bytes in input buffer (src) 1.134 +*/ 1.135 + 1.136 +MY_STDAPI LzmaUncompress(unsigned char *dest, size_t *destLen, const unsigned char *src, SizeT *srcLen, 1.137 + const unsigned char *props, size_t propsSize); 1.138 + 1.139 +#endif