diff options
author | Eugene Kliuchnikov <eustas.ru@gmail.com> | 2021-06-23 09:40:57 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-06-23 09:40:57 +0200 |
commit | f8c671774514357abec2f6b14c8ee13c6fd885d3 (patch) | |
tree | fa1605f92feea7b851389d805b5bd8c1f010b636 /c | |
parent | bbe5d72ba37b164c4e8e0d7baeb78a22aa849c38 (diff) | |
download | brotli-f8c671774514357abec2f6b14c8ee13c6fd885d3.zip brotli-f8c671774514357abec2f6b14c8ee13c6fd885d3.tar.gz brotli-f8c671774514357abec2f6b14c8ee13c6fd885d3.tar.bz2 |
Update (#908)
* re-enable Js build/test
* improve decoder performance
* rewrite dictionary data in Java/Js to a shorter uncompressed form
* improve dictionary generation tool
Diffstat (limited to 'c')
-rw-r--r-- | c/dec/bit_reader.h | 50 |
1 files changed, 30 insertions, 20 deletions
diff --git a/c/dec/bit_reader.h b/c/dec/bit_reader.h index 22bc060..3906455 100644 --- a/c/dec/bit_reader.h +++ b/c/dec/bit_reader.h @@ -108,45 +108,55 @@ static BROTLI_INLINE void BrotliFillBitWindow( BrotliBitReader* const br, uint32_t n_bits) { #if (BROTLI_64_BITS) if (!BROTLI_ALIGNED_READ && BROTLI_IS_CONSTANT(n_bits) && (n_bits <= 8)) { - if (br->bit_pos_ >= 56) { - br->val_ >>= 56; - br->bit_pos_ ^= 56; /* here same as -= 56 because of the if condition */ - br->val_ |= BROTLI_UNALIGNED_LOAD64LE(br->next_in) << 8; + uint32_t bit_pos = br->bit_pos_; + if (bit_pos >= 56) { + br->val_ = + (br->val_ >> 56) | (BROTLI_UNALIGNED_LOAD64LE(br->next_in) << 8); + br->bit_pos_ = + bit_pos ^ 56; /* here same as -= 56 because of the if condition */ br->avail_in -= 7; br->next_in += 7; } } else if ( !BROTLI_ALIGNED_READ && BROTLI_IS_CONSTANT(n_bits) && (n_bits <= 16)) { - if (br->bit_pos_ >= 48) { - br->val_ >>= 48; - br->bit_pos_ ^= 48; /* here same as -= 48 because of the if condition */ - br->val_ |= BROTLI_UNALIGNED_LOAD64LE(br->next_in) << 16; + uint32_t bit_pos = br->bit_pos_; + if (bit_pos >= 48) { + br->val_ = + (br->val_ >> 48) | (BROTLI_UNALIGNED_LOAD64LE(br->next_in) << 16); + br->bit_pos_ = + bit_pos ^ 48; /* here same as -= 48 because of the if condition */ br->avail_in -= 6; br->next_in += 6; } } else { - if (br->bit_pos_ >= 32) { - br->val_ >>= 32; - br->bit_pos_ ^= 32; /* here same as -= 32 because of the if condition */ - br->val_ |= ((uint64_t)BROTLI_UNALIGNED_LOAD32LE(br->next_in)) << 32; + uint32_t bit_pos = br->bit_pos_; + if (bit_pos >= 32) { + br->val_ = (br->val_ >> 32) | + (((uint64_t)BROTLI_UNALIGNED_LOAD32LE(br->next_in)) << 32); + br->bit_pos_ = + bit_pos ^ 32; /* here same as -= 32 because of the if condition */ br->avail_in -= BROTLI_SHORT_FILL_BIT_WINDOW_READ; br->next_in += BROTLI_SHORT_FILL_BIT_WINDOW_READ; } } #else if (!BROTLI_ALIGNED_READ && BROTLI_IS_CONSTANT(n_bits) && (n_bits <= 8)) { - if (br->bit_pos_ >= 24) { - br->val_ >>= 24; - br->bit_pos_ ^= 24; /* here same as -= 24 because of the if condition */ - br->val_ |= BROTLI_UNALIGNED_LOAD32LE(br->next_in) << 8; + uint32_t bit_pos = br->bit_pos_; + if (bit_pos >= 24) { + br->val_ = + (br->val_ >> 24) | (BROTLI_UNALIGNED_LOAD32LE(br->next_in) << 8); + br->bit_pos_ = + bit_pos ^ 24; /* here same as -= 24 because of the if condition */ br->avail_in -= 3; br->next_in += 3; } } else { - if (br->bit_pos_ >= 16) { - br->val_ >>= 16; - br->bit_pos_ ^= 16; /* here same as -= 16 because of the if condition */ - br->val_ |= ((uint32_t)BROTLI_UNALIGNED_LOAD16LE(br->next_in)) << 16; + uint32_t bit_pos = br->bit_pos_; + if (bit_pos >= 16) { + br->val_ = (br->val_ >> 16) | + (((uint32_t)BROTLI_UNALIGNED_LOAD16LE(br->next_in)) << 16); + br->bit_pos_ = + bit_pos ^ 16; /* here same as -= 16 because of the if condition */ br->avail_in -= BROTLI_SHORT_FILL_BIT_WINDOW_READ; br->next_in += BROTLI_SHORT_FILL_BIT_WINDOW_READ; } |