histogram.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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. /* Models the histograms of literals, commands and distance codes. */
  6. #ifndef BROTLI_ENC_HISTOGRAM_H_
  7. #define BROTLI_ENC_HISTOGRAM_H_
  8. #include <string.h> /* memset */
  9. #include "../common/constants.h"
  10. #include "../common/context.h"
  11. #include "../common/platform.h"
  12. #include <brotli/types.h>
  13. #include "./block_splitter.h"
  14. #include "./command.h"
  15. #if defined(__cplusplus) || defined(c_plusplus)
  16. extern "C" {
  17. #endif
  18. /* The distance symbols effectively used by "Large Window Brotli" (32-bit). */
  19. #define BROTLI_NUM_HISTOGRAM_DISTANCE_SYMBOLS 544
  20. #define FN(X) X ## Literal
  21. #define DATA_SIZE BROTLI_NUM_LITERAL_SYMBOLS
  22. #define DataType uint8_t
  23. #include "./histogram_inc.h" /* NOLINT(build/include) */
  24. #undef DataType
  25. #undef DATA_SIZE
  26. #undef FN
  27. #define FN(X) X ## Command
  28. #define DataType uint16_t
  29. #define DATA_SIZE BROTLI_NUM_COMMAND_SYMBOLS
  30. #include "./histogram_inc.h" /* NOLINT(build/include) */
  31. #undef DATA_SIZE
  32. #undef FN
  33. #define FN(X) X ## Distance
  34. #define DATA_SIZE BROTLI_NUM_HISTOGRAM_DISTANCE_SYMBOLS
  35. #include "./histogram_inc.h" /* NOLINT(build/include) */
  36. #undef DataType
  37. #undef DATA_SIZE
  38. #undef FN
  39. BROTLI_INTERNAL void BrotliBuildHistogramsWithContext(
  40. const Command* cmds, const size_t num_commands,
  41. const BlockSplit* literal_split, const BlockSplit* insert_and_copy_split,
  42. const BlockSplit* dist_split, const uint8_t* ringbuffer, size_t pos,
  43. size_t mask, uint8_t prev_byte, uint8_t prev_byte2,
  44. const ContextType* context_modes, HistogramLiteral* literal_histograms,
  45. HistogramCommand* insert_and_copy_histograms,
  46. HistogramDistance* copy_dist_histograms);
  47. #if defined(__cplusplus) || defined(c_plusplus)
  48. } /* extern "C" */
  49. #endif
  50. #endif /* BROTLI_ENC_HISTOGRAM_H_ */