Lines Matching refs:bs
226 static inline void bitstream_init(struct bitstream *bs, void *s, size_t len, unsigned int pad_bits) in bitstream_init() argument
228 bs->buf = s; in bitstream_init()
229 bs->buf_len = len; in bitstream_init()
230 bs->pad_bits = pad_bits; in bitstream_init()
231 bitstream_cursor_reset(&bs->cur, bs->buf); in bitstream_init()
234 static inline void bitstream_rewind(struct bitstream *bs) in bitstream_rewind() argument
236 bitstream_cursor_reset(&bs->cur, bs->buf); in bitstream_rewind()
237 memset(bs->buf, 0, bs->buf_len); in bitstream_rewind()
248 static inline int bitstream_put_bits(struct bitstream *bs, u64 val, const unsigned int bits) in bitstream_put_bits() argument
250 unsigned char *b = bs->cur.b; in bitstream_put_bits()
256 if ((bs->cur.b + ((bs->cur.bit + bits -1) >> 3)) - bs->buf >= bs->buf_len) in bitstream_put_bits()
263 *b++ |= (val & 0xff) << bs->cur.bit; in bitstream_put_bits()
265 for (tmp = 8 - bs->cur.bit; tmp < bits; tmp += 8) in bitstream_put_bits()
268 bitstream_cursor_advance(&bs->cur, bits); in bitstream_put_bits()
281 static inline int bitstream_get_bits(struct bitstream *bs, u64 *out, int bits) in bitstream_get_bits() argument
289 if (bs->cur.b + ((bs->cur.bit + bs->pad_bits + bits -1) >> 3) - bs->buf >= bs->buf_len) in bitstream_get_bits()
290 bits = ((bs->buf_len - (bs->cur.b - bs->buf)) << 3) in bitstream_get_bits()
291 - bs->cur.bit - bs->pad_bits; in bitstream_get_bits()
300 n = (bs->cur.bit + bits + 7) >> 3; in bitstream_get_bits()
304 memcpy(&val, bs->cur.b+1, n - 1); in bitstream_get_bits()
305 val = le64_to_cpu(val) << (8 - bs->cur.bit); in bitstream_get_bits()
309 val |= bs->cur.b[0] >> bs->cur.bit; in bitstream_get_bits()
314 bitstream_cursor_advance(&bs->cur, bits); in bitstream_get_bits()
328 static inline int vli_encode_bits(struct bitstream *bs, u64 in) in vli_encode_bits() argument
336 return bitstream_put_bits(bs, code, bits); in vli_encode_bits()