static_dict.h 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. /* Copyright 2013 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. /* Class to model the static dictionary. */
  6. #ifndef BROTLI_ENC_STATIC_DICT_H_
  7. #define BROTLI_ENC_STATIC_DICT_H_
  8. #include "../common/dictionary.h"
  9. #include "../common/platform.h"
  10. #include <brotli/types.h>
  11. #include "./encoder_dict.h"
  12. #if defined(__cplusplus) || defined(c_plusplus)
  13. extern "C" {
  14. #endif
  15. #define BROTLI_MAX_STATIC_DICTIONARY_MATCH_LEN 37
  16. static const uint32_t kInvalidMatch = 0xFFFFFFF;
  17. /* Matches data against static dictionary words, and for each length l,
  18. for which a match is found, updates matches[l] to be the minimum possible
  19. (distance << 5) + len_code.
  20. Returns 1 if matches have been found, otherwise 0.
  21. Prerequisites:
  22. matches array is at least BROTLI_MAX_STATIC_DICTIONARY_MATCH_LEN + 1 long
  23. all elements are initialized to kInvalidMatch */
  24. BROTLI_INTERNAL BROTLI_BOOL BrotliFindAllStaticDictionaryMatches(
  25. const BrotliEncoderDictionary* dictionary,
  26. const uint8_t* data, size_t min_length, size_t max_length,
  27. uint32_t* matches);
  28. #if defined(__cplusplus) || defined(c_plusplus)
  29. } /* extern "C" */
  30. #endif
  31. #endif /* BROTLI_ENC_STATIC_DICT_H_ */