MCPcopy Create free account
hub / github.com/DFHack/dfhack / ilog2i

Function ilog2i

depends/lodepng/lodepng.cpp:5435–5442  ·  view source on GitHub ↗

integer approximation for i * log2(i), helper function for LFS_ENTROPY */

Source from the content-addressed store, hash-verified

5433
5434/* integer approximation for i * log2(i), helper function for LFS_ENTROPY */
5435static size_t ilog2i(size_t i) {
5436 size_t l;
5437 if(i == 0) return 0;
5438 l = ilog2(i);
5439 /* approximate i*log2(i): l is integer logarithm, ((i - (1u << l)) << 1u)
5440 linearly approximates the missing fractional part multiplied by i */
5441 return i * l + ((i - (1u << l)) << 1u);
5442}
5443
5444static unsigned filter(unsigned char* out, const unsigned char* in, unsigned w, unsigned h,
5445 const LodePNGColorMode* color, const LodePNGEncoderSettings* settings) {

Callers 1

filterFunction · 0.85

Calls 1

ilog2Function · 0.85

Tested by

no test coverage detected