Merge branch 'xenia-canary:canary_experimental' into command_processor_optimizations

This commit is contained in:
chrisps
2022-12-14 11:35:13 -08:00
committed by GitHub
4 changed files with 52 additions and 16 deletions

View File

@@ -29,6 +29,16 @@ void BitStream::SetOffset(size_t offset_bits) {
size_t BitStream::BitsRemaining() { return size_bits_ - offset_bits_; }
bool BitStream::IsOffsetValid(size_t num_bits) {
size_t offset_bytes = offset_bits_ >> 3;
size_t rel_offset_bits = offset_bits_ - (offset_bytes << 3);
if (rel_offset_bits && int32_t(num_bits - 8 - rel_offset_bits) < 0) {
return false;
}
return true;
}
uint64_t BitStream::Peek(size_t num_bits) {
// FYI: The reason we can't copy more than 57 bits is:
// 57 = 7 * 8 + 1 - that can only span a maximum of 8 bytes.

View File

@@ -28,6 +28,7 @@ class BitStream {
void Advance(size_t num_bits);
void SetOffset(size_t offset_bits);
size_t BitsRemaining();
bool IsOffsetValid(size_t num_bits);
// Note: num_bits MUST be in the range 0-57 (inclusive)
uint64_t Peek(size_t num_bits);