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


C# RangeCoder.DecodeDirectBits方法代码示例

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


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

示例1: 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.DecodeDirectBits方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。