public byte[] GetUncompressedFrame() { byte[] result = null; // Get the new frame if (decodedFrame == null) { decodedFrame = new byte[m_width * m_height * 4]; } int width; int height; int format; UInt64 timeStamp; IntPtr frame; int numBytes; CudaTools.VideoDecoder_GetNextDecodedFrame64(m_videoDecoder, out frame, out numBytes, out width, out height, out format, out timeStamp); // Why the double copy? Marshal.Copy(frame, decodedFrame, 0, (int)numBytes); CudaTools.VideoDecoder_ReleaseFrame(m_videoDecoder); result = new byte[decodedFrame.Length]; Buffer.BlockCopy(decodedFrame, 0, result, 0, decodedFrame.Length); return(result); }