本文整理匯總了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();
}