MCPcopy Create free account
hub / github.com/IENT/YUView / checkForMp4Format

Function checkForMp4Format

YUViewLib/src/ffmpeg/AVPacketWrapper.cpp:54–78  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

52}
53
54bool checkForMp4Format(QByteArray &data)
55{
56 // Check the ISO mp4 format: Parse the whole data and check if the size bytes per Unit are
57 // correct.
58 uint64_t posInData = 0;
59 while (posInData + 4 <= uint64_t(data.length()))
60 {
61 auto firstBytes = data.mid(posInData, 4);
62
63 unsigned size = (unsigned char)firstBytes.at(3);
64 size += (unsigned char)firstBytes.at(2) << 8;
65 size += (unsigned char)firstBytes.at(1) << 16;
66 size += (unsigned char)firstBytes.at(0) << 24;
67 posInData += 4;
68
69 if (size > 1'000'000'000)
70 // A Nal with more then 1GB? This is probably an error.
71 return false;
72 if (posInData + size > uint64_t(data.length()))
73 // Not enough data in the input array to read NAL unit.
74 return false;
75 posInData += size;
76 }
77 return true;
78}
79
80bool checkForObuFormat(QByteArray &data)
81{

Callers 1

Calls 1

atMethod · 0.45

Tested by

no test coverage detected