home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / PASCAL / CRUNCH10.ZIP / SQUASH.HOW < prev    next >
Encoding:
Text File  |  1988-12-15  |  2.3 KB  |  55 lines

  1. Ok, here are the steps required to implement 13-bit squashing:
  2.  
  3. 1).  Squashing uses 9 to 13 bit codes while crunching only uses 9 to 12.
  4.      Change the constant CrunchBits from 12 to 13.
  5.  
  6. 2).  The use of 13-bit codes requires a larger code table since the largest
  7.      possible code will increase from 4095 to 8191.  Change the constant
  8.      TableSize to 8191.
  9.  
  10. 3).  In 12-bit "Crunching", the header record written to the archive file
  11.      for each file archived is 30 bytes long.  The last of these bytes
  12.      contains the maximum code size (in bits).  The header records for
  13.      squashed files does not contain this entry in the header (ie. squash
  14.      headers are only 29 bytes long).  Remove the field MaxBits from the
  15.      HdrRec type definition and also remove any references to MaxBits.
  16.  
  17. 4).  Since we removed that byte from the header record in step 3, the
  18.      resulting archived filesize doesn't need the extra help that is
  19.      provided in the Update_ARC_Header procedure via the succ function.
  20.      Change the assignment statement for ArcHdr.Size to read: ArcHdr.Size :=
  21.      EndPos - HdrOffset - SizeOf(ArcHdr);
  22.  
  23. 5).  Crunched files are recognized by archive extraction programs by a value
  24.      of 8 in the Compression Type field of the header record. Squashed files
  25.      have a 9 in this field.  Modify the Begin_Arc procedure to set the
  26.      header record field ComprType to 9 instead of 8.
  27.  
  28. 6).  The crunching algorithm calls for "packing" of repeated input
  29.      characters before actually crunching the file.  Squashing does not
  30.      pre-pack the input before applying the LZW compression technique.
  31.      So...change the Pack_and_Crunch procedure to look like:
  32.  
  33.      Procedure Pack_and_Crunch(Source : String);
  34.      Var
  35.         I : Word;
  36.      Begin
  37.         If FirstCh then
  38.            CrcVal := 0;
  39.  
  40.         If Source = '' then
  41.            Crunch(-1)
  42.         else
  43.            For I := 1 to Length(Source) do begin
  44.               Inc(BytesIn);
  45.               CRCVal := ((CRCVal shr 8) and $00FF) xor
  46.                           CRCTab[(CRCVal xor Ord(Source[I])) and $00FF];
  47.               Crunch(Ord(Source[I]));
  48.            end {for};
  49.  
  50.      end {Pack_and_Crunch};
  51.  
  52.  
  53.                                                            rpb
  54.                                                       12/15/88
  55.