269 |
* steps. |
* steps. |
270 |
* |
* |
271 |
* Once the whole data was processed by __calculateCRC(), one should |
* Once the whole data was processed by __calculateCRC(), one should |
272 |
* call __encodeCRC() to get the final CRC result. |
* call __finalizeCRC() to get the final CRC result. |
273 |
* |
* |
274 |
* @param buf - pointer to data the CRC shall be calculated of |
* @param buf - pointer to data the CRC shall be calculated of |
275 |
* @param bufSize - size of the data to be processed |
* @param bufSize - size of the data to be processed |
286 |
* |
* |
287 |
* @param crc - variable previously passed to __calculateCRC() |
* @param crc - variable previously passed to __calculateCRC() |
288 |
*/ |
*/ |
289 |
inline static uint32_t __encodeCRC(const uint32_t& crc) { |
inline static void __finalizeCRC(uint32_t& crc) { |
290 |
return crc ^ 0xffffffff; |
crc ^= 0xffffffff; |
291 |
} |
} |
292 |
|
|
293 |
|
|
1294 |
// if this is the last write, update the checksum chunk in the |
// if this is the last write, update the checksum chunk in the |
1295 |
// file |
// file |
1296 |
if (pCkData->GetPos() == pCkData->GetSize()) { |
if (pCkData->GetPos() == pCkData->GetSize()) { |
1297 |
|
__finalizeCRC(crc); |
1298 |
File* pFile = static_cast<File*>(GetParent()); |
File* pFile = static_cast<File*>(GetParent()); |
1299 |
pFile->SetSampleChecksum(this, __encodeCRC(crc)); |
pFile->SetSampleChecksum(this, crc); |
1300 |
} |
} |
1301 |
return res; |
return res; |
1302 |
} |
} |
1417 |
if (nRead <= 0) break; |
if (nRead <= 0) break; |
1418 |
__calculateCRC(&buffer[0], nRead * FrameSize, crc); |
__calculateCRC(&buffer[0], nRead * FrameSize, crc); |
1419 |
} |
} |
1420 |
__encodeCRC(crc); |
__finalizeCRC(crc); |
1421 |
return crc; |
return crc; |
1422 |
} |
} |
1423 |
|
|
4247 |
// recalculate CRC32 check sum |
// recalculate CRC32 check sum |
4248 |
__resetCRC(crc); |
__resetCRC(crc); |
4249 |
__calculateCRC(&data[0], data.size(), crc); |
__calculateCRC(&data[0], data.size(), crc); |
4250 |
__encodeCRC(crc); |
__finalizeCRC(crc); |
4251 |
// make sure chunk exists and has the required size |
// make sure chunk exists and has the required size |
4252 |
const file_offset_t chunkSize = (file_offset_t) 7*sizeof(int32_t) + Name.size() + data.size(); |
const file_offset_t chunkSize = (file_offset_t) 7*sizeof(int32_t) + Name.size() + data.size(); |
4253 |
if (!pChunk) pChunk = pGroup->pList->AddSubChunk(CHUNK_ID_SCRI, chunkSize); |
if (!pChunk) pChunk = pGroup->pList->AddSubChunk(CHUNK_ID_SCRI, chunkSize); |