integer approximation for i * log2(i), helper function for LFS_ENTROPY */
| 5433 | |
| 5434 | /* integer approximation for i * log2(i), helper function for LFS_ENTROPY */ |
| 5435 | static 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 | |
| 5444 | static unsigned filter(unsigned char* out, const unsigned char* in, unsigned w, unsigned h, |
| 5445 | const LodePNGColorMode* color, const LodePNGEncoderSettings* settings) { |