Fix for handling negative h264 offsets in mp4
This commit is contained in:
parent
3b9911df71
commit
4c2eeb96c8
5 changed files with 14 additions and 12 deletions
|
@ -2575,7 +2575,8 @@ namespace MP4 {
|
|||
setEntryCount(no + 1);
|
||||
}
|
||||
setInt32(newCTTSEntry.sampleCount, 8 + no * 8);
|
||||
setInt32(newCTTSEntry.sampleOffset, 8 + (no * 8) + 4);
|
||||
setInt32(*(reinterpret_cast<uint32_t*>(&newCTTSEntry.sampleOffset)), 8 + (no * 8) + 4);
|
||||
|
||||
}
|
||||
|
||||
CTTSEntry CTTS::getCTTSEntry(uint32_t no) {
|
||||
|
@ -2585,7 +2586,8 @@ namespace MP4 {
|
|||
return inval;
|
||||
}
|
||||
retval.sampleCount = getInt32(8 + (no * 8));
|
||||
retval.sampleOffset = getInt32(8 + (no * 8) + 4);
|
||||
uint32_t tmp = getInt32(8 + (no * 8) + 4);
|
||||
retval.sampleOffset = *(reinterpret_cast<int32_t*>(&tmp));
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
|
|
@ -538,7 +538,7 @@ namespace MP4 {
|
|||
|
||||
struct CTTSEntry {
|
||||
uint32_t sampleCount;
|
||||
uint32_t sampleOffset;
|
||||
int32_t sampleOffset;
|
||||
};
|
||||
|
||||
class CTTS: public fullBox {
|
||||
|
|
|
@ -100,7 +100,7 @@ namespace Mist {
|
|||
}//rof trak
|
||||
}
|
||||
|
||||
void mp4TrackHeader::getPart(long unsigned int index, long long unsigned int & offset,unsigned int& size, long long unsigned int & timestamp, long long unsigned int & timeOffset){
|
||||
void mp4TrackHeader::getPart(long unsigned int index, long long unsigned int & offset,unsigned int& size, long long unsigned int & timestamp, int32_t & timeOffset){
|
||||
|
||||
|
||||
if (index < sampleIndex){
|
||||
|
@ -171,7 +171,7 @@ namespace Mist {
|
|||
while (offsetIndex < cttsBox.getEntryCount()){
|
||||
tmpCTTS = cttsBox.getCTTSEntry(offsetIndex);
|
||||
if ((index - offsetPos) < tmpCTTS.sampleCount){
|
||||
timeOffset = (tmpCTTS.sampleOffset*1000)/timeScale;
|
||||
timeOffset = (tmpCTTS.sampleOffset*1000)/(int32_t)timeScale;
|
||||
break;
|
||||
}
|
||||
offsetPos += tmpCTTS.sampleCount;
|
||||
|
@ -518,7 +518,7 @@ namespace Mist {
|
|||
cttsIndex++;
|
||||
cttsEntryRead = 0;
|
||||
}
|
||||
BsetPart.timeOffset = (cttsEntry.sampleOffset * 1000)/timeScale;
|
||||
BsetPart.timeOffset = (cttsEntry.sampleOffset * 1000)/(int32_t)timeScale;
|
||||
}else{
|
||||
BsetPart.timeOffset = 0;
|
||||
}
|
||||
|
@ -529,9 +529,9 @@ namespace Mist {
|
|||
/// \todo Fix this. This makes no sense whatsoever. This isn't frame per kilosecond, but milli-STCO-entries per second.
|
||||
// (A single STCO entry may be more than 1 part, and 1 part may be a partial frame or multiple frames)
|
||||
if (stcoIs64){
|
||||
myMeta.tracks[trackNo].fpks = (((double)(((MP4::CO64*)&stcoBox)->getEntryCount()*1000))/((totaldur*1000)/timeScale))*1000;
|
||||
myMeta.tracks[trackNo].fpks = (((double)(((MP4::CO64*)&stcoBox)->getEntryCount()*1000))/((totaldur*1000)))*1000;
|
||||
}else{
|
||||
myMeta.tracks[trackNo].fpks = (((double)(stcoBox.getEntryCount()*1000))/((totaldur*1000)/timeScale))*1000;
|
||||
myMeta.tracks[trackNo].fpks = (((double)(stcoBox.getEntryCount()*1000))/((totaldur*1000)))*1000;
|
||||
}
|
||||
}
|
||||
}//fi stbl
|
||||
|
|
|
@ -23,7 +23,7 @@ namespace Mist {
|
|||
return false;
|
||||
}
|
||||
long long unsigned int time;
|
||||
long long unsigned int offset;
|
||||
int32_t offset;
|
||||
unsigned int trackID;
|
||||
long long unsigned int bpos;
|
||||
unsigned int size;
|
||||
|
@ -52,7 +52,7 @@ namespace Mist {
|
|||
long long unsigned int bpos;
|
||||
long long unsigned int size;
|
||||
long long unsigned int stcoNr;
|
||||
long unsigned int timeOffset;
|
||||
int32_t timeOffset;
|
||||
bool keyframe;
|
||||
};
|
||||
|
||||
|
@ -67,7 +67,7 @@ namespace Mist {
|
|||
MP4::CTTS cttsBox;
|
||||
MP4::STSC stscBox;
|
||||
long unsigned int timeScale;
|
||||
void getPart(long unsigned int index, long long unsigned int & offset,unsigned int& size, long long unsigned int & timestamp, long long unsigned int & timeOffset);
|
||||
void getPart(long unsigned int index, long long unsigned int & offset,unsigned int& size, long long unsigned int & timestamp, int32_t & timeOffset);
|
||||
long unsigned int size();
|
||||
private:
|
||||
bool initialised;
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
namespace Mist {
|
||||
OutProgressiveMP4::OutProgressiveMP4(Socket::Connection & conn) : HTTPOutput(conn) {
|
||||
completeKeysOnly = true;
|
||||
completeKeysOnly = false;
|
||||
}
|
||||
OutProgressiveMP4::~OutProgressiveMP4() {}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue