func (s *Scratch) Decompress1X(in []byte) (out []byte, err error) {
	if cap(s.Out) < s.MaxDecodedSize {
		s.Out = make([]byte, s.MaxDecodedSize)
	}
	s.Out = s.Out[:0:s.MaxDecodedSize]
	s.Out, err = s.Decoder().Decompress1X(s.Out, in)
	return s.Out, err
}
Decompress1X will decompress a 1X encoded stream.
The length of the supplied input must match the end of a block exactly.
Before this is called, the table must be initialized with ReadTable unless
the encoder re-used the table.
deprecated: Use the stateless Decoder() to get a concurrent version.
package huff0
import (
	"errors"
	"fmt"
	"io"
	"github.com/klauspost/compress/fse"
)
type dTable struct {
	single []dEntrySingle
	double []dEntryDouble
}
type dEntrySingle struct {
	entry uint16
}
type dEntryDouble struct {
	seq   uint16
	nBits uint8
	len   uint8
}
const use8BitTables = true
func ReadTable(in []byte, s *Scratch) (s2 *Scratch, remain []byte, err error) {
	s, err = s.prepare(in)
	if err != nil {
		return s, nil, err
	}
	if len(in) <= 1 {
		return s, nil, errors.New("input too small for table")
	}
	iSize := in[0]
	in = in[1:]
	if iSize >= 128 {
		oSize := iSize - 127
		iSize = (oSize + 1) / 2
		if int(iSize) > len(in) {
			return s, nil, errors.New("input too small for table")
		}
		for n := uint8(0); n < oSize; n += 2 {
			v := in[n/2]
			s.huffWeight[n] = v >> 4
			s.huffWeight[n+1] = v & 15
		}
		s.symbolLen = uint16(oSize)
		in = in[iSize:]
	} else {
		if len(in) < int(iSize) {
			return s, nil, fmt.Errorf("input too small for table, want %d bytes, have %d", iSize, len(in))
		}
		s.fse.DecompressLimit = 255
		hw := s.huffWeight[:]
		s.fse.Out = hw
		b, err := fse.Decompress(in[:iSize], s.fse)
		s.fse.Out = nil
		if err != nil {
			return s, nil, err
		}
		if len(b) > 255 {
			return s, nil, errors.New("corrupt input: output table too large")
		}
		s.symbolLen = uint16(len(b))
		in = in[iSize:]
	}
	var rankStats [16]uint32
	weightTotal := uint32(0)
	for _, v := range s.huffWeight[:s.symbolLen] {
		if v > tableLogMax {
			return s, nil, errors.New("corrupt input: weight too large")
		}
		v2 := v & 15
		rankStats[v2]++
		weightTotal += (1 << v2) >> 1
	}
	if weightTotal == 0 {
		return s, nil, errors.New("corrupt input: weights zero")
	}
	{
		tableLog := highBit32(weightTotal) + 1
		if tableLog > tableLogMax {
			return s, nil, errors.New("corrupt input: tableLog too big")
		}
		s.actualTableLog = uint8(tableLog)
		{
			total := uint32(1) << tableLog
			rest := total - weightTotal
			verif := uint32(1) << highBit32(rest)
			lastWeight := highBit32(rest) + 1
			if verif != rest {
				return s, nil, errors.New("corrupt input: last value not power of two")
			}
			s.huffWeight[s.symbolLen] = uint8(lastWeight)
			s.symbolLen++
			rankStats[lastWeight]++
		}
	}
	if (rankStats[1] < 2) || (rankStats[1]&1 != 0) {
		return s, nil, errors.New("corrupt input: min elt size, even check failed ")
	}
	{
		var nextRankStart uint32
		for n := uint8(1); n < s.actualTableLog+1; n++ {
			current := nextRankStart
			nextRankStart += rankStats[n] << (n - 1)
			rankStats[n] = current
		}
	}
	tSize := 1 << tableLogMax
	if len(s.dt.single) != tSize {
		s.dt.single = make([]dEntrySingle, tSize)
	}
	cTable := s.prevTable
	if cap(cTable) < maxSymbolValue+1 {
		cTable = make([]cTableEntry, 0, maxSymbolValue+1)
	}
	cTable = cTable[:maxSymbolValue+1]
	s.prevTable = cTable[:s.symbolLen]
	s.prevTableLog = s.actualTableLog
	for n, w := range s.huffWeight[:s.symbolLen] {
		if w == 0 {
			cTable[n] = cTableEntry{
				val:   0,
				nBits: 0,
			}
			continue
		}
		length := (uint32(1) << w) >> 1
		d := dEntrySingle{
			entry: uint16(s.actualTableLog+1-w) | (uint16(n) << 8),
		}
		rank := &rankStats[w]
		cTable[n] = cTableEntry{
			val:   uint16(*rank >> (w - 1)),
			nBits: uint8(d.entry),
		}
		single := s.dt.single[*rank : *rank+length]
		for i := range single {
			single[i] = d
		}
		*rank += length
	}
	return s, in, nil
}