MCPcopy Create free account
hub / github.com/MegEngine/MegEngine / stbi__parse_zlib_header

Function stbi__parse_zlib_header

lite/example/cpp_example/mge/cv/stb_image.h:4782–4799  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4780}
4781
4782static int stbi__parse_zlib_header(stbi__zbuf* a) {
4783 int cmf = stbi__zget8(a);
4784 int cm = cmf & 15;
4785 /* int cinfo = cmf >> 4; */
4786 int flg = stbi__zget8(a);
4787 if (stbi__zeof(a))
4788 return stbi__err("bad zlib header", "Corrupt PNG"); // zlib spec
4789 if ((cmf * 256 + flg) % 31 != 0)
4790 return stbi__err("bad zlib header", "Corrupt PNG"); // zlib spec
4791 if (flg & 32)
4792 return stbi__err(
4793 "no preset dict",
4794 "Corrupt PNG"); // preset dictionary not allowed in png
4795 if (cm != 8)
4796 return stbi__err("bad compression", "Corrupt PNG"); // DEFLATE required for png
4797 // window = 1 << (8 + cinfo)... but who cares, we fully buffer output
4798 return 1;
4799}
4800
4801static const stbi_uc stbi__zdefault_length[STBI__ZNSYMS] = {
4802 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,

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