private int DecodeWhiteCodeWord()
{
int current, entry, bits, isT, twoBits, code = -1;
int runLength = 0;
bool isWhite = true;
while (isWhite) {
current = NextNBits(10);
entry = white[current];
// Get the 3 fields from the entry
isT = entry & 0x0001;
bits = (entry >> 1) & 0x0f;
if (bits == 12) { // Additional Make up code
// Get the next 2 bits
twoBits = NextLesserThan8Bits(2);
// Consolidate the 2 new bits and last 2 bits into 4 bits
current = ((current << 2) & 0x000c) | twoBits;
entry = additionalMakeup[current];
bits = (entry >> 1) & 0x07; // 3 bits 0000 0111
code = (entry >> 4) & 0x0fff; // 12 bits
runLength += code;
UpdatePointer(4 - bits);
} else if (bits == 0) { // ERROR
throw new Exception("Error 0");
} else if (bits == 15) { // EOL
throw new Exception("Error 1");
} else {
// 11 bits - 0000 0111 1111 1111 = 0x07ff
code = (entry >> 5) & 0x07ff;
runLength += code;
UpdatePointer(10 - bits);
if (isT == 0) {
isWhite = false;
}
}
}
return runLength;
}