Updated Doxygen comments, removed an incorrectly placed LGPL header (we own
[opus.git] / libcelt / bitrdec.c
1 #ifdef HAVE_CONFIG_H
2 #include "config.h"
3 #endif
4
5 #include "bitree.h"
6
7 int ec_bitree_find_and_update(unsigned *_this,int _sz,int _split,
8  unsigned _freq,unsigned *_fl,int _val){
9   int base;
10   int test;
11   int fl;
12   base=-1;
13   fl=0;
14   while(_split>0){
15     test=base+_split;
16     if(test<_sz){
17       if(_freq>=_this[test]){
18         _freq-=_this[test];
19         fl+=_this[test];
20         base=test;
21       }
22       else _this[test]+=_val;
23     }
24     _split>>=1;
25   }
26   *_fl=fl;
27   return base+1;
28 }