| 1 | /* Copyright 2015 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 | /* Hash table on the 4-byte prefixes of static dictionary words. */ |
| 8 | |
| 9 | #ifndef BROTLI_ENC_DICTIONARY_HASH_H_ |
| 10 | #define BROTLI_ENC_DICTIONARY_HASH_H_ |
| 11 | |
| 12 | #include "../common/platform.h" |
| 13 | #include "../common/static_init.h" |
| 14 | |
| 15 | #if (BROTLI_STATIC_INIT != BROTLI_STATIC_INIT_NONE) |
| 16 | #include "../common/dictionary.h" |
| 17 | #endif |
| 18 | |
| 19 | #if defined(__cplusplus) || defined(c_plusplus) |
| 20 | extern "C" { |
| 21 | #endif |
| 22 | |
| 23 | /* Bucket is (Hash14 * 2 + length_lt_8); in other words we reserve 2 buckets |
| 24 | for each hash - one for shorter words and one for longer words. */ |
| 25 | #define BROTLI_ENC_NUM_HASH_BUCKETS 32768 |
| 26 | |
| 27 | #if (BROTLI_STATIC_INIT != BROTLI_STATIC_INIT_NONE) |
| 28 | BROTLI_BOOL BROTLI_INTERNAL BrotliEncoderInitDictionaryHash( |
| 29 | const BrotliDictionary* dictionary, uint16_t* words, uint8_t* lengths); |
| 30 | BROTLI_INTERNAL extern BROTLI_MODEL("small") uint16_t |
| 31 | kStaticDictionaryHashWords[BROTLI_ENC_NUM_HASH_BUCKETS]; |
| 32 | BROTLI_INTERNAL extern BROTLI_MODEL("small") uint8_t |
| 33 | kStaticDictionaryHashLengths[BROTLI_ENC_NUM_HASH_BUCKETS]; |
| 34 | #else |
| 35 | BROTLI_INTERNAL extern const BROTLI_MODEL("small") uint16_t |
| 36 | kStaticDictionaryHashWords[BROTLI_ENC_NUM_HASH_BUCKETS]; |
| 37 | BROTLI_INTERNAL extern const BROTLI_MODEL("small") uint8_t |
| 38 | kStaticDictionaryHashLengths[BROTLI_ENC_NUM_HASH_BUCKETS]; |
| 39 | #endif |
| 40 | |
| 41 | #if defined(__cplusplus) || defined(c_plusplus) |
| 42 | } /* extern "C" */ |
| 43 | #endif |
| 44 | |
| 45 | #endif /* BROTLI_ENC_DICTIONARY_HASH_H_ */ |