Skip at least some corruption in TS

This commit is contained in:
Erik Zandvliet 2018-05-02 16:26:22 +02:00 committed by Thulinma
parent 98c50762e8
commit 0fff6f8773
6 changed files with 25 additions and 18 deletions

View file

@ -142,15 +142,15 @@ namespace aac {
if (syncWord != 0xfff){
res << " Sync word " << std::hex << syncWord << " != fff!" << std::endl;
}
if (data[1] & 0x8 == 0x8){
if ((data[1] & 0x8) == 0x8){
res << " MPEG-2" << std::endl;
}else{
res << " MPEG-4" << std::endl;
}
if (data[1] & 0x6 != 0){
if ((data[1] & 0x6) != 0){
res << " Non-zero layer!" << std::endl;
}
if (data[1] & 0x1 == 0x0){
if ((data[1] & 0x1) == 0x0){
res << " CRC present" << std::endl;
}
res << " MPEG-4 audio object type: " << getAACProfile() << std::endl;
@ -161,7 +161,7 @@ namespace aac {
return res.str();
}
adts::operator bool() const{
return hasSync() && len && len >= getHeaderSize() && getFrequency();
return hasSync() && len && len >= getHeaderSize() && getFrequency() && getChannelCount() && getSampleCount();
}
bool adts::hasSync() const{
return len && (((int)data[0] << 4) | ((data[1] >> 4) & 0x0F)) == 0xfff;

View file

@ -219,7 +219,7 @@ namespace DTSC {
//keyframe, if true, adds 9 bytes (integer type) and 10 bytes (2+namelen)
//data adds packDataSize+5 bytes (string type) and 6 bytes (2+namelen)
if (packData && packDataSize < 1){
FAIL_MSG("Attempted to fill a packet with %lli bytes!", packDataSize);
FAIL_MSG("Attempted to fill a packet with %lli bytes for timestamp %llu, track %llu!", packDataSize, packTime, packTrack);
return;
}
unsigned int sendLen = 24 + (packOffset?17:0) + (packBytePos?15:0) + (isKeyframe?19:0) + packDataSize+11;

View file

@ -305,7 +305,7 @@ namespace TS{
}
std::deque<Packet> &inStream = pesStreams[tid];
if (inStream.size() <= 1){
HIGH_MSG("No PES packets to parse");
FAIL_MSG("No PES packets to parse");
return;
}
// Find number of packets before unit Start
@ -325,7 +325,7 @@ namespace TS{
}
}
if (!finished && curPack == inStream.end()){
INFO_MSG("No PES packets to parse (%lu)", seenUnitStart[tid]);
FAIL_MSG("No PES packets to parse (%lu)", seenUnitStart[tid]);
return;
}
@ -518,14 +518,18 @@ namespace TS{
adtsInfo[tid] = adtsPack;
}
out.push_back(DTSC::Packet());
out.back().genericFill(timeStamp + msRead, timeOffset, tid,
adtsPack.getPayload(), adtsPack.getPayloadSize(), bPos,
0);
msRead += (adtsPack.getSampleCount() * 1000) / adtsPack.getFrequency();
offsetInPes += adtsPack.getCompleteSize();
if (adtsPack.getPayloadSize()){
out.back().genericFill(timeStamp + msRead, timeOffset, tid,
adtsPack.getPayload(), adtsPack.getPayloadSize(), bPos,
0);
offsetInPes += adtsPack.getCompleteSize();
msRead += (adtsPack.getSampleCount() * 1000) / adtsPack.getFrequency();
}else{
offsetInPes++;
}
}else{
/// \todo What about the case that we have an invalid start, going over the PES boundary?
if (!adtsPack.hasSync()){
if (!adtsPack){
offsetInPes++;
}else{
// remainder, keep it, use it next time
@ -815,7 +819,7 @@ namespace TS{
for (std::map<unsigned long, std::deque<DTSC::Packet> >::iterator it = outPackets.begin();
it != outPackets.end(); it++){
if (it->second.front().getTime() < packTime){
if (it->second.size() && it->second.front().getTime() < packTime){
packTrack = it->first;
packTime = it->second.front().getTime();
}