예제 #1
0
 public void Encode(Encoder 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 < Encoder.kTopValue)
     {
         encoder.Range <<= 8;
         encoder.ShiftLow();
     }
 }
예제 #2
0
 public void ReverseEncode(Encoder 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;
     }
 }
예제 #3
0
 public static void ReverseEncode(BitEncoder[] Models, UInt32 startIndex,
     Encoder 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;
     }
 }
예제 #4
0
 public void Encode(Encoder 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;
     }
 }