find out symbol for a given cumulative frequency */ lt_f cumulative frequency */
| 217 | /* find out symbol for a given cumulative frequency */ |
| 218 | /* lt_f cumulative frequency */ |
| 219 | U32 RangeModel::getsym(U32 lt_f) |
| 220 | { |
| 221 | U32 lo, hi; |
| 222 | U16 *tmp; |
| 223 | tmp = search+(lt_f>>searchshift); |
| 224 | lo = *tmp; |
| 225 | hi = *(tmp+1) + 1; |
| 226 | while (lo+1 < hi ) |
| 227 | { |
| 228 | I32 mid = (lo+hi)>>1; |
| 229 | if (lt_f < cf[mid]) |
| 230 | { |
| 231 | hi = mid; |
| 232 | } |
| 233 | else |
| 234 | { |
| 235 | lo = mid; |
| 236 | } |
| 237 | } |
| 238 | return lo; |
| 239 | } |
| 240 | |
| 241 | /* update model */ |
| 242 | /* sym symbol that occurred (must be <n from init) */ |