From 336cce52bf37de5d43629f16f57570286d26f3d7 Mon Sep 17 00:00:00 2001 From: Marcus Holland-Moritz Date: Sat, 10 Feb 2024 11:11:38 +0100 Subject: [PATCH] chore(ricepp): add comment to bitstream_reader --- ricepp/include/ricepp/bitstream_reader.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ricepp/include/ricepp/bitstream_reader.h b/ricepp/include/ricepp/bitstream_reader.h index 5068530b..a641d856 100644 --- a/ricepp/include/ricepp/bitstream_reader.h +++ b/ricepp/include/ricepp/bitstream_reader.h @@ -121,6 +121,12 @@ class bitstream_reader final { if (bit_pos_ == 0) [[unlikely]] { data_ = read_packet(); } + // The remainder of this function is equivalent to: + // + // return _bextr_u64(data_, bit_pos_, num_bits); + // + // However, in practice, at least clang generates code that is as fast + // as the intrinsic, so we use the following code for portability. bits_type bits = data_ >> bit_pos_; if (num_bits < kBitsTypeBits) [[likely]] { bits &= (static_cast(1) << num_bits) - 1;