Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

86 lines
3.0 KiB

  1. /*
  2. * stdenc.h
  3. *
  4. * Defines for the standard encoder
  5. */
  6. //
  7. // Size of hash table for std encoder
  8. //
  9. #define STD_ENCODER_HASH_TABLE_SIZE 8192
  10. #define STD_ENCODER_HASH_MASK (STD_ENCODER_HASH_TABLE_SIZE-1)
  11. #define STD_ENCODER_HASH_SHIFT 5
  12. #define STD_ENCODER_RECALCULATE_HASH(loc) \
  13. (((window[loc] << (2*STD_ENCODER_HASH_SHIFT)) ^ \
  14. (window[loc+1] << STD_ENCODER_HASH_SHIFT) ^ \
  15. (window[loc+2])) & STD_ENCODER_HASH_MASK)
  16. //
  17. // Maximum number of item we allow; this must be <= 65534, since this doesn't include
  18. // freq[END_OF_BLOCK_CODE] = 1, which brings us to 65535; any more than this would make
  19. // the frequency counts overflow, since they are stored in ushort's
  20. //
  21. // Note that this number does not affect the memory requirements in any way; that is
  22. // determined by LIT_DIST_BUFFER_SIZE
  23. //
  24. // -8 for some slack (not really necessary)
  25. //
  26. #define STD_ENCODER_MAX_ITEMS (65534-8)
  27. //
  28. // Size of the literal/distance buffer
  29. //
  30. #define STD_ENCODER_LIT_DIST_BUFFER_SIZE 32768
  31. //
  32. // Don't take a match 3 further away than this
  33. // BUGBUG 4K seems a little close, but does do a marginally better job than 8K on
  34. // an 80K html file, so might as well leave it be
  35. //
  36. #define STD_ENCODER_MATCH3_DIST_THRESHOLD 4096
  37. //
  38. // Standard encoder context
  39. //
  40. typedef struct std_encoder
  41. {
  42. // history window
  43. BYTE window[2*WINDOW_SIZE + MAX_MATCH + 4];
  44. // next most recent occurance of chars with same hash value
  45. t_search_node prev[WINDOW_SIZE + MAX_MATCH];
  46. // hash table to find most recent occurance of chars with same hash value
  47. t_search_node lookup[STD_ENCODER_HASH_TABLE_SIZE];
  48. // recording buffer for recording literals and distances
  49. BYTE lit_dist_buffer[STD_ENCODER_LIT_DIST_BUFFER_SIZE];
  50. unsigned long recording_bitbuf;
  51. unsigned long recording_bitcount;
  52. BYTE * recording_bufptr;
  53. short recording_dist_tree_table[REC_DISTANCES_DECODING_TABLE_SIZE];
  54. short recording_dist_tree_left[2*MAX_DIST_TREE_ELEMENTS];
  55. short recording_dist_tree_right[2*MAX_DIST_TREE_ELEMENTS];
  56. BYTE recording_dist_tree_len[MAX_DIST_TREE_ELEMENTS];
  57. USHORT recording_dist_tree_code[MAX_DIST_TREE_ELEMENTS];
  58. short recording_literal_tree_table[REC_LITERALS_DECODING_TABLE_SIZE];
  59. short recording_literal_tree_left[2*MAX_LITERAL_TREE_ELEMENTS];
  60. short recording_literal_tree_right[2*MAX_LITERAL_TREE_ELEMENTS];
  61. BYTE recording_literal_tree_len[MAX_LITERAL_TREE_ELEMENTS];
  62. USHORT recording_literal_tree_code[MAX_LITERAL_TREE_ELEMENTS];
  63. // literal trees
  64. USHORT literal_tree_freq[2*MAX_LITERAL_TREE_ELEMENTS];
  65. USHORT literal_tree_code[MAX_LITERAL_TREE_ELEMENTS];
  66. BYTE literal_tree_len[MAX_LITERAL_TREE_ELEMENTS];
  67. // dist trees
  68. USHORT dist_tree_freq[2*MAX_DIST_TREE_ELEMENTS];
  69. USHORT dist_tree_code[MAX_DIST_TREE_ELEMENTS];
  70. BYTE dist_tree_len[MAX_DIST_TREE_ELEMENTS];
  71. } t_std_encoder;