本文整理汇总了C#中NVorbis.DataPacket类的典型用法代码示例。如果您正苦于以下问题:C# DataPacket类的具体用法?C# DataPacket怎么用?C# DataPacket使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DataPacket类属于NVorbis命名空间,在下文中一共展示了DataPacket类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: Init
internal static VorbisMode Init(VorbisStreamDecoder vorbis, DataPacket packet)
{
var mode = new VorbisMode(vorbis);
mode.BlockFlag = packet.ReadBit();
mode.WindowType = (int)packet.ReadBits(16);
mode.TransformType = (int)packet.ReadBits(16);
var mapping = (int)packet.ReadBits(8);
if (mode.WindowType != 0 || mode.TransformType != 0 || mapping >= vorbis.Maps.Length) throw new InvalidDataException();
mode.Mapping = vorbis.Maps[mapping];
mode.BlockSize = mode.BlockFlag ? vorbis.Block1Size : vorbis.Block0Size;
// now pre-calc the window(s)...
if (mode.BlockFlag)
{
// long block
mode._windows = new float[4][];
mode._windows[0] = new float[vorbis.Block1Size];
mode._windows[1] = new float[vorbis.Block1Size];
mode._windows[2] = new float[vorbis.Block1Size];
mode._windows[3] = new float[vorbis.Block1Size];
}
else
{
// short block
mode._windows = new float[1][];
mode._windows[0] = new float[vorbis.Block0Size];
}
mode.CalcWindows();
return mode;
}
示例3: Init
internal static VorbisCodebook Init(VorbisStreamDecoder vorbis, DataPacket packet, int number)
{
var temp = new VorbisCodebook();
temp.BookNum = number;
temp.Init(packet);
return temp;
}
示例4: AddPacket
internal void AddPacket(DataPacket packet)
{
if (packet.IsResync)
{
packet.IsContinuation = false;
if (this._last != null)
this._last.IsContinued = false;
}
if (packet.IsContinuation)
{
if (this._last == null)
throw new InvalidDataException();
if (!this._last.IsContinued)
throw new InvalidDataException();
this._last.MergeWith(packet);
this._last.IsContinued = packet.IsContinued;
}
else
{
Packet packet1 = packet as Packet;
if (packet1 == null)
throw new ArgumentException("Wrong packet datatype", "packet");
if (this._first == null)
{
this._first = packet1;
this._last = packet1;
}
else
this._last = (packet1.Prev = this._last).Next = packet1;
}
PacketReader packetReader = this;
int num = packetReader._eosFound | packet.IsEndOfStream ? 1 : 0;
packetReader._eosFound = num != 0;
}
示例5: Init
internal static VorbisMode Init(VorbisStreamDecoder vorbis, DataPacket packet)
{
VorbisMode vorbisMode = new VorbisMode(vorbis);
vorbisMode.BlockFlag = packet.ReadBit();
vorbisMode.WindowType = (int) packet.ReadBits(16);
vorbisMode.TransformType = (int) packet.ReadBits(16);
int index = (int) packet.ReadBits(8);
if (vorbisMode.WindowType != 0 || vorbisMode.TransformType != 0 || index >= vorbis.Maps.Length)
throw new InvalidDataException();
vorbisMode.Mapping = vorbis.Maps[index];
vorbisMode.BlockSize = vorbisMode.BlockFlag ? vorbis.Block1Size : vorbis.Block0Size;
if (vorbisMode.BlockFlag)
{
vorbisMode._windows = new float[4][];
vorbisMode._windows[0] = new float[vorbis.Block1Size];
vorbisMode._windows[1] = new float[vorbis.Block1Size];
vorbisMode._windows[2] = new float[vorbis.Block1Size];
vorbisMode._windows[3] = new float[vorbis.Block1Size];
}
else
{
vorbisMode._windows = new float[1][];
vorbisMode._windows[0] = new float[vorbis.Block0Size];
}
vorbisMode.CalcWindows();
return vorbisMode;
}
示例6: Init
internal static VorbisCodebook Init(VorbisStreamDecoder vorbis, DataPacket packet, int number)
{
VorbisCodebook vorbisCodebook = new VorbisCodebook();
vorbisCodebook.BookNum = number;
vorbisCodebook.Init(packet);
return vorbisCodebook;
}
示例7: Init
protected override void Init(DataPacket packet)
{
var submapCount = 1;
if (packet.ReadBit()) submapCount += (int)packet.ReadBits(4);
// square polar mapping
var couplingSteps = 0;
if (packet.ReadBit())
{
couplingSteps = (int)packet.ReadBits(8) + 1;
}
var couplingBits = Utils.ilog(_vorbis._channels - 1);
CouplingSteps = new CouplingStep[couplingSteps];
for (int j = 0; j < couplingSteps; j++)
{
var magnitude = (int)packet.ReadBits(couplingBits);
var angle = (int)packet.ReadBits(couplingBits);
if (magnitude == angle || magnitude > _vorbis._channels - 1 || angle > _vorbis._channels - 1)
throw new Exception();
CouplingSteps[j] = new CouplingStep { Angle = angle, Magnitude = magnitude };
}
// reserved bits
if (packet.ReadBits(2) != 0UL) throw new Exception();
// channel multiplex
var mux = new int[_vorbis._channels];
if (submapCount > 1)
{
for (int c = 0; c < ChannelSubmap.Length; c++)
{
mux[c] = (int)packet.ReadBits(4);
if (mux[c] >= submapCount) throw new Exception();
}
}
// submaps
Submaps = new Submap[submapCount];
for (int j = 0; j < submapCount; j++)
{
packet.ReadBits(8); // unused placeholder
var floorNum = (int)packet.ReadBits(8);
if (floorNum >= _vorbis.Floors.Length) throw new Exception();
var residueNum = (int)packet.ReadBits(8);
if (residueNum >= _vorbis.Residues.Length) throw new Exception();
Submaps[j] = new Submap
{
Floor = _vorbis.Floors[floorNum],
Residue = _vorbis.Residues[floorNum]
};
}
ChannelSubmap = new Submap[_vorbis._channels];
for (int c = 0; c < ChannelSubmap.Length; c++)
{
ChannelSubmap[c] = Submaps[mux[c]];
}
}
示例8: Init
internal static VorbisMapping Init(VorbisStreamDecoder vorbis, DataPacket packet)
{
int num = (int) packet.ReadBits(16);
VorbisMapping vorbisMapping = (VorbisMapping) null;
if (num == 0)
vorbisMapping = (VorbisMapping) new VorbisMapping.Mapping0(vorbis);
if (vorbisMapping == null)
throw new InvalidDataException();
vorbisMapping.Init(packet);
return vorbisMapping;
}
示例9: Init
internal static VorbisTime Init(VorbisStreamDecoder vorbis, DataPacket packet)
{
int num = (int) packet.ReadBits(16);
VorbisTime vorbisTime = (VorbisTime) null;
if (num == 0)
vorbisTime = (VorbisTime) new VorbisTime.Time0(vorbis);
if (vorbisTime == null)
throw new InvalidDataException();
vorbisTime.Init(packet);
return vorbisTime;
}
示例10: Init
protected override void Init(DataPacket packet)
{
this._begin = (int) packet.ReadBits(24);
this._end = (int) packet.ReadBits(24);
this._partitionSize = (int) packet.ReadBits(24) + 1;
this._classifications = (int) packet.ReadBits(6) + 1;
this._classBookNum = (int) packet.ReadBits(8);
this._classBook = this._vorbis.Books[this._classBookNum];
this._cascade = new int[this._classifications];
int length = 0;
int val2 = 0;
for (int index = 0; index < this._classifications; ++index)
{
int num1 = 0;
int num2 = (int) packet.ReadBits(3);
if (packet.ReadBit())
num1 = (int) packet.ReadBits(5);
this._cascade[index] = num1 << 3 | num2;
length += VorbisResidue.Residue0.icount(this._cascade[index]);
val2 = Math.Max(Utils.ilog(this._cascade[index]), val2);
}
this._maxPasses = val2;
int[] numArray = new int[length];
for (int index = 0; index < length; ++index)
numArray[index] = (int) packet.ReadBits(8);
int num3 = 0;
this._books = new VorbisCodebook[this._classifications][];
this._bookNums = new int[this._classifications][];
for (int index1 = 0; index1 < this._classifications; ++index1)
{
this._books[index1] = new VorbisCodebook[8];
this._bookNums[index1] = new int[8];
int num1 = 1;
int index2 = 0;
while (num1 < 256)
{
if ((this._cascade[index1] & num1) == num1)
{
int index3 = numArray[num3++];
this._books[index1][index2] = this._vorbis.Books[index3];
this._bookNums[index1][index2] = index3;
if (this._books[index1][index2].MapType == 0)
throw new InvalidDataException();
}
num1 <<= 1;
++index2;
}
}
this._classWordsPerCodeWord = this._classBook.Dimensions;
this._nToRead = this._end - this._begin;
this._partsToRead = this._nToRead / this._partitionSize;
this._partWords = (this._partsToRead + this._classWordsPerCodeWord - 1) / this._classWordsPerCodeWord;
}
示例11: Init
internal static VorbisTime Init(VorbisStreamDecoder vorbis, DataPacket packet)
{
var type = (int)packet.ReadBits(16);
VorbisTime time = null;
switch (type)
{
case 0: time = new Time0(vorbis); break;
}
if (time == null) throw new InvalidDataException();
time.Init(packet);
return time;
}
示例12: Init
internal static VorbisFloor Init(VorbisStreamDecoder vorbis, DataPacket packet)
{
var type = (int)packet.ReadBits(16);
VorbisFloor floor = null;
switch (type)
{
case 0: floor = new Floor0(vorbis); break;
case 1: floor = new Floor1(vorbis); break;
}
if (floor == null) throw new InvalidDataException();
floor.Init(packet);
return floor;
}
示例13: Init
protected override void Init(DataPacket packet)
{
this._order = (int) packet.ReadBits(8);
this._rate = (int) packet.ReadBits(16);
this._bark_map_size = (int) packet.ReadBits(16);
this._ampBits = (int) packet.ReadBits(6);
this._ampOfs = (int) packet.ReadBits(8);
this._books = new VorbisCodebook[(int) packet.ReadBits(4) + 1];
for (int index = 0; index < this._books.Length; ++index)
this._books[index] = this._vorbis.Books[(int) packet.ReadBits(8)];
this._bookBits = Utils.ilog(this._books.Length);
this._barkMaps = new Dictionary<int, float[]>();
this._barkMaps[this._vorbis.Block0Size] = this.SynthesizeBarkCurve(this._vorbis.Block0Size);
this._barkMaps[this._vorbis.Block1Size] = this.SynthesizeBarkCurve(this._vorbis.Block1Size);
}
示例14: DoMergeWith
protected override void DoMergeWith(DataPacket continuation)
{
Packet packet1 = continuation as Packet;
if (packet1 == null)
throw new ArgumentException("Incorrect packet type!");
Packet packet2 = this;
int num = packet2.Length + continuation.Length;
packet2.Length = num;
if (this._mergedPacket == null)
this._mergedPacket = packet1;
else
this._mergedPacket.DoMergeWith(continuation);
this.PageGranulePosition = continuation.PageGranulePosition;
this.PageSequenceNumber = continuation.PageSequenceNumber;
}
示例15: Init
internal void Init(DataPacket packet)
{
// first, check the sync pattern
var chkVal = packet.ReadBits(24);
if (chkVal != 0x564342UL) throw new Exception();
// get the counts
Dimensions = (int)packet.ReadBits(16);
Entries = (int)packet.ReadBits(24);
// init the storage
Lengths = new int[Entries];
InitTree(packet);
InitLookupTable(packet);
}