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

Function mz_crc32

SampleFramework12/v1.00/TinyEXR.cpp:1447–1462  ·  view source on GitHub ↗

Karl Malbrain's compact CRC-32. See "A compact CCITT crc16 and crc32 C implementation that balances processor cache usage against speed": http://www.geocities.com/malbrain/

Source from the content-addressed store, hash-verified

1445// implementation that balances processor cache usage against speed":
1446// http://www.geocities.com/malbrain/
1447mz_ulong mz_crc32(mz_ulong crc, const mz_uint8 *ptr, size_t buf_len) {
1448 static const mz_uint32 s_crc32[16] = {
1449 0, 0x1db71064, 0x3b6e20c8, 0x26d930ac, 0x76dc4190, 0x6b6b51f4,
1450 0x4db26158, 0x5005713c, 0xedb88320, 0xf00f9344, 0xd6d6a3e8, 0xcb61b38c,
1451 0x9b64c2b0, 0x86d3d2d4, 0xa00ae278, 0xbdbdf21c};
1452 mz_uint32 crcu32 = (mz_uint32)crc;
1453 if (!ptr)
1454 return MZ_CRC32_INIT;
1455 crcu32 = ~crcu32;
1456 while (buf_len--) {
1457 mz_uint8 b = *ptr++;
1458 crcu32 = (crcu32 >> 4) ^ s_crc32[(crcu32 & 0xF) ^ (b & 0xF)];
1459 crcu32 = (crcu32 >> 4) ^ s_crc32[(crcu32 & 0xF) ^ (b >> 4)];
1460 }
1461 return ~crcu32;
1462}
1463
1464void mz_free(void *p) { MZ_FREE(p); }
1465

Calls

no outgoing calls

Tested by

no test coverage detected