public static int DecompressUsingTable(ReadOnlySpan <byte> source, Span <byte> destination, FseDecompressTableHeader header, ReadOnlySpan <FseDecompressTable> decodeTable) { int destinationLength = destination.Length; var reader = new FseBitReader(source); var state1 = FseDecompressState.Initialize(ref reader, header, decodeTable); var state2 = FseDecompressState.Initialize(ref reader, header, decodeTable); while (destination.Length >= 16) { ref byte destinationRef = ref MemoryMarshal.GetReference(destination); destinationRef = state1.DecodeSymbol(ref reader); Unsafe.Add(ref destinationRef, 1) = state2.DecodeSymbol(ref reader); Unsafe.Add(ref destinationRef, 2) = state1.DecodeSymbol(ref reader); Unsafe.Add(ref destinationRef, 3) = state2.DecodeSymbol(ref reader); Unsafe.Add(ref destinationRef, 4) = state1.DecodeSymbol(ref reader); Unsafe.Add(ref destinationRef, 5) = state2.DecodeSymbol(ref reader); Unsafe.Add(ref destinationRef, 6) = state1.DecodeSymbol(ref reader); Unsafe.Add(ref destinationRef, 7) = state2.DecodeSymbol(ref reader); Unsafe.Add(ref destinationRef, 8) = state1.DecodeSymbol(ref reader); Unsafe.Add(ref destinationRef, 9) = state2.DecodeSymbol(ref reader); Unsafe.Add(ref destinationRef, 10) = state1.DecodeSymbol(ref reader); Unsafe.Add(ref destinationRef, 11) = state2.DecodeSymbol(ref reader); Unsafe.Add(ref destinationRef, 12) = state1.DecodeSymbol(ref reader); Unsafe.Add(ref destinationRef, 13) = state2.DecodeSymbol(ref reader); Unsafe.Add(ref destinationRef, 14) = state1.DecodeSymbol(ref reader); Unsafe.Add(ref destinationRef, 15) = state2.DecodeSymbol(ref reader); destination = destination.Slice(16); }
public void UpdateState(ref FseBitReader reader) { FseDecompressTable dInfo = Table[State]; uint lowBits = reader.ReadBits(dInfo.NumberOfBits); State = (int)(dInfo.NewState + lowBits); }
public byte DecodeSymbol(ref FseBitReader reader) { FseDecompressTable dInfo = Table[State]; uint lowBits = reader.ReadBits(dInfo.NumberOfBits); State = (int)(dInfo.NewState + lowBits); return(dInfo.Symbol); }
public static FseDecompressState Initialize(ref FseBitReader reader, FseDecompressTableHeader header, ReadOnlySpan <FseDecompressTable> dt) { FseDecompressState fse = default; fse.Table = dt; fse.State = (int)reader.ReadBits(header.TableLog); return(fse); }