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);
            }
示例#2
0
        public void UpdateState(ref FseBitReader reader)
        {
            FseDecompressTable dInfo = Table[State];
            uint lowBits             = reader.ReadBits(dInfo.NumberOfBits);

            State = (int)(dInfo.NewState + lowBits);
        }
示例#3
0
        public byte DecodeSymbol(ref FseBitReader reader)
        {
            FseDecompressTable dInfo = Table[State];
            uint lowBits             = reader.ReadBits(dInfo.NumberOfBits);

            State = (int)(dInfo.NewState + lowBits);
            return(dInfo.Symbol);
        }
示例#4
0
        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);
        }