MCPcopy Create free account
hub / github.com/OpenFodder/openfodder / stbi__zhuffman_decode_slowpath

Function stbi__zhuffman_decode_slowpath

Source/Utils/stb_image.h:4223–4240  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4221}
4222
4223static 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
4242stbi_inline static int stbi__zhuffman_decode(stbi__zbuf *a, stbi__zhuffman *z)
4243{

Callers 1

stbi__zhuffman_decodeFunction · 0.85

Calls 1

stbi__bit_reverseFunction · 0.85

Tested by

no test coverage detected