home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / lang / perl / 5700 < prev    next >
Encoding:
Internet Message Format  |  1992-09-03  |  92.0 KB

  1. Xref: sparky comp.lang.perl:5700 comp.compression:3172 comp.lang.postscript:4560
  2. Path: sparky!uunet!gumby!wupost!zaphod.mps.ohio-state.edu!not-for-mail
  3. From: parker@shape.mps.ohio-state.edu (Steve Parker)
  4. Newsgroups: comp.lang.perl,comp.compression,comp.lang.postscript
  5. Subject: postscript compression script in perl.
  6. Date: 3 Sep 1992 12:52:31 -0400
  7. Organization: Department of Mathematics, The Ohio State University
  8. Lines: 2268
  9. Sender: parker@mps.ohio-state.edu
  10. Distribution: world
  11. Message-ID: <185fsfINNcbs@shape.mps.ohio-state.edu>
  12. NNTP-Posting-Host: shape.mps.ohio-state.edu
  13. Keywords: compression compress postscript perl
  14.  
  15. To Whom It May Concern,
  16.  
  17. A few months ago I posted a request to the net regarding a postscript
  18. compression routine.  I have since found out that Postscript 2 is to have
  19. it's own standard way to compress images, nevertheless I have written a
  20. postscript image compressor.
  21.  
  22. The postscript compressor I have written is in perl but the form of compression
  23. is run-length encoding, and could be written in other languages, such as C, sed,
  24. awk, nawk, etc. (I am sure that Larry could probably even write the thing in
  25. roff--the man is mutant! ceveat: I am forever in his debt for writting perl.)
  26.  
  27. The most common responce that I received when telling my peers of my plans was
  28. "Why write the thing in postscript?" or "Why write the thing at all?"
  29.  
  30. Everyone knows that the way screen dump/image capture routines output their
  31. results on various architures is straight forward but disk wasteful.  Computer
  32. screen images are not like images from other sources in that they almost always
  33. have huge amounts of repetition, large areas all the same pattern.  And are
  34. therefore very susceptible to run-length-encoding-type compression schemes.
  35.  
  36. The reasons I think that a compression routine written in postscript is valuable
  37. are that the resulting compressed image is still a valid posctscript program,
  38. which can be sent via E-mail without fear of corruption to anyone with a
  39. postscript printer regardless of the machine to which it is connected, and
  40. futhermore can be subsequently compressed with your favorite routine:
  41. compress, pack, zip, zoo, arc, etc.
  42.  
  43. Finally I realize that this is not the most efficient method, but before I work
  44. on enhancing it, I thought that I'd post it.  I would like your input on how to
  45. improve it and I thought that many of you could use it 'as is' to help with
  46. disk space problems (a never-ending problem at our site at least).  I have found
  47. that users mind this form of compression less since it requires no additional
  48. actions to print the file later.
  49.  
  50. If you use this package, I would appreciate timing results/comments/suggestions.
  51. Please E-mail me any posts that you might make concerning this post so that
  52. I will post a summary at a later date:
  53.  
  54.  Steve Parker                    parker@mps.ohio-state.edu
  55.  Dept of Chemistry               201 McPherson Labs
  56.  Ohio State University           614-292-5042
  57.  
  58. I have thought of many ways to improve this script:
  59.  
  60. 1) Record which and how many of the decompression routines were used in a given
  61.    image, and insert only those that were used and in the order of fequency
  62.    that they were used.
  63. 2) Search the unique runs for patterns of 2 4 or 8 characters.
  64. 3) Make a new decompression routine called I for insert which would be used for
  65.    inserting unique string into a long run of repeating characters.
  66.  
  67. NOTE: The above ideas would most easily be accomplished by saving the compressed
  68.       image in memory or a temp file and/or making multiple passes at the image
  69.       data.
  70.  
  71. Any other suggestions?
  72.  
  73. Here are timing results for postscript images created on various machines,
  74. compressed on a Sparc ELC and printed on a AppleLaserWriter II:
  75.  
  76.  
  77. Test cases:
  78.  
  79.                                 (Apple LaserWriter II)
  80. Filename    size in    chars      bits in    time to     approximate time
  81.                                 image    compress     to print
  82. -------------------------------------------------------------------------
  83. snapshot.cmp.ps    63861         ---     67.0 s        100 s
  84. snapshot.ps      262906       1024000        --          245 s
  85. stripes.cmp.ps        2241         ---     31.0 s           30 s
  86. stripes.ps      133403       1036800        --        130 s
  87. iris.cmp.ps       73384            ---     68.5 s          100 s
  88. iris.ps          261385        524288        --        250 s
  89. stellar.cmp.ps      129140         ---     1027.3 s       425 s
  90. stellar.ps     1968436       1966728        --       1740 s
  91.  
  92. I am presently getting results for NeXT printers, and some others.
  93.  
  94. These files are available by E-mail at request to above address.
  95.  
  96. Here is my description of the two pieces necessary for
  97. compression/decompression (I originally had two files but now use the <DATA>
  98. file handle of perl):
  99.  
  100. decomp.header    is the postscript decompression header that will be used in
  101.         place of
  102.         "/picstr 1024 string def
  103.          { currentfile /picstr readhexstring pop }"
  104.         which is often used as the proc for the image function
  105.         ie "width hieght bitpersample proc image"
  106.  
  107. pscmp        is the perl script that compresses the hex digit pair
  108.         format often used to encode a bitmap in postscript, it also
  109.         inserts the decompression header file in a clever way.
  110.         Since the last thing on the stack before the image command
  111.         is called is the procedure that image will use to obtain the 
  112.         image, pscmp looks for the image command and inserts
  113.         pop { decompress }
  114.         before it.  The 'pop' command removes whatever procedure was
  115.         on the stack and then '{ decompress }' (my command) is pushed
  116.         on the stack in it's place.
  117.  
  118.         It does compression with the following four "codes":
  119.         u - one character  follows, whos ascii value  will determine
  120.             how many "unique" hex pairs follow. 1-256   pairs.
  121.         U - two characters follows, whos ascii values will determine
  122.             how many "unique" hex pairs follow. 257-65535 pairs.
  123.         r - one character  follows, whos ascii value  will determine
  124.             how many times to "repeat" the hex pair that follows.
  125.         R - one characters follows, whos ascii values will determine
  126.             how many times to "repeat" the hex pair that follows.
  127. NOTES:
  128.         * ranges for R and U could not be made to be 257-65792,
  129.           without splitting the runs into multiple strings,
  130.           since the largest string is 65335.
  131.         * I attempted two ways of storing the length of unique and
  132.           repeating runs.
  133.           The first and most straight forward to interpret in
  134.           postscipt, was to store them as one or two characters whose
  135.           ascii value was then interpretted as an integer by using the
  136.           'currentfile read pop' sequence.
  137.           The second used two or four digit hex number to represent
  138.           the length of the run, and used the postscript command
  139.           sequence:
  140.  
  141. /charx2  2 string def
  142. /charx4  4 string def
  143. /hexnum2 5 string def
  144. /hexnum4 7 string def
  145. /hexnum2 (16#00) def
  146. /hexnum4 (16#0000) def
  147. /getcount    { hexnum2 3 currentfile charx2 readstring pop
  148.           putinterval hexnum2 cvi } def
  149. /getbigcount    { hexnum4 3 currentfile charx4 readstring pop
  150.           putinterval hexnum4 cvi } def
  151.  
  152.           which works by putting the hex number ,ie. 'fd', in a string
  153.           like '16#00' thus giving the string '16#fd' which the command
  154.           'cvi' interprets as 0xfd, or 253.
  155.  
  156.           The later method was necessary because characters representing
  157.           serial port I/O controls, ie. '^D', '^S/^Q' were interpretted
  158.           by the printers I/O control and not pasted to the postscript
  159.           interpretter.
  160.           The former method did work however with Sun's Postscript
  161.           previewer "pageview version 3"
  162.         * pscmp removes the comments and unnecessary white space (used
  163.           for readability) from decomp.header as it inserts it into the
  164.           postscript.
  165.  
  166. *******************************************************************************
  167. Here is the script:
  168.  
  169. #!/usr/local/bin/perl
  170. # A perl script to compress postscript images.
  171.  
  172. # Written by: 
  173. # Steve Parker                    parker@mps.ohio-state.edu
  174. # Dept of Chemistry               201 McPherson Labs
  175. # Ohio State University           614-292-5042
  176. # Columbus OH, 43210
  177. #
  178. # codes: u - small count   run of unique hex pairs
  179. #     U - big   count   run of unique hex pairs
  180. #     r - small count+1    repeated   hex pair
  181. #     R - big   count+1    repeated   hex pair
  182. #     a repeat last r or R. NOT SUPPORTED IN THIS PERL SCRIPT.
  183. #
  184. # formats: u cc    'hphp...'
  185. #       U CC CC 'hphp...'
  186. #       r cc    'hp'
  187. #       R CC CC 'hp'
  188. #
  189. # where: 1) spaces are not output
  190. #     2) uUrR are output literally
  191. #     3) cc   is a 2 digit hex number (0-255) and represents range (1-256)
  192. #     4) CCCC is a 4 digit hex number (0-65535) for a range (257-65535)
  193. #        if not for max size on postscript string would be  (257-65792)
  194. #     5) 'hp' is a hex digit pair from 'image' data.
  195.  
  196. $name = $0;
  197. $name =~ s'.*/''; # remove path--like basename
  198. $usage = "usage:\n$name [postscript_file_with_IMAGE_data]";
  199.  
  200. select(STDOUT); $|=1;
  201.  
  202. $biggest=65534;
  203. $last="";
  204. while (<>) {
  205.   if ( /([^A-Fa-f\d\n])/ ) {
  206. #   print "'$1' ->$_";
  207.     if ($_ =~ /showpage/ || $_ =~ /grestore/ ) {
  208. #
  209. # FOUND a showpage or grestore so write out last repeating pair or unique run.
  210. #
  211.       if ($repeating) {
  212.     # we didn't record the first pair in $repeating
  213.     # so we needn't subtract 1.
  214. #$num=$repeating-1;
  215.     $num=$repeating;
  216.         if ( $num <= 255 ) {
  217.           #   case 2 small count repeat unit 2 hex digits.
  218.           printf("r%02X%2s\n",$num,$last);
  219.       $r++;
  220.         } else {
  221.           #   case 3  big  count repeat unit 2 hex digits.
  222.           printf("R%02X%02X%2s\n",int($num/256),($num%256),$last);
  223.       $R++;
  224.         }
  225.       } else {
  226.     $unique_str.=$last;
  227.     # we didn't yet record this last pair in $unique_run
  228.     # so we needn't subtract 1.
  229.     $num=$unique_run;
  230.         if ( $num <= 255 ) {
  231.           # case 0 small count unique string of hex digit pairs.
  232.           printf("u%02X%s",$num,$unique_str);
  233.       $u++;
  234.         } else {
  235.           # case 1  big  count unique string of hex digit pairs.
  236.           printf("\nU%02X%02X%s",int($num/256),($num%256),$unique_str);
  237.       $U++;
  238.         }
  239.       }
  240.       & end;
  241.     }
  242. # add the postscript decompression header
  243. # inbetween the original proc called by the 'image' command
  244. # and the 'image' command itself
  245.     if ( $_ =~ /^(image\s?.*)$|^([^%]*)?(\simage\s?.*)$/ ) {
  246.       print "$1\n" if ($1);
  247.       if ($headerin) {
  248.         $file="/home/sysadmin/postscript/compress/decomp.header";
  249. #       open(HEADER,"$file") || die("$name: Cannot open $file: '$!'\n");
  250.         while (<DATA>) { s/(\s)\s+/\1/g; print if !(/^%/); }
  251.         $headerin++;
  252.         close(DATA);
  253.       } else {
  254.     print " pop { decompress } ";
  255.       }
  256.       print "$2";
  257.       next;
  258.     }
  259.     print;
  260.     next;
  261.   } # else { print "\n" if ($unique_run || $repeating); }
  262. #
  263. #--------------------   HEX PAIR HANDLING LOOP   --------------------------
  264. #
  265.   while (s?([A-F0-9a-f][A-F0-9a-f])??) {
  266.     if ($repeating) {
  267.       if ($1 eq $last) {
  268. #-debug print STDERR "rs"; # repeating; same
  269.         $repeating++;   # found another one.
  270.     # check to see if we have filled biggest postscript string
  271.     # this will kept the decompress in postscript simple and fast.
  272.     if ($repeating eq $biggest) {
  273.       printf("Rfffe%2s",$last);
  274.       # set to start over fresh
  275.       $repeating=0;
  276.       # $unique_str should be set to null and $unique_run set to 0
  277.     }
  278.       } else {
  279. #-debug print STDERR "rd"; # repeating; different
  280. #
  281. # FOUND a unique hex pair so repeating unit has ended, write it out.
  282. #
  283. #$num=$repeating-1;
  284.     $num=$repeating;
  285.         if ( $repeating <= 255 ) {
  286.           #   case 2 small count repeat unit 2 hex digits.
  287. # -line-  $line+=6; if ( $line > 80) { $line=6; print "\n"; }
  288. #-debug   printf STDERR ">2,%2X,%2s ",$num,$last;
  289.           printf("r%02X%2s",$num,$last);
  290.       $r++;
  291.         } else {
  292.           #   case 3  big  count repeat unit 2 hex digits.
  293. # -line-  $line+=8; if ( $line > 80) { $line=8; print "\n"; }
  294. #-debug   printf(">3,%2X,%2X,%2s ",int($num/256),($num%256),$last);
  295.           printf("R%02X%02X%2s",int($num/256),($num%256),$last);
  296.       $R++;
  297.         }
  298.         $repeating=0;
  299.         $last=$1;
  300.       }
  301.  
  302.     } else { # must be unique'ing
  303.  
  304.       if ($1 eq $last) {
  305. #-debug print "us"; # uniquing; same
  306. #
  307. # FOUND a repeating hex pair so might have a unique run
  308. # which has ended, if so write it out.
  309. #
  310.         if ($unique_str) {
  311.       $num=$unique_run-1;
  312.           if ( $num <= 255 ) {
  313.             # case 0 small count unique string of hex digit pairs.
  314. # -line-    $line+=(4+$unique_run)); if ( $line > 80) { $line=4+$unique_run; print "\n"; }
  315. #-debug     printf("\n>0,%2X,'%s' ",$num,$unique_str);
  316.             printf("\nu%02X%s",$num,$unique_str);
  317.         $u++;
  318.           } else {
  319.             # case 1  big  count unique string of hex digit pairs.
  320. # -line-    $line+=(6+$unique_run); if ( $line > 80) { $line=6+$unique_run; print "\n"; }
  321. #-debug     printf("\n>1,%2X,%2X,'%s' ",int($num/256),($num%256),
  322.             printf("\nU%02X%02X%s",int($num/256),($num%256),$unique_str);
  323.         $U++;
  324.           }
  325.         }
  326.         # start counting repeating pairs, reset unique_run count
  327.         # and remember last.
  328.         $repeating++;
  329.         $unique_str='';$unique_run=0;
  330.         $last=$1;
  331.       } else { # countiue uniquing
  332. #-debug print "ud"; # uniquing; different
  333.         $unique_str.=$last;
  334. #       $unique_run+=2; # use this if using $line to limit to 80 chars/line.
  335.                         # but REMEMBER to divid by two when outputing!
  336.         $unique_run++;
  337.     # check to see if we have filled biggest postscript string
  338.     # this will kept the decompress in postscript simple and fast.
  339.     if ($unique_run eq $biggest) {
  340.       printf("Ufffe%s",$unique_str);
  341.       # set to start over fresh
  342.           $unique_str='';$unique_run=0;
  343.           $last=$1;
  344.       # $repeating should be set to 0
  345.     }
  346.         $last=$1;
  347.       }
  348.     }
  349.   }
  350. }
  351. &end;
  352. sub end {
  353.   printf STDERR "Statistics:\n" ;
  354.   printf STDERR "r's:%5d\n",$r ;
  355.   printf STDERR "R's:%5d\n",$R ;
  356.   printf STDERR "u's:%5d\n",$u ;
  357.   printf STDERR "U's:%5d\n",$U ;
  358.   ($user,$system,$cuser,$csystem)=times;
  359.   printf STDERR "Times:\tuser,\tsystem,\tcuser,\tcsystem\n";
  360.   printf STDERR "Times:\t%5f,\t%5f,\t%5f,\t%5f\n",
  361.          $user,$system,$cuser,$csystem;
  362.   exit;
  363.          }
  364. __END__
  365. %-------------------------------------------------------------------------------
  366. %
  367. % header to define 'decompress' which will replace the
  368. % { currentfile string readhexstring pop } proc commonly used with 'image'
  369. %
  370. % to be placed just before the 'image' command
  371. % the 'pop' on the following line is to remove bogus 'proc' (as above)
  372. pop
  373. /repeater 1 string def
  374. /char     1 string def
  375. /charx2   2 string def
  376. /charx4   4 string def
  377. /hexnum2  5 string def
  378. /hexnum4  7 string def
  379. /debug   30 string def
  380. /big  65535 string def
  381. /hexnum2 (16#00)   def
  382. /hexnum4 (16#0000) def
  383. /gethexpair    { currentfile char readhexstring pop } def
  384. /getcount    { hexnum2 3
  385.           currentfile charx2 readstring pop
  386.           putinterval hexnum2 cvi } def
  387. /getbigcount    { hexnum4 3
  388.           currentfile charx4 readstring pop
  389.           putinterval hexnum4 cvi } def
  390. /codeu        { pop /cnt getcount def
  391.                   big 0 1 cnt { gethexpair putinterval big } for
  392.                   0 cnt 1 add getinterval
  393.          } def
  394. /codeU        { pop /cnt getbigcount def
  395.                   big 0 1 cnt { gethexpair putinterval big } for
  396.                   0 cnt 1 add getinterval
  397.          } def
  398. /coder        { pop /cnt getcount    def
  399.           /repeater gethexpair def % get repeater unit
  400.                   big 0 1 cnt {repeater putinterval big} for
  401.           0 cnt 1 add getinterval
  402.         } def
  403. /codeR        { pop /cnt getbigcount def
  404.           /repeater gethexpair def % get repeater unit
  405.                   big 0 1 cnt {repeater putinterval big} for
  406.           0 cnt 1 add getinterval
  407.                 } def
  408. /codeX        { pop big 0 cnt 1 add getinterval } def
  409. /done        { currentfile debug readstring pstack exit } def
  410. /skip        { pop decompress } def
  411. #
  412. # the following order of r,u,R,U was chosen by noting the frequency
  413. # of occurance from a small number of examples but can easily be changed.
  414. /others0    { dup (u)  eq { codeu } { others1 } ifelse } def
  415. /others1    { dup (R)  eq { codeR } { others2 } ifelse } def
  416. /others2    { dup (U)  eq { codeU } { others3 } ifelse } def
  417. /others3    { dup (a)  eq { codeX } { others4 } ifelse } def
  418. /others4    { dup (\n) eq { skip  } {  done   } ifelse } def
  419. /decompress    { currentfile char readstring pop
  420.           dup (r)  eq { coder } { others0 } ifelse } def
  421. { decompress }
  422. %-----------------------------------------------------------------------------
  423. Newsgroups: comp.lang.postscript
  424. Subject: postscript compression script in perl
  425. Summary: 
  426. Expires: 
  427. Sender: 
  428. Followup-To: 
  429. Distribution: world
  430. Organization: Department of Mathematics, The Ohio State University
  431. Keywords: 
  432.  
  433. Newsgroups: comp.compression
  434. Subject: Re: comp.compression Frequently Asked Questions (part 1/2)
  435. Summary: 
  436. Expires: 
  437. References: <compr1_11aug92@chorus.fr>
  438. Sender: 
  439. Followup-To: 
  440. Distribution: 
  441. Organization: Department of Mathematics, The Ohio State University
  442. Keywords: data compression, FAQ
  443.  
  444. In article <compr1_11aug92@chorus.fr> jloup@chorus.fr writes:
  445. >Archive-name: compression-faq/part1
  446. >Last-modified: Aug 11th, 1992
  447. >
  448. >This file is part 1 of a set of Frequently Asked Questions (FAQ) for
  449. >the groups comp.compression and comp.compression.research.  Certain
  450. >questions get asked time and again, and this is an attempt to reduce
  451. >the bandwidth taken up by these posts and their associated replies.
  452. >If you have a question, *please* check this file before you post.  It
  453. >may save a lot of peoples time.
  454. >
  455. >If you have not already read the overall Usenet introductory material
  456. >posted to "news.announce.newusers", please do.
  457. >
  458. >If you don't want to see this FAQ regularly, please add the
  459. >subject line to your kill file. If you have corrections or suggestions
  460. >for this FAQ, send them to Jean-loup Gailly <jloup@chorus.fr>.
  461. >Thank you.
  462. >
  463. >Part 1 is oriented towards practical usage of compression programs.
  464. >Part 2 is more intended for people who want to know how compression works.
  465. >
  466. >Main changes relative to the previous version: 
  467. >
  468. >- renumbered some questions to group together image compression subjects
  469. >- included comp.compression.research (item 1)
  470. >- corrected pointer to stuffit (item 2)
  471. >- corrected pointer to Calgary text compression corpus (item 5)
  472. >- added a few patent references -- to be checked for Fiala (item 8)
  473. >- ccitt standards are no longer on ftp.uu.net (item 11)
  474. >- added a pointer to more arithmetic coding sources (item 13)
  475. >- added some references for fractal compression (item 17)
  476. >- added pointer to H.261 spec (item 20)
  477. >- added item 25: Fast DCT (Discrete Cosine Transform) algorithms
  478. >- added pointers to a compression program for Sun audio files
  479. >  and for a fast ADPCM algorithm (item 26)
  480. >- discrete wavelet transforms are not slower than DCT (item 72)
  481. >
  482. >
  483. >Contents
  484. >========
  485. >
  486. >General questions:
  487. >
  488. >[1]  What are these newsgroups about?
  489. >[2]  What is this .xxx file type?
  490. >     Where can I find the corresponding compression program?
  491. >[4]  What is an archiver?
  492. >[5]  What is the best general purpose compression program?
  493. >[7]  Which books should I read?
  494. >[8]  What about patents on data compression algorithms?
  495. >[9]  The WEB 16:1 compressor.
  496. >[11] What is the V.42bis standard?
  497. >[12] I need source for the winners of the Dr Dobbs compression contest
  498. >[13] I need source for arithmetic coding
  499. >
  500. >Image and audio compression:
  501. >
  502. >[15] Where can I get image compression programs?
  503. >[16] What is the state of the art in lossless image compression?
  504. >[17] What is the state of fractal compression?
  505. >[18] I need specs and source for TIFF and CCITT group 4 Fax.
  506. >[19] What is JPEG?
  507. >[20] I am looking for source of an H.261 codec.
  508. >[25] Fast DCT (Discrete Cosine Transform) algorithms
  509. >[26] Are there algorithms and standards for audio compression?
  510. >
  511. >Common problems:
  512. >
  513. >[30] My archive is corrupted!
  514. >[31] pkunzip reports a CRC error!
  515. >[32] VMS zip is not compatible with pkzip!
  516. >
  517. >Questions which do not really belong to comp.compression:
  518. >
  519. >[50] What is this 'tar' compression program?
  520. >[51] I need a CRC algorithm
  521. >[52] What about those people who continue to ask frequently asked questions?
  522. >[53] Where are FAQ lists archived?
  523. >[54] I need specs for graphics formats
  524. >[55] Where can I find Lenna and other images?
  525. >
  526. >(Long) introductions to data compression techniques (in part 2)
  527. >
  528. >[70] Introduction to data compression (long)
  529. >       Huffman and Related Compression Techniques
  530. >       Arithmetic Coding
  531. >       Substitutional Compressors
  532. >          The LZ78 family of compressors
  533. >          The LZ77 family of compressors
  534. >
  535. >[71] Introduction to MPEG (long)
  536. >       What is MPEG?
  537. >       Does it have anything to do with JPEG?
  538. >       Then what's JBIG and MHEG?
  539. >       What has MPEG accomplished?
  540. >       So how does MPEG I work?
  541. >       What about the audio compression?
  542. >       So how much does it compress?
  543. >       What's phase II?
  544. >       When will all this be finished?
  545. >       How do I join MPEG?
  546. >       How do I get the documents, like the MPEG I draft?
  547. >
  548. >[72] What is wavelet theory?
  549. >[73] What is the theoretical compression limit?
  550. >[74] Introduction to JBIG
  551. >
  552. >[99] Acknowledgments
  553. >
  554. >Search for "Subject: [#]" to get to question number # quickly. Some news
  555. >readers can also take advantage of the message digest format used here.
  556. >
  557. >If you know very little about data compression, read question 70 in
  558. >part 2 first.
  559. >
  560. >------------------------------------------------------------------------------
  561. >
  562. >Subject: [1] What are these newsgroups about?
  563. >
  564. >
  565. >comp.compression is the place to discuss about data compression, both
  566. >lossless (for text or data) and lossy (for images, sound, etc..).
  567. >comp.compression.research was created later to provide a forum for
  568. >current research on data compression and data compression algorithms.
  569. >If you are not experienced in data compression, please post in
  570. >comp.compression only.
  571. >
  572. >If you only want to find a particular compression program for a
  573. >particular operating system, please read first this FAQ and the
  574. >article "How to find sources" which is regularly posted in
  575. >news.answers.
  576. >
  577. >If you can't resist posting such a request, other groups are probably
  578. >more appropriate (comp.binaries.ibm.pc.wanted, comp.sources.wanted,
  579. >comp.sys.mac.wanted, alt.graphics.pixutils). Please post your request
  580. >in comp.compression only as a last resource.
  581. >
  582. >Please do not post any program in binary form to comp.compression.
  583. >Very short sources can be posted, but long sources should be be posted
  584. >to the specialized source groups, such as comp.sources.* or alt.sources.
  585. >
  586. >------------------------------------------------------------------------------
  587. >
  588. >Subject: [2] What is this .xxx file type?
  589. >             Where can I find the corresponding compression program?
  590. >
  591. >
  592. >For most programs, one US and one European ftp site are given.
  593. >(wuarchive.wustl.edu: 128.152.135.4, garbo.uwasa.fi: 128.214.87.1)
  594. >Many other sites (in particular wsmr-simtel20.army.mil: 192.88.110.2)
  595. >have the same programs.
  596. >
  597. >To keep this list to a reasonable size, many programs are not
  598. >mentioned here. Additional information can be found in the file
  599. >ux1.cso.uiuc.edu:/doc/pcnet/compression [128.174.5.59] maintained by
  600. >David Lemson (lemson@uiuc.edu). When several programs can handle
  601. >the same archive format, only one of them is given.
  602. >
  603. >For Macintosh programs, look on sumex-aim.stanford.edu:/info-mac [36.44.0.6].
  604. >For VM/CMS, look on vmd.cso.uiuc.edu:/public.477 [128.174.5.98].
  605. >For Atari, look on terminator.cc.umich.edu:/atari/archivers [141.211.164.8]
  606. >For Amiga, look on ab20.larc.nasa.gov:/amiga/utils/archivers  [128.155.23.64]
  607. >    
  608. >If you don't know how to use ftp or don't have ftp access, read the
  609. >article "How to find sources" which is regularly posted in news.answers.
  610. >
  611. >If you can't find a program given below, it is likely that a newer
  612. >version exists in the same directory. (Tell me <jloup@chorus.fr>)
  613. >
  614. >ext:  produced by or read by
  615. >
  616. >.arc: arc, pkarc (MSDOS)
  617. >    wuarchive.wustl.edu:/mirrors/msdos/starter/pk361.exe
  618. >    garbo.uwasa.fi:/pc/arcers/pk361.exe
  619. >
  620. >      arc (Unix)
  621. >        wuarchive.wustl.edu:/mirrors/misc/unix/arc521e.tar-z
  622. >    garbo.uwasa.fi:/unix/arcers/arc.tar.Z
  623. >        Contact: Howard Chu <hyc@umix.cc.umich.edu>
  624. >
  625. >      arc (VMS)
  626. >    wuarchive.wustl.edu:/packages/compression/vax-vms/arc.exe
  627. >
  628. >      arcmac (Mac)
  629. >    mac.archive.umich.edu:/mac/utilities/compressionapps/arcmac.hqx
  630. >
  631. >.arj: arj (MSDOS)
  632. >        wuarchive.wustl.edu:/mirrors/msdos/arc-lbr/arj230.exe
  633. >    garbo.uwasa.fi:/pc/arcers/arj230ng.exe
  634. >
  635. >      unarj (Unix). There is *no* arj for Unix. Don't post a request.
  636. >        wuarchive.wustl.edu:/mirrors/misc/unix/unarj230.tar-z
  637. >    garbo.uwasa.fi:/unix/arcers/unarj221.tar.Z
  638. >      Contact: Robert K Jung <robjung@world.std.com>
  639. >
  640. >.cpt: Compact Pro (Macintosh)
  641. >        sumex-aim.stanford.edu:/info-mac/util/compact-pro-132.hqx [36.44.0.6]
  642. >
  643. >.gif: gif files are images compressed with the LZW algorithm. See the
  644. >      comp.graphics FAQ list for programs manipulating .gif files.
  645. >
  646. >.hqx: Macintosh BinHex format. (binhex is *not* a compression program, BTW.)
  647. >       for Mac:
  648. >     mac.archive.umich.edu:/mac/utilities/compressionapps/binhex4.0.bin
  649. >
  650. >       for Unix:
  651. >         sumex-aim.stanford.edu:/info-mac/unix/mcvert-165.shar [36.44.0.6]
  652. >
  653. >.lzh: lha (MSDOS)
  654. >    wuarchive.wustl.edu:/mirrors/msdos/arc-lbr/lha213.exe
  655. >    garbo.uwasa.fi:/pc/arcers/lha213.exe
  656. >
  657. >      lharc (Unix). Warning: lharc can extract .lzh files created by
  658. >           lharc 1.xx but not those created by lha. See lha for Unix below.
  659. >        wuarchive.wustl.edu:/mirrors/misc/unix/lharc102a.tar-z
  660. >    garbo.uwasa.fi:/unix/arcers/lharcsrc.zoo
  661. >
  662. >      lha (Unix) Warning: all doc is in Japanese.
  663. >    garbo.uwasa.fi:/unix/arcers/lha-1.00.tar.Z
  664. >        ftp.kuis.kyoto-u.ac.jp:/utils/lha-1.00.tar.Z
  665. >          Contact: lha-admin@oki.co.jp
  666. >
  667. >      lha (Mac)
  668. >        mac.archive.umich.edu:/mac/utilities/compressionapps/maclha2.0.cpt.hqx
  669. >
  670. >      lharc (VMS). Same warning as for Unix lharc.
  671. >    wuarchive.wustl.edu:/packages/compression/vax-vms/lharc.exe
  672. >
  673. >.pak: pak (MSDOS)
  674. >        wuarchive.wustl.edu:/mirrors/msdos/arc-lbr/pak251.exe
  675. >    garbo.uwasa.fi:/pc/arcers/pak251.exe
  676. >
  677. >.pit: PackIt (Macintosh)
  678. >       for Mac:
  679. >         sumex-aim.stanford.edu:/info-mac/util/stuffit-151.hqx  [36.44.0.6]
  680. >
  681. >       for Unix:
  682. >         sumex-aim.stanford.edu:/info-mac/unix/mcvert-165.shar [36.44.0.6]
  683. >
  684. >.sea: self-extracting archive (Macintosh)
  685. >         Run the file to extract it. You can also extract it with:
  686. >      mac.archive.umich.edu:/mac/utilities/compressionapps/desea1.11.cpt.hqx
  687. >
  688. >.sit: Stuffit (Macintosh)
  689. >       for Mac:
  690. >         sumex-aim.stanford.edu:/info-mac/util/stuffit-lite-30.hqx [36.44.0.6]
  691. >
  692. >       for Unix:
  693. >         sumex-aim.stanford.edu:/info-mac/unix/unsit-15.shar [36.44.0.6]
  694. >
  695. >.tar: tar is *not* a compression program. However, to be kind for you:
  696. >      for MSDOS
  697. >    wuarchive.wustl.edu:/mirrors/msdos/starter/tarread.exe
  698. >    garbo.uwasa.fi:/pc/unix/tar4dos.zoo
  699. >
  700. >      for Unix
  701. >        tar (you have it already. To extract: tar xvf file.tar)
  702. >
  703. >      for VMS
  704. >    wuarchive.wustl.edu:/packages/compression/vax-vms/tar.exe
  705. >
  706. >      for Macintosh
  707. >        sumex-aim.stanford.edu:/info-mac/util/tar-30.hqx
  708. >
  709. >.tar.Z, .tar-z, .taz: tar + compress
  710. >      For Unix: zcat file.tar.Z | tar xvf -
  711. >      Other OS: first uncompress (see .Z below) then untar (see .tar above)
  712. >
  713. >.zip: pkzip 1.10 (MSDOS).
  714. >    From the PKWARE BBS (June 92): "PKZIP 2.0 is expected to be released
  715. >            sometime in the next few months, as soon as possible".
  716. >           Contact: pkware.inc@mixcom.com
  717. >
  718. >         wuarchive.wustl.edu:/mirrors/msdos/zip/pkz110eu.exe.
  719. >         garbo.uwasa.fi:/pc/arcers/pkz110eu.exe.
  720. >           Note: pkz110eu.exe is an 'export' version without encryption.
  721. >         ux1.cso.uiuc.edu:/pc/exec-pc/pkz193a.exe [128.174.5.59]
  722. >           Note: pkzip 1.93a is an alpha version.
  723. >           pkz201.exe is a hacked (illegal) copy of pkz193a.exe
  724. >           pkz220.exe is also a hack and contains a dangerous virus.
  725. >
  726. >      zip 1.0 and unzip 4.2 (Unix, MSDOS, VMS, OS/2)
  727. >     wuarchive.wustl.edu:/mirrors/misc/unix/zip10ex.zip
  728. >     wuarchive.wustl.edu:/mirrors/misc/unix/unzip42.tar-z
  729. >         wuarchive.wustl.edu:/mirrors3/garbo.uwasa.fi/arcutil/zcrypt10.zip
  730. >           Non US residents must get the encryption code from garbo (see below)
  731. >     garbo.uwasa.fi:/unix/arcers/zip10ex.zip
  732. >     garbo.uwasa.fi:/unix/arcers/unzip42.tar.Z.
  733. >         garbo.uwasa.fi:/pc/arcutil/zcrypt10.zip  (encryption code)
  734. >           Contact: zip-bugs@cs.ucla.edu
  735. >
  736. >      zip 1.0 and unzip 4.2 (Mac)
  737. >         valeria.cs.ucla.edu:/info-zip/Mac/zip_uzip.hqx
  738. >         sumex-aim.stanford.edu:/info-mac/util/unzip-42.hqx
  739. >
  740. >.zoo: zoo 2.10 (MSDOS)
  741. >     wuarchive.wustl.edu:/mirrors/msdos/zoo/zoo210.exe
  742. >     garbo.uwasa.fi:/pc/arcers/zoo210.exe
  743. >
  744. >      zoo 2.10 (Unix, VMS)
  745. >         wsmr-simtel20.army.mil:pd8:<misc.unix>zoo210.tar-z [192.88.110.2]
  746. >     garbo.uwasa.fi:/unix/arcers/zoo210.tar.Z
  747. >
  748. >      zoo (Mac)
  749. >      mac.archive.umich.edu:/mac/utilities/compressionapps/maczoo.sit.hqx
  750. >
  751. >      Contact: Rahul Dhesi <dhesi@cirrus.com>
  752. >
  753. >.F: freeze (Unix)
  754. >     wuarchive.wustl.edu:/usenet/comp.sources.misc/volume25/freeze/part0[1-2].Z
  755. >     ftp.inria.fr:/system/arch-compr/freeze-2.3.2.tar.Z
  756. >     Contact: Leonid A. Broukhis <leo@s514.ipmce.su>
  757. >
  758. >.Y: yabba (Unix, VMS, ...)
  759. >  wuarchive.wustl.edu:/usenet/comp.sources.unix/volume24/yabbawhap/part0[1-4].Z
  760. >  ftp.inria.fr:/system/arch-compr/yabba.tar.Z
  761. >  Contact: Dan Bernstein <brnstnd@nyu.edu>
  762. >
  763. >.Z: compress (Unix)
  764. >      It is likely that your Unix system has 'compress' already. Otherwise:
  765. >    wuarchive.wustl.edu:/packages/compression/compress-4.1.tar
  766. >        (not in .Z format to avoid chicken and egg problem)
  767. >
  768. >    compress (MSDOS)
  769. >    wuarchive.wustl.edu:/mirrors/msdos/compress/comp430[ds].zip
  770. >    garbo.uwasa.fi:/pc/unix/comp430d.zip
  771. >
  772. >    compress (Macintosh)
  773. >        sumex-aim.stanford.edu:/info-mac/util/maccompress-32.hqx
  774. >
  775. >------------------------------------------------------------------------------
  776. >
  777. >Subject: [4] What is an archiver?
  778. >
  779. >
  780. >There is a distinction between archivers and other compression
  781. >programs:
  782. >
  783. >- an archiver takes several input files, compresses them and produces
  784. >  a single archive file. Examples are arc, arj, lha, zip, zoo.
  785. >
  786. >- other compression programs create one compressed file for each
  787. >  input file. Examples are freeze, yabba, compress. Such programs
  788. >  are often combined with tar to create compressed archives (see
  789. >  question 50: "What is this tar compression program?").
  790. >
  791. >------------------------------------------------------------------------------
  792. >
  793. >Subject: [5] What is the best general purpose compression program?
  794. >
  795. >
  796. >The answer is: it depends. (You did not expect a definitive answer,
  797. >did you?)
  798. >
  799. >It depends whether you favor speed, compression ratio, a standard and
  800. >widely used archive format, the number of features, etc...  Just as
  801. >for text editors, personal taste plays an important role. compress has
  802. >4 options, arj 2.30 has about 130 options; different people like
  803. >different programs. *Please* do not start or continue flame wars on
  804. >such matters of taste.
  805. >
  806. >The only objective comparisons are speed and compression ratio. Here
  807. >is a short table comparing various programs on a 33Mhz Compaq 386.
  808. >All programs have been run on Unix SVR4, except pkzip and arj which
  809. >only run on MSDOS.  Detailed benchmarks have been posted in
  810. >comp.compression by Peter Gutmann <pgut1@cs.aukuni.ac.nz>.
  811. >
  812. >*Please* do not post your own benchmarks made on your own files that
  813. >nobody else can access. If you think that you must absolutely post yet
  814. >another benchmark, make sure that your test files are available by
  815. >anonymous ftp.
  816. >
  817. >The programs compared here were chosen because they are the most popular
  818. >or because they run on Unix and source is available.  For ftp
  819. >information, see above. Two programs (hpack and comp-2) have been added
  820. >because they achieve better compression (at the expense of speed)
  821. >and one program (lzrw3-a) has been added because it favors speed at
  822. >the expense of compression:
  823. >- comp-2 is in wuarchive.wustl.edu:/mirrors/msdos/ddjmag/ddj9102.zip
  824. >  (inner zip file nelson.zip),
  825. >- hpack is in wuarchive.wustl.edu:/mirrors/misc/unix/hpack75a.tar-z
  826. >  and garbo.uwasa.fi:/unix/arcers/hpack75a.tar.Z
  827. >- sirius.ucs.adelaide.edu.au:/pub/compression/lzrw3-a.c  [129.127.40.3]
  828. >
  829. >The 14 files used in the comparison are from the standard Calgary
  830. >Text Compression Corpus, available by ftp on fsa.cpsc.ucalgary.ca [136.159.2.1]
  831. >in /pub/text.compression.corpus/text.compression.corpus.tar.Z.
  832. >
  833. >The whole corpus includes 18 files, but the 4 files paper[3-6] are
  834. >generally omitted in benchmarks. It contains several kinds of file
  835. >(ascii, binary, image, etc...) but has a bias towards large files.
  836. >You may well get different ratings on the typical mix of files that
  837. >you use daily, so keep in mind that the comparisons given below are
  838. >only indicative.
  839. >
  840. >The programs are ordered by decreasing total compressed size. For a
  841. >fair comparison between archivers and other programs, this size is
  842. >only the size of the compressed data, not the archive size.
  843. >
  844. >The programs were run on an idle machine, so the elapsed time
  845. >is significant and can be used to compare Unix and MSDOS programs.
  846. >
  847. >[Note: I still have to add all decompression times.]
  848. >
  849. >       size     lzrw3a   compress    lharc    yabba     pkzip    freeze 
  850. >version:                   4.0       1.02      1.0       1.10     2.3.2 
  851. >options:                                    -m300000                    
  852. >       ------    -----    ------    ------    ------    ------   ------
  853. >bib    111261    49040     46528     46502     40456     41354    41515 
  854. >book1  768771   416131    332056    369479    306813    350560   344793 
  855. >book2  610856   274371    250759    252540    229851    232589   230861 
  856. >geo    102400    84214     77777     70955     76695     76172    68626 
  857. >news   377109   191291    182121    166048    168287    157326   155783 
  858. >obj1    21504    12647     14048     10748     13859     10546    10453 
  859. >obj2   246814   108040    128659     90848    114323     90130    85500 
  860. >paper1  53161    24522     25077     21748     22453     20041    20021 
  861. >paper2  82199    39479     36161     35275     32733     32867    32693 
  862. >pic    513216   111000     62215     61394     65377     63805    53291 
  863. >progc   39611    17919     19143     15399     17064     14164    14143 
  864. >progl   71646    24358     27148     18760     23512     17255    17064 
  865. >progp   49379    16801     19209     12792     16617     11877    11686 
  866. >trans   93695    30292     38240     28092     31300     23135    22861 
  867. >    3,141,622  1,400,105 1,259,141 1,200,580 1,159,340 1,141,821 1,109,290
  868. >real             0m35s     0m59s     5m03s     2m40s              5m09s
  869. >user             0m25s     0m29s     4m29s     1m46s              4m04s
  870. >sys              0m05s     0m10s     0m07s     0m18s              0m11s
  871. >MSDOS:                                                   1m39s
  872. >                        
  873. >    zip      zoo       lha       arj      pkzip     hpack    comp-2   
  874. >        1.0     2.10    1.0(Unix)   2.30      1.93a     0.75a       
  875. >     -9      ah    2.13(MSDOS)   -jm       -ex               
  876. >       ------  ------     ------       ------    ------    ------   ------
  877. >bib    40717   40742      40740        36090     35186     35619    29840  
  878. >book1  339932  339076     339074       318382    313566    306876   237380  
  879. >book2  229419  228444     228442       210521    207204    208486   174085  
  880. >geo    69837   68576      68574        69209     68698     58976    64590  
  881. >news   154865  155086     155084       146855    144954    141608   128047  
  882. >obj1    10522   10312      10310        10333     10307     10572    10819  
  883. >obj2    86661   84983      84981        82052     81213     80806    85465  
  884. >paper1    19761   19678      19676        18710     18519     18607    16895  
  885. >paper2    32296   32098      32096        30034     29566     29825    25453  
  886. >pic    56828   52223      52221        53578     52777     51778    55461  
  887. >progc    13955   13943      13941        13408     13363     13475    12896  
  888. >progl    16954   16916      16914        16408     16148     16586    17354  
  889. >progp    11558   11509      11507        11308     11214     11647    11668  
  890. >trans    22737   22580      22578        20046     19808     20506    21023  
  891. >    1,106,013 1,096,166 1,096,138 1,036,934 1,022,523 1,005,367  890,976
  892. >real    3m28s   4m07s     6m03s                       1h22m17s  27m05s
  893. >user    1m45s   3m47s      4m23s                    1h20m46s  19m27s
  894. >sys     0m11s   0m04s      0m08s                       0m12s   2m03s
  895. >MSDOS:                    1m49s     2m41s     1m55s
  896. >
  897. >Notes:
  898. >- zip 2.0 is not included in this comparison since it will be released
  899. >  only when pkzip 2.0 is released. (Compression is comparable to that of
  900. >  pkzip 1.93a.)
  901. >
  902. >- the compressed data for 'zoo ah' is always two bytes longer than for
  903. >  lha. This is simply because both programs are derived from the same
  904. >  source (ar002, written by Haruhiko Okumura).
  905. >
  906. >- hpack 0.75a gives slightly different results on SunOS (undeterministic
  907. >  behaviour still under investigation).
  908. >
  909. >- the MSDOS versions are all optimized with assembler code and were run
  910. >  on a RAM disk. So it is not surprising that they go faster than their
  911. >  Unix equivalent.
  912. >
  913. >------------------------------------------------------------------------------
  914. >
  915. >Subject: [7] Which books should I read?
  916. >
  917. >
  918. >[BWC 1989] Bell, T.C, Witten, I.H, and Cleary, J.G.  "Text Compression",
  919. >    Prentice-Hall 1989. ISBN: 0-13-911991-4. Price: approx. US$40
  920. >    The reference on text data compression.
  921. >
  922. >[Nel 1991] Mark Nelson, "The Data Compression Book"
  923. >    M&T Books, Redwood City, CA, 1991.  ISBN 1-55851-216-0.
  924. >    Price $36.95 including two 5" PC-compatible disks bearing
  925. >    all the source code printed in the book.
  926. >    A practical introduction to data compression.
  927. >    The book is targeted at a person who is comfortable reading C code but
  928. >    doesn't know anything about data compression.  Its stated goal is to get
  929. >    you up to the point where you are competent to program standard
  930. >    compression algorithms.
  931. >
  932. >[Will 1990] Williams, R.  "Adaptive Data Compression", Kluwer Books, 1990.
  933. >    ISBN: 0-7923-9085-7. Price: US$75.
  934. >    Reviews the field of text data compression and then addresses the
  935. >    problem of compressing rapidly changing data streams.
  936. >
  937. >[Stor 1988] Storer, J.A.  "Data Compression: Methods and Theory", Computer
  938. >    Science Press, Rockville, MD. ISBN: 0-88175-161-8.
  939. >    A survey of various compression techniques, mainly statistical
  940. >    non-arithmetic compression and LZSS compression.  Includes complete Pascal
  941. >    code for a series of LZ78 variants.
  942. >
  943. >[ACG 1991] Advances in Speech Coding, edited by Atal, Cuperman, and Gersho,
  944. >    Kluwer Academic Press, 1991.
  945. >
  946. >[GG 1991] Vector Quantization and Signal Compression, by Gersho and Gray,
  947. >    Kluwer Acad. Press, 1991
  948. >
  949. >[CT 1991] Elements of Information Theory, by T.M.Cover and J.A.Thomas
  950. >     John Wiley & Sons, 1991.
  951. >
  952. >Review papers:
  953. >
  954. >[BWC 1989] Bell, T.C, Witten, I.H, and Cleary, J.G.  "Modeling for Text
  955. >    Compression", ACM Computing Surveys, Vol.21, No.4 (December 1989), p.557
  956. >    A good general overview of compression techniques (as well as modeling for
  957. >    text compression); the condensed version of "Text Compression".
  958. >
  959. >[Lele 1987] Lelewer, D.A, and Hirschberg, D.S.  "Data Compression", ACM
  960. >    Computing Surveys, Vol.19, No.3 (September 1987), p.261.
  961. >    A survey of data compression techniques which concentrates on Huffman
  962. >    compression and makes only passing mention of other techniques.
  963. >
  964. >
  965. >------------------------------------------------------------------------------
  966. >
  967. >Subject: [8] What about patents on data compression algorithms?
  968. >
  969. >
  970. >[Note: the appropriate group for discussing software patents is
  971. >comp.patents (or misc.legal.computing), not comp.compression.]
  972. >
  973. >All patents mentioned here are US patents, and thus probably
  974. >not applicable outside the US.
  975. >
  976. >- The Gibson & Graybill patent 5,049,881 is the most general.
  977. >  Claims 4 and 12 cover about any LZ algorithm using hashing, and could
  978. >  even be interpreted as applying to the LZ78 family. (See below,
  979. >  "Introduction to data compression" for the meaning of 'LZ').
  980. >
  981. >     4. A compression method for compressing a stream of input data into
  982. >     a compressed stream of output data based on a minimum number of
  983. >     characters in each input data string to be compressed, said
  984. >     compression method comprising the creation of a hash table, hashing
  985. >     each occurrence of a string of input data and subsequently searching
  986. >     for identical strings of input data and if such an identical string
  987. >     of input data is located whose string size is at least equal to the
  988. >     minimum compression size selected, compressing the second and all
  989. >     subsequent occurrences of such identical string of data, if a string
  990. >     of data is located which does not match to a previously compressed
  991. >     string of data, storing such data as uncompressed data, and for each
  992. >     input strings after each hash is used to find a possible previous
  993. >     match location of the string, the location of the string is stored
  994. >     in the hash table, thereby using the previously processed data to
  995. >     act as a compression dictionary.
  996. >
  997. >  Claim 12 is identical, with 'method' replaced with 'apparatus'.
  998. >  Since the 'minimal compression size' can be as small as 2, the claim
  999. >  covers any dictionary technique of the LZ family.
  1000. >
  1001. >- Phil Katz, author of pkzip, also has a patent on LZ77 (5,051,745)
  1002. >  but the claims only apply to sorted hash tables, and when the hash
  1003. >  table is substantially smaller than the window size.
  1004. >
  1005. >- The LZW algorithm used in 'compress' is patented by IBM (4,814,746)
  1006. >  and Unisys (4,558,302). Unisys has licensed it for use in the V.42bis
  1007. >  compression standard. (See question 11 on V.42bis below.)
  1008. >
  1009. >- AP coding is patented by Storer (4,876,541). (Get the yabba package
  1010. >  for source code, see question 2 above, file type .Y)
  1011. >
  1012. >- Fiala and Greene have a patent (4,906,991?) on the algorithms they
  1013. >  published in Comm.ACM, April 89. One of their algorithms is used in lha
  1014. >  and zoo, and was used in zip 0.8.
  1015. >
  1016. >- IBM patented (5,001,478) the idea of combining a history buffer (the
  1017. >  LZ77 technique) and a lexicon (as in LZ78).
  1018. >
  1019. >- IBM holds a patent on the Q-coder implementation of arithmetic
  1020. >  coding.  The arithmetic coding option of the JPEG standard requires
  1021. >  use of the patented algorithm. (See the JPEG FAQ for details.)
  1022. >
  1023. >
  1024. >Here are some references on data compression patents, taken from the
  1025. >list maintained by Michael Ernst <mernst@theory.lcs.mit.edu> in
  1026. >mintaka.lcs.mit.edu:/mitlpf/ai/patent-list (or patent-list.Z).
  1027. >
  1028. >4,464,650
  1029. >Apparatus and method for compressing data signals and restoring the
  1030. >compressed data signals
  1031. >inventors Lempel, Ziv, Cohn, Eastman
  1032. >assignees Sperry Corporation and At&T Bell Laboratories
  1033. >filed 8/10/81, granted 8/7/84
  1034. >
  1035. >4,558,302
  1036. >High speed data compression and decompression apparatus and method
  1037. >inventor Welch
  1038. >assignee Sperry Corporation (now Unisys)
  1039. >filed 6/20/83, granted 12/10/85
  1040. >The text for this patent can be ftped from ftp.uu.net as pub/lzw-patent.Z
  1041. >
  1042. >4,814,746
  1043. >Data compression method
  1044. >inventors Victor S. Miller, Mark N. Wegman
  1045. >assignee IBM
  1046. >filed 8/11/86, granted 3/21/89
  1047. >
  1048. >4,876,541
  1049. >Stem [sic] for dynamically compressing and decompressing electronic data
  1050. >inventor James A. Storer
  1051. >assignee Data Compression Corporation
  1052. >filed 10/15/87, granted 10/24/89
  1053. >
  1054. >4,955,066
  1055. >Compressing and Decompressing Text Files
  1056. >inventor Notenboom, L.A.
  1057. >assignee Microsoft
  1058. >filed  10/13/89, granted 09/04/90
  1059. >
  1060. >5,001,478
  1061. >Method of Encoding Compressed Data
  1062. >filed 1989-12-28
  1063. >granted 1991-03-19
  1064. >inventor Michael E. Nagy
  1065. >assignee IBM
  1066. >
  1067. >5,049,881
  1068. >Apparatus and method for very high data rate-compression incorporating
  1069. >lossless data compression and expansion utilizing a hashing technique
  1070. >inventors Dean K. Gibson, Mark D. Graybill
  1071. >assignee Intersecting Concepts, Inc.
  1072. >filed 6/18/90, granted 9/17/91
  1073. >cites McIntosh 3,914,586, Johannesson 4,087,788, Eastman 4,464,650,
  1074. >      Finn 4,560,976, Tsukiyama 4,586,027, 4,758,899 and 4,872,009,
  1075. >      Kunishi 4,677,649, Mathes 4,682,150, Shimoni 4,809,359, Miller 4,814,746,
  1076. >      Mukherjee 4,853,696, Fiala 4,906,991.
  1077. >
  1078. >5,051,745
  1079. >String searcher, and compressor using same
  1080. >inventor  Phillip W. Katz (author of pkzip)
  1081. >filed  8/21/90, granted 9/24/91
  1082. >cites MacCrisken 4,730,348 and Hong 4,961,139
  1083. >
  1084. >Data Compression with Finite Windows, Comm.ACM, 32,4 (1989) 490-595.
  1085. >inventors Fiala,E.R., and Greene,D.H.
  1086. >
  1087. >------------------------------------------------------------------------------
  1088. >
  1089. >Subject: [9]  The WEB 16:1 compressor.
  1090. >
  1091. >
  1092. >[WARNING: this topic has generated the greatest volume of news in the
  1093. >history of comp.compression. Read this before posting on this subject.]
  1094. >
  1095. >
  1096. >(a) What the press says
  1097. >
  1098. >April 20, 1992  Byte Week Vol 4. No. 25:
  1099. >
  1100. >   "In an announcement that has generated high interest - and more than a
  1101. >   bit of skepticism - WEB Technologies (Smyrna, GA) says it has
  1102. >   developed a utility that will compress files of greater than 64KB in
  1103. >   size to about 1/16th their original length.  Furthermore, WEB says its
  1104. >   DataFiles/16 program can shrink files it has already compressed."
  1105. >   [...]
  1106. >   "A week after our preliminary test, WEB showed us the program successfully
  1107. >   compressing a file without losing any data.  But we have not been able
  1108. >   to test this latest beta release ourselves."
  1109. >   [...]
  1110. >   "WEB, in fact, says that virtually any amount of data can be squeezed 
  1111. >   to under 1024 bytes by using DataFiles/16 to compress its own output
  1112. >   multiple times."
  1113. >
  1114. >June 1992 Byte, Vol 17 No 6:
  1115. >
  1116. >   [...] According to Earl Bradley, WEB Technologies' vice president of
  1117. >   sales and marketing, the compression algorihtm used by DataFiles/16
  1118. >   is not subject to the laws of information theory. [...]
  1119. >
  1120. >
  1121. >(b) First details, by John Wallace <buckeye@spf.trw.com>:
  1122. >
  1123. >I called WEB at (404)514-8000 and they sent me some product
  1124. >literature as well as chatting for a few minutes with me on the phone.
  1125. >Their product is called DataFiles/16, and their claims for it are
  1126. >roughly those heard on the net.
  1127. >
  1128. >According to their flier:
  1129. >
  1130. >"DataFiles/16 will compress all types of binary files to approximately
  1131. >one-sixteenth of their original size ... regardless of the type of
  1132. >file (word processing document, spreadsheet file, image file,
  1133. >executable file, etc.), NO DATA WILL BE LOST by DataFiles/16."
  1134. >(Their capitalizations; 16:1 compression only promised for files >64K
  1135. >bytes in length.)
  1136. >
  1137. >"Performed on a 386/25 machine, the program can complete a
  1138. >compression/decompression cycle on one megabyte of data in less than
  1139. >thirty seconds"
  1140. >
  1141. >"The compressed output file created by DataFiles/16 can be used as the 
  1142. >input file to subsequent executions of the program.  This feature of 
  1143. >the utility is known as recursive or iterative compression, and will 
  1144. >enable you to compress your data files to a tiny fraction of the 
  1145. >original size.  In fact, virtually any amount of computer data can 
  1146. >be compressed to under 1024 bytes using DataFiles/16 to compress its 
  1147. >own output files muliple times.  Then, by repeating in reverse the 
  1148. >steps taken to perform the recusive compression, all original data 
  1149. >can be decompressed to its original form without the loss of a single 
  1150. >bit."
  1151. >
  1152. >They had a table that showed the expected size of resulting files,
  1153. >with the warning that "Your actual compresion results may vary
  1154. >slightly from the figures shown".  Here is my abridged version of their
  1155. >table. 
  1156. >        ---------- Iteration -------
  1157. >INPUT        1    2    3     4        Ratio
  1158. >1K        630                    1.6:1
  1159. >16K        1.5K    812                20:1
  1160. >64K        4K    1K    644            101:1
  1161. >512K        30K    2K    938            558:1
  1162. >8M        490K    14K    1.5K    798        10512:1
  1163. >64M        3M    40K    3K    994        67513:1
  1164. >
  1165. >Their flier also claims: 
  1166. >
  1167. >"Constant levels of compression across ALL TYPES of FILES"
  1168. >"Convenient, single floppy DATA TRANSPORTATION"
  1169. >
  1170. >From my telephone conversation, I was was assured that this is an
  1171. >actual compression program.  Decompression is done by using only the 
  1172. >data in the compressed file; there are no hidden or extra files.
  1173. >
  1174. >
  1175. >(c) More information, by Rafael Ramirez <rafael.ramirez@channel1.com>:
  1176. >
  1177. >   Today (Tuesday, 28th) I got a call from Earl Bradley of Web
  1178. >who now says that they have put off releasing a software version of
  1179. >the algorithm because they are close to signing a major contract with
  1180. >a big company to put the algorithm in silicon.  He said he could not
  1181. >name the company due to non-disclosure agreements, but that they had
  1182. >run extensive independent tests of their own and verified that the
  1183. >algorithm works. [...]
  1184. >
  1185. >   Mr. Bradley went on to say that Web will not be sending out any
  1186. >more copies to magazines and that they had even recalled the copy they
  1187. >had sent to Byte.  He claimed that he told the guy at Byte that the
  1188. >version they had at the time had just been translated to assembler and
  1189. >had some bugs, but that the guy at Byte kept insisting that they send
  1190. >a copy anyway, and so of course the version Byte had didn't work.
  1191. >
  1192. >[Correction from Russ Schnapp <rschnapp@metaflow.com>:
  1193. >Contrary to WEB's claim, I did NOT insist that WEB send me a
  1194. >non-functional copy of the program. I didn't even ask for the latest
  1195. >version.]
  1196. >
  1197. >He said the algorithm is so simple that he doesn't want anybody
  1198. >getting their hands on it and copying it even though he said they
  1199. >have filed a patent on it. [...] Mr. Bradley said the silicon version
  1200. >would hold up much better to patent enforcement and be harder to copy.
  1201. >
  1202. >   He claimed that the algorithm takes up about 4K of code, uses only
  1203. >integer math, and the current software implementation only uses a 65K
  1204. >buffer.  He said the silicon version would likely use a parallel
  1205. >version and work in real-time.
  1206. >
  1207. >   He said they will be sending out copies to about seven companies
  1208. >that want to license the technology for various applications but he
  1209. >could not give out any names due to non-disclosure agreements.  He
  1210. >hoped that in about two weeks he will be able to make an announcement
  1211. >and said he would call me when he could provide independent
  1212. >verification that the algorithm works.  For now, we can only wait.
  1213. >
  1214. >   He also said they have not as yet sold anything, but that he's
  1215. >been traveling constantly for the last three weeks (presumably to
  1216. >the seven companies he mentioned) and that he hasn't slept very
  1217. >well lately just thinking about all the applications the algorithm
  1218. >could be applied to.
  1219. >
  1220. >   And he confirmed that each pass will get 16:1 compression as
  1221. >long as the data is >64K, and that regardless, any file should be
  1222. >able to be compressed to less than 1024 bytes after enough passes.
  1223. >I asked if he is claiming that they can compress ANY data including
  1224. >data that is already compressed, and he just answered by saying
  1225. >that they had tested the program by compressing PKZIP files, and
  1226. >other files and that they all compressed as claimed (which of course
  1227. >still doesn't answer the question).
  1228. >
  1229. >
  1230. >(d) The interpretation of the claims
  1231. >
  1232. >The biggest controversy is over the claim to compress "all types of
  1233. >files".  As noted above by Rafael Ramirez, we do not know with
  1234. >certainty if WEB claims to compress *all* files greater than 64K
  1235. >bytes, or just *most* files. The WEB flier only says all *types* of
  1236. >files, not *all* files.  Keep this in mind when reading the
  1237. >impossibility proof given below.
  1238. >
  1239. >
  1240. >(e) The impossiblity proofs.
  1241. >
  1242. >It is impossible for a given program to compress without loss *all*
  1243. >files greater than a certain size by at least one bit. This can be
  1244. >proven by a simple counting argument. (Many other proofs have been
  1245. >posted on comp.compression, *please* do not post yet another one.)
  1246. >
  1247. >Assume that the program can compress without loss all files of size >= N
  1248. >bits.  Compress with this program all the 2^N files which have
  1249. >exactly N bits.  All compressed files have at most N-1 bits, so there
  1250. >are at most 2^(N-1) different compressed files. So at least two
  1251. >different input files must compress to the same output file. (Actually
  1252. >at least half of them, but two suffice for the proof.) Hence the
  1253. >compression program cannot be lossless.
  1254. >
  1255. >This argument applies of course to WEB's case (take N = 64K*8 bits).
  1256. >Note that no assumption is made about the compression algorithm.
  1257. >The proof applies to *any* algorithm, including those using an
  1258. >external dictionary, or repeated application of another algorithm,
  1259. >or combination of different algorithms, or representation of the
  1260. >data as formulas, etc... All schemes are subject to the counting argument.
  1261. >There is no need to use information theory to provide a proof, just
  1262. >basic mathematics.
  1263. >
  1264. >This assumes of course that the information available to the decompressor
  1265. >is only the bit sequence of the compressed data. If external information
  1266. >such as a file name or a number of iterations is necessary to decompress
  1267. >the data, the bits providing the extra information must be included in
  1268. >the bit count of the compressed data. (Otherwise, it would be sufficient
  1269. >to consider any input data as a number, use this as the iteration
  1270. >count or file name, and pretend that the compressed size is zero.)
  1271. >
  1272. >
  1273. >(f) Late news: no software version
  1274. >
  1275. >Appeared on BIX, reposted by Bruce Hoult <Bruce.Hoult@actrix.gen.nz>:
  1276. >
  1277. >tojerry/chaos #673, from abailey, 562 chars, Tue Jun 16 20:40:34 1992
  1278. >Comment(s). 
  1279. >----------
  1280. >TITLE: WEB Technology
  1281. >I promised everyone a report when I finally got the poop on WEB's
  1282. >16:1 data compression. After talking back and forth for a year
  1283. >and being put off for the past month by un-returned phone calls,
  1284. >I finally got hold of Marc Spindler who is their sales manager.
  1285. >_No_ software product is forth coming, period!
  1286. >He began talking about hardware they are designing for delivery
  1287. >at the end of the year. [...]
  1288. >
  1289. >
  1290. >(g) Conclusion
  1291. >
  1292. >Most readers of comp.compression are tired of this thread.  Please,
  1293. >please, do not post another article "I know this has been beaten to
  1294. >death, but...".
  1295. >
  1296. >The consensus is that we have to wait until WEB delivers a real product
  1297. >which can be independently tested. Only then will it be possible
  1298. >to know exactly what the product can and cannot do.
  1299. >
  1300. >[See also question 73 "What is the theoretical compression limit?" in
  1301. >part 2 of this FAQ.]
  1302. >
  1303. >------------------------------------------------------------------------------
  1304. >
  1305. >Subject: [11] What is the V.42bis standard?
  1306. >
  1307. >
  1308. >from Alejo Hausner <hausner@qucis.queensu.ca>:
  1309. >
  1310. >The V.42bis Compression Standard was proposed by the International
  1311. >Consultative Committee on Telephony and Telegraphy (CCITT) as an
  1312. >addition to the v.42 error-correction protocol for modems. Its purpose
  1313. >is to increase data throughput, and uses a variant of the
  1314. >Lempel-Ziv-Welch (LZW) compression method.  It is meant to be
  1315. >implemented in the modem hardware, but can also be built into the
  1316. >software that interfaces to an ordinary non-compressing modem.
  1317. >
  1318. >V.42bis can send data compressed or not, depending on the
  1319. >data.  There are some types of data that cannot be
  1320. >compressed.  For example, if a file was compressed first,
  1321. >and then sent through a V.42bis modem, the modem would not
  1322. >likely reduce the number of bits sent.  Indeed it is likely
  1323. >that the amount of data would increase somewhat.
  1324. >
  1325. >To avoid this problem, the algorithm constantly monitors the
  1326. >compressibility of the data, and if it finds fewer bits
  1327. >would be necessary to send it uncompressed, it switches to
  1328. >transparent mode.  The sender informs the receiver of this
  1329. >transition through a reserved escape code.  Henceforth the
  1330. >data is passed as plain bytes.
  1331. >
  1332. >The choice of escape code is clever.  Initially, it is a
  1333. >zero byte.  Any occurrence of the escape code is replaced,
  1334. >as is customary, by two escape codes.  In order to prevent a
  1335. >string of escape codes from temporarily cutting throughput
  1336. >in half, the escape code is redefined by adding 51 mod 256
  1337. >each time it is used.
  1338. >
  1339. >While transmitting in transparent mode, the sender maintains
  1340. >the LZW trees of strings, and expects the receiver to do
  1341. >likewise.  If it finds an advantage in returning to
  1342. >compressed mode, it will do so, first informing the receiver
  1343. >by a special control code.  Thus the method allows the
  1344. >hardware to adapt to the compressibility of the data.
  1345. >
  1346. >
  1347. >The CCITT standards documents are available by ftp on src.doc.ic.ac.uk,
  1348. >in directory doc/ccitt-standards/ccitt. The v42bis standard is in
  1349. >/doc/ccitt-standards/ccitt/1992/v/v42bis.asc.Z.
  1350. >(ccitt standards used to be on ftp.uu.net in /doc/standards/ccitt
  1351. >but this directory is now empty -- Aug 11th.)
  1352. >
  1353. >------------------------------------------------------------------------------
  1354. >
  1355. >Subject: [12] I need source for the winners of the Dr Dobbs compression contest
  1356. >
  1357. >
  1358. >The source of the top 6 programs of the Feb 91 Dr Dobbs data compression
  1359. >contest are available by ftp on
  1360. >  wsmr-simtel20.army.mil in pd1:<msdos.compress>ddjcompr.zip. [192.88.110.2]
  1361. >  garbo.uwasa.fi:/pc/source/ddjcompr.zip [128.214.87.1]
  1362. >
  1363. >The sources are in MSDOS end-of-line format, one directory per program.
  1364. >Unix or VMS users, use "unzip -ad ddjcompr" to get correct end-of-lines
  1365. >and recreate the directory structure. Five of the 6 programs are not
  1366. >portable and only run on MSDOS.
  1367. >
  1368. >------------------------------------------------------------------------------
  1369. >
  1370. >Subject: [13] I need source for arithmetic coding
  1371. >
  1372. >
  1373. >(See question 70 for an introduction to arithmetic coding.)
  1374. >
  1375. >Kris Popat <popat@image.mit.edu> has worked on "Scalar Quantization
  1376. >with Arithmetic Coding."  It describes an arithmetic coding technique
  1377. >which is quite general and computationally inexpensive.  The
  1378. >documentation and example C code are available via anonymous ftp from
  1379. >media-lab.media.mit.edu (18.85.0.2), in /pub/k-arith-code.
  1380. >
  1381. >See also the directory /pub/arithmetic.coding on fsa.cpsc.ucalgary.ca
  1382. >[136.159.2.1].
  1383. >
  1384. >------------------------------------------------------------------------------
  1385. >
  1386. >Subject: [15] Where can I get image compression programs?
  1387. >
  1388. >
  1389. >JPEG:
  1390. >      Source code for most any machine:
  1391. >      ftp.uu.net:/graphics/jpeg/jpegsrc.v3.tar.Z [137.39.1.9]
  1392. >      nic.funet.fi:/pub/graphics/programs/jpeg/jpegsrc.v3.tar.Z [128.214.6.100]
  1393. >      Contact: jpeg-info@uunet.uu.net (Independent JPEG Group)
  1394. >
  1395. >      xv, an image viewer which can read JPEG pictures, is available in
  1396. >      ftp.cicb.fr:/pub/X11R5/contrib/xv-2.20.tar.Z  [129.20.128.2]
  1397. >
  1398. >epic:
  1399. >      whitechapel.media.mit.edu:/pub/epic.tar.Z [18.85.0.125]
  1400. >      The "Lenna" test image is available as part of the EPIC package,
  1401. >      where it is named "test_image".
  1402. >
  1403. >compfits:
  1404. >      uwila.cfht.hawaii.edu:/pub/compfits/compfits.tar.Z  [128.171.80.50]
  1405. >      Contact: Jim Wright <jwright@cfht.hawaii.edu>
  1406. >
  1407. >fitspress:
  1408. >      128.103.40.79:/pub/fitspress08.tar.Z
  1409. >
  1410. >tiff:
  1411. >      For source and sample images, see question 18 below.
  1412. >
  1413. >------------------------------------------------------------------------------
  1414. >
  1415. >Subject: [16] What is the state of the art in lossless image compression?
  1416. >
  1417. >
  1418. >The current state-of-the-art is the JBIG algorithm.  For an
  1419. >introduction to JBIG, see question 54 in part 2.
  1420. >
  1421. >JBIG works best on bi-level images (like faxes) and also works well on
  1422. >Gray-coded grey scale images up to about six or so bits per pixel.  You
  1423. >just apply JBIG to the bit planes individually.  For more bits/pixel,
  1424. >lossless JPEG provides better performance, sometimes. (For JPEG, see
  1425. >question 19 below.)
  1426. >
  1427. >You can find a description of JBIG in ISO/IEC CD 11544, contained in
  1428. >document ISO/IEC JTC1/SC2/N2285.  The only way to get it is to ask
  1429. >your National Standards Body for a copy.
  1430. >
  1431. >------------------------------------------------------------------------------
  1432. >
  1433. >Subject: [17] What is the state of fractal compression?
  1434. >
  1435. >
  1436. >from Tal Kubo <kubo@zariski.harvard.edu>:
  1437. >
  1438. >According to Barnsley's book 'Fractals Everywhere', this method is
  1439. >based on a measure of deviation between a given image and its
  1440. >approximation by an IFS code.  The Collage Theorem states that there is
  1441. >a convergent process to minimize this deviation.  Unfortunately,
  1442. >according to an article Barnsley wrote for BYTE a few years ago, this
  1443. >convergence was rather slow, about 100 hours on a Cray, unless assisted by
  1444. >a person.
  1445. >
  1446. >Barnsley et al are not divulging any technical information beyond the
  1447. >meager bit in 'Fractals Everywhere'.  The book explains the idea of IFS
  1448. >codes at length, but is vague about the application of the Collage theorem
  1449. >to specific compression problems.
  1450. >
  1451. >There is reason to believe that Barnsley's company has
  1452. >*no algorithm* which takes a given reasonable image and achieves
  1453. >the compression ratios initially claimed for their fractal methods.
  1454. >The 1000-to-1 compression advertised was achieved only for a 'rigged'
  1455. >class of images, with human assistance. The best unaided
  1456. >performance I've heard of is good lossy compression of about 80-1.
  1457. >
  1458. >Steve Tate <srt@duke.cs.duke.edu> confirms:
  1459. >
  1460. >Compression ratios (unzoomed) seem to range from 20:1 to 60:1...  The
  1461. >quality is considerably worse than wavelets or JPEG on most of the
  1462. >non-contrived images I have seen.
  1463. >
  1464. >
  1465. >There is a fractal image compression demo program  available via anonymous
  1466. >ftp in lyapunov.ucsd.edu:/pub/fractal_image_processing/all.tar.Z.
  1467. >There are executables and sample images in the same directory.
  1468. >
  1469. >References:
  1470. >  M. Barnsley, L. Anson, "Graphics Compression Technology, SunWorld,
  1471. >    October 1991, pp. 42-52.
  1472. >  M.F. Barnsley, A. Jacquin, F. Malassenet, L. Reuter & A.D. Sloan,
  1473. >    'Harnessing chaos for image synthesis', Computer Graphics,
  1474. >    vol 22 no 4 pp 131-140, 1988.
  1475. >  M.F. Barnsley, A.E. Jacquin, 'Application of recurrent iterated
  1476. >    function systems to images', Visual Comm. and Image Processing,
  1477. >    vol SPIE-1001, 1988.
  1478. >  A. Jacquin, "Image Coding Based on a Fractal Theory of Iterated Contractive
  1479. >    Image Transformations" p.18, January 1992 (Vol 1 Issue 1) of IEEE Trans
  1480. >    on Image Processing.
  1481. >  A. Jacquin, A Fractal Theory of Iterated Markov Operators with
  1482. >    Applications to Digital Image Coding, PhD Thesis, Georgia Tech, 1989.
  1483. >  A.E. Jacquin, 'A novel fractal block-coding technique for digital
  1484. >    images', Proc. ICASSP 1990.
  1485. >  A. Jacquin, 'Fractal image coding based on a theory of iterated
  1486. >    contractive image transformations', Visual Comm. and Image
  1487. >    Processing, vol SPIE-1360, 1990.
  1488. >  G.E. Oien, S. Lepsoy & T.A. Ramstad, 'An inner product space
  1489. >    approach to image coding by contractive transformations',
  1490. >    Proc. ICASSP 1991, pp 2773-2776.
  1491. >  D.S. Mazel, Fractal Modeling of Time-Series Data, PhD Thesis,
  1492. >    Georgia Tech, 1991.    (One dimensional, not pictures)
  1493. >  S. A. Hollatz, "Digital image compression with two-dimensional affine
  1494. >    fractal interpolation functions", Department of Mathematics and
  1495. >    Statistics, University of Minnesota-Duluth, Technical Report 91-2.
  1496. >    (a nuts-and-bolts how-to-do-it paper on the technique)
  1497. >  Stark, J., "Iterated function systems as neural networks",
  1498. >    Neural Networks, Vol 4, pp 679-690, Pergamon Press, 1991.
  1499. >  Monro D M and Dudbridge F, "Fractal block coding of images",
  1500. >    Electronics Letters 28(11):1053-1054 (1992)
  1501. >  Beaumont J M, "Image data compression using fractal techniques",
  1502. >    British Telecom Technological Journal 9(4):93-108 (1991)
  1503. >  Fisher Y, "Fractal image compression", Siggraph 92
  1504. >  Graf S, "Barnsley's Scheme for the Fractal Encoding of Images",
  1505. >    Journal Of Complexity, V8, 72-78 (1992).
  1506. >
  1507. >
  1508. >Barnsley's company is:
  1509. >
  1510. >Iterated Systems, Inc.
  1511. >5550A Peachtree Parkway, Suite 545
  1512. >Norcross, GA  30092
  1513. >404-840-0728
  1514. >404-840-0029 (fax)
  1515. >
  1516. >------------------------------------------------------------------------------
  1517. >
  1518. >Subject: [18] I need specs and source for TIFF and CCITT group 4 Fax
  1519. >
  1520. >
  1521. >Specs for Group 3 and 4 image coding (group 3 is very similar to group 4)
  1522. >are in CCITT (1988) volume VII fascicle VII.3. They are recommendations
  1523. >T.4 and T.6 respectively. There is also an updated spec contained in 1992
  1524. >recommendations T.1 to T.6.
  1525. >
  1526. >CCITT specs are available by anonymous ftp (see above answer on V.42bis).
  1527. >The T.4 spec is in ccitt/1988/ascii/7_3_01.txt.Z, the T.6 spec
  1528. >is in 7_3_02.txt.Z.
  1529. >
  1530. >Source code can be obtained as part of a TIFF toolkit - TIFF image
  1531. >compression techniques for binary images include CCITT T.4 and T.6:
  1532. >
  1533. >    sgi.com:/graphics/tiff/v3.0beta.tar.Z     [192.48.153.1]
  1534. >    Contact: sam@sgi.com
  1535. >
  1536. >There is also a companion compressed tar file (v3.0pics.tar.Z) that
  1537. >has sample TIFF image files. A draft of TIFF 6.0 is in TIFF6.ps.Z.
  1538. >
  1539. >See also question 54 below.
  1540. >
  1541. >------------------------------------------------------------------------------
  1542. >
  1543. >Subject: [19] What is JPEG?
  1544. >
  1545. >
  1546. >JPEG (pronounced "jay-peg") is a standardized image compression mechanism.
  1547. >JPEG stands for Joint Photographic Experts Group, the original name of the
  1548. >committee that wrote the standard.  JPEG is designed for compressing either
  1549. >full-color or gray-scale digital images of "natural" (real-world) scenes.
  1550. >JPEG does not handle black-and-white (1-bit-per-pixel) images, nor does it
  1551. >handle motion picture compression.  (Standards for compressing those types
  1552. >of images are being worked on by other committees, named JBIG and MPEG
  1553. >respectively.)
  1554. >
  1555. >A good introduction to JPEG is posted regularly in news.answers by
  1556. >Tom Lane <tgl+@cs.cmu.edu>. (See question 53 "Where are FAQ lists archived"
  1557. >if this posting has expired at your site.)
  1558. >
  1559. >------------------------------------------------------------------------------
  1560. >
  1561. >Subject: [20] I am looking for source of an H.261 codec.
  1562. >
  1563. >
  1564. >The H.261 spec is available on src.doc.ic.ac.uk in
  1565. >/doc/ccitt-standards/ccitt/1992/h/h261.doc.Z (or h261.rtf.Z)
  1566. >
  1567. >
  1568. >from Thierry TURLETTI <turletti@sophia.inria.fr>:
  1569. >
  1570. >We have implemented a software version of H.261 codec. 
  1571. >It runs on top of UNIX and X-Windows. The coder uses the simple video capture
  1572. >board "VideoPix" provided by SUN for the SparcStation. The output is directed
  1573. >towards a standard TCP connection, instead of the leased lines or switched 
  1574. >circuits for which regular H.261 codecs are designed. This enable us to test
  1575. >video conferences over regular internet connections.
  1576. >We have to polish it a bit, but the first release is now available by anonymous
  1577. >ftp from avahi.inria.fr, in "/pub/h261.tar.Z".
  1578. >
  1579. >------------------------------------------------------------------------------
  1580. >
  1581. >Subject: [25] Fast DCT (Discrete Cosine Transform) algorithms
  1582. >
  1583. >
  1584. >Here are some references provided by Tom Lane <tgl+@cs.cmu.edu>:
  1585. >
  1586. >Polynomial Transform Computation of the 2-D DCT, Duhamel & Guillemot,
  1587. >  ICASSP '90 p. 1515.
  1588. >A Forward-Mapping Realization of the Inverse DCT, McMillan & Westover,
  1589. >  DCC '92 p. 219.
  1590. >A Fast Algorithm for 2-D DCT, Cho, Yun & Lee, ICASSP '91 p. 2197.
  1591. >Fast Algorithm and Implementation of 2-D DCT, Cho & Lee, Tr. CAS v38 p. 297.
  1592. >A DCT Chip based on a new Structured and Computationally Efficient DCT
  1593. >  Algorithm, Duhamel, Guillemot & Carlach, ICCAS '90 p. 77.
  1594. >Trade-offs in the Computation of Mono- and Multi-dimensional DCTs,
  1595. >  Vetterli, Duhamel & Guillemot, ICASSP '89 p. 999.
  1596. >Practical Fast 1-D DCT Algorithms with 11 Multiplications,
  1597. >  Loeffler, Ligtenberg & Moschytz, ICASSP '89 p. 988.
  1598. >New Scaled DCT Algorithms for Fused Multiply/Add Architectures,
  1599. >  Linzer & Feig, ICASSP '91 p. 2201.
  1600. >Fast Algorithms for the 2-D Discrete Cosine Transform, Kamangar & Rao,
  1601. >  IEEE Tr. Computers, v C-31 p. 899.
  1602. >Fast 2-D Discrete Cosine Transform, Vetterli, ICASSP '85 p. 1538.
  1603. >A Two-Dimensional Fast Cosine Transform, Haque, Tr. ASSP v ASSP-33 p. 1532.
  1604. >Real-Time Parallel and Fully Pipelined 2-D DCT Lattice Structures with
  1605. >  Application to HDTV Systems, Chiu & Liu, Tr. CAS for Video Tech, v 2 p. 25.
  1606. >
  1607. >The Rao & Yip book cited in the jpeg v3 DCT code (see item 15 above) is a
  1608. >good overall introduction, with an extensive (though now dated) bibliography.
  1609. >
  1610. >------------------------------------------------------------------------------
  1611. >
  1612. >Subject: [26] Are there algorithms and standards for audio compression?
  1613. >
  1614. >
  1615. >Yes. See the introduction to MPEG given in part 2 of this FAQ.
  1616. >
  1617. >A compression program for Sun audio files (.au) is available by anonymous
  1618. >ftp as svr-ftp.eng.cam.ac.uk:/pub/misc/shorten-0.2.shar.
  1619. >
  1620. >
  1621. >Copied from the comp.dsp FAQ posted by guido@cwi.nl (Guido van Rossum):
  1622. >
  1623. >Strange though it seems, audio data is remarkably hard to compress
  1624. >effectively.  For 8-bit data, a Huffman encoding of the deltas between
  1625. >successive samples is relatively successful.  For 16-bit data,
  1626. >companies like Sony and Philips have spent millions to develop
  1627. >proprietary schemes.
  1628. >
  1629. >Public standards for voice compression are slowly gaining popularity,
  1630. >e.g. CCITT G.721 and G.723 (ADPCM at 32 and 24 kbits/sec).  (ADPCM ==
  1631. >Adaptive Delta Pulse Code Modulation.)  Free source code for a *fast*
  1632. >32 kbits/sec ADPCM algorithm is available by ftp from ftp.cwi.nl as
  1633. >/pub/adpcm.shar.
  1634. >
  1635. >
  1636. >There are also two US federal standards, 1016 (Code excited linear
  1637. >prediction (CELP), 4800 bits/s) and 1015 (LPC-10E, 2400 bits/s).  See
  1638. >also the appendix for 1016.
  1639. >
  1640. >(Note that U-LAW and silence detection can also be considered
  1641. >compression schemes.)
  1642. >
  1643. >------------------------------------------------------------------------------
  1644. >
  1645. >Subject: [30] My archive is corrupted!
  1646. >
  1647. >
  1648. >The two most common reasons for this are
  1649. >
  1650. >(1) failing to use the magic word "tenex" (when connected to SIMTEL20 and
  1651. >    other TOPS20 systems) or "binary" (when connected to UNIX systems) when
  1652. >    transferring the file from an ftp site to your host machine.  The
  1653. >    reasons for this are technical and boring.  A synonym for "tenex" is
  1654. >    "type L 8", in case your ftp doesn't know what "tenex" means.
  1655. >
  1656. >(2) failing to use an eight-bit binary transfer protocol when transferring
  1657. >    the file from the host to your PC.  Make sure to set the transfer type
  1658. >    to "binary" on both your host machine and your PC.
  1659. >
  1660. >------------------------------------------------------------------------------
  1661. >
  1662. >Subject: [31] pkunzip reports a CRC error!
  1663. >
  1664. >
  1665. >The portable zip contains many workarounds for undocumented restrictions
  1666. >in pkunzip. Compatibility is ensured for pkunzip 1.10 only. All previous
  1667. >versions (pkunzip 1.0x) have too many bugs and cannot be supported. This
  1668. >includes Borland unzip.
  1669. >
  1670. >So if your pkunzip reports a CRC error, check that you are not using
  1671. >an obsolete version. Get either pkzip 1.10 or unzip 4.2 (see question
  1672. >2 above for ftp sites).
  1673. >
  1674. >Immediately after zip 1.0 was released, a new undocumented feature
  1675. >of pkunzip was discovered, which causes CRC errors even with pkunzip 1.10
  1676. >on rare occasions. A patch is available on valeria.cs.ucla.edu in
  1677. >/pub/zip10.patch.
  1678. >
  1679. >------------------------------------------------------------------------------
  1680. >
  1681. >Subject: [32] VMS zip is not compatible with pkzip!
  1682. >
  1683. >
  1684. >The problem is most likely in the file transfer program.
  1685. >
  1686. >Many use kermit to transfer zipped files between PC and VMS VAX.  The
  1687. >following VMS kermit settings make VMS-ZIP compatible with PKZIP:
  1688. >
  1689. >                                             VMS kermit        PC kermit
  1690. >                                           ---------------   --------------
  1691. >
  1692. >Uploading PKZIPped file to be UNZIPped:    set fi ty fixed    set fi ty bi
  1693. >Downloading ZIPped file to be PKUNZIPped:  set fi ty block    set fi ty bi
  1694. >
  1695. >If you are not using kermit, transfer a file created by pkzip on MSDOS
  1696. >to VMS, transfer it back to your PC and check that pkunzip can extract it.
  1697. >
  1698. >------------------------------------------------------------------------------
  1699. >
  1700. >Subject: [50] What is this 'tar' compression program?
  1701. >
  1702. >
  1703. >tar is not a compression program. It just combines several files
  1704. >into one, without compressing them. tar file are often compressed with
  1705. >'compress', resulting in a .tar.Z file. See question 2, file type .tar.Z.
  1706. >(However, some versions of tar have the capability to compress files
  1707. >as well.)
  1708. >
  1709. >When you have to archive a lot of very small files, it is often
  1710. >preferable to create a single .tar file and compress it, than to
  1711. >compress the individual files separately. The compression program can
  1712. >thus take advantage of redundancy between separate files.  The
  1713. >disadvantage is that you must uncompress the whole .tar file to
  1714. >extract any member.
  1715. >
  1716. >------------------------------------------------------------------------------
  1717. >
  1718. >Subject: [51] I need a CRC algorithm
  1719. >
  1720. >
  1721. >As its name implies (Cyclic Redundancy Check) a crc adds redundancy
  1722. >whereas the topic of this group is to remove it. But since this
  1723. >question comes up often, here is some code (by Rob Warnock <rpw3@sgi.com>).
  1724. >
  1725. >The following C code does CRC-32 in BigEndian/BigEndian byte/bit order.
  1726. >That is, the data is sent most significant byte first, and each of the bits
  1727. >within a byte is sent most significant bit first, as in FDDI. You will need
  1728. >to twiddle with it to do Ethernet CRC, i.e., BigEndian/LittleEndian byte/bit
  1729. >order. [Left as an exercise for the reader.]
  1730. >
  1731. >The CRCs this code generates agree with the vendor-supplied Verilog models
  1732. >of several of the popular FDDI "MAC" chips.
  1733. >
  1734. >u_long crc32_table[256];
  1735. >/* Initialized first time "crc32()" is called. If you prefer, you can
  1736. > * statically initialize it at compile time. [Another exercise.]
  1737. > */
  1738. >
  1739. >u_long crc32(u_char *buf, int len)
  1740. >{
  1741. >        u_char *p;
  1742. >        u_long  crc;
  1743. >
  1744. >        if (!crc32_table[1])    /* if not already done, */
  1745. >                init_crc32();   /* build table */
  1746. >        crc = 0xffffffff;       /* preload shift register, per CRC-32 spec */
  1747. >        for (p = buf; len > 0; ++p, --len)
  1748. >                crc = (crc << 8) ^ crc32_table[(crc >> 24) ^ *p];
  1749. >        return ~crc;            /* transmit complement, per CRC-32 spec */
  1750. >}
  1751. >
  1752. >/*
  1753. > * Build auxiliary table for parallel byte-at-a-time CRC-32.
  1754. > */
  1755. >#define CRC32_POLY 0x04c11db7     /* AUTODIN II, Ethernet, & FDDI */
  1756. >
  1757. >init_crc32()
  1758. >{
  1759. >        int i, j;
  1760. >        u_long c;
  1761. >
  1762. >        for (i = 0; i < 256; ++i) {
  1763. >                for (c = i << 24, j = 8; j > 0; --j)
  1764. >                        c = c & 0x80000000 ? (c << 1) ^ CRC32_POLY : (c << 1);
  1765. >                crc32_table[i] = c;
  1766. >        }
  1767. >}
  1768. >
  1769. >------------------------------------------------------------------------------
  1770. >
  1771. >Subject: [52] What about those people who continue to ask frequently asked
  1772. >              questions in spite of the frequently asked questions document?
  1773. >
  1774. >
  1775. >Just send them a polite mail message, referring them to this document.
  1776. >There is no need to flame them on comp.compression.  That would just
  1777. >add more noise to this group.  Posted answers that are in the FAQ are
  1778. >just as annoying as posted questions that are in the FAQ.
  1779. >
  1780. >------------------------------------------------------------------------------
  1781. >
  1782. >Subject: [53] Where are FAQ lists archived?
  1783. >
  1784. >
  1785. >Many are crossposted to news.answers.  That newsgroup should have a
  1786. >long expiry time at your site; if not, talk to your sysadmin.
  1787. >
  1788. >FAQ lists are available by anonymous FTP from pit-manager.mit.edu
  1789. >(18.72.1.58) and by email from mail-server@pit-manager.mit.edu (send
  1790. >a message containing "help" for instructions about the mail server).
  1791. >
  1792. >This posting is /pub/usenet/news.answers/compression-faq/part1.
  1793. >Part 2 is in (guess?) compression-faq/part2.
  1794. >
  1795. >------------------------------------------------------------------------------
  1796. >
  1797. >Subject: [54] I need specs for graphics formats
  1798. >
  1799. >
  1800. >Have a look in directory /pub/graphics.formats on zamenhof.cs.rice.edu.
  1801. >It contains descriptions of gif, tiff, fits, etc...
  1802. >
  1803. >See also the FAQ list for comp.graphics.
  1804. >
  1805. >------------------------------------------------------------------------------
  1806. >
  1807. >Subject: [55] Where can I find Lenna and other images?
  1808. >
  1809. >
  1810. >A bunch of standard images (lenna, baboon, cameraman, crowd, moon
  1811. >etc..)  were on ftp site gauss.eedsp.gatech.edu (130.207.226.2) in
  1812. >directory /database/images. On Apr 1st, the system manager said:
  1813. >this site has had some hardware problems and will have the image
  1814. >database back online as soon as the problems get corrected. However
  1815. >the images are still not there (June 4th).
  1816. >
  1817. >The site ftp.ipl.rpi.edu also has standard images, in two directories:
  1818. >   ftp.ipl.rpi.edu:/pub/image/still/usc 
  1819. >   ftp.ipl.rpi.edu:/pub/image/still/canon
  1820. >
  1821. >In each of those directories are the following directories:
  1822. >   bgr     - 24 bit blue, green, red
  1823. >   color   - 24 bit red, green, blue
  1824. >   gray    - 8 bit grayscale uniform weighted
  1825. >   gray601 - 8 bit grayscale CCIR-601 weighted
  1826. >
  1827. >And in these directories are the actual images.  
  1828. >
  1829. >For example, the popular lena image is in
  1830. >   ftp.ipl.rpi.edu:/pub/image/still/usc/color/lena  # 24 bit RGB
  1831. >   ftp.ipl.rpi.edu:/pub/image/still/usc/bgr/lena    # 24 bit BGR
  1832. >   ftp.ipl.rpi.edu:/pub/image/still/usc/gray/lena   # 8 bit gray
  1833. >
  1834. >All of the images are in Sun rasterfile format.  You can use the pbm
  1835. >utilities to convert them to whatever format is most convenient.
  1836. >[pbm is available in ftp.ee.lbl.gov:/pbmplus*.tar.Z].
  1837. >Questions about the ipl archive should be sent to rodney@ipl.rpi.edu.
  1838. >
  1839. >The archive maintainer at ftp.ipl.rpi.edu is interested in some method
  1840. >of establishing a canonical ftp database of images and could volunteer
  1841. >the ipl to be an ftp site for that database. Send suggestions to
  1842. >rodney@ipl.rpi.edu.
  1843. >
  1844. >
  1845. >Beware: the same image often comes in many different forms, at
  1846. >different resolutions, etc... The original lenna image is 512 wide,
  1847. >512 high, 8 bits per pel, red, green and blue fields.  Gray-scale
  1848. >versions of Lenna have been obtained in two different ways from the
  1849. >original:
  1850. > (1) Using the green field as a gray-scale image, and
  1851. > (2) Doing an RGB->YUV transformation and saving the Y component.
  1852. >Method (1) makes it easier to compare different people's results since
  1853. >everyone's version should be the same using that method.  Method (2)
  1854. >produces a more correct image.
  1855. >
  1856. >For the curious: 'lena' or 'lenna' is a digitized Playboy centerfold,
  1857. >from November 1972. (Lenna is the spelling in Playboy, Lena is the
  1858. >Swedish spelling of the name.) Lena Soderberg (ne Sjooblom) was last
  1859. >reported living in her native Sweden, happily married with three kids
  1860. >and a job with the state liquor monopoly.  In 1988, she was
  1861. >interviewed by some Swedish computer related publication, and she was
  1862. >pleasantly amused by what had happened to her picture.  That was the
  1863. >first she knew of the use of that picture in the computer business.
  1864. >
  1865. >The editorial in the January 1992 issue of Optical Engineering (v. 31
  1866. >no. 1) details how Playboy has finally caught on to the fact that
  1867. >their copyright on Lenna Sjooblom's photo is being widely infringed.
  1868. >It sounds as if you will have to get permission from Playboy to
  1869. >publish it in the future.
  1870. >
  1871. >          End of part 1 of the comp.compression faq.
  1872.  
  1873. To Whom It May Concern,
  1874.  
  1875. A few months ago I posted a request to the net regarding a postscript
  1876. compression routine.  I have since found out that Postscript 2 is to have
  1877. it's own standard way to compress images, nevertheless I have written a
  1878. postscript image compressor.
  1879.  
  1880. The postscript compressor I have written is in perl but the form of compression
  1881. is run-length encoding, and could be written in other languages, such as C, sed,
  1882. awk, nawk, etc. (I am sure that Larry could probably even write the thing in
  1883. roff--the man is mutant! ceveat: I am forever in his debt for writting perl.)
  1884.  
  1885. The most common responce that I received when telling my peers of my plans was
  1886. "Why write the thing in postscript?" or "Why write the thing at all?"
  1887.  
  1888. Everyone knows that the way screen dump/image capture routines output their
  1889. results on various architures is straight forward but disk wasteful.  Computer
  1890. screen images are not like images from other sources in that they almost always
  1891. have huge amounts of repetition, large areas all the same pattern.  And are
  1892. therefore very susceptible to run-length-encoding-type compression schemes.
  1893.  
  1894. The reasons I think that a compression routine written in postscript is valuable
  1895. are that the resulting compressed image is still a valid posctscript program,
  1896. which can be sent via E-mail without fear of corruption to anyone with a
  1897. postscript printer regardless of the machine to which it is connected, and
  1898. futhermore can be subsequently compressed with your favorite routine:
  1899. compress, pack, zip, zoo, arc, etc.
  1900.  
  1901. Finally I realize that this is not the most efficient method, but before I work
  1902. on enhancing it, I thought that I'd post it.  I would like your input on how to
  1903. improve it and I thought that many of you could use it 'as is' to help with
  1904. disk space problems (a never-ending problem at our site at least).  I have found
  1905. that users mind this form of compression less since it requires no additional
  1906. actions to print the file later.
  1907.  
  1908. If you use this package, I would appreciate timing results/comments/suggestions.
  1909. Please E-mail me any posts that you might make concerning this post so that
  1910. I will post a summary at a later date:
  1911.  
  1912.  Steve Parker                    parker@mps.ohio-state.edu
  1913.  Dept of Chemistry               201 McPherson Labs
  1914.  Ohio State University           614-292-5042
  1915.  
  1916. I have thought of many ways to improve this script:
  1917.  
  1918. 1) Record which and how many of the decompression routines were used in a given
  1919.    image, and insert only those that were used and in the order of fequency
  1920.    that they were used.
  1921. 2) Search the unique runs for patterns of 2 4 or 8 characters.
  1922. 3) Make a new decompression routine called I for insert which would be used for
  1923.    inserting unique string into a long run of repeating characters.
  1924.  
  1925. NOTE: The above ideas would most easily be accomplished by saving the compressed
  1926.       image in memory or a temp file and/or making multiple passes at the image
  1927.       data.
  1928.  
  1929. Any other suggestions?
  1930.  
  1931. Here are timing results for postscript images created on various machines,
  1932. compressed on a Sparc ELC and printed on a AppleLaserWriter II:
  1933.  
  1934.  
  1935. Test cases:
  1936.  
  1937.                                 (Apple LaserWriter II)
  1938. Filename    size in    chars      bits in    time to     approximate time
  1939.                                 image    compress     to print
  1940. -------------------------------------------------------------------------
  1941. snapshot.cmp.ps    63861         ---     67.0 s        100 s
  1942. snapshot.ps      262906       1024000        --          245 s
  1943. stripes.cmp.ps        2241         ---     31.0 s           30 s
  1944. stripes.ps      133403       1036800        --        130 s
  1945. iris.cmp.ps       73384            ---     68.5 s          100 s
  1946. iris.ps          261385        524288        --        250 s
  1947. stellar.cmp.ps      129140         ---     1027.3 s       425 s
  1948. stellar.ps     1968436       1966728        --       1740 s
  1949.  
  1950. I am presently getting results for NeXT printers, and some others.
  1951.  
  1952. These files are available by E-mail at request to above address.
  1953.  
  1954. Here is my description of the two pieces necessary for
  1955. compression/decompression (I originally had two files but now use the <DATA>
  1956. file handle of perl):
  1957.  
  1958. decomp.header    is the postscript decompression header that will be used in
  1959.         place of
  1960.         "/picstr 1024 string def
  1961.          { currentfile /picstr readhexstring pop }"
  1962.         which is often used as the proc for the image function
  1963.         ie "width hieght bitpersample proc image"
  1964.  
  1965. pscmp        is the perl script that compresses the hex digit pair
  1966.         format often used to encode a bitmap in postscript, it also
  1967.         inserts the decompression header file in a clever way.
  1968.         Since the last thing on the stack before the image command
  1969.         is called is the procedure that image will use to obtain the 
  1970.         image, pscmp looks for the image command and inserts
  1971.         pop { decompress }
  1972.         before it.  The 'pop' command removes whatever procedure was
  1973.         on the stack and then '{ decompress }' (my command) is pushed
  1974.         on the stack in it's place.
  1975.  
  1976.         It does compression with the following four "codes":
  1977.         u - one character  follows, whos ascii value  will determine
  1978.             how many "unique" hex pairs follow. 1-256   pairs.
  1979.         U - two characters follows, whos ascii values will determine
  1980.             how many "unique" hex pairs follow. 257-65535 pairs.
  1981.         r - one character  follows, whos ascii value  will determine
  1982.             how many times to "repeat" the hex pair that follows.
  1983.         R - one characters follows, whos ascii values will determine
  1984.             how many times to "repeat" the hex pair that follows.
  1985. NOTES:
  1986.         * ranges for R and U could not be made to be 257-65792,
  1987.           without splitting the runs into multiple strings,
  1988.           since the largest string is 65335.
  1989.         * I attempted two ways of storing the length of unique and
  1990.           repeating runs.
  1991.           The first and most straight forward to interpret in
  1992.           postscipt, was to store them as one or two characters whose
  1993.           ascii value was then interpretted as an integer by using the
  1994.           'currentfile read pop' sequence.
  1995.           The second used two or four digit hex number to represent
  1996.           the length of the run, and used the postscript command
  1997.           sequence:
  1998.  
  1999. /charx2  2 string def
  2000. /charx4  4 string def
  2001. /hexnum2 5 string def
  2002. /hexnum4 7 string def
  2003. /hexnum2 (16#00) def
  2004. /hexnum4 (16#0000) def
  2005. /getcount    { hexnum2 3 currentfile charx2 readstring pop
  2006.           putinterval hexnum2 cvi } def
  2007. /getbigcount    { hexnum4 3 currentfile charx4 readstring pop
  2008.           putinterval hexnum4 cvi } def
  2009.  
  2010.           which works by putting the hex number ,ie. 'fd', in a string
  2011.           like '16#00' thus giving the string '16#fd' which the command
  2012.           'cvi' interprets as 0xfd, or 253.
  2013.  
  2014.           The later method was necessary because characters representing
  2015.           serial port I/O controls, ie. '^D', '^S/^Q' were interpretted
  2016.           by the printers I/O control and not pasted to the postscript
  2017.           interpretter.
  2018.           The former method did work however with Sun's Postscript
  2019.           previewer "pageview version 3"
  2020.         * pscmp removes the comments and unnecessary white space (used
  2021.           for readability) from decomp.header as it inserts it into the
  2022.           postscript.
  2023.  
  2024. *******************************************************************************
  2025. Here is the script:
  2026.  
  2027. #!/usr/local/bin/perl
  2028. # A perl script to compress postscript images.
  2029.  
  2030. # Written by: 
  2031. # Steve Parker                    parker@mps.ohio-state.edu
  2032. # Dept of Chemistry               201 McPherson Labs
  2033. # Ohio State University           614-292-5042
  2034. # Columbus OH, 43210
  2035. #
  2036. # codes: u - small count   run of unique hex pairs
  2037. #     U - big   count   run of unique hex pairs
  2038. #     r - small count+1    repeated   hex pair
  2039. #     R - big   count+1    repeated   hex pair
  2040. #     a repeat last r or R. NOT SUPPORTED IN THIS PERL SCRIPT.
  2041. #
  2042. # formats: u cc    'hphp...'
  2043. #       U CC CC 'hphp...'
  2044. #       r cc    'hp'
  2045. #       R CC CC 'hp'
  2046. #
  2047. # where: 1) spaces are not output
  2048. #     2) uUrR are output literally
  2049. #     3) cc   is a 2 digit hex number (0-255) and represents range (1-256)
  2050. #     4) CCCC is a 4 digit hex number (0-65535) for a range (257-65535)
  2051. #        if not for max size on postscript string would be  (257-65792)
  2052. #     5) 'hp' is a hex digit pair from 'image' data.
  2053.  
  2054. $name = $0;
  2055. $name =~ s'.*/''; # remove path--like basename
  2056. $usage = "usage:\n$name [postscript_file_with_IMAGE_data]";
  2057.  
  2058. select(STDOUT); $|=1;
  2059.  
  2060. $biggest=65534;
  2061. $last="";
  2062. while (<>) {
  2063.   if ( /([^A-Fa-f\d\n])/ ) {
  2064. #   print "'$1' ->$_";
  2065.     if ($_ =~ /showpage/ || $_ =~ /grestore/ ) {
  2066. #
  2067. # FOUND a showpage or grestore so write out last repeating pair or unique run.
  2068. #
  2069.       if ($repeating) {
  2070.     # we didn't record the first pair in $repeating
  2071.     # so we needn't subtract 1.
  2072. #$num=$repeating-1;
  2073.     $num=$repeating;
  2074.         if ( $num <= 255 ) {
  2075.           #   case 2 small count repeat unit 2 hex digits.
  2076.           printf("r%02X%2s\n",$num,$last);
  2077.       $r++;
  2078.         } else {
  2079.           #   case 3  big  count repeat unit 2 hex digits.
  2080.           printf("R%02X%02X%2s\n",int($num/256),($num%256),$last);
  2081.       $R++;
  2082.         }
  2083.       } else {
  2084.     $unique_str.=$last;
  2085.     # we didn't yet record this last pair in $unique_run
  2086.     # so we needn't subtract 1.
  2087.     $num=$unique_run;
  2088.         if ( $num <= 255 ) {
  2089.           # case 0 small count unique string of hex digit pairs.
  2090.           printf("u%02X%s",$num,$unique_str);
  2091.       $u++;
  2092.         } else {
  2093.           # case 1  big  count unique string of hex digit pairs.
  2094.           printf("\nU%02X%02X%s",int($num/256),($num%256),$unique_str);
  2095.       $U++;
  2096.         }
  2097.       }
  2098.       & end;
  2099.     }
  2100. # add the postscript decompression header
  2101. # inbetween the original proc called by the 'image' command
  2102. # and the 'image' command itself
  2103.     if ( $_ =~ /^(image\s?.*)$|^([^%]*)?(\simage\s?.*)$/ ) {
  2104.       print "$1\n" if ($1);
  2105.       if ($headerin) {
  2106.         $file="/home/sysadmin/postscript/compress/decomp.header";
  2107. #       open(HEADER,"$file") || die("$name: Cannot open $file: '$!'\n");
  2108.         while (<DATA>) { s/(\s)\s+/\1/g; print if !(/^%/); }
  2109.         $headerin++;
  2110.         close(DATA);
  2111.       } else {
  2112.     print " pop { decompress } ";
  2113.       }
  2114.       print "$2";
  2115.       next;
  2116.     }
  2117.     print;
  2118.     next;
  2119.   } # else { print "\n" if ($unique_run || $repeating); }
  2120. #
  2121. #--------------------   HEX PAIR HANDLING LOOP   --------------------------
  2122. #
  2123.   while (s?([A-F0-9a-f][A-F0-9a-f])??) {
  2124.     if ($repeating) {
  2125.       if ($1 eq $last) {
  2126. #-debug print STDERR "rs"; # repeating; same
  2127.         $repeating++;   # found another one.
  2128.     # check to see if we have filled biggest postscript string
  2129.     # this will kept the decompress in postscript simple and fast.
  2130.     if ($repeating eq $biggest) {
  2131.       printf("Rfffe%2s",$last);
  2132.       # set to start over fresh
  2133.       $repeating=0;
  2134.       # $unique_str should be set to null and $unique_run set to 0
  2135.     }
  2136.       } else {
  2137. #-debug print STDERR "rd"; # repeating; different
  2138. #
  2139. # FOUND a unique hex pair so repeating unit has ended, write it out.
  2140. #
  2141. #$num=$repeating-1;
  2142.     $num=$repeating;
  2143.         if ( $repeating <= 255 ) {
  2144.           #   case 2 small count repeat unit 2 hex digits.
  2145. # -line-  $line+=6; if ( $line > 80) { $line=6; print "\n"; }
  2146. #-debug   printf STDERR ">2,%2X,%2s ",$num,$last;
  2147.           printf("r%02X%2s",$num,$last);
  2148.       $r++;
  2149.         } else {
  2150.           #   case 3  big  count repeat unit 2 hex digits.
  2151. # -line-  $line+=8; if ( $line > 80) { $line=8; print "\n"; }
  2152. #-debug   printf(">3,%2X,%2X,%2s ",int($num/256),($num%256),$last);
  2153.           printf("R%02X%02X%2s",int($num/256),($num%256),$last);
  2154.       $R++;
  2155.         }
  2156.         $repeating=0;
  2157.         $last=$1;
  2158.       }
  2159.  
  2160.     } else { # must be unique'ing
  2161.  
  2162.       if ($1 eq $last) {
  2163. #-debug print "us"; # uniquing; same
  2164. #
  2165. # FOUND a repeating hex pair so might have a unique run
  2166. # which has ended, if so write it out.
  2167. #
  2168.         if ($unique_str) {
  2169.       $num=$unique_run-1;
  2170.           if ( $num <= 255 ) {
  2171.             # case 0 small count unique string of hex digit pairs.
  2172. # -line-    $line+=(4+$unique_run)); if ( $line > 80) { $line=4+$unique_run; print "\n"; }
  2173. #-debug     printf("\n>0,%2X,'%s' ",$num,$unique_str);
  2174.             printf("\nu%02X%s",$num,$unique_str);
  2175.         $u++;
  2176.           } else {
  2177.             # case 1  big  count unique string of hex digit pairs.
  2178. # -line-    $line+=(6+$unique_run); if ( $line > 80) { $line=6+$unique_run; print "\n"; }
  2179. #-debug     printf("\n>1,%2X,%2X,'%s' ",int($num/256),($num%256),
  2180.             printf("\nU%02X%02X%s",int($num/256),($num%256),$unique_str);
  2181.         $U++;
  2182.           }
  2183.         }
  2184.         # start counting repeating pairs, reset unique_run count
  2185.         # and remember last.
  2186.         $repeating++;
  2187.         $unique_str='';$unique_run=0;
  2188.         $last=$1;
  2189.       } else { # countiue uniquing
  2190. #-debug print "ud"; # uniquing; different
  2191.         $unique_str.=$last;
  2192. #       $unique_run+=2; # use this if using $line to limit to 80 chars/line.
  2193.                         # but REMEMBER to divid by two when outputing!
  2194.         $unique_run++;
  2195.     # check to see if we have filled biggest postscript string
  2196.     # this will kept the decompress in postscript simple and fast.
  2197.     if ($unique_run eq $biggest) {
  2198.       printf("Ufffe%s",$unique_str);
  2199.       # set to start over fresh
  2200.           $unique_str='';$unique_run=0;
  2201.           $last=$1;
  2202.       # $repeating should be set to 0
  2203.     }
  2204.         $last=$1;
  2205.       }
  2206.     }
  2207.   }
  2208. }
  2209. &end;
  2210. sub end {
  2211.   printf STDERR "Statistics:\n" ;
  2212.   printf STDERR "r's:%5d\n",$r ;
  2213.   printf STDERR "R's:%5d\n",$R ;
  2214.   printf STDERR "u's:%5d\n",$u ;
  2215.   printf STDERR "U's:%5d\n",$U ;
  2216.   ($user,$system,$cuser,$csystem)=times;
  2217.   printf STDERR "Times:\tuser,\tsystem,\tcuser,\tcsystem\n";
  2218.   printf STDERR "Times:\t%5f,\t%5f,\t%5f,\t%5f\n",
  2219.          $user,$system,$cuser,$csystem;
  2220.   exit;
  2221.          }
  2222. __END__
  2223. %-------------------------------------------------------------------------------
  2224. %
  2225. % header to define 'decompress' which will replace the
  2226. % { currentfile string readhexstring pop } proc commonly used with 'image'
  2227. %
  2228. % to be placed just before the 'image' command
  2229. % the 'pop' on the following line is to remove bogus 'proc' (as above)
  2230. pop
  2231. /repeater 1 string def
  2232. /char     1 string def
  2233. /charx2   2 string def
  2234. /charx4   4 string def
  2235. /hexnum2  5 string def
  2236. /hexnum4  7 string def
  2237. /debug   30 string def
  2238. /big  65535 string def
  2239. /hexnum2 (16#00)   def
  2240. /hexnum4 (16#0000) def
  2241. /gethexpair    { currentfile char readhexstring pop } def
  2242. /getcount    { hexnum2 3
  2243.           currentfile charx2 readstring pop
  2244.           putinterval hexnum2 cvi } def
  2245. /getbigcount    { hexnum4 3
  2246.           currentfile charx4 readstring pop
  2247.           putinterval hexnum4 cvi } def
  2248. /codeu        { pop /cnt getcount def
  2249.                   big 0 1 cnt { gethexpair putinterval big } for
  2250.                   0 cnt 1 add getinterval
  2251.          } def
  2252. /codeU        { pop /cnt getbigcount def
  2253.                   big 0 1 cnt { gethexpair putinterval big } for
  2254.                   0 cnt 1 add getinterval
  2255.          } def
  2256. /coder        { pop /cnt getcount    def
  2257.           /repeater gethexpair def % get repeater unit
  2258.                   big 0 1 cnt {repeater putinterval big} for
  2259.           0 cnt 1 add getinterval
  2260.         } def
  2261. /codeR        { pop /cnt getbigcount def
  2262.           /repeater gethexpair def % get repeater unit
  2263.                   big 0 1 cnt {repeater putinterval big} for
  2264.           0 cnt 1 add getinterval
  2265.                 } def
  2266. /codeX        { pop big 0 cnt 1 add getinterval } def
  2267. /done        { currentfile debug readstring pstack exit } def
  2268. /skip        { pop decompress } def
  2269. #
  2270. # the following order of r,u,R,U was chosen by noting the frequency
  2271. # of occurance from a small number of examples but can easily be changed.
  2272. /others0    { dup (u)  eq { codeu } { others1 } ifelse } def
  2273. /others1    { dup (R)  eq { codeR } { others2 } ifelse } def
  2274. /others2    { dup (U)  eq { codeU } { others3 } ifelse } def
  2275. /others3    { dup (a)  eq { codeX } { others4 } ifelse } def
  2276. /others4    { dup (\n) eq { skip  } {  done   } ifelse } def
  2277. /decompress    { currentfile char readstring pop
  2278.           dup (r)  eq { coder } { others0 } ifelse } def
  2279. { decompress }
  2280. %-----------------------------------------------------------------------------
  2281.