trees.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #ifndef TREES_H_
  2. #define TREES_H_
  3. /* Constants */
  4. #define DIST_CODE_LEN 512
  5. /* see definition of array dist_code in trees.c */
  6. #define MAX_BL_BITS 7
  7. /* Bit length codes must not exceed MAX_BL_BITS bits */
  8. #define REP_3_6 16
  9. /* repeat previous bit length 3-6 times (2 bits of repeat count) */
  10. #define REPZ_3_10 17
  11. /* repeat a zero length 3-10 times (3 bits of repeat count) */
  12. #define REPZ_11_138 18
  13. /* repeat a zero length 11-138 times (7 bits of repeat count) */
  14. static const int extra_lbits[LENGTH_CODES] /* extra bits for each length code */
  15. = {0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0};
  16. static const int extra_dbits[D_CODES] /* extra bits for each distance code */
  17. = {0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13};
  18. static const int extra_blbits[BL_CODES] /* extra bits for each bit length code */
  19. = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7};
  20. static const unsigned char bl_order[BL_CODES]
  21. = {16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15};
  22. /* The lengths of the bit length codes are sent in order of decreasing
  23. * probability, to avoid transmitting the lengths for unused bit length codes.
  24. */
  25. /* Function definitions */
  26. void gen_codes (ct_data *tree, int max_code, uint16_t *bl_count);
  27. #endif