本文整理汇总了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;
}
示例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();
}
示例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();
}