// Disallow values larger than 32-bits to ensure consistent behavior on 32 and // 64 bit targets: value is typically used to determine buffer allocation size // when decoded. staticconst uint64_t kMaximumLeb128Value = UINT32_MAX;
int aom_uleb_decode(const uint8_t *buffer, size_t available, uint64_t *value,
size_t *length) {
if (buffer && value) {
*value = 0;
for (size_t i = 0; i < kMaximumLeb128Size && i < available; ++i) { const uint8_t decoded_byte = *(buffer + i) & kLeb128ByteMask;
*value |= ((uint64_t)decoded_byte) << (i * 7);
if ((*(buffer + i) >> 7) == 0) {
if (length) {
*length = i + 1;
}
// Fail on values larger than 32-bits to ensure consistent behavior on // 32 and 64 bit targets: value is typically used to determine buffer // allocation size.
if (*value > UINT32_MAX) return -1;
return0;
}
}
}
// If we get here, either the buffer/value pointers were invalid, // or we ran over the available space return -1;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.