| 224 | } |
| 225 | |
| 226 | void BitStream::writeBits(S32 bitCount, const void *bitPtr) |
| 227 | { |
| 228 | if(!bitCount) |
| 229 | return; |
| 230 | |
| 231 | if((bitCount + bitNum) > maxWriteBitNum) |
| 232 | { |
| 233 | error = true; |
| 234 | AssertFatal(false, avar("BitStream::writeBits - Out of range write [(%i+%i)/%i]", bitCount, bitNum, maxWriteBitNum)); |
| 235 | return; |
| 236 | } |
| 237 | |
| 238 | // [tom, 8/17/2006] This is probably a lot lamer then it needs to be. However, |
| 239 | // at least it doesnt clobber data or overrun the buffer like the old code did. |
| 240 | const U8 *ptr = (U8 *)bitPtr; |
| 241 | |
| 242 | for(S32 srcBitNum = 0;srcBitNum < bitCount;srcBitNum++) |
| 243 | { |
| 244 | if((*(ptr + (srcBitNum >> 3)) & (1 << (srcBitNum & 0x7))) != 0) |
| 245 | *(mDataPtr + (bitNum >> 3)) |= (1 << (bitNum & 0x7)); |
| 246 | else |
| 247 | *(mDataPtr + (bitNum >> 3)) &= ~(1 << (bitNum & 0x7)); |
| 248 | bitNum++; |
| 249 | } |
| 250 | } |
| 251 | |
| 252 | void BitStream::setBit(S32 bitCount, bool set) |
| 253 | { |
no test coverage detected