Write code update

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>
This commit is contained in:
John Bowler
2016-05-04 17:02:20 -07:00
parent 1fd42d849d
commit cde9b583a8
10 changed files with 1834 additions and 1330 deletions

View File

@@ -930,20 +930,36 @@ option CONVERT_tIME requires WRITE_ANCILLARY_CHUNKS
# png_set_filter interface allowing the application to select the filter
# used for each row.
#
# SELECT_FILTER_HEURISTICALLY
# Enables code to cause libpng to choose a filter from a set passed to
# png_set_filter. Without this code libpng just chooses the first filter in
# the list if multiple are given.
# SELECT_FILTER
# Enables code to select between multiple filters on write. Without this
# the 'first' (lowest numbered) filter will be selected an this typically
# works out as PNG_FILTER_VALUE_NONE.
#
# SELECT_FILTER_METHODICALLY
# Enables code to try all the filters in the list passed to png_set_filter
# and choose the one which results in the least number of compressed bytes
# added by the current row.
# COMPRESSION_BUFFER_MAX
# WARNING: take care if you set this. This is the maximum amount of input
# data that the implementation of deflate can consume before it outputs a
# Huffman table for that data. I.e. before it commits to an encoding of the
# data it has read. This is used solely to implement a limit on the amount
# of image data buffering that occurs inside libpng before filter selection
# is done. Normally the limit is never reached because of the next setting,
# but this is a compile time limit and it is intended to prevent a potential
# DNS service as a result of an application setting the libpng equivalent of
# volume level 11 (read the wikipedia article on "Up to eleven").
#
# NOTE: the image of a black cat in a coal mine obviously requires this
# limit, but some more valid images can get very close; well over 8MByte.
#
# COMPRESSION_BUFFER_LIMIT
# This is the (overrideable) default for the amount of memory libpng will
# buffer before selecting a filter for a row. It is limited itself to
# COMPRESSION_BUFFER_MAX as values above that level make no change (see the
# previous paragraph.)
#
# See png.h for more description of these options.
option WRITE_FILTER requires WRITE
option SELECT_FILTER_HEURISTICALLY requires WRITE_FILTER enables SET_OPTION
option SELECT_FILTER_METHODICALLY requires WRITE_FILTER enables SET_OPTION
option SELECT_FILTER requires WRITE_FILTER disabled
setting COMPRESSION_BUFFER_MAX default 8453377
setting COMPRESSION_BUFFER_LIMIT default 8453377
# added at libpng-1.5.4