/* * Copyright (c) 2010 The WebM project authors. All Rights Reserved. * * Use of this source code is governed by a BSD-style license * that can be found in the LICENSE file in the root of the source * tree. An additional intellectual property rights grant can be found * in the file PATENTS. All contributing project authors may * be found in the AUTHORS file in the root of the source tree.
*/
// This is meant to be a large, positive constant that can still be efficiently // loaded as an immediate (on platforms like ARM, for example). // Even relatively modest values like 100 would work fine. #define LOTS_OF_BITS 0x40000000
typedefstruct { // Be careful when reordering this struct, it may impact the cache negatively.
BD_VALUE value; unsignedint range; int count; const uint8_t *buffer_end; const uint8_t *buffer;
vpx_decrypt_cb decrypt_cb; void *decrypt_state;
uint8_t clear_buffer[sizeof(BD_VALUE) + 1];
} vpx_reader;
staticINLINEint vpx_reader_has_error(vpx_reader *r) { // Check if we have reached the end of the buffer. // // Variable 'count' stores the number of bits in the 'value' buffer, minus // 8. The top byte is part of the algorithm, and the remainder is buffered // to be shifted into it. So if count == 8, the top 16 bits of 'value' are // occupied, 8 for the algorithm and 8 in the buffer. // // When reading a byte from the user's buffer, count is filled with 8 and // one byte is filled into the value buffer. When we reach the end of the // data, count is additionally filled with LOTS_OF_BITS. So when // count == LOTS_OF_BITS - 1, the user's data has been exhausted. // // 1 if we have tried to decode bits after the end of stream was encountered. // 0 No error. return r->count > BD_VALUE_SIZE && r->count < LOTS_OF_BITS;
}
staticINLINEint vpx_read(vpx_reader *r, int prob) { unsignedint bit = 0;
BD_VALUE value;
BD_VALUE bigsplit; int count; unsignedint range; unsignedint split = (r->range * prob + (256 - prob)) >> CHAR_BIT;
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.