public void ReverseEncode(RangeEncoder rangeEncoder, UInt32 symbol)
        {
            UInt32 m = 1;

            for (UInt32 i = 0; i < _numBitLevels; i++)
            {
                UInt32 bit = symbol & 1;
                _models[m].Encode(rangeEncoder, bit);
                m        = (m << 1) | bit;
                symbol >>= 1;
            }
        }
        public void Encode(RangeEncoder rangeEncoder, UInt32 symbol)
        {
            UInt32 m = 1;

            for (int bitIndex = _numBitLevels; bitIndex > 0;)
            {
                bitIndex--;
                UInt32 bit = (symbol >> bitIndex) & 1;
                _models[m].Encode(rangeEncoder, bit);
                m = (m << 1) | bit;
            }
        }
        public static void ReverseEncode(RangeBitEncoder[] Models, UInt32 startIndex,
                                         RangeEncoder rangeEncoder, int NumBitLevels, UInt32 symbol)
        {
            UInt32 m = 1;

            for (int i = 0; i < NumBitLevels; i++)
            {
                UInt32 bit = symbol & 1;
                Models[startIndex + m].Encode(rangeEncoder, bit);
                m        = (m << 1) | bit;
                symbol >>= 1;
            }
        }
Exemple #4
0
        public void Encode(RangeEncoder encoder, uint symbol)
        {
            // encoder.EncodeBit(Prob, kNumBitModelTotalBits, symbol);
            // UpdateModel(symbol);
            uint newBound = (encoder.Range >> kNumBitModelTotalBits) * _prob;

            if (symbol == 0)
            {
                encoder.Range = newBound;
                _prob        += (kBitModelTotal - _prob) >> kNumMoveBits;
            }
            else
            {
                encoder.Low   += newBound;
                encoder.Range -= newBound;
                _prob         -= (_prob) >> kNumMoveBits;
            }
            if (encoder.Range < RangeEncoder.kTopValue)
            {
                encoder.Range <<= 8;
                encoder.ShiftLow();
            }
        }