Various MP4 lib optimizations.

This commit is contained in:
Thulinma 2014-12-13 16:54:40 +01:00
parent 6d67bcdd67
commit 69bfb3a0be
2 changed files with 11 additions and 11 deletions

View file

@ -479,8 +479,7 @@ namespace MP4 {
return;
}
}
newData = htonl(newData);
memcpy(data + index, (char *) &newData, 4);
((int *)(data + index))[0] = htonl(newData);
}
/// Gets the 32 bits integer at the given index.
@ -494,9 +493,7 @@ namespace MP4 {
}
setInt32(0, index - payloadOffset);
}
uint32_t result;
memcpy((char *) &result, data + index, 4);
return ntohl(result);
return ntohl(((int *)(data + index))[0]);
}
/// Sets the 64 bits integer at the given index.

View file

@ -2251,13 +2251,16 @@ namespace MP4 {
}
void STCO::setChunkOffset(uint32_t newChunkOffset, uint32_t no) {
if (no + 1 > getEntryCount()) {
for (unsigned int i = getEntryCount(); i < no; i++) {
setInt32(0, 8 + i * 4);//filling undefined entries
}
setEntryCount(no + 1);
}
setInt32(newChunkOffset, 8 + no * 4);
uint32_t entryCount = getEntryCount();
//if entrycount is lower than new entry count, update it and fill any skipped entries with zeroes.
if (no + 1 > entryCount) {
setEntryCount(no + 1);
//fill undefined entries, if any (there's only undefined entries if we skipped an entry)
if (no > entryCount){
memset(data+payloadOffset+8+entryCount*4, 0, 4*(no-entryCount));
}
}
}
uint32_t STCO::getChunkOffset(uint32_t no) {