Find a top-level box by type within a range. Returns offset of box start, or ~0 if not found.
| 30 | |
| 31 | // Find a top-level box by type within a range. Returns offset of box start, or ~0 if not found. |
| 32 | fl::size findBox(fl::span<const fl::u8> data, fl::size start, fl::size end, const char* type) { |
| 33 | fl::size pos = start; |
| 34 | while (pos + 8 <= end) { |
| 35 | bool ok = true; |
| 36 | fl::u32 boxSize = readU32BE(data, pos, ok); |
| 37 | if (!ok || boxSize < 8) break; |
| 38 | if (boxIs(data, pos + 4, type)) return pos; |
| 39 | pos += boxSize; |
| 40 | } |
| 41 | return fl::size(-1); // not found |
| 42 | } |
| 43 | |
| 44 | // Parse avcC (AVC Decoder Configuration Record) at given offset. |
| 45 | // ISO 14496-15 section 5.2.4.1 |