transform will transform the decoder table into a table usable for decoding without having to apply the transformation while decoding. The state will contain the base value and the number of bits to read.
(t []baseOffset)
| 272 | // decoding without having to apply the transformation while decoding. |
| 273 | // The state will contain the base value and the number of bits to read. |
| 274 | func (s *fseDecoder) transform(t []baseOffset) error { |
| 275 | tableSize := uint16(1 << s.actualTableLog) |
| 276 | s.maxBits = 0 |
| 277 | for i, v := range s.dt[:tableSize] { |
| 278 | add := v.addBits() |
| 279 | if int(add) >= len(t) { |
| 280 | return fmt.Errorf("invalid decoding table entry %d, symbol %d >= max (%d)", i, v.addBits(), len(t)) |
| 281 | } |
| 282 | lu := t[add] |
| 283 | if lu.addBits > s.maxBits { |
| 284 | s.maxBits = lu.addBits |
| 285 | } |
| 286 | v.setExt(lu.addBits, lu.baseLine) |
| 287 | s.dt[i] = v |
| 288 | } |
| 289 | return nil |
| 290 | } |
| 291 | |
| 292 | type fseState struct { |
| 293 | dt []decSymbol |
no test coverage detected