goat3d

annotate libs/openctm/liblzma/LzmaLib.h @ 49:0ecb788a87f7

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