shared_dictionary_internal.h 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. /* Copyright 2017 Google Inc. All Rights Reserved.
  2. Distributed under MIT license.
  3. See file LICENSE for detail or copy at https://opensource.org/licenses/MIT
  4. */
  5. /* (Transparent) Shared Dictionary definition. */
  6. #ifndef BROTLI_COMMON_SHARED_DICTIONARY_INTERNAL_H_
  7. #define BROTLI_COMMON_SHARED_DICTIONARY_INTERNAL_H_
  8. #include <brotli/shared_dictionary.h>
  9. #include <brotli/types.h>
  10. #include "dictionary.h"
  11. #include "transform.h"
  12. #if defined(__cplusplus) || defined(c_plusplus)
  13. extern "C" {
  14. #endif
  15. struct BrotliSharedDictionaryStruct {
  16. /* LZ77 prefixes (compound dictionary). */
  17. uint32_t num_prefix; /* max SHARED_BROTLI_MAX_COMPOUND_DICTS */
  18. size_t prefix_size[SHARED_BROTLI_MAX_COMPOUND_DICTS];
  19. const uint8_t* prefix[SHARED_BROTLI_MAX_COMPOUND_DICTS];
  20. /* If set, the context map is used to select word and transform list from 64
  21. contexts, if not set, the context map is not used and only words[0] and
  22. transforms[0] are to be used. */
  23. BROTLI_BOOL context_based;
  24. uint8_t context_map[SHARED_BROTLI_NUM_DICTIONARY_CONTEXTS];
  25. /* Amount of word_list+transform_list combinations. */
  26. uint8_t num_dictionaries;
  27. /* Must use num_dictionaries values. */
  28. const BrotliDictionary* words[SHARED_BROTLI_NUM_DICTIONARY_CONTEXTS];
  29. /* Must use num_dictionaries values. */
  30. const BrotliTransforms* transforms[SHARED_BROTLI_NUM_DICTIONARY_CONTEXTS];
  31. /* Amount of custom word lists. May be 0 if only Brotli's built-in is used */
  32. uint8_t num_word_lists;
  33. /* Contents of the custom words lists. Must be NULL if num_word_lists is 0. */
  34. BrotliDictionary* words_instances;
  35. /* Amount of custom transform lists. May be 0 if only Brotli's built-in is
  36. used */
  37. uint8_t num_transform_lists;
  38. /* Contents of the custom transform lists. Must be NULL if num_transform_lists
  39. is 0. */
  40. BrotliTransforms* transforms_instances;
  41. /* Concatenated prefix_suffix_maps of the custom transform lists. Must be NULL
  42. if num_transform_lists is 0. */
  43. uint16_t* prefix_suffix_maps;
  44. /* Memory management */
  45. brotli_alloc_func alloc_func;
  46. brotli_free_func free_func;
  47. void* memory_manager_opaque;
  48. };
  49. typedef struct BrotliSharedDictionaryStruct BrotliSharedDictionaryInternal;
  50. #define BrotliSharedDictionary BrotliSharedDictionaryInternal
  51. #if defined(__cplusplus) || defined(c_plusplus)
  52. } /* extern "C" */
  53. #endif
  54. #endif /* BROTLI_COMMON_SHARED_DICTIONARY_INTERNAL_H_ */