MP4 header read optimise by Erik

This reverts commit b244618737.
This commit is contained in:
Erik Zandvliet 2016-04-12 15:07:17 +02:00
parent 90419e15eb
commit 3b9911df71

View file

@ -280,7 +280,6 @@ namespace Mist {
return true; return true;
} }
trackNo = 0; trackNo = 0;
std::set<mp4PartBpos> BPosSet;
//Create header file from MP4 data //Create header file from MP4 data
while(!feof(inFile)){ while(!feof(inFile)){
std::string boxType = MP4::readBoxType(inFile); std::string boxType = MP4::readBoxType(inFile);
@ -523,11 +522,7 @@ namespace Mist {
}else{ }else{
BsetPart.timeOffset = 0; BsetPart.timeOffset = 0;
} }
//set size, that's easy myMeta.update(BsetPart.time, BsetPart.timeOffset, trackNo, stszBox.getEntrySize(sampleIndex), BsetPart.bpos, BsetPart.keyframe);
BsetPart.size = stszBox.getEntrySize(sampleIndex);
//trackid
BsetPart.trackID=trackNo;
BPosSet.insert(BsetPart);
}//while over stsc }//while over stsc
if (vidTrack){ if (vidTrack){
//something wrong with the time formula, but the answer is right for some reason //something wrong with the time formula, but the answer is right for some reason
@ -559,25 +554,6 @@ namespace Mist {
//for all in bpos set, find its data //for all in bpos set, find its data
clearerr(inFile); clearerr(inFile);
for (std::set<mp4PartBpos>::iterator it = BPosSet.begin(); it != BPosSet.end(); it++){
if (!fseeko(inFile,it->bpos,SEEK_SET)){
if (it->size > malSize){
data = (char*)realloc(data, it->size);
malSize = it->size;
}
int tmp = fread(data, it->size, 1, inFile);
if (tmp == 1){
//add data
myMeta.update(it->time, it->timeOffset, it->trackID, it->size, it->bpos, it->keyframe);
}else{
INFO_MSG("fread did not return 1, bpos: %llu size: %llu keyframe: %d error: %s", it->bpos, it->size, it->keyframe, strerror(errno));
return false;
}
}else{
INFO_MSG("fseek failed!");
return false;
}
}//rof bpos set
//outputting dtsh file //outputting dtsh file
std::ofstream oFile(std::string(config->getString("input") + ".dtsh").c_str()); std::ofstream oFile(std::string(config->getString("input") + ".dtsh").c_str());
oFile << myMeta.toJSON().toNetPacked(); oFile << myMeta.toJSON().toNetPacked();