| 1 | /* Copyright 2013 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 | #include "dictionary.h" |
| 8 | #include "platform.h" |
| 9 | |
| 10 | #if defined(__cplusplus) || defined(c_plusplus) |
| 11 | extern "C" { |
| 12 | #endif |
| 13 | |
| 14 | #if !defined(BROTLI_EXTERNAL_DICTIONARY_DATA) |
| 15 | /* Embed kBrotliDictionaryData */ |
| 16 | #include "dictionary_inc.h" |
| 17 | static const BROTLI_MODEL("small") BrotliDictionary kBrotliDictionary = { |
| 18 | #else |
| 19 | static BROTLI_MODEL("small") BrotliDictionary kBrotliDictionary = { |
| 20 | #endif |
| 21 | /* size_bits_by_length */ |
| 22 | { |
| 23 | 0, 0, 0, 0, 10, 10, 11, 11, |
| 24 | 10, 10, 10, 10, 10, 9, 9, 8, |
| 25 | 7, 7, 8, 7, 7, 6, 6, 5, |
| 26 | 5, 0, 0, 0, 0, 0, 0, 0 |
| 27 | }, |
| 28 | |
| 29 | /* offsets_by_length */ |
| 30 | { |
| 31 | 0, 0, 0, 0, 0, 4096, 9216, 21504, |
| 32 | 35840, 44032, 53248, 63488, 74752, 87040, 93696, 100864, |
| 33 | 104704, 106752, 108928, 113536, 115968, 118528, 119872, 121280, |
| 34 | 122016, 122784, 122784, 122784, 122784, 122784, 122784, 122784 |
| 35 | }, |
| 36 | |
| 37 | /* data_size == sizeof(kBrotliDictionaryData) */ |
| 38 | 122784, |
| 39 | |
| 40 | /* data */ |
| 41 | #if defined(BROTLI_EXTERNAL_DICTIONARY_DATA) |
| 42 | NULL |
| 43 | #else |
| 44 | kBrotliDictionaryData |
| 45 | #endif |
| 46 | }; |
| 47 | |
| 48 | const BrotliDictionary* BrotliGetDictionary(void) { |
| 49 | return &kBrotliDictionary; |
| 50 | } |
| 51 | |
| 52 | void BrotliSetDictionaryData(const uint8_t* data) { |
| 53 | #if defined(BROTLI_EXTERNAL_DICTIONARY_DATA) |
| 54 | if (!!data && !kBrotliDictionary.data) { |
| 55 | kBrotliDictionary.data = data; |
| 56 | } |
| 57 | #else |
| 58 | BROTLI_UNUSED(data); // Appease -Werror=unused-parameter |
| 59 | #endif |
| 60 | } |
| 61 | |
| 62 | #if defined(__cplusplus) || defined(c_plusplus) |
| 63 | } /* extern "C" */ |
| 64 | #endif |