FastLED 3.10.8
Loading...
Searching...
No Matches

◆ parseAvcC()

bool fl::anonymous_namespace{mp4_parser.cpp.hpp}::parseAvcC ( fl::span< const fl::u8 > data,
fl::size offset,
fl::size boxEnd,
Mp4TrackInfo & info )

Definition at line 47 of file mp4_parser.cpp.hpp.

48 {
49 // avcC box: 8 bytes header, then:
50 // u8 configVersion (1)
51 // u8 profile_idc
52 // u8 profile_compat
53 // u8 level_idc
54 // u8 lengthSizeMinusOne (& 0x03)
55 // u8 numSPS (& 0x1F)
56 // for each SPS: u16 spsLength, u8[] spsData
57 // u8 numPPS
58 // for each PPS: u16 ppsLength, u8[] ppsData
59
60 fl::size pos = offset + 8; // skip box header
61 if (pos + 6 > boxEnd) return false;
62
63 fl::u8 configVersion = data[pos++];
64 if (configVersion != 1) return false;
65
66 info.profile = data[pos++];
67 pos++; // profile_compat
68 info.level = data[pos++];
69 info.lengthSizeMinusOne = data[pos++] & 0x03;
70
71 fl::u8 numSPS = data[pos++] & 0x1F;
72 for (fl::u8 i = 0; i < numSPS; i++) {
73 bool ok = true;
74 fl::u16 spsLen = readU16BE(data, pos, ok);
75 if (!ok) return false;
76 pos += 2;
77 if (pos + spsLen > boxEnd) return false;
78 fl::vector<fl::u8> sps(spsLen);
79 for (fl::u16 j = 0; j < spsLen; j++) {
80 sps[j] = data[pos + j];
81 }
82 info.sps.push_back(sps);
83 pos += spsLen;
84 }
85
86 if (pos >= boxEnd) return false;
87 fl::u8 numPPS = data[pos++];
88 for (fl::u8 i = 0; i < numPPS; i++) {
89 bool ok = true;
90 fl::u16 ppsLen = readU16BE(data, pos, ok);
91 if (!ok) return false;
92 pos += 2;
93 if (pos + ppsLen > boxEnd) return false;
94 fl::vector<fl::u8> pps(ppsLen);
95 for (fl::u16 j = 0; j < ppsLen; j++) {
96 pps[j] = data[pos + j];
97 }
98 info.pps.push_back(pps);
99 pos += ppsLen;
100 }
101
102 return true;
103}
uint8_t pos
Definition Blur.ino:11
void push_back(const T &value) FL_NO_EXCEPT
Definition vector.h:624
fl::UISlider offset("Offset", 0.0f, 0.0f, 1.0f, 0.01f)
fl::u16 readU16BE(fl::span< const fl::u8 > data, fl::size offset, bool &ok) FL_NO_EXCEPT
unsigned char u8
Definition stdint.h:131
fl::u8 lengthSizeMinusOne
Definition mp4_parser.h:20
fl::vector< fl::vector< fl::u8 > > pps
Definition mp4_parser.h:22
fl::vector< fl::vector< fl::u8 > > sps
Definition mp4_parser.h:21

References fl::FL_NO_EXCEPT, offset(), parseAvcC(), pos, and readU16BE().

Referenced by parseAvcC().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: