コード例 #1
0
        public FileSegment ParseFile(IDecodingInputStream stream, WeightsTable weightsTable)
        {
            Guard.IsNotNull(stream, nameof(stream));
            Guard.IsNotNull(weightsTable, nameof(weightsTable));

            int    nameLength = stream.ReadInt() / 2;
            string name       = ReadString(stream, nameLength);
            long   dataLength = stream.ReadLong();

            return(new FileSegment(name, new DefaultFileDecoder(weightsTable, stream, dataLength, decoder)));
        }
コード例 #2
0
        public BootstrapSegment ParseWeightsTable(IDecodingInputStream stream)
        {
            Guard.IsNotNull(stream, nameof(stream));

            WeightsTable weightsTable = new WeightsTable();
            int          tableSize    = stream.ReadInt() / 9;

            for (int n = 0; n < tableSize; n++)
            {
                byte code      = stream.ReadByte();
                long frequency = stream.ReadLong();
                weightsTable.TrackSymbol(code, frequency);
            }
            return(new BootstrapSegment(weightsTable));
        }