constants.h 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. /* Copyright 2016 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. #ifndef BROTLI_COMMON_CONSTANTS_H_
  6. #define BROTLI_COMMON_CONSTANTS_H_
  7. /* Specification: 7.3. Encoding of the context map */
  8. #define BROTLI_CONTEXT_MAP_MAX_RLE 16
  9. /* Specification: 2. Compressed representation overview */
  10. #define BROTLI_MAX_NUMBER_OF_BLOCK_TYPES 256
  11. /* Specification: 3.3. Alphabet sizes: insert-and-copy length */
  12. #define BROTLI_NUM_LITERAL_SYMBOLS 256
  13. #define BROTLI_NUM_COMMAND_SYMBOLS 704
  14. #define BROTLI_NUM_BLOCK_LEN_SYMBOLS 26
  15. #define BROTLI_MAX_CONTEXT_MAP_SYMBOLS (BROTLI_MAX_NUMBER_OF_BLOCK_TYPES + \
  16. BROTLI_CONTEXT_MAP_MAX_RLE)
  17. #define BROTLI_MAX_BLOCK_TYPE_SYMBOLS (BROTLI_MAX_NUMBER_OF_BLOCK_TYPES + 2)
  18. /* Specification: 3.5. Complex prefix codes */
  19. #define BROTLI_REPEAT_PREVIOUS_CODE_LENGTH 16
  20. #define BROTLI_REPEAT_ZERO_CODE_LENGTH 17
  21. #define BROTLI_CODE_LENGTH_CODES (BROTLI_REPEAT_ZERO_CODE_LENGTH + 1)
  22. /* "code length of 8 is repeated" */
  23. #define BROTLI_INITIAL_REPEATED_CODE_LENGTH 8
  24. /* Specification: 4. Encoding of distances */
  25. #define BROTLI_NUM_DISTANCE_SHORT_CODES 16
  26. #define BROTLI_MAX_NPOSTFIX 3
  27. #define BROTLI_MAX_NDIRECT 120
  28. /* BROTLI_NUM_DISTANCE_SYMBOLS == 520 */
  29. #define BROTLI_NUM_DISTANCE_SYMBOLS (BROTLI_NUM_DISTANCE_SHORT_CODES + \
  30. BROTLI_MAX_NDIRECT + \
  31. (24 << (BROTLI_MAX_NPOSTFIX + 1)))
  32. /* 7.1. Context modes and context ID lookup for literals */
  33. /* "context IDs for literals are in the range of 0..63" */
  34. #define BROTLI_LITERAL_CONTEXT_BITS 6
  35. /* 7.2. Context ID for distances */
  36. #define BROTLI_DISTANCE_CONTEXT_BITS 2
  37. #endif /* BROTLI_COMMON_CONSTANTS_H_ */