Page 1 of 2

How to uncompress?

Posted: Mon Oct 09, 2006 1:48 pm
by astro
How to uncompress?

Posted: Mon Oct 09, 2006 7:17 pm
by Deniz Oezmen
The files are compressed with a pretty standard LZSS variation. Try the attached program with the following command line:

Code: Select all

delzss in.txt out.txt
It works on the files you presented, but might fail on others. Just come back if that happens ...

Posted: Tue Oct 10, 2006 10:02 am
by astro
It works 100% :mrgreen:

but i need to uncompress more than 2000 files :cry:
i need source in visual C#

pls help

Posted: Tue Oct 10, 2006 11:03 am
by Deniz Oezmen
astro wrote:but i need to uncompress more than 2000 files
Well, in that case try the attached file. The first parameter should be the file specification (wildcards allowed), the second one should be an output directory. Example:

Code: Select all

DeLZSS c:\compressed\*.* c:\decompressed
astro wrote:i need source in visual C#
I am sure that would be quite easy to do, but I have neither the C# experience nor the development environment necessary to do that.

You will have to ask somebody else to translate the code. If you know how to program in C#, you should even be able to do that yourself. Delphi code is usually quite easy to read; in this case you only need to understand the procedure DecompressBlock.

Hope that helps ...

Posted: Wed Oct 11, 2006 1:50 pm
by astro
TY
Can you give source of this :?:

Posted: Wed Oct 11, 2006 2:05 pm
by Mr.Mouse
It's in the file! DPR, Delphi code!

By the way, Deniz, Good Job! Can I interest you in taking a crack at that RA compression? See the TAW Total Air War thread. That looks like a similar way, but with a dictionary saved before the compressed text. Would be really cool if you could figure that one out?

viewtopic.php?p=17481#17481

Posted: Wed Oct 11, 2006 4:19 pm
by Deniz Oezmen
Mr.Mouse wrote:It's in the file! DPR, Delphi code!
Now that you mention it, I see that I should have written that ... :-)
Mr.Mouse wrote:Can I interest you in taking a crack at that RA compression? See the TAW Total Air War thread.
Sure, I can try. I can't promise anything, however, since the winter term of my studies starts in a few days. But let's see ... ;-)

Posted: Wed Oct 11, 2006 6:03 pm
by astro
i've translated lzss decompressor code to C# but only half of file is decompressing correctly
maby i need to change this:

Code: Select all

  const byte NBits     = 12;
  const byte FBits     = 4;
  const byte Threshold = 3;

Posted: Wed Oct 11, 2006 7:09 pm
by Deniz Oezmen
astro wrote:i've translated lzss decompressor code to C# but only half of file is decompressing correctly
maby i need to change this:

Code: Select all

  const byte NBits     = 12;
  const byte FBits     = 4;
  const byte Threshold = 3;
No, the constants are correct that way. If you change them, the decompression will fail. (The deal is this: All references into the history buffer [also called "sliding window"] are 16 bits [i. e. two bytes] wide. NBits and FBits specify how many bits of those 16 are used for the length and offset values. The Threshold value tells you the minimum length of a compressed sequence -- since a buffer reference takes up two bytes, only longer sequences are compressed, thus the value of three.)

By the way, I just noticed a bug in my code. Remove the lines

Code: Select all

if (Offset = 0) and (Len = 0) then
  Exit;
That's actually complete nonsense ... though it's not critical, since it will never be invoked.

On the first look, I cannot see any problem with your code. We could try some checks, though: Output the values of "Len" and "Offset" to the console right after they have been computed. In the case of the files you posted earlier, they should look like this:

Code: Select all

lifepoint_compressed.txt:

(3, 4078)
(4, 2)
(18, 10)
(18, 28)
(4, 4084)
(10, 114)
(6, 124)


match_compressed.txt:

(10, 4078)
(5, 4089)
(4, 7)
(5, 15)
(7, 21)
(3, 29)
(14, 37)
(5, 4089)
(3, 112)
(9, 65)
(3, 8)
(9, 39)
(7, 108)
(4, 127)
(4, 123)
(10, 4078)
(11, 108)
(18, 168)
(12, 186)
(12, 138)
(17, 151)
(12, 198)
(13, 149)
(12, 228)
(5, 274)
(12, 244)
(10, 291)
(6, 198)
[Edit: Too stupid to fix my own code ... :?]

Posted: Wed Oct 11, 2006 8:27 pm
by astro
my numbers are bad

Posted: Wed Oct 11, 2006 9:28 pm
by Deniz Oezmen
astro wrote:my numbers are bad
Okay; you should first start by checking the most basic things. Have you verified that the input file has been read to memory correctly? (Examples: Is the first character of the input buffer within the DecompressBlock routine #255? Are the following characters correct? Does the buffer have the correct size?)

Posted: Thu Oct 12, 2006 2:07 pm
by astro
:D

Posted: Thu Oct 12, 2006 6:55 pm
by Deniz Oezmen
May I guess that your code is working now? ;-)

Posted: Thu Oct 12, 2006 8:00 pm
by astro
yes

Code: Select all

myprogram in.txt out.txt

Posted: Thu Oct 12, 2006 10:16 pm
by Deniz Oezmen
Sorry; I cannot try it right now, since I currently do not have the required .NET framework installed.

Nevertheless: Congratulations. ;-)