| 220 | } |
| 221 | |
| 222 | void ArithmeticEncoder::encodeSymbol(ArithmeticModel* m, U32 sym) |
| 223 | { |
| 224 | assert(m && (sym <= m->last_symbol)); |
| 225 | |
| 226 | U32 x, init_base = base; |
| 227 | // compute products |
| 228 | if (sym == m->last_symbol) { |
| 229 | x = m->distribution[sym] * (length >> DM__LengthShift); |
| 230 | base += x; // update interval |
| 231 | length -= x; // no product needed |
| 232 | } |
| 233 | else { |
| 234 | x = m->distribution[sym] * (length >>= DM__LengthShift); |
| 235 | base += x; // update interval |
| 236 | length = m->distribution[sym+1] * length - x; |
| 237 | } |
| 238 | |
| 239 | if (init_base > base) propagate_carry(); // overflow = carry |
| 240 | if (length < AC__MinLength) renorm_enc_interval(); // renormalization |
| 241 | |
| 242 | ++m->symbol_count[sym]; |
| 243 | if (--m->symbols_until_update == 0) m->update(); // periodic model update |
| 244 | } |
| 245 | |
| 246 | void ArithmeticEncoder::writeBit(U32 sym) |
| 247 | { |
no test coverage detected