Ejemplo n.º 1
0
        public byte[] Encode(short[] depthBuffer, bool keyFrame)
        {
            int frameSize = _pixels.Length;

            byte[] encodedFrame     = new byte[frameSize];
            int    encodedDataBytes = 0;

            if (keyFrame)
            {
                for (int i = 0; i < _pixels.Length; i++)
                {
                    _pixels[i].value        = depthBuffer[i];
                    _pixels[i].invalidCound = (short)((depthBuffer[i] == 0) ? 1 : 0);
                }

                encodedDataBytes = RVL.CompressRVL(depthBuffer, encodedFrame);
                Array.Resize(ref encodedFrame, encodedDataBytes);
                return(encodedFrame);
            }

            short[] pixelDiffs = new short[frameSize];
            for (int i = 0; i < pixelDiffs.Length; i++)
            {
                pixelDiffs[i] = _pixels[i].value;
                UpdatePixel(ref _pixels[i], depthBuffer[i], _changeThreshold, _invalidThreshold);
                pixelDiffs[i] = (short)(_pixels[i].value - pixelDiffs[i]);
            }

            encodedDataBytes = RVL.CompressRVL(pixelDiffs, encodedFrame);
            Array.Resize(ref encodedFrame, encodedDataBytes);
            return(encodedFrame);
        }
Ejemplo n.º 2
0
        public short[] Decode(byte[] trvlEncodedFrame, bool keyFrame)
        {
            int frameSize = _previousPixelValues.Length;

            if (keyFrame)
            {
                RVL.DecompressRVL(trvlEncodedFrame, _previousPixelValues);
                return(_previousPixelValues);
            }

            RVL.DecompressRVL(trvlEncodedFrame, _pixelDiffs);
            for (int i = 0; i < frameSize; i++)
            {
                _previousPixelValues[i] += _pixelDiffs[i];
            }

            return(_previousPixelValues);
        }