home *** CD-ROM | disk | FTP | other *** search
/ Club Amiga de Montreal - CAM / CAM_CD_1.iso / files / 617a.lha / Freeze_alpha / README < prev    next >
Text File  |  1992-03-12  |  7KB  |  185 lines

  1.         FREEZE / MELT COMPRESSION PROGRAM
  2.  
  3. This is Alpha version. It is tested under ISC 2.2, Xenix, SunOS.
  4.  
  5. The following preprocessor symbols control the compilation of Freeze
  6. package:
  7.  
  8.     o BITS                  The size of hash table (default is 18,
  9.                 reducing to 14 gives a 50% speeddown).
  10.     o COMPAT                Turns on backwards compatibility
  11.                 with Freeze 1.0
  12.     o M_XENIX & M_I286      Makes arrays < 65536 bytes each
  13.     o BSD4_2        Allow long filenames ( > 14 characters) &
  14.                 Call setlinebuf(stderr)
  15.     o INT_SIG               signal is int (*)() unstead of void
  16.     o MSDOS                 Turns off some UNIX-dependencies
  17.                 and MSDOS' ones - vice versa
  18.                 !!! It's important !!!
  19.                 If your MSDOS' C compiler do support
  20.                 inline functions, define DO_INLINE.
  21.                 This will cause the main loop to be
  22.                 replaced with a call of memcmp, which
  23.                 will be represented as 'repz cmpsb'.
  24.     o FAST                  Forces the Get_Next_Match routine
  25.                 to be inline. This gives additional
  26.                 percents of speedup.
  27.     o __TURBOC__            For compiling under TURBO C
  28.  
  29.     o __i386__              When compiling under GNU C causes
  30.                 some fixed register allocations,
  31.                 which give better code.
  32.  
  33. Please! If your computer supports the string operations, try to write
  34. "asm" instructions (GNU style) which realize the right-to-left memory
  35. comparison (s1, s2, length) in minimum number of clock cycles.
  36. If a noticeable (5% or more) speedup is gained, please send me a message.
  37.  
  38. Other preprocessor symbols (DEBUG, GATHER_STAT) are for internal use
  39. only.
  40.  
  41. The format of frozen (2.X) file is incompatible with that of frozen (1.0),
  42. but if this package is compiled with -DCOMPAT switch, you will able to
  43. unpack frozen (1.0) files, if you have them.
  44.  
  45. ----
  46.  
  47.     The format of a frozen file is as follows:
  48.     (version 1.0 had only 2-bytes header)
  49.  
  50. offset    type      value    comment
  51.   0       byte       037     2 byte magic header
  52.   1       byte       0237    (version 1.0 - 0236)
  53.   2       short       X      (little endian)
  54.   4       byte        Y
  55.  
  56. X = 0 e e e e e d d d d c c c b b a   \
  57.                        > [a-f] are binary digits
  58. Y = 0 0 f f f f f f                   /
  59.  
  60. a - number of 1-bit static Huffman codes in the `matching positions'
  61. table (see freeze.1)
  62. bb - number of 2-bit codes,
  63.     etc.
  64.  
  65. The numbers of 7- and 8-bits codes are evaluated from the
  66. conditions: sum(codes) = 62(dec), max code = 1111111(bin).
  67.  
  68. The default values are: 0 1 1 1 4 10 27 18, what means:
  69. no 1-bit codes,
  70. one 2-bit, 3-bit and 4-bit codes, etc., so Huffman codes are:
  71. 00, 010, 0110, 01110, 01111, 10000, .... , 11111111.
  72.  
  73. ------------------- !!!!!!!!!! -----------------
  74.  
  75. (If you do not deal with compression algorithms, you may skip
  76. until asterisks.)
  77.  
  78. General format of frozen file is:
  79.  
  80. magic header - table description - stream of bits
  81.  
  82. The stream of bits is considered as a sequence of variable length dynamic
  83. Huffman codes (if their values are in the range of 0-255, they mean single
  84. bytes, special value of 256 means EOF, and further values mean the lengths
  85. of matched string.) If we have the value greater than 256, we get a static
  86. Huffman code from the stream (his value is 6 higher bits of matched
  87. string's position in the buffer), and then we get 7 bits literally.
  88.  
  89. Because buffer length is 8192 bytes and maximum match length is 256 bytes,
  90. the position of matched string cannot be greater than 8192-256, that's why
  91. there is only (8192-256)/2^7 = 62 static codes.
  92.  
  93.             *        *       *
  94.  
  95. The default table is tuned for both C texts and executable files (as in
  96. LHARC). If you freeze any other files (databases, images, fonts,
  97. etc.) you can calculate the matching positions distribution using the
  98. `statist' program, which calculates and displays the mentioned
  99. distribution for the given file. It is useful for large (100K or more)
  100. files.
  101.  
  102. Though the built-in position table is polyvalent, the tuning can increase
  103. the compression rate up to one additional percent.  (Or even more, if the
  104. matching strings distribution is very bizarre!)
  105.  
  106. Usage: statist < sample_file ; you can also see the intermediate values
  107. and watch their changes by pressing INTR key when you wish.
  108.  
  109. Note: If you use "gensample | statist", remember that INTR influence BOTH
  110. processes !!
  111.  
  112. Sometimes `statist' can output the string "not enough information".
  113. This means it cannot build the appropriate static Huffman table
  114. (the given file is too trivial or random).
  115.  
  116. You may create the /etc/default/freeze file (if you don't like
  117. /etc/default/ directory, choose another - in MS-DOS it is FREEZE.CNF in
  118. the directory of FREEZE.EXE), which has the following format:  name =
  119. ``statist's output (8 numbers)'', f.ex.:
  120.  
  121. ---------- cut here -----------
  122. # This is freeze's defaults file
  123. gif =   0 0 0 0 2 60 0 0        # This is NOT! an optimal data
  124.                 # for GIF files
  125. doc=0 0 1 2 7 16 36 0           # The sample was gcc.lp
  126. # End of file
  127. ---------- cut here -----------
  128.  
  129. If you find values which are better THAN DEFAULT both for text (C
  130. programs) and binary (executable) files, please send them to me.
  131.  
  132. Important note: statist.c is NOT a part of freeze package, it is an
  133. additional feature.
  134.  
  135. ------------------- LINT ----------------------------
  136.  
  137. Lint complains about MANY `constant in conditional context', but ALL these
  138. contexts aren't `conditional', because they are unconditional (!)
  139. expressions:
  140.  
  141. #define BITS 18
  142. . . .
  143. #define LEN0    (BITS/3 + (BITS%3 != 0))
  144. . . .
  145.     ... + (key[0] >> LEN0) ....
  146.  
  147. Do you think about /*CONDITIONAL*/ pseudo-comment for lint?
  148.  
  149. Other lint's complaints about `used/declared inconsistently' are (in my
  150. case) due to inconsistencies of /usr/include/* and /usr/lib/llib*ln. It
  151. isn't dangerous.
  152.  
  153. ------------------- BUGS ----------------------------
  154.  
  155. Please send descriptions of found bugs, incompatibilities, etc.  to
  156. leo@s514.ipmce.su.  MS-DOS version will not be supported in future
  157. versions !!  (If they will be :-) )
  158.  
  159. ------------ SPEED & COMPRESSION RATE ---------------
  160.  
  161. When using 18 bits table (about 600K) and gcc, the speed of freeze is more
  162. than the same of ARJ 1.00, but is less than of LHA 2.05.
  163.  
  164. Note: the percents mean 'relatively to compressed size', if you want
  165. to have them relatively to original size, divide them to 2-2.5.
  166.  
  167. Compression rate is *INDEPENDENT* of the hash table size, but may vary
  168. with different static Huffman tables.  It is about 2% worse than the same
  169. of ARJ 1.00 and LHA 2.05, but ARJ 2.00 beats Freeze on 8%.
  170.  
  171. Note: if you see Compress works nearly as Freeze (on some files), this
  172. means the maximum is gained, so LHA and ARJ won't better more than
  173. 1-1.5%.
  174.  
  175. --------------- POSSIBLE IMPROVEMENTS ---------------
  176.  
  177. The high-level routines (freeze, melt) are almost independent from
  178. low-level routines (Get_Next_Match, Insert/Delete_Node,
  179. Encode/Decode_Char/Position), so if you want the speed and/or compression
  180. rate `a la vogue' you may replace the low-level routines with the homebrew
  181. (f. ex.) ones and enjoy the results.
  182.  
  183. (I tried to implement splay trees instead of Huffman ones and instead of
  184. static table for position information, but this gives nothing, alas.)
  185.