89{
91 int cachedBits, padBits, len, startBits, linBits, maxBits, minBits;
93 unsigned short cw, *tBase, *tCurr;
94 unsigned int cache;
95
96 if(nVals <= 0)
97 return 0;
98
99 if (bitsLeft < 0)
100 return -1;
101 startBits = bitsLeft;
102
106
111
112
113 cache = 0;
114 cachedBits = (8 - bitOffset) & 0x07;
115 if (cachedBits)
116 cache = (unsigned int)(*buf++) << (32 - cachedBits);
117 bitsLeft -= cachedBits;
118
120
121 for (i = 0; i < nVals; i+=2) {
124 }
125 return 0;
126 }
else if (tabType ==
oneShot) {
127
129 tBase++;
130 padBits = 0;
131 while (nVals > 0) {
132
133 if (bitsLeft >= 16) {
134
135 cache |= (unsigned int)(*buf++) << (24 - cachedBits);
136 cache |= (unsigned int)(*buf++) << (16 - cachedBits);
137 cachedBits += 16;
138 bitsLeft -= 16;
139 } else {
140
141 if (cachedBits + bitsLeft <= 0) return -1;
142 if (bitsLeft > 0) cache |= (unsigned int)(*buf++) << (24 - cachedBits);
143 if (bitsLeft > 8) cache |= (unsigned int)(*buf++) << (16 - cachedBits);
144 cachedBits += bitsLeft;
145 bitsLeft = 0;
146
147 cache &= (
signed int)(
int32_t)0x80000000 >> (cachedBits - 1);
148 padBits = 11;
149 cachedBits += padBits;
150 }
151
152
153 while (nVals > 0 && cachedBits >= 11 ) {
154 cw = tBase[cache >> (32 - maxBits)];
156 cachedBits -= len;
157 cache <<= len;
158
161
162
163 if (cachedBits < padBits)
164 return -1;
165
168 nVals -= 2;
169 }
170 }
171 bitsLeft += (cachedBits - padBits);
172 return (startBits - bitsLeft);
174 tCurr = tBase;
175 padBits = 0;
176 while (nVals > 0) {
177
178 if (bitsLeft >= 16) {
179
180 cache |= (unsigned int)(*buf++) << (24 - cachedBits);
181 cache |= (unsigned int)(*buf++) << (16 - cachedBits);
182 cachedBits += 16;
183 bitsLeft -= 16;
184 } else {
185
186 if (cachedBits + bitsLeft <= 0) return -1;
187 if (bitsLeft > 0) cache |= (unsigned int)(*buf++) << (24 - cachedBits);
188 if (bitsLeft > 8) cache |= (unsigned int)(*buf++) << (16 - cachedBits);
189 cachedBits += bitsLeft;
190 bitsLeft = 0;
191
192 cache &= (
signed int)(
int32_t)0x80000000 >> (cachedBits - 1);
193 padBits = 11;
194 cachedBits += padBits;
195 }
196
197
198 while (nVals > 0 && cachedBits >= 11 ) {
200 cw = tCurr[(cache >> (32 - maxBits)) + 1];
202 if (!len) {
203 cachedBits -= maxBits;
204 cache <<= maxBits;
205 tCurr += cw;
206 continue;
207 }
208 cachedBits -= len;
209 cache <<= len;
210
213
215 minBits = linBits + 1 + (
y ? 1 : 0);
216 if (cachedBits + bitsLeft < minBits)
217 return -1;
218 while (cachedBits < minBits) {
219 cache |= (unsigned int)(*buf++) << (24 - cachedBits);
220 cachedBits += 8;
221 bitsLeft -= 8;
222 }
223 if (bitsLeft < 0) {
224 cachedBits += bitsLeft;
225 bitsLeft = 0;
226 cache &= (
signed int)(
int32_t)0x80000000 >> (cachedBits - 1);
227 }
228 x += (int)(cache >> (32 - linBits));
229 cachedBits -= linBits;
230 cache <<= linBits;
231 }
232 if (
x) {
ApplySign(
x, cache); cache <<= 1; cachedBits--;}
233
235 minBits = linBits + 1;
236 if (cachedBits + bitsLeft < minBits)
237 return -1;
238 while (cachedBits < minBits) {
239 cache |= (unsigned int)(*buf++) << (24 - cachedBits);
240 cachedBits += 8;
241 bitsLeft -= 8;
242 }
243 if (bitsLeft < 0) {
244 cachedBits += bitsLeft;
245 bitsLeft = 0;
246 cache &= (
signed int)(
int32_t)0x80000000 >> (cachedBits - 1);
247 }
248 y += (int)(cache >> (32 - linBits));
249 cachedBits -= linBits;
250 cache <<= linBits;
251 }
252 if (
y) {
ApplySign(
y, cache); cache <<= 1; cachedBits--;}
253
254
255 if (cachedBits < padBits)
256 return -1;
257
260 nVals -= 2;
261 tCurr = tBase;
262 }
263 }
264 bitsLeft += (cachedBits - padBits);
265 return (startBits - bitsLeft);
266 }
267
268
269 return -1;
270}
unsigned int xy(unsigned int x, unsigned int y)
enum fl::third_party::_HuffTabType HuffTabType
const int32_t huffTabOffset[HUFF_PAIRTABS]
const HuffTabLookup huffTabLookup[HUFF_PAIRTABS]
const unsigned short huffTable[]