diff options
author | David Walter Seikel | 2013-01-13 18:54:10 +1000 |
---|---|---|
committer | David Walter Seikel | 2013-01-13 18:54:10 +1000 |
commit | 959831f4ef5a3e797f576c3de08cd65032c997ad (patch) | |
tree | e7351908be5995f0b325b2ebeaa02d5a34b82583 /libraries/irrlicht-1.8/source/Irrlicht/lzma/LzmaDec.h | |
parent | Add info about changes to Irrlicht. (diff) | |
download | SledjHamr-959831f4ef5a3e797f576c3de08cd65032c997ad.zip SledjHamr-959831f4ef5a3e797f576c3de08cd65032c997ad.tar.gz SledjHamr-959831f4ef5a3e797f576c3de08cd65032c997ad.tar.bz2 SledjHamr-959831f4ef5a3e797f576c3de08cd65032c997ad.tar.xz |
Remove damned ancient DOS line endings from Irrlicht. Hopefully I did not go overboard.
Diffstat (limited to 'libraries/irrlicht-1.8/source/Irrlicht/lzma/LzmaDec.h')
-rw-r--r-- | libraries/irrlicht-1.8/source/Irrlicht/lzma/LzmaDec.h | 462 |
1 files changed, 231 insertions, 231 deletions
diff --git a/libraries/irrlicht-1.8/source/Irrlicht/lzma/LzmaDec.h b/libraries/irrlicht-1.8/source/Irrlicht/lzma/LzmaDec.h index 6741a64..bf7f084 100644 --- a/libraries/irrlicht-1.8/source/Irrlicht/lzma/LzmaDec.h +++ b/libraries/irrlicht-1.8/source/Irrlicht/lzma/LzmaDec.h | |||
@@ -1,231 +1,231 @@ | |||
1 | /* LzmaDec.h -- LZMA Decoder | 1 | /* LzmaDec.h -- LZMA Decoder |
2 | 2009-02-07 : Igor Pavlov : Public domain */ | 2 | 2009-02-07 : Igor Pavlov : Public domain */ |
3 | 3 | ||
4 | #ifndef __LZMA_DEC_H | 4 | #ifndef __LZMA_DEC_H |
5 | #define __LZMA_DEC_H | 5 | #define __LZMA_DEC_H |
6 | 6 | ||
7 | #include "Types.h" | 7 | #include "Types.h" |
8 | 8 | ||
9 | #ifdef __cplusplus | 9 | #ifdef __cplusplus |
10 | extern "C" { | 10 | extern "C" { |
11 | #endif | 11 | #endif |
12 | 12 | ||
13 | /* #define _LZMA_PROB32 */ | 13 | /* #define _LZMA_PROB32 */ |
14 | /* _LZMA_PROB32 can increase the speed on some CPUs, | 14 | /* _LZMA_PROB32 can increase the speed on some CPUs, |
15 | but memory usage for CLzmaDec::probs will be doubled in that case */ | 15 | but memory usage for CLzmaDec::probs will be doubled in that case */ |
16 | 16 | ||
17 | #ifdef _LZMA_PROB32 | 17 | #ifdef _LZMA_PROB32 |
18 | #define CLzmaProb UInt32 | 18 | #define CLzmaProb UInt32 |
19 | #else | 19 | #else |
20 | #define CLzmaProb UInt16 | 20 | #define CLzmaProb UInt16 |
21 | #endif | 21 | #endif |
22 | 22 | ||
23 | 23 | ||
24 | /* ---------- LZMA Properties ---------- */ | 24 | /* ---------- LZMA Properties ---------- */ |
25 | 25 | ||
26 | #define LZMA_PROPS_SIZE 5 | 26 | #define LZMA_PROPS_SIZE 5 |
27 | 27 | ||
28 | typedef struct _CLzmaProps | 28 | typedef struct _CLzmaProps |
29 | { | 29 | { |
30 | unsigned lc, lp, pb; | 30 | unsigned lc, lp, pb; |
31 | UInt32 dicSize; | 31 | UInt32 dicSize; |
32 | } CLzmaProps; | 32 | } CLzmaProps; |
33 | 33 | ||
34 | /* LzmaProps_Decode - decodes properties | 34 | /* LzmaProps_Decode - decodes properties |
35 | Returns: | 35 | Returns: |
36 | SZ_OK | 36 | SZ_OK |
37 | SZ_ERROR_UNSUPPORTED - Unsupported properties | 37 | SZ_ERROR_UNSUPPORTED - Unsupported properties |
38 | */ | 38 | */ |
39 | 39 | ||
40 | SRes LzmaProps_Decode(CLzmaProps *p, const Byte *data, unsigned size); | 40 | SRes LzmaProps_Decode(CLzmaProps *p, const Byte *data, unsigned size); |
41 | 41 | ||
42 | 42 | ||
43 | /* ---------- LZMA Decoder state ---------- */ | 43 | /* ---------- LZMA Decoder state ---------- */ |
44 | 44 | ||
45 | /* LZMA_REQUIRED_INPUT_MAX = number of required input bytes for worst case. | 45 | /* LZMA_REQUIRED_INPUT_MAX = number of required input bytes for worst case. |
46 | Num bits = log2((2^11 / 31) ^ 22) + 26 < 134 + 26 = 160; */ | 46 | Num bits = log2((2^11 / 31) ^ 22) + 26 < 134 + 26 = 160; */ |
47 | 47 | ||
48 | #define LZMA_REQUIRED_INPUT_MAX 20 | 48 | #define LZMA_REQUIRED_INPUT_MAX 20 |
49 | 49 | ||
50 | typedef struct | 50 | typedef struct |
51 | { | 51 | { |
52 | CLzmaProps prop; | 52 | CLzmaProps prop; |
53 | CLzmaProb *probs; | 53 | CLzmaProb *probs; |
54 | Byte *dic; | 54 | Byte *dic; |
55 | const Byte *buf; | 55 | const Byte *buf; |
56 | UInt32 range, code; | 56 | UInt32 range, code; |
57 | SizeT dicPos; | 57 | SizeT dicPos; |
58 | SizeT dicBufSize; | 58 | SizeT dicBufSize; |
59 | UInt32 processedPos; | 59 | UInt32 processedPos; |
60 | UInt32 checkDicSize; | 60 | UInt32 checkDicSize; |
61 | unsigned state; | 61 | unsigned state; |
62 | UInt32 reps[4]; | 62 | UInt32 reps[4]; |
63 | unsigned remainLen; | 63 | unsigned remainLen; |
64 | int needFlush; | 64 | int needFlush; |
65 | int needInitState; | 65 | int needInitState; |
66 | UInt32 numProbs; | 66 | UInt32 numProbs; |
67 | unsigned tempBufSize; | 67 | unsigned tempBufSize; |
68 | Byte tempBuf[LZMA_REQUIRED_INPUT_MAX]; | 68 | Byte tempBuf[LZMA_REQUIRED_INPUT_MAX]; |
69 | } CLzmaDec; | 69 | } CLzmaDec; |
70 | 70 | ||
71 | #define LzmaDec_Construct(p) { (p)->dic = 0; (p)->probs = 0; } | 71 | #define LzmaDec_Construct(p) { (p)->dic = 0; (p)->probs = 0; } |
72 | 72 | ||
73 | void LzmaDec_Init(CLzmaDec *p); | 73 | void LzmaDec_Init(CLzmaDec *p); |
74 | 74 | ||
75 | /* There are two types of LZMA streams: | 75 | /* There are two types of LZMA streams: |
76 | 0) Stream with end mark. That end mark adds about 6 bytes to compressed size. | 76 | 0) Stream with end mark. That end mark adds about 6 bytes to compressed size. |
77 | 1) Stream without end mark. You must know exact uncompressed size to decompress such stream. */ | 77 | 1) Stream without end mark. You must know exact uncompressed size to decompress such stream. */ |
78 | 78 | ||
79 | typedef enum | 79 | typedef enum |
80 | { | 80 | { |
81 | LZMA_FINISH_ANY, /* finish at any point */ | 81 | LZMA_FINISH_ANY, /* finish at any point */ |
82 | LZMA_FINISH_END /* block must be finished at the end */ | 82 | LZMA_FINISH_END /* block must be finished at the end */ |
83 | } ELzmaFinishMode; | 83 | } ELzmaFinishMode; |
84 | 84 | ||
85 | /* ELzmaFinishMode has meaning only if the decoding reaches output limit !!! | 85 | /* ELzmaFinishMode has meaning only if the decoding reaches output limit !!! |
86 | 86 | ||
87 | You must use LZMA_FINISH_END, when you know that current output buffer | 87 | You must use LZMA_FINISH_END, when you know that current output buffer |
88 | covers last bytes of block. In other cases you must use LZMA_FINISH_ANY. | 88 | covers last bytes of block. In other cases you must use LZMA_FINISH_ANY. |
89 | 89 | ||
90 | If LZMA decoder sees end marker before reaching output limit, it returns SZ_OK, | 90 | If LZMA decoder sees end marker before reaching output limit, it returns SZ_OK, |
91 | and output value of destLen will be less than output buffer size limit. | 91 | and output value of destLen will be less than output buffer size limit. |
92 | You can check status result also. | 92 | You can check status result also. |
93 | 93 | ||
94 | You can use multiple checks to test data integrity after full decompression: | 94 | You can use multiple checks to test data integrity after full decompression: |
95 | 1) Check Result and "status" variable. | 95 | 1) Check Result and "status" variable. |
96 | 2) Check that output(destLen) = uncompressedSize, if you know real uncompressedSize. | 96 | 2) Check that output(destLen) = uncompressedSize, if you know real uncompressedSize. |
97 | 3) Check that output(srcLen) = compressedSize, if you know real compressedSize. | 97 | 3) Check that output(srcLen) = compressedSize, if you know real compressedSize. |
98 | You must use correct finish mode in that case. */ | 98 | You must use correct finish mode in that case. */ |
99 | 99 | ||
100 | typedef enum | 100 | typedef enum |
101 | { | 101 | { |
102 | LZMA_STATUS_NOT_SPECIFIED, /* use main error code instead */ | 102 | LZMA_STATUS_NOT_SPECIFIED, /* use main error code instead */ |
103 | LZMA_STATUS_FINISHED_WITH_MARK, /* stream was finished with end mark. */ | 103 | LZMA_STATUS_FINISHED_WITH_MARK, /* stream was finished with end mark. */ |
104 | LZMA_STATUS_NOT_FINISHED, /* stream was not finished */ | 104 | LZMA_STATUS_NOT_FINISHED, /* stream was not finished */ |
105 | LZMA_STATUS_NEEDS_MORE_INPUT, /* you must provide more input bytes */ | 105 | LZMA_STATUS_NEEDS_MORE_INPUT, /* you must provide more input bytes */ |
106 | LZMA_STATUS_MAYBE_FINISHED_WITHOUT_MARK /* there is probability that stream was finished without end mark */ | 106 | LZMA_STATUS_MAYBE_FINISHED_WITHOUT_MARK /* there is probability that stream was finished without end mark */ |
107 | } ELzmaStatus; | 107 | } ELzmaStatus; |
108 | 108 | ||
109 | /* ELzmaStatus is used only as output value for function call */ | 109 | /* ELzmaStatus is used only as output value for function call */ |
110 | 110 | ||
111 | 111 | ||
112 | /* ---------- Interfaces ---------- */ | 112 | /* ---------- Interfaces ---------- */ |
113 | 113 | ||
114 | /* There are 3 levels of interfaces: | 114 | /* There are 3 levels of interfaces: |
115 | 1) Dictionary Interface | 115 | 1) Dictionary Interface |
116 | 2) Buffer Interface | 116 | 2) Buffer Interface |
117 | 3) One Call Interface | 117 | 3) One Call Interface |
118 | You can select any of these interfaces, but don't mix functions from different | 118 | You can select any of these interfaces, but don't mix functions from different |
119 | groups for same object. */ | 119 | groups for same object. */ |
120 | 120 | ||
121 | 121 | ||
122 | /* There are two variants to allocate state for Dictionary Interface: | 122 | /* There are two variants to allocate state for Dictionary Interface: |
123 | 1) LzmaDec_Allocate / LzmaDec_Free | 123 | 1) LzmaDec_Allocate / LzmaDec_Free |
124 | 2) LzmaDec_AllocateProbs / LzmaDec_FreeProbs | 124 | 2) LzmaDec_AllocateProbs / LzmaDec_FreeProbs |
125 | You can use variant 2, if you set dictionary buffer manually. | 125 | You can use variant 2, if you set dictionary buffer manually. |
126 | For Buffer Interface you must always use variant 1. | 126 | For Buffer Interface you must always use variant 1. |
127 | 127 | ||
128 | LzmaDec_Allocate* can return: | 128 | LzmaDec_Allocate* can return: |
129 | SZ_OK | 129 | SZ_OK |
130 | SZ_ERROR_MEM - Memory allocation error | 130 | SZ_ERROR_MEM - Memory allocation error |
131 | SZ_ERROR_UNSUPPORTED - Unsupported properties | 131 | SZ_ERROR_UNSUPPORTED - Unsupported properties |
132 | */ | 132 | */ |
133 | 133 | ||
134 | SRes LzmaDec_AllocateProbs(CLzmaDec *p, const Byte *props, unsigned propsSize, ISzAlloc *alloc); | 134 | SRes LzmaDec_AllocateProbs(CLzmaDec *p, const Byte *props, unsigned propsSize, ISzAlloc *alloc); |
135 | void LzmaDec_FreeProbs(CLzmaDec *p, ISzAlloc *alloc); | 135 | void LzmaDec_FreeProbs(CLzmaDec *p, ISzAlloc *alloc); |
136 | 136 | ||
137 | SRes LzmaDec_Allocate(CLzmaDec *state, const Byte *prop, unsigned propsSize, ISzAlloc *alloc); | 137 | SRes LzmaDec_Allocate(CLzmaDec *state, const Byte *prop, unsigned propsSize, ISzAlloc *alloc); |
138 | void LzmaDec_Free(CLzmaDec *state, ISzAlloc *alloc); | 138 | void LzmaDec_Free(CLzmaDec *state, ISzAlloc *alloc); |
139 | 139 | ||
140 | /* ---------- Dictionary Interface ---------- */ | 140 | /* ---------- Dictionary Interface ---------- */ |
141 | 141 | ||
142 | /* You can use it, if you want to eliminate the overhead for data copying from | 142 | /* You can use it, if you want to eliminate the overhead for data copying from |
143 | dictionary to some other external buffer. | 143 | dictionary to some other external buffer. |
144 | You must work with CLzmaDec variables directly in this interface. | 144 | You must work with CLzmaDec variables directly in this interface. |
145 | 145 | ||
146 | STEPS: | 146 | STEPS: |
147 | LzmaDec_Constr() | 147 | LzmaDec_Constr() |
148 | LzmaDec_Allocate() | 148 | LzmaDec_Allocate() |
149 | for (each new stream) | 149 | for (each new stream) |
150 | { | 150 | { |
151 | LzmaDec_Init() | 151 | LzmaDec_Init() |
152 | while (it needs more decompression) | 152 | while (it needs more decompression) |
153 | { | 153 | { |
154 | LzmaDec_DecodeToDic() | 154 | LzmaDec_DecodeToDic() |
155 | use data from CLzmaDec::dic and update CLzmaDec::dicPos | 155 | use data from CLzmaDec::dic and update CLzmaDec::dicPos |
156 | } | 156 | } |
157 | } | 157 | } |
158 | LzmaDec_Free() | 158 | LzmaDec_Free() |
159 | */ | 159 | */ |
160 | 160 | ||
161 | /* LzmaDec_DecodeToDic | 161 | /* LzmaDec_DecodeToDic |
162 | 162 | ||
163 | The decoding to internal dictionary buffer (CLzmaDec::dic). | 163 | The decoding to internal dictionary buffer (CLzmaDec::dic). |
164 | You must manually update CLzmaDec::dicPos, if it reaches CLzmaDec::dicBufSize !!! | 164 | You must manually update CLzmaDec::dicPos, if it reaches CLzmaDec::dicBufSize !!! |
165 | 165 | ||
166 | finishMode: | 166 | finishMode: |
167 | It has meaning only if the decoding reaches output limit (dicLimit). | 167 | It has meaning only if the decoding reaches output limit (dicLimit). |
168 | LZMA_FINISH_ANY - Decode just dicLimit bytes. | 168 | LZMA_FINISH_ANY - Decode just dicLimit bytes. |
169 | LZMA_FINISH_END - Stream must be finished after dicLimit. | 169 | LZMA_FINISH_END - Stream must be finished after dicLimit. |
170 | 170 | ||
171 | Returns: | 171 | Returns: |
172 | SZ_OK | 172 | SZ_OK |
173 | status: | 173 | status: |
174 | LZMA_STATUS_FINISHED_WITH_MARK | 174 | LZMA_STATUS_FINISHED_WITH_MARK |
175 | LZMA_STATUS_NOT_FINISHED | 175 | LZMA_STATUS_NOT_FINISHED |
176 | LZMA_STATUS_NEEDS_MORE_INPUT | 176 | LZMA_STATUS_NEEDS_MORE_INPUT |
177 | LZMA_STATUS_MAYBE_FINISHED_WITHOUT_MARK | 177 | LZMA_STATUS_MAYBE_FINISHED_WITHOUT_MARK |
178 | SZ_ERROR_DATA - Data error | 178 | SZ_ERROR_DATA - Data error |
179 | */ | 179 | */ |
180 | 180 | ||
181 | SRes LzmaDec_DecodeToDic(CLzmaDec *p, SizeT dicLimit, | 181 | SRes LzmaDec_DecodeToDic(CLzmaDec *p, SizeT dicLimit, |
182 | const Byte *src, SizeT *srcLen, ELzmaFinishMode finishMode, ELzmaStatus *status); | 182 | const Byte *src, SizeT *srcLen, ELzmaFinishMode finishMode, ELzmaStatus *status); |
183 | 183 | ||
184 | 184 | ||
185 | /* ---------- Buffer Interface ---------- */ | 185 | /* ---------- Buffer Interface ---------- */ |
186 | 186 | ||
187 | /* It's zlib-like interface. | 187 | /* It's zlib-like interface. |
188 | See LzmaDec_DecodeToDic description for information about STEPS and return results, | 188 | See LzmaDec_DecodeToDic description for information about STEPS and return results, |
189 | but you must use LzmaDec_DecodeToBuf instead of LzmaDec_DecodeToDic and you don't need | 189 | but you must use LzmaDec_DecodeToBuf instead of LzmaDec_DecodeToDic and you don't need |
190 | to work with CLzmaDec variables manually. | 190 | to work with CLzmaDec variables manually. |
191 | 191 | ||
192 | finishMode: | 192 | finishMode: |
193 | It has meaning only if the decoding reaches output limit (*destLen). | 193 | It has meaning only if the decoding reaches output limit (*destLen). |
194 | LZMA_FINISH_ANY - Decode just destLen bytes. | 194 | LZMA_FINISH_ANY - Decode just destLen bytes. |
195 | LZMA_FINISH_END - Stream must be finished after (*destLen). | 195 | LZMA_FINISH_END - Stream must be finished after (*destLen). |
196 | */ | 196 | */ |
197 | 197 | ||
198 | SRes LzmaDec_DecodeToBuf(CLzmaDec *p, Byte *dest, SizeT *destLen, | 198 | SRes LzmaDec_DecodeToBuf(CLzmaDec *p, Byte *dest, SizeT *destLen, |
199 | const Byte *src, SizeT *srcLen, ELzmaFinishMode finishMode, ELzmaStatus *status); | 199 | const Byte *src, SizeT *srcLen, ELzmaFinishMode finishMode, ELzmaStatus *status); |
200 | 200 | ||
201 | 201 | ||
202 | /* ---------- One Call Interface ---------- */ | 202 | /* ---------- One Call Interface ---------- */ |
203 | 203 | ||
204 | /* LzmaDecode | 204 | /* LzmaDecode |
205 | 205 | ||
206 | finishMode: | 206 | finishMode: |
207 | It has meaning only if the decoding reaches output limit (*destLen). | 207 | It has meaning only if the decoding reaches output limit (*destLen). |
208 | LZMA_FINISH_ANY - Decode just destLen bytes. | 208 | LZMA_FINISH_ANY - Decode just destLen bytes. |
209 | LZMA_FINISH_END - Stream must be finished after (*destLen). | 209 | LZMA_FINISH_END - Stream must be finished after (*destLen). |
210 | 210 | ||
211 | Returns: | 211 | Returns: |
212 | SZ_OK | 212 | SZ_OK |
213 | status: | 213 | status: |
214 | LZMA_STATUS_FINISHED_WITH_MARK | 214 | LZMA_STATUS_FINISHED_WITH_MARK |
215 | LZMA_STATUS_NOT_FINISHED | 215 | LZMA_STATUS_NOT_FINISHED |
216 | LZMA_STATUS_MAYBE_FINISHED_WITHOUT_MARK | 216 | LZMA_STATUS_MAYBE_FINISHED_WITHOUT_MARK |
217 | SZ_ERROR_DATA - Data error | 217 | SZ_ERROR_DATA - Data error |
218 | SZ_ERROR_MEM - Memory allocation error | 218 | SZ_ERROR_MEM - Memory allocation error |
219 | SZ_ERROR_UNSUPPORTED - Unsupported properties | 219 | SZ_ERROR_UNSUPPORTED - Unsupported properties |
220 | SZ_ERROR_INPUT_EOF - It needs more bytes in input buffer (src). | 220 | SZ_ERROR_INPUT_EOF - It needs more bytes in input buffer (src). |
221 | */ | 221 | */ |
222 | 222 | ||
223 | SRes LzmaDecode(Byte *dest, SizeT *destLen, const Byte *src, SizeT *srcLen, | 223 | SRes LzmaDecode(Byte *dest, SizeT *destLen, const Byte *src, SizeT *srcLen, |
224 | const Byte *propData, unsigned propSize, ELzmaFinishMode finishMode, | 224 | const Byte *propData, unsigned propSize, ELzmaFinishMode finishMode, |
225 | ELzmaStatus *status, ISzAlloc *alloc); | 225 | ELzmaStatus *status, ISzAlloc *alloc); |
226 | 226 | ||
227 | #ifdef __cplusplus | 227 | #ifdef __cplusplus |
228 | } | 228 | } |
229 | #endif | 229 | #endif |
230 | 230 | ||
231 | #endif | 231 | #endif |