decode sequences from the stream without the provided history.
(seqs []seqVals)
| 174 | |
| 175 | // decode sequences from the stream without the provided history. |
| 176 | func (s *sequenceDecs) decode(seqs []seqVals) error { |
| 177 | br := s.br |
| 178 | |
| 179 | maxBlockSize := min(s.windowSize, maxCompressedBlockSize) |
| 180 | |
| 181 | ctx := decodeAsmContext{ |
| 182 | llTable: s.litLengths.fse.dt[:maxTablesize], |
| 183 | mlTable: s.matchLengths.fse.dt[:maxTablesize], |
| 184 | ofTable: s.offsets.fse.dt[:maxTablesize], |
| 185 | llState: uint64(s.litLengths.state.state), |
| 186 | mlState: uint64(s.matchLengths.state.state), |
| 187 | ofState: uint64(s.offsets.state.state), |
| 188 | seqs: seqs, |
| 189 | iteration: len(seqs) - 1, |
| 190 | litRemain: len(s.literals), |
| 191 | } |
| 192 | |
| 193 | if debugDecoder { |
| 194 | println("decode: decoding", len(seqs), "sequences", br.remain(), "bits remain on stream") |
| 195 | } |
| 196 | |
| 197 | s.seqSize = 0 |
| 198 | lte56bits := s.maxBits+s.offsets.fse.actualTableLog+s.matchLengths.fse.actualTableLog+s.litLengths.fse.actualTableLog <= 56 |
| 199 | errCode := decodeAsm(s, br, &ctx, lte56bits) |
| 200 | if errCode != 0 { |
| 201 | i := len(seqs) - ctx.iteration - 1 |
| 202 | switch errCode { |
| 203 | case errorMatchLenOfsMismatch: |
| 204 | ml := ctx.seqs[i].ml |
| 205 | return fmt.Errorf("zero matchoff and matchlen (%d) > 0", ml) |
| 206 | |
| 207 | case errorMatchLenTooBig: |
| 208 | ml := ctx.seqs[i].ml |
| 209 | return fmt.Errorf("match len (%d) bigger than max allowed length", ml) |
| 210 | |
| 211 | case errorNotEnoughLiterals: |
| 212 | ll := ctx.seqs[i].ll |
| 213 | return fmt.Errorf("unexpected literal count, want %d bytes, but only %d is available", ll, ctx.litRemain+ll) |
| 214 | case errorOverread: |
| 215 | return io.ErrUnexpectedEOF |
| 216 | } |
| 217 | |
| 218 | return fmt.Errorf("sequenceDecs_decode_amd64 returned erroneous code %d", errCode) |
| 219 | } |
| 220 | |
| 221 | if ctx.litRemain < 0 { |
| 222 | return fmt.Errorf("literal count is too big: total available %d, total requested %d", |
| 223 | len(s.literals), len(s.literals)-ctx.litRemain) |
| 224 | } |
| 225 | |
| 226 | s.seqSize += ctx.litRemain |
| 227 | if s.seqSize > maxBlockSize { |
| 228 | return fmt.Errorf("output bigger than max block size (%d)", maxBlockSize) |
| 229 | } |
| 230 | if debugDecoder { |
| 231 | println("decode: ", br.remain(), "bits remain on stream. code:", errCode) |
| 232 | } |
| 233 | err := br.close() |