Lines Matching refs:br
51 BROTLI_INTERNAL void BrotliInitBitReader(BrotliBitReader* const br);
58 BROTLI_INTERNAL BROTLI_BOOL BrotliWarmupBitReader(BrotliBitReader* const br);
64 BrotliBitReader* const br, uint32_t n_bits, uint32_t* val);
83 const BrotliBitReader* br) {
84 return (BROTLI_64_BITS ? 64 : 32) - br->bit_pos_;
88 BrotliInput, including whole bytes in br->val_. Result is capped with
90 static BROTLI_INLINE size_t BrotliGetRemainingBytes(BrotliBitReader* br) {
92 if (br->avail_in > kCap) return kCap;
93 return br->avail_in + (BrotliGetAvailableBits(br) >> 3);
97 (excluding the bits remaining in br->val_). */
99 BrotliBitReader* const br, size_t num) {
100 return TO_BROTLI_BOOL(br->avail_in >= num);
108 BrotliBitReader* const br, uint32_t n_bits) {
111 if (br->bit_pos_ >= 56) {
112 br->val_ >>= 56;
113 br->bit_pos_ ^= 56; /* here same as -= 56 because of the if condition */
114 br->val_ |= BROTLI_UNALIGNED_LOAD64LE(br->next_in) << 8;
115 br->avail_in -= 7;
116 br->next_in += 7;
120 if (br->bit_pos_ >= 48) {
121 br->val_ >>= 48;
122 br->bit_pos_ ^= 48; /* here same as -= 48 because of the if condition */
123 br->val_ |= BROTLI_UNALIGNED_LOAD64LE(br->next_in) << 16;
124 br->avail_in -= 6;
125 br->next_in += 6;
128 if (br->bit_pos_ >= 32) {
129 br->val_ >>= 32;
130 br->bit_pos_ ^= 32; /* here same as -= 32 because of the if condition */
131 br->val_ |= ((uint64_t)BROTLI_UNALIGNED_LOAD32LE(br->next_in)) << 32;
132 br->avail_in -= BROTLI_SHORT_FILL_BIT_WINDOW_READ;
133 br->next_in += BROTLI_SHORT_FILL_BIT_WINDOW_READ;
138 if (br->bit_pos_ >= 24) {
139 br->val_ >>= 24;
140 br->bit_pos_ ^= 24; /* here same as -= 24 because of the if condition */
141 br->val_ |= BROTLI_UNALIGNED_LOAD32LE(br->next_in) << 8;
142 br->avail_in -= 3;
143 br->next_in += 3;
146 if (br->bit_pos_ >= 16) {
147 br->val_ >>= 16;
148 br->bit_pos_ ^= 16; /* here same as -= 16 because of the if condition */
149 br->val_ |= ((uint32_t)BROTLI_UNALIGNED_LOAD16LE(br->next_in)) << 16;
150 br->avail_in -= BROTLI_SHORT_FILL_BIT_WINDOW_READ;
151 br->next_in += BROTLI_SHORT_FILL_BIT_WINDOW_READ;
159 static BROTLI_INLINE void BrotliFillBitWindow16(BrotliBitReader* const br) {
160 BrotliFillBitWindow(br, 17);
165 static BROTLI_INLINE BROTLI_BOOL BrotliPullByte(BrotliBitReader* const br) {
166 if (br->avail_in == 0) {
169 br->val_ >>= 8;
171 br->val_ |= ((uint64_t)*br->next_in) << 56;
173 br->val_ |= ((uint32_t)*br->next_in) << 24;
175 br->bit_pos_ -= 8;
176 --br->avail_in;
177 ++br->next_in;
184 BrotliBitReader* const br) {
185 return br->val_ >> br->bit_pos_;
191 BrotliBitReader* const br) {
192 BrotliFillBitWindow(br, 16);
193 return (uint32_t)BrotliGetBitsUnmasked(br);
196 /* Returns the specified number of bits from |br| without advancing bit
199 BrotliBitReader* const br, uint32_t n_bits) {
200 BrotliFillBitWindow(br, n_bits);
201 return (uint32_t)BrotliGetBitsUnmasked(br) & BitMask(n_bits);
207 BrotliBitReader* const br, uint32_t n_bits, uint32_t* val) {
208 while (BrotliGetAvailableBits(br) < n_bits) {
209 if (!BrotliPullByte(br)) {
213 *val = (uint32_t)BrotliGetBitsUnmasked(br) & BitMask(n_bits);
219 BrotliBitReader* const br, uint32_t n_bits) {
220 br->bit_pos_ += n_bits;
223 static BROTLI_INLINE void BrotliBitReaderUnload(BrotliBitReader* br) {
224 uint32_t unused_bytes = BrotliGetAvailableBits(br) >> 3;
226 br->avail_in += unused_bytes;
227 br->next_in -= unused_bytes;
228 if (unused_bits == sizeof(br->val_) << 3) {
229 br->val_ = 0;
231 br->val_ <<= unused_bits;
233 br->bit_pos_ += unused_bits;
236 /* Reads the specified number of bits from |br| and advances the bit pos.
239 BrotliBitReader* const br, uint32_t n_bits, uint32_t* val) {
240 *val = (uint32_t)BrotliGetBitsUnmasked(br) & BitMask(n_bits);
242 (int)br->avail_in, (int)br->bit_pos_, (int)n_bits, (int)*val));
243 BrotliDropBits(br, n_bits);
246 /* Reads the specified number of bits from |br| and advances the bit pos.
250 BrotliBitReader* const br, uint32_t n_bits) {
254 BrotliFillBitWindow(br, n_bits);
255 BrotliTakeBits(br, n_bits, &val);
260 BrotliFillBitWindow(br, 16);
261 BrotliTakeBits(br, 16, &low_val);
262 BrotliFillBitWindow(br, 8);
263 BrotliTakeBits(br, n_bits - 16, &high_val);
270 BrotliBitReader* const br, uint32_t n_bits) {
274 BrotliFillBitWindow(br, n_bits);
275 BrotliTakeBits(br, n_bits, &val);
280 BrotliFillBitWindow(br, 16);
281 BrotliTakeBits(br, 16, &low_val);
282 BrotliFillBitWindow(br, 16);
283 BrotliTakeBits(br, n_bits - 16, &high_val);
292 BrotliBitReader* const br, uint32_t n_bits, uint32_t* val) {
294 while (BrotliGetAvailableBits(br) < n_bits) {
295 if (!BrotliPullByte(br)) {
299 BrotliTakeBits(br, n_bits, val);
305 BrotliBitReader* const br, uint32_t n_bits, uint32_t* val) {
308 while (BrotliGetAvailableBits(br) < n_bits) {
309 if (!BrotliPullByte(br)) {
313 BrotliTakeBits(br, n_bits, val);
316 return BrotliSafeReadBits32Slow(br, n_bits, val);
322 static BROTLI_INLINE BROTLI_BOOL BrotliJumpToByteBoundary(BrotliBitReader* br) {
323 uint32_t pad_bits_count = BrotliGetAvailableBits(br) & 0x7;
326 BrotliTakeBits(br, pad_bits_count, &pad_bits);
335 BrotliBitReader* br, size_t num) {
336 while (BrotliGetAvailableBits(br) >= 8 && num > 0) {
337 *dest = (uint8_t)BrotliGetBitsUnmasked(br);
338 BrotliDropBits(br, 8);
342 memcpy(dest, br->next_in, num);
343 br->avail_in -= num;
344 br->next_in += num;