predictorInverseTransform method Null safety

void predictorInverseTransform(
  1. int yStart,
  2. int yEnd,
  3. Uint32List outData,
  4. int data
)

Implementation

void predictorInverseTransform(
    int yStart, int yEnd, Uint32List outData, int data) {
  final width = xsize;
  if (yStart == 0) {
    // First Row follows the L (mode=1) mode.
    final pred0 = _predictor0(outData, outData[data - 1], 0);
    _addPixelsEq(outData, data, pred0);
    for (var x = 1; x < width; ++x) {
      final pred1 = _predictor1(outData, outData[data + x - 1], 0);
      _addPixelsEq(outData, data + x, pred1);
    }
    data += width;
    ++yStart;
  }

  var y = yStart;
  final mask = (1 << bits) - 1;
  final tilesPerRow = InternalVP8L.subSampleSize(width, bits);
  var predModeBase = (y >> bits) * tilesPerRow; //this.data +

  while (y < yEnd) {
    final pred2 = _predictor2(outData, outData[data - 1], data - width);
    var predModeSrc = predModeBase; //this.data +

    // First pixel follows the T (mode=2) mode.
    _addPixelsEq(outData, data, pred2);

    // .. the rest:
    final k = (this.data![predModeSrc++] >> 8) & 0xf;

    var predFunc = PREDICTORS[k];
    for (var x = 1; x < width; ++x) {
      if ((x & mask) == 0) {
        // start of tile. Read predictor function.
        final k = ((this.data![predModeSrc++]) >> 8) & 0xf;
        predFunc = PREDICTORS[k];
      }
      final d = outData[data + x - 1];
      final pred = predFunc(outData, d, data + x - width);
      _addPixelsEq(outData, data + x, pred);
    }

    data += width;
    ++y;

    if ((y & mask) == 0) {
      // Use the same mask, since tiles are squares.
      predModeBase += tilesPerRow;
    }
  }
}