| 574 | |
| 575 | template <typename T> |
| 576 | inline bool RleBatchDecoder<T>::SkipLiteralValues(int32_t num_literals_to_skip) { |
| 577 | DCHECK_GT(num_literals_to_skip, 0); |
| 578 | DCHECK_GE(literal_count_, num_literals_to_skip); |
| 579 | DCHECK(!HaveBufferedLiterals()); |
| 580 | |
| 581 | int32_t num_remaining = num_literals_to_skip; |
| 582 | |
| 583 | // Need to round to a batch of 32 if the caller is skipping only part of the current |
| 584 | // run to avoid ending on a non-byte boundary. |
| 585 | int32_t num_to_skip = std::min<int32_t>(literal_count_, |
| 586 | BitUtil::RoundDownToPowerOf2(num_remaining, 32)); |
| 587 | if (num_to_skip > 0) { |
| 588 | bool skipped = bit_reader_.SkipBatch(bit_width_, num_to_skip); |
| 589 | DCHECK(skipped); |
| 590 | literal_count_ -= num_to_skip; |
| 591 | num_remaining -= num_to_skip; |
| 592 | } |
| 593 | |
| 594 | if (num_remaining > 0) { |
| 595 | // Earlier we called RoundDownToPowerOf2() to skip literals that fit on byte boundary. |
| 596 | // But some literals still need to be skipped. Let's fill the literal buffer |
| 597 | // and skip 'num_remaining' values. |
| 598 | if (UNLIKELY(!FillLiteralBuffer())) return false; |
| 599 | if (SkipBufferedLiterals(num_remaining) != num_remaining) return false; |
| 600 | } |
| 601 | return true; |
| 602 | } |
| 603 | |
| 604 | template <typename T> |
| 605 | template <typename OutType> |