Various MP4 lib optimizations.
This commit is contained in:
parent
6d67bcdd67
commit
69bfb3a0be
2 changed files with 11 additions and 11 deletions
|
@ -479,8 +479,7 @@ namespace MP4 {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
newData = htonl(newData);
|
((int *)(data + index))[0] = htonl(newData);
|
||||||
memcpy(data + index, (char *) &newData, 4);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Gets the 32 bits integer at the given index.
|
/// Gets the 32 bits integer at the given index.
|
||||||
|
@ -494,9 +493,7 @@ namespace MP4 {
|
||||||
}
|
}
|
||||||
setInt32(0, index - payloadOffset);
|
setInt32(0, index - payloadOffset);
|
||||||
}
|
}
|
||||||
uint32_t result;
|
return ntohl(((int *)(data + index))[0]);
|
||||||
memcpy((char *) &result, data + index, 4);
|
|
||||||
return ntohl(result);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Sets the 64 bits integer at the given index.
|
/// Sets the 64 bits integer at the given index.
|
||||||
|
|
|
@ -2251,13 +2251,16 @@ namespace MP4 {
|
||||||
}
|
}
|
||||||
|
|
||||||
void STCO::setChunkOffset(uint32_t newChunkOffset, uint32_t no) {
|
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);
|
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) {
|
uint32_t STCO::getChunkOffset(uint32_t no) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue