Code: Select all
static uint64_t get_ber_length(uint8_t *p)
{
uint64_t size = *p++;
if (size & 0x80) { /* long form */
int bytes_num = size & 0x7f;
/* Different implementations might have different uses for BER. */
/* KLV data from UAV's for example follow 379M standards */
/* SMPTE 379M 5.3.4 guarantee that bytes_num must not exceed 8 bytes */
if (bytes_num > 8)
return 0xFF;
size = 0;
/* should probably include a check that byte_num doesn't put us past the end of the file/data */
while (bytes_num--)
size = size << 8 | *p++;
}
return size;
}