1 /* Copyright 2017 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 /* (Transparent) Shared Dictionary definition. */ 8 9 #ifndef BROTLI_COMMON_SHARED_DICTIONARY_INTERNAL_H_ 10 #define BROTLI_COMMON_SHARED_DICTIONARY_INTERNAL_H_ 11 12 #include "dictionary.h" 13 #include <brotli/shared_dictionary.h> 14 #include "transform.h" 15 #include <brotli/types.h> 16 17 #if defined(__cplusplus) || defined(c_plusplus) 18 extern "C" { 19 #endif 20 21 struct BrotliSharedDictionaryStruct { 22 /* LZ77 prefixes (compound dictionary). */ 23 uint32_t num_prefix; /* max SHARED_BROTLI_MAX_COMPOUND_DICTS */ 24 size_t prefix_size[SHARED_BROTLI_MAX_COMPOUND_DICTS]; 25 const uint8_t* prefix[SHARED_BROTLI_MAX_COMPOUND_DICTS]; 26 27 /* If set, the context map is used to select word and transform list from 64 28 contexts, if not set, the context map is not used and only words[0] and 29 transforms[0] are to be used. */ 30 BROTLI_BOOL context_based; 31 32 uint8_t context_map[SHARED_BROTLI_NUM_DICTIONARY_CONTEXTS]; 33 34 /* Amount of word_list+transform_list combinations. */ 35 uint8_t num_dictionaries; 36 37 /* Must use num_dictionaries values. */ 38 const BrotliDictionary* words[SHARED_BROTLI_NUM_DICTIONARY_CONTEXTS]; 39 40 /* Must use num_dictionaries values. */ 41 const BrotliTransforms* transforms[SHARED_BROTLI_NUM_DICTIONARY_CONTEXTS]; 42 43 /* Amount of custom word lists. May be 0 if only Brotli's built-in is used */ 44 uint8_t num_word_lists; 45 46 /* Contents of the custom words lists. Must be NULL if num_word_lists is 0. */ 47 BrotliDictionary* words_instances; 48 49 /* Amount of custom transform lists. May be 0 if only Brotli's built-in is 50 used */ 51 uint8_t num_transform_lists; 52 53 /* Contents of the custom transform lists. Must be NULL if num_transform_lists 54 is 0. */ 55 BrotliTransforms* transforms_instances; 56 57 /* Concatenated prefix_suffix_maps of the custom transform lists. Must be NULL 58 if num_transform_lists is 0. */ 59 uint16_t* prefix_suffix_maps; 60 61 /* Memory management */ 62 brotli_alloc_func alloc_func; 63 brotli_free_func free_func; 64 void* memory_manager_opaque; 65 }; 66 67 typedef struct BrotliSharedDictionaryStruct BrotliSharedDictionaryInternal; 68 #define BrotliSharedDictionary BrotliSharedDictionaryInternal 69 70 #if defined(__cplusplus) || defined(c_plusplus) 71 } /* extern "C" */ 72 #endif 73 74 #endif /* BROTLI_COMMON_SHARED_DICTIONARY_INTERNAL_H_ */ 75