public void Encode(BinaryCoder enc, uint value) { ++value; int magnitude = 0; while (value >= (2u << magnitude)) { ++magnitude; } m_magnitude.Encode(enc, magnitude); uint mask = (uint)(magnitude == 0 ? 1u << (magnitude - 1) : 0); if (mask != 0) { int top = (magnitude < MAX_TOP) ? magnitude : MAX_TOP; m_bitPositions[top].Encode(enc, ((value & mask) != 0) ? 1:0); mask >>= 1; while (mask != 0) { int bit = (value & mask) != 0 ? 1 : 0; enc.Encode(bit, CoderConstants.PROB_MAX / 2); mask >>= 1; } } }
public void Encode(BinaryCoder enc, int val, bool signPred) { int absv = (val < 0) ? -val : val; m_absoluteVal.Encode(enc, (uint)absv); if (absv != 0) { m_signs[signPred ? 1 : 0].Encode(enc, val < 0 ? 1 : 0); } }
public void Encode(BinaryCoder enc, int value) { if (m_init == false) { throw new Exception("BitTreeMode uninitialized!"); } int context = 1; while (context < m_totalSymbols) { int bit = ((value & m_MSB) != 0) ? 1 : 0; value += value; m_model[context - 1].Encode(enc, bit); context += context + bit; } }
public void Encode(BinaryCoder enc, int bit) { enc.Encode(bit, m_prob); Adapt(bit); }