#ifndef BROTLI_COMMON_DICTIONARY_H_\r
#define BROTLI_COMMON_DICTIONARY_H_\r
\r
-#include "./types.h"\r
+#include <brotli/port.h>\r
+#include <brotli/types.h>\r
\r
#if defined(__cplusplus) || defined(c_plusplus)\r
extern "C" {\r
#endif\r
\r
-extern const uint8_t kBrotliDictionary[122784];\r
-extern const uint32_t kBrotliDictionaryOffsetsByLength[25];\r
-extern const uint8_t kBrotliDictionarySizeBitsByLength[25];\r
+typedef struct BrotliDictionary {\r
+ /**\r
+ * Number of bits to encode index of dictionary word in a bucket.\r
+ *\r
+ * Specification: Appendix A. Static Dictionary Data\r
+ *\r
+ * Words in a dictionary are bucketed by length.\r
+ * @c 0 means that there are no words of a given length.\r
+ * Dictionary consists of words with length of [4..24] bytes.\r
+ * Values at [0..3] and [25..31] indices should not be addressed.\r
+ */\r
+ uint8_t size_bits_by_length[32];\r
\r
-#define kBrotliMinDictionaryWordLength 4\r
-#define kBrotliMaxDictionaryWordLength 24\r
+ /* assert(offset[i + 1] == offset[i] + (bits[i] ? (i << bits[i]) : 0)) */\r
+ uint32_t offsets_by_length[32];\r
+\r
+ /* assert(data_size == offsets_by_length[31]) */\r
+ size_t data_size;\r
+\r
+ /* Data array is not bound, and should obey to size_bits_by_length values.\r
+ Specified size matches default (RFC 7932) dictionary. Its size is\r
+ defined by data_size */\r
+ const uint8_t* data;\r
+} BrotliDictionary;\r
+\r
+BROTLI_COMMON_API const BrotliDictionary* BrotliGetDictionary(void);\r
+\r
+/**\r
+ * Sets dictionary data.\r
+ *\r
+ * When dictionary data is already set / present, this method is no-op.\r
+ *\r
+ * Dictionary data MUST be provided before BrotliGetDictionary is invoked.\r
+ * This method is used ONLY in multi-client environment (e.g. C + Java),\r
+ * to reduce storage by sharing single dictionary between implementations.\r
+ */\r
+BROTLI_COMMON_API void BrotliSetDictionaryData(const uint8_t* data);\r
+\r
+#define BROTLI_MIN_DICTIONARY_WORD_LENGTH 4\r
+#define BROTLI_MAX_DICTIONARY_WORD_LENGTH 24\r
\r
#if defined(__cplusplus) || defined(c_plusplus)\r
} /* extern "C" */\r