當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。