diff options
-rw-r--r-- | c/enc/hash_longest_match64_inc.h | 12 | ||||
-rw-r--r-- | c/enc/hash_longest_match64_simd_inc.h | 12 | ||||
-rw-r--r-- | c/enc/hash_longest_match_inc.h | 12 | ||||
-rw-r--r-- | c/enc/hash_longest_match_simd_inc.h | 12 | ||||
-rw-r--r-- | c/enc/quality.h | 4 |
5 files changed, 34 insertions, 18 deletions
diff --git a/c/enc/hash_longest_match64_inc.h b/c/enc/hash_longest_match64_inc.h index 7e0b2f5..bdbb30a 100644 --- a/c/enc/hash_longest_match64_inc.h +++ b/c/enc/hash_longest_match64_inc.h @@ -192,8 +192,10 @@ static BROTLI_INLINE void FN(FindLongestMatch)( } prev_ix &= ring_buffer_mask; - if (cur_ix_masked + best_len > ring_buffer_mask || - prev_ix + best_len > ring_buffer_mask || + if (cur_ix_masked + best_len > ring_buffer_mask) { + break; + } + if (prev_ix + best_len > ring_buffer_mask || data[cur_ix_masked + best_len] != data[prev_ix + best_len]) { continue; } @@ -239,8 +241,10 @@ static BROTLI_INLINE void FN(FindLongestMatch)( break; } prev_ix &= ring_buffer_mask; - if (cur_ix_masked + best_len > ring_buffer_mask || - prev_ix + best_len > ring_buffer_mask || + if (cur_ix_masked + best_len > ring_buffer_mask) { + break; + } + if (prev_ix + best_len > ring_buffer_mask || /* compare 4 bytes ending at best_len + 1 */ BrotliUnalignedRead32(&data[cur_ix_masked + best_len - 3]) != BrotliUnalignedRead32(&data[prev_ix + best_len - 3])) { diff --git a/c/enc/hash_longest_match64_simd_inc.h b/c/enc/hash_longest_match64_simd_inc.h index cd4e7b1..12bd8cf 100644 --- a/c/enc/hash_longest_match64_simd_inc.h +++ b/c/enc/hash_longest_match64_simd_inc.h @@ -209,8 +209,10 @@ static BROTLI_INLINE void FN(FindLongestMatch)( } prev_ix &= ring_buffer_mask; - if (cur_ix_masked + best_len > ring_buffer_mask || - prev_ix + best_len > ring_buffer_mask || + if (cur_ix_masked + best_len > ring_buffer_mask) { + break; + } + if (prev_ix + best_len > ring_buffer_mask || data[cur_ix_masked + best_len] != data[prev_ix + best_len]) { continue; } @@ -263,8 +265,10 @@ static BROTLI_INLINE void FN(FindLongestMatch)( break; } prev_ix &= ring_buffer_mask; - if (cur_ix_masked + best_len > ring_buffer_mask || - prev_ix + best_len > ring_buffer_mask || + if (cur_ix_masked + best_len > ring_buffer_mask) { + break; + } + if (prev_ix + best_len > ring_buffer_mask || /* compare 4 bytes ending at best_len + 1 */ BrotliUnalignedRead32(&data[cur_ix_masked + best_len - 3]) != BrotliUnalignedRead32(&data[prev_ix + best_len - 3])) { diff --git a/c/enc/hash_longest_match_inc.h b/c/enc/hash_longest_match_inc.h index b744f4d..58e88b3 100644 --- a/c/enc/hash_longest_match_inc.h +++ b/c/enc/hash_longest_match_inc.h @@ -192,8 +192,10 @@ static BROTLI_INLINE void FN(FindLongestMatch)( } prev_ix &= ring_buffer_mask; - if (cur_ix_masked + best_len > ring_buffer_mask || - prev_ix + best_len > ring_buffer_mask || + if (cur_ix_masked + best_len > ring_buffer_mask) { + break; + } + if (prev_ix + best_len > ring_buffer_mask || data[cur_ix_masked + best_len] != data[prev_ix + best_len]) { continue; } @@ -234,8 +236,10 @@ static BROTLI_INLINE void FN(FindLongestMatch)( break; } prev_ix &= ring_buffer_mask; - if (cur_ix_masked + best_len > ring_buffer_mask || - prev_ix + best_len > ring_buffer_mask || + if (cur_ix_masked + best_len > ring_buffer_mask) { + break; + } + if (prev_ix + best_len > ring_buffer_mask || /* compare 4 bytes ending at best_len + 1 */ BrotliUnalignedRead32(&data[cur_ix_masked + best_len - 3]) != BrotliUnalignedRead32(&data[prev_ix + best_len - 3])) { diff --git a/c/enc/hash_longest_match_simd_inc.h b/c/enc/hash_longest_match_simd_inc.h index 2bf9b6c..79b341a 100644 --- a/c/enc/hash_longest_match_simd_inc.h +++ b/c/enc/hash_longest_match_simd_inc.h @@ -184,8 +184,10 @@ static BROTLI_INLINE void FN(FindLongestMatch)( } prev_ix &= ring_buffer_mask; - if (cur_ix_masked + best_len > ring_buffer_mask || - prev_ix + best_len > ring_buffer_mask || + if (cur_ix_masked + best_len > ring_buffer_mask) { + break; + } + if (prev_ix + best_len > ring_buffer_mask || data[cur_ix_masked + best_len] != data[prev_ix + best_len]) { continue; } @@ -235,8 +237,10 @@ static BROTLI_INLINE void FN(FindLongestMatch)( break; } prev_ix &= ring_buffer_mask; - if (cur_ix_masked + best_len > ring_buffer_mask || - prev_ix + best_len > ring_buffer_mask || + if (cur_ix_masked + best_len > ring_buffer_mask) { + break; + } + if (prev_ix + best_len > ring_buffer_mask || /* compare 4 bytes ending at best_len + 1 */ BrotliUnalignedRead32(&data[cur_ix_masked + best_len - 3]) != BrotliUnalignedRead32(&data[prev_ix + best_len - 3])) { diff --git a/c/enc/quality.h b/c/enc/quality.h index 4fe649e..1065f23 100644 --- a/c/enc/quality.h +++ b/c/enc/quality.h @@ -194,14 +194,14 @@ static BROTLI_INLINE void ChooseHasher(const BrotliEncoderParams* params, hasher already works well with large window. So the changes are: H3 --> H35: for quality 3. H54 --> H55: for quality 4 with size hint > 1MB - H6 --> H65: for qualities 5, 6, 7, 8, 9. */ + H6/H68 --> H65: for qualities 5, 6, 7, 8, 9. */ if (hparams->type == 3) { hparams->type = 35; } if (hparams->type == 54) { hparams->type = 55; } - if (hparams->type == 6) { + if (hparams->type == 6 || hparams->type == 68) { hparams->type = 65; } } |