minSize returns the minimum possible size considering the shannon limit.
(total int)
| 321 | |
| 322 | // minSize returns the minimum possible size considering the shannon limit. |
| 323 | func (s *Scratch) minSize(total int) int { |
| 324 | nbBits := float64(7) |
| 325 | fTotal := float64(total) |
| 326 | for _, v := range s.count[:s.symbolLen] { |
| 327 | n := float64(v) |
| 328 | if n > 0 { |
| 329 | nbBits += math.Log2(fTotal/n) * n |
| 330 | } |
| 331 | } |
| 332 | return int(nbBits) >> 3 |
| 333 | } |
| 334 | |
| 335 | func highBit32(val uint32) (n uint32) { |
| 336 | return uint32(bits.Len32(val) - 1) |
no outgoing calls