当前位置: 首页>>代码示例>>C#>>正文


C# DataPacket.SkipBits方法代码示例

本文整理汇总了C#中NVorbis.DataPacket.SkipBits方法的典型用法代码示例。如果您正苦于以下问题:C# DataPacket.SkipBits方法的具体用法?C# DataPacket.SkipBits怎么用?C# DataPacket.SkipBits使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在NVorbis.DataPacket的用法示例。


在下文中一共展示了DataPacket.SkipBits方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: LoadBooks

 private void LoadBooks(DataPacket packet)
 {
   packet.SkipBits(8);
   if (!Enumerable.SequenceEqual<byte>((IEnumerable<byte>) packet.ReadBytes(6), (IEnumerable<byte>) new byte[6]
   {
     (byte) 118,
     (byte) 111,
     (byte) 114,
     (byte) 98,
     (byte) 105,
     (byte) 115
   }))
     throw new InvalidDataException("Corrupted book header!");
   long bitsRead1 = packet.BitsRead;
   this._glueBits += packet.BitsRead;
   this.Books = new VorbisCodebook[(int) packet.ReadByte() + 1];
   for (int number = 0; number < this.Books.Length; ++number)
     this.Books[number] = VorbisCodebook.Init(this, packet, number);
   this._bookBits += packet.BitsRead - bitsRead1;
   long bitsRead2 = packet.BitsRead;
   this.Times = new VorbisTime[(int) packet.ReadBits(6) + 1];
   for (int index = 0; index < this.Times.Length; ++index)
     this.Times[index] = VorbisTime.Init(this, packet);
   this._timeHdrBits += packet.BitsRead - bitsRead2;
   long bitsRead3 = packet.BitsRead;
   this.Floors = new VorbisFloor[(int) packet.ReadBits(6) + 1];
   for (int index = 0; index < this.Floors.Length; ++index)
     this.Floors[index] = VorbisFloor.Init(this, packet);
   this._floorHdrBits += packet.BitsRead - bitsRead3;
   long bitsRead4 = packet.BitsRead;
   this.Residues = new VorbisResidue[(int) packet.ReadBits(6) + 1];
   for (int index = 0; index < this.Residues.Length; ++index)
     this.Residues[index] = VorbisResidue.Init(this, packet);
   this._resHdrBits += packet.BitsRead - bitsRead4;
   long bitsRead5 = packet.BitsRead;
   this.Maps = new VorbisMapping[(int) packet.ReadBits(6) + 1];
   for (int index = 0; index < this.Maps.Length; ++index)
     this.Maps[index] = VorbisMapping.Init(this, packet);
   this._mapHdrBits += packet.BitsRead - bitsRead5;
   long bitsRead6 = packet.BitsRead;
   this.Modes = new VorbisMode[(int) packet.ReadBits(6) + 1];
   for (int index = 0; index < this.Modes.Length; ++index)
     this.Modes[index] = VorbisMode.Init(this, packet);
   this._modeHdrBits += packet.BitsRead - bitsRead6;
   if (!packet.ReadBit())
     throw new InvalidDataException();
   ++this._glueBits;
   this._wasteHdrBits += (long) (8 * packet.Length) - packet.BitsRead;
   this._modeFieldBits = Utils.ilog(this.Modes.Length - 1);
 }
开发者ID:tanis2000,项目名称:FEZ,代码行数:50,代码来源:VorbisStreamDecoder.cs

示例4: LoadComments

 private void LoadComments(DataPacket packet)
 {
   packet.SkipBits(8);
   if (!Enumerable.SequenceEqual<byte>((IEnumerable<byte>) packet.ReadBytes(6), (IEnumerable<byte>) new byte[6]
   {
     (byte) 118,
     (byte) 111,
     (byte) 114,
     (byte) 98,
     (byte) 105,
     (byte) 115
   }))
     throw new InvalidDataException("Corrupted comment header!");
   this._glueBits += 56L;
   this._vendor = Encoding.UTF8.GetString(packet.ReadBytes(packet.ReadInt32()));
   this._comments = new string[packet.ReadInt32()];
   for (int index = 0; index < this._comments.Length; ++index)
     this._comments[index] = Encoding.UTF8.GetString(packet.ReadBytes(packet.ReadInt32()));
   this._metaBits += packet.BitsRead - 56L;
   this._wasteHdrBits += (long) (8 * packet.Length) - packet.BitsRead;
 }
开发者ID:tanis2000,项目名称:FEZ,代码行数:21,代码来源:VorbisStreamDecoder.cs

示例5: LoadComments

        void LoadComments(DataPacket packet)
        {
            byte [] temp;

            packet.SkipBits(8);
            if (!packet.ReadBytes(6).SequenceEqual(new byte[] { 0x76, 0x6f, 0x72, 0x62, 0x69, 0x73 })) throw new ArgumentException("Corrupted comment header!");

            _glueBits += 56;

            temp = packet.ReadBytes ( packet.ReadInt32 () );
            _vendor = Encoding.UTF8.GetString ( temp, 0, temp.Length );

            _comments = new string[packet.ReadInt32()];
            for (int i = 0; i < _comments.Length; i++)
            {
                temp = packet.ReadBytes ( packet.ReadInt32 () );
                _comments[i] = Encoding.UTF8.GetString( temp, 0, temp.Length );
            }

            _metaBits += packet.BitsRead - 56;
            _wasteHdrBits += 8 * packet.Length - packet.BitsRead;
        }
开发者ID:Daramkun,项目名称:Misty,代码行数:22,代码来源:VorbisStreamDecoder.cs

示例6: LoadBooks

        void LoadBooks(DataPacket packet)
        {
            packet.SkipBits(8);
            if ( !packet.ReadBytes ( 6 ).SequenceEqual ( new byte [] { 0x76, 0x6f, 0x72, 0x62, 0x69, 0x73 } ) ) throw new ArgumentException ( "Corrupted book header!" );

            var bits = packet.BitsRead;

            _glueBits += packet.BitsRead;

            // get books
            Books = new VorbisCodebook[packet.ReadByte() + 1];
            for (int i = 0; i < Books.Length; i++)
            {
                Books[i] = VorbisCodebook.Init(this, packet, i);
            }

            _bookBits += packet.BitsRead - bits;
            bits = packet.BitsRead;

            // get times
            Times = new VorbisTime[(int)packet.ReadBits(6) + 1];
            for (int i = 0; i < Times.Length; i++)
            {
                Times[i] = VorbisTime.Init(this, packet);
            }

            _timeHdrBits += packet.BitsRead - bits;
            bits = packet.BitsRead;

            // get floor
            Floors = new VorbisFloor[(int)packet.ReadBits(6) + 1];
            for (int i = 0; i < Floors.Length; i++)
            {
                Floors[i] = VorbisFloor.Init(this, packet);
            }

            _floorHdrBits += packet.BitsRead - bits;
            bits = packet.BitsRead;

            // get residue
            Residues = new VorbisResidue[(int)packet.ReadBits(6) + 1];
            for (int i = 0; i < Residues.Length; i++)
            {
                Residues[i] = VorbisResidue.Init(this, packet);
            }

            _resHdrBits += packet.BitsRead - bits;
            bits = packet.BitsRead;

            // get map
            Maps = new VorbisMapping[(int)packet.ReadBits(6) + 1];
            for (int i = 0; i < Maps.Length; i++)
            {
                Maps[i] = VorbisMapping.Init(this, packet);
            }

            _mapHdrBits += packet.BitsRead - bits;
            bits = packet.BitsRead;

            // get mode settings
            Modes = new VorbisMode[(int)packet.ReadBits(6) + 1];
            for (int i = 0; i < Modes.Length; i++)
            {
                Modes[i] = VorbisMode.Init(this, packet);
            }

            _modeHdrBits += packet.BitsRead - bits;

            // check the framing bit
            if ( !packet.ReadBit () ) throw new ArgumentException ();

            ++_glueBits;

            _wasteHdrBits += 8 * packet.Length - packet.BitsRead;

            _modeFieldBits = Utils.ilog(Modes.Length - 1);
        }
开发者ID:Daramkun,项目名称:Misty,代码行数:77,代码来源:VorbisStreamDecoder.cs

示例7: 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.SkipBits方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。