Lines Matching refs:b

39 void oggpack_writeinit(oggpack_buffer *b){  in oggpack_writeinit()  argument
40 memset(b,0,sizeof(*b)); in oggpack_writeinit()
41 b->ptr=b->buffer=_ogg_malloc(BUFFER_INCREMENT); in oggpack_writeinit()
42 b->buffer[0]='\0'; in oggpack_writeinit()
43 b->storage=BUFFER_INCREMENT; in oggpack_writeinit()
46 void oggpackB_writeinit(oggpack_buffer *b){ in oggpackB_writeinit() argument
47 oggpack_writeinit(b); in oggpackB_writeinit()
50 int oggpack_writecheck(oggpack_buffer *b){ in oggpack_writecheck() argument
51 if(!b->ptr || !b->storage)return -1; in oggpack_writecheck()
55 int oggpackB_writecheck(oggpack_buffer *b){ in oggpackB_writecheck() argument
56 return oggpack_writecheck(b); in oggpackB_writecheck()
59 void oggpack_writetrunc(oggpack_buffer *b,long bits){ in oggpack_writetrunc() argument
61 if(b->ptr){ in oggpack_writetrunc()
63 b->ptr=b->buffer+bytes; in oggpack_writetrunc()
64 b->endbit=bits; in oggpack_writetrunc()
65 b->endbyte=bytes; in oggpack_writetrunc()
66 *b->ptr&=mask[bits]; in oggpack_writetrunc()
70 void oggpackB_writetrunc(oggpack_buffer *b,long bits){ in oggpackB_writetrunc() argument
72 if(b->ptr){ in oggpackB_writetrunc()
74 b->ptr=b->buffer+bytes; in oggpackB_writetrunc()
75 b->endbit=bits; in oggpackB_writetrunc()
76 b->endbyte=bytes; in oggpackB_writetrunc()
77 *b->ptr&=mask8B[bits]; in oggpackB_writetrunc()
82 void oggpack_write(oggpack_buffer *b,unsigned long value,int bits){ in oggpack_write() argument
83 if(b->endbyte+4>=b->storage){ in oggpack_write()
85 if(!b->ptr)return; in oggpack_write()
86 ret=_ogg_realloc(b->buffer,b->storage+BUFFER_INCREMENT); in oggpack_write()
88 oggpack_writeclear(b); in oggpack_write()
91 b->buffer=ret; in oggpack_write()
92 b->storage+=BUFFER_INCREMENT; in oggpack_write()
93 b->ptr=b->buffer+b->endbyte; in oggpack_write()
97 bits+=b->endbit; in oggpack_write()
99 b->ptr[0]|=value<<b->endbit; in oggpack_write()
102 b->ptr[1]=(unsigned char)(value>>(8-b->endbit)); in oggpack_write()
104 b->ptr[2]=(unsigned char)(value>>(16-b->endbit)); in oggpack_write()
106 b->ptr[3]=(unsigned char)(value>>(24-b->endbit)); in oggpack_write()
108 if(b->endbit) in oggpack_write()
109 b->ptr[4]=(unsigned char)(value>>(32-b->endbit)); in oggpack_write()
111 b->ptr[4]=0; in oggpack_write()
117 b->endbyte+=bits/8; in oggpack_write()
118 b->ptr+=bits/8; in oggpack_write()
119 b->endbit=bits&7; in oggpack_write()
123 void oggpackB_write(oggpack_buffer *b,unsigned long value,int bits){ in oggpackB_write() argument
124 if(b->endbyte+4>=b->storage){ in oggpackB_write()
126 if(!b->ptr)return; in oggpackB_write()
127 ret=_ogg_realloc(b->buffer,b->storage+BUFFER_INCREMENT); in oggpackB_write()
129 oggpack_writeclear(b); in oggpackB_write()
132 b->buffer=ret; in oggpackB_write()
133 b->storage+=BUFFER_INCREMENT; in oggpackB_write()
134 b->ptr=b->buffer+b->endbyte; in oggpackB_write()
138 bits+=b->endbit; in oggpackB_write()
140 b->ptr[0]|=value>>(24+b->endbit); in oggpackB_write()
143 b->ptr[1]=(unsigned char)(value>>(16+b->endbit)); in oggpackB_write()
145 b->ptr[2]=(unsigned char)(value>>(8+b->endbit)); in oggpackB_write()
147 b->ptr[3]=(unsigned char)(value>>(b->endbit)); in oggpackB_write()
149 if(b->endbit) in oggpackB_write()
150 b->ptr[4]=(unsigned char)(value<<(8-b->endbit)); in oggpackB_write()
152 b->ptr[4]=0; in oggpackB_write()
158 b->endbyte+=bits/8; in oggpackB_write()
159 b->ptr+=bits/8; in oggpackB_write()
160 b->endbit=bits&7; in oggpackB_write()
163 void oggpack_writealign(oggpack_buffer *b){ in oggpack_writealign() argument
164 int bits=8-b->endbit; in oggpack_writealign()
166 oggpack_write(b,0,bits); in oggpack_writealign()
169 void oggpackB_writealign(oggpack_buffer *b){ in oggpackB_writealign() argument
170 int bits=8-b->endbit; in oggpackB_writealign()
172 oggpackB_write(b,0,bits); in oggpackB_writealign()
175 static void oggpack_writecopy_helper(oggpack_buffer *b, in oggpack_writecopy_helper() argument
187 if(b->endbit){ in oggpack_writecopy_helper()
191 w(b,(unsigned long)(ptr[i]),8); in oggpack_writecopy_helper()
194 if(b->endbyte+bytes+1>=b->storage){ in oggpack_writecopy_helper()
196 if(!b->ptr)return; in oggpack_writecopy_helper()
197 b->storage=b->endbyte+bytes+BUFFER_INCREMENT; in oggpack_writecopy_helper()
198 ret=_ogg_realloc(b->buffer,b->storage); in oggpack_writecopy_helper()
200 oggpack_writeclear(b); in oggpack_writecopy_helper()
203 b->buffer=ret; in oggpack_writecopy_helper()
204 b->ptr=b->buffer+b->endbyte; in oggpack_writecopy_helper()
207 memmove(b->ptr,source,bytes); in oggpack_writecopy_helper()
208 b->ptr+=bytes; in oggpack_writecopy_helper()
209 b->endbyte+=bytes; in oggpack_writecopy_helper()
210 *b->ptr=0; in oggpack_writecopy_helper()
215 w(b,(unsigned long)(ptr[bytes]>>(8-bits)),bits); in oggpack_writecopy_helper()
217 w(b,(unsigned long)(ptr[bytes]),bits); in oggpack_writecopy_helper()
221 void oggpack_writecopy(oggpack_buffer *b,void *source,long bits){ in oggpack_writecopy() argument
222 oggpack_writecopy_helper(b,source,bits,oggpack_write,0); in oggpack_writecopy()
225 void oggpackB_writecopy(oggpack_buffer *b,void *source,long bits){ in oggpackB_writecopy() argument
226 oggpack_writecopy_helper(b,source,bits,oggpackB_write,1); in oggpackB_writecopy()
229 void oggpack_reset(oggpack_buffer *b){ in oggpack_reset() argument
230 if(!b->ptr)return; in oggpack_reset()
231 b->ptr=b->buffer; in oggpack_reset()
232 b->buffer[0]=0; in oggpack_reset()
233 b->endbit=b->endbyte=0; in oggpack_reset()
236 void oggpackB_reset(oggpack_buffer *b){ in oggpackB_reset() argument
237 oggpack_reset(b); in oggpackB_reset()
240 void oggpack_writeclear(oggpack_buffer *b){ in oggpack_writeclear() argument
241 if(b->buffer)_ogg_free(b->buffer); in oggpack_writeclear()
242 memset(b,0,sizeof(*b)); in oggpack_writeclear()
245 void oggpackB_writeclear(oggpack_buffer *b){ in oggpackB_writeclear() argument
246 oggpack_writeclear(b); in oggpackB_writeclear()
249 void oggpack_readinit(oggpack_buffer *b,unsigned char *buf,int bytes){ in oggpack_readinit() argument
250 memset(b,0,sizeof(*b)); in oggpack_readinit()
251 b->buffer=b->ptr=buf; in oggpack_readinit()
252 b->storage=bytes; in oggpack_readinit()
255 void oggpackB_readinit(oggpack_buffer *b,unsigned char *buf,int bytes){ in oggpackB_readinit() argument
256 oggpack_readinit(b,buf,bytes); in oggpackB_readinit()
260 long oggpack_look(oggpack_buffer *b,int bits){ in oggpack_look() argument
264 bits+=b->endbit; in oggpack_look()
266 if(b->endbyte+4>=b->storage){ in oggpack_look()
268 if(b->endbyte*8+bits>b->storage*8)return(-1); in oggpack_look()
271 ret=b->ptr[0]>>b->endbit; in oggpack_look()
273 ret|=b->ptr[1]<<(8-b->endbit); in oggpack_look()
275 ret|=b->ptr[2]<<(16-b->endbit); in oggpack_look()
277 ret|=b->ptr[3]<<(24-b->endbit); in oggpack_look()
278 if(bits>32 && b->endbit) in oggpack_look()
279 ret|=b->ptr[4]<<(32-b->endbit); in oggpack_look()
287 long oggpackB_look(oggpack_buffer *b,int bits){ in oggpackB_look() argument
291 bits+=b->endbit; in oggpackB_look()
293 if(b->endbyte+4>=b->storage){ in oggpackB_look()
295 if(b->endbyte*8+bits>b->storage*8)return(-1); in oggpackB_look()
298 ret=b->ptr[0]<<(24+b->endbit); in oggpackB_look()
300 ret|=b->ptr[1]<<(16+b->endbit); in oggpackB_look()
302 ret|=b->ptr[2]<<(8+b->endbit); in oggpackB_look()
304 ret|=b->ptr[3]<<(b->endbit); in oggpackB_look()
305 if(bits>32 && b->endbit) in oggpackB_look()
306 ret|=b->ptr[4]>>(8-b->endbit); in oggpackB_look()
313 long oggpack_look1(oggpack_buffer *b){ in oggpack_look1() argument
314 if(b->endbyte>=b->storage)return(-1); in oggpack_look1()
315 return((b->ptr[0]>>b->endbit)&1); in oggpack_look1()
318 long oggpackB_look1(oggpack_buffer *b){ in oggpackB_look1() argument
319 if(b->endbyte>=b->storage)return(-1); in oggpackB_look1()
320 return((b->ptr[0]>>(7-b->endbit))&1); in oggpackB_look1()
323 void oggpack_adv(oggpack_buffer *b,int bits){ in oggpack_adv() argument
324 bits+=b->endbit; in oggpack_adv()
325 b->ptr+=bits/8; in oggpack_adv()
326 b->endbyte+=bits/8; in oggpack_adv()
327 b->endbit=bits&7; in oggpack_adv()
330 void oggpackB_adv(oggpack_buffer *b,int bits){ in oggpackB_adv() argument
331 oggpack_adv(b,bits); in oggpackB_adv()
334 void oggpack_adv1(oggpack_buffer *b){ in oggpack_adv1() argument
335 if(++(b->endbit)>7){ in oggpack_adv1()
336 b->endbit=0; in oggpack_adv1()
337 b->ptr++; in oggpack_adv1()
338 b->endbyte++; in oggpack_adv1()
342 void oggpackB_adv1(oggpack_buffer *b){ in oggpackB_adv1() argument
343 oggpack_adv1(b); in oggpackB_adv1()
347 long oggpack_read(oggpack_buffer *b,int bits){ in oggpack_read() argument
351 bits+=b->endbit; in oggpack_read()
353 if(b->endbyte+4>=b->storage){ in oggpack_read()
356 if(b->endbyte*8+bits>b->storage*8)goto overflow; in oggpack_read()
359 ret=b->ptr[0]>>b->endbit; in oggpack_read()
361 ret|=b->ptr[1]<<(8-b->endbit); in oggpack_read()
363 ret|=b->ptr[2]<<(16-b->endbit); in oggpack_read()
365 ret|=b->ptr[3]<<(24-b->endbit); in oggpack_read()
366 if(bits>32 && b->endbit){ in oggpack_read()
367 ret|=b->ptr[4]<<(32-b->endbit); in oggpack_read()
376 b->ptr+=bits/8; in oggpack_read()
377 b->endbyte+=bits/8; in oggpack_read()
378 b->endbit=bits&7; in oggpack_read()
383 long oggpackB_read(oggpack_buffer *b,int bits){ in oggpackB_read() argument
387 bits+=b->endbit; in oggpackB_read()
389 if(b->endbyte+4>=b->storage){ in oggpackB_read()
392 if(b->endbyte*8+bits>b->storage*8)goto overflow; in oggpackB_read()
398 ret=b->ptr[0]<<(24+b->endbit); in oggpackB_read()
400 ret|=b->ptr[1]<<(16+b->endbit); in oggpackB_read()
402 ret|=b->ptr[2]<<(8+b->endbit); in oggpackB_read()
404 ret|=b->ptr[3]<<(b->endbit); in oggpackB_read()
405 if(bits>32 && b->endbit) in oggpackB_read()
406 ret|=b->ptr[4]>>(8-b->endbit); in oggpackB_read()
414 b->ptr+=bits/8; in oggpackB_read()
415 b->endbyte+=bits/8; in oggpackB_read()
416 b->endbit=bits&7; in oggpackB_read()
420 long oggpack_read1(oggpack_buffer *b){ in oggpack_read1() argument
423 if(b->endbyte>=b->storage){ in oggpack_read1()
429 ret=(b->ptr[0]>>b->endbit)&1; in oggpack_read1()
433 b->endbit++; in oggpack_read1()
434 if(b->endbit>7){ in oggpack_read1()
435 b->endbit=0; in oggpack_read1()
436 b->ptr++; in oggpack_read1()
437 b->endbyte++; in oggpack_read1()
442 long oggpackB_read1(oggpack_buffer *b){ in oggpackB_read1() argument
445 if(b->endbyte>=b->storage){ in oggpackB_read1()
451 ret=(b->ptr[0]>>(7-b->endbit))&1; in oggpackB_read1()
455 b->endbit++; in oggpackB_read1()
456 if(b->endbit>7){ in oggpackB_read1()
457 b->endbit=0; in oggpackB_read1()
458 b->ptr++; in oggpackB_read1()
459 b->endbyte++; in oggpackB_read1()
464 long oggpack_bytes(oggpack_buffer *b){ in oggpack_bytes() argument
465 return(b->endbyte+(b->endbit+7)/8); in oggpack_bytes()
468 long oggpack_bits(oggpack_buffer *b){ in oggpack_bits() argument
469 return(b->endbyte*8+b->endbit); in oggpack_bits()
472 long oggpackB_bytes(oggpack_buffer *b){ in oggpackB_bytes() argument
473 return oggpack_bytes(b); in oggpackB_bytes()
476 long oggpackB_bits(oggpack_buffer *b){ in oggpackB_bits() argument
477 return oggpack_bits(b); in oggpackB_bits()
480 unsigned char *oggpack_get_buffer(oggpack_buffer *b){ in oggpack_get_buffer() argument
481 return(b->buffer); in oggpack_get_buffer()
484 unsigned char *oggpackB_get_buffer(oggpack_buffer *b){ in oggpackB_get_buffer() argument
485 return oggpack_get_buffer(b); in oggpackB_get_buffer()
511 void cliptest(unsigned long *b,int vals,int bits,int *comp,int compsize){ in cliptest() argument
517 oggpack_write(&o,b[i],bits?bits:ilog(b[i])); in cliptest()
527 int tbit=bits?bits:ilog(b[i]); in cliptest()
530 if(oggpack_look(&r,tbit)!=(b[i]&mask[tbit])) in cliptest()
533 if(oggpack_look1(&r)!=(b[i]&mask[tbit])) in cliptest()
536 if(oggpack_read1(&r)!=(b[i]&mask[tbit])) in cliptest()
539 if(oggpack_read(&r,tbit)!=(b[i]&mask[tbit])) in cliptest()
546 void cliptestB(unsigned long *b,int vals,int bits,int *comp,int compsize){ in cliptestB() argument
552 oggpackB_write(&o,b[i],bits?bits:ilog(b[i])); in cliptestB()
562 int tbit=bits?bits:ilog(b[i]); in cliptestB()
565 if(oggpackB_look(&r,tbit)!=(b[i]&mask[tbit])) in cliptestB()
568 if(oggpackB_look1(&r)!=(b[i]&mask[tbit])) in cliptestB()
571 if(oggpackB_read1(&r)!=(b[i]&mask[tbit])) in cliptestB()
574 if(oggpackB_read(&r,tbit)!=(b[i]&mask[tbit])) in cliptestB()