/* * Copyright (c) 2018, Alliance for Open Media. All rights reserved. * * This source code is subject to the terms of the BSD 2 Clause License and * the Alliance for Open Media Patent License 1.0. If the BSD 2 Clause License * was not distributed with this source code in the LICENSE file, you can * obtain it at www.aomedia.org/license/software. If the Alliance for Open * Media Patent License 1.0 was not distributed with this source code in the * PATENTS file, you can obtain it at www.aomedia.org/license/patent.
*/ #include <assert.h>
// 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;
return 0;
}
}
}
// 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.