Lines Matching refs:br
29 void VP8InitBitReader(VP8BitReader* const br,
31 assert(br != NULL);
34 br->range_ = MK(255 - 1);
35 br->buf_ = start;
36 br->buf_end_ = end;
37 br->value_ = 0;
38 br->bits_ = -8; // to load the very first 8bits
39 br->eof_ = 0;
76 void VP8LoadFinalBytes(VP8BitReader* const br) {
77 assert(br != NULL && br->buf_ != NULL);
79 if (br->buf_ < br->buf_end_) {
81 br->value_ |= (bit_t)(*br->buf_++) << ((BITS) - 8 - br->bits_);
83 br->value_ = (bit_t)(*br->buf_++) | (br->value_ << 8);
85 br->bits_ += 8;
86 } else if (!br->eof_) {
90 br->value_ <<= 8;
91 br->bits_ += 8;
93 br->eof_ = 1;
100 uint32_t VP8GetValue(VP8BitReader* const br, int bits) {
103 v |= VP8GetBit(br, 0x80) << bits;
108 int32_t VP8GetSignedValue(VP8BitReader* const br, int bits) {
109 const int value = VP8GetValue(br, bits);
110 return VP8Get(br) ? -value : value;
127 void VP8LInitBitReader(VP8LBitReader* const br,
131 assert(br != NULL);
135 br->buf_ = start;
136 br->len_ = length;
137 br->val_ = 0;
138 br->pos_ = 0;
139 br->bit_pos_ = 0;
140 br->eos_ = 0;
141 br->error_ = 0;
142 for (i = 0; i < sizeof(br->val_) && i < br->len_; ++i) {
143 br->val_ |= ((vp8l_val_t)br->buf_[br->pos_]) << (8 * i);
144 ++br->pos_;
148 void VP8LBitReaderSetBuffer(VP8LBitReader* const br,
150 assert(br != NULL);
153 br->eos_ = (br->pos_ >= len);
154 br->buf_ = buf;
155 br->len_ = len;
159 static void ShiftBytes(VP8LBitReader* const br) {
160 while (br->bit_pos_ >= 8 && br->pos_ < br->len_) {
161 br->val_ >>= 8;
162 br->val_ |= ((vp8l_val_t)br->buf_[br->pos_]) << (LBITS - 8);
163 ++br->pos_;
164 br->bit_pos_ -= 8;
168 void VP8LFillBitWindow(VP8LBitReader* const br) {
169 if (br->bit_pos_ >= WBITS) {
171 if (br->pos_ + sizeof(br->val_) < br->len_) {
172 br->val_ >>= WBITS;
173 br->bit_pos_ -= WBITS;
176 br->val_ |= *(const vp8l_val_t*)(br->buf_ + br->pos_) << (LBITS - WBITS);
177 br->pos_ += LOG8_WBITS;
181 ShiftBytes(br); // Slow path.
182 if (br->pos_ == br->len_ && br->bit_pos_ == LBITS) {
183 br->eos_ = 1;
188 uint32_t VP8LReadBits(VP8LBitReader* const br, int n_bits) {
191 if (!br->eos_ && n_bits < MAX_NUM_BIT_READ) {
193 (uint32_t)(br->val_ >> br->bit_pos_) & kBitMask[n_bits];
194 const int new_bits = br->bit_pos_ + n_bits;
195 br->bit_pos_ = new_bits;
197 if (br->pos_ == br->len_) {
199 br->eos_ = 1;
202 ShiftBytes(br);
205 br->error_ = 1;