c/common/context.h
inline void ACPredictContext(int64_t p, size_t* avg_ctx, size_t* sgn) {
  int multiplier;
  if (p >= 0) {
    multiplier = 1;
  } else {
    multiplier = -1;
    p = -p;
  }
  size_t ctx;
  if (p >= (1u << kMaxAverageContext)) {
    ctx = kMaxAverageContext;
  } else {
    // 0 -> 0, 1 -> 1, 2..3 -> 2, 4..7 -> 3, etc.
    ctx = Log2FloorNonZero(2 * static_cast<uint32_t>(p)+ 1);
  }
  *avg_ctx = ctx;
  *sgn = kMaxAverageContext + multiplier * ctx;
}
// Computes average and sign context from the AC prediction.
Computes average and sign context from the AC prediction.
Computes average and sign context from the AC prediction .
inline void ACPredictContext(int64_t p, size_t* avg_ctx, size_t* sgn) {
  int multiplier;
  if (p >= 0) {
    multiplier = 1;
  } else {
    multiplier = -1;
    p = -p;
  }
  size_t ctx;
  if (p >= (1u << kMaxAverageContext)) {
    ctx = kMaxAverageContext;
  } else {
    ctx = Log2FloorNonZero(2 * static_cast<uint32_t>(p)+ 1);
  }
  *avg_ctx = ctx;
  *sgn = kMaxAverageContext + multiplier * ctx;
}
inline void ACPredictContext ( int64_t p , size_t * avg_ctx , size_t * sgn ) { int multiplier ; if ( p >= 0 ) { multiplier = 1 ; } else { multiplier = -1 ; p = - p ; } size_t ctx ; if ( p >= ( 1u << kMaxAverageContext ) ) { ctx = kMaxAverageContext ; } else { ctx = Log2FloorNonZero ( 2 * static_cast < uint32_t > ( p ) + 1 ) ; } * avg_ctx = ctx ; * sgn = kMaxAverageContext + multiplier * ctx ; }
Computes average and sign context from the AC prediction.
Computes average and sign context from the AC prediction .
// 0 -> 0, 1 -> 1, 2..3 -> 2, 4..7 -> 3, etc.