MCPcopy Create free account
hub / github.com/FastLED/FastLED / splitAnnexB

Function splitAnnexB

src/platforms/esp/32/codec/h264_hw_decoder.hpp:46–82  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

44};
45
46fl::vector<NalUnit> splitAnnexB(const fl::vector<fl::u8>& annexB) FL_NOEXCEPT {
47 fl::vector<NalUnit> units;
48 const fl::size sz = annexB.size();
49 if (sz < 4) return units;
50
51 fl::size start = 0;
52 // Find first start code
53 for (fl::size i = 0; i + 3 < sz; i++) {
54 if (annexB[i] == 0 && annexB[i+1] == 0 &&
55 annexB[i+2] == 0 && annexB[i+3] == 1) {
56 start = i + 4;
57 break;
58 }
59 }
60 if (start == 0) return units;
61
62 for (fl::size i = start; i + 3 < sz; i++) {
63 if (annexB[i] == 0 && annexB[i+1] == 0 &&
64 annexB[i+2] == 0 && annexB[i+3] == 1) {
65 if (i > start) {
66 NalUnit u;
67 u.data = annexB.data() + start;
68 u.len = i - start;
69 units.push_back(u);
70 }
71 start = i + 4;
72 }
73 }
74 // Last NAL unit
75 if (start < sz) {
76 NalUnit u;
77 u.data = annexB.data() + start;
78 u.len = sz - start;
79 units.push_back(u);
80 }
81 return units;
82}
83
84} // namespace
85

Callers 1

decodeMethod · 0.85

Calls 3

sizeMethod · 0.45
dataMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected