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 | |
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')
-rw-r--r-- | libraries/irrlicht-1.8/source/Irrlicht/lzma/LzmaDec.c | 1998 | ||||
-rw-r--r-- | libraries/irrlicht-1.8/source/Irrlicht/lzma/LzmaDec.h | 462 | ||||
-rw-r--r-- | libraries/irrlicht-1.8/source/Irrlicht/lzma/Types.h | 508 |
3 files changed, 1484 insertions, 1484 deletions
diff --git a/libraries/irrlicht-1.8/source/Irrlicht/lzma/LzmaDec.c b/libraries/irrlicht-1.8/source/Irrlicht/lzma/LzmaDec.c index 4fdc11d..2036761 100644 --- a/libraries/irrlicht-1.8/source/Irrlicht/lzma/LzmaDec.c +++ b/libraries/irrlicht-1.8/source/Irrlicht/lzma/LzmaDec.c | |||
@@ -1,999 +1,999 @@ | |||
1 | /* LzmaDec.c -- LZMA Decoder | 1 | /* LzmaDec.c -- LZMA Decoder |
2 | 2009-09-20 : Igor Pavlov : Public domain */ | 2 | 2009-09-20 : Igor Pavlov : Public domain */ |
3 | 3 | ||
4 | #include "LzmaDec.h" | 4 | #include "LzmaDec.h" |
5 | 5 | ||
6 | #include <string.h> | 6 | #include <string.h> |
7 | 7 | ||
8 | #define kNumTopBits 24 | 8 | #define kNumTopBits 24 |
9 | #define kTopValue ((UInt32)1 << kNumTopBits) | 9 | #define kTopValue ((UInt32)1 << kNumTopBits) |
10 | 10 | ||
11 | #define kNumBitModelTotalBits 11 | 11 | #define kNumBitModelTotalBits 11 |
12 | #define kBitModelTotal (1 << kNumBitModelTotalBits) | 12 | #define kBitModelTotal (1 << kNumBitModelTotalBits) |
13 | #define kNumMoveBits 5 | 13 | #define kNumMoveBits 5 |
14 | 14 | ||
15 | #define RC_INIT_SIZE 5 | 15 | #define RC_INIT_SIZE 5 |
16 | 16 | ||
17 | #define NORMALIZE if (range < kTopValue) { range <<= 8; code = (code << 8) | (*buf++); } | 17 | #define NORMALIZE if (range < kTopValue) { range <<= 8; code = (code << 8) | (*buf++); } |
18 | 18 | ||
19 | #define IF_BIT_0(p) ttt = *(p); NORMALIZE; bound = (range >> kNumBitModelTotalBits) * ttt; if (code < bound) | 19 | #define IF_BIT_0(p) ttt = *(p); NORMALIZE; bound = (range >> kNumBitModelTotalBits) * ttt; if (code < bound) |
20 | #define UPDATE_0(p) range = bound; *(p) = (CLzmaProb)(ttt + ((kBitModelTotal - ttt) >> kNumMoveBits)); | 20 | #define UPDATE_0(p) range = bound; *(p) = (CLzmaProb)(ttt + ((kBitModelTotal - ttt) >> kNumMoveBits)); |
21 | #define UPDATE_1(p) range -= bound; code -= bound; *(p) = (CLzmaProb)(ttt - (ttt >> kNumMoveBits)); | 21 | #define UPDATE_1(p) range -= bound; code -= bound; *(p) = (CLzmaProb)(ttt - (ttt >> kNumMoveBits)); |
22 | #define GET_BIT2(p, i, A0, A1) IF_BIT_0(p) \ | 22 | #define GET_BIT2(p, i, A0, A1) IF_BIT_0(p) \ |
23 | { UPDATE_0(p); i = (i + i); A0; } else \ | 23 | { UPDATE_0(p); i = (i + i); A0; } else \ |
24 | { UPDATE_1(p); i = (i + i) + 1; A1; } | 24 | { UPDATE_1(p); i = (i + i) + 1; A1; } |
25 | #define GET_BIT(p, i) GET_BIT2(p, i, ; , ;) | 25 | #define GET_BIT(p, i) GET_BIT2(p, i, ; , ;) |
26 | 26 | ||
27 | #define TREE_GET_BIT(probs, i) { GET_BIT((probs + i), i); } | 27 | #define TREE_GET_BIT(probs, i) { GET_BIT((probs + i), i); } |
28 | #define TREE_DECODE(probs, limit, i) \ | 28 | #define TREE_DECODE(probs, limit, i) \ |
29 | { i = 1; do { TREE_GET_BIT(probs, i); } while (i < limit); i -= limit; } | 29 | { i = 1; do { TREE_GET_BIT(probs, i); } while (i < limit); i -= limit; } |
30 | 30 | ||
31 | /* #define _LZMA_SIZE_OPT */ | 31 | /* #define _LZMA_SIZE_OPT */ |
32 | 32 | ||
33 | #ifdef _LZMA_SIZE_OPT | 33 | #ifdef _LZMA_SIZE_OPT |
34 | #define TREE_6_DECODE(probs, i) TREE_DECODE(probs, (1 << 6), i) | 34 | #define TREE_6_DECODE(probs, i) TREE_DECODE(probs, (1 << 6), i) |
35 | #else | 35 | #else |
36 | #define TREE_6_DECODE(probs, i) \ | 36 | #define TREE_6_DECODE(probs, i) \ |
37 | { i = 1; \ | 37 | { i = 1; \ |
38 | TREE_GET_BIT(probs, i); \ | 38 | TREE_GET_BIT(probs, i); \ |
39 | TREE_GET_BIT(probs, i); \ | 39 | TREE_GET_BIT(probs, i); \ |
40 | TREE_GET_BIT(probs, i); \ | 40 | TREE_GET_BIT(probs, i); \ |
41 | TREE_GET_BIT(probs, i); \ | 41 | TREE_GET_BIT(probs, i); \ |
42 | TREE_GET_BIT(probs, i); \ | 42 | TREE_GET_BIT(probs, i); \ |
43 | TREE_GET_BIT(probs, i); \ | 43 | TREE_GET_BIT(probs, i); \ |
44 | i -= 0x40; } | 44 | i -= 0x40; } |
45 | #endif | 45 | #endif |
46 | 46 | ||
47 | #define NORMALIZE_CHECK if (range < kTopValue) { if (buf >= bufLimit) return DUMMY_ERROR; range <<= 8; code = (code << 8) | (*buf++); } | 47 | #define NORMALIZE_CHECK if (range < kTopValue) { if (buf >= bufLimit) return DUMMY_ERROR; range <<= 8; code = (code << 8) | (*buf++); } |
48 | 48 | ||
49 | #define IF_BIT_0_CHECK(p) ttt = *(p); NORMALIZE_CHECK; bound = (range >> kNumBitModelTotalBits) * ttt; if (code < bound) | 49 | #define IF_BIT_0_CHECK(p) ttt = *(p); NORMALIZE_CHECK; bound = (range >> kNumBitModelTotalBits) * ttt; if (code < bound) |
50 | #define UPDATE_0_CHECK range = bound; | 50 | #define UPDATE_0_CHECK range = bound; |
51 | #define UPDATE_1_CHECK range -= bound; code -= bound; | 51 | #define UPDATE_1_CHECK range -= bound; code -= bound; |
52 | #define GET_BIT2_CHECK(p, i, A0, A1) IF_BIT_0_CHECK(p) \ | 52 | #define GET_BIT2_CHECK(p, i, A0, A1) IF_BIT_0_CHECK(p) \ |
53 | { UPDATE_0_CHECK; i = (i + i); A0; } else \ | 53 | { UPDATE_0_CHECK; i = (i + i); A0; } else \ |
54 | { UPDATE_1_CHECK; i = (i + i) + 1; A1; } | 54 | { UPDATE_1_CHECK; i = (i + i) + 1; A1; } |
55 | #define GET_BIT_CHECK(p, i) GET_BIT2_CHECK(p, i, ; , ;) | 55 | #define GET_BIT_CHECK(p, i) GET_BIT2_CHECK(p, i, ; , ;) |
56 | #define TREE_DECODE_CHECK(probs, limit, i) \ | 56 | #define TREE_DECODE_CHECK(probs, limit, i) \ |
57 | { i = 1; do { GET_BIT_CHECK(probs + i, i) } while (i < limit); i -= limit; } | 57 | { i = 1; do { GET_BIT_CHECK(probs + i, i) } while (i < limit); i -= limit; } |
58 | 58 | ||
59 | 59 | ||
60 | #define kNumPosBitsMax 4 | 60 | #define kNumPosBitsMax 4 |
61 | #define kNumPosStatesMax (1 << kNumPosBitsMax) | 61 | #define kNumPosStatesMax (1 << kNumPosBitsMax) |
62 | 62 | ||
63 | #define kLenNumLowBits 3 | 63 | #define kLenNumLowBits 3 |
64 | #define kLenNumLowSymbols (1 << kLenNumLowBits) | 64 | #define kLenNumLowSymbols (1 << kLenNumLowBits) |
65 | #define kLenNumMidBits 3 | 65 | #define kLenNumMidBits 3 |
66 | #define kLenNumMidSymbols (1 << kLenNumMidBits) | 66 | #define kLenNumMidSymbols (1 << kLenNumMidBits) |
67 | #define kLenNumHighBits 8 | 67 | #define kLenNumHighBits 8 |
68 | #define kLenNumHighSymbols (1 << kLenNumHighBits) | 68 | #define kLenNumHighSymbols (1 << kLenNumHighBits) |
69 | 69 | ||
70 | #define LenChoice 0 | 70 | #define LenChoice 0 |
71 | #define LenChoice2 (LenChoice + 1) | 71 | #define LenChoice2 (LenChoice + 1) |
72 | #define LenLow (LenChoice2 + 1) | 72 | #define LenLow (LenChoice2 + 1) |
73 | #define LenMid (LenLow + (kNumPosStatesMax << kLenNumLowBits)) | 73 | #define LenMid (LenLow + (kNumPosStatesMax << kLenNumLowBits)) |
74 | #define LenHigh (LenMid + (kNumPosStatesMax << kLenNumMidBits)) | 74 | #define LenHigh (LenMid + (kNumPosStatesMax << kLenNumMidBits)) |
75 | #define kNumLenProbs (LenHigh + kLenNumHighSymbols) | 75 | #define kNumLenProbs (LenHigh + kLenNumHighSymbols) |
76 | 76 | ||
77 | 77 | ||
78 | #define kNumStates 12 | 78 | #define kNumStates 12 |
79 | #define kNumLitStates 7 | 79 | #define kNumLitStates 7 |
80 | 80 | ||
81 | #define kStartPosModelIndex 4 | 81 | #define kStartPosModelIndex 4 |
82 | #define kEndPosModelIndex 14 | 82 | #define kEndPosModelIndex 14 |
83 | #define kNumFullDistances (1 << (kEndPosModelIndex >> 1)) | 83 | #define kNumFullDistances (1 << (kEndPosModelIndex >> 1)) |
84 | 84 | ||
85 | #define kNumPosSlotBits 6 | 85 | #define kNumPosSlotBits 6 |
86 | #define kNumLenToPosStates 4 | 86 | #define kNumLenToPosStates 4 |
87 | 87 | ||
88 | #define kNumAlignBits 4 | 88 | #define kNumAlignBits 4 |
89 | #define kAlignTableSize (1 << kNumAlignBits) | 89 | #define kAlignTableSize (1 << kNumAlignBits) |
90 | 90 | ||
91 | #define kMatchMinLen 2 | 91 | #define kMatchMinLen 2 |
92 | #define kMatchSpecLenStart (kMatchMinLen + kLenNumLowSymbols + kLenNumMidSymbols + kLenNumHighSymbols) | 92 | #define kMatchSpecLenStart (kMatchMinLen + kLenNumLowSymbols + kLenNumMidSymbols + kLenNumHighSymbols) |
93 | 93 | ||
94 | #define IsMatch 0 | 94 | #define IsMatch 0 |
95 | #define IsRep (IsMatch + (kNumStates << kNumPosBitsMax)) | 95 | #define IsRep (IsMatch + (kNumStates << kNumPosBitsMax)) |
96 | #define IsRepG0 (IsRep + kNumStates) | 96 | #define IsRepG0 (IsRep + kNumStates) |
97 | #define IsRepG1 (IsRepG0 + kNumStates) | 97 | #define IsRepG1 (IsRepG0 + kNumStates) |
98 | #define IsRepG2 (IsRepG1 + kNumStates) | 98 | #define IsRepG2 (IsRepG1 + kNumStates) |
99 | #define IsRep0Long (IsRepG2 + kNumStates) | 99 | #define IsRep0Long (IsRepG2 + kNumStates) |
100 | #define PosSlot (IsRep0Long + (kNumStates << kNumPosBitsMax)) | 100 | #define PosSlot (IsRep0Long + (kNumStates << kNumPosBitsMax)) |
101 | #define SpecPos (PosSlot + (kNumLenToPosStates << kNumPosSlotBits)) | 101 | #define SpecPos (PosSlot + (kNumLenToPosStates << kNumPosSlotBits)) |
102 | #define Align (SpecPos + kNumFullDistances - kEndPosModelIndex) | 102 | #define Align (SpecPos + kNumFullDistances - kEndPosModelIndex) |
103 | #define LenCoder (Align + kAlignTableSize) | 103 | #define LenCoder (Align + kAlignTableSize) |
104 | #define RepLenCoder (LenCoder + kNumLenProbs) | 104 | #define RepLenCoder (LenCoder + kNumLenProbs) |
105 | #define Literal (RepLenCoder + kNumLenProbs) | 105 | #define Literal (RepLenCoder + kNumLenProbs) |
106 | 106 | ||
107 | #define LZMA_BASE_SIZE 1846 | 107 | #define LZMA_BASE_SIZE 1846 |
108 | #define LZMA_LIT_SIZE 768 | 108 | #define LZMA_LIT_SIZE 768 |
109 | 109 | ||
110 | #define LzmaProps_GetNumProbs(p) ((UInt32)LZMA_BASE_SIZE + (LZMA_LIT_SIZE << ((p)->lc + (p)->lp))) | 110 | #define LzmaProps_GetNumProbs(p) ((UInt32)LZMA_BASE_SIZE + (LZMA_LIT_SIZE << ((p)->lc + (p)->lp))) |
111 | 111 | ||
112 | #if Literal != LZMA_BASE_SIZE | 112 | #if Literal != LZMA_BASE_SIZE |
113 | StopCompilingDueBUG | 113 | StopCompilingDueBUG |
114 | #endif | 114 | #endif |
115 | 115 | ||
116 | #define LZMA_DIC_MIN (1 << 12) | 116 | #define LZMA_DIC_MIN (1 << 12) |
117 | 117 | ||
118 | /* First LZMA-symbol is always decoded. | 118 | /* First LZMA-symbol is always decoded. |
119 | And it decodes new LZMA-symbols while (buf < bufLimit), but "buf" is without last normalization | 119 | And it decodes new LZMA-symbols while (buf < bufLimit), but "buf" is without last normalization |
120 | Out: | 120 | Out: |
121 | Result: | 121 | Result: |
122 | SZ_OK - OK | 122 | SZ_OK - OK |
123 | SZ_ERROR_DATA - Error | 123 | SZ_ERROR_DATA - Error |
124 | p->remainLen: | 124 | p->remainLen: |
125 | < kMatchSpecLenStart : normal remain | 125 | < kMatchSpecLenStart : normal remain |
126 | = kMatchSpecLenStart : finished | 126 | = kMatchSpecLenStart : finished |
127 | = kMatchSpecLenStart + 1 : Flush marker | 127 | = kMatchSpecLenStart + 1 : Flush marker |
128 | = kMatchSpecLenStart + 2 : State Init Marker | 128 | = kMatchSpecLenStart + 2 : State Init Marker |
129 | */ | 129 | */ |
130 | 130 | ||
131 | static int MY_FAST_CALL LzmaDec_DecodeReal(CLzmaDec *p, SizeT limit, const Byte *bufLimit) | 131 | static int MY_FAST_CALL LzmaDec_DecodeReal(CLzmaDec *p, SizeT limit, const Byte *bufLimit) |
132 | { | 132 | { |
133 | CLzmaProb *probs = p->probs; | 133 | CLzmaProb *probs = p->probs; |
134 | 134 | ||
135 | unsigned state = p->state; | 135 | unsigned state = p->state; |
136 | UInt32 rep0 = p->reps[0], rep1 = p->reps[1], rep2 = p->reps[2], rep3 = p->reps[3]; | 136 | UInt32 rep0 = p->reps[0], rep1 = p->reps[1], rep2 = p->reps[2], rep3 = p->reps[3]; |
137 | unsigned pbMask = ((unsigned)1 << (p->prop.pb)) - 1; | 137 | unsigned pbMask = ((unsigned)1 << (p->prop.pb)) - 1; |
138 | unsigned lpMask = ((unsigned)1 << (p->prop.lp)) - 1; | 138 | unsigned lpMask = ((unsigned)1 << (p->prop.lp)) - 1; |
139 | unsigned lc = p->prop.lc; | 139 | unsigned lc = p->prop.lc; |
140 | 140 | ||
141 | Byte *dic = p->dic; | 141 | Byte *dic = p->dic; |
142 | SizeT dicBufSize = p->dicBufSize; | 142 | SizeT dicBufSize = p->dicBufSize; |
143 | SizeT dicPos = p->dicPos; | 143 | SizeT dicPos = p->dicPos; |
144 | 144 | ||
145 | UInt32 processedPos = p->processedPos; | 145 | UInt32 processedPos = p->processedPos; |
146 | UInt32 checkDicSize = p->checkDicSize; | 146 | UInt32 checkDicSize = p->checkDicSize; |
147 | unsigned len = 0; | 147 | unsigned len = 0; |
148 | 148 | ||
149 | const Byte *buf = p->buf; | 149 | const Byte *buf = p->buf; |
150 | UInt32 range = p->range; | 150 | UInt32 range = p->range; |
151 | UInt32 code = p->code; | 151 | UInt32 code = p->code; |
152 | 152 | ||
153 | do | 153 | do |
154 | { | 154 | { |
155 | CLzmaProb *prob; | 155 | CLzmaProb *prob; |
156 | UInt32 bound; | 156 | UInt32 bound; |
157 | unsigned ttt; | 157 | unsigned ttt; |
158 | unsigned posState = processedPos & pbMask; | 158 | unsigned posState = processedPos & pbMask; |
159 | 159 | ||
160 | prob = probs + IsMatch + (state << kNumPosBitsMax) + posState; | 160 | prob = probs + IsMatch + (state << kNumPosBitsMax) + posState; |
161 | IF_BIT_0(prob) | 161 | IF_BIT_0(prob) |
162 | { | 162 | { |
163 | unsigned symbol; | 163 | unsigned symbol; |
164 | UPDATE_0(prob); | 164 | UPDATE_0(prob); |
165 | prob = probs + Literal; | 165 | prob = probs + Literal; |
166 | if (checkDicSize != 0 || processedPos != 0) | 166 | if (checkDicSize != 0 || processedPos != 0) |
167 | prob += (LZMA_LIT_SIZE * (((processedPos & lpMask) << lc) + | 167 | prob += (LZMA_LIT_SIZE * (((processedPos & lpMask) << lc) + |
168 | (dic[(dicPos == 0 ? dicBufSize : dicPos) - 1] >> (8 - lc)))); | 168 | (dic[(dicPos == 0 ? dicBufSize : dicPos) - 1] >> (8 - lc)))); |
169 | 169 | ||
170 | if (state < kNumLitStates) | 170 | if (state < kNumLitStates) |
171 | { | 171 | { |
172 | state -= (state < 4) ? state : 3; | 172 | state -= (state < 4) ? state : 3; |
173 | symbol = 1; | 173 | symbol = 1; |
174 | do { GET_BIT(prob + symbol, symbol) } while (symbol < 0x100); | 174 | do { GET_BIT(prob + symbol, symbol) } while (symbol < 0x100); |
175 | } | 175 | } |
176 | else | 176 | else |
177 | { | 177 | { |
178 | unsigned matchByte = p->dic[(dicPos - rep0) + ((dicPos < rep0) ? dicBufSize : 0)]; | 178 | unsigned matchByte = p->dic[(dicPos - rep0) + ((dicPos < rep0) ? dicBufSize : 0)]; |
179 | unsigned offs = 0x100; | 179 | unsigned offs = 0x100; |
180 | state -= (state < 10) ? 3 : 6; | 180 | state -= (state < 10) ? 3 : 6; |
181 | symbol = 1; | 181 | symbol = 1; |
182 | do | 182 | do |
183 | { | 183 | { |
184 | unsigned bit; | 184 | unsigned bit; |
185 | CLzmaProb *probLit; | 185 | CLzmaProb *probLit; |
186 | matchByte <<= 1; | 186 | matchByte <<= 1; |
187 | bit = (matchByte & offs); | 187 | bit = (matchByte & offs); |
188 | probLit = prob + offs + bit + symbol; | 188 | probLit = prob + offs + bit + symbol; |
189 | GET_BIT2(probLit, symbol, offs &= ~bit, offs &= bit) | 189 | GET_BIT2(probLit, symbol, offs &= ~bit, offs &= bit) |
190 | } | 190 | } |
191 | while (symbol < 0x100); | 191 | while (symbol < 0x100); |
192 | } | 192 | } |
193 | dic[dicPos++] = (Byte)symbol; | 193 | dic[dicPos++] = (Byte)symbol; |
194 | processedPos++; | 194 | processedPos++; |
195 | continue; | 195 | continue; |
196 | } | 196 | } |
197 | else | 197 | else |
198 | { | 198 | { |
199 | UPDATE_1(prob); | 199 | UPDATE_1(prob); |
200 | prob = probs + IsRep + state; | 200 | prob = probs + IsRep + state; |
201 | IF_BIT_0(prob) | 201 | IF_BIT_0(prob) |
202 | { | 202 | { |
203 | UPDATE_0(prob); | 203 | UPDATE_0(prob); |
204 | state += kNumStates; | 204 | state += kNumStates; |
205 | prob = probs + LenCoder; | 205 | prob = probs + LenCoder; |
206 | } | 206 | } |
207 | else | 207 | else |
208 | { | 208 | { |
209 | UPDATE_1(prob); | 209 | UPDATE_1(prob); |
210 | if (checkDicSize == 0 && processedPos == 0) | 210 | if (checkDicSize == 0 && processedPos == 0) |
211 | return SZ_ERROR_DATA; | 211 | return SZ_ERROR_DATA; |
212 | prob = probs + IsRepG0 + state; | 212 | prob = probs + IsRepG0 + state; |
213 | IF_BIT_0(prob) | 213 | IF_BIT_0(prob) |
214 | { | 214 | { |
215 | UPDATE_0(prob); | 215 | UPDATE_0(prob); |
216 | prob = probs + IsRep0Long + (state << kNumPosBitsMax) + posState; | 216 | prob = probs + IsRep0Long + (state << kNumPosBitsMax) + posState; |
217 | IF_BIT_0(prob) | 217 | IF_BIT_0(prob) |
218 | { | 218 | { |
219 | UPDATE_0(prob); | 219 | UPDATE_0(prob); |
220 | dic[dicPos] = dic[(dicPos - rep0) + ((dicPos < rep0) ? dicBufSize : 0)]; | 220 | dic[dicPos] = dic[(dicPos - rep0) + ((dicPos < rep0) ? dicBufSize : 0)]; |
221 | dicPos++; | 221 | dicPos++; |
222 | processedPos++; | 222 | processedPos++; |
223 | state = state < kNumLitStates ? 9 : 11; | 223 | state = state < kNumLitStates ? 9 : 11; |
224 | continue; | 224 | continue; |
225 | } | 225 | } |
226 | UPDATE_1(prob); | 226 | UPDATE_1(prob); |
227 | } | 227 | } |
228 | else | 228 | else |
229 | { | 229 | { |
230 | UInt32 distance; | 230 | UInt32 distance; |
231 | UPDATE_1(prob); | 231 | UPDATE_1(prob); |
232 | prob = probs + IsRepG1 + state; | 232 | prob = probs + IsRepG1 + state; |
233 | IF_BIT_0(prob) | 233 | IF_BIT_0(prob) |
234 | { | 234 | { |
235 | UPDATE_0(prob); | 235 | UPDATE_0(prob); |
236 | distance = rep1; | 236 | distance = rep1; |
237 | } | 237 | } |
238 | else | 238 | else |
239 | { | 239 | { |
240 | UPDATE_1(prob); | 240 | UPDATE_1(prob); |
241 | prob = probs + IsRepG2 + state; | 241 | prob = probs + IsRepG2 + state; |
242 | IF_BIT_0(prob) | 242 | IF_BIT_0(prob) |
243 | { | 243 | { |
244 | UPDATE_0(prob); | 244 | UPDATE_0(prob); |
245 | distance = rep2; | 245 | distance = rep2; |
246 | } | 246 | } |
247 | else | 247 | else |
248 | { | 248 | { |
249 | UPDATE_1(prob); | 249 | UPDATE_1(prob); |
250 | distance = rep3; | 250 | distance = rep3; |
251 | rep3 = rep2; | 251 | rep3 = rep2; |
252 | } | 252 | } |
253 | rep2 = rep1; | 253 | rep2 = rep1; |
254 | } | 254 | } |
255 | rep1 = rep0; | 255 | rep1 = rep0; |
256 | rep0 = distance; | 256 | rep0 = distance; |
257 | } | 257 | } |
258 | state = state < kNumLitStates ? 8 : 11; | 258 | state = state < kNumLitStates ? 8 : 11; |
259 | prob = probs + RepLenCoder; | 259 | prob = probs + RepLenCoder; |
260 | } | 260 | } |
261 | { | 261 | { |
262 | unsigned limit, offset; | 262 | unsigned limit, offset; |
263 | CLzmaProb *probLen = prob + LenChoice; | 263 | CLzmaProb *probLen = prob + LenChoice; |
264 | IF_BIT_0(probLen) | 264 | IF_BIT_0(probLen) |
265 | { | 265 | { |
266 | UPDATE_0(probLen); | 266 | UPDATE_0(probLen); |
267 | probLen = prob + LenLow + (posState << kLenNumLowBits); | 267 | probLen = prob + LenLow + (posState << kLenNumLowBits); |
268 | offset = 0; | 268 | offset = 0; |
269 | limit = (1 << kLenNumLowBits); | 269 | limit = (1 << kLenNumLowBits); |
270 | } | 270 | } |
271 | else | 271 | else |
272 | { | 272 | { |
273 | UPDATE_1(probLen); | 273 | UPDATE_1(probLen); |
274 | probLen = prob + LenChoice2; | 274 | probLen = prob + LenChoice2; |
275 | IF_BIT_0(probLen) | 275 | IF_BIT_0(probLen) |
276 | { | 276 | { |
277 | UPDATE_0(probLen); | 277 | UPDATE_0(probLen); |
278 | probLen = prob + LenMid + (posState << kLenNumMidBits); | 278 | probLen = prob + LenMid + (posState << kLenNumMidBits); |
279 | offset = kLenNumLowSymbols; | 279 | offset = kLenNumLowSymbols; |
280 | limit = (1 << kLenNumMidBits); | 280 | limit = (1 << kLenNumMidBits); |
281 | } | 281 | } |
282 | else | 282 | else |
283 | { | 283 | { |
284 | UPDATE_1(probLen); | 284 | UPDATE_1(probLen); |
285 | probLen = prob + LenHigh; | 285 | probLen = prob + LenHigh; |
286 | offset = kLenNumLowSymbols + kLenNumMidSymbols; | 286 | offset = kLenNumLowSymbols + kLenNumMidSymbols; |
287 | limit = (1 << kLenNumHighBits); | 287 | limit = (1 << kLenNumHighBits); |
288 | } | 288 | } |
289 | } | 289 | } |
290 | TREE_DECODE(probLen, limit, len); | 290 | TREE_DECODE(probLen, limit, len); |
291 | len += offset; | 291 | len += offset; |
292 | } | 292 | } |
293 | 293 | ||
294 | if (state >= kNumStates) | 294 | if (state >= kNumStates) |
295 | { | 295 | { |
296 | UInt32 distance; | 296 | UInt32 distance; |
297 | prob = probs + PosSlot + | 297 | prob = probs + PosSlot + |
298 | ((len < kNumLenToPosStates ? len : kNumLenToPosStates - 1) << kNumPosSlotBits); | 298 | ((len < kNumLenToPosStates ? len : kNumLenToPosStates - 1) << kNumPosSlotBits); |
299 | TREE_6_DECODE(prob, distance); | 299 | TREE_6_DECODE(prob, distance); |
300 | if (distance >= kStartPosModelIndex) | 300 | if (distance >= kStartPosModelIndex) |
301 | { | 301 | { |
302 | unsigned posSlot = (unsigned)distance; | 302 | unsigned posSlot = (unsigned)distance; |
303 | int numDirectBits = (int)(((distance >> 1) - 1)); | 303 | int numDirectBits = (int)(((distance >> 1) - 1)); |
304 | distance = (2 | (distance & 1)); | 304 | distance = (2 | (distance & 1)); |
305 | if (posSlot < kEndPosModelIndex) | 305 | if (posSlot < kEndPosModelIndex) |
306 | { | 306 | { |
307 | distance <<= numDirectBits; | 307 | distance <<= numDirectBits; |
308 | prob = probs + SpecPos + distance - posSlot - 1; | 308 | prob = probs + SpecPos + distance - posSlot - 1; |
309 | { | 309 | { |
310 | UInt32 mask = 1; | 310 | UInt32 mask = 1; |
311 | unsigned i = 1; | 311 | unsigned i = 1; |
312 | do | 312 | do |
313 | { | 313 | { |
314 | GET_BIT2(prob + i, i, ; , distance |= mask); | 314 | GET_BIT2(prob + i, i, ; , distance |= mask); |
315 | mask <<= 1; | 315 | mask <<= 1; |
316 | } | 316 | } |
317 | while (--numDirectBits != 0); | 317 | while (--numDirectBits != 0); |
318 | } | 318 | } |
319 | } | 319 | } |
320 | else | 320 | else |
321 | { | 321 | { |
322 | numDirectBits -= kNumAlignBits; | 322 | numDirectBits -= kNumAlignBits; |
323 | do | 323 | do |
324 | { | 324 | { |
325 | NORMALIZE | 325 | NORMALIZE |
326 | range >>= 1; | 326 | range >>= 1; |
327 | 327 | ||
328 | { | 328 | { |
329 | UInt32 t; | 329 | UInt32 t; |
330 | code -= range; | 330 | code -= range; |
331 | t = (0 - ((UInt32)code >> 31)); /* (UInt32)((Int32)code >> 31) */ | 331 | t = (0 - ((UInt32)code >> 31)); /* (UInt32)((Int32)code >> 31) */ |
332 | distance = (distance << 1) + (t + 1); | 332 | distance = (distance << 1) + (t + 1); |
333 | code += range & t; | 333 | code += range & t; |
334 | } | 334 | } |
335 | /* | 335 | /* |
336 | distance <<= 1; | 336 | distance <<= 1; |
337 | if (code >= range) | 337 | if (code >= range) |
338 | { | 338 | { |
339 | code -= range; | 339 | code -= range; |
340 | distance |= 1; | 340 | distance |= 1; |
341 | } | 341 | } |
342 | */ | 342 | */ |
343 | } | 343 | } |
344 | while (--numDirectBits != 0); | 344 | while (--numDirectBits != 0); |
345 | prob = probs + Align; | 345 | prob = probs + Align; |
346 | distance <<= kNumAlignBits; | 346 | distance <<= kNumAlignBits; |
347 | { | 347 | { |
348 | unsigned i = 1; | 348 | unsigned i = 1; |
349 | GET_BIT2(prob + i, i, ; , distance |= 1); | 349 | GET_BIT2(prob + i, i, ; , distance |= 1); |
350 | GET_BIT2(prob + i, i, ; , distance |= 2); | 350 | GET_BIT2(prob + i, i, ; , distance |= 2); |
351 | GET_BIT2(prob + i, i, ; , distance |= 4); | 351 | GET_BIT2(prob + i, i, ; , distance |= 4); |
352 | GET_BIT2(prob + i, i, ; , distance |= 8); | 352 | GET_BIT2(prob + i, i, ; , distance |= 8); |
353 | } | 353 | } |
354 | if (distance == (UInt32)0xFFFFFFFF) | 354 | if (distance == (UInt32)0xFFFFFFFF) |
355 | { | 355 | { |
356 | len += kMatchSpecLenStart; | 356 | len += kMatchSpecLenStart; |
357 | state -= kNumStates; | 357 | state -= kNumStates; |
358 | break; | 358 | break; |
359 | } | 359 | } |
360 | } | 360 | } |
361 | } | 361 | } |
362 | rep3 = rep2; | 362 | rep3 = rep2; |
363 | rep2 = rep1; | 363 | rep2 = rep1; |
364 | rep1 = rep0; | 364 | rep1 = rep0; |
365 | rep0 = distance + 1; | 365 | rep0 = distance + 1; |
366 | if (checkDicSize == 0) | 366 | if (checkDicSize == 0) |
367 | { | 367 | { |
368 | if (distance >= processedPos) | 368 | if (distance >= processedPos) |
369 | return SZ_ERROR_DATA; | 369 | return SZ_ERROR_DATA; |
370 | } | 370 | } |
371 | else if (distance >= checkDicSize) | 371 | else if (distance >= checkDicSize) |
372 | return SZ_ERROR_DATA; | 372 | return SZ_ERROR_DATA; |
373 | state = (state < kNumStates + kNumLitStates) ? kNumLitStates : kNumLitStates + 3; | 373 | state = (state < kNumStates + kNumLitStates) ? kNumLitStates : kNumLitStates + 3; |
374 | } | 374 | } |
375 | 375 | ||
376 | len += kMatchMinLen; | 376 | len += kMatchMinLen; |
377 | 377 | ||
378 | if (limit == dicPos) | 378 | if (limit == dicPos) |
379 | return SZ_ERROR_DATA; | 379 | return SZ_ERROR_DATA; |
380 | { | 380 | { |
381 | SizeT rem = limit - dicPos; | 381 | SizeT rem = limit - dicPos; |
382 | unsigned curLen = ((rem < len) ? (unsigned)rem : len); | 382 | unsigned curLen = ((rem < len) ? (unsigned)rem : len); |
383 | SizeT pos = (dicPos - rep0) + ((dicPos < rep0) ? dicBufSize : 0); | 383 | SizeT pos = (dicPos - rep0) + ((dicPos < rep0) ? dicBufSize : 0); |
384 | 384 | ||
385 | processedPos += curLen; | 385 | processedPos += curLen; |
386 | 386 | ||
387 | len -= curLen; | 387 | len -= curLen; |
388 | if (pos + curLen <= dicBufSize) | 388 | if (pos + curLen <= dicBufSize) |
389 | { | 389 | { |
390 | Byte *dest = dic + dicPos; | 390 | Byte *dest = dic + dicPos; |
391 | ptrdiff_t src = (ptrdiff_t)pos - (ptrdiff_t)dicPos; | 391 | ptrdiff_t src = (ptrdiff_t)pos - (ptrdiff_t)dicPos; |
392 | const Byte *lim = dest + curLen; | 392 | const Byte *lim = dest + curLen; |
393 | dicPos += curLen; | 393 | dicPos += curLen; |
394 | do | 394 | do |
395 | *(dest) = (Byte)*(dest + src); | 395 | *(dest) = (Byte)*(dest + src); |
396 | while (++dest != lim); | 396 | while (++dest != lim); |
397 | } | 397 | } |
398 | else | 398 | else |
399 | { | 399 | { |
400 | do | 400 | do |
401 | { | 401 | { |
402 | dic[dicPos++] = dic[pos]; | 402 | dic[dicPos++] = dic[pos]; |
403 | if (++pos == dicBufSize) | 403 | if (++pos == dicBufSize) |
404 | pos = 0; | 404 | pos = 0; |
405 | } | 405 | } |
406 | while (--curLen != 0); | 406 | while (--curLen != 0); |
407 | } | 407 | } |
408 | } | 408 | } |
409 | } | 409 | } |
410 | } | 410 | } |
411 | while (dicPos < limit && buf < bufLimit); | 411 | while (dicPos < limit && buf < bufLimit); |
412 | NORMALIZE; | 412 | NORMALIZE; |
413 | p->buf = buf; | 413 | p->buf = buf; |
414 | p->range = range; | 414 | p->range = range; |
415 | p->code = code; | 415 | p->code = code; |
416 | p->remainLen = len; | 416 | p->remainLen = len; |
417 | p->dicPos = dicPos; | 417 | p->dicPos = dicPos; |
418 | p->processedPos = processedPos; | 418 | p->processedPos = processedPos; |
419 | p->reps[0] = rep0; | 419 | p->reps[0] = rep0; |
420 | p->reps[1] = rep1; | 420 | p->reps[1] = rep1; |
421 | p->reps[2] = rep2; | 421 | p->reps[2] = rep2; |
422 | p->reps[3] = rep3; | 422 | p->reps[3] = rep3; |
423 | p->state = state; | 423 | p->state = state; |
424 | 424 | ||
425 | return SZ_OK; | 425 | return SZ_OK; |
426 | } | 426 | } |
427 | 427 | ||
428 | static void MY_FAST_CALL LzmaDec_WriteRem(CLzmaDec *p, SizeT limit) | 428 | static void MY_FAST_CALL LzmaDec_WriteRem(CLzmaDec *p, SizeT limit) |
429 | { | 429 | { |
430 | if (p->remainLen != 0 && p->remainLen < kMatchSpecLenStart) | 430 | if (p->remainLen != 0 && p->remainLen < kMatchSpecLenStart) |
431 | { | 431 | { |
432 | Byte *dic = p->dic; | 432 | Byte *dic = p->dic; |
433 | SizeT dicPos = p->dicPos; | 433 | SizeT dicPos = p->dicPos; |
434 | SizeT dicBufSize = p->dicBufSize; | 434 | SizeT dicBufSize = p->dicBufSize; |
435 | unsigned len = p->remainLen; | 435 | unsigned len = p->remainLen; |
436 | UInt32 rep0 = p->reps[0]; | 436 | UInt32 rep0 = p->reps[0]; |
437 | if (limit - dicPos < len) | 437 | if (limit - dicPos < len) |
438 | len = (unsigned)(limit - dicPos); | 438 | len = (unsigned)(limit - dicPos); |
439 | 439 | ||
440 | if (p->checkDicSize == 0 && p->prop.dicSize - p->processedPos <= len) | 440 | if (p->checkDicSize == 0 && p->prop.dicSize - p->processedPos <= len) |
441 | p->checkDicSize = p->prop.dicSize; | 441 | p->checkDicSize = p->prop.dicSize; |
442 | 442 | ||
443 | p->processedPos += len; | 443 | p->processedPos += len; |
444 | p->remainLen -= len; | 444 | p->remainLen -= len; |
445 | while (len-- != 0) | 445 | while (len-- != 0) |
446 | { | 446 | { |
447 | dic[dicPos] = dic[(dicPos - rep0) + ((dicPos < rep0) ? dicBufSize : 0)]; | 447 | dic[dicPos] = dic[(dicPos - rep0) + ((dicPos < rep0) ? dicBufSize : 0)]; |
448 | dicPos++; | 448 | dicPos++; |
449 | } | 449 | } |
450 | p->dicPos = dicPos; | 450 | p->dicPos = dicPos; |
451 | } | 451 | } |
452 | } | 452 | } |
453 | 453 | ||
454 | static int MY_FAST_CALL LzmaDec_DecodeReal2(CLzmaDec *p, SizeT limit, const Byte *bufLimit) | 454 | static int MY_FAST_CALL LzmaDec_DecodeReal2(CLzmaDec *p, SizeT limit, const Byte *bufLimit) |
455 | { | 455 | { |
456 | do | 456 | do |
457 | { | 457 | { |
458 | SizeT limit2 = limit; | 458 | SizeT limit2 = limit; |
459 | if (p->checkDicSize == 0) | 459 | if (p->checkDicSize == 0) |
460 | { | 460 | { |
461 | UInt32 rem = p->prop.dicSize - p->processedPos; | 461 | UInt32 rem = p->prop.dicSize - p->processedPos; |
462 | if (limit - p->dicPos > rem) | 462 | if (limit - p->dicPos > rem) |
463 | limit2 = p->dicPos + rem; | 463 | limit2 = p->dicPos + rem; |
464 | } | 464 | } |
465 | RINOK(LzmaDec_DecodeReal(p, limit2, bufLimit)); | 465 | RINOK(LzmaDec_DecodeReal(p, limit2, bufLimit)); |
466 | if (p->processedPos >= p->prop.dicSize) | 466 | if (p->processedPos >= p->prop.dicSize) |
467 | p->checkDicSize = p->prop.dicSize; | 467 | p->checkDicSize = p->prop.dicSize; |
468 | LzmaDec_WriteRem(p, limit); | 468 | LzmaDec_WriteRem(p, limit); |
469 | } | 469 | } |
470 | while (p->dicPos < limit && p->buf < bufLimit && p->remainLen < kMatchSpecLenStart); | 470 | while (p->dicPos < limit && p->buf < bufLimit && p->remainLen < kMatchSpecLenStart); |
471 | 471 | ||
472 | if (p->remainLen > kMatchSpecLenStart) | 472 | if (p->remainLen > kMatchSpecLenStart) |
473 | { | 473 | { |
474 | p->remainLen = kMatchSpecLenStart; | 474 | p->remainLen = kMatchSpecLenStart; |
475 | } | 475 | } |
476 | return 0; | 476 | return 0; |
477 | } | 477 | } |
478 | 478 | ||
479 | typedef enum | 479 | typedef enum |
480 | { | 480 | { |
481 | DUMMY_ERROR, /* unexpected end of input stream */ | 481 | DUMMY_ERROR, /* unexpected end of input stream */ |
482 | DUMMY_LIT, | 482 | DUMMY_LIT, |
483 | DUMMY_MATCH, | 483 | DUMMY_MATCH, |
484 | DUMMY_REP | 484 | DUMMY_REP |
485 | } ELzmaDummy; | 485 | } ELzmaDummy; |
486 | 486 | ||
487 | static ELzmaDummy LzmaDec_TryDummy(const CLzmaDec *p, const Byte *buf, SizeT inSize) | 487 | static ELzmaDummy LzmaDec_TryDummy(const CLzmaDec *p, const Byte *buf, SizeT inSize) |
488 | { | 488 | { |
489 | UInt32 range = p->range; | 489 | UInt32 range = p->range; |
490 | UInt32 code = p->code; | 490 | UInt32 code = p->code; |
491 | const Byte *bufLimit = buf + inSize; | 491 | const Byte *bufLimit = buf + inSize; |
492 | CLzmaProb *probs = p->probs; | 492 | CLzmaProb *probs = p->probs; |
493 | unsigned state = p->state; | 493 | unsigned state = p->state; |
494 | ELzmaDummy res; | 494 | ELzmaDummy res; |
495 | 495 | ||
496 | { | 496 | { |
497 | CLzmaProb *prob; | 497 | CLzmaProb *prob; |
498 | UInt32 bound; | 498 | UInt32 bound; |
499 | unsigned ttt; | 499 | unsigned ttt; |
500 | unsigned posState = (p->processedPos) & ((1 << p->prop.pb) - 1); | 500 | unsigned posState = (p->processedPos) & ((1 << p->prop.pb) - 1); |
501 | 501 | ||
502 | prob = probs + IsMatch + (state << kNumPosBitsMax) + posState; | 502 | prob = probs + IsMatch + (state << kNumPosBitsMax) + posState; |
503 | IF_BIT_0_CHECK(prob) | 503 | IF_BIT_0_CHECK(prob) |
504 | { | 504 | { |
505 | UPDATE_0_CHECK | 505 | UPDATE_0_CHECK |
506 | 506 | ||
507 | /* if (bufLimit - buf >= 7) return DUMMY_LIT; */ | 507 | /* if (bufLimit - buf >= 7) return DUMMY_LIT; */ |
508 | 508 | ||
509 | prob = probs + Literal; | 509 | prob = probs + Literal; |
510 | if (p->checkDicSize != 0 || p->processedPos != 0) | 510 | if (p->checkDicSize != 0 || p->processedPos != 0) |
511 | prob += (LZMA_LIT_SIZE * | 511 | prob += (LZMA_LIT_SIZE * |
512 | ((((p->processedPos) & ((1 << (p->prop.lp)) - 1)) << p->prop.lc) + | 512 | ((((p->processedPos) & ((1 << (p->prop.lp)) - 1)) << p->prop.lc) + |
513 | (p->dic[(p->dicPos == 0 ? p->dicBufSize : p->dicPos) - 1] >> (8 - p->prop.lc)))); | 513 | (p->dic[(p->dicPos == 0 ? p->dicBufSize : p->dicPos) - 1] >> (8 - p->prop.lc)))); |
514 | 514 | ||
515 | if (state < kNumLitStates) | 515 | if (state < kNumLitStates) |
516 | { | 516 | { |
517 | unsigned symbol = 1; | 517 | unsigned symbol = 1; |
518 | do { GET_BIT_CHECK(prob + symbol, symbol) } while (symbol < 0x100); | 518 | do { GET_BIT_CHECK(prob + symbol, symbol) } while (symbol < 0x100); |
519 | } | 519 | } |
520 | else | 520 | else |
521 | { | 521 | { |
522 | unsigned matchByte = p->dic[p->dicPos - p->reps[0] + | 522 | unsigned matchByte = p->dic[p->dicPos - p->reps[0] + |
523 | ((p->dicPos < p->reps[0]) ? p->dicBufSize : 0)]; | 523 | ((p->dicPos < p->reps[0]) ? p->dicBufSize : 0)]; |
524 | unsigned offs = 0x100; | 524 | unsigned offs = 0x100; |
525 | unsigned symbol = 1; | 525 | unsigned symbol = 1; |
526 | do | 526 | do |
527 | { | 527 | { |
528 | unsigned bit; | 528 | unsigned bit; |
529 | CLzmaProb *probLit; | 529 | CLzmaProb *probLit; |
530 | matchByte <<= 1; | 530 | matchByte <<= 1; |
531 | bit = (matchByte & offs); | 531 | bit = (matchByte & offs); |
532 | probLit = prob + offs + bit + symbol; | 532 | probLit = prob + offs + bit + symbol; |
533 | GET_BIT2_CHECK(probLit, symbol, offs &= ~bit, offs &= bit) | 533 | GET_BIT2_CHECK(probLit, symbol, offs &= ~bit, offs &= bit) |
534 | } | 534 | } |
535 | while (symbol < 0x100); | 535 | while (symbol < 0x100); |
536 | } | 536 | } |
537 | res = DUMMY_LIT; | 537 | res = DUMMY_LIT; |
538 | } | 538 | } |
539 | else | 539 | else |
540 | { | 540 | { |
541 | unsigned len; | 541 | unsigned len; |
542 | UPDATE_1_CHECK; | 542 | UPDATE_1_CHECK; |
543 | 543 | ||
544 | prob = probs + IsRep + state; | 544 | prob = probs + IsRep + state; |
545 | IF_BIT_0_CHECK(prob) | 545 | IF_BIT_0_CHECK(prob) |
546 | { | 546 | { |
547 | UPDATE_0_CHECK; | 547 | UPDATE_0_CHECK; |
548 | state = 0; | 548 | state = 0; |
549 | prob = probs + LenCoder; | 549 | prob = probs + LenCoder; |
550 | res = DUMMY_MATCH; | 550 | res = DUMMY_MATCH; |
551 | } | 551 | } |
552 | else | 552 | else |
553 | { | 553 | { |
554 | UPDATE_1_CHECK; | 554 | UPDATE_1_CHECK; |
555 | res = DUMMY_REP; | 555 | res = DUMMY_REP; |
556 | prob = probs + IsRepG0 + state; | 556 | prob = probs + IsRepG0 + state; |
557 | IF_BIT_0_CHECK(prob) | 557 | IF_BIT_0_CHECK(prob) |
558 | { | 558 | { |
559 | UPDATE_0_CHECK; | 559 | UPDATE_0_CHECK; |
560 | prob = probs + IsRep0Long + (state << kNumPosBitsMax) + posState; | 560 | prob = probs + IsRep0Long + (state << kNumPosBitsMax) + posState; |
561 | IF_BIT_0_CHECK(prob) | 561 | IF_BIT_0_CHECK(prob) |
562 | { | 562 | { |
563 | UPDATE_0_CHECK; | 563 | UPDATE_0_CHECK; |
564 | NORMALIZE_CHECK; | 564 | NORMALIZE_CHECK; |
565 | return DUMMY_REP; | 565 | return DUMMY_REP; |
566 | } | 566 | } |
567 | else | 567 | else |
568 | { | 568 | { |
569 | UPDATE_1_CHECK; | 569 | UPDATE_1_CHECK; |
570 | } | 570 | } |
571 | } | 571 | } |
572 | else | 572 | else |
573 | { | 573 | { |
574 | UPDATE_1_CHECK; | 574 | UPDATE_1_CHECK; |
575 | prob = probs + IsRepG1 + state; | 575 | prob = probs + IsRepG1 + state; |
576 | IF_BIT_0_CHECK(prob) | 576 | IF_BIT_0_CHECK(prob) |
577 | { | 577 | { |
578 | UPDATE_0_CHECK; | 578 | UPDATE_0_CHECK; |
579 | } | 579 | } |
580 | else | 580 | else |
581 | { | 581 | { |
582 | UPDATE_1_CHECK; | 582 | UPDATE_1_CHECK; |
583 | prob = probs + IsRepG2 + state; | 583 | prob = probs + IsRepG2 + state; |
584 | IF_BIT_0_CHECK(prob) | 584 | IF_BIT_0_CHECK(prob) |
585 | { | 585 | { |
586 | UPDATE_0_CHECK; | 586 | UPDATE_0_CHECK; |
587 | } | 587 | } |
588 | else | 588 | else |
589 | { | 589 | { |
590 | UPDATE_1_CHECK; | 590 | UPDATE_1_CHECK; |
591 | } | 591 | } |
592 | } | 592 | } |
593 | } | 593 | } |
594 | state = kNumStates; | 594 | state = kNumStates; |
595 | prob = probs + RepLenCoder; | 595 | prob = probs + RepLenCoder; |
596 | } | 596 | } |
597 | { | 597 | { |
598 | unsigned limit, offset; | 598 | unsigned limit, offset; |
599 | CLzmaProb *probLen = prob + LenChoice; | 599 | CLzmaProb *probLen = prob + LenChoice; |
600 | IF_BIT_0_CHECK(probLen) | 600 | IF_BIT_0_CHECK(probLen) |
601 | { | 601 | { |
602 | UPDATE_0_CHECK; | 602 | UPDATE_0_CHECK; |
603 | probLen = prob + LenLow + (posState << kLenNumLowBits); | 603 | probLen = prob + LenLow + (posState << kLenNumLowBits); |
604 | offset = 0; | 604 | offset = 0; |
605 | limit = 1 << kLenNumLowBits; | 605 | limit = 1 << kLenNumLowBits; |
606 | } | 606 | } |
607 | else | 607 | else |
608 | { | 608 | { |
609 | UPDATE_1_CHECK; | 609 | UPDATE_1_CHECK; |
610 | probLen = prob + LenChoice2; | 610 | probLen = prob + LenChoice2; |
611 | IF_BIT_0_CHECK(probLen) | 611 | IF_BIT_0_CHECK(probLen) |
612 | { | 612 | { |
613 | UPDATE_0_CHECK; | 613 | UPDATE_0_CHECK; |
614 | probLen = prob + LenMid + (posState << kLenNumMidBits); | 614 | probLen = prob + LenMid + (posState << kLenNumMidBits); |
615 | offset = kLenNumLowSymbols; | 615 | offset = kLenNumLowSymbols; |
616 | limit = 1 << kLenNumMidBits; | 616 | limit = 1 << kLenNumMidBits; |
617 | } | 617 | } |
618 | else | 618 | else |
619 | { | 619 | { |
620 | UPDATE_1_CHECK; | 620 | UPDATE_1_CHECK; |
621 | probLen = prob + LenHigh; | 621 | probLen = prob + LenHigh; |
622 | offset = kLenNumLowSymbols + kLenNumMidSymbols; | 622 | offset = kLenNumLowSymbols + kLenNumMidSymbols; |
623 | limit = 1 << kLenNumHighBits; | 623 | limit = 1 << kLenNumHighBits; |
624 | } | 624 | } |
625 | } | 625 | } |
626 | TREE_DECODE_CHECK(probLen, limit, len); | 626 | TREE_DECODE_CHECK(probLen, limit, len); |
627 | len += offset; | 627 | len += offset; |
628 | } | 628 | } |
629 | 629 | ||
630 | if (state < 4) | 630 | if (state < 4) |
631 | { | 631 | { |
632 | unsigned posSlot; | 632 | unsigned posSlot; |
633 | prob = probs + PosSlot + | 633 | prob = probs + PosSlot + |
634 | ((len < kNumLenToPosStates ? len : kNumLenToPosStates - 1) << | 634 | ((len < kNumLenToPosStates ? len : kNumLenToPosStates - 1) << |
635 | kNumPosSlotBits); | 635 | kNumPosSlotBits); |
636 | TREE_DECODE_CHECK(prob, 1 << kNumPosSlotBits, posSlot); | 636 | TREE_DECODE_CHECK(prob, 1 << kNumPosSlotBits, posSlot); |
637 | if (posSlot >= kStartPosModelIndex) | 637 | if (posSlot >= kStartPosModelIndex) |
638 | { | 638 | { |
639 | int numDirectBits = ((posSlot >> 1) - 1); | 639 | int numDirectBits = ((posSlot >> 1) - 1); |
640 | 640 | ||
641 | /* if (bufLimit - buf >= 8) return DUMMY_MATCH; */ | 641 | /* if (bufLimit - buf >= 8) return DUMMY_MATCH; */ |
642 | 642 | ||
643 | if (posSlot < kEndPosModelIndex) | 643 | if (posSlot < kEndPosModelIndex) |
644 | { | 644 | { |
645 | prob = probs + SpecPos + ((2 | (posSlot & 1)) << numDirectBits) - posSlot - 1; | 645 | prob = probs + SpecPos + ((2 | (posSlot & 1)) << numDirectBits) - posSlot - 1; |
646 | } | 646 | } |
647 | else | 647 | else |
648 | { | 648 | { |
649 | numDirectBits -= kNumAlignBits; | 649 | numDirectBits -= kNumAlignBits; |
650 | do | 650 | do |
651 | { | 651 | { |
652 | NORMALIZE_CHECK | 652 | NORMALIZE_CHECK |
653 | range >>= 1; | 653 | range >>= 1; |
654 | code -= range & (((code - range) >> 31) - 1); | 654 | code -= range & (((code - range) >> 31) - 1); |
655 | /* if (code >= range) code -= range; */ | 655 | /* if (code >= range) code -= range; */ |
656 | } | 656 | } |
657 | while (--numDirectBits != 0); | 657 | while (--numDirectBits != 0); |
658 | prob = probs + Align; | 658 | prob = probs + Align; |
659 | numDirectBits = kNumAlignBits; | 659 | numDirectBits = kNumAlignBits; |
660 | } | 660 | } |
661 | { | 661 | { |
662 | unsigned i = 1; | 662 | unsigned i = 1; |
663 | do | 663 | do |
664 | { | 664 | { |
665 | GET_BIT_CHECK(prob + i, i); | 665 | GET_BIT_CHECK(prob + i, i); |
666 | } | 666 | } |
667 | while (--numDirectBits != 0); | 667 | while (--numDirectBits != 0); |
668 | } | 668 | } |
669 | } | 669 | } |
670 | } | 670 | } |
671 | } | 671 | } |
672 | } | 672 | } |
673 | NORMALIZE_CHECK; | 673 | NORMALIZE_CHECK; |
674 | return res; | 674 | return res; |
675 | } | 675 | } |
676 | 676 | ||
677 | 677 | ||
678 | static void LzmaDec_InitRc(CLzmaDec *p, const Byte *data) | 678 | static void LzmaDec_InitRc(CLzmaDec *p, const Byte *data) |
679 | { | 679 | { |
680 | p->code = ((UInt32)data[1] << 24) | ((UInt32)data[2] << 16) | ((UInt32)data[3] << 8) | ((UInt32)data[4]); | 680 | p->code = ((UInt32)data[1] << 24) | ((UInt32)data[2] << 16) | ((UInt32)data[3] << 8) | ((UInt32)data[4]); |
681 | p->range = 0xFFFFFFFF; | 681 | p->range = 0xFFFFFFFF; |
682 | p->needFlush = 0; | 682 | p->needFlush = 0; |
683 | } | 683 | } |
684 | 684 | ||
685 | void LzmaDec_InitDicAndState(CLzmaDec *p, Bool initDic, Bool initState) | 685 | void LzmaDec_InitDicAndState(CLzmaDec *p, Bool initDic, Bool initState) |
686 | { | 686 | { |
687 | p->needFlush = 1; | 687 | p->needFlush = 1; |
688 | p->remainLen = 0; | 688 | p->remainLen = 0; |
689 | p->tempBufSize = 0; | 689 | p->tempBufSize = 0; |
690 | 690 | ||
691 | if (initDic) | 691 | if (initDic) |
692 | { | 692 | { |
693 | p->processedPos = 0; | 693 | p->processedPos = 0; |
694 | p->checkDicSize = 0; | 694 | p->checkDicSize = 0; |
695 | p->needInitState = 1; | 695 | p->needInitState = 1; |
696 | } | 696 | } |
697 | if (initState) | 697 | if (initState) |
698 | p->needInitState = 1; | 698 | p->needInitState = 1; |
699 | } | 699 | } |
700 | 700 | ||
701 | void LzmaDec_Init(CLzmaDec *p) | 701 | void LzmaDec_Init(CLzmaDec *p) |
702 | { | 702 | { |
703 | p->dicPos = 0; | 703 | p->dicPos = 0; |
704 | LzmaDec_InitDicAndState(p, True, True); | 704 | LzmaDec_InitDicAndState(p, True, True); |
705 | } | 705 | } |
706 | 706 | ||
707 | static void LzmaDec_InitStateReal(CLzmaDec *p) | 707 | static void LzmaDec_InitStateReal(CLzmaDec *p) |
708 | { | 708 | { |
709 | UInt32 numProbs = Literal + ((UInt32)LZMA_LIT_SIZE << (p->prop.lc + p->prop.lp)); | 709 | UInt32 numProbs = Literal + ((UInt32)LZMA_LIT_SIZE << (p->prop.lc + p->prop.lp)); |
710 | UInt32 i; | 710 | UInt32 i; |
711 | CLzmaProb *probs = p->probs; | 711 | CLzmaProb *probs = p->probs; |
712 | for (i = 0; i < numProbs; i++) | 712 | for (i = 0; i < numProbs; i++) |
713 | probs[i] = kBitModelTotal >> 1; | 713 | probs[i] = kBitModelTotal >> 1; |
714 | p->reps[0] = p->reps[1] = p->reps[2] = p->reps[3] = 1; | 714 | p->reps[0] = p->reps[1] = p->reps[2] = p->reps[3] = 1; |
715 | p->state = 0; | 715 | p->state = 0; |
716 | p->needInitState = 0; | 716 | p->needInitState = 0; |
717 | } | 717 | } |
718 | 718 | ||
719 | SRes LzmaDec_DecodeToDic(CLzmaDec *p, SizeT dicLimit, const Byte *src, SizeT *srcLen, | 719 | SRes LzmaDec_DecodeToDic(CLzmaDec *p, SizeT dicLimit, const Byte *src, SizeT *srcLen, |
720 | ELzmaFinishMode finishMode, ELzmaStatus *status) | 720 | ELzmaFinishMode finishMode, ELzmaStatus *status) |
721 | { | 721 | { |
722 | SizeT inSize = *srcLen; | 722 | SizeT inSize = *srcLen; |
723 | (*srcLen) = 0; | 723 | (*srcLen) = 0; |
724 | LzmaDec_WriteRem(p, dicLimit); | 724 | LzmaDec_WriteRem(p, dicLimit); |
725 | 725 | ||
726 | *status = LZMA_STATUS_NOT_SPECIFIED; | 726 | *status = LZMA_STATUS_NOT_SPECIFIED; |
727 | 727 | ||
728 | while (p->remainLen != kMatchSpecLenStart) | 728 | while (p->remainLen != kMatchSpecLenStart) |
729 | { | 729 | { |
730 | int checkEndMarkNow; | 730 | int checkEndMarkNow; |
731 | 731 | ||
732 | if (p->needFlush != 0) | 732 | if (p->needFlush != 0) |
733 | { | 733 | { |
734 | for (; inSize > 0 && p->tempBufSize < RC_INIT_SIZE; (*srcLen)++, inSize--) | 734 | for (; inSize > 0 && p->tempBufSize < RC_INIT_SIZE; (*srcLen)++, inSize--) |
735 | p->tempBuf[p->tempBufSize++] = *src++; | 735 | p->tempBuf[p->tempBufSize++] = *src++; |
736 | if (p->tempBufSize < RC_INIT_SIZE) | 736 | if (p->tempBufSize < RC_INIT_SIZE) |
737 | { | 737 | { |
738 | *status = LZMA_STATUS_NEEDS_MORE_INPUT; | 738 | *status = LZMA_STATUS_NEEDS_MORE_INPUT; |
739 | return SZ_OK; | 739 | return SZ_OK; |
740 | } | 740 | } |
741 | if (p->tempBuf[0] != 0) | 741 | if (p->tempBuf[0] != 0) |
742 | return SZ_ERROR_DATA; | 742 | return SZ_ERROR_DATA; |
743 | 743 | ||
744 | LzmaDec_InitRc(p, p->tempBuf); | 744 | LzmaDec_InitRc(p, p->tempBuf); |
745 | p->tempBufSize = 0; | 745 | p->tempBufSize = 0; |
746 | } | 746 | } |
747 | 747 | ||
748 | checkEndMarkNow = 0; | 748 | checkEndMarkNow = 0; |
749 | if (p->dicPos >= dicLimit) | 749 | if (p->dicPos >= dicLimit) |
750 | { | 750 | { |
751 | if (p->remainLen == 0 && p->code == 0) | 751 | if (p->remainLen == 0 && p->code == 0) |
752 | { | 752 | { |
753 | *status = LZMA_STATUS_MAYBE_FINISHED_WITHOUT_MARK; | 753 | *status = LZMA_STATUS_MAYBE_FINISHED_WITHOUT_MARK; |
754 | return SZ_OK; | 754 | return SZ_OK; |
755 | } | 755 | } |
756 | if (finishMode == LZMA_FINISH_ANY) | 756 | if (finishMode == LZMA_FINISH_ANY) |
757 | { | 757 | { |
758 | *status = LZMA_STATUS_NOT_FINISHED; | 758 | *status = LZMA_STATUS_NOT_FINISHED; |
759 | return SZ_OK; | 759 | return SZ_OK; |
760 | } | 760 | } |
761 | if (p->remainLen != 0) | 761 | if (p->remainLen != 0) |
762 | { | 762 | { |
763 | *status = LZMA_STATUS_NOT_FINISHED; | 763 | *status = LZMA_STATUS_NOT_FINISHED; |
764 | return SZ_ERROR_DATA; | 764 | return SZ_ERROR_DATA; |
765 | } | 765 | } |
766 | checkEndMarkNow = 1; | 766 | checkEndMarkNow = 1; |
767 | } | 767 | } |
768 | 768 | ||
769 | if (p->needInitState) | 769 | if (p->needInitState) |
770 | LzmaDec_InitStateReal(p); | 770 | LzmaDec_InitStateReal(p); |
771 | 771 | ||
772 | if (p->tempBufSize == 0) | 772 | if (p->tempBufSize == 0) |
773 | { | 773 | { |
774 | SizeT processed; | 774 | SizeT processed; |
775 | const Byte *bufLimit; | 775 | const Byte *bufLimit; |
776 | if (inSize < LZMA_REQUIRED_INPUT_MAX || checkEndMarkNow) | 776 | if (inSize < LZMA_REQUIRED_INPUT_MAX || checkEndMarkNow) |
777 | { | 777 | { |
778 | int dummyRes = LzmaDec_TryDummy(p, src, inSize); | 778 | int dummyRes = LzmaDec_TryDummy(p, src, inSize); |
779 | if (dummyRes == DUMMY_ERROR) | 779 | if (dummyRes == DUMMY_ERROR) |
780 | { | 780 | { |
781 | memcpy(p->tempBuf, src, inSize); | 781 | memcpy(p->tempBuf, src, inSize); |
782 | p->tempBufSize = (unsigned)inSize; | 782 | p->tempBufSize = (unsigned)inSize; |
783 | (*srcLen) += inSize; | 783 | (*srcLen) += inSize; |
784 | *status = LZMA_STATUS_NEEDS_MORE_INPUT; | 784 | *status = LZMA_STATUS_NEEDS_MORE_INPUT; |
785 | return SZ_OK; | 785 | return SZ_OK; |
786 | } | 786 | } |
787 | if (checkEndMarkNow && dummyRes != DUMMY_MATCH) | 787 | if (checkEndMarkNow && dummyRes != DUMMY_MATCH) |
788 | { | 788 | { |
789 | *status = LZMA_STATUS_NOT_FINISHED; | 789 | *status = LZMA_STATUS_NOT_FINISHED; |
790 | return SZ_ERROR_DATA; | 790 | return SZ_ERROR_DATA; |
791 | } | 791 | } |
792 | bufLimit = src; | 792 | bufLimit = src; |
793 | } | 793 | } |
794 | else | 794 | else |
795 | bufLimit = src + inSize - LZMA_REQUIRED_INPUT_MAX; | 795 | bufLimit = src + inSize - LZMA_REQUIRED_INPUT_MAX; |
796 | p->buf = src; | 796 | p->buf = src; |
797 | if (LzmaDec_DecodeReal2(p, dicLimit, bufLimit) != 0) | 797 | if (LzmaDec_DecodeReal2(p, dicLimit, bufLimit) != 0) |
798 | return SZ_ERROR_DATA; | 798 | return SZ_ERROR_DATA; |
799 | processed = (SizeT)(p->buf - src); | 799 | processed = (SizeT)(p->buf - src); |
800 | (*srcLen) += processed; | 800 | (*srcLen) += processed; |
801 | src += processed; | 801 | src += processed; |
802 | inSize -= processed; | 802 | inSize -= processed; |
803 | } | 803 | } |
804 | else | 804 | else |
805 | { | 805 | { |
806 | unsigned rem = p->tempBufSize, lookAhead = 0; | 806 | unsigned rem = p->tempBufSize, lookAhead = 0; |
807 | while (rem < LZMA_REQUIRED_INPUT_MAX && lookAhead < inSize) | 807 | while (rem < LZMA_REQUIRED_INPUT_MAX && lookAhead < inSize) |
808 | p->tempBuf[rem++] = src[lookAhead++]; | 808 | p->tempBuf[rem++] = src[lookAhead++]; |
809 | p->tempBufSize = rem; | 809 | p->tempBufSize = rem; |
810 | if (rem < LZMA_REQUIRED_INPUT_MAX || checkEndMarkNow) | 810 | if (rem < LZMA_REQUIRED_INPUT_MAX || checkEndMarkNow) |
811 | { | 811 | { |
812 | int dummyRes = LzmaDec_TryDummy(p, p->tempBuf, rem); | 812 | int dummyRes = LzmaDec_TryDummy(p, p->tempBuf, rem); |
813 | if (dummyRes == DUMMY_ERROR) | 813 | if (dummyRes == DUMMY_ERROR) |
814 | { | 814 | { |
815 | (*srcLen) += lookAhead; | 815 | (*srcLen) += lookAhead; |
816 | *status = LZMA_STATUS_NEEDS_MORE_INPUT; | 816 | *status = LZMA_STATUS_NEEDS_MORE_INPUT; |
817 | return SZ_OK; | 817 | return SZ_OK; |
818 | } | 818 | } |
819 | if (checkEndMarkNow && dummyRes != DUMMY_MATCH) | 819 | if (checkEndMarkNow && dummyRes != DUMMY_MATCH) |
820 | { | 820 | { |
821 | *status = LZMA_STATUS_NOT_FINISHED; | 821 | *status = LZMA_STATUS_NOT_FINISHED; |
822 | return SZ_ERROR_DATA; | 822 | return SZ_ERROR_DATA; |
823 | } | 823 | } |
824 | } | 824 | } |
825 | p->buf = p->tempBuf; | 825 | p->buf = p->tempBuf; |
826 | if (LzmaDec_DecodeReal2(p, dicLimit, p->buf) != 0) | 826 | if (LzmaDec_DecodeReal2(p, dicLimit, p->buf) != 0) |
827 | return SZ_ERROR_DATA; | 827 | return SZ_ERROR_DATA; |
828 | lookAhead -= (rem - (unsigned)(p->buf - p->tempBuf)); | 828 | lookAhead -= (rem - (unsigned)(p->buf - p->tempBuf)); |
829 | (*srcLen) += lookAhead; | 829 | (*srcLen) += lookAhead; |
830 | src += lookAhead; | 830 | src += lookAhead; |
831 | inSize -= lookAhead; | 831 | inSize -= lookAhead; |
832 | p->tempBufSize = 0; | 832 | p->tempBufSize = 0; |
833 | } | 833 | } |
834 | } | 834 | } |
835 | if (p->code == 0) | 835 | if (p->code == 0) |
836 | *status = LZMA_STATUS_FINISHED_WITH_MARK; | 836 | *status = LZMA_STATUS_FINISHED_WITH_MARK; |
837 | return (p->code == 0) ? SZ_OK : SZ_ERROR_DATA; | 837 | return (p->code == 0) ? SZ_OK : SZ_ERROR_DATA; |
838 | } | 838 | } |
839 | 839 | ||
840 | SRes LzmaDec_DecodeToBuf(CLzmaDec *p, Byte *dest, SizeT *destLen, const Byte *src, SizeT *srcLen, ELzmaFinishMode finishMode, ELzmaStatus *status) | 840 | SRes LzmaDec_DecodeToBuf(CLzmaDec *p, Byte *dest, SizeT *destLen, const Byte *src, SizeT *srcLen, ELzmaFinishMode finishMode, ELzmaStatus *status) |
841 | { | 841 | { |
842 | SizeT outSize = *destLen; | 842 | SizeT outSize = *destLen; |
843 | SizeT inSize = *srcLen; | 843 | SizeT inSize = *srcLen; |
844 | *srcLen = *destLen = 0; | 844 | *srcLen = *destLen = 0; |
845 | for (;;) | 845 | for (;;) |
846 | { | 846 | { |
847 | SizeT inSizeCur = inSize, outSizeCur, dicPos; | 847 | SizeT inSizeCur = inSize, outSizeCur, dicPos; |
848 | ELzmaFinishMode curFinishMode; | 848 | ELzmaFinishMode curFinishMode; |
849 | SRes res; | 849 | SRes res; |
850 | if (p->dicPos == p->dicBufSize) | 850 | if (p->dicPos == p->dicBufSize) |
851 | p->dicPos = 0; | 851 | p->dicPos = 0; |
852 | dicPos = p->dicPos; | 852 | dicPos = p->dicPos; |
853 | if (outSize > p->dicBufSize - dicPos) | 853 | if (outSize > p->dicBufSize - dicPos) |
854 | { | 854 | { |
855 | outSizeCur = p->dicBufSize; | 855 | outSizeCur = p->dicBufSize; |
856 | curFinishMode = LZMA_FINISH_ANY; | 856 | curFinishMode = LZMA_FINISH_ANY; |
857 | } | 857 | } |
858 | else | 858 | else |
859 | { | 859 | { |
860 | outSizeCur = dicPos + outSize; | 860 | outSizeCur = dicPos + outSize; |
861 | curFinishMode = finishMode; | 861 | curFinishMode = finishMode; |
862 | } | 862 | } |
863 | 863 | ||
864 | res = LzmaDec_DecodeToDic(p, outSizeCur, src, &inSizeCur, curFinishMode, status); | 864 | res = LzmaDec_DecodeToDic(p, outSizeCur, src, &inSizeCur, curFinishMode, status); |
865 | src += inSizeCur; | 865 | src += inSizeCur; |
866 | inSize -= inSizeCur; | 866 | inSize -= inSizeCur; |
867 | *srcLen += inSizeCur; | 867 | *srcLen += inSizeCur; |
868 | outSizeCur = p->dicPos - dicPos; | 868 | outSizeCur = p->dicPos - dicPos; |
869 | memcpy(dest, p->dic + dicPos, outSizeCur); | 869 | memcpy(dest, p->dic + dicPos, outSizeCur); |
870 | dest += outSizeCur; | 870 | dest += outSizeCur; |
871 | outSize -= outSizeCur; | 871 | outSize -= outSizeCur; |
872 | *destLen += outSizeCur; | 872 | *destLen += outSizeCur; |
873 | if (res != 0) | 873 | if (res != 0) |
874 | return res; | 874 | return res; |
875 | if (outSizeCur == 0 || outSize == 0) | 875 | if (outSizeCur == 0 || outSize == 0) |
876 | return SZ_OK; | 876 | return SZ_OK; |
877 | } | 877 | } |
878 | } | 878 | } |
879 | 879 | ||
880 | void LzmaDec_FreeProbs(CLzmaDec *p, ISzAlloc *alloc) | 880 | void LzmaDec_FreeProbs(CLzmaDec *p, ISzAlloc *alloc) |
881 | { | 881 | { |
882 | alloc->Free(alloc, p->probs); | 882 | alloc->Free(alloc, p->probs); |
883 | p->probs = 0; | 883 | p->probs = 0; |
884 | } | 884 | } |
885 | 885 | ||
886 | static void LzmaDec_FreeDict(CLzmaDec *p, ISzAlloc *alloc) | 886 | static void LzmaDec_FreeDict(CLzmaDec *p, ISzAlloc *alloc) |
887 | { | 887 | { |
888 | alloc->Free(alloc, p->dic); | 888 | alloc->Free(alloc, p->dic); |
889 | p->dic = 0; | 889 | p->dic = 0; |
890 | } | 890 | } |
891 | 891 | ||
892 | void LzmaDec_Free(CLzmaDec *p, ISzAlloc *alloc) | 892 | void LzmaDec_Free(CLzmaDec *p, ISzAlloc *alloc) |
893 | { | 893 | { |
894 | LzmaDec_FreeProbs(p, alloc); | 894 | LzmaDec_FreeProbs(p, alloc); |
895 | LzmaDec_FreeDict(p, alloc); | 895 | LzmaDec_FreeDict(p, alloc); |
896 | } | 896 | } |
897 | 897 | ||
898 | SRes LzmaProps_Decode(CLzmaProps *p, const Byte *data, unsigned size) | 898 | SRes LzmaProps_Decode(CLzmaProps *p, const Byte *data, unsigned size) |
899 | { | 899 | { |
900 | UInt32 dicSize; | 900 | UInt32 dicSize; |
901 | Byte d; | 901 | Byte d; |
902 | 902 | ||
903 | if (size < LZMA_PROPS_SIZE) | 903 | if (size < LZMA_PROPS_SIZE) |
904 | return SZ_ERROR_UNSUPPORTED; | 904 | return SZ_ERROR_UNSUPPORTED; |
905 | else | 905 | else |
906 | dicSize = data[1] | ((UInt32)data[2] << 8) | ((UInt32)data[3] << 16) | ((UInt32)data[4] << 24); | 906 | dicSize = data[1] | ((UInt32)data[2] << 8) | ((UInt32)data[3] << 16) | ((UInt32)data[4] << 24); |
907 | 907 | ||
908 | if (dicSize < LZMA_DIC_MIN) | 908 | if (dicSize < LZMA_DIC_MIN) |
909 | dicSize = LZMA_DIC_MIN; | 909 | dicSize = LZMA_DIC_MIN; |
910 | p->dicSize = dicSize; | 910 | p->dicSize = dicSize; |
911 | 911 | ||
912 | d = data[0]; | 912 | d = data[0]; |
913 | if (d >= (9 * 5 * 5)) | 913 | if (d >= (9 * 5 * 5)) |
914 | return SZ_ERROR_UNSUPPORTED; | 914 | return SZ_ERROR_UNSUPPORTED; |
915 | 915 | ||
916 | p->lc = d % 9; | 916 | p->lc = d % 9; |
917 | d /= 9; | 917 | d /= 9; |
918 | p->pb = d / 5; | 918 | p->pb = d / 5; |
919 | p->lp = d % 5; | 919 | p->lp = d % 5; |
920 | 920 | ||
921 | return SZ_OK; | 921 | return SZ_OK; |
922 | } | 922 | } |
923 | 923 | ||
924 | static SRes LzmaDec_AllocateProbs2(CLzmaDec *p, const CLzmaProps *propNew, ISzAlloc *alloc) | 924 | static SRes LzmaDec_AllocateProbs2(CLzmaDec *p, const CLzmaProps *propNew, ISzAlloc *alloc) |
925 | { | 925 | { |
926 | UInt32 numProbs = LzmaProps_GetNumProbs(propNew); | 926 | UInt32 numProbs = LzmaProps_GetNumProbs(propNew); |
927 | if (p->probs == 0 || numProbs != p->numProbs) | 927 | if (p->probs == 0 || numProbs != p->numProbs) |
928 | { | 928 | { |
929 | LzmaDec_FreeProbs(p, alloc); | 929 | LzmaDec_FreeProbs(p, alloc); |
930 | p->probs = (CLzmaProb *)alloc->Alloc(alloc, numProbs * sizeof(CLzmaProb)); | 930 | p->probs = (CLzmaProb *)alloc->Alloc(alloc, numProbs * sizeof(CLzmaProb)); |
931 | p->numProbs = numProbs; | 931 | p->numProbs = numProbs; |
932 | if (p->probs == 0) | 932 | if (p->probs == 0) |
933 | return SZ_ERROR_MEM; | 933 | return SZ_ERROR_MEM; |
934 | } | 934 | } |
935 | return SZ_OK; | 935 | return SZ_OK; |
936 | } | 936 | } |
937 | 937 | ||
938 | SRes LzmaDec_AllocateProbs(CLzmaDec *p, const Byte *props, unsigned propsSize, ISzAlloc *alloc) | 938 | SRes LzmaDec_AllocateProbs(CLzmaDec *p, const Byte *props, unsigned propsSize, ISzAlloc *alloc) |
939 | { | 939 | { |
940 | CLzmaProps propNew; | 940 | CLzmaProps propNew; |
941 | RINOK(LzmaProps_Decode(&propNew, props, propsSize)); | 941 | RINOK(LzmaProps_Decode(&propNew, props, propsSize)); |
942 | RINOK(LzmaDec_AllocateProbs2(p, &propNew, alloc)); | 942 | RINOK(LzmaDec_AllocateProbs2(p, &propNew, alloc)); |
943 | p->prop = propNew; | 943 | p->prop = propNew; |
944 | return SZ_OK; | 944 | return SZ_OK; |
945 | } | 945 | } |
946 | 946 | ||
947 | SRes LzmaDec_Allocate(CLzmaDec *p, const Byte *props, unsigned propsSize, ISzAlloc *alloc) | 947 | SRes LzmaDec_Allocate(CLzmaDec *p, const Byte *props, unsigned propsSize, ISzAlloc *alloc) |
948 | { | 948 | { |
949 | CLzmaProps propNew; | 949 | CLzmaProps propNew; |
950 | SizeT dicBufSize; | 950 | SizeT dicBufSize; |
951 | RINOK(LzmaProps_Decode(&propNew, props, propsSize)); | 951 | RINOK(LzmaProps_Decode(&propNew, props, propsSize)); |
952 | RINOK(LzmaDec_AllocateProbs2(p, &propNew, alloc)); | 952 | RINOK(LzmaDec_AllocateProbs2(p, &propNew, alloc)); |
953 | dicBufSize = propNew.dicSize; | 953 | dicBufSize = propNew.dicSize; |
954 | if (p->dic == 0 || dicBufSize != p->dicBufSize) | 954 | if (p->dic == 0 || dicBufSize != p->dicBufSize) |
955 | { | 955 | { |
956 | LzmaDec_FreeDict(p, alloc); | 956 | LzmaDec_FreeDict(p, alloc); |
957 | p->dic = (Byte *)alloc->Alloc(alloc, dicBufSize); | 957 | p->dic = (Byte *)alloc->Alloc(alloc, dicBufSize); |
958 | if (p->dic == 0) | 958 | if (p->dic == 0) |
959 | { | 959 | { |
960 | LzmaDec_FreeProbs(p, alloc); | 960 | LzmaDec_FreeProbs(p, alloc); |
961 | return SZ_ERROR_MEM; | 961 | return SZ_ERROR_MEM; |
962 | } | 962 | } |
963 | } | 963 | } |
964 | p->dicBufSize = dicBufSize; | 964 | p->dicBufSize = dicBufSize; |
965 | p->prop = propNew; | 965 | p->prop = propNew; |
966 | return SZ_OK; | 966 | return SZ_OK; |
967 | } | 967 | } |
968 | 968 | ||
969 | SRes LzmaDecode(Byte *dest, SizeT *destLen, const Byte *src, SizeT *srcLen, | 969 | SRes LzmaDecode(Byte *dest, SizeT *destLen, const Byte *src, SizeT *srcLen, |
970 | const Byte *propData, unsigned propSize, ELzmaFinishMode finishMode, | 970 | const Byte *propData, unsigned propSize, ELzmaFinishMode finishMode, |
971 | ELzmaStatus *status, ISzAlloc *alloc) | 971 | ELzmaStatus *status, ISzAlloc *alloc) |
972 | { | 972 | { |
973 | CLzmaDec p; | 973 | CLzmaDec p; |
974 | SRes res; | 974 | SRes res; |
975 | SizeT inSize = *srcLen; | 975 | SizeT inSize = *srcLen; |
976 | SizeT outSize = *destLen; | 976 | SizeT outSize = *destLen; |
977 | *srcLen = *destLen = 0; | 977 | *srcLen = *destLen = 0; |
978 | if (inSize < RC_INIT_SIZE) | 978 | if (inSize < RC_INIT_SIZE) |
979 | return SZ_ERROR_INPUT_EOF; | 979 | return SZ_ERROR_INPUT_EOF; |
980 | 980 | ||
981 | LzmaDec_Construct(&p); | 981 | LzmaDec_Construct(&p); |
982 | res = LzmaDec_AllocateProbs(&p, propData, propSize, alloc); | 982 | res = LzmaDec_AllocateProbs(&p, propData, propSize, alloc); |
983 | if (res != 0) | 983 | if (res != 0) |
984 | return res; | 984 | return res; |
985 | p.dic = dest; | 985 | p.dic = dest; |
986 | p.dicBufSize = outSize; | 986 | p.dicBufSize = outSize; |
987 | 987 | ||
988 | LzmaDec_Init(&p); | 988 | LzmaDec_Init(&p); |
989 | 989 | ||
990 | *srcLen = inSize; | 990 | *srcLen = inSize; |
991 | res = LzmaDec_DecodeToDic(&p, outSize, src, srcLen, finishMode, status); | 991 | res = LzmaDec_DecodeToDic(&p, outSize, src, srcLen, finishMode, status); |
992 | 992 | ||
993 | if (res == SZ_OK && *status == LZMA_STATUS_NEEDS_MORE_INPUT) | 993 | if (res == SZ_OK && *status == LZMA_STATUS_NEEDS_MORE_INPUT) |
994 | res = SZ_ERROR_INPUT_EOF; | 994 | res = SZ_ERROR_INPUT_EOF; |
995 | 995 | ||
996 | (*destLen) = p.dicPos; | 996 | (*destLen) = p.dicPos; |
997 | LzmaDec_FreeProbs(&p, alloc); | 997 | LzmaDec_FreeProbs(&p, alloc); |
998 | return res; | 998 | return res; |
999 | } | 999 | } |
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 |
diff --git a/libraries/irrlicht-1.8/source/Irrlicht/lzma/Types.h b/libraries/irrlicht-1.8/source/Irrlicht/lzma/Types.h index f193ce2..7732c24 100644 --- a/libraries/irrlicht-1.8/source/Irrlicht/lzma/Types.h +++ b/libraries/irrlicht-1.8/source/Irrlicht/lzma/Types.h | |||
@@ -1,254 +1,254 @@ | |||
1 | /* Types.h -- Basic types | 1 | /* Types.h -- Basic types |
2 | 2010-10-09 : Igor Pavlov : Public domain */ | 2 | 2010-10-09 : Igor Pavlov : Public domain */ |
3 | 3 | ||
4 | #ifndef __7Z_TYPES_H | 4 | #ifndef __7Z_TYPES_H |
5 | #define __7Z_TYPES_H | 5 | #define __7Z_TYPES_H |
6 | 6 | ||
7 | #include <stddef.h> | 7 | #include <stddef.h> |
8 | 8 | ||
9 | #ifdef _WIN32 | 9 | #ifdef _WIN32 |
10 | #include <windows.h> | 10 | #include <windows.h> |
11 | #endif | 11 | #endif |
12 | 12 | ||
13 | #ifndef EXTERN_C_BEGIN | 13 | #ifndef EXTERN_C_BEGIN |
14 | #ifdef __cplusplus | 14 | #ifdef __cplusplus |
15 | #define EXTERN_C_BEGIN extern "C" { | 15 | #define EXTERN_C_BEGIN extern "C" { |
16 | #define EXTERN_C_END } | 16 | #define EXTERN_C_END } |
17 | #else | 17 | #else |
18 | #define EXTERN_C_BEGIN | 18 | #define EXTERN_C_BEGIN |
19 | #define EXTERN_C_END | 19 | #define EXTERN_C_END |
20 | #endif | 20 | #endif |
21 | #endif | 21 | #endif |
22 | 22 | ||
23 | EXTERN_C_BEGIN | 23 | EXTERN_C_BEGIN |
24 | 24 | ||
25 | #define SZ_OK 0 | 25 | #define SZ_OK 0 |
26 | 26 | ||
27 | #define SZ_ERROR_DATA 1 | 27 | #define SZ_ERROR_DATA 1 |
28 | #define SZ_ERROR_MEM 2 | 28 | #define SZ_ERROR_MEM 2 |
29 | #define SZ_ERROR_CRC 3 | 29 | #define SZ_ERROR_CRC 3 |
30 | #define SZ_ERROR_UNSUPPORTED 4 | 30 | #define SZ_ERROR_UNSUPPORTED 4 |
31 | #define SZ_ERROR_PARAM 5 | 31 | #define SZ_ERROR_PARAM 5 |
32 | #define SZ_ERROR_INPUT_EOF 6 | 32 | #define SZ_ERROR_INPUT_EOF 6 |
33 | #define SZ_ERROR_OUTPUT_EOF 7 | 33 | #define SZ_ERROR_OUTPUT_EOF 7 |
34 | #define SZ_ERROR_READ 8 | 34 | #define SZ_ERROR_READ 8 |
35 | #define SZ_ERROR_WRITE 9 | 35 | #define SZ_ERROR_WRITE 9 |
36 | #define SZ_ERROR_PROGRESS 10 | 36 | #define SZ_ERROR_PROGRESS 10 |
37 | #define SZ_ERROR_FAIL 11 | 37 | #define SZ_ERROR_FAIL 11 |
38 | #define SZ_ERROR_THREAD 12 | 38 | #define SZ_ERROR_THREAD 12 |
39 | 39 | ||
40 | #define SZ_ERROR_ARCHIVE 16 | 40 | #define SZ_ERROR_ARCHIVE 16 |
41 | #define SZ_ERROR_NO_ARCHIVE 17 | 41 | #define SZ_ERROR_NO_ARCHIVE 17 |
42 | 42 | ||
43 | typedef int SRes; | 43 | typedef int SRes; |
44 | 44 | ||
45 | #ifdef _WIN32 | 45 | #ifdef _WIN32 |
46 | typedef DWORD WRes; | 46 | typedef DWORD WRes; |
47 | #else | 47 | #else |
48 | typedef int WRes; | 48 | typedef int WRes; |
49 | #endif | 49 | #endif |
50 | 50 | ||
51 | #ifndef RINOK | 51 | #ifndef RINOK |
52 | #define RINOK(x) { int __result__ = (x); if (__result__ != 0) return __result__; } | 52 | #define RINOK(x) { int __result__ = (x); if (__result__ != 0) return __result__; } |
53 | #endif | 53 | #endif |
54 | 54 | ||
55 | typedef unsigned char Byte; | 55 | typedef unsigned char Byte; |
56 | typedef short Int16; | 56 | typedef short Int16; |
57 | typedef unsigned short UInt16; | 57 | typedef unsigned short UInt16; |
58 | 58 | ||
59 | #ifdef _LZMA_UINT32_IS_ULONG | 59 | #ifdef _LZMA_UINT32_IS_ULONG |
60 | typedef long Int32; | 60 | typedef long Int32; |
61 | typedef unsigned long UInt32; | 61 | typedef unsigned long UInt32; |
62 | #else | 62 | #else |
63 | typedef int Int32; | 63 | typedef int Int32; |
64 | typedef unsigned int UInt32; | 64 | typedef unsigned int UInt32; |
65 | #endif | 65 | #endif |
66 | 66 | ||
67 | #ifdef _SZ_NO_INT_64 | 67 | #ifdef _SZ_NO_INT_64 |
68 | 68 | ||
69 | /* define _SZ_NO_INT_64, if your compiler doesn't support 64-bit integers. | 69 | /* define _SZ_NO_INT_64, if your compiler doesn't support 64-bit integers. |
70 | NOTES: Some code will work incorrectly in that case! */ | 70 | NOTES: Some code will work incorrectly in that case! */ |
71 | 71 | ||
72 | typedef long Int64; | 72 | typedef long Int64; |
73 | typedef unsigned long UInt64; | 73 | typedef unsigned long UInt64; |
74 | 74 | ||
75 | #else | 75 | #else |
76 | 76 | ||
77 | #if defined(_MSC_VER) || defined(__BORLANDC__) | 77 | #if defined(_MSC_VER) || defined(__BORLANDC__) |
78 | typedef __int64 Int64; | 78 | typedef __int64 Int64; |
79 | typedef unsigned __int64 UInt64; | 79 | typedef unsigned __int64 UInt64; |
80 | #define UINT64_CONST(n) n | 80 | #define UINT64_CONST(n) n |
81 | #else | 81 | #else |
82 | typedef long long int Int64; | 82 | typedef long long int Int64; |
83 | typedef unsigned long long int UInt64; | 83 | typedef unsigned long long int UInt64; |
84 | #define UINT64_CONST(n) n ## ULL | 84 | #define UINT64_CONST(n) n ## ULL |
85 | #endif | 85 | #endif |
86 | 86 | ||
87 | #endif | 87 | #endif |
88 | 88 | ||
89 | #ifdef _LZMA_NO_SYSTEM_SIZE_T | 89 | #ifdef _LZMA_NO_SYSTEM_SIZE_T |
90 | typedef UInt32 SizeT; | 90 | typedef UInt32 SizeT; |
91 | #else | 91 | #else |
92 | typedef size_t SizeT; | 92 | typedef size_t SizeT; |
93 | #endif | 93 | #endif |
94 | 94 | ||
95 | typedef int Bool; | 95 | typedef int Bool; |
96 | #define True 1 | 96 | #define True 1 |
97 | #define False 0 | 97 | #define False 0 |
98 | 98 | ||
99 | 99 | ||
100 | #ifdef _WIN32 | 100 | #ifdef _WIN32 |
101 | #define MY_STD_CALL __stdcall | 101 | #define MY_STD_CALL __stdcall |
102 | #else | 102 | #else |
103 | #define MY_STD_CALL | 103 | #define MY_STD_CALL |
104 | #endif | 104 | #endif |
105 | 105 | ||
106 | #ifdef _MSC_VER | 106 | #ifdef _MSC_VER |
107 | 107 | ||
108 | #if _MSC_VER >= 1300 | 108 | #if _MSC_VER >= 1300 |
109 | #define MY_NO_INLINE __declspec(noinline) | 109 | #define MY_NO_INLINE __declspec(noinline) |
110 | #else | 110 | #else |
111 | #define MY_NO_INLINE | 111 | #define MY_NO_INLINE |
112 | #endif | 112 | #endif |
113 | 113 | ||
114 | #define MY_CDECL __cdecl | 114 | #define MY_CDECL __cdecl |
115 | #define MY_FAST_CALL __fastcall | 115 | #define MY_FAST_CALL __fastcall |
116 | 116 | ||
117 | #else | 117 | #else |
118 | 118 | ||
119 | #define MY_CDECL | 119 | #define MY_CDECL |
120 | #define MY_FAST_CALL | 120 | #define MY_FAST_CALL |
121 | 121 | ||
122 | #endif | 122 | #endif |
123 | 123 | ||
124 | 124 | ||
125 | /* The following interfaces use first parameter as pointer to structure */ | 125 | /* The following interfaces use first parameter as pointer to structure */ |
126 | 126 | ||
127 | typedef struct | 127 | typedef struct |
128 | { | 128 | { |
129 | Byte (*Read)(void *p); /* reads one byte, returns 0 in case of EOF or error */ | 129 | Byte (*Read)(void *p); /* reads one byte, returns 0 in case of EOF or error */ |
130 | } IByteIn; | 130 | } IByteIn; |
131 | 131 | ||
132 | typedef struct | 132 | typedef struct |
133 | { | 133 | { |
134 | void (*Write)(void *p, Byte b); | 134 | void (*Write)(void *p, Byte b); |
135 | } IByteOut; | 135 | } IByteOut; |
136 | 136 | ||
137 | typedef struct | 137 | typedef struct |
138 | { | 138 | { |
139 | SRes (*Read)(void *p, void *buf, size_t *size); | 139 | SRes (*Read)(void *p, void *buf, size_t *size); |
140 | /* if (input(*size) != 0 && output(*size) == 0) means end_of_stream. | 140 | /* if (input(*size) != 0 && output(*size) == 0) means end_of_stream. |
141 | (output(*size) < input(*size)) is allowed */ | 141 | (output(*size) < input(*size)) is allowed */ |
142 | } ISeqInStream; | 142 | } ISeqInStream; |
143 | 143 | ||
144 | /* it can return SZ_ERROR_INPUT_EOF */ | 144 | /* it can return SZ_ERROR_INPUT_EOF */ |
145 | SRes SeqInStream_Read(ISeqInStream *stream, void *buf, size_t size); | 145 | SRes SeqInStream_Read(ISeqInStream *stream, void *buf, size_t size); |
146 | SRes SeqInStream_Read2(ISeqInStream *stream, void *buf, size_t size, SRes errorType); | 146 | SRes SeqInStream_Read2(ISeqInStream *stream, void *buf, size_t size, SRes errorType); |
147 | SRes SeqInStream_ReadByte(ISeqInStream *stream, Byte *buf); | 147 | SRes SeqInStream_ReadByte(ISeqInStream *stream, Byte *buf); |
148 | 148 | ||
149 | typedef struct | 149 | typedef struct |
150 | { | 150 | { |
151 | size_t (*Write)(void *p, const void *buf, size_t size); | 151 | size_t (*Write)(void *p, const void *buf, size_t size); |
152 | /* Returns: result - the number of actually written bytes. | 152 | /* Returns: result - the number of actually written bytes. |
153 | (result < size) means error */ | 153 | (result < size) means error */ |
154 | } ISeqOutStream; | 154 | } ISeqOutStream; |
155 | 155 | ||
156 | typedef enum | 156 | typedef enum |
157 | { | 157 | { |
158 | SZ_SEEK_SET = 0, | 158 | SZ_SEEK_SET = 0, |
159 | SZ_SEEK_CUR = 1, | 159 | SZ_SEEK_CUR = 1, |
160 | SZ_SEEK_END = 2 | 160 | SZ_SEEK_END = 2 |
161 | } ESzSeek; | 161 | } ESzSeek; |
162 | 162 | ||
163 | typedef struct | 163 | typedef struct |
164 | { | 164 | { |
165 | SRes (*Read)(void *p, void *buf, size_t *size); /* same as ISeqInStream::Read */ | 165 | SRes (*Read)(void *p, void *buf, size_t *size); /* same as ISeqInStream::Read */ |
166 | SRes (*Seek)(void *p, Int64 *pos, ESzSeek origin); | 166 | SRes (*Seek)(void *p, Int64 *pos, ESzSeek origin); |
167 | } ISeekInStream; | 167 | } ISeekInStream; |
168 | 168 | ||
169 | typedef struct | 169 | typedef struct |
170 | { | 170 | { |
171 | SRes (*Look)(void *p, const void **buf, size_t *size); | 171 | SRes (*Look)(void *p, const void **buf, size_t *size); |
172 | /* if (input(*size) != 0 && output(*size) == 0) means end_of_stream. | 172 | /* if (input(*size) != 0 && output(*size) == 0) means end_of_stream. |
173 | (output(*size) > input(*size)) is not allowed | 173 | (output(*size) > input(*size)) is not allowed |
174 | (output(*size) < input(*size)) is allowed */ | 174 | (output(*size) < input(*size)) is allowed */ |
175 | SRes (*Skip)(void *p, size_t offset); | 175 | SRes (*Skip)(void *p, size_t offset); |
176 | /* offset must be <= output(*size) of Look */ | 176 | /* offset must be <= output(*size) of Look */ |
177 | 177 | ||
178 | SRes (*Read)(void *p, void *buf, size_t *size); | 178 | SRes (*Read)(void *p, void *buf, size_t *size); |
179 | /* reads directly (without buffer). It's same as ISeqInStream::Read */ | 179 | /* reads directly (without buffer). It's same as ISeqInStream::Read */ |
180 | SRes (*Seek)(void *p, Int64 *pos, ESzSeek origin); | 180 | SRes (*Seek)(void *p, Int64 *pos, ESzSeek origin); |
181 | } ILookInStream; | 181 | } ILookInStream; |
182 | 182 | ||
183 | SRes LookInStream_LookRead(ILookInStream *stream, void *buf, size_t *size); | 183 | SRes LookInStream_LookRead(ILookInStream *stream, void *buf, size_t *size); |
184 | SRes LookInStream_SeekTo(ILookInStream *stream, UInt64 offset); | 184 | SRes LookInStream_SeekTo(ILookInStream *stream, UInt64 offset); |
185 | 185 | ||
186 | /* reads via ILookInStream::Read */ | 186 | /* reads via ILookInStream::Read */ |
187 | SRes LookInStream_Read2(ILookInStream *stream, void *buf, size_t size, SRes errorType); | 187 | SRes LookInStream_Read2(ILookInStream *stream, void *buf, size_t size, SRes errorType); |
188 | SRes LookInStream_Read(ILookInStream *stream, void *buf, size_t size); | 188 | SRes LookInStream_Read(ILookInStream *stream, void *buf, size_t size); |
189 | 189 | ||
190 | #define LookToRead_BUF_SIZE (1 << 14) | 190 | #define LookToRead_BUF_SIZE (1 << 14) |
191 | 191 | ||
192 | typedef struct | 192 | typedef struct |
193 | { | 193 | { |
194 | ILookInStream s; | 194 | ILookInStream s; |
195 | ISeekInStream *realStream; | 195 | ISeekInStream *realStream; |
196 | size_t pos; | 196 | size_t pos; |
197 | size_t size; | 197 | size_t size; |
198 | Byte buf[LookToRead_BUF_SIZE]; | 198 | Byte buf[LookToRead_BUF_SIZE]; |
199 | } CLookToRead; | 199 | } CLookToRead; |
200 | 200 | ||
201 | void LookToRead_CreateVTable(CLookToRead *p, int lookahead); | 201 | void LookToRead_CreateVTable(CLookToRead *p, int lookahead); |
202 | void LookToRead_Init(CLookToRead *p); | 202 | void LookToRead_Init(CLookToRead *p); |
203 | 203 | ||
204 | typedef struct | 204 | typedef struct |
205 | { | 205 | { |
206 | ISeqInStream s; | 206 | ISeqInStream s; |
207 | ILookInStream *realStream; | 207 | ILookInStream *realStream; |
208 | } CSecToLook; | 208 | } CSecToLook; |
209 | 209 | ||
210 | void SecToLook_CreateVTable(CSecToLook *p); | 210 | void SecToLook_CreateVTable(CSecToLook *p); |
211 | 211 | ||
212 | typedef struct | 212 | typedef struct |
213 | { | 213 | { |
214 | ISeqInStream s; | 214 | ISeqInStream s; |
215 | ILookInStream *realStream; | 215 | ILookInStream *realStream; |
216 | } CSecToRead; | 216 | } CSecToRead; |
217 | 217 | ||
218 | void SecToRead_CreateVTable(CSecToRead *p); | 218 | void SecToRead_CreateVTable(CSecToRead *p); |
219 | 219 | ||
220 | typedef struct | 220 | typedef struct |
221 | { | 221 | { |
222 | SRes (*Progress)(void *p, UInt64 inSize, UInt64 outSize); | 222 | SRes (*Progress)(void *p, UInt64 inSize, UInt64 outSize); |
223 | /* Returns: result. (result != SZ_OK) means break. | 223 | /* Returns: result. (result != SZ_OK) means break. |
224 | Value (UInt64)(Int64)-1 for size means unknown value. */ | 224 | Value (UInt64)(Int64)-1 for size means unknown value. */ |
225 | } ICompressProgress; | 225 | } ICompressProgress; |
226 | 226 | ||
227 | typedef struct | 227 | typedef struct |
228 | { | 228 | { |
229 | void *(*Alloc)(void *p, size_t size); | 229 | void *(*Alloc)(void *p, size_t size); |
230 | void (*Free)(void *p, void *address); /* address can be 0 */ | 230 | void (*Free)(void *p, void *address); /* address can be 0 */ |
231 | } ISzAlloc; | 231 | } ISzAlloc; |
232 | 232 | ||
233 | #define IAlloc_Alloc(p, size) (p)->Alloc((p), size) | 233 | #define IAlloc_Alloc(p, size) (p)->Alloc((p), size) |
234 | #define IAlloc_Free(p, a) (p)->Free((p), a) | 234 | #define IAlloc_Free(p, a) (p)->Free((p), a) |
235 | 235 | ||
236 | #ifdef _WIN32 | 236 | #ifdef _WIN32 |
237 | 237 | ||
238 | #define CHAR_PATH_SEPARATOR '\\' | 238 | #define CHAR_PATH_SEPARATOR '\\' |
239 | #define WCHAR_PATH_SEPARATOR L'\\' | 239 | #define WCHAR_PATH_SEPARATOR L'\\' |
240 | #define STRING_PATH_SEPARATOR "\\" | 240 | #define STRING_PATH_SEPARATOR "\\" |
241 | #define WSTRING_PATH_SEPARATOR L"\\" | 241 | #define WSTRING_PATH_SEPARATOR L"\\" |
242 | 242 | ||
243 | #else | 243 | #else |
244 | 244 | ||
245 | #define CHAR_PATH_SEPARATOR '/' | 245 | #define CHAR_PATH_SEPARATOR '/' |
246 | #define WCHAR_PATH_SEPARATOR L'/' | 246 | #define WCHAR_PATH_SEPARATOR L'/' |
247 | #define STRING_PATH_SEPARATOR "/" | 247 | #define STRING_PATH_SEPARATOR "/" |
248 | #define WSTRING_PATH_SEPARATOR L"/" | 248 | #define WSTRING_PATH_SEPARATOR L"/" |
249 | 249 | ||
250 | #endif | 250 | #endif |
251 | 251 | ||
252 | EXTERN_C_END | 252 | EXTERN_C_END |
253 | 253 | ||
254 | #endif | 254 | #endif |