| 373 | } |
| 374 | |
| 375 | inline void RleEncoder::FlushLiteralRun(bool update_indicator_byte) { |
| 376 | if (literal_indicator_byte_ == NULL) { |
| 377 | // The literal indicator byte has not been reserved yet, get one now. |
| 378 | literal_indicator_byte_ = bit_writer_.GetNextBytePtr(); |
| 379 | DCHECK(literal_indicator_byte_ != NULL); |
| 380 | } |
| 381 | |
| 382 | // Write all the buffered values as bit packed literals |
| 383 | for (int i = 0; i < num_buffered_values_; ++i) { |
| 384 | bool success = bit_writer_.PutValue(buffered_values_[i], bit_width_); |
| 385 | DCHECK(success) << "There is a bug in using CheckBufferFull()"; |
| 386 | } |
| 387 | num_buffered_values_ = 0; |
| 388 | |
| 389 | if (update_indicator_byte) { |
| 390 | // At this point we need to write the indicator byte for the literal run. |
| 391 | // We only reserve one byte, to allow for streaming writes of literal values. |
| 392 | // The logic makes sure we flush literal runs often enough to not overrun |
| 393 | // the 1 byte. |
| 394 | DCHECK_EQ(literal_count_ % 8, 0); |
| 395 | int num_groups = literal_count_ / 8; |
| 396 | int32_t indicator_value = (num_groups << 1) | 1; |
| 397 | DCHECK_EQ(indicator_value & 0xFFFFFF00, 0); |
| 398 | *literal_indicator_byte_ = indicator_value; |
| 399 | literal_indicator_byte_ = NULL; |
| 400 | literal_count_ = 0; |
| 401 | CheckBufferFull(); |
| 402 | } |
| 403 | } |
| 404 | |
| 405 | inline void RleEncoder::FlushRepeatedRun() { |
| 406 | DCHECK_GT(repeat_count_, 0); |
nothing calls this directly
no test coverage detected