This is the mail archive of the ecos-discuss@sourceware.org mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

ZLIB: using gzip decompression in combination with libpng


Hi,

I experienced some problems when trying to read PNG files and decompress gzip compressed data in the same application

In order to be able to read PNG files I have to set the cdl option CYGSEM_COMPRESS_ZLIB_DEFLATE_MAKES_GZIP  to 0. When it is set to 1 an "incorrect header" error is returned when trying to read the PNG file.

But if the cdl option is set to 0 then gzip compression or decompression is disabled.
Surely it must be possible to be able to do gzip decompression and using PNG files.

When looking into the zconf.h zlib header file I found the following lines:

#ifdef CYGSEM_COMPRESS_ZLIB_DEFLATE_MAKES_GZIP
#undef  MAX_WBITS
#define MAX_WBITS   15+16 /* 32K LZ77 window */
#else
#define NO_GZIP
#define NO_GZCOMPRESS
#endif

When the CYGSEM_COMPRESS_ZLIB_DEFLATE_MAKES_GZIP is set it causes MAX_WBITS to be equal to (15+16) instead of the default 15.
And this causes DEF_WBITS (in zutil.h) to be also equal to (15+16).
As a result the default windowBits for decompression is equal to (15+16) and this seems to be somehow the cause why libpng can't read png files anymore.

I was able to fix the issue by either setting MAX_WBITS to 15 (instead of 15+16) or leaving MAX_WBITS to (15+16) but explicitily setting DEF_WBITS to 15 in zconf.h.
This made libpng work with CYGSEM_COMPRESS_ZLIB_DEFLATE_MAKES_GZIP to 1.

Now my question is:
Does anybody know why MAX_WBITS was set to 15+16 instead of the default 15 ?

Thanks,
regards Stephane Deltour




-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]