MCPcopy Create free account
hub / github.com/HiLab-git/SimpleCRF / getHash

Function getHash

dependency/densecrf/examples/lodepng.cpp:1421–1440  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1419
1420
1421static unsigned getHash(const unsigned char* data, size_t size, size_t pos)
1422{
1423 unsigned result = 0;
1424 if(pos + 2 < size)
1425 {
1426 /*A simple shift and xor hash is used. Since the data of PNGs is dominated
1427 by zeroes due to the filters, a better hash does not have a significant
1428 effect on speed in traversing the chain, and causes more time spend on
1429 calculating the hash.*/
1430 result ^= (unsigned)(data[pos + 0] << 0u);
1431 result ^= (unsigned)(data[pos + 1] << 4u);
1432 result ^= (unsigned)(data[pos + 2] << 8u);
1433 } else {
1434 size_t amount, i;
1435 if(pos >= size) return 0;
1436 amount = size - pos;
1437 for(i = 0; i != amount; ++i) result ^= (unsigned)(data[pos + i] << (i * 8u));
1438 }
1439 return result & HASH_BIT_MASK;
1440}
1441
1442static unsigned countZeros(const unsigned char* data, size_t size, size_t pos)
1443{

Callers 1

encodeLZ77Function · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected