Recent

Author Topic: Pure Pascal LZ4, LZ5 and LIZ  (Read 1425 times)

LemonParty

  • Sr. Member
  • ****
  • Posts: 457
Re: Pure Pascal LZ4, LZ5 and LIZ
« Reply #15 on: May 02, 2026, 05:22:24 pm »
I applied your changes and tested compression with this program:
Code: Pascal  [Select][+][-]
  1.  
  2. {$Mode ObjFPC}{$H+}
  3. {$R *.res}
  4.  
  5. uses
  6.   LizSimple;
  7.  
  8. var
  9.   S: String = 'Word Word Word Word Word Word Word Word Word Word Word Word Word Word Word Word Word Word Word Word Word Word Word Word Word Word Word Word Word Word Word Word Word Word ';
  10.   Compressed: String;
  11. begin
  12.   Compressed:= LIZ(S);
  13.   Writeln(Length(S), ' ', Length(Compressed));
  14.   Readln;
  15. end.
  16.  
The output is
Quote
170 190
Isn't the algorithm should find a pattern and make the resulting string to be smaller than input?
Lazarus v. 4.99. FPC v. 3.3.1. Windows 11

Tomxe

  • Jr. Member
  • **
  • Posts: 63
Re: Pure Pascal LZ4, LZ5 and LIZ
« Reply #16 on: May 04, 2026, 08:47:35 am »
Isn't the algorithm should find a pattern and make the resulting string to be smaller than input?
This is a very short string and Lizard's goal is no to compress efficiently but quickly. Try with something over 1 kB.

LemonParty

  • Sr. Member
  • ****
  • Posts: 457
Re: Pure Pascal LZ4, LZ5 and LIZ
« Reply #17 on: May 04, 2026, 03:02:16 pm »
I tried with this input data:
Code: Pascal  [Select][+][-]
  1. {$Mode ObjFPC}{$H+}
  2. {$R *.res}
  3.  
  4. uses
  5.   LizSimple;
  6.  
  7. var
  8.   S: String = 'Word Word Word Word Word Word Word Word Word Word Word Word Word Word Word Word Word Word Word Word Word Word Word Word Word Word Word Word Word Word Word Word Word Word ';
  9.   Compressed: String;
  10. begin
  11.   S:= S + S + S + S + S + S + S + S + S + S + S + S + S + S + S + S;
  12.   Compressed:= LIZ(S);
  13.   Writeln(Length(S), ' ', Length(Compressed));
  14.   Readln;
  15. end.
  16.  
The output is:
Quote
2720 64
Nice. It works. Good job.

There is possible improvement to your library. Since FPC by default support overloading of functions (and Delphi too by adding "overload" to your function) you may short names of your functions this way:
Code: Pascal  [Select][+][-]
  1. LIZCompressStreams -> LIZCompress
  2. LIZDecompressStreams -> LIZDecompress
  3. LIZCompressFile -> LIZCompress
  4. LIZDecompressFile -> LIZDecompress
According function will be selected depend on argument you pass into it.
Lazarus v. 4.99. FPC v. 3.3.1. Windows 11

Tomxe

  • Jr. Member
  • **
  • Posts: 63
Re: Pure Pascal LZ4, LZ5 and LIZ
« Reply #18 on: May 05, 2026, 12:46:27 pm »

A candidate for future work may be UPX/UCL

UPX started

 

TinyPortal © 2005-2018