@@ -153,6 +153,22 @@ static BROTLI_INLINE size_t LiteralSpreeLengthForSparseSearch(
153153
154154 Where "q" is quality, "h" is hasher type, "b" is bucket bits,
155155 "l" is source len. */
156+
157+ #if defined(BROTLI_MAX_SIMD_QUALITY )
158+ static BROTLI_INLINE BROTLI_BOOL
159+ ShouldUseSimdHasher (const BrotliEncoderParams * params ) {
160+ if (params -> simd_hasher == BROTLI_SIMD_HASHER_DISABLE ) {
161+ return BROTLI_FALSE ;
162+ }
163+ int max_quality = BROTLI_MAX_RECOMMENDED_SIMD_QUALITY ;
164+
165+ if (params -> simd_hasher == BROTLI_SIMD_HASHER_ENABLE ) {
166+ max_quality = BROTLI_MAX_SIMD_QUALITY ;
167+ }
168+ return TO_BROTLI_BOOL (params -> quality <= max_quality );
169+ }
170+ #endif
171+
156172static BROTLI_INLINE void ChooseHasher (const BrotliEncoderParams * params ,
157173 BrotliHasherParams * hparams ) {
158174 if (params -> quality > 9 ) {
@@ -165,7 +181,7 @@ static BROTLI_INLINE void ChooseHasher(const BrotliEncoderParams* params,
165181 hparams -> type = params -> quality < 7 ? 40 : params -> quality < 9 ? 41 : 42 ;
166182 } else if (params -> size_hint >= (1 << 20 ) && params -> lgwin >= 19 ) {
167183#if defined(BROTLI_MAX_SIMD_QUALITY )
168- hparams -> type = params -> quality <= BROTLI_MAX_SIMD_QUALITY ? 68 : 6 ;
184+ hparams -> type = ShouldUseSimdHasher ( params ) ? 68 : 6 ;
169185#else
170186 hparams -> type = 6 ;
171187#endif
@@ -177,7 +193,7 @@ static BROTLI_INLINE void ChooseHasher(const BrotliEncoderParams* params,
177193 /* TODO(eustas): often previous setting (H6) is faster and denser; consider
178194 adding an option to use it. */
179195#if defined(BROTLI_MAX_SIMD_QUALITY )
180- hparams -> type = params -> quality <= BROTLI_MAX_SIMD_QUALITY ? 58 : 5 ;
196+ hparams -> type = ShouldUseSimdHasher ( params ) ? 58 : 5 ;
181197#else
182198 hparams -> type = 5 ;
183199#endif
0 commit comments