public long get24Bits() { while (bufferLength < 24) { buffer = ((BinaryOperation.bit32ShiftL(buffer, 8)) | (reader.readbyte() & 0xff)); bufferLength += 8; noOfbytesRead++; } return((BinaryOperation.bit32ShiftR(buffer, (int)(bufferLength - 24))) & 0xffffff); }
public int get2DCode() { int tuple0, tuple1; if (bufferLength == 0) { buffer = (reader.readbyte() & 0xff); bufferLength = 8; noOfbytesRead++; int lookup = (int)((BinaryOperation.bit32ShiftR(buffer, 1)) & 0x7f); tuple0 = twoDimensionalTable1[lookup, 0]; tuple1 = twoDimensionalTable1[lookup, 1]; } else if (bufferLength == 8) { int lookup = (int)((BinaryOperation.bit32ShiftR(buffer, 1)) & 0x7f); tuple0 = twoDimensionalTable1[lookup, 0]; tuple1 = twoDimensionalTable1[lookup, 1]; } else { int lookup = (int)((BinaryOperation.bit32ShiftL(buffer, (int)(7 - bufferLength))) & 0x7f); tuple0 = twoDimensionalTable1[lookup, 0]; tuple1 = twoDimensionalTable1[lookup, 1]; if (tuple0 < 0 || tuple0 > (int)bufferLength) { int right = (reader.readbyte() & 0xff); long left = (BinaryOperation.bit32ShiftL(buffer, 8)); buffer = left | right; bufferLength += 8; noOfbytesRead++; int look = (int)(BinaryOperation.bit32ShiftR(buffer, (int)(bufferLength - 7)) & 0x7f); tuple0 = twoDimensionalTable1[look, 0]; tuple1 = twoDimensionalTable1[look, 1]; } } if (tuple0 < 0) { return(0); } bufferLength -= tuple0; return(tuple1); }
public int getBlackCode() { int tuple0, tuple1; long code; if (bufferLength == 0) { buffer = (reader.readbyte() & 0xff); bufferLength = 8; noOfbytesRead++; } while (true) { if (bufferLength >= 6 && ((BinaryOperation.bit32ShiftR(buffer, (int)(bufferLength - 6))) & 0x3f) == 0) { if (bufferLength <= 13) { code = BinaryOperation.bit32ShiftL(buffer, (int)(13 - bufferLength)); } else { code = BinaryOperation.bit32ShiftR(buffer, (int)(bufferLength - 13)); } tuple0 = blackTable1[(int)(code & 0x7f), 0]; tuple1 = blackTable1[(int)(code & 0x7f), 1]; } else if (bufferLength >= 4 && ((buffer >> ((int)bufferLength - 4)) & 0x0f) == 0) { if (bufferLength <= 12) { code = BinaryOperation.bit32ShiftL(buffer, (int)(12 - bufferLength)); } else { code = BinaryOperation.bit32ShiftR(buffer, (int)(bufferLength - 12)); } int lookup = (int)((code & 0xff) - 64); if (lookup >= 0) { tuple0 = blackTable2[lookup, 0]; tuple1 = blackTable2[lookup, 1]; } else { tuple0 = blackTable1[blackTable1.Length + lookup, 0]; tuple1 = blackTable1[blackTable1.Length + lookup, 1]; } } else { if (bufferLength <= 6) { code = BinaryOperation.bit32ShiftL(buffer, (int)(6 - bufferLength)); } else { code = BinaryOperation.bit32ShiftR(buffer, (int)(bufferLength - 6)); } int lookup = (int)(code & 0x3f); if (lookup >= 0) { tuple0 = blackTable3[lookup, 0]; tuple1 = blackTable3[lookup, 1]; } else { tuple0 = blackTable2[blackTable2.Length + lookup, 0]; tuple1 = blackTable2[blackTable2.Length + lookup, 1]; } } if (tuple0 > 0 && tuple0 <= (int)bufferLength) { bufferLength -= tuple0; return(tuple1); } if (bufferLength >= 13) { break; } buffer = ((BinaryOperation.bit32ShiftL(buffer, 8)) | (reader.readbyte() & 0xff)); bufferLength += 8; noOfbytesRead++; } bufferLength--; return(1); }
public int getWhiteCode() { int tuple0, tuple1; long code; if (bufferLength == 0) { buffer = (reader.readbyte() & 0xff); bufferLength = 8; noOfbytesRead++; } while (true) { if (bufferLength >= 7 && ((BinaryOperation.bit32ShiftR(buffer, (int)(bufferLength - 7))) & 0x7f) == 0) { if (bufferLength <= 12) { code = BinaryOperation.bit32ShiftL(buffer, (int)(12 - bufferLength)); } else { code = BinaryOperation.bit32ShiftR(buffer, (int)(bufferLength - 12)); } tuple0 = whiteTable1[(int)(code & 0x1f), 0]; tuple1 = whiteTable1[(int)(code & 0x1f), 1]; } else { if (bufferLength <= 9) { code = BinaryOperation.bit32ShiftL(buffer, (int)(9 - bufferLength)); } else { code = BinaryOperation.bit32ShiftR(buffer, (int)(bufferLength - 9)); } int lookup = (int)(code & 0x1ff); if (lookup >= 0) { tuple0 = whiteTable2[lookup, 0]; tuple1 = whiteTable2[lookup, 1]; } else { tuple0 = whiteTable2[whiteTable2.Length + lookup, 0]; tuple1 = whiteTable2[whiteTable2.Length + lookup, 1]; } } if (tuple0 > 0 && tuple0 <= (int)bufferLength) { bufferLength -= tuple0; return(tuple1); } if (bufferLength >= 12) { break; } buffer = ((BinaryOperation.bit32ShiftL(buffer, 8)) | reader.readbyte() & 0xff); bufferLength += 8; noOfbytesRead++; } bufferLength--; return(1); }