decode method

int decode(
  1. Uint8List contexts,
  2. int contextIndex
)

Implementation

int decode(Uint8List contexts, int contextIndex) {
  int cxIndex = (contexts[contextIndex] >> 1) & 0x7F;
  int cxMps = contexts[contextIndex] & 1;
  final int qe = _qe[cxIndex];
  int d;
  _a -= qe;
  if (_chigh < qe) {
    if (_a < qe) {
      _a = qe;
      d = cxMps;
      cxIndex = _nmps[cxIndex];
    } else {
      _a = qe;
      d = 1 ^ cxMps;
      if (_switch[cxIndex] == 1) cxMps = d;
      cxIndex = _nlps[cxIndex];
    }
  } else {
    _chigh -= qe;
    if ((_a & 0x8000) != 0) return cxMps;
    if (_a < qe) {
      d = 1 ^ cxMps;
      if (_switch[cxIndex] == 1) cxMps = d;
      cxIndex = _nlps[cxIndex];
    } else {
      d = cxMps;
      cxIndex = _nmps[cxIndex];
    }
  }
  do {
    if (_ct == 0) _byteIn();
    _a <<= 1;
    _chigh = ((_chigh << 1) & 0xFFFF) | ((_clow >> 15) & 1);
    _clow = (_clow << 1) & 0xFFFF;
    _ct--;
  } while ((_a & 0x8000) == 0);
  contexts[contextIndex] = (cxIndex << 1) | cxMps;
  return d;
}