XnUInt32 Link12BitS2DParser::ProcessFramePacketChunk(const XnUInt8* pData,XnUInt8* pDest, XnUInt32 nDataSize) { XnStatus nRetVal = XN_STATUS_OK; XnUInt32 totalRead = 0; XnUInt32 totalWrite = 0; // check if we have data from previous packet if (m_ContinuousBufferSize!= 0) { // fill in to a whole element XnUInt32 nReadBytes = XN_MIN(nDataSize, XN_INPUT_ELEMENT_SIZE - m_ContinuousBufferSize); xnOSMemCopy(m_ContinuousBuffer + m_ContinuousBufferSize, pData, nReadBytes); m_ContinuousBufferSize += nReadBytes; pData += nReadBytes; nDataSize -= nReadBytes; if (m_ContinuousBufferSize == XN_INPUT_ELEMENT_SIZE) { // process it XnUInt32 nActualRead = 0; XnUInt32 nActualWritten = 0; Unpack12to16(m_ContinuousBuffer,pDest, XN_INPUT_ELEMENT_SIZE, &nActualRead, &nActualWritten); pDest += nActualWritten; totalRead += nActualRead; totalWrite += nActualWritten; m_ContinuousBufferSize = 0; } } // find out the number of input elements we have XnUInt32 nActualRead = 0; XnUInt32 nActualWritten = 0; nRetVal = Unpack12to16(pData, pDest, nDataSize, &nActualRead, &nActualWritten); totalRead += nActualRead; totalWrite += nActualWritten; if (nRetVal == XN_STATUS_OK) { pData += nActualRead; nDataSize -= nActualRead; // if we have any bytes left, store them for next packet. if (nDataSize > 0) { // no need to check for overflow. there can not be a case in which more than XN_INPUT_ELEMENT_SIZE // are left. xnOSMemCopy(m_ContinuousBuffer + m_ContinuousBufferSize, pData, nDataSize); m_ContinuousBufferSize += nDataSize; } } return totalWrite; //return total written bytes }
void XnPacked12DepthProcessor::ProcessFramePacketChunk(const XnSensorProtocolResponseHeader* /*pHeader*/, const XnUChar* pData, XnUInt32 /*nDataOffset*/, XnUInt32 nDataSize) { XN_PROFILING_START_SECTION("XnPacked12DepthProcessor::ProcessFramePacketChunk") XnStatus nRetVal = XN_STATUS_OK; // check if we have data from previous packet if (m_ContinuousBuffer.GetSize() != 0) { // fill in to a whole element XnUInt32 nReadBytes = XN_MIN(nDataSize, XN_INPUT_ELEMENT_SIZE - m_ContinuousBuffer.GetSize()); m_ContinuousBuffer.UnsafeWrite(pData, nReadBytes); pData += nReadBytes; nDataSize -= nReadBytes; if (m_ContinuousBuffer.GetSize() == XN_INPUT_ELEMENT_SIZE) { // process it XnUInt32 nActualRead = 0; Unpack12to16(m_ContinuousBuffer.GetData(), XN_INPUT_ELEMENT_SIZE, &nActualRead); m_ContinuousBuffer.Reset(); } } // find out the number of input elements we have XnUInt32 nActualRead = 0; nRetVal = Unpack12to16(pData, nDataSize, &nActualRead); if (nRetVal == XN_STATUS_OK) { pData += nActualRead; nDataSize -= nActualRead; // if we have any bytes left, store them for next packet. if (nDataSize > 0) { // no need to check for overflow. there can not be a case in which more than XN_INPUT_ELEMENT_SIZE // are left. m_ContinuousBuffer.UnsafeWrite(pData, nDataSize); } } XN_PROFILING_END_SECTION }