| 4221 | } |
| 4222 | |
| 4223 | static int stbi__zhuffman_decode_slowpath(stbi__zbuf *a, stbi__zhuffman *z) |
| 4224 | { |
| 4225 | int b,s,k; |
| 4226 | // not resolved by fast table, so compute it the slow way |
| 4227 | // use jpeg approach, which requires MSbits at top |
| 4228 | k = stbi__bit_reverse(a->code_buffer, 16); |
| 4229 | for (s=STBI__ZFAST_BITS+1; ; ++s) |
| 4230 | if (k < z->maxcode[s]) |
| 4231 | break; |
| 4232 | if (s >= 16) return -1; // invalid code! |
| 4233 | // code size is s, so: |
| 4234 | b = (k >> (16-s)) - z->firstcode[s] + z->firstsymbol[s]; |
| 4235 | if (b >= STBI__ZNSYMS) return -1; // some data was corrupt somewhere! |
| 4236 | if (z->size[b] != s) return -1; // was originally an assert, but report failure instead. |
| 4237 | a->code_buffer >>= s; |
| 4238 | a->num_bits -= s; |
| 4239 | return z->value[b]; |
| 4240 | } |
| 4241 | |
| 4242 | stbi_inline static int stbi__zhuffman_decode(stbi__zbuf *a, stbi__zhuffman *z) |
| 4243 | { |
no test coverage detected