/// <summary> /// Return the next symbol in the bitstream. /// </summary> /// <param name="bits">The bitstream.</param> /// <returns></returns> public uint GetSymbol(BitStream bits) { uint code = 0; for (var i = 0; i < _codes.Length; i++) { bits.AddBit(ref code, i); foreach (var cCode in _codes[i]) { if (code == cCode.code) { return(cCode.symbol); } } } throw new InvalidOperationException("Unknown Huffman code"); }
/// <summary> /// Return the next symbol in the bitstream. /// </summary> /// <param name="bits">The bitstream.</param> /// <returns></returns> public uint GetSymbol(BitStream bits) { uint code = 0; for (var i = 0; i < _codes.Length; i++) { bits.AddBit(ref code, i); foreach (var cCode in _codes[i]) { if (code == cCode.code) return cCode.symbol; } } throw new InvalidOperationException("Unknown Huffman code"); }