当前位置: 首页>>代码示例>>C#>>正文


C# RangeCoder类代码示例

本文整理汇总了C#中RangeCoder的典型用法代码示例。如果您正苦于以下问题:C# RangeCoder类的具体用法?C# RangeCoder怎么用?C# RangeCoder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


RangeCoder类属于命名空间,在下文中一共展示了RangeCoder类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Decode

		public uint Decode(RangeCoder.Decoder rangeDecoder)
		{
			uint newBound = (uint)(rangeDecoder.Range >> kNumBitModelTotalBits) * (uint)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;
			}
		}
开发者ID:RafaelRMachado,项目名称:de4dot,代码行数:27,代码来源:RangeCoderBit.cs

示例2: Decode

 public uint Decode(RangeCoder.Decoder rangeDecoder)
 {
     uint m = 1;
     for (int bitIndex = NumBitLevels; bitIndex > 0; bitIndex--)
         m = (m << 1) + Models[m].Decode(rangeDecoder);
     return m - ((uint)1 << NumBitLevels);
 }
开发者ID:jbtule,项目名称:DaringDocs,代码行数:7,代码来源:RangeCoderBitTree.cs

示例3: DecodeNormal

 public byte DecodeNormal(RangeCoder.Decoder rangeDecoder)
 {
     uint symbol = 1;
     do
         symbol = (symbol << 1) | m_Decoders[symbol].Decode(rangeDecoder); while (symbol < 0x100);
     return (byte) symbol;
 }
开发者ID:yaozd,项目名称:sharpcompress,代码行数:7,代码来源:LzmaDecoder.cs

示例4: Encode

 public void Encode(RangeCoder.Encoder 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;
     }
 }
开发者ID:debop,项目名称:NFramework,代码行数:8,代码来源:LzmaEncoder.cs

示例5: ReverseDecode

 public uint ReverseDecode(RangeCoder.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;
 }
开发者ID:KOLANICH,项目名称:SevenZipSharp,代码行数:12,代码来源:RangeCoderBitTree.cs

示例6: ReverseDecode

 public static uint ReverseDecode(BitDecoder[] models, uint startIndex, RangeCoder.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;
 }
开发者ID:BclEx,项目名称:AdamsyncEx,代码行数:13,代码来源:BitTreeDecoder.cs

示例7: ReverseDecode

        public static uint ReverseDecode(BitDecoder[] Models, UInt32 startIndex,
			RangeCoder.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;
        }
开发者ID:kakkerlakgly,项目名称:de4dot,代码行数:14,代码来源:RangeCoderBitTree.cs

示例8: Decode

			public uint Decode(RangeCoder.Decoder rangeDecoder, uint posState)
			{
				if (m_Choice.Decode(rangeDecoder) == 0)
					return m_LowCoder[posState].Decode(rangeDecoder);
			    uint symbol = Base.kNumLowLenSymbols;
			    if (m_Choice2.Decode(rangeDecoder) == 0)
			        symbol += m_MidCoder[posState].Decode(rangeDecoder);
			    else
			    {
			        symbol += Base.kNumMidLenSymbols;
			        symbol += m_HighCoder.Decode(rangeDecoder);
			    }
			    return symbol;
			}
开发者ID:Ygocore,项目名称:ygosharp_v0.1.1,代码行数:14,代码来源:LzmaDecoder.cs

示例9: DecodeWithMatchByte

 public byte DecodeWithMatchByte(RangeCoder.Decoder rangeDecoder, byte matchByte) {
     uint symbol = 1;
     do {
         uint matchBit = (uint)(matchByte >> 7) & 1;
         matchByte <<= 1;
         uint bit = m_Decoders[((1 + matchBit) << 8) + symbol].Decode(rangeDecoder);
         symbol = (symbol << 1) | bit;
         if(matchBit != bit) {
             while(symbol < 0x100)
                 symbol = (symbol << 1) | m_Decoders[symbol].Decode(rangeDecoder);
             break;
         }
     } while(symbol < 0x100);
     return (byte)symbol;
 }
开发者ID:debop,项目名称:NFramework,代码行数:15,代码来源:LzmaDecoder.cs

示例10: EncodeMatched

 public void EncodeMatched(RangeCoder.Encoder 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;
     }
 }
开发者ID:debop,项目名称:NFramework,代码行数:15,代码来源:LzmaEncoder.cs

示例11: Decode

 /// <summary>
 /// Decodes the specified range decoder.
 /// </summary>
 /// <param name="rangeDecoder">The range decoder.</param>
 /// <param name="posState">State of the pos.</param>
 /// <returns></returns>
 public uint Decode(RangeCoder.Decoder rangeDecoder, uint posState)
 {
     if (_choice.Decode(rangeDecoder) == 0)
         return _lowCoder[posState].Decode(rangeDecoder);
     else
     {
         uint symbol = Base.kNumLowLenSymbols;
         if (_choice2.Decode(rangeDecoder) == 0)
             symbol += _midCoder[posState].Decode(rangeDecoder);
         else
         {
             symbol += Base.kNumMidLenSymbols;
             symbol += _highCoder.Decode(rangeDecoder);
         }
         return symbol;
     }
 }
开发者ID:BclEx,项目名称:AdamsyncEx,代码行数:23,代码来源:Decoder+LenDecoder.cs

示例12: Encode

			public new void Encode(RangeCoder.Encoder rangeEncoder, UInt32 symbol, UInt32 posState)
			{
				base.Encode(rangeEncoder, symbol, posState);
				if (--_counters[posState] == 0)
					UpdateTable(posState);
			}
开发者ID:naterh,项目名称:firmware-mod-kit-osx,代码行数:6,代码来源:LzmaEncoder.cs

示例13: DecodeWithMatchByte

 public byte DecodeWithMatchByte(RangeCoder.Decoder rangeDecoder, uint pos, byte prevByte, byte matchByte)
 {
     return m_Coders[GetState(pos, prevByte)].DecodeWithMatchByte(rangeDecoder, matchByte);
 }
开发者ID:dnywu,项目名称:sales,代码行数:4,代码来源:LzmaDecoder.cs

示例14: DecodeNormal

 public byte DecodeNormal(RangeCoder.Decoder rangeDecoder, uint pos, byte prevByte)
 {
     return m_Coders[GetState(pos, prevByte)].DecodeNormal(rangeDecoder);
 }
开发者ID:dnywu,项目名称:sales,代码行数:4,代码来源:LzmaDecoder.cs

示例15: Code

        internal bool Code(int dictionarySize, LZ.OutWindow outWindow, RangeCoder.Decoder rangeDecoder)
        {
            int dictionarySizeCheck = Math.Max(dictionarySize, 1);

            outWindow.CopyPending();

            while (outWindow.HasSpace)
            {
                uint posState = (uint)outWindow.Total & m_PosStateMask;
                if (m_IsMatchDecoders[(state.Index << Base.kNumPosStatesBitsMax) + posState].Decode(rangeDecoder) == 0)
                {
                    byte b;
                    byte prevByte = outWindow.GetByte(0);
                    if (!state.IsCharState())
                        b = m_LiteralDecoder.DecodeWithMatchByte(rangeDecoder,
                            (uint)outWindow.Total, prevByte, outWindow.GetByte((int)rep0));
                    else
                        b = m_LiteralDecoder.DecodeNormal(rangeDecoder, (uint)outWindow.Total, prevByte);
                    outWindow.PutByte(b);
                    state.UpdateChar();
                }
                else
                {
                    uint len;
                    if (m_IsRepDecoders[state.Index].Decode(rangeDecoder) == 1)
                    {
                        if (m_IsRepG0Decoders[state.Index].Decode(rangeDecoder) == 0)
                        {
                            if (m_IsRep0LongDecoders[(state.Index << Base.kNumPosStatesBitsMax) + posState].Decode(rangeDecoder) == 0)
                            {
                                state.UpdateShortRep();
                                outWindow.PutByte(outWindow.GetByte((int)rep0));
                                continue;
                            }
                        }
                        else
                        {
                            UInt32 distance;
                            if (m_IsRepG1Decoders[state.Index].Decode(rangeDecoder) == 0)
                            {
                                distance = rep1;
                            }
                            else
                            {
                                if (m_IsRepG2Decoders[state.Index].Decode(rangeDecoder) == 0)
                                    distance = rep2;
                                else
                                {
                                    distance = rep3;
                                    rep3 = rep2;
                                }
                                rep2 = rep1;
                            }
                            rep1 = rep0;
                            rep0 = distance;
                        }
                        len = m_RepLenDecoder.Decode(rangeDecoder, posState) + Base.kMatchMinLen;
                        state.UpdateRep();
                    }
                    else
                    {
                        rep3 = rep2;
                        rep2 = rep1;
                        rep1 = rep0;
                        len = Base.kMatchMinLen + m_LenDecoder.Decode(rangeDecoder, posState);
                        state.UpdateMatch();
                        uint posSlot = m_PosSlotDecoder[Base.GetLenToPosState(len)].Decode(rangeDecoder);
                        if (posSlot >= Base.kStartPosModelIndex)
                        {
                            int numDirectBits = (int)((posSlot >> 1) - 1);
                            rep0 = ((2 | (posSlot & 1)) << numDirectBits);
                            if (posSlot < Base.kEndPosModelIndex)
                                rep0 += BitTreeDecoder.ReverseDecode(m_PosDecoders,
                                        rep0 - posSlot - 1, rangeDecoder, numDirectBits);
                            else
                            {
                                rep0 += (rangeDecoder.DecodeDirectBits(
                                    numDirectBits - Base.kNumAlignBits) << Base.kNumAlignBits);
                                rep0 += m_PosAlignDecoder.ReverseDecode(rangeDecoder);
                            }
                        }
                        else
                            rep0 = posSlot;
                    }
                    if (rep0 >= outWindow.Total || rep0 >= dictionarySizeCheck)
                    {
                        if (rep0 == 0xFFFFFFFF)
                            return true;
                        throw new DataErrorException();
                    }
                    outWindow.CopyBlock((int)rep0, (int)len);
                }
            }
            return false;
        }
开发者ID:theahuramazda,项目名称:Saluse-ComicReader,代码行数:95,代码来源:LzmaDecoder.cs


注:本文中的RangeCoder类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。