DinoChiesa / DotNetZip

Library for creating and reading .ZIP files from a .NET Language
Other
120 stars 41 forks source link

zlibx changes? #1

Open bravepuzzle opened 6 years ago

bravepuzzle commented 6 years ago

Hi @DinoChiesa ,

I am not very knowledge in compression and if you could point me in the right direction I would greatly appreciate it!

I've came across what is called zlibx a variation of zlib, where it carries the inflate changes as follow:

#define MOVE_30_TO_288   288 // the original is 30, this is probably the max

/* extra bits and base tables for length codes */
unsigned char length_bits[MOVE_30_TO_288];
unsigned short length_base[MOVE_30_TO_288];

/* extra bits and base tables for distance codes */
unsigned char dist_bits[MOVE_30_TO_288];
unsigned short dist_base[MOVE_30_TO_288];

static void tinf_build_bits_base(unsigned char *bits, unsigned short *base, int delta, int first)
{
   int i, sum;

   /* build bits table */
   for (i = 0; i < delta; ++i) bits[i] = 0;
   for (i = 0; i < MOVE_30_TO_288 - delta; ++i) bits[i + delta] = i / delta;

   /* build base table */
   for (sum = first, i = 0; i < MOVE_30_TO_288; ++i)
   {
      base[i] = sum;
      sum += 1 << bits[i];
   }
}

So instead of using 30 it uses 288, the above code comes from https://bitbucket.org/jibsen/tinf/src/d4327ed5fe3826620e2c53c292d456d5cb6b5932/src/tinflate.c?at=default&fileviewer=file-view-default with the changes mentioned above for MOVE_30_TO_288.

I've looked at DotNetZip source of the Zlib portion but the code is so complex, I don't even know where to start, more over I do see some initializes with 288, for example https://github.com/DinoChiesa/DotNetZip/blob/4b120bc6a47dc7eecfb92601d473e5ac3a26ad17/Zlib/InfTree.cs#L355 and https://github.com/DinoChiesa/DotNetZip/blob/7ac10dc7793cbf21212848e9814334ee946f26d3/Zlib/Zlib.cs#L363 which could be related to it but I am unsure.

I wanted to know if you could point me which parts of Zlib from DotNetZip I would have to change to reflect the above.

If you could share me anything on this matter I would appreciate.

Thanks.

peter-dolkens commented 4 years ago

I recommend checking https://github.com/haf/DotNetZip.Semverd as it appears this project is simply a snapshot, whilst the other project has full history, and at least a minimal amount of maintenance.