2457 Commits

Author SHA1 Message Date
John Bowler
2b711a751c LOW_MEMORY and COMPAT bug fixes
The LOW_MEMORY PNG_COMPRESSION option should not be setting HUFFMAN_ONLY or
using a low deflate 'level'; according to the comments in zconf.h only
windowBits and memLevel affect the memory.  pngwutil.c has been changed to use
the same values as HIGH compression.

The COMPAT option turned on the old optimize_cmf code (now in fix_cinfo),
however there was a serious bug in that code; it put the wrong value in z_cmf.
The setting was also not handled correctly in pz_compression_settings.

pngtest now verifies the operation of COMPAT and, as a result, pngtest.png has
been reverted to the libpng 1.6 (etc) version.

IDAT size handling has been improved; if not explicitly set values appropriate
to png_level are now chosen (in addition to the handling for the COMPAT
setting).  HIGH and HIGH_READ_SPEED now create unlimited size IDAT chunks, which
requires buffering the whole of the IDAT data in memory but reflects what other
programs and optimizers do.

Signed-off-by: John Bowler <jbowler@acm.org>
2016-06-07 11:27:23 -07:00
Glenn Randers-Pehrson
2e68f96511 [libpng17] Update link to RFC-2083 in png.5 2016-06-07 11:03:26 -05:00
Glenn Randers-Pehrson
8c7b59f2b9 [libpng17] Update CHANGES and ANNOUNCE, fixed several new typos 2016-06-07 11:02:07 -05:00
John Bowler
01ff090760 API reduction, PNG compression level
PNG compression level setting API: this allows the various compression settings
controlling deflate, fitlering, and so on to be set via a single setting with
six values.  This is currently documented in png.h ("Write compression
settings").

Internally the compression settings have been tuned both for the overall setting
and for any specific settings made by the original APIs.

APIs to control iCCP chunk compression separately have been added.

contrib/examples/pngcp.c has been modified to accomodate the new compression
setting and to include options for separate control of iCCP chunk compression.

The new ABI, png_setting, has been modified to accomodate a wider range of
settings and most of the old compression control ABIs have been replaced by
function-like macros with the same API which call png_setting.  This is an API
check in 1.7.0 for png_setting (alone).  png_setting now handles all of
png_set_option.  This eliminates 19 ABIs at the cost of adding 1 (png_setting).

CRC and benign error checking has been updated internally to use bit-fields and
the CRC calculation skip when the CRC is not used has been improved slightly to
avoid the initialization of the CRC.  A new png_setting based API allows more
detailed control of benign error/warning messages (this may change, the internal
error handling seems too complex.)  The ERROR_NUMBERS support has been removed
with the intent of implementing proper i18n.

The memcpy-size-0 issue in png_push_fill_buffer has been fixed, with an
appropriate debug() assert if a fill for 0 bytes occurs.

Most PNG_FLAG_ values for png_struct::flags have been eliminated (as a result of
the benign error handling changes).  Only one remains.

Signed-off-by: John Bowler <jbowler@acm.org>
2016-06-07 06:48:52 -07:00
Glenn Randers-Pehrson
120f80369b [libpng17] Port contrib/libtests/pngvalid.c from libpng16. 2016-05-31 10:14:08 -05:00
John Bowler
1982dc6c2f Back-port 1.6 pngvalid.c
No changes; files are identical

Signed-off-by: John Bowler <jbowler@acm.org>
2016-05-29 09:28:39 -07:00
Glenn Randers-Pehrson
a1296131fe [libpng17] Refactored duplicate coded in png_set_check_for_invalid_index()
to quiet a Coverity issue and save a few bytes of code.
2016-05-22 14:42:14 -05:00
Glenn Randers-Pehrson
5095b2adfb [libpng17] Update CHANGES and ANNOUNCE 2016-05-21 13:26:51 -05:00
John Bowler
5b19ac3019 Write fine tuning
Fine tuning of options so that the default settings are comparable with 1.6;
test set sizes are about 2% greater than 1.6 because of the use of FAST rather
than ALL filters (this mainly affects RGB images).

Signed-off-by: John Bowler <jbowler@acm.org>
2016-05-21 08:41:44 -07:00
John Bowler
a5b340e20b timepng: fix builds in certain 1.7 configs
Libpng 1.7 supports read without PNG de-interlace, however this means the old
checks on whether contrib/libtests/timepng.c (just checking for sequential read)
are inadequate.  1.7 also provides macros to explicitly turn off png_read_png
and png_read_image, so use these instead.

Signed-off-by: John Bowler <jbowler@acm.org>
2016-05-21 08:40:04 -07:00
John Bowler
21f92eef89 timepng.c: check for clock_gettime
Signed-off-by: John Bowler <jbowler@acm.org>
2016-05-18 08:42:21 -07:00
John Bowler
bf101dcea1 Merge branch 'libpng17' into 20160506-write 2016-05-18 08:41:15 -07:00
John Bowler
764ae3995b Filter tuning, legacy option
png_level -1 sets the defaults for write compression/filters/IDAT size to those
used in pre-1.7 versions of libpng, producing results that with a few exceptions
are identical to earlier versions.  This commit also includes an important bug
fix for the previous commit which was erroneously using the greatest sum not the
least sum of absolute values when performing filter selection.

Signed-off-by: John Bowler <jbowler@acm.org>
2016-05-16 22:59:20 -07:00
Glenn Randers-Pehrson
bd6fb5534f [libpng17] Update Makefile.am, fix typo in timepng.c 2016-05-16 19:39:55 -05:00
Glenn Randers-Pehrson
f05407d292 [libpng17] Check for CLOCK_PROCESS_CPUTIME_ID in /contrib/libtests/timepng.
Otherwise it does not build on platforms that don't supply clock_gettime().
2016-05-16 18:59:47 -05:00
John Bowler
5652acdd48 Filter selection, palette index checks
Palette index checking: checking on read was erroneously skipped.  pngcp can now
turn off the palette index checking or fix the errors (mainly to allow
comparison with libpng 1.6, which defaulted to ignoring it).  The API now
documents how the 'enabled' parameter works.  On read the check is on by default
(it was apparently off in libpng 1.6) however now if explicitly turned on the
warning message is stopped, this provides better interaction with
get_palette_max at the cost of a small API change (may need to be reviewed.)

Palette size errors: invalid entries in the palette are now set to #beaded to
make the errors more obvious and allow easy detection in memory.

Read transform pipeline caching: changes to fix the palette index check (which
are erroneously cached), the pipeline can now contain multiple caches.  E.g.
caching of packing of palette indices can be combined with caching of palette
RGB transforms.

Read code now checks for callbacks to read 0 data (and faults them).  Fixed the
reading of PNGs with multiple 0 length IDATs that failed as a result plus the
handling of zero length unknown.  (Which occurs, validly; the spurious warning
has been removed).

filter selection: the 1.6 and earlier sum of absolute differences algorithm has
been reintroduced with an option to disfavor some filters over others where the
sums are close (not yet exposed).  The selection code also logs the last known
occurence of each possible byte code across multiple lines.  This allows
detection of PNG images with lower bit depth than the format implies and,
therefore, allows the filtering to be turned off in those cases as well.

The default write zlib settings are still lower than libpng16.  The selection
algorithm is being refined (the overall results are worse than not doing any
filtering).

Signed-off-by: John Bowler <jbowler@acm.org>
2016-05-15 16:32:01 -07:00
John Bowler
cf46e3748f Implement base filter selection
Row buffering and a crude code-count algorithm.

Signed-off-by: John Bowler <jbowler@acm.org>
2016-05-14 18:08:25 -07:00
John Bowler
52c9e4fdd6 signed/unsigned warning fix (GCC 4.8.5)
Signed-off-by: John Bowler <jbowler@acm.org>
2016-05-09 16:36:15 -07:00
John Bowler
4905ed4aae Reenable filter selection (dummy)
This implements the code for row-by-row filter selection but does not provide an
actual implementation; the selection function just chooses the lowest set filter
bit.

Signed-off-by: John Bowler <jbowler@acm.org>
2016-05-09 13:08:50 -07:00
Glenn Randers-Pehrson
ba356b4e4d [libpng17] Bump version to 1.7.0beta81 2016-05-07 15:45:03 -05:00
Glenn Randers-Pehrson
d23207b866 [libpng17] Imported from libpng-1.7.0beta80.tar v1.7.0beta80 2016-05-07 15:44:55 -05:00
John Bowler
a70f5053de [libpng17] Update CHANGES and ANNOUNCE about pngcp; sync timepng.c with libpng16 2016-05-06 19:09:58 -05:00
John Bowler
4cc89fb733 Minor write bug-fixes, remove unimplemented code
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>
2016-05-06 14:35:35 -07:00
Glenn Randers-Pehrson
e966fac5ac [libpng17] Update CHANGES and ANNOUNCE for Write code update (John Bowler) 2016-05-04 22:02:52 -05:00
John Bowler
cde9b583a8 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>
2016-05-04 17:02:20 -07:00
Glenn Randers-Pehrson
1fd42d849d [libpng17] Bump version to 1.7.0beta80 2016-03-09 12:05:09 -06:00
Glenn Randers-Pehrson
b6a1f48ab2 [libpng17] Imported from libpng-1.7.0beta79.tar v1.7.0beta79 2016-03-09 12:05:00 -06:00
Glenn Randers-Pehrson
bbe8ea6eb0 [libpng17] Fixed some misleading indentation (Krishnaraj Bhat). 2016-03-07 07:49:09 -06:00
Glenn Randers-Pehrson
6d2e06f25f [libpng17] Changed PNG_INFO_cHNK and PNG_FREE_cHNK from 0xnnnn to 0xnnnnU in
png.h (Robert C. Seacord). Various other flags in png.h made unsigned as well.
2016-02-14 13:13:20 -06:00
Glenn Randers-Pehrson
3fb14ea53b [libpng17] Make cmake install pnglibconf.h; rename some tests to be
similar to the names generated by "configure"
2016-02-09 08:54:17 -06:00
John Bowler
af9ad9545d Write compression options
More sophisticated defaulting which helps significantly for some files along
with code to make it easier to control the compression defaults and to make the
settings honor the API calls the application makes (previously low windowBits
settings would get reset to higher values.)

Signed-off-by: John Bowler <jbowler@acm.org>
2016-02-02 05:58:38 -08:00
Glenn Randers-Pehrson
5e88e9c396 [libpng17] Update CHANGES and ANNOUNCE 2016-02-02 07:46:12 -06:00
John Bowler
8498aa1c97 Expand search logging
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>
2016-02-01 18:04:31 -08:00
Roger Leigh
8fb81acd98 [libpng17] Deleted pngstest-pngsuite from CMakeLists.txt 2016-01-30 21:20:55 -06:00
Glenn Randers-Pehrson
1a087bf921 [libpng17] Update copyright info in CMakeLists.txt 2016-01-30 17:19:49 -06:00
Roger Leigh
5a857b7d83 [libpng17] Remove extra pngvalid test from CMakeLists.txt 2016-01-30 17:04:51 -06:00
John Bowler
e2414effed pngcp: 1.6 support and better --search output
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>
2016-01-30 14:09:39 -08:00
Glenn Randers-Pehrson
023b399e40 [libpng17] Mention pngchunk.h in documentation 2016-01-30 09:47:13 -06:00
Glenn Randers-Pehrson
0b073f4a4d [libpng17] Add pngchunk.h dependency and remove some redundant
dependencies from CMakeLists.txt
2016-01-30 09:44:44 -06:00
Glenn Randers-Pehrson
a8b45d9f7e [libpng17] Removed pngstest-pngsuite test from CMakeLists.txt 2016-01-30 09:31:33 -06:00
Roger Leigh
c39c5640b4 [libpng17] Updated CMakeLists.txt, added supporting scripts/gen*.cmake.in
and test.cmake.in (Roger Leigh).
2016-01-29 17:27:39 -06:00
Glenn Randers-Pehrson
eb5e71cc8c [libpng17] Update CHANGES, ANNOUNCE, and some "last changed" dates 2016-01-29 16:20:34 -06:00
John Bowler
85cb69aa82 Forward port libpng16 fixes
Batched fixes from libpng16: PNG_IMAGE_PNG_SIZE_MAX macro fix, contrib/libtests
exit(77) change to just do that for configure and changes to pngstest to
(by default) make random backgrounds on a per-file, not per-session, basis.

Signed-off-by: John Bowler <jbowler@acm.org>
2016-01-28 23:11:33 -08:00
Glenn Randers-Pehrson
dcb3f792d9 [libpng17] Bump version to 1.7.0beta79 2016-01-23 14:57:49 -06:00
Glenn Randers-Pehrson
9a6922896d [libpng17] Imported from libpng-1.7.0beta78.tar v1.7.0beta78 2016-01-23 14:06:48 -06:00
Glenn Randers-Pehrson
55d3b3226e [libpng17] Document new png_image_write_to_memory() API 2016-01-23 13:59:24 -06:00
Glenn Randers-Pehrson
443694d7ac [libpng17] Revised workaround for Coverity issue in pngvalid.c 2016-01-23 10:10:52 -06:00
Glenn Randers-Pehrson
f26fa77ef8 [libpng17] Updated CHANGES and ANNOUNCE, fixed typo in pngunknown.c comment. 2016-01-19 08:32:18 -06:00
John Bowler
e46cd2e6bc Simplified API: use system appropriate types
This is an API change for 1.7, albeit a quiet one; it may produce compiler
warnings but should not result in errors, unless warnings are treated as errors.

On 64-bit systems it widens the results of the various PNG_IMAGE_ macros that
return size values (component counts, byte sizes) to 64 bits.  It also changes
the row_stride parameter, which is the pointer difference between adjacent rows
of the image buffer, to ptrdiff_t which is the ANSI-C90 defined type of the
difference of two pointers.  The existing (1.6.22) checks for overflow are
preserved but now accomdate images that require more than 32 bits of address
space when size_t/ptrdiff_t are 64 bit types.

Signed-off-by: John Bowler <jbowler@acm.org>
2016-01-18 20:44:26 -08:00
John Bowler
f2a160299e pngunknown: update date 2016-01-18 12:02:40 -08:00