Mercurial > libavcodec.hg
comparison snow.c @ 2240:c46fed9b7575 libavcodec
simplify getsymbol patch by (Loren Merritt <lorenm at u dot washington dot edu>)
author | michael |
---|---|
date | Fri, 17 Sep 2004 23:51:36 +0000 |
parents | 960e3552e418 |
children | c26038875ebc |
comparison
equal
deleted
inserted
replaced
2239:506fdbb9d19c | 2240:c46fed9b7575 |
---|---|
505 | 505 |
506 static inline int get_symbol(CABACContext *c, uint8_t *state, int is_signed){ | 506 static inline int get_symbol(CABACContext *c, uint8_t *state, int is_signed){ |
507 if(get_cabac(c, state+0)) | 507 if(get_cabac(c, state+0)) |
508 return 0; | 508 return 0; |
509 else{ | 509 else{ |
510 int i, e, a, el; | 510 int i, e, a; |
511 //FIXME try to merge loops with FFMIN() maybe they are equally fast and they are surly cuter | 511 e= 0; |
512 for(e=0; e<10; e++){ | 512 while(get_cabac(c, state+1 + FFMIN(e,9))){ //1..10 |
513 if(get_cabac(c, state + 1 + e)==0) // 1..10 | 513 e++; |
514 break; | 514 } |
515 } | 515 |
516 el= e; | |
517 | |
518 if(e==10){ | |
519 while(get_cabac(c, state + 1 + 9)) //10 | |
520 e++; | |
521 } | |
522 a= 1; | 516 a= 1; |
523 for(i=e-1; i>=el; i--){ | 517 for(i=e-1; i>=0; i--){ |
524 a += a + get_cabac(c, state+22+9); //31 | 518 a += a + get_cabac(c, state+22 + FFMIN(i,9)); //22..31 |
525 } | 519 } |
526 for(; i>=0; i--){ | 520 |
527 a += a + get_cabac(c, state+22+i); //22..31 | 521 if(is_signed && get_cabac(c, state+11 + FFMIN(e,10))) //11..21 |
528 } | |
529 | |
530 if(is_signed && get_cabac(c, state+11 + el)) //11..21 | |
531 return -a; | 522 return -a; |
532 else | 523 else |
533 return a; | 524 return a; |
534 } | 525 } |
535 } | 526 } |