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


C# DataPacket.TryPeekBits方法代码示例

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


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

示例1: DecodeScalar

        internal int DecodeScalar(DataPacket packet)
        {
            int bitCnt;
            var bits = (int)packet.TryPeekBits(PrefixBitLength, out bitCnt);
            if (bitCnt == 0) return -1;

            // try to get the value from the prefix list...
            var node = PrefixList[bits];
            if (node != null)
            {
                packet.SkipBits(node.Length);
                return node.Value;
            }

            // nope, not possible... run the tree
            bits = (int)packet.TryPeekBits(MaxBits, out bitCnt);

            node = PrefixOverflowTree;
            do
            {
                if (node.Bits == (bits & node.Mask))
                {
                    packet.SkipBits(node.Length);
                    return node.Value;
                }
            } while ((node = node.Next) != null);
            return -1;
        }
开发者ID:gregzo,项目名称:G-Audio,代码行数:28,代码来源:VorbisCodebook.cs

示例2: DecodeScalar

        internal int DecodeScalar(DataPacket packet)
        {
            // try to get as many bits as possible...
            int bitCnt; // we really don't care how many bits were read; try to decode anyway...
            var bits = (int)packet.TryPeekBits(MaxBits, out bitCnt);
            if (bitCnt == 0) throw new InvalidDataException();

            // now go through the list and find the matching entry
            var node = LTree;
            while (node != null)
            {
                if (node.Bits == (bits & node.Mask))
                {
                    node.HitCount++;
                    packet.SkipBits(node.Length);
                    return node.Value;
                }
                node = node.Next;
            }
            throw new InvalidDataException();
        }
开发者ID:mokujin,项目名称:DN,代码行数:21,代码来源:VorbisCodebook.cs

示例3: DecodeScalar

 internal int DecodeScalar(DataPacket packet)
 {
   int bitsRead;
   int num = (int) packet.TryPeekBits(this.MaxBits, out bitsRead);
   if (bitsRead == 0)
     throw new InvalidDataException();
   for (HuffmanListNode<int> huffmanListNode = this.LTree; huffmanListNode != null; huffmanListNode = huffmanListNode.Next)
   {
     if (huffmanListNode.Bits == (num & huffmanListNode.Mask))
     {
       ++huffmanListNode.HitCount;
       packet.SkipBits(huffmanListNode.Length);
       return huffmanListNode.Value;
     }
   }
   throw new InvalidDataException();
 }
开发者ID:Zeludon,项目名称:FEZ,代码行数:17,代码来源:VorbisCodebook.cs


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