コード例 #1
0
ファイル: VorbisMode.cs プロジェクト: tanis2000/FEZ
 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;
 }
コード例 #2
0
ファイル: VorbisMode.cs プロジェクト: chen-ye/SoundStockUnity
        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
0
ファイル: VorbisMode.cs プロジェクト: 1144822034/sc2.2mobile
        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 num = (int)packet.ReadBits(8);

            if (vorbisMode.WindowType != 0 || vorbisMode.TransformType != 0 || num >= vorbis.Maps.Length)
            {
                throw new InvalidDataException();
            }
            vorbisMode.Mapping   = vorbis.Maps[num];
            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);
        }
コード例 #4
0
        internal int GetPacketLength(DataPacket curPacket, DataPacket lastPacket)
        {
            if (lastPacket == null || curPacket.IsResync)
            {
                return(0);
            }
            if (curPacket.ReadBit())
            {
                return(0);
            }
            if (lastPacket.ReadBit())
            {
                return(0);
            }
            int num = (int)curPacket.ReadBits(_modeFieldBits);

            if (num < 0 || num >= Modes.Length)
            {
                return(0);
            }
            VorbisMode vorbisMode = Modes[num];

            num = (int)lastPacket.ReadBits(_modeFieldBits);
            if (num < 0 || num >= Modes.Length)
            {
                return(0);
            }
            VorbisMode vorbisMode2 = Modes[num];

            return(vorbisMode.BlockSize / 4 + vorbisMode2.BlockSize / 4);
        }
コード例 #5
0
        internal int GetPacketLength(DataPacket curPacket, DataPacket lastPacket)
        {
            if (lastPacket == null || curPacket.IsResync || (curPacket.ReadBit() || lastPacket.ReadBit()))
            {
                return(0);
            }
            int index1 = (int)curPacket.ReadBits(this._modeFieldBits);

            if (index1 < 0 || index1 >= this.Modes.Length)
            {
                return(0);
            }
            VorbisMode vorbisMode1 = this.Modes[index1];
            int        index2      = (int)lastPacket.ReadBits(this._modeFieldBits);

            if (index2 < 0 || index2 >= this.Modes.Length)
            {
                return(0);
            }
            VorbisMode vorbisMode2 = this.Modes[index2];

            return(vorbisMode1.BlockSize / 4 + vorbisMode2.BlockSize / 4);
        }
コード例 #6
0
        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 Exception();
            }

            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);
        }
コード例 #7
0
        bool UnpackPacket(DataPacket packet)
        {
            // make sure we're on an audio packet
            if (packet.ReadBit())
            {
                // we really can't do anything... count the bits as waste
                return(false);
            }

            // get mode and prev/next flags
            var modeBits = _modeFieldBits;

            _mode = Modes[(int)packet.ReadBits(_modeFieldBits)];
            if (_mode.BlockFlag)
            {
                _prevFlag = packet.ReadBit();
                _nextFlag = packet.ReadBit();
                modeBits += 2;
            }
            else
            {
                _prevFlag = _nextFlag = false;
            }

            if (packet.IsShort)
            {
                return(false);
            }

            var startBits = packet.BitsRead;

            var halfBlockSize = _mode.BlockSize / 2;

            // read the noise floor data (but don't decode yet)
            for (int i = 0; i < _channels; i++)
            {
                _floorData[i]        = _mode.Mapping.ChannelSubmap[i].Floor.UnpackPacket(packet, _mode.BlockSize, i);
                _noExecuteChannel[i] = !_floorData[i].ExecuteChannel;

                // go ahead and clear the residue buffers
                Array.Clear(_residue[i], 0, halfBlockSize);
            }

            // make sure we handle no-energy channels correctly given the couplings...
            foreach (var step in _mode.Mapping.CouplingSteps)
            {
                if (_floorData[step.Angle].ExecuteChannel || _floorData[step.Magnitude].ExecuteChannel)
                {
                    _floorData[step.Angle].ForceEnergy     = true;
                    _floorData[step.Magnitude].ForceEnergy = true;
                }
            }

            var floorBits = packet.BitsRead - startBits;

            startBits = packet.BitsRead;

            foreach (var subMap in _mode.Mapping.Submaps)
            {
                for (int j = 0; j < _channels; j++)
                {
                    if (_mode.Mapping.ChannelSubmap[j] != subMap)
                    {
                        _floorData[j].ForceNoEnergy = true;
                    }
                }

                var rTemp = subMap.Residue.Decode(packet, _noExecuteChannel, _channels, _mode.BlockSize);
                for (int c = 0; c < _channels; c++)
                {
                    var r  = _residue[c];
                    var rt = rTemp[c];
                    for (int i = 0; i < halfBlockSize; i++)
                    {
                        r[i] += rt[i];
                    }
                }
            }

            _glueBits  += 1;
            _modeBits  += modeBits;
            _floorBits += floorBits;
            _resBits   += packet.BitsRead - startBits;
            _wasteBits += 8 * packet.Length - packet.BitsRead;

            _packetCount += 1;

            return(true);
        }
コード例 #8
0
        bool LoadBooks(DataPacket packet)
        {
            bool equal = true;

            byte[] sequence = new byte[] { 0x05, 0x76, 0x6f, 0x72, 0x62, 0x69, 0x73 };
            byte[] packets  = packet.ReadBytes(7);

            for (int i = 0; i < 7; i++)
            {
                if (packets[i] != sequence[i])
                {
                    equal = false;
                    break;
                }
            }

            if (!equal)
            {
                return(false);
            }

            if (!_pagesSeen.Contains((_lastPageSeen = packet.PageSequenceNumber)))
            {
                _pagesSeen.Add(_lastPageSeen);
            }

            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 InvalidDataException();
            }

            ++_glueBits;

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

            _modeFieldBits = Utils.ilog(Modes.Length - 1);

            return(true);
        }
コード例 #9
0
        void LoadBooks(DataPacket packet)
        {
            packet.SkipBits(8);
            if (!packet.ReadBytes(6).SequenceEqual(new byte[] { 0x76, 0x6f, 0x72, 0x62, 0x69, 0x73 }))
            {
                throw new InvalidDataException("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 InvalidDataException();
            }

            ++_glueBits;

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

            _modeFieldBits = Utils.ilog(Modes.Length - 1);
        }
コード例 #10
0
ファイル: VorbisStreamDecoder.cs プロジェクト: Daramkun/Misty
        bool UnpackPacket(DataPacket packet)
        {
            // make sure we're on an audio packet
            if (packet.ReadBit())
            {
                // we really can't do anything... count the bits as waste
                return false;
            }

            // get mode and prev/next flags
            var modeBits = _modeFieldBits;
            _mode = Modes[(int)packet.ReadBits(_modeFieldBits)];
            if (_mode.BlockFlag)
            {
                _prevFlag = packet.ReadBit();
                _nextFlag = packet.ReadBit();
                modeBits += 2;
            }
            else
            {
                _prevFlag = _nextFlag = false;
            }

            if (packet.IsShort) return false;

            var startBits = packet.BitsRead;

            var halfBlockSize = _mode.BlockSize / 2;

            // read the noise floor data (but don't decode yet)
            for (int i = 0; i < _channels; i++)
            {
                _floorData[i] = _mode.Mapping.ChannelSubmap[i].Floor.UnpackPacket(packet, _mode.BlockSize, i);
                _noExecuteChannel[i] = !_floorData[i].ExecuteChannel;

                // go ahead and clear the residue buffers
                Array.Clear(_residue[i], 0, halfBlockSize);
            }

            // make sure we handle no-energy channels correctly given the couplings...
            foreach (var step in _mode.Mapping.CouplingSteps)
            {
                if (_floorData[step.Angle].ExecuteChannel || _floorData[step.Magnitude].ExecuteChannel)
                {
                    _floorData[step.Angle].ForceEnergy = true;
                    _floorData[step.Magnitude].ForceEnergy = true;
                }
            }

            var floorBits = packet.BitsRead - startBits;
            startBits = packet.BitsRead;

            foreach (var subMap in _mode.Mapping.Submaps)
            {
                for (int j = 0; j < _channels; j++)
                {
                    if (_mode.Mapping.ChannelSubmap[j] != subMap)
                    {
                        _floorData[j].ForceNoEnergy = true;
                    }
                }

                var rTemp = subMap.Residue.Decode(packet, _noExecuteChannel, _channels, _mode.BlockSize);
                for (int c = 0; c < _channels; c++)
                {
                    var r = _residue[c];
                    var rt = rTemp[c];
                    for (int i = 0; i < halfBlockSize; i++)
                    {
                        r[i] += rt[i];
                    }
                }
            }

            _glueBits += 1;
            _modeBits += modeBits;
            _floorBits += floorBits;
            _resBits += packet.BitsRead - startBits;
            _wasteBits += 8 * packet.Length - packet.BitsRead;

            _packetCount += 1;

            return true;
        }
コード例 #11
0
        bool LoadBooks(DataPacket packet)
        {
            if (!CheckForHeader(packet, bookHeader))
            {
                return(false);
            }

            if (!_pagesSeen.Contains(_lastPageSeen = packet.PageSequenceNumber))
            {
                _pagesSeen.Add(_lastPageSeen);
            }

            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.Create(this, packet, i);
            }

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

            // get times
            Times = new VorbisTime[(int)packet.ReadUBits(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.ReadUBits(6) + 1];
            for (int i = 0; i < Floors.Length; i++)
            {
                Floors[i] = VorbisFloor.Create(this, packet);
            }

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

            // get residue
            Residues = new VorbisResidue[(int)packet.ReadUBits(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.ReadUBits(6) + 1];
            for (int i = 0; i < Maps.Length; i++)
            {
                Maps[i] = VorbisMapping.Create(this, packet);
            }

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

            // get mode settings
            Modes = new VorbisMode[(int)packet.ReadUBits(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 InvalidDataException();
            }

            ++_glueBits;

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

            _modeFieldBits = Utils.ILog(Modes.Length - 1);

            return(true);
        }
コード例 #12
0
        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);
        }
コード例 #13
0
        public bool UnpackPacket(DataPacket packet)
        {
            if (packet.ReadBit())
            {
                return(false);
            }
            int num = _modeFieldBits;

            _mode = Modes[(uint)packet.ReadBits(_modeFieldBits)];
            if (_mode.BlockFlag)
            {
                _prevFlag = packet.ReadBit();
                _nextFlag = packet.ReadBit();
                num      += 2;
            }
            else
            {
                _prevFlag = (_nextFlag = false);
            }
            if (packet.IsShort)
            {
                return(false);
            }
            long bitsRead = packet.BitsRead;
            int  num2     = _mode.BlockSize / 2;

            for (int i = 0; i < _channels; i++)
            {
                _floorData[i]        = _mode.Mapping.ChannelSubmap[i].Floor.UnpackPacket(packet, _mode.BlockSize, i);
                _noExecuteChannel[i] = !_floorData[i].ExecuteChannel;
                Array.Clear(_residue[i], 0, num2);
            }
            VorbisMapping.CouplingStep[] couplingSteps = _mode.Mapping.CouplingSteps;
            foreach (VorbisMapping.CouplingStep couplingStep in couplingSteps)
            {
                if (_floorData[couplingStep.Angle].ExecuteChannel || _floorData[couplingStep.Magnitude].ExecuteChannel)
                {
                    _floorData[couplingStep.Angle].ForceEnergy     = true;
                    _floorData[couplingStep.Magnitude].ForceEnergy = true;
                }
            }
            long num3 = packet.BitsRead - bitsRead;

            bitsRead = packet.BitsRead;
            VorbisMapping.Submap[] submaps = _mode.Mapping.Submaps;
            foreach (VorbisMapping.Submap submap in submaps)
            {
                for (int k = 0; k < _channels; k++)
                {
                    if (_mode.Mapping.ChannelSubmap[k] != submap)
                    {
                        _floorData[k].ForceNoEnergy = true;
                    }
                }
                float[][] array = submap.Residue.Decode(packet, _noExecuteChannel, _channels, _mode.BlockSize);
                for (int l = 0; l < _channels; l++)
                {
                    float[] array2 = _residue[l];
                    float[] array3 = array[l];
                    for (int m = 0; m < num2; m++)
                    {
                        array2[m] += array3[m];
                    }
                }
            }
            _glueBits++;
            _modeBits  += num;
            _floorBits += num3;
            _resBits   += packet.BitsRead - bitsRead;
            _wasteBits += 8 * packet.Length - packet.BitsRead;
            _packetCount++;
            return(true);
        }
コード例 #14
0
        public bool LoadBooks(DataPacket packet)
        {
            if (!packet.ReadBytes(7).SequenceEqual(new byte[7]
            {
                5,
                118,
                111,
                114,
                98,
                105,
                115
            }))
            {
                return(false);
            }
            if (!_pagesSeen.Contains(_lastPageSeen = packet.PageSequenceNumber))
            {
                _pagesSeen.Add(_lastPageSeen);
            }
            long bitsRead = packet.BitsRead;

            _glueBits += packet.BitsRead;
            Books      = new VorbisCodebook[packet.ReadByte() + 1];
            for (int i = 0; i < Books.Length; i++)
            {
                Books[i] = VorbisCodebook.Init(this, packet, i);
            }
            _bookBits += packet.BitsRead - bitsRead;
            bitsRead   = packet.BitsRead;
            Times      = new VorbisTime[(int)packet.ReadBits(6) + 1];
            for (int j = 0; j < Times.Length; j++)
            {
                Times[j] = VorbisTime.Init(this, packet);
            }
            _timeHdrBits += packet.BitsRead - bitsRead;
            bitsRead      = packet.BitsRead;
            Floors        = new VorbisFloor[(int)packet.ReadBits(6) + 1];
            for (int k = 0; k < Floors.Length; k++)
            {
                Floors[k] = VorbisFloor.Init(this, packet);
            }
            _floorHdrBits += packet.BitsRead - bitsRead;
            bitsRead       = packet.BitsRead;
            Residues       = new VorbisResidue[(int)packet.ReadBits(6) + 1];
            for (int l = 0; l < Residues.Length; l++)
            {
                Residues[l] = VorbisResidue.Init(this, packet);
            }
            _resHdrBits += packet.BitsRead - bitsRead;
            bitsRead     = packet.BitsRead;
            Maps         = new VorbisMapping[(int)packet.ReadBits(6) + 1];
            for (int m = 0; m < Maps.Length; m++)
            {
                Maps[m] = VorbisMapping.Init(this, packet);
            }
            _mapHdrBits += packet.BitsRead - bitsRead;
            bitsRead     = packet.BitsRead;
            Modes        = new VorbisMode[(int)packet.ReadBits(6) + 1];
            for (int n = 0; n < Modes.Length; n++)
            {
                Modes[n] = VorbisMode.Init(this, packet);
            }
            _modeHdrBits += packet.BitsRead - bitsRead;
            if (!packet.ReadBit())
            {
                throw new InvalidDataException();
            }
            _glueBits++;
            _wasteHdrBits += 8 * packet.Length - packet.BitsRead;
            _modeFieldBits = Utils.ilog(Modes.Length - 1);
            return(true);
        }