Deflate algorithm source code

  • Follow


Hi all,

I'm searching source code examples to decompress streams compressed with
deflate algorithms other than CM=8 (standard used in GZIP, by example). So
I'm looking for CM=0-7 or 9-14.

Delphi/pascal code will be the best, but C code too.

Any links will be appreciated.

Best regards,

Lionel

0
Reply Lionel 12/1/2010 6:30:19 PM

On 12/1/2010 11:30 AM, Lionel Delafosse wrote:
> Hi all,
>
> I'm searching source code examples to decompress streams compressed with
> deflate algorithms other than CM=8 (standard used in GZIP, by example). So
> I'm looking for CM=0-7 or 9-14.
>
> Delphi/pascal code will be the best, but C code too.
>
> Any links will be appreciated.
>

AFAIK, GZIP is only really defined for CM=8, which also aligns with the 
PKZip CM=8, both of which mean Deflate.

now, if one is assuming GZ=ZIP at least WRT the CM field:
0=store (no compression, raw data);
1..7=stale algos largely no longer commonly used (Shrink, Reduce, 
Implode, ...);
9=Deflate64 (slightly tweaked Deflate which uses 64kB window);
10...=various less common algos (BZip2, LZMA, ...).

but, none of these others are called deflate, each has their own names.

now, whether or not these apply to GZ is unknown.


finding code for them is ones' own task...
0
Reply BGB 12/2/2010 5:10:08 PM


On 2010-12-01 10:30:19 -0800, Lionel Delafosse said:
> I'm searching source code examples to decompress streams compressed with
> deflate algorithms other than CM=8 (standard used in GZIP, by example). So
> I'm looking for CM=0-7 or 9-14.

PKWare defined compression algorithms for the ZIP format with 
compression methods other than 8, which is what I presume you are 
talking about.  The ones that are not CM=8 are not called deflate 
(except CM=9 is called deflate64).

The last version of the PKWare appnote I have (from 2007) lists these:

          0 - The file is stored (no compression)
          1 - The file is Shrunk
          2 - The file is Reduced with compression factor 1
          3 - The file is Reduced with compression factor 2
          4 - The file is Reduced with compression factor 3
          5 - The file is Reduced with compression factor 4
          6 - The file is Imploded
          7 - Reserved for Tokenizing compression algorithm
          8 - The file is Deflated
          9 - Enhanced Deflating using Deflate64(tm)
         10 - PKWARE Data Compression Library Imploding (old IBM TERSE)
         11 - Reserved by PKWARE
         12 - File is compressed using BZIP2 algorithm
         13 - Reserved by PKWARE
         14 - LZMA (EFS)
         15 - Reserved by PKWARE
         16 - Reserved by PKWARE
         17 - Reserved by PKWARE
         18 - File is compressed using IBM TERSE (new)
         19 - IBM LZ77 z Architecture (PFS)
         97 - WavPack compressed data
         98 - PPMd version I, Rev 1

The decompression code for 0 is memcpy().

For 1, you can find unshrink.c in Info-ZIP's unzip source code.

For 2-5, Info-ZIP's unzip used to have unreduce.c, but that was removed 
in more recent versions.  If you can find an older archive of unzip 
source code, you will find the original code for unreduce.c.

For 6, look at explode.c in unzip.

For 9, look at contrib/infback9 in the zlib source code distribution.

For 10, look at contrib/blast in zlib.

For 12 and 14, just google and you'll find the separate source code 
packages for those.

Mark

0
Reply Mark 12/3/2010 8:16:02 AM

"BGB" <cr88192@hotmail.com> a �crit dans le message de news:
id8jtm$fdm$1@news.albasani.net...
> On 12/1/2010 11:30 AM, Lionel Delafosse wrote:
> > Hi all,
> >
> > I'm searching source code examples to decompress streams compressed with
> > deflate algorithms other than CM=8 (standard used in GZIP, by example).
So
> > I'm looking for CM=0-7 or 9-14.
> >
> > Delphi/pascal code will be the best, but C code too.
> >
> > Any links will be appreciated.
> >
>
> AFAIK, GZIP is only really defined for CM=8, which also aligns with the
> PKZip CM=8, both of which mean Deflate.
>
> now, if one is assuming GZ=ZIP at least WRT the CM field:
> 0=store (no compression, raw data);
> 1..7=stale algos largely no longer commonly used (Shrink, Reduce,
> Implode, ...);
> 9=Deflate64 (slightly tweaked Deflate which uses 64kB window);
> 10...=various less common algos (BZip2, LZMA, ...).
>
> but, none of these others are called deflate, each has their own names.
>
> now, whether or not these apply to GZ is unknown.
>
>
> finding code for them is ones' own task...

Thanks for the infos.

Lionel

0
Reply Lionel 12/7/2010 3:07:45 PM

"Mark Adler" <mark.adler@jpl.nasa.gov> a �crit dans le message de news:
2010120300160228469-markadler@jplnasagov...
> On 2010-12-01 10:30:19 -0800, Lionel Delafosse said:
> > I'm searching source code examples to decompress streams compressed with
> > deflate algorithms other than CM=8 (standard used in GZIP, by example).
So
> > I'm looking for CM=0-7 or 9-14.
>
> PKWare defined compression algorithms for the ZIP format with
> compression methods other than 8, which is what I presume you are
> talking about.  The ones that are not CM=8 are not called deflate
> (except CM=9 is called deflate64).
>
> The last version of the PKWare appnote I have (from 2007) lists these:
>
>           0 - The file is stored (no compression)
>           1 - The file is Shrunk
>           2 - The file is Reduced with compression factor 1
>           3 - The file is Reduced with compression factor 2
>           4 - The file is Reduced with compression factor 3
>           5 - The file is Reduced with compression factor 4
>           6 - The file is Imploded
>           7 - Reserved for Tokenizing compression algorithm
>           8 - The file is Deflated
>           9 - Enhanced Deflating using Deflate64(tm)
>          10 - PKWARE Data Compression Library Imploding (old IBM TERSE)
>          11 - Reserved by PKWARE
>          12 - File is compressed using BZIP2 algorithm
>          13 - Reserved by PKWARE
>          14 - LZMA (EFS)
>          15 - Reserved by PKWARE
>          16 - Reserved by PKWARE
>          17 - Reserved by PKWARE
>          18 - File is compressed using IBM TERSE (new)
>          19 - IBM LZ77 z Architecture (PFS)
>          97 - WavPack compressed data
>          98 - PPMd version I, Rev 1
>
> The decompression code for 0 is memcpy().
>
> For 1, you can find unshrink.c in Info-ZIP's unzip source code.
>
> For 2-5, Info-ZIP's unzip used to have unreduce.c, but that was removed
> in more recent versions.  If you can find an older archive of unzip
> source code, you will find the original code for unreduce.c.
>
> For 6, look at explode.c in unzip.
>
> For 9, look at contrib/infback9 in the zlib source code distribution.
>
> For 10, look at contrib/blast in zlib.
>
> For 12 and 14, just google and you'll find the separate source code
> packages for those.
>
> Mark

Thanks for these detailled infos.

I'm facing with some strange compression types used in several PDFs. So, I'm
searching around but didn't found a lot...

Lionel

0
Reply Lionel 12/7/2010 3:11:17 PM

4 Replies
787 Views

(page loaded in 0.082 seconds)

Similiar Articles:












7/21/2012 1:13:08 AM


Reply: