Пример #1
0
 public uint Decode(Decoder rangeDecoder)
 {
     uint newBound = (rangeDecoder.Range >> kNumBitModelTotalBits)*Prob;
     if (rangeDecoder.Code < newBound)
     {
         rangeDecoder.Range = newBound;
         Prob += (kBitModelTotal - Prob) >> kNumMoveBits;
         if (rangeDecoder.Range < Decoder.kTopValue)
         {
             rangeDecoder.Code = (rangeDecoder.Code << 8) | (byte) rangeDecoder.Stream.ReadByte();
             rangeDecoder.Range <<= 8;
         }
         return 0;
     }
     else
     {
         rangeDecoder.Range -= newBound;
         rangeDecoder.Code -= newBound;
         Prob -= (Prob) >> kNumMoveBits;
         if (rangeDecoder.Range < Decoder.kTopValue)
         {
             rangeDecoder.Code = (rangeDecoder.Code << 8) | (byte) rangeDecoder.Stream.ReadByte();
             rangeDecoder.Range <<= 8;
         }
         return 1;
     }
 }
Пример #2
0
 public uint Decode(Decoder rangeDecoder)
 {
     uint m = 1;
     for (int bitIndex = NumBitLevels; bitIndex > 0; bitIndex--)
         m = (m << 1) + Models[m].Decode(rangeDecoder);
     return m - ((uint) 1 << NumBitLevels);
 }
Пример #3
0
 public uint ReverseDecode(Decoder rangeDecoder)
 {
     uint m = 1;
     uint symbol = 0;
     for (int bitIndex = 0; bitIndex < NumBitLevels; bitIndex++)
     {
         uint bit = Models[m].Decode(rangeDecoder);
         m <<= 1;
         m += bit;
         symbol |= (bit << bitIndex);
     }
     return symbol;
 }
Пример #4
0
 public static uint ReverseDecode(BitDecoder[] Models, UInt32 startIndex,
                                  Decoder rangeDecoder, int NumBitLevels)
 {
     uint m = 1;
     uint symbol = 0;
     for (int bitIndex = 0; bitIndex < NumBitLevels; bitIndex++)
     {
         uint bit = Models[startIndex + m].Decode(rangeDecoder);
         m <<= 1;
         m += bit;
         symbol |= (bit << bitIndex);
     }
     return symbol;
 }