| 160 | } |
| 161 | |
| 162 | U32 ArithmeticDecoder::decodeBit(ArithmeticBitModel* m) |
| 163 | { |
| 164 | assert(m); |
| 165 | |
| 166 | U32 x = m->bit_0_prob * (length >> BM__LengthShift); // product l x p0 |
| 167 | U32 sym = (value >= x); // decision |
| 168 | // update & shift interval |
| 169 | if (sym == 0) { |
| 170 | length = x; |
| 171 | ++m->bit_0_count; |
| 172 | } |
| 173 | else { |
| 174 | value -= x; // shifted interval base = 0 |
| 175 | length -= x; |
| 176 | } |
| 177 | |
| 178 | if (length < AC__MinLength) renorm_dec_interval(); // renormalization |
| 179 | if (--m->bits_until_update == 0) m->update(); // periodic model update |
| 180 | |
| 181 | return sym; // return data bit value |
| 182 | } |
| 183 | |
| 184 | U32 ArithmeticDecoder::decodeSymbol(ArithmeticModel* m) |
| 185 | { |