home *** CD-ROM | disk | FTP | other *** search
/ ftp.cse.unsw.edu.au / 2014.06.ftp.cse.unsw.edu.au.tar / ftp.cse.unsw.edu.au / pub / doc / algorithms / Lempel_Ziv_Compress_Algorithm < prev   
Encoding:
Internet Message Format  |  1992-10-18  |  3.7 KB

  1. Path: spinifex!elecvax!usage!basser!munnari!otc!softway!swine
  2. From: swine@softway.oz (Peter Swain)
  3. Newsgroups: comp.theory
  4. Subject: Zev-Limpel (Lempel-Ziv?) compression algorithm (long)
  5. Keywords: Zev_Limpel,compression
  6. Message-ID: <1057@softway.oz>
  7. Date: 4 Jan 89 00:10:48 GMT
  8. References: <182@syacus.acus.oz>
  9. Reply-To: swine@softway.oz (Peter Swain)
  10. Distribution: aus
  11. Organization: Softway Pty Ltd, Sydney, Australia
  12. Lines: 77
  13.  
  14. In article <182@syacus.acus.oz> petri@syacus.UUCP (Petri Nuuttila) writes:
  15. > Does anybody have a reference for Zev-Limpel compression allgorithm?
  16. > Better yet, could somebody post some information on it. Is it some variant 
  17. > of Huffman encoding, which it improves?
  18.  
  19. Quite different, really.
  20.  
  21. Huffman codes are designed through a static examination of
  22. the symbol space, giving the shortest names to most common
  23. symbols.
  24.  
  25. Lempel-Ziv (I think that's them) is a dynamic encoding,
  26. which need not see the whole file before compressing.
  27. It's best seen as a smart communication channel which
  28. generates its own abbreviations for common strings.
  29.  
  30. We have an encoder, E, and a decoder, D, with a stream of
  31. symbols being passed from E to D (the compressed text).
  32. E & D both start out with an initial alphabet (call it a,b,c...)
  33. and a common boredom threshold.
  34. The initial alphabet is just the character set of the input
  35. stream (8bit bytes, 7bit ascii, 64bit chunks or wotever).
  36. E starts sending text to D:
  37.     thecatsatonthematthecatsatonthemat....
  38. and soon notices that some pairs of symbols are common.
  39.  
  40. When any pair reaches the boredom threshold, E picks the
  41. next free symbol to encode future occurences of the pair.
  42. Say we get bored after two occurences of a pair,
  43. and pick new symbols (A,B,C,...) to represent them:
  44.     thecatsatonthemABecAsAonBemA....
  45. On the second occurence of "at", we invent a macro "A".
  46. Similarly "B" for "th".
  47. E *does not* send this new code the first time, but lets the
  48. old pair pass. D, using the same algorithm, expects that E
  49. will have been bored by "at", and intuits that it will have
  50. assigned the next free symbol "A".
  51. Some time later "Be" (from "the") will be assigned (say)
  52. "E", and "Em" (from "Bem" from "them") will get (say) "G".
  53. {appropriately, "Bem" == "BugEyedMonster" == "them"}
  54.  
  55. As a reasonably redundant text passes under their noses, E &
  56. D invent a more compact notation, but it costs them in size
  57. of symbol space (bits per symbol).
  58.  
  59. The PD compress utility (for Unix and much else) is a good
  60. example of Lempel-Ziv. Initially knowing nothing about the
  61. plaintext, it encodes input bytes into 8 bit symbols
  62. (themselves). On getting bored with "at" above, it would
  63. invent the symbol "A" as 256, thus blowing out the symbol
  64. space to 9 bits. Both E & D realise this on the last
  65. occurrence of "at", and shift to a 9 bit encoding from
  66. the next symbol.
  67. After inventing 256 symbols, they shift to 10 bit encoding,
  68. and so on, limited only by the size of the decoding table
  69. they need to maintain.
  70. Compress can be told to limit its symbol space size to
  71. enable the decoding to run on small machines (usually 13 bit
  72. space for 64k addressing).
  73.  
  74. This algorithm picks up local text features quickly, and can
  75. fill its symbol space with anachronisms if the text shape
  76. changes (say from English to machine code).
  77. If E notices a decrease in compression (perhaps because it's
  78. now sending 10 bit symbols for essentially incompressible
  79. data), it can blow away that excess baggage and go back to
  80. 8 bit encoding again, moving to 9 bits when it sees new
  81. idioms in the text.
  82.  
  83. If my library were not in such disarry i'd feed you some
  84. references.
  85. Seek out the Compress sources, from me if necessary.
  86. -- 
  87. Peter Swain - Softway Pty Ltd    (swine@softway.oz)
  88.  
  89. PHONE:    +61-2-698-2322        UUCP:        uunet!softway.oz!swine
  90. FAX:    +61-2-699-9174        INTERNET:    swine@softway.oz.au
  91.