CreateDecodeMatrix() публичный Метод

public CreateDecodeMatrix ( byte encMatrix, int index, int k, int n ) : byte[]
encMatrix byte
index int
k int
n int
Результат byte[]
Пример #1
0
        private void Decode(byte[][] pkts, int[] pktsOff, int[] index, int packetLength)
        {
            byte[] decMatrix = _fecMath.CreateDecodeMatrix(_encMatrix, index, _k, _n);

            // do the actual decoding..
            byte[][] tmpPkts = new byte[_k][];

            Parallel.For(0, _k, new ParallelOptions()
            {
                MaxDegreeOfParallelism = _threadCount
            }, row =>
            {
                if (_cancel)
                {
                    return;
                }

                Thread.CurrentThread.IsBackground = true;
                Thread.CurrentThread.Priority     = ThreadPriority.Lowest;

                if (index[row] >= _k)
                {
                    tmpPkts[row] = _bufferManager.TakeBuffer(packetLength);
                    Unsafe.Zero(tmpPkts[row], 0, packetLength);

                    for (int col = 0; col < _k; col++)
                    {
                        if (_cancel)
                        {
                            return;
                        }

                        _fecMath.AddMul(tmpPkts[row], 0, pkts[col], pktsOff[col], decMatrix[row * _k + col], packetLength);
                    }
                }
            });

            if (_cancel)
            {
                return;
            }

            // move pkts to their final destination
            for (int row = 0; row < _k; row++)
            {
                if (index[row] >= _k)
                {
                    // only copy those actually decoded.
                    Unsafe.Copy(tmpPkts[row], 0, pkts[row], pktsOff[row], packetLength);
                    index[row] = row;
                    _bufferManager.ReturnBuffer(tmpPkts[row]);
                }
            }
        }