| 250 | } |
| 251 | |
| 252 | U32 ArithmeticDecoder::readBits(U32 bits) |
| 253 | { |
| 254 | assert(bits && (bits <= 32)); |
| 255 | |
| 256 | if (bits > 19) |
| 257 | { |
| 258 | U32 tmp = readShort(); |
| 259 | bits = bits - 16; |
| 260 | U32 tmp1 = readBits(bits) << 16; |
| 261 | return (tmp1|tmp); |
| 262 | } |
| 263 | |
| 264 | U32 sym = value / (length >>= bits);// decode symbol, change length |
| 265 | value -= length * sym; // update interval |
| 266 | |
| 267 | if (length < AC__MinLength) renorm_dec_interval(); // renormalization |
| 268 | |
| 269 | if (sym >= (1u<<bits)) |
| 270 | { |
| 271 | throw 4711; |
| 272 | } |
| 273 | |
| 274 | return sym; |
| 275 | } |
| 276 | |
| 277 | U8 ArithmeticDecoder::readByte() |
| 278 | { |