private static int DecodeHuffmanCode(ref JpegBitReader reader, JpegHuffmanDecodingTable table) { int bits = reader.PeekBits(16, out int bitsRead); JpegHuffmanDecodingTable.Entry entry = table.Lookup(bits); bitsRead = Math.Min(entry.CodeSize, bitsRead); _ = reader.TryAdvanceBits(bitsRead, out _); return(entry.SymbolValue); }