Lines Matching refs:vlc
92 vl_vlc_next_input(struct vl_vlc *vlc) in vl_vlc_next_input() argument
94 const uint8_t* data = vlc->inputs[0]; in vl_vlc_next_input()
95 unsigned len = vlc->sizes[0]; in vl_vlc_next_input()
97 assert(vlc); in vl_vlc_next_input()
98 assert(vlc->num_inputs); in vl_vlc_next_input()
100 vlc->bytes_left -= len; in vl_vlc_next_input()
104 vlc->buffer |= (uint64_t)*data << (24 + vlc->invalid_bits); in vl_vlc_next_input()
107 vlc->invalid_bits -= 8; in vl_vlc_next_input()
109 vlc->data = data; in vl_vlc_next_input()
110 vlc->end = data + len; in vl_vlc_next_input()
112 --vlc->num_inputs; in vl_vlc_next_input()
113 ++vlc->inputs; in vl_vlc_next_input()
114 ++vlc->sizes; in vl_vlc_next_input()
121 vl_vlc_fillbits(struct vl_vlc *vlc) in vl_vlc_fillbits() argument
123 assert(vlc); in vl_vlc_fillbits()
126 while (vlc->invalid_bits > 0) { in vl_vlc_fillbits()
127 unsigned bytes_left = vlc->end - vlc->data; in vl_vlc_fillbits()
132 if (vlc->num_inputs) in vl_vlc_fillbits()
134 vl_vlc_next_input(vlc); in vl_vlc_fillbits()
142 uint64_t value = *(const uint32_t*)vlc->data; in vl_vlc_fillbits()
148 vlc->buffer |= value << vlc->invalid_bits; in vl_vlc_fillbits()
149 vlc->data += 4; in vl_vlc_fillbits()
150 vlc->invalid_bits -= 32; in vl_vlc_fillbits()
155 } else while (vlc->data < vlc->end) { in vl_vlc_fillbits()
158 vlc->buffer |= (uint64_t)*vlc->data << (24 + vlc->invalid_bits); in vl_vlc_fillbits()
159 ++vlc->data; in vl_vlc_fillbits()
160 vlc->invalid_bits -= 8; in vl_vlc_fillbits()
169 vl_vlc_init(struct vl_vlc *vlc, unsigned num_inputs, in vl_vlc_init() argument
174 assert(vlc); in vl_vlc_init()
177 vlc->buffer = 0; in vl_vlc_init()
178 vlc->invalid_bits = 32; in vl_vlc_init()
179 vlc->num_inputs = num_inputs; in vl_vlc_init()
180 vlc->inputs = inputs; in vl_vlc_init()
181 vlc->sizes = sizes; in vl_vlc_init()
182 vlc->bytes_left = 0; in vl_vlc_init()
185 vlc->bytes_left += sizes[i]; in vl_vlc_init()
187 vl_vlc_next_input(vlc); in vl_vlc_init()
188 vl_vlc_fillbits(vlc); in vl_vlc_init()
189 vl_vlc_fillbits(vlc); in vl_vlc_init()
196 vl_vlc_valid_bits(struct vl_vlc *vlc) in vl_vlc_valid_bits() argument
198 return 32 - vlc->invalid_bits; in vl_vlc_valid_bits()
205 vl_vlc_bits_left(struct vl_vlc *vlc) in vl_vlc_bits_left() argument
207 signed bytes_left = vlc->end - vlc->data; in vl_vlc_bits_left()
208 bytes_left += vlc->bytes_left; in vl_vlc_bits_left()
209 return bytes_left * 8 + vl_vlc_valid_bits(vlc); in vl_vlc_bits_left()
216 vl_vlc_peekbits(struct vl_vlc *vlc, unsigned num_bits) in vl_vlc_peekbits() argument
218 assert(vl_vlc_valid_bits(vlc) >= num_bits || vlc->data >= vlc->end); in vl_vlc_peekbits()
219 return vlc->buffer >> (64 - num_bits); in vl_vlc_peekbits()
226 vl_vlc_eatbits(struct vl_vlc *vlc, unsigned num_bits) in vl_vlc_eatbits() argument
228 assert(vl_vlc_valid_bits(vlc) >= num_bits); in vl_vlc_eatbits()
230 vlc->buffer <<= num_bits; in vl_vlc_eatbits()
231 vlc->invalid_bits += num_bits; in vl_vlc_eatbits()
238 vl_vlc_get_uimsbf(struct vl_vlc *vlc, unsigned num_bits) in vl_vlc_get_uimsbf() argument
242 assert(vl_vlc_valid_bits(vlc) >= num_bits); in vl_vlc_get_uimsbf()
244 value = vlc->buffer >> (64 - num_bits); in vl_vlc_get_uimsbf()
245 vl_vlc_eatbits(vlc, num_bits); in vl_vlc_get_uimsbf()
254 vl_vlc_get_simsbf(struct vl_vlc *vlc, unsigned num_bits) in vl_vlc_get_simsbf() argument
258 assert(vl_vlc_valid_bits(vlc) >= num_bits); in vl_vlc_get_simsbf()
260 value = ((int64_t)vlc->buffer) >> (64 - num_bits); in vl_vlc_get_simsbf()
261 vl_vlc_eatbits(vlc, num_bits); in vl_vlc_get_simsbf()
270 vl_vlc_get_vlclbf(struct vl_vlc *vlc, const struct vl_vlc_entry *tbl, unsigned num_bits) in vl_vlc_get_vlclbf() argument
272 tbl += vl_vlc_peekbits(vlc, num_bits); in vl_vlc_get_vlclbf()
273 vl_vlc_eatbits(vlc, tbl->length); in vl_vlc_get_vlclbf()