optimalTableLog calculates and sets the optimal tableLog in s.actualTableLog
(length int)
| 427 | |
| 428 | // optimalTableLog calculates and sets the optimal tableLog in s.actualTableLog |
| 429 | func (s *fseEncoder) optimalTableLog(length int) { |
| 430 | tableLog := uint8(maxEncTableLog) |
| 431 | minBitsSrc := highBit(uint32(length)) + 1 |
| 432 | minBitsSymbols := highBit(uint32(s.symbolLen-1)) + 2 |
| 433 | minBits := uint8(minBitsSymbols) |
| 434 | if minBitsSrc < minBitsSymbols { |
| 435 | minBits = uint8(minBitsSrc) |
| 436 | } |
| 437 | |
| 438 | maxBitsSrc := uint8(highBit(uint32(length-1))) - 2 |
| 439 | if maxBitsSrc < tableLog { |
| 440 | // Accuracy can be reduced |
| 441 | tableLog = maxBitsSrc |
| 442 | } |
| 443 | if minBits > tableLog { |
| 444 | tableLog = minBits |
| 445 | } |
| 446 | // Need a minimum to safely represent all symbol values |
| 447 | if tableLog < minEncTablelog { |
| 448 | tableLog = minEncTablelog |
| 449 | } |
| 450 | if tableLog > maxEncTableLog { |
| 451 | tableLog = maxEncTableLog |
| 452 | } |
| 453 | s.actualTableLog = tableLog |
| 454 | } |
| 455 | |
| 456 | // validateNorm validates the normalized histogram table. |
| 457 | func (s *fseEncoder) validateNorm() (err error) { |
no test coverage detected