A debug() assert fired if windowBits was set to 8 for the Huffman only and
no-compression cases. This commit changes it to do some extra checking. Remove
unreachable code in pz_default_settings, eliminate a spurious warning in pngcp
for small files.
Signed-off-by: John Bowler <jbowler@acm.org>
Implemented better defaulting of zlib settings based on image properties.
Implemented pass-through of png_write_rows when the rows can be used directly (a
common case) optimizing the handling of previous-row buffering.
Removed the METHODICAL filter selection method and disabled the HEURISTIC one;
the first was ridiculously slow (though useful for experiments) the second
doesn't work. Filter selection is temporarily disabled (it defaults to the
lowest numbered filter in the list; typically 'none').
New handling of compression settings (incomplete), new PNG compression level
(not yet visible in an API).
Back ported 'PNG_FAST_FILTERS' from 1.6 (in png.h).
There are minimal API changes beyond removal of the selection options. Work is
still to be done to investigate a filter selection mechanism that is at least as
good as the previous one.
Signed-off-by: John Bowler <jbowler@acm.org>
Output results during the search; not a perfect implementation but sufficient
for basic tests on zlib parameters.
Signed-off-by: John Bowler <jbowler@acm.org>
Some refinements for the search option and better (more consistent) reporting of
the results plus changes so that when compiled against libpng 1.6 the program
correctly copies text chunks; previously when a search option caused multiple
copies of the same file the copies after the first would not have the text
chunks.
Signed-off-by: John Bowler <jbowler@acm.org>
The internal read code change to stop sharing the palette was incompletely
implemented. The result is that unless palette index checking is turned off and
there are no read transformations the png_info palette gets deleted when the
png_struct is deleted. This is normally harmless (png_info gets deleted first)
but in the case of pngcp it results in use-after-free of the palette and,
therefore, palette corruption and maybe on some operating systems and access
violation.
This also updated pngcp 'search' mode to check a restricted range of memLevels;
there is an unrelated bug which means that lower zlib memLevels result in memory
corruption under some circumstances, probably less often than 1:1000.
Signed-off-by: John Bowler <jbowler@acm.org>
Also change the order of the 'level' and 'windowBits' searches to seach
windowBits first; this favours windowBits optimizations over compression level
ones on the basis that the latter should only affect the write code.
Signed-off-by: John Bowler <jbowler@acm.org>
This is still a work-in-progress but it seems fairly stable (if not exactly 100%
optimal). pngcp now allows 'all' for some options which iterates through all
possible settings (this reliably produces the smallest IDAT that libpng can
produce with those settings.) It also contains a --search command line option
which attempts to optimize this by skipping pointless tests; it is close, most
of the time, but not perfect.
Signed-off-by: John Bowler <jbowler@acm.org>
This adds code to iterate through the command line options when non-list options
have the 'all' parameter. Used to rapidly test the effect of different zlib
options.
Signed-off-by: John Bowler <jbowler@acm.org>
Also add an example program, pngcp.c, which illustrates the problem when used to
copy pngtest.png (the result is an invalid PNG because the tIME chunk is
duplicated.)
Signed-off-by: John Bowler <jbowler@acm.org>
Most of these are back-portable to earlier versions (contrib/libtests
should just work with earlier versions), however the 1.7 specific
changes in pngvalid mean that it probably won't work against 1.7 without
the commits following this one.
Signed-off-by: John Bowler <jbowler@acm.org>
a flag to change default. In 1.6.0 when the simplified API was used
to produce color-mapped output from an input image with no gamma
information the gamma assumed for the input could be different from
that assumed for non-color-mapped output. In particular 16-bit depth
input files were assumed to be sRGB encoded, whereas in the 'direct'
case they were assumed to have linear data. This was an error. The
fix makes the simplified API treat all input files the same way and
adds a new flag to the png_image::flags member to allow the
application/user to specify that 16-bit files contain sRGB data
rather than the default linear.
Fixed bugs in the pngpixel and makepng test programs.