rename BitReader to VP8LBitReader

Change-Id: I192b76422e131a94fb58c2c4a5520a5dba807126
This commit is contained in:
Pascal Massimino
2012-04-13 01:56:31 -07:00
parent 90ead710dc
commit fac0f12e1b
4 changed files with 29 additions and 29 deletions

View File

@ -95,14 +95,16 @@ int32_t VP8GetSignedValue(VP8BitReader* const br, int bits) {
}
//------------------------------------------------------------------------------
// BitReader
// VP8LBitReader
#define MAX_NUM_BIT_READ 25
static const uint32_t kBitMask[MAX_NUM_BIT_READ] = {
0, 1, 3, 7, 15, 31, 63, 127, 255, 511, 1023, 2047, 4095, 8191, 16383, 32767,
65535, 131071, 262143, 524287, 1048575, 2097151, 4194303, 8388607, 16777215
};
void VP8LInitBitReader(BitReader* const br,
void VP8LInitBitReader(VP8LBitReader* const br,
const uint8_t* const start,
size_t length) {
size_t i;
@ -122,14 +124,14 @@ void VP8LInitBitReader(BitReader* const br,
}
}
void VP8LBitReaderSetBuffer(BitReader* const br,
void VP8LBitReaderSetBuffer(VP8LBitReader* const br,
const uint8_t* const buf, size_t len) {
br->eos_ = (br->pos_ >= len);
br->buf_ = buf;
br->len_ = len;
}
static void ShiftBytes(BitReader* const br) {
static void ShiftBytes(VP8LBitReader* const br) {
while (br->bit_pos_ >= 8 && br->pos_ < br->len_) {
br->val_ >>= 8;
br->val_ |= ((uint64_t)br->buf_[br->pos_]) << 56;
@ -138,7 +140,7 @@ static void ShiftBytes(BitReader* const br) {
}
}
void VP8LFillBitWindow(BitReader* const br) {
void VP8LFillBitWindow(VP8LBitReader* const br) {
if (br->bit_pos_ >= 32) {
#if defined(__x86_64__)
if (br->pos_ < br->len_ - 8) {
@ -162,7 +164,7 @@ void VP8LFillBitWindow(BitReader* const br) {
}
}
uint32_t VP8LReadOneBit(BitReader* const br) {
uint32_t VP8LReadOneBit(VP8LBitReader* const br) {
const uint32_t val = (br->val_ >> br->bit_pos_) & 1;
// Flag an error at end_of_stream.
if (!br->eos_) {
@ -180,7 +182,7 @@ uint32_t VP8LReadOneBit(BitReader* const br) {
return val;
}
uint32_t VP8LReadBits(BitReader* const br, int n_bits) {
uint32_t VP8LReadBits(VP8LBitReader* const br, int n_bits) {
uint32_t val = 0;
assert(n_bits >= 0);
// Flag an error if end_of_stream or n_bits is more than allowed limit.

View File

@ -152,8 +152,6 @@ static WEBP_INLINE int VP8GetSigned(VP8BitReader* const br, int v) {
// -----------------------------------------------------------------------------
// Bitreader
#define MAX_NUM_BIT_READ 25
typedef struct {
uint64_t val_;
const uint8_t* buf_;
@ -162,36 +160,36 @@ typedef struct {
int bit_pos_;
int eos_;
int error_;
} BitReader;
} VP8LBitReader;
void VP8LInitBitReader(BitReader* const br,
void VP8LInitBitReader(VP8LBitReader* const br,
const uint8_t* const start,
size_t length);
// Sets a new data buffer.
void VP8LBitReaderSetBuffer(BitReader* const br,
void VP8LBitReaderSetBuffer(VP8LBitReader* const br,
const uint8_t* const buffer, size_t length);
// Reads the specified number of bits from Read Buffer.
// Flags an error in case end_of_stream or n_bits is more than allowed limit.
// Flags eos if this read attempt is going to cross the read buffer.
uint32_t VP8LReadBits(BitReader* const br, int n_bits);
uint32_t VP8LReadBits(VP8LBitReader* const br, int n_bits);
// Reads one bit from Read Buffer. Flags an error in case end_of_stream.
// Flags eos after reading last bit from the buffer.
uint32_t VP8LReadOneBit(BitReader* const br);
uint32_t VP8LReadOneBit(VP8LBitReader* const br);
// VP8LReadOneBitUnsafe is faster than VP8LReadOneBit, but it can be called only
// 32 times after the last VP8LFillBitWindow. Any subsequent calls
// (without VP8LFillBitWindow) will return invalid data.
static WEBP_INLINE uint32_t VP8LReadOneBitUnsafe(BitReader* const br) {
static WEBP_INLINE uint32_t VP8LReadOneBitUnsafe(VP8LBitReader* const br) {
const uint32_t val = (br->val_ >> br->bit_pos_) & 1;
++br->bit_pos_;
return val;
}
// Advances the Read buffer by 4 bytes to make room for reading next 32 bits.
void VP8LFillBitWindow(BitReader* const br);
void VP8LFillBitWindow(VP8LBitReader* const br);
#if defined(__cplusplus) || defined(c_plusplus)
} // extern "C"