encodeMortal method

dynamic encodeMortal(
  1. int current,
  2. int period
)

Implementation

encodeMortal(int current, int period) {
  final calPeriod = pow(2, (log(period) / log(2)).ceil());
  final phase = current % min(max(calPeriod, 4), 1 << 16);
  final quantizeFactor = max(1, period >> 12);
  final quantizedPhase = phase / quantizeFactor * quantizeFactor;

  return encode(quantizedPhase.toInt(), calPeriod as int);
}