2

I'm trying to find two parameters (sliding window size and max match length) in the LZ77 algorithm (source code: http://www.zlib.net/) in order to analyse different levels of compression. At first, I found the CHUNK value in zpipe.c to be the max match length parameter, and the sliding window to be the parameter windowBits in the function deflateInit2 in deflate.c The problem is that the compressed files in different compression levels according to these parameters are identical no matter the parameters are.

if someone used this source code and already recognized theses parameters in the code, it will be very helpful for me.

Thanks!

timrau
  • 22,578
  • 4
  • 51
  • 64
Elad
  • 21
  • 3

1 Answers1

3

By default zlib uses a 32K sliding window. The maximum match length is 258.

The amount of data fed to deflate at a time (e.g. CHUNK in zpipe.c) has no bearing on the compression whatsoever. You could feed in the data a byte at a time and you would get the same output.

Mark Adler
  • 101,978
  • 13
  • 118
  • 158
  • Thanks for your helping. but still I have a problem. I ran zpipe with 2 parameters that I defined and a binary file (parameters are sliding window and max match length - I made a few changes in the code deflate.c etc to make it work). when I run zpipe with different values of these 2 parameters, the 2 compressed files in each running are identical, meaning that the parameters didn't change during the deflating. Can you find out what's the cause of it. Again thanks for helping – Elad Jan 06 '15 at 18:41
  • No, I can't find out what's causing it. You can look at your data to figure it out. The sliding window and max match length determine the maximum distance of a match and the maximum length, respectively. If it didn't change, then that just means that it never found distances that far or matches that long in the first place. – Mark Adler Jan 06 '15 at 19:04
  • Hi, in general, what parameters/variables in the code (constant or not) might affect the compression ratio? and where they are defined in the code? thanks in advance – Elad Apr 09 '15 at 16:35
  • Read the documentation for `deflateTune()`, which provides direct access to all of the parameters that affect compression. You can then dive into the deflate code to see what exactly those parameters do. – Mark Adler Apr 09 '15 at 18:11
  • Thanks for your reply. I would be glad to get a brief explaination about the 4 parameters: good_length, max_lazy, nice_length, max_chain. – Elad Apr 10 '15 at 11:57
  • By the way, in addition to those parameters are the window size, the memory size, and the strategy. – Mark Adler Apr 10 '15 at 14:02
  • how do they call and where are they defined in the code? – Elad Apr 10 '15 at 14:25
  • `deflateInit2()`. If you follow that with `deflateTune()`, you have set all of the available parameters. – Mark Adler Apr 10 '15 at 15:26
  • OK, I don't understand the meaning of the 4- parameters good_length etc and where should I call the deflateTune() function if I use zpipe.c? inside deflateInit() maybe? – Elad Apr 10 '15 at 16:34
  • `deflateTune()` is called immediately after `deflateInit()` or `deflateInit2()`. – Mark Adler Apr 10 '15 at 17:20
  • There is no documentation of the four `deflateTune()` parameters other than in the deflate source code. So you will need to look there. – Mark Adler Apr 10 '15 at 17:20