Esempio n. 1
0
 public new void Encode(RangeEncoder rangeEncoder, UInt32 symbol, UInt32 posState)
 {
     base.Encode(rangeEncoder, symbol, posState);
     if (--_counters[posState] == 0)
         UpdateTable(posState);
 }
Esempio n. 2
0
 public void EncodeMatched(RangeEncoder rangeEncoder, byte matchByte, byte symbol)
 {
     uint context = 1;
     bool same = true;
     for (int i = 7; i >= 0; i--)
     {
         uint bit = (uint)((symbol >> i) & 1);
         uint state = context;
         if (same)
         {
             uint matchBit = (uint)((matchByte >> i) & 1);
             state += ((1 + matchBit) << 8);
             same = (matchBit == bit);
         }
         m_Encoders[state].Encode(rangeEncoder, bit);
         context = (context << 1) | bit;
     }
 }
Esempio n. 3
0
 public void Encode(RangeEncoder rangeEncoder, UInt32 symbol, UInt32 posState)
 {
     if (symbol < LZMABase.kNumLowLenSymbols)
     {
         _choice.Encode(rangeEncoder, 0);
         _lowCoder[posState].Encode(rangeEncoder, symbol);
     }
     else
     {
         symbol -= LZMABase.kNumLowLenSymbols;
         _choice.Encode(rangeEncoder, 1);
         if (symbol < LZMABase.kNumMidLenSymbols)
         {
             _choice2.Encode(rangeEncoder, 0);
             _midCoder[posState].Encode(rangeEncoder, symbol);
         }
         else
         {
             _choice2.Encode(rangeEncoder, 1);
             _highCoder.Encode(rangeEncoder, symbol - LZMABase.kNumMidLenSymbols);
         }
     }
 }
Esempio n. 4
0
 public void Encode(RangeEncoder rangeEncoder, byte symbol)
 {
     uint context = 1;
     for (int i = 7; i >= 0; i--)
     {
         uint bit = (uint)((symbol >> i) & 1);
         m_Encoders[context].Encode(rangeEncoder, bit);
         context = (context << 1) | bit;
     }
 }
Esempio n. 5
0
 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;
     }
 }
Esempio n. 6
0
 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;
     }
 }
Esempio n. 7
0
 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;
     }
 }
Esempio n. 8
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();
     }
 }