MCPcopy Create free account
hub / github.com/ARM-software/ComputeLibrary / stbi__parse_zlib_header

Function stbi__parse_zlib_header

include/stb/stb_image.h:4438–4450  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4436}
4437
4438static int stbi__parse_zlib_header(stbi__zbuf *a)
4439{
4440 int cmf = stbi__zget8(a);
4441 int cm = cmf & 15;
4442 /* int cinfo = cmf >> 4; */
4443 int flg = stbi__zget8(a);
4444 if (stbi__zeof(a)) return stbi__err("bad zlib header","Corrupt PNG"); // zlib spec
4445 if ((cmf*256+flg) % 31 != 0) return stbi__err("bad zlib header","Corrupt PNG"); // zlib spec
4446 if (flg & 32) return stbi__err("no preset dict","Corrupt PNG"); // preset dictionary not allowed in png
4447 if (cm != 8) return stbi__err("bad compression","Corrupt PNG"); // DEFLATE required for png
4448 // window = 1 << (8 + cinfo)... but who cares, we fully buffer output
4449 return 1;
4450}
4451
4452static const stbi_uc stbi__zdefault_length[STBI__ZNSYMS] =
4453{

Callers 1

stbi__parse_zlibFunction · 0.85

Calls 3

stbi__zget8Function · 0.85
stbi__zeofFunction · 0.85
stbi__errFunction · 0.85

Tested by

no test coverage detected