Пример #1
0
        public void DecodePacket()
        {
            VorbisMapping.CouplingStep[] couplingSteps = _mode.Mapping.CouplingSteps;
            int num = _mode.BlockSize / 2;

            for (int num2 = couplingSteps.Length - 1; num2 >= 0; num2--)
            {
                if (_floorData[couplingSteps[num2].Angle].ExecuteChannel || _floorData[couplingSteps[num2].Magnitude].ExecuteChannel)
                {
                    float[] array  = _residue[couplingSteps[num2].Magnitude];
                    float[] array2 = _residue[couplingSteps[num2].Angle];
                    for (int i = 0; i < num; i++)
                    {
                        float num3;
                        float num4;
                        if (array[i] > 0f)
                        {
                            if (array2[i] > 0f)
                            {
                                num3 = array[i];
                                num4 = array[i] - array2[i];
                            }
                            else
                            {
                                num4 = array[i];
                                num3 = array[i] + array2[i];
                            }
                        }
                        else if (array2[i] > 0f)
                        {
                            num3 = array[i];
                            num4 = array[i] + array2[i];
                        }
                        else
                        {
                            num4 = array[i];
                            num3 = array[i] - array2[i];
                        }
                        array[i]  = num3;
                        array2[i] = num4;
                    }
                }
            }
            for (int j = 0; j < _channels; j++)
            {
                VorbisFloor.PacketData packetData = _floorData[j];
                float[] array3 = _residue[j];
                if (packetData.ExecuteChannel)
                {
                    _mode.Mapping.ChannelSubmap[j].Floor.Apply(packetData, array3);
                    Mdct.Reverse(array3, _mode.BlockSize);
                }
                else
                {
                    Array.Clear(array3, num, num);
                }
            }
        }
Пример #2
0
 static Mdct GetSetup(int n)
 {
     lock (_setupCache)
     {
         if (!_setupCache.TryGetValue(n, out var value))
         {
             _setupCache[n] = value = new Mdct(n);
         }
         return(value);
     }
 }
Пример #3
0
 public static Mdct GetSetup(int n)
 {
     lock (_setupCache)
     {
         if (!_setupCache.ContainsKey(n))
         {
             _setupCache[n] = new Mdct(n);
         }
         return(_setupCache[n]);
     }
 }
Пример #4
0
        static Mdct GetSetup(int n)
        {
            lock (_setupCache)
            {
                if (!_setupCache.ContainsKey(n))
                {
                    _setupCache[n] = new Mdct(n);
                }

                return _setupCache[n];
            }
        }
Пример #5
0
        private int DecodePacket(VorbisStreamDecoder.PacketDecodeInfo pdi)
        {
            VorbisMapping.CouplingStep[] couplingStepArray = pdi.Mode.Mapping.CouplingSteps;
            int num1 = pdi.Mode.BlockSize / 2;

            for (int index1 = couplingStepArray.Length - 1; index1 >= 0; --index1)
            {
                float[] numArray1 = pdi.Residue[couplingStepArray[index1].Magnitude];
                float[] numArray2 = pdi.Residue[couplingStepArray[index1].Angle];
                for (int index2 = 0; index2 < num1; ++index2)
                {
                    float num2;
                    float num3;
                    if ((double)numArray1[index2] > 0.0)
                    {
                        if ((double)numArray2[index2] > 0.0)
                        {
                            num2 = numArray1[index2];
                            num3 = numArray1[index2] - numArray2[index2];
                        }
                        else
                        {
                            num3 = numArray1[index2];
                            num2 = numArray1[index2] + numArray2[index2];
                        }
                    }
                    else if ((double)numArray2[index2] > 0.0)
                    {
                        num2 = numArray1[index2];
                        num3 = numArray1[index2] + numArray2[index2];
                    }
                    else
                    {
                        num3 = numArray1[index2];
                        num2 = numArray1[index2] - numArray2[index2];
                    }
                    numArray1[index2] = num2;
                    numArray2[index2] = num3;
                }
            }
            for (int index = 0; index < this._channels; ++index)
            {
                VorbisFloor.PacketData packetData = pdi.FloorData[index];
                float[] numArray = pdi.Residue[index];
                if (packetData.ExecuteChannel)
                {
                    pdi.Mode.Mapping.ChannelSubmap[index].Floor.Apply(packetData, numArray);
                    Mdct.Reverse(numArray);
                }
            }
            return(this.WindowSamples(pdi));
        }
Пример #6
0
        void DecodePacket()
        {
            // inverse coupling
            var steps     = _mode.Mapping.CouplingSteps;
            var halfSizeW = _mode.BlockSize / 2;

            for (int i = steps.Length - 1; i >= 0; i--)
            {
                if (_floorData[steps[i].Angle].ExecuteChannel || _floorData[steps[i].Magnitude].ExecuteChannel)
                {
                    var magnitude = _residue[steps[i].Magnitude];
                    var angle     = _residue[steps[i].Angle];

                    // we only have to do the first half; MDCT ignores the last half
                    for (int j = 0; j < halfSizeW; j++)
                    {
                        float newM, newA;

                        if (magnitude[j] > 0)
                        {
                            if (angle[j] > 0)
                            {
                                newM = magnitude[j];
                                newA = magnitude[j] - angle[j];
                            }
                            else
                            {
                                newA = magnitude[j];
                                newM = magnitude[j] + angle[j];
                            }
                        }
                        else
                        {
                            if (angle[j] > 0)
                            {
                                newM = magnitude[j];
                                newA = magnitude[j] + angle[j];
                            }
                            else
                            {
                                newA = magnitude[j];
                                newM = magnitude[j] - angle[j];
                            }
                        }

                        magnitude[j] = newM;
                        angle[j]     = newA;
                    }
                }
            }

            // apply floor / dot product / MDCT (only run if we have sound energy in that channel)
            for (int c = 0; c < _channels; c++)
            {
                var floorData = _floorData[c];
                var res       = _residue[c];
                if (floorData.ExecuteChannel)
                {
                    _mode.Mapping.ChannelSubmap[c].Floor.Apply(floorData, res);
                    Mdct.Reverse(res, _mode.BlockSize);
                }
                else
                {
                    // since we aren't doing the IMDCT, we have to explicitly clear the back half of the block
                    Array.Clear(res, halfSizeW, halfSizeW);
                }
            }
        }
Пример #7
0
 public static float[] Reverse(float[] samples)
 {
     Mdct.GetSetup(samples.Length).CalcReverse(samples);
     return(samples);
 }