Stability fixes for MP4 lib, fixed MP4 unit test.
This commit is contained in:
parent
d7c2d268e1
commit
7d13a18c47
2 changed files with 11 additions and 2 deletions
11
lib/mp4.cpp
11
lib/mp4.cpp
|
@ -342,6 +342,9 @@ namespace MP4{
|
||||||
/// \returns True on success, false otherwise.
|
/// \returns True on success, false otherwise.
|
||||||
bool Box::reserve(size_t position, size_t current, size_t wanted){
|
bool Box::reserve(size_t position, size_t current, size_t wanted){
|
||||||
if (current == wanted){return true;}
|
if (current == wanted){return true;}
|
||||||
|
if (position > boxedSize()){
|
||||||
|
wanted += position - boxedSize();
|
||||||
|
}
|
||||||
if (current < wanted){
|
if (current < wanted){
|
||||||
//make bigger
|
//make bigger
|
||||||
if (boxedSize() + (wanted-current) > data_size){
|
if (boxedSize() + (wanted-current) > data_size){
|
||||||
|
@ -350,6 +353,7 @@ namespace MP4{
|
||||||
void * ret = realloc(data, boxedSize() + (wanted-current));
|
void * ret = realloc(data, boxedSize() + (wanted-current));
|
||||||
if (!ret){return false;}
|
if (!ret){return false;}
|
||||||
data = (char*)ret;
|
data = (char*)ret;
|
||||||
|
memset(data+boxedSize(), 0, wanted-current);//initialize to 0
|
||||||
data_size = boxedSize() + (wanted-current);
|
data_size = boxedSize() + (wanted-current);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -757,6 +761,11 @@ namespace MP4{
|
||||||
int countLoc = tempLoc;
|
int countLoc = tempLoc;
|
||||||
tempLoc += 4;
|
tempLoc += 4;
|
||||||
for (int i = 0; i < no; i++){
|
for (int i = 0; i < no; i++){
|
||||||
|
if (i+1 > getInt32(countLoc)){
|
||||||
|
setInt32(0,tempLoc);
|
||||||
|
setInt64(0,tempLoc+4);
|
||||||
|
setInt32(1,tempLoc+12);
|
||||||
|
}
|
||||||
if (getInt32(tempLoc+12) == 0){tempLoc += 17;}else{tempLoc += 16;}
|
if (getInt32(tempLoc+12) == 0){tempLoc += 17;}else{tempLoc += 16;}
|
||||||
}
|
}
|
||||||
setInt32(newRun.firstFragment,tempLoc);
|
setInt32(newRun.firstFragment,tempLoc);
|
||||||
|
@ -878,7 +887,7 @@ namespace MP4{
|
||||||
for (int i = 0; i < getQualityEntryCount(); i++){tempLoc += getStringLen(tempLoc)+1;}
|
for (int i = 0; i < getQualityEntryCount(); i++){tempLoc += getStringLen(tempLoc)+1;}
|
||||||
int countLoc = tempLoc;
|
int countLoc = tempLoc;
|
||||||
tempLoc += 4 + no*8;
|
tempLoc += 4 + no*8;
|
||||||
if (no+1 < getSegmentRunEntryCount()){
|
if (no+1 > getInt32(countLoc)){
|
||||||
setInt32(no+1, countLoc);//set new qualityEntryCount
|
setInt32(no+1, countLoc);//set new qualityEntryCount
|
||||||
}
|
}
|
||||||
setInt32(firstSegment,tempLoc);
|
setInt32(firstSegment,tempLoc);
|
||||||
|
|
|
@ -331,5 +331,5 @@ int main(int argc, char ** argv) {
|
||||||
abst.setFragmentRunTable(afrt, 0);
|
abst.setFragmentRunTable(afrt, 0);
|
||||||
|
|
||||||
if (abst.boxedSize() != __data_len){return 42;}
|
if (abst.boxedSize() != __data_len){return 42;}
|
||||||
return memcmp(abst.asBox(), __data, __data_len) << std::endl;
|
return memcmp(abst.asBox(), __data, __data_len);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue