feat(ricepp): another 15% decode speedup

This commit is contained in:
Marcus Holland-Moritz 2024-02-04 13:48:23 +01:00
parent 107a89425e
commit 4811199406

View File

@ -65,6 +65,10 @@ class bitstream_reader final {
size_t find_first_set() {
size_t zeros = 0;
if (bit_pos_ != 0) [[likely]] {
if (peek_bit()) [[likely]] {
skip_bits(1);
return zeros;
}
size_t const remaining_bits = kBitsTypeBits - bit_pos_;
bits_type const bits = peek_bits(remaining_bits);
size_t const ffs = std::countr_zero(bits);
@ -107,6 +111,11 @@ class bitstream_reader final {
}
}
bool peek_bit() {
assert(bit_pos_ > 0 && bit_pos_ < kBitsTypeBits);
return (data_ & (static_cast<bits_type>(1) << bit_pos_)) != 0;
}
bits_type peek_bits(size_t num_bits) {
assert(bit_pos_ + num_bits <= kBitsTypeBits);
if (bit_pos_ == 0) [[unlikely]] {