MCPcopy Create free account
hub / github.com/TheRealMJP/DeferredTexturing / mz_adler32

Function mz_adler32

SampleFramework12/v1.00/TinyEXR.cpp:1419–1442  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1417// ------------------- zlib-style API's
1418
1419mz_ulong mz_adler32(mz_ulong adler, const unsigned char *ptr, size_t buf_len) {
1420 mz_uint32 i, s1 = (mz_uint32)(adler & 0xffff), s2 = (mz_uint32)(adler >> 16);
1421 size_t block_len = buf_len % 5552;
1422 if (!ptr)
1423 return MZ_ADLER32_INIT;
1424 while (buf_len) {
1425 for (i = 0; i + 7 < block_len; i += 8, ptr += 8) {
1426 s1 += ptr[0], s2 += s1;
1427 s1 += ptr[1], s2 += s1;
1428 s1 += ptr[2], s2 += s1;
1429 s1 += ptr[3], s2 += s1;
1430 s1 += ptr[4], s2 += s1;
1431 s1 += ptr[5], s2 += s1;
1432 s1 += ptr[6], s2 += s1;
1433 s1 += ptr[7], s2 += s1;
1434 }
1435 for (; i < block_len; ++i)
1436 s1 += *ptr++, s2 += s1;
1437 s1 %= 65521U, s2 %= 65521U;
1438 buf_len -= block_len;
1439 block_len = 5552;
1440 }
1441 return (s2 << 16) + s1;
1442}
1443
1444// Karl Malbrain's compact CRC-32. See "A compact CCITT crc16 and crc32 C
1445// implementation that balances processor cache usage against speed":

Callers 1

tdefl_compressFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected