Poll time! Click here: Are you interested in the chiptune scene? If so, which?. Let's see what our community thinks of the chiptune scene. :) !

How to uncompress?

Read or post about compression. And decompression. Or ask questions how to decompress your files.
astro
beginner
Posts: 20
Joined: Sun Sep 24, 2006 9:34 am
Has thanked: 1 time
Been thanked: 1 time

How to uncompress?

Post by astro » Mon Oct 09, 2006 1:48 pm

How to uncompress?
You do not have the required permissions to view the files attached to this post.

User avatar
Deniz Oezmen
VIP member
VIP member
Posts: 185
Joined: Mon Aug 28, 2006 2:07 pm
Has thanked: 1 time
Been thanked: 14 times
Contact:

Post by Deniz Oezmen » Mon Oct 09, 2006 7:17 pm

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 ...
You do not have the required permissions to view the files attached to this post.

astro
beginner
Posts: 20
Joined: Sun Sep 24, 2006 9:34 am
Has thanked: 1 time
Been thanked: 1 time

Post by astro » Tue Oct 10, 2006 10:02 am

It works 100% :mrgreen:

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

pls help

User avatar
Deniz Oezmen
VIP member
VIP member
Posts: 185
Joined: Mon Aug 28, 2006 2:07 pm
Has thanked: 1 time
Been thanked: 14 times
Contact:

Post by Deniz Oezmen » Tue Oct 10, 2006 11:03 am

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 ...
You do not have the required permissions to view the files attached to this post.

astro
beginner
Posts: 20
Joined: Sun Sep 24, 2006 9:34 am
Has thanked: 1 time
Been thanked: 1 time

Post by astro » Wed Oct 11, 2006 1:50 pm

TY
Can you give source of this :?:

User avatar
Mr.Mouse
Site Admin
Posts: 4051
Joined: Wed Jan 15, 2003 6:45 pm
Location: Dungeons of Doom
Has thanked: 421 times
Been thanked: 575 times
Contact:

Post by Mr.Mouse » Wed Oct 11, 2006 2:05 pm

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

User avatar
Deniz Oezmen
VIP member
VIP member
Posts: 185
Joined: Mon Aug 28, 2006 2:07 pm
Has thanked: 1 time
Been thanked: 14 times
Contact:

Post by Deniz Oezmen » Wed Oct 11, 2006 4:19 pm

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 ... ;-)

astro
beginner
Posts: 20
Joined: Sun Sep 24, 2006 9:34 am
Has thanked: 1 time
Been thanked: 1 time

Post by astro » Wed Oct 11, 2006 6:03 pm

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;
You do not have the required permissions to view the files attached to this post.

User avatar
Deniz Oezmen
VIP member
VIP member
Posts: 185
Joined: Mon Aug 28, 2006 2:07 pm
Has thanked: 1 time
Been thanked: 14 times
Contact:

Post by Deniz Oezmen » Wed Oct 11, 2006 7:09 pm

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 ... :?]
Last edited by Deniz Oezmen on Wed Oct 11, 2006 11:24 pm, edited 1 time in total.

astro
beginner
Posts: 20
Joined: Sun Sep 24, 2006 9:34 am
Has thanked: 1 time
Been thanked: 1 time

Post by astro » Wed Oct 11, 2006 8:27 pm

my numbers are bad

User avatar
Deniz Oezmen
VIP member
VIP member
Posts: 185
Joined: Mon Aug 28, 2006 2:07 pm
Has thanked: 1 time
Been thanked: 14 times
Contact:

Post by Deniz Oezmen » Wed Oct 11, 2006 9:28 pm

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?)

astro
beginner
Posts: 20
Joined: Sun Sep 24, 2006 9:34 am
Has thanked: 1 time
Been thanked: 1 time

Post by astro » Thu Oct 12, 2006 2:07 pm

:D
You do not have the required permissions to view the files attached to this post.

User avatar
Deniz Oezmen
VIP member
VIP member
Posts: 185
Joined: Mon Aug 28, 2006 2:07 pm
Has thanked: 1 time
Been thanked: 14 times
Contact:

Post by Deniz Oezmen » Thu Oct 12, 2006 6:55 pm

May I guess that your code is working now? ;-)

astro
beginner
Posts: 20
Joined: Sun Sep 24, 2006 9:34 am
Has thanked: 1 time
Been thanked: 1 time

Post by astro » Thu Oct 12, 2006 8:00 pm

yes

Code: Select all

myprogram in.txt out.txt

User avatar
Deniz Oezmen
VIP member
VIP member
Posts: 185
Joined: Mon Aug 28, 2006 2:07 pm
Has thanked: 1 time
Been thanked: 14 times
Contact:

Post by Deniz Oezmen » Thu Oct 12, 2006 10:16 pm

Sorry; I cannot try it right now, since I currently do not have the required .NET framework installed.

Nevertheless: Congratulations. ;-)

Post Reply