| 309 | } |
| 310 | |
| 311 | void BitpackDecoder::inBufferShiftDown() |
| 312 | { |
| 313 | // Move uneaten data down to beginning of inBuffer_. |
| 314 | // Keep on natural boundaries. |
| 315 | // Moves all of word that contains inBufferFirstBit. |
| 316 | size_t firstWord = inBufferFirstBit_ / bitsPerWord_; |
| 317 | size_t firstNaturalByte = firstWord * bytesPerWord_; |
| 318 | |
| 319 | #if VALIDATE_BASIC |
| 320 | if ( firstNaturalByte > inBufferEndByte_ ) |
| 321 | { |
| 322 | throw E57_EXCEPTION2( ErrorInternal, "firstNaturalByte=" + toString( firstNaturalByte ) + |
| 323 | " inBufferEndByte=" + toString( inBufferEndByte_ ) ); |
| 324 | } |
| 325 | #endif |
| 326 | size_t byteCount = inBufferEndByte_ - firstNaturalByte; |
| 327 | if ( byteCount > 0 ) |
| 328 | { |
| 329 | memmove( inBuffer_.data(), &inBuffer_[firstNaturalByte], |
| 330 | byteCount ); // Overlapping regions ok with memmove(). |
| 331 | } |
| 332 | |
| 333 | // Update indexes |
| 334 | inBufferEndByte_ = byteCount; |
| 335 | inBufferFirstBit_ = inBufferFirstBit_ % bitsPerWord_; |
| 336 | } |
| 337 | |
| 338 | #ifdef E57_ENABLE_DIAGNOSTIC_OUTPUT |
| 339 | void BitpackDecoder::dump( int indent, std::ostream &os ) |