home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / lzo100.zip / lzo-1.00 / doc / LZO.FAQ < prev    next >
Text File  |  1997-07-11  |  7KB  |  188 lines

  1. ============================================================================
  2. LZO Frequently Asked Questions
  3. ============================================================================
  4.  
  5.  
  6. Can you explain the naming conventions of the algorithms ?
  7. ==========================================================
  8.  
  9. Let's take a look at LZO1X:
  10.  
  11.      The algorithm name is LZO1X.
  12.      The algorithm category is LZO1.
  13.      Various compression levels are implemented.
  14.  
  15.      LZO1X-999
  16.         !---------- algorithm category
  17.          !--------- algorithm type
  18.            !!!----- compression level (1-9, 99, 999)
  19.  
  20.      LZO1X-1(11)
  21.         !---------- algorithm category
  22.          !--------- algorithm type
  23.            !------- compression level (1-9, 99, 999)
  24.              !!---- memory level (memory requirements for compression)
  25.  
  26. All compression/memory levels generate the same compressed data format,
  27. so e.g. the LZO1X decompressor handles all LZO1X-* compression levels
  28. (for more information about the decompressors see below).
  29.  
  30. Category LZO1 algorithms: compressed data format is strictly byte aligned
  31. Category LZO2 algorithms: uses bit-shifting, slower decompression
  32.  
  33.  
  34. Why are there so many algorithms ?
  35. ==================================
  36.  
  37. Because of historical reasons - I want to support unlimited
  38. backwards compatibility.
  39.  
  40. Don't get misleaded by the size of the library - using one algorithm
  41. increases the size of your application by only a few kB.
  42.  
  43. If you just want too add a little bit of data compression to your
  44. application you may be looking for miniLZO.
  45. See minilzo/00readme.txt for more information.
  46.  
  47.  
  48. Which algorithm should I use ?
  49. ==============================
  50.  
  51. LZO1X seems to be best choice in many cases, so:
  52. - when going for speed use LZO1X-1
  53. - when generating pre-compressed data use LZO1X-999
  54. - if you have little memory available for compression use LZO1X-1(11)
  55.  
  56. Of course, your mileage may vary, and you are encouraged to run your
  57. own experiments. Try LZO1Y and LZO1F next.
  58.  
  59. You can also try LZO1X-1(15) if you need even a little bit more
  60. compression speed.
  61.  
  62.  
  63. What's the difference beetween the decompressors per algorithm ?
  64. ================================================================
  65.  
  66. Once again let's use LZO1X for explanation:
  67.  
  68. - lzo1x_decompress
  69.     The `standard' decompressor. Pretty fast - use this whenever possible.
  70.  
  71.     This decompressor expects valid compressed data.
  72.     If the compressed data gets corrupted somehow (e.g transmission
  73.     via an errornous channel, disk errors, ...) it will probably crash
  74.     your application because absolutely no additional checks are done.
  75.  
  76. - lzo1x_decompress_safe
  77.     The `safe' decompressor. Somewhat slower.
  78.  
  79.     This decompressor will catch all compressed data violations and
  80.     return an error code in this case - it will never crash.
  81.  
  82. - lzo1x_decompress_asm
  83.     Same as lzo1x_decompress - written in assembler.
  84.  
  85. - lzo1x_decompress_asm_safe
  86.     Same as lzo1x_decompress_safe - written in assembler.
  87.  
  88. - lzo1x_decompress_asm_fast
  89.     Similiar to lzo1x_decompress_asm - but even faster.
  90.  
  91.     For reasons of speed this decompressor can write 1 to 3 bytes
  92.     past the end of the decompressed (output) block.
  93.  
  94.     Use this when you are decompressing from one memory block to
  95.     another memory block - just provide output space for 3 extra bytes.
  96.     You shouldn't use it if e.g. you are directly decompressing to video
  97.     memory (because the extra bytes will be visible on screen).
  98.  
  99. - lzo1x_decompress_asm_fast_safe
  100.     This is the safe version of lzo1x_decompress_asm_fast.
  101.  
  102.  
  103. Notes:
  104. ------
  105. - When using a safe decompressor you must pass the number of
  106.   bytes available in `dst' via the parameter `dst_len'.
  107.  
  108. - If you want to be sure that your data is not corrupted you must
  109.   use a checksum - just using the safe decompressor is not enough,
  110.   because many data errors will not result in a compressed data violation.
  111.  
  112. - Assembler versions are only available for the i386 family yet.
  113.  
  114. - You should test if the assembler decompressors are actually faster
  115.   than the C version on your machine - some compilers (like Watcom C)
  116.   can do a very good optimization job and they also can optimize the code
  117.   for a specific processor like the PentiumPro.
  118.  
  119.  
  120. What is this optimization thing ?
  121. =================================
  122.  
  123. The compressors use a heuristic approach - they sometimes code
  124. information that doesn't improve compression ratio.
  125.  
  126. Optimization removes this superfluos information in order to
  127. increase decompression speed.
  128.  
  129. Optimization works similiar to decompression except that the
  130. compressed data is modified as well. The lenght of the compressed
  131. data block will not change - only the compressed data-bytes will
  132. get rearranged a little bit.
  133.  
  134. Don't expect too much, though - my tests have shown that the
  135. optimization step improves decompression speed by about 1-3%.
  136.  
  137.  
  138. I need even more decompression speed...
  139. =======================================
  140.  
  141. Many modern processors (DEC Alpha, MIPS, ...) can transfer 32bit words
  142. much faster than bytes - this can significantly speed up decompression.
  143. So after verifying that everything works fine you can try if activating
  144. the LZO_ALIGNED_OK_4 macro improves LZO1X and LZO1Y decompression
  145. performance. Change the file config.h accordingly and recompile everything.
  146.  
  147. On a i386/i486/Pentium you should definitely use the assembler versions.
  148.  
  149.  
  150. Can you give a cookbook for using pre-compressed data ?
  151. =======================================================
  152.  
  153. Let's assume you use LZO1X-999.
  154.  
  155. 1) pre-compression step
  156.    - call lzo_init()
  157.    - call lzo1x_999_compress()
  158.    - call lzo1x_optimize()
  159.    - compute an adler32 checksum of the *compressed* data
  160.    - store the compressed data and the checksum in a file
  161.    - if you are paranoid you can verify decompression now
  162.  
  163. 2) decompression step within your application
  164.    - call lzo_init()
  165.    - load your compressed data and the checksum
  166.    - verify the checksum of the compressed data
  167.      (so that you can use the standard decompressor)
  168.    - decompress
  169.  
  170.  
  171. How much can my data expand during compression ?
  172. ================================================
  173.  
  174. LZO will expand incompressible data by a little amount.
  175. I still haven't computed the exact values, but I suggest these
  176. formulas for a worst-case expansion calculation:
  177.  
  178.   LZO1* algorithms:
  179.   -----------------
  180.     output_block_size = input_block_size + (input_block_size / 64) + 16 + 3
  181.  
  182.     This is about 101.6% for a large block size.
  183.  
  184.   LZO2* algorithms:
  185.   -----------------
  186.     output_block_size = input_block_size + (input_block_size / 8) + 128 + 3
  187.  
  188.