c/common/context.h
inline uint8_t NumNonzerosContext(const uint8_t* prev, int x, int y) {
  size_t prediction;
  if (y == 0) {
    if (x == 0) {
      // Special case: top-left block.
      prediction = 0;
    } else {
      // No row above; use block at left.
      prediction = prev[x - 1];
    }
  } else if (x == 0) {
    // No column to the left; use block above.
    prediction = prev[x];
  } else {
    // Average of left and above blocks.
    prediction = (prev[x - 1] + prev[x] + 1) / 2;
  }
  BRUNSLI_DCHECK(prediction <= kNumNonZeroTreeSize);
  return static_cast<uint8_t>(prediction / kNumNonZeroQuant);
}
/**
 * PRECONDITION: 0 <= prev[i] <= 63
 * PRECONDITION: elements of prev at and after x correspond to previous
 *               row; elements before x correspond to current row
 */
0 <= prev[i] <= 63
PRECONDITION: elements of prev at and after x correspond to previous
row; elements before x correspond to current row
0 < = prev [ i ] < = 63 PRECONDITION : elements of prev at and after x correspond to previous row ; elements before x correspond to current row
inline uint8_t NumNonzerosContext(const uint8_t* prev, int x, int y) {
  size_t prediction;
  if (y == 0) {
    if (x == 0) {
      prediction = 0;
    } else {
      prediction = prev[x - 1];
    }
  } else if (x == 0) {
    prediction = prev[x];
  } else {
    prediction = (prev[x - 1] + prev[x] + 1) / 2;
  }
  BRUNSLI_DCHECK(prediction <= kNumNonZeroTreeSize);
  return static_cast<uint8_t>(prediction / kNumNonZeroQuant);
}
inline uint8_t NumNonzerosContext ( const uint8_t * prev , int x , int y ) { size_t prediction ; if ( y == 0 ) { if ( x == 0 ) { prediction = 0 ; } else { prediction = prev [ x - 1 ] ; } } else if ( x == 0 ) { prediction = prev [ x ] ; } else { prediction = ( prev [ x - 1 ] + prev [ x ] + 1 ) / 2 ; } BRUNSLI_DCHECK ( prediction <= kNumNonZeroTreeSize ) ; return static_cast < uint8_t > ( prediction / kNumNonZeroQuant ) ; }
PRECONDITION: 0 <= prev[i] <= 63
 PRECONDITION: elements of prev at and after x correspond to previous
               row; elements before x correspond to current row
PRECONDITION : 0 < = prev [ i ] < = 63 PRECONDITION : elements of prev at and after x correspond to previous row ; elements before x correspond to current row
// Special case: top-left block. // No row above; use block at left. // No column to the left; use block above. // Average of left and above blocks.