public int DecodeBit(long context, ArithmeticDecoderStats stats) { int iCX = BinaryOperation.Bit8Shift(stats.GetContextCodingTableValue((int)context), 1, BinaryOperation.RIGHT_SHIFT); int mpsCX = stats.GetContextCodingTableValue((int)context) & 1; int qe = qeTable[iCX]; a -= qe; int bit; if (c < a) { if ((a & 0x80000000) != 0) { bit = mpsCX; } else { if (a < qe) { bit = 1 - mpsCX; if (switchTable[iCX] != 0) { stats.SetContextCodingTableValue((int)context, (nlpsTable[iCX] << 1) | (1 - mpsCX)); } else { stats.SetContextCodingTableValue((int)context, (nlpsTable[iCX] << 1) | mpsCX); } } else { bit = mpsCX; stats.SetContextCodingTableValue((int)context, (nmpsTable[iCX] << 1) | mpsCX); } do { if (counter == 0) { Readbyte(); } a = BinaryOperation.Bit32ShiftL(a, 1); c = BinaryOperation.Bit32ShiftL(c, 1); counter--; } while ((a & 0x80000000) == 0); } } else { c -= a; if (a < qe) { bit = mpsCX; stats.SetContextCodingTableValue((int)context, (nmpsTable[iCX] << 1) | mpsCX); } else { bit = 1 - mpsCX; if (switchTable[iCX] != 0) { stats.SetContextCodingTableValue((int)context, (nlpsTable[iCX] << 1) | (1 - mpsCX)); } else { stats.SetContextCodingTableValue((int)context, (nlpsTable[iCX] << 1) | mpsCX); } } a = qe; do { if (counter == 0) { Readbyte(); } a = BinaryOperation.Bit32ShiftL(a, 1); c = BinaryOperation.Bit32ShiftL(c, 1); counter--; } while ((a & 0x80000000) == 0); } return(bit); }