MCPcopy Index your code
hub / github.com/klauspost/compress / optimalTableLog

Method optimalTableLog

zstd/fse_encoder.go:429–454  ·  view source on GitHub ↗

optimalTableLog calculates and sets the optimal tableLog in s.actualTableLog

(length int)

Source from the content-addressed store, hash-verified

427
428// optimalTableLog calculates and sets the optimal tableLog in s.actualTableLog
429func (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.
457func (s *fseEncoder) validateNorm() (err error) {

Callers 1

normalizeCountMethod · 0.95

Calls 1

highBitFunction · 0.85

Tested by

no test coverage detected