1 /********************************************************************
2 * *
3 * THIS FILE IS PART OF THE OggVorbis 'TREMOR' CODEC SOURCE CODE. *
4 * *
5 * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS *
6 * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
7 * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
8 * *
9 * THE OggVorbis 'TREMOR' SOURCE CODE IS (C) COPYRIGHT 1994-2003 *
10 * BY THE Xiph.Org FOUNDATION http://www.xiph.org/ *
11 * *
12 ********************************************************************
13
14 function: packing variable sized words into an octet stream
15
16 ********************************************************************/
17
18 /* We're 'LSb' endian; if we write a word but read individual bits,
19 then we'll read the lsb first */
20
21 #include <string.h>
22 #include <stdlib.h>
23 #include "misc.h"
24 #include "ogg.h"
25
26 static unsigned long mask[]=
27 {0x00000000,0x00000001,0x00000003,0x00000007,0x0000000f,
28 0x0000001f,0x0000003f,0x0000007f,0x000000ff,0x000001ff,
29 0x000003ff,0x000007ff,0x00000fff,0x00001fff,0x00003fff,
30 0x00007fff,0x0000ffff,0x0001ffff,0x0003ffff,0x0007ffff,
31 0x000fffff,0x001fffff,0x003fffff,0x007fffff,0x00ffffff,
32 0x01ffffff,0x03ffffff,0x07ffffff,0x0fffffff,0x1fffffff,
33 0x3fffffff,0x7fffffff,0xffffffff };
34
35 /* spans forward, skipping as many bytes as headend is negative; if
36 headend is zero, simply finds next byte. If we're up to the end
37 of the buffer, leaves headend at zero. If we've read past the end,
38 halt the decode process. */
39
_span(oggpack_buffer * b)40 static void _span(oggpack_buffer *b){
41 while(b->headend-(b->headbit>>3)<1){
42 b->headend-=b->headbit>>3;
43 b->headbit&=0x7;
44
45 if(b->head && b->head->next){
46 b->count+=b->head->length;
47 b->head=b->head->next;
48
49 if(b->headend+b->head->length>0)
50 b->headptr=b->head->buffer->data+b->head->begin-b->headend;
51
52 b->headend+=b->head->length;
53 }else{
54 /* we've either met the end of decode, or gone past it. halt
55 only if we're past */
56 if(b->headend*8<b->headbit)
57 /* read has fallen off the end */
58 b->headend=-1;
59 break;
60 }
61 }
62 }
63
oggpack_readinit(oggpack_buffer * b,ogg_reference * r)64 void oggpack_readinit(oggpack_buffer *b,ogg_reference *r){
65 memset(b,0,sizeof(*b));
66
67 b->tail=b->head=r;
68 b->count=0;
69 if (b->head) {
70 b->headptr=b->head->buffer->data+b->head->begin;
71 b->headend=b->head->length;
72 } else {
73 b->headptr=0;
74 b->headend=0;
75 }
76 _span(b);
77 }
78
79 #define _lookspan() while(!end){\
80 head=head->next;\
81 if(!head) return -1;\
82 ptr=head->buffer->data + head->begin;\
83 end=head->length;\
84 }
85
86 /* Read in bits without advancing the bitptr; bits <= 32 */
oggpack_look(oggpack_buffer * b,int bits)87 long oggpack_look(oggpack_buffer *b,int bits){
88 unsigned long m=mask[bits];
89 unsigned long ret;
90
91 bits+=b->headbit;
92
93 if(bits >= b->headend<<3){
94 int end=b->headend;
95 unsigned char *ptr=b->headptr;
96 ogg_reference *head=b->head;
97
98 if(end<0)return -1;
99 if (!head || !end)return -1;
100
101 if(bits){
102 _lookspan();
103 ret=*ptr++>>b->headbit;
104 if(bits>8){
105 --end;
106 _lookspan();
107 ret|=*ptr++<<(8-b->headbit);
108 if(bits>16){
109 --end;
110 _lookspan();
111 ret|=*ptr++<<(16-b->headbit);
112 if(bits>24){
113 --end;
114 _lookspan();
115 ret|=*ptr++<<(24-b->headbit);
116 if(bits>32 && b->headbit){
117 --end;
118 _lookspan();
119 ret|=*ptr<<(32-b->headbit);
120 }
121 }
122 }
123 }
124 }
125
126 }else{
127
128 /* make this a switch jump-table */
129 ret=b->headptr[0]>>b->headbit;
130 if(bits>8){
131 ret|=b->headptr[1]<<(8-b->headbit);
132 if(bits>16){
133 ret|=b->headptr[2]<<(16-b->headbit);
134 if(bits>24){
135 ret|=b->headptr[3]<<(24-b->headbit);
136 if(bits>32 && b->headbit)
137 ret|=b->headptr[4]<<(32-b->headbit);
138 }
139 }
140 }
141 }
142
143 ret&=m;
144 return ret;
145 }
146
147 /* limited to 32 at a time */
oggpack_adv(oggpack_buffer * b,int bits)148 void oggpack_adv(oggpack_buffer *b,int bits){
149 bits+=b->headbit;
150 b->headbit=bits&7;
151 b->headend-=(bits>>3);
152 b->headptr+=(bits>>3);
153 if(b->headend<1)_span(b);
154 }
155
oggpack_eop(oggpack_buffer * b)156 int oggpack_eop(oggpack_buffer *b){
157 if(b->headend<0)return -1;
158 return 0;
159 }
160
161 /* bits <= 32 */
oggpack_read(oggpack_buffer * b,int bits)162 long oggpack_read(oggpack_buffer *b,int bits){
163 long ret=oggpack_look(b,bits);
164 oggpack_adv(b,bits);
165 return(ret);
166 }
167
oggpack_bytes(oggpack_buffer * b)168 long oggpack_bytes(oggpack_buffer *b){
169 if(b->headend<0)return b->count+b->head->length;
170 return b->count + b->head->length-b->headend +
171 (b->headbit+7)/8;
172 }
173
oggpack_bits(oggpack_buffer * b)174 long oggpack_bits(oggpack_buffer *b){
175 if(b->headend<0)return (b->count+b->head->length)*8;
176 return (b->count + b->head->length-b->headend)*8 +
177 b->headbit;
178 }
179
180 /* Self test of the bitwise routines; everything else is based on
181 them, so they damned well better be solid. */
182
183 #ifdef _V_BIT_TEST
184 #include <string.h>
185 #include <stdlib.h>
186 #include <stdio.h>
187 #include "framing.c"
188
ilog(unsigned long v)189 static int ilog(unsigned long v){
190 int ret=0;
191 while(v){
192 ret++;
193 v>>=1;
194 }
195 return(ret);
196 }
197
198 oggpack_buffer r;
199 oggpack_buffer o;
200 ogg_buffer_state *bs;
201 ogg_reference *or;
202 #define TESTWORDS 256
203
report(char * in)204 void report(char *in){
205 fprintf(stderr,"%s",in);
206 exit(1);
207 }
208
getbyte(ogg_reference * or,int position)209 int getbyte(ogg_reference *or,int position){
210 while(or && position>=or->length){
211 position-=or->length;
212 or=or->next;
213 if(or==NULL){
214 fprintf(stderr,"\n\tERROR: getbyte ran off end of buffer.\n");
215 exit(1);
216 }
217 }
218
219 if((position+or->begin)&1)
220 return (or->buffer->data[(position+or->begin)>>1])&0xff;
221 else
222 return (or->buffer->data[(position+or->begin)>>1]>>8)&0xff;
223 }
224
cliptest(unsigned long * b,int vals,int bits,int * comp,int compsize)225 void cliptest(unsigned long *b,int vals,int bits,int *comp,int compsize){
226 long i,bitcount=0;
227 ogg_reference *or=ogg_buffer_alloc(bs,64);
228 for(i=0;i<compsize;i++)
229 or->buffer->data[i]= comp[i];
230 or->length=i;
231
232 oggpack_readinit(&r,or);
233 for(i=0;i<vals;i++){
234 unsigned long test;
235 int tbit=bits?bits:ilog(b[i]);
236 if((test=oggpack_look(&r,tbit))==0xffffffff)
237 report("out of data!\n");
238 if(test!=(b[i]&mask[tbit])){
239 fprintf(stderr,"%ld) %lx %lx\n",i,(b[i]&mask[tbit]),test);
240 report("looked at incorrect value!\n");
241 }
242 if((test=oggpack_read(&r,tbit))==0xffffffff){
243 report("premature end of data when reading!\n");
244 }
245 if(test!=(b[i]&mask[tbit])){
246 fprintf(stderr,"%ld) %lx %lx\n",i,(b[i]&mask[tbit]),test);
247 report("read incorrect value!\n");
248 }
249 bitcount+=tbit;
250
251 if(bitcount!=oggpack_bits(&r))
252 report("wrong number of bits while reading!\n");
253 if((bitcount+7)/8!=oggpack_bytes(&r))
254 report("wrong number of bytes while reading!\n");
255
256 }
257 if(oggpack_bytes(&r)!=(bitcount+7)/8)report("leftover bytes after read!\n");
258 ogg_buffer_release(or);
259 }
260
_end_verify(int count)261 void _end_verify(int count){
262 int i;
263
264 /* are the proper number of bits left over? */
265 int leftover=count*8-oggpack_bits(&o);
266 if(leftover>7)
267 report("\nERROR: too many bits reported left over.\n");
268
269 /* does reading to exactly byte alignment *not* trip EOF? */
270 if(oggpack_read(&o,leftover)==-1)
271 report("\nERROR: read to but not past exact end tripped EOF.\n");
272 if(oggpack_bits(&o)!=count*8)
273 report("\nERROR: read to but not past exact end reported bad bitcount.\n");
274
275 /* does EOF trip properly after a single additional bit? */
276 if(oggpack_read(&o,1)!=-1)
277 report("\nERROR: read past exact end did not trip EOF.\n");
278 if(oggpack_bits(&o)!=count*8)
279 report("\nERROR: read past exact end reported bad bitcount.\n");
280
281 /* does EOF stay set over additional bit reads? */
282 for(i=0;i<=32;i++){
283 if(oggpack_read(&o,i)!=-1)
284 report("\nERROR: EOF did not stay set on stream.\n");
285 if(oggpack_bits(&o)!=count*8)
286 report("\nERROR: read past exact end reported bad bitcount.\n");
287 }
288 }
289
_end_verify2(int count)290 void _end_verify2(int count){
291 int i;
292
293 /* are the proper number of bits left over? */
294 int leftover=count*8-oggpack_bits(&o);
295 if(leftover>7)
296 report("\nERROR: too many bits reported left over.\n");
297
298 /* does reading to exactly byte alignment *not* trip EOF? */
299 oggpack_adv(&o,leftover);
300 if(o.headend!=0)
301 report("\nERROR: read to but not past exact end tripped EOF.\n");
302 if(oggpack_bits(&o)!=count*8)
303 report("\nERROR: read to but not past exact end reported bad bitcount.\n");
304
305 /* does EOF trip properly after a single additional bit? */
306 oggpack_adv(&o,1);
307 if(o.headend>=0)
308 report("\nERROR: read past exact end did not trip EOF.\n");
309 if(oggpack_bits(&o)!=count*8)
310 report("\nERROR: read past exact end reported bad bitcount.\n");
311
312 /* does EOF stay set over additional bit reads? */
313 for(i=0;i<=32;i++){
314 oggpack_adv(&o,i);
315 if(o.headend>=0)
316 report("\nERROR: EOF did not stay set on stream.\n");
317 if(oggpack_bits(&o)!=count*8)
318 report("\nERROR: read past exact end reported bad bitcount.\n");
319 }
320 }
321
ogg_buffer_length(ogg_reference * or)322 long ogg_buffer_length(ogg_reference *or){
323 int count=0;
324 while(or){
325 count+=or->length;
326 or=or->next;
327 }
328 return count;
329 }
330
ogg_buffer_extend(ogg_reference * or,long bytes)331 ogg_reference *ogg_buffer_extend(ogg_reference *or,long bytes){
332 if(or){
333 while(or->next){
334 or=or->next;
335 }
336 or->next=ogg_buffer_alloc(or->buffer->ptr.owner,bytes);
337 return(or->next);
338 }
339 return 0;
340 }
341
ogg_buffer_posttruncate(ogg_reference * or,long pos)342 void ogg_buffer_posttruncate(ogg_reference *or,long pos){
343 /* walk to the point where we want to begin truncate */
344 while(or && pos>or->length){
345 pos-=or->length;
346 or=or->next;
347 }
348 if(or){
349 ogg_buffer_release(or->next);
350 or->next=0;
351 or->length=pos;
352 }
353 }
354
main(void)355 int main(void){
356 long i;
357 static unsigned long testbuffer1[]=
358 {18,12,103948,4325,543,76,432,52,3,65,4,56,32,42,34,21,1,23,32,546,456,7,
359 567,56,8,8,55,3,52,342,341,4,265,7,67,86,2199,21,7,1,5,1,4};
360 int test1size=43;
361
362 static unsigned long testbuffer2[]=
363 {216531625L,1237861823,56732452,131,3212421,12325343,34547562,12313212,
364 1233432,534,5,346435231,14436467,7869299,76326614,167548585,
365 85525151,0,12321,1,349528352};
366 int test2size=21;
367
368 static unsigned long testbuffer3[]=
369 {1,0,14,0,1,0,12,0,1,0,0,0,1,1,0,1,0,1,0,1,0,1,0,1,0,1,0,0,1,1,1,1,1,0,0,1,
370 0,1,30,1,1,1,0,0,1,0,0,0,12,0,11,0,1,0,0,1};
371 int test3size=56;
372
373 static unsigned long large[]=
374 {2136531625L,2137861823,56732452,131,3212421,12325343,34547562,12313212,
375 1233432,534,5,2146435231,14436467,7869299,76326614,167548585,
376 85525151,0,12321,1,2146528352};
377
378 int onesize=33;
379 static int one[33]={146,25,44,151,195,15,153,176,233,131,196,65,85,172,47,40,
380 34,242,223,136,35,222,211,86,171,50,225,135,214,75,172,
381 223,4};
382
383 int twosize=6;
384 static int two[6]={61,255,255,251,231,29};
385
386 int threesize=54;
387 static int three[54]={169,2,232,252,91,132,156,36,89,13,123,176,144,32,254,
388 142,224,85,59,121,144,79,124,23,67,90,90,216,79,23,83,
389 58,135,196,61,55,129,183,54,101,100,170,37,127,126,10,
390 100,52,4,14,18,86,77,1};
391
392 int foursize=38;
393 static int four[38]={18,6,163,252,97,194,104,131,32,1,7,82,137,42,129,11,72,
394 132,60,220,112,8,196,109,64,179,86,9,137,195,208,122,169,
395 28,2,133,0,1};
396
397 int fivesize=45;
398 static int five[45]={169,2,126,139,144,172,30,4,80,72,240,59,130,218,73,62,
399 241,24,210,44,4,20,0,248,116,49,135,100,110,130,181,169,
400 84,75,159,2,1,0,132,192,8,0,0,18,22};
401
402 int sixsize=7;
403 static int six[7]={17,177,170,242,169,19,148};
404
405 /* Test read/write together */
406 /* Later we test against pregenerated bitstreams */
407 bs=ogg_buffer_create();
408
409 fprintf(stderr,"\nSmall preclipped packing (LSb): ");
410 cliptest(testbuffer1,test1size,0,one,onesize);
411 fprintf(stderr,"ok.");
412
413 fprintf(stderr,"\nNull bit call (LSb): ");
414 cliptest(testbuffer3,test3size,0,two,twosize);
415 fprintf(stderr,"ok.");
416
417 fprintf(stderr,"\nLarge preclipped packing (LSb): ");
418 cliptest(testbuffer2,test2size,0,three,threesize);
419 fprintf(stderr,"ok.");
420
421 fprintf(stderr,"\n32 bit preclipped packing (LSb): ");
422
423 or=ogg_buffer_alloc(bs,128);
424 for(i=0;i<test2size;i++){
425 or->buffer->data[i*4] = large[i]&0xff;
426 or->buffer->data[i*4+1] = (large[i]>>8)&0xff;
427 or->buffer->data[i*4+2] = (large[i]>>16)&0xff;
428 or->buffer->data[i*4+3] = (large[i]>>24)&0xff;
429 }
430 or->length=test2size*4;
431 oggpack_readinit(&r,or);
432 for(i=0;i<test2size;i++){
433 unsigned long test;
434 if((test=oggpack_look(&r,32))==0xffffffffUL)report("out of data. failed!");
435 if(test!=large[i]){
436 fprintf(stderr,"%ld != %ld (%lx!=%lx):",test,large[i],
437 test,large[i]);
438 report("read incorrect value!\n");
439 }
440 oggpack_adv(&r,32);
441 }
442 ogg_buffer_release(or);
443 if(oggpack_bytes(&r)!=test2size*4)report("leftover bytes after read!\n");
444 fprintf(stderr,"ok.");
445
446 fprintf(stderr,"\nSmall unclipped packing (LSb): ");
447 cliptest(testbuffer1,test1size,7,four,foursize);
448 fprintf(stderr,"ok.");
449
450 fprintf(stderr,"\nLarge unclipped packing (LSb): ");
451 cliptest(testbuffer2,test2size,17,five,fivesize);
452 fprintf(stderr,"ok.");
453
454 fprintf(stderr,"\nSingle bit unclipped packing (LSb): ");
455 cliptest(testbuffer3,test3size,1,six,sixsize);
456 fprintf(stderr,"ok.");
457
458 fprintf(stderr,"\nTesting read past end (LSb): ");
459 {
460 unsigned char dda[]={0,0,0,0};
461 ogg_buffer lob={dda,8,0,{0}};
462 ogg_reference lor={&lob,0,8,0};
463
464 oggpack_readinit(&r,&lor);
465 for(i=0;i<64;i++){
466 if(oggpack_read(&r,1)<0){
467 fprintf(stderr,"failed; got -1 prematurely.\n");
468 exit(1);
469 }
470 }
471 if(oggpack_look(&r,1)!=-1 ||
472 oggpack_read(&r,1)!=-1){
473 fprintf(stderr,"failed; read past end without -1.\n");
474 exit(1);
475 }
476 }
477 {
478 unsigned char dda[]={0,0,0,0};
479 ogg_buffer lob={dda,8,0,{0}};
480 ogg_reference lor={&lob,0,8,0};
481 unsigned long test;
482
483 oggpack_readinit(&r,&lor);
484 if((test=oggpack_read(&r,30))==0xffffffffUL ||
485 (test=oggpack_read(&r,16))==0xffffffffUL){
486 fprintf(stderr,"failed 2; got -1 prematurely.\n");
487 exit(1);
488 }
489
490 if((test=oggpack_look(&r,18))==0xffffffffUL){
491 fprintf(stderr,"failed 3; got -1 prematurely.\n");
492 exit(1);
493 }
494 if((test=oggpack_look(&r,19))!=0xffffffffUL){
495 fprintf(stderr,"failed; read past end without -1.\n");
496 exit(1);
497 }
498 if((test=oggpack_look(&r,32))!=0xffffffffUL){
499 fprintf(stderr,"failed; read past end without -1.\n");
500 exit(1);
501 }
502 }
503 fprintf(stderr,"ok.\n");
504
505 /* now the scary shit: randomized testing */
506
507 for(i=0;i<10000;i++){
508 long j,count=0,count2=0,bitcount=0;
509 unsigned long values[TESTWORDS];
510 int len[TESTWORDS];
511 unsigned char flat[4*TESTWORDS]; /* max possible needed size */
512
513 memset(flat,0,sizeof(flat));
514 fprintf(stderr,"\rRandomized testing (LSb)... (%ld) ",10000-i);
515
516 /* generate a list of words and lengths */
517 /* write the required number of bits out to packbuffer */
518 {
519 long word=0;
520 long bit=0;
521 int k;
522
523 for(j=0;j<TESTWORDS;j++){
524 values[j]=rand();
525 len[j]=(rand()%33);
526
527 for(k=0;k<len[j];k++){
528 flat[word] |= ((values[j]>>k)&0x1)<<bit;
529 bit++;
530 bitcount++;
531 if(bit>7){
532 bit=0;
533 word++;
534 }
535 }
536 }
537 }
538 count2=(bitcount+7)>>3;
539
540 /* construct random-length buffer chain from flat vector; random
541 byte starting offset within the length of the vector */
542 {
543 ogg_reference *or=NULL,*orl=NULL;
544 long pos=0;
545
546 /* build buffer chain */
547 while(count2){
548 int ilen=(rand()%32),k;
549 int ibegin=(rand()%32);
550
551
552 if(ilen>count2)ilen=count2;
553
554 if(or)
555 orl=ogg_buffer_extend(orl,64);
556 else
557 or=orl=ogg_buffer_alloc(bs,64);
558
559 orl->length=ilen;
560 orl->begin=ibegin;
561
562 for(k=0;k<ilen;k++)
563 orl->buffer->data[ibegin++]= flat[pos++];
564
565 count2-=ilen;
566 }
567
568 if(ogg_buffer_length(or)!=(bitcount+7)/8){
569 fprintf(stderr,"\nERROR: buffer length incorrect after build.\n");
570 exit(1);
571 }
572
573
574 {
575 int begin=0; //=(rand()%TESTWORDS);
576 int ilen=(rand()%(TESTWORDS-begin));
577 int bitoffset,bitcount=0;
578 unsigned long temp;
579
580 for(j=0;j<begin;j++)
581 bitcount+=len[j];
582 or=ogg_buffer_pretruncate(or,bitcount/8);
583 bitoffset=bitcount%=8;
584 for(;j<begin+ilen;j++)
585 bitcount+=len[j];
586 ogg_buffer_posttruncate(or,((bitcount+7)/8));
587
588 if((count=ogg_buffer_length(or))!=(bitcount+7)/8){
589 fprintf(stderr,"\nERROR: buffer length incorrect after truncate.\n");
590 exit(1);
591 }
592
593 oggpack_readinit(&o,or);
594
595 /* verify bit count */
596 if(oggpack_bits(&o)!=0){
597 fprintf(stderr,"\nERROR: Read bitcounter not zero!\n");
598 exit(1);
599 }
600 if(oggpack_bytes(&o)!=0){
601 fprintf(stderr,"\nERROR: Read bytecounter not zero!\n");
602 exit(1);
603 }
604
605 bitcount=bitoffset;
606 oggpack_read(&o,bitoffset);
607
608 /* read and compare to original list */
609 for(j=begin;j<begin+ilen;j++){
610 temp=oggpack_read(&o,len[j]);
611 if(temp==0xffffffffUL){
612 fprintf(stderr,"\nERROR: End of stream too soon! word: %ld,%d\n",
613 j-begin,ilen);
614 exit(1);
615 }
616 if(temp!=(values[j]&mask[len[j]])){
617 fprintf(stderr,"\nERROR: Incorrect read %lx != %lx, word %ld, len %d\n"
618 ,
619 values[j]&mask[len[j]],temp,j-begin,len[j]);
620 exit(1);
621 }
622 bitcount+=len[j];
623 if(oggpack_bits(&o)!=bitcount){
624 fprintf(stderr,"\nERROR: Read bitcounter %d != %ld!\n",
625 bitcount,oggpack_bits(&o));
626 exit(1);
627 }
628 if(oggpack_bytes(&o)!=(bitcount+7)/8){
629 fprintf(stderr,"\nERROR: Read bytecounter %d != %ld!\n",
630 (bitcount+7)/8,oggpack_bytes(&o));
631 exit(1);
632 }
633
634 }
635 _end_verify(count);
636
637 /* look/adv version */
638 oggpack_readinit(&o,or);
639 bitcount=bitoffset;
640 oggpack_adv(&o,bitoffset);
641
642 /* read and compare to original list */
643 for(j=begin;j<begin+ilen;j++){
644 temp=oggpack_look(&o,len[j]);
645
646 if(temp==0xffffffffUL){
647 fprintf(stderr,"\nERROR: End of stream too soon! word: %ld\n",
648 j-begin);
649 exit(1);
650 }
651 if(temp!=(values[j]&mask[len[j]])){
652 fprintf(stderr,"\nERROR: Incorrect look %lx != %lx, word %ld, len %d\n"
653 ,
654 values[j]&mask[len[j]],temp,j-begin,len[j]);
655 exit(1);
656 }
657 oggpack_adv(&o,len[j]);
658 bitcount+=len[j];
659 if(oggpack_bits(&o)!=bitcount){
660 fprintf(stderr,"\nERROR: Look/Adv bitcounter %d != %ld!\n",
661 bitcount,oggpack_bits(&o));
662 exit(1);
663 }
664 if(oggpack_bytes(&o)!=(bitcount+7)/8){
665 fprintf(stderr,"\nERROR: Look/Adv bytecounter %d != %ld!\n",
666 (bitcount+7)/8,oggpack_bytes(&o));
667 exit(1);
668 }
669
670 }
671 _end_verify2(count);
672
673 }
674 ogg_buffer_release(or);
675 }
676 }
677 fprintf(stderr,"\rRandomized testing (LSb)... ok. \n");
678
679 return(0);
680 }
681 #endif
682