| 279 | } |
| 280 | |
| 281 | void BitStream::readBits(S32 bitCount, void *bitPtr) |
| 282 | { |
| 283 | if(!bitCount) |
| 284 | return; |
| 285 | if(bitCount + bitNum > maxReadBitNum) |
| 286 | { |
| 287 | error = true; |
| 288 | //AssertFatal(false, "Out of range read"); |
| 289 | AssertWarn(false, "Out of range read"); |
| 290 | return; |
| 291 | } |
| 292 | U8 *stPtr = mDataPtr + (bitNum >> 3); |
| 293 | S32 byteCount = (bitCount + 7) >> 3; |
| 294 | |
| 295 | U8 *ptr = (U8 *) bitPtr; |
| 296 | |
| 297 | S32 downShift = bitNum & 0x7; |
| 298 | S32 upShift = 8 - downShift; |
| 299 | |
| 300 | U8 curB = *stPtr; |
| 301 | const U8 *stEnd = mDataPtr + bufSize; |
| 302 | while(byteCount--) |
| 303 | { |
| 304 | stPtr++; |
| 305 | U8 nextB = stPtr < stEnd ? *stPtr : 0; |
| 306 | *ptr++ = (curB >> downShift) | (nextB << upShift); |
| 307 | curB = nextB; |
| 308 | } |
| 309 | |
| 310 | bitNum += bitCount; |
| 311 | } |
| 312 | |
| 313 | bool BitStream::_read(U32 size, void *dataPtr) |
| 314 | { |
no test coverage detected