| 4240 | } |
| 4241 | |
| 4242 | stbi_inline static int stbi__zhuffman_decode(stbi__zbuf *a, stbi__zhuffman *z) |
| 4243 | { |
| 4244 | int b,s; |
| 4245 | if (a->num_bits < 16) { |
| 4246 | if (stbi__zeof(a)) { |
| 4247 | if (!a->hit_zeof_once) { |
| 4248 | // This is the first time we hit eof, insert 16 extra padding btis |
| 4249 | // to allow us to keep going; if we actually consume any of them |
| 4250 | // though, that is invalid data. This is caught later. |
| 4251 | a->hit_zeof_once = 1; |
| 4252 | a->num_bits += 16; // add 16 implicit zero bits |
| 4253 | } else { |
| 4254 | // We already inserted our extra 16 padding bits and are again |
| 4255 | // out, this stream is actually prematurely terminated. |
| 4256 | return -1; |
| 4257 | } |
| 4258 | } else { |
| 4259 | stbi__fill_bits(a); |
| 4260 | } |
| 4261 | } |
| 4262 | b = z->fast[a->code_buffer & STBI__ZFAST_MASK]; |
| 4263 | if (b) { |
| 4264 | s = b >> 9; |
| 4265 | a->code_buffer >>= s; |
| 4266 | a->num_bits -= s; |
| 4267 | return b & 511; |
| 4268 | } |
| 4269 | return stbi__zhuffman_decode_slowpath(a, z); |
| 4270 | } |
| 4271 | |
| 4272 | static int stbi__zexpand(stbi__zbuf *z, char *zout, int n) // need to make room for n bytes |
| 4273 | { |
no test coverage detected