internal static VorbisCodebook Init(VorbisStreamDecoder vorbis, DataPacket packet, int number) { VorbisCodebook vorbisCodebook = new VorbisCodebook(); vorbisCodebook.BookNum = number; vorbisCodebook.Init(packet); return vorbisCodebook; }
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; }
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; }
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; }
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]]; } }
internal static VorbisCodebook Init(VorbisStreamDecoder vorbis, DataPacket packet, int number) { var temp = new VorbisCodebook(); temp.BookNum = number; temp.Init(packet); return temp; }
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; }
internal void Init(DataPacket packet) { if ((long) packet.ReadBits(24) != 5653314L) throw new InvalidDataException(); this.Dimensions = (int) packet.ReadBits(16); this.Entries = (int) packet.ReadBits(24); this.Lengths = new int[this.Entries]; this.InitTree(packet); this.InitLookupTable(packet); }
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; }
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; }
protected override void Init(DataPacket packet) { int length1 = 1; if (packet.ReadBit()) length1 += (int) packet.ReadBits(4); int length2 = 0; if (packet.ReadBit()) length2 = (int) packet.ReadBits(8) + 1; int count = Utils.ilog(this._vorbis._channels - 1); this.CouplingSteps = new VorbisMapping.CouplingStep[length2]; for (int index = 0; index < length2; ++index) { int num1 = (int) packet.ReadBits(count); int num2 = (int) packet.ReadBits(count); if (num1 == num2 || num1 > this._vorbis._channels - 1 || num2 > this._vorbis._channels - 1) throw new InvalidDataException(); this.CouplingSteps[index] = new VorbisMapping.CouplingStep() { Angle = num2, Magnitude = num1 }; } if ((long) packet.ReadBits(2) != 0L) throw new InvalidDataException(); int[] numArray = new int[this._vorbis._channels]; if (length1 > 1) { for (int index = 0; index < this.ChannelSubmap.Length; ++index) { numArray[index] = (int) packet.ReadBits(4); if (numArray[index] >= length1) throw new InvalidDataException(); } } this.Submaps = new VorbisMapping.Submap[length1]; for (int index1 = 0; index1 < length1; ++index1) { long num = (long) packet.ReadBits(8); int index2 = (int) packet.ReadBits(8); if (index2 >= this._vorbis.Floors.Length) throw new InvalidDataException(); if ((int) packet.ReadBits(8) >= this._vorbis.Residues.Length) throw new InvalidDataException(); this.Submaps[index1] = new VorbisMapping.Submap() { Floor = this._vorbis.Floors[index2], Residue = this._vorbis.Residues[index2] }; } this.ChannelSubmap = new VorbisMapping.Submap[this._vorbis._channels]; for (int index = 0; index < this.ChannelSubmap.Length; ++index) this.ChannelSubmap[index] = this.Submaps[numArray[index]]; }
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; }
internal static VorbisMapping Init(VorbisStreamDecoder vorbis, DataPacket packet) { var type = (int)packet.ReadBits(16); VorbisMapping mapping = null; switch (type) { case 0: mapping = new Mapping0(vorbis); break; } if (mapping == null) throw new Exception(); mapping.Init(packet); return mapping; }
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; }
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; }
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; }
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); }
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); }
internal static VorbisResidue Init(VorbisStreamDecoder vorbis, DataPacket packet) { var type = (int)packet.ReadBits(16); VorbisResidue residue = null; switch (type) { case 0: residue = new Residue0(vorbis); break; case 1: residue = new Residue1(vorbis); break; case 2: residue = new Residue2(vorbis); break; } if (residue == null) throw new InvalidDataException(); residue.Init(packet); return residue; }
internal static VorbisFloor Init(VorbisStreamDecoder vorbis, DataPacket packet) { int num = (int) packet.ReadBits(16); VorbisFloor vorbisFloor = (VorbisFloor) null; switch (num) { case 0: vorbisFloor = (VorbisFloor) new VorbisFloor.Floor0(vorbis); break; case 1: vorbisFloor = (VorbisFloor) new VorbisFloor.Floor1(vorbis); break; } if (vorbisFloor == null) throw new InvalidDataException(); vorbisFloor.Init(packet); return vorbisFloor; }
internal static VorbisResidue Init(VorbisStreamDecoder vorbis, DataPacket packet) { int num = (int) packet.ReadBits(16); VorbisResidue vorbisResidue = (VorbisResidue) null; switch (num) { case 0: vorbisResidue = (VorbisResidue) new VorbisResidue.Residue0(vorbis); break; case 1: vorbisResidue = (VorbisResidue) new VorbisResidue.Residue1(vorbis); break; case 2: vorbisResidue = (VorbisResidue) new VorbisResidue.Residue2(vorbis); break; } if (vorbisResidue == null) throw new InvalidDataException(); vorbisResidue.Init(packet); return vorbisResidue; }
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(); }
protected override void Init(DataPacket packet) { // this is pretty well stolen directly from libvorbis... BSD license _order = (int)packet.ReadBits(8); _rate = (int)packet.ReadBits(16); _bark_map_size = (int)packet.ReadBits(16); _ampBits = (int)packet.ReadBits(6); _ampOfs = (int)packet.ReadBits(8); _books = new VorbisCodebook[(int)packet.ReadBits(4) + 1]; if (_order < 1 || _rate < 1 || _bark_map_size < 1 || _books.Length == 0) throw new Exception(); _ampDiv = (1 << _ampBits) - 1; for (int i = 0; i < _books.Length; i++) { var num = (int)packet.ReadBits(8); if (num < 0 || num >= _vorbis.Books.Length) throw new Exception(); var book = _vorbis.Books[num]; if (book.MapType == 0 || book.Dimensions < 1) throw new Exception(); _books[i] = book; } _bookBits = Utils.ilog(_books.Length); _barkMaps = new Dictionary<int, int[]>(); _barkMaps[_vorbis.Block0Size] = SynthesizeBarkCurve(_vorbis.Block0Size / 2); _barkMaps[_vorbis.Block1Size] = SynthesizeBarkCurve(_vorbis.Block1Size / 2); _wMap = new Dictionary<int, float[]>(); _wMap[_vorbis.Block0Size] = SynthesizeWDelMap(_vorbis.Block0Size / 2); _wMap[_vorbis.Block1Size] = SynthesizeWDelMap(_vorbis.Block1Size / 2); _reusablePacketData = new PacketData0[_vorbis._channels]; for (int i = 0; i < _reusablePacketData.Length; i++) { _reusablePacketData[i] = new PacketData0() { Coeff = new float[_order + 1] }; } }
public override void Init(DataPacket packet) { _partitionClass = new int[(uint)packet.ReadBits(5)]; for (int i = 0; i < _partitionClass.Length; i++) { _partitionClass[i] = (int)packet.ReadBits(4); } int num = _partitionClass.Max(); _classDimensions = new int[num + 1]; _classSubclasses = new int[num + 1]; _classMasterbooks = new VorbisCodebook[num + 1]; _classMasterBookIndex = new int[num + 1]; _subclassBooks = new VorbisCodebook[num + 1][]; _subclassBookIndex = new int[num + 1][]; for (int j = 0; j <= num; j++) { _classDimensions[j] = (int)packet.ReadBits(3) + 1; _classSubclasses[j] = (int)packet.ReadBits(2); if (_classSubclasses[j] > 0) { _classMasterBookIndex[j] = (int)packet.ReadBits(8); _classMasterbooks[j] = _vorbis.Books[_classMasterBookIndex[j]]; } _subclassBooks[j] = new VorbisCodebook[1 << _classSubclasses[j]]; _subclassBookIndex[j] = new int[_subclassBooks[j].Length]; for (int k = 0; k < _subclassBooks[j].Length; k++) { int num2 = (int)packet.ReadBits(8) - 1; if (num2 >= 0) { _subclassBooks[j][k] = _vorbis.Books[num2]; } _subclassBookIndex[j][k] = num2; } } _multiplier = (int)packet.ReadBits(2); _range = _rangeLookup[_multiplier]; _yBits = _yBitsLookup[_multiplier]; _multiplier++; int num3 = (int)packet.ReadBits(4); List <int> list = new List <int>(); list.Add(0); list.Add(1 << num3); for (int l = 0; l < _partitionClass.Length; l++) { int num4 = _partitionClass[l]; for (int m = 0; m < _classDimensions[num4]; m++) { list.Add((int)packet.ReadBits(num3)); } } _xList = list.ToArray(); _lNeigh = new int[list.Count]; _hNeigh = new int[list.Count]; _sortIdx = new int[list.Count]; _sortIdx[0] = 0; _sortIdx[1] = 1; for (int n = 2; n < _lNeigh.Length; n++) { _lNeigh[n] = 0; _hNeigh[n] = 1; _sortIdx[n] = n; for (int num5 = 2; num5 < n; num5++) { int num6 = _xList[num5]; if (num6 < _xList[n]) { if (num6 > _xList[_lNeigh[n]]) { _lNeigh[n] = num5; } } else if (num6 < _xList[_hNeigh[n]]) { _hNeigh[n] = num5; } } } for (int num7 = 0; num7 < _sortIdx.Length - 1; num7++) { for (int num8 = num7 + 1; num8 < _sortIdx.Length; num8++) { if (_xList[num7] == _xList[num8]) { throw new InvalidDataException(); } if (_xList[_sortIdx[num7]] > _xList[_sortIdx[num8]]) { int num9 = _sortIdx[num7]; _sortIdx[num7] = _sortIdx[num8]; _sortIdx[num8] = num9; } } } _reusablePacketData = new PacketData1[_vorbis._channels]; for (int num10 = 0; num10 < _reusablePacketData.Length; num10++) { _reusablePacketData[num10] = new PacketData1(); } }
protected abstract void Init(DataPacket packet);
internal abstract PacketData UnpackPacket(DataPacket packet, int blockSize, int channel);
internal abstract float[][] Decode(DataPacket packet, bool[] doNotDecode, int channels, int blockSize);
internal override float[][] Decode(DataPacket packet, bool[] doNotDecode, int channels, int blockSize) { float[][] numArray = ACache.Get<float>(channels, blockSize); int num1 = this._partitionSize / channels; if (Enumerable.Contains<bool>((IEnumerable<bool>) doNotDecode, false) && this._nToRead > 0) { int[][] buffer = ACache.Get<int>(this._partWords, this._classWordsPerCodeWord); for (int index1 = 0; index1 < this._maxPasses; ++index1) { int num2 = 0; int index2 = 0; int num3 = this._begin; while (num2 < this._partsToRead) { if (index1 == 0) { int num4 = this._classBook.DecodeScalar(packet); for (int index3 = this._classWordsPerCodeWord - 1; index3 >= 0 && num4 > 0; --index3) { buffer[index2][index3] = num4 % this._classifications; num4 /= this._classifications; } } for (int index3 = 0; index3 < this._classWordsPerCodeWord && num2 < this._partsToRead; ++index3) { VorbisCodebook vorbisCodebook = this._books[buffer[index2][index3]][index1]; if (vorbisCodebook != null && vorbisCodebook.MapType != 0) { int index4 = 0; int num4 = vorbisCodebook.Dimensions; int num5 = 0; int index5 = num3 / channels; while (num5 < num1) { int index6 = vorbisCodebook.DecodeScalar(packet); for (int index7 = 0; index7 < num4; ++index7) { numArray[index4][index5] += vorbisCodebook[index6, index7]; if (++index4 == channels) { index4 = 0; ++num5; ++index5; } } } } ++num2; num3 += this._partitionSize; } ++index2; } } ACache.Return<int>(ref buffer); } return numArray; }
protected override void WriteVectors(VorbisCodebook codebook, DataPacket packet, float[] residue, int offset, int channel) { int num = 0; while (num < this._partitionSize) { int index1 = codebook.DecodeScalar(packet); for (int index2 = 0; index2 < codebook.Dimensions; ++index2) residue[offset + num++] += codebook[index1, index2]; } }
protected virtual void WriteVectors(VorbisCodebook codebook, DataPacket packet, float[] residue, int offset, int channel) { int num1 = this._nToRead / codebook.Dimensions; for (int index1 = 0; index1 < num1; ++index1) { int num2 = 0; int index2 = codebook.DecodeScalar(packet); for (int index3 = 0; index3 < codebook.Dimensions; ++index3) residue[offset + index1 + num2++ * num1] += codebook[index2, index3]; } }
internal override float[][] Decode(DataPacket packet, bool[] doNotDecode, int channels, int blockSize) { float[][] numArray = ACache.Get<float>(doNotDecode.Length, blockSize); if (this._nToRead > 0) { int[][][] buffer = ACache.Get<int>(channels, this._partsToRead, this._classWordsPerCodeWord); for (int index1 = 0; index1 < this._maxPasses; ++index1) { int num1 = 0; int index2 = 0; int num2 = this._begin; while (num1 < this._partsToRead) { if (index1 == 0) { for (int index3 = 0; index3 < channels; ++index3) { if (!doNotDecode[index3]) { int num3 = this._classBook.DecodeScalar(packet); for (int index4 = this._classWordsPerCodeWord - 1; index4 >= 0; --index4) { buffer[index3][index2][index4] = num3 % this._classifications; num3 /= this._classifications; } } } } int index5 = 0; while (index5 < this._classWordsPerCodeWord && num1 < this._partsToRead) { for (int index3 = 0; index3 < channels; ++index3) { if (!doNotDecode[index3]) { VorbisCodebook vorbisCodebook = this._books[buffer[index3][index2][index5]][index1]; if (vorbisCodebook != null && vorbisCodebook.MapType != 0) { VorbisResidue.Residue0 residue0 = this; int num3 = index3; VorbisCodebook codebook = vorbisCodebook; DataPacket packet1 = packet; float[] residue = numArray[index3]; int offset = num2; int channel = num3; residue0.WriteVectors(codebook, packet1, residue, offset, channel); } } } ++index5; ++num1; num2 += this._partitionSize; } ++index2; } } ACache.Return<int>(ref buffer); } return numArray; }
protected override void Init(DataPacket packet) { }
protected override void Init(DataPacket packet) { int length1 = 1; if (packet.ReadBit()) { length1 += (int)packet.ReadBits(4); } int length2 = 0; if (packet.ReadBit()) { length2 = (int)packet.ReadBits(8) + 1; } int count = Utils.ilog(this._vorbis._channels - 1); this.CouplingSteps = new VorbisMapping.CouplingStep[length2]; for (int index = 0; index < length2; ++index) { int num1 = (int)packet.ReadBits(count); int num2 = (int)packet.ReadBits(count); if (num1 == num2 || num1 > this._vorbis._channels - 1 || num2 > this._vorbis._channels - 1) { throw new InvalidDataException(); } this.CouplingSteps[index] = new VorbisMapping.CouplingStep() { Angle = num2, Magnitude = num1 }; } if ((long)packet.ReadBits(2) != 0L) { throw new InvalidDataException(); } int[] numArray = new int[this._vorbis._channels]; if (length1 > 1) { for (int index = 0; index < this.ChannelSubmap.Length; ++index) { numArray[index] = (int)packet.ReadBits(4); if (numArray[index] >= length1) { throw new InvalidDataException(); } } } this.Submaps = new VorbisMapping.Submap[length1]; for (int index1 = 0; index1 < length1; ++index1) { long num = (long)packet.ReadBits(8); int index2 = (int)packet.ReadBits(8); if (index2 >= this._vorbis.Floors.Length) { throw new InvalidDataException(); } if ((int)packet.ReadBits(8) >= this._vorbis.Residues.Length) { throw new InvalidDataException(); } this.Submaps[index1] = new VorbisMapping.Submap() { Floor = this._vorbis.Floors[index2], Residue = this._vorbis.Residues[index2] }; } this.ChannelSubmap = new VorbisMapping.Submap[this._vorbis._channels]; for (int index = 0; index < this.ChannelSubmap.Length; ++index) { this.ChannelSubmap[index] = this.Submaps[numArray[index]]; } }
public abstract void Init(DataPacket packet);