Saturday, 14 September 2013

C++: Reading data from a memory mapped file

C++: Reading data from a memory mapped file

I have used MapVirtualFile to map a file under Window using C++ VS2010.
I would now like to fill a structure with the data.
I have been using
void clsMapping::FeedPitchmarksFromMap(udtPitchmarks &uAudioInfo,unsigned
long int uByteStart)
{
unsigned long int iCountPM;
memcpy(&iCountPM, &((char*)(m_pVoiceData))[uBytePos],sizeof(int));
uAudioInfo.Pitchmarks.resize(iCountPM);
for (unsigned long int i=0;i<iCountPM;i++)
{
iBytePos+=sizeof(int);
unsigned long int iByteStart;
memcpy(&iByteStart, &((char*)(m_pVoiceData))[iBytePos],4);
iBytePos+=sizeof(int);
unsigned long int iByteCount;
memcpy(&iByteCount, &((char*)(m_pVoiceData))[iBytePos],4);
iBytePos+=sizeof(int);
unsigned int iF0;
memcpy(&iF0, &((char*)(m_pVoiceData))[iBytePos],4);
uAudioInfo.Pitchmarks[i].ByteStart =iByteStart;
uAudioInfo.Pitchmarks[i].ByteCount =iByteCount;
uAudioInfo.Pitchmarks[i].F0 =iF0;
}
}
As one can see, I am currently using memcpy to get the data. Is there a
faster way to do "get my data over"?

No comments:

Post a Comment