/src/ghostpdl/brotli/c/enc/hash_base.h
Line | Count | Source |
1 | | /* Copyright 2025 Google Inc. All Rights Reserved. |
2 | | |
3 | | Distributed under MIT license. |
4 | | See file LICENSE for detail or copy at https://opensource.org/licenses/MIT |
5 | | */ |
6 | | |
7 | | /* Basic common hash functions / constants. */ |
8 | | |
9 | | #ifndef THIRD_PARTY_BROTLI_ENC_HASH_BASE_H_ |
10 | | #define THIRD_PARTY_BROTLI_ENC_HASH_BASE_H_ |
11 | | |
12 | | #include "../common/platform.h" |
13 | | |
14 | | /* kHashMul32 multiplier has these properties: |
15 | | * The multiplier must be odd. Otherwise we may lose the highest bit. |
16 | | * No long streaks of ones or zeros. |
17 | | * There is no effort to ensure that it is a prime, the oddity is enough |
18 | | for this use. |
19 | | * The number has been tuned heuristically against compression benchmarks. */ |
20 | | static const uint32_t kHashMul32 = 0x1E35A7BD; |
21 | | static const uint64_t kHashMul64 = |
22 | | BROTLI_MAKE_UINT64_T(0x1FE35A7Bu, 0xD3579BD3u); |
23 | | |
24 | 0 | static BROTLI_INLINE uint32_t Hash14(const uint8_t* data) { |
25 | 0 | uint32_t h = BROTLI_UNALIGNED_LOAD32LE(data) * kHashMul32; |
26 | | /* The higher bits contain more mixture from the multiplication, |
27 | | so we take our results from there. */ |
28 | 0 | return h >> (32 - 14); |
29 | 0 | } Unexecuted instantiation: encode.c:Hash14 Unexecuted instantiation: encoder_dict.c:Hash14 Unexecuted instantiation: backward_references.c:Hash14 Unexecuted instantiation: backward_references_hq.c:Hash14 Unexecuted instantiation: compress_fragment.c:Hash14 Unexecuted instantiation: compress_fragment_two_pass.c:Hash14 Unexecuted instantiation: static_dict.c:Hash14 |
30 | | |
31 | 0 | static BROTLI_INLINE uint32_t Hash15(const uint8_t* data) { |
32 | 0 | uint32_t h = BROTLI_UNALIGNED_LOAD32LE(data) * kHashMul32; |
33 | | /* The higher bits contain more mixture from the multiplication, |
34 | | so we take our results from there. */ |
35 | 0 | return h >> (32 - 15); |
36 | 0 | } Unexecuted instantiation: encode.c:Hash15 Unexecuted instantiation: encoder_dict.c:Hash15 Unexecuted instantiation: backward_references.c:Hash15 Unexecuted instantiation: backward_references_hq.c:Hash15 Unexecuted instantiation: compress_fragment.c:Hash15 Unexecuted instantiation: compress_fragment_two_pass.c:Hash15 Unexecuted instantiation: static_dict.c:Hash15 |
37 | | |
38 | | #endif // THIRD_PARTY_BROTLI_ENC_HASH_BASE_H_ |