Compare commits

...

804 Commits

Author SHA1 Message Date
Glenn Randers-Pehrson
1c2e35ab73 [libpng17] Imported from libpng-1.7.0beta88.tar 2017-08-07 09:45:14 -05:00
Glenn Randers-Pehrson
58cd558a43 [libpng17] Added some bad PNGs to the test directory and to the test/pngtest script 2017-08-06 14:16:17 -05:00
Glenn Randers-Pehrson
bdca749e35 [libpng17] Added private png_check_chunk_name() and png_check_chunk_length()
functions.
2017-08-06 14:13:18 -05:00
Glenn Randers-Pehrson
19855cd8b1 [libpng17] Fix URL in documentation. 2017-05-22 17:39:22 -05:00
Glenn Randers-Pehrson
9bda575f69 [libpng17] Change http: urls to https: in libpng.3 2017-04-03 16:58:43 -05:00
Glenn Randers-Pehrson
66def3fb3c [libpng17] Bump version to 1.7.0beta88 2017-04-01 11:29:32 -05:00
Glenn Randers-Pehrson
8f4d83a881 [libpng17] Imported from libpng-1.7.0beta87.tar 2017-04-01 11:29:12 -05:00
Glenn Randers-Pehrson
a9b02399ac [libpng17] Added missing "$(CPPFLAGS)" to the compile line for c.pic.o in
makefile.linux and makefile.solaris-x86 (Cosmin).
2017-03-21 20:12:09 -05:00
Glenn Randers-Pehrson
ba42eccb05 [libpng17] Merge contrib/examples/pngtopng.c with libpng-1.6.29beta02 2017-02-24 09:25:27 -06:00
Glenn Randers-Pehrson
7345c50aaa [libpng17] Fixed arm/aarch64 detection in CMakeLists.txt (Gianfranco Costamagna) 2016-12-31 13:02:01 -06:00
Glenn Randers-Pehrson
20be5b5411 [libpng16] Mention CVE-2016-10087 in CHANGES. 2016-12-30 14:00:44 -06:00
Glenn Randers-Pehrson
750a023377 [libpng17] Merge license info from libpng-1.6.27 2016-12-30 12:10:45 -06:00
Glenn Randers-Pehrson
e00c39596a [libpng17] Update license info from libpng-1.6.27 2016-12-30 10:27:53 -06:00
Glenn Randers-Pehrson
448fad2d02 [libpng17] Bump version to 1.7.0beta87 2016-12-30 08:29:13 -06:00
Glenn Randers-Pehrson
76a1f4bb3f [libpng17] Imported from libpng-1.7.0beta86.tar 2016-12-29 07:58:43 -06:00
Glenn Randers-Pehrson
243d4e5f3f [libpng17] Fixed a potential null pointer dereference in png_set_text_2()
(bug report and patch by Patrick Keshishian)
2016-12-29 07:57:58 -06:00
Glenn Randers-Pehrson
48f8ca26e4 [libpng17] Bump version to 1.7.0beta86 2016-12-29 07:56:24 -06:00
Glenn Randers-Pehrson
6c9ecd348d [libpng17] Removed clutter 2016-12-28 06:13:59 -06:00
Glenn Randers-Pehrson
e6470a8876 [libpng17] Ported new ARM support in CMakeLists.txt from libpng16 2016-12-27 11:35:56 -06:00
John Bowler
b14987b483 Merge branch 'libpng17' of ../../libpng into libpng17 2016-12-27 08:24:04 -08:00
Glenn Randers-Pehrson
7ed5c08fad [libpng17] Imported from libpng-1.7.0beta86.tar 2016-12-27 08:24:34 -06:00
John Bowler
5a1f75289e Merge branch 'libpng17' of ../../libpng into libpng17 2016-12-26 18:04:54 -08:00
Glenn Randers-Pehrson
4caddaafbb [libpng17] Update CHANGES and ANNOUNCE 2016-12-26 19:56:53 -06:00
John Bowler
512336676e Remove 'defined' within macro
This eliminates the use of 'defined' within macros that get substituted
on #if lines; see the previous patch for a more detailed discussion.

Signed-off-by: John Bowler <jbowler@acm.org>
2016-12-26 16:46:30 -08:00
John Bowler
0ea7a09ced Remove 'defined' within macro
This removes the use of a macro containing the pre-processor 'defined'
operator.  It is unclear whether this is valid; a macro which
"generates" 'defined' is not permitted, but the use of the work
"generates" within the C90 standard seems to imply more than simple
substitution of an expression itself containing a well-formed defined
operation.

Signed-off-by: John Bowler <jbowler@acm.org>
2016-12-26 16:45:31 -08:00
Glenn Randers-Pehrson
0b02a667cf [libpng17] Fix some indentation in pngrutil.c
(bug report and patch by Patrick Keshishian).
2016-12-26 18:38:13 -06:00
Glenn Randers-Pehrson
e1c7c0402c [libpng17] Quieted warnings from clang-3.8 in pngunknown.c and pngvalid.c. 2016-10-01 20:09:52 -05:00
Glenn Randers-Pehrson
2127ecd0fa [libpng17 Updated the documentation about CRC and ADLER32 handling. 2016-09-26 11:16:08 -05:00
Glenn Randers-Pehrson
1757736115 [libpng17] Bump version to 1.7.0beta85 2016-09-26 08:58:31 -05:00
Glenn Randers-Pehrson
6f9a39848e [libpng17] Imported from libpng-1.7.0beta84.tar 2016-09-26 08:58:23 -05:00
Glenn Randers-Pehrson
517fe770e2 [libpng17] Changed bad CRC from 0x00000000 to 0xabadcc32 and bad ADLER32
from 0x00000000 to 0xabadad32 in badcrc.png and badadler.png, to make
them recognizable in hex dumps.
2016-09-26 08:07:21 -05:00
Glenn Randers-Pehrson
f911c1146a [libpng17] Warn about ADLER32 checksum mismatch instead of issuing png_error().
Add tests/badcrc.png and tests/badadler.png to tests/pngtest.
2016-09-25 22:22:47 -05:00
Glenn Randers-Pehrson
28de8bf6cd [libpng17] Changed PNG_ZLIB_VERNUM to ZLIB_VERNUM in pngrutil.c.
Conditionally compile png_set_benign_errors() in pngtest.c
2016-09-19 17:02:26 -05:00
Glenn Randers-Pehrson
6f39846891 [libpng17] Conditionally compile png_set_benign_errors() in pngread.c 2016-09-11 19:33:34 -05:00
Glenn Randers-Pehrson
07e2cf117f [libpng17] Fixed handling zero length IDAT in pngfix (bug report by Agostino Sarubbo,
bugfix by John Bowler).
2016-09-01 17:36:36 -05:00
Glenn Randers-Pehrson
f0ada4edee [libpng17] Minor editing of INSTALL, (whitespace, added copyright line) 2016-08-18 18:45:35 -05:00
Glenn Randers-Pehrson
3220f9c5a5 [libpng17] Bump version to 1.7.0beta84 2016-08-07 19:54:00 -05:00
Glenn Randers-Pehrson
5096cac90c [libpng17] Imported from libpng-1.7.0beta83.tar 2016-08-07 19:45:17 -05:00
Glenn Randers-Pehrson
2a2373c1ec [libpng17] Update CHANGES and ANNOUNCE, fix typos in pngrutil.c 2016-07-23 16:41:19 -05:00
John Bowler
4283e2bf66 Fix debug test of output gamma
The test would fire when a gamma transform was eliminated because it was not
significant if other transforms remained.  This is a debug-only change to alter
the test to check for an insignificant mis-match of the actual output gamma from
the requested output gamma.

Signed-off-by: John Bowler <jbowler@acm.org>
2016-07-23 10:03:48 -07:00
Glenn Randers-Pehrson
8ffea2e56b [libpng17] Update CHANGES and ANNOUNCE 2016-07-16 11:37:48 -05:00
John Bowler
99eb6b5d5d Remove/rearrange png_struct fields
Certain fields are only used in reading.  This attempts to do some minor
cleanup/rearrangement.

Signed-off-by: John Bowler <jbowler@acm.org>
2016-07-16 08:26:14 -07:00
Glenn Randers-Pehrson
096dbf8335 [libpng17] Fixed more indentation to comply with our coding style. 2016-07-15 14:43:19 -05:00
Glenn Randers-Pehrson
9743d58bc0 [libpng17] Fix one incorrect indent in pngvalid.c 2016-07-13 17:19:58 -05:00
Glenn Randers-Pehrson
bdb730a593 [libng17] Undo bad indentation change in example.c 2016-07-13 16:30:28 -05:00
Glenn Randers-Pehrson
f1fb09c406 [libpng17] Fixed some indentation to comply with our coding style (synced
with libpng-1.6.24beta05).
2016-07-13 15:27:04 -05:00
Glenn Randers-Pehrson
83ca33b017 [libpng17] Minor update of INSTALL 2016-07-04 20:39:41 -05:00
Glenn Randers-Pehrson
aa78bc36d9 [libpng17] Bump version to 1.7.0beta83 2016-07-04 14:30:59 -05:00
Glenn Randers-Pehrson
f7b1d9a172 [libpng17] Imported from libpng-1.7.0beta82.tar 2016-07-04 14:30:52 -05:00
Glenn Randers-Pehrson
ce67b437ea [libpng17] Fixed two Coverity issues in pngcp.c. 2016-07-04 12:30:10 -05:00
Glenn Randers-Pehrson
86a3c4fb14 [libpng17] Don't call png_icc_set_sRGB() when it's not compiled. 2016-07-03 10:26:38 -05:00
Glenn Randers-Pehrson
4b846be113 [libpng17] Relocated misplaced #endif in png.c sRGB profile checking. 2016-07-02 21:33:25 -05:00
Glenn Randers-Pehrson
b9d7d5525b [libpng17] Added "Common linking failures" section to INSTALL 2016-07-02 12:01:27 -05:00
John Bowler
0ecbe53243 pngimage: correct #define checking
In libpng 1.7 pngimage needs to check PNG_WRITE_PNG_SUPPORTED (new in 1.7), not
PNG_WRITE_SUPPORTED because png_write_png can be disabled without disabling
PNG_WRITE_SUPPORTED.  Copied the approach from 1.6 pngcp.c (so this still works
in 1.6 as well.)
2016-07-02 07:37:37 -07:00
Glenn Randers-Pehrson
53bda5a7af [libpng17] Sync contrib/libtests/pngimage.c with libpng16; update CHANGES and ANNOUNCE 2016-07-02 08:53:21 -05:00
John Bowler
6a574a84bd pngcp minimal configuration changes
Corrections for the pngcp minimal configuration in libpng 1.7 and corrections to
the libpng 1.7 code to fix bugs revealed by the reduced configuration.

Signed-off-by: John Bowler <jbowler@acm.org>
2016-07-01 22:39:13 -07:00
John Bowler
eaf7abfdc3 pngcp: tool to copy PNG files
This adds pngcp to the build together with a pngcp.dfa configuration test; the
test revealed some configuration bugs which are fixed by corrections to the
_SUPPORTED macros.

pngcp builds on all tested configurations and a number of bugs have been fixed
to make this happen relative to the version in libpng 1.7 contrib/examples.
pngcp.dfa will have to be different for 1.7 but pngcp.c should work fine (not
yet tested).  pngcp itself is still missing a usage message; this is a
preliminary version, although since it behaves the same way as 'cp' most unoids
shouldn't have a problem using it correctly.

Signed-off-by: John Bowler <jbowler@acm.org>
2016-07-01 11:44:08 -07:00
John Bowler
0f5992051f Move pngcp to contrib/tools
Signed-off-by: John Bowler <jbowler@acm.org>
2016-07-01 11:38:03 -07:00
Glenn Randers-Pehrson
12c3c2e136 [libpng17] Sync pngvalid.c with libpng16; update CHANGES and ANNOUNCE 2016-06-24 21:36:29 -05:00
Glenn Randers-Pehrson
d6037dcb09 [libpng17] Update CHANGES and ANNOUNCE 2016-06-23 12:14:15 -05:00
John Bowler
9dfdb2270b SKIP definition in pngstest.c misplaced
The SKIP definition needs to come after the png.h include (see all the other .c
files in contrib/libtests) because it depends on PNG_LIBPNG_VER.  This commit
puts it in the correct place.

Signed-off-by: John Bowler <jbowler@acm.org>
2016-06-23 09:13:10 -07:00
Glenn Randers-Pehrson
29be8f11ed [libpng17] Bump version to 1.7.0beta82 2016-06-11 18:47:04 -05:00
Glenn Randers-Pehrson
8592a85535 [libpng17] Imported from libpng-1.7.0beta81.tar 2016-06-11 18:46:56 -05:00
John Bowler
b21a37323f [libpng17] Avoid potential overflow of the PNG_IMAGE_SIZE macro. This macro
is not used within libpng, but is used in some of the examples.
2016-06-11 14:21:08 -05:00
John Bowler
7a0fe97841 Change image size checks
This covers the case where PNG_IMAGE_BUFFER_SIZE can overflow in the application
as a result of the application using an increased 'row_stride'; previously
png_image_finish_read only checked for overflow on the base calculation of
components.  (I.e. it checked for overflow of a png_alloc_size_t number on the
total number of pixel components in the output format, not the possibly padded
row length and not the number of bytes, which for linear formats is twice the
number of components.)
2016-06-11 10:12:59 -07:00
Glenn Randers-Pehrson
9a137f332f [libpng17] Update CHANGES and ANNOUNCE 2016-06-08 13:45:37 -05:00
John Bowler
8c8aea7fd4 png_app_warning fix
The implementations of png_app_error and png_app_warning were swapped.  The
non-release behavior of using PNG_ERROR on both doesn't work in practice because
there are some cases where the warnings are very mild (specifically the one
about writing an iCCP chunk when sRGB could be used.)  png_app_warning now does
PNG_WARN by default in all cases.

Signed-off-by: John Bowler <jbowler@acm.org>
2016-06-08 10:43:25 -07:00
John Bowler
d52c8eba99 Compression changes/fixes
Simplified API: change handling of PNG_IMAGE_FLAG_FAST to use
PNG_COMPRESSION_HIGH_SPEED, and PNG_COMPRESSION_HIGH otherwise.

Compression: add missing break statements that caused some compression settings
to fall through to the 'HIGH' setting.

Internal: remove png_struct::flags, it only stored the 'library mismatch' flag
and that could never be accessed (because immediately after it was set the
png_struct, which was on the stack, was eliminated.)

Signed-off-by: John Bowler <jbowler@acm.org>
2016-06-08 08:37:20 -07:00
Glenn Randers-Pehrson
b70b51ba17 [libpng17] Update CHANGES and ANNOUNCE 2016-06-07 14:46:42 -05:00
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 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 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 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
John Bowler
4697cbded6 Simplified API: write-to-memory, overflow handling
This implements an API and provides a number of assist macros to allow an
application which uses the simplified API write to bypass stdio and write
directly to memory.

It also includes some warnings (png.h) and some check code to detect *possible*
overflow in the ROW_STRIDE and simplified image SIZE macros.  This disallows
image width/height/format that *might* overflow.  A quiet API change that limits
in-memory image size (uncompressed) to less that 4GByte and image row size
(stride) to less than 2GByte.

Signed-off-by: John Bowler <jbowler@acm.org>
2016-01-18 11:50:30 -08:00
John Bowler
033a0d7b49 pngunknown: fix NO_STDIO build
pngunknown.c calls png_init_io (always), skip the test if there is no stdio.h
support.

Signed-off-by: John Bowler <jbowler@acm.org>
2016-01-18 11:34:13 -08:00
Glenn Randers-Pehrson
eacf6f9637 [libpng17] Changed PNG_USE_MKSTEMP to __COVERITY__ to select alternate
"tmpfile()" implementation in contrib/libtests/pngstest.c
2016-01-17 16:03:10 -06:00
Glenn Randers-Pehrson
7912bf3037 [libpng17] Bump version to 1.7.0beta78 2016-01-16 08:00:36 -06:00
Glenn Randers-Pehrson
e4fad63915 [libpng17] Imported from libpng-1.7.0beta77.tar 2016-01-16 08:00:23 -06:00
Glenn Randers-Pehrson
89287f10b8 [libpng17] Worked around a false-positive Coverity issue in pngvalid.c. 2016-01-13 09:48:41 -06:00
Glenn Randers-Pehrson
6271b4fc78 [libpng17] Updated CHANGES and ANNOUNCE 2016-01-12 14:44:47 -06:00
John Bowler
3d024874a5 Recently introduced palette sharing bug
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>
2016-01-12 09:36:10 -08:00
Glenn Randers-Pehrson
2fce16e5c4 [libpng17] Update CHANGES and ANNOUNCE, fix typo in png.h 2016-01-10 19:34:16 -06:00
John Bowler
fc322f6d48 Add pngcp IDAT size test
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>
2016-01-10 13:53:47 -08:00
John Bowler
1afbb57994 IDAT read buffering correction
The sequential read code failed to read to the end of the IDAT stream in about
1/820 cases, resulting in a spurious warning.  The
png_set_compression_buffer_size API also would not work (or do bad things) if
the size of a zlib uInt was less than 32 bits.

This includes a quiet API change to alter png_set_compression_buffer_size to use
a png_alloc_size_t, not png_size_t and implement the correct checks.

Signed-off-by: John Bowler <jbowler@acm.org>
2016-01-10 13:51:29 -08:00
John Bowler
e393f19527 Fix write problem with reduced size IDAT chunks
png_set_compression_buffer_size would result in a spurious debug assert if the
compression buffer size was set to something other than a multiple of
PNG_ROW_BUFFER_SIZE; the debug test failed to add the buffer 'start'

Signed-off-by: John Bowler <jbowler@acm.org>
2016-01-10 13:49:34 -08:00
John Bowler
79378d49b3 [libpng17] Changed copyright and license in pngcp.c to be nearly public domain
similar to the other files in the contrib/examples directory.
2016-01-10 12:09:38 -06:00
Glenn Randers-Pehrson
d9d6b6e361 [libpng17] Update CHANGES and ANNOUNCE 2016-01-10 08:00:00 -06:00
John Bowler
b9014ed336 contrib/examples/pngcp search mode
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>
2016-01-09 17:40:55 -08:00
John Bowler
faf68f8d57 Fix for serious write bugs in pngwutil.c
There are two separate problems.  The first is that the CMINFO optimization code
gets run twice on any PNG IDAT stream longer than 2048 bytes and the second time
can overwrite bytes 2048,2049 destroying the output.

The second is that one of the (debug) checks was slightly wrong (< when <=
should have been used) and this causes write to abort maybe 1/2048 times.

Signed-off-by: John Bowler <jbowler@acm.org>
2016-01-09 17:38:34 -08:00
Glenn Randers-Pehrson
09a1afbb3d [libpng17] Fixed another Coverity defect, NULL dereference "ps" in pngwutil.c 2016-01-08 18:59:36 -06:00
Glenn Randers-Pehrson
27e11dc8cf [libpng17] Bump version to 1.7.0beta77 2016-01-07 13:08:04 -06:00
Glenn Randers-Pehrson
df4568f84b [libpng17] Imported from libpng-1.7.0beta76.tar 2016-01-07 13:06:57 -06:00
Glenn Randers-Pehrson
6d5f00571d [libpng17] Fixed new Coverity defect, potential NULL dereference of "ps"
in pngwutil.c; Added temporary workaround for Coverity "Dead code" defect.
2016-01-07 09:24:56 -06:00
Glenn Randers-Pehrson
4705951df1 [libpng17] Relocate assert() in pngfix.c, update CHANGES and ANNOUNCE. 2016-01-06 16:16:09 -06:00
John Bowler
f33fe44b9f Mark 'limit' UNUSED in transform_range_check
Only affects release builds

Signed-off-by: John Bowler <jbowler@acm.org>
2016-01-06 13:00:08 -08:00
Glenn Randers-Pehrson
43d0aa7218 [libpng17] Removed redundant "option WRITE" from scripts/pnglibconf.dfa 2016-01-02 14:13:49 -06:00
Glenn Randers-Pehrson
89ebb4dd52 [libpng17] Happy 2016! Updated copyright year 2016-01-02 13:51:52 -06:00
Glenn Randers-Pehrson
8d18e76f2b [libpng17] Updated the manpage (libpng.3 and libpng-manual.txt) 2015-12-29 20:39:28 -06:00
Glenn Randers-Pehrson
fafbc6a458 [libpng17] Update CHANGES and ANNOUNCE, fix two trivial typos in comments 2015-12-29 19:50:41 -06:00
John Bowler
4253c4d759 tIME and text position handling
The handling of tIME and text chunks on read now records the location of the
chunks relative to PLTE and IDAT.  Behavior on write is unchanged except that if
the position was recorded on read it will be re-used.

This involves an ABI change to the png_text_struct; a one byte location field is
added (with the same meaning as the one used to record unknown chunk location.)
Because this field is only used on read there is no API change unless a png_info
from a libpng read is passed to a subsequent libpng write (this did not work
very well before 1.7; the tIME chunk could get duplicated.)

png_set_text ignores the new field, resetting it to the current position in the
read or write stream.  On write the position is set to the next location to be
written unless the write has not started (the position is before the signature)
in which case the location is set to PNG_HAVE_PLTE|PNG_AFTER_IDAT.  When the
chunk is written the position is set to the actual write location (effectively
the position is frozen.)

Signed-off-by: John Bowler <jbowler@acm.org>
2015-12-29 15:30:31 -08:00
Glenn Randers-Pehrson
c90572ee77 [libpng17] Updated CHANGES and ANNOUNCE 2015-12-28 19:57:26 -06:00
John Bowler
ef26a3f0fb pngcp.c: code to test zlib options
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>
2015-12-28 16:17:12 -08:00
John Bowler
63ea57a796 Add NULL pz->list test to png_zlib_compress_validate
This seems safer; in fact a NULL dereference never happens because the test ends
up just doing arithmetic on NULL but it seems possible that the undefined
arithmetic can still happen if there is a bug elsewhere.

Signed-off-by: John Bowler <jbowler@acm.org>
2015-12-28 16:15:36 -08:00
John Bowler
07c60a383a Correct the options handling
Setting the new, higher, option bits triggered the byte check (which is no
longer necessary).

Signed-off-by: John Bowler <jbowler@acm.org>
2015-12-28 16:14:15 -08:00
Glenn Randers-Pehrson
8d124a250a [libpng17] In projects/vstudio, merged readme.txt and WARNING into README.txt 2015-12-28 08:50:52 -06:00
Glenn Randers-Pehrson
0340dcdcbd [libpng17] Indented tables in projects/vstudio/WARNING 2015-12-27 20:50:18 -06:00
Glenn Randers-Pehrson
ff57ec2126 [libpng17] Minor update to vstudio documentation 2015-12-27 20:35:29 -06:00
Glenn Randers-Pehrson
745a926a38 [libpng17] Bump version to 1.7.0beta76 2015-12-25 08:48:02 -06:00
Glenn Randers-Pehrson
4b1d9e8c2a [libpng17] Imported from libpng-1.7.0beta75.tar 2015-12-25 08:31:37 -06:00
Glenn Randers-Pehrson
bb4bcecaa0 [libpng17] Updated CHANGES and ANNOUNCE 2015-12-21 09:21:31 -06:00
David Drysdale
28fa0d23c1 Reverse order of tests in png_zlib_compress_validate
Undefined behaviour sanitizer currently fires for this test
with an error about member access within null pointer to
struct; put the check that relies on pz->list being non-NULL
second.
2015-12-21 11:29:34 +00:00
Glenn Randers-Pehrson
1bfeb46881 [libpng17] Update CHANGES and ANNOUNCE 2015-12-19 14:49:48 -06:00
John Bowler
ace10ed9a2 Fix release builds (incorrect debug macro)
Signed-off-by: John Bowler <jbowler@acm.org>
2015-12-19 10:26:45 -08:00
John Bowler
156006bb1a Added an accurate 'methodical' measure
Also fix incorrect references to 'pngimage' in pngcp.

Signed-off-by: John Bowler <jbowler@acm.org>
2015-12-19 09:51:41 -08:00
John Bowler
8d48a512bd Fix duplicate tIME chunk from png_write_png
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>
2015-12-19 09:51:07 -08:00
John Bowler
c75a0a40b4 Revert "Disable 'methodical' filter selection code"
This reverts commit 9c76207dbb86e04fd2f5eef088be72ba4a454a36.

Signed-off-by: John Bowler <jbowler@acm.org>
2015-12-19 09:50:15 -08:00
Glenn Randers-Pehrson
fad9c9af47 [libpng17] Bump version to 1.7.0beta75 2015-12-19 09:25:12 -06:00
Glenn Randers-Pehrson
5695e897fd [libpng17] Imported from libpng-1.7.0beta74.tar 2015-12-19 09:25:01 -06:00
Glenn Randers-Pehrson
0e249e9d93 [libpng17] Updated CHANGES and ANNOUNCE 2015-12-18 22:28:13 -06:00
Glenn Randers-Pehrson
a78c4e286a Merge branch 'test17' of git://github.com/daviddrysdale/libpng into libpng17 2015-12-18 18:09:31 -06:00
Glenn Randers-Pehrson
16424d20b5 [libpng17] Update CHANGES and ANNOUNCE 2015-12-18 14:41:17 -06:00
John Bowler
9c76207dbb Disable 'methodical' filter selection code
It is incomplete; it works but does not do anything useful except, maybe, on
really enormous images.

Signed-off-by: John Bowler <jbowler@acm.org>
2015-12-18 09:17:41 -08:00
David Drysdale
2023c4a0a5 Add Travis build configuration
Include sanitizers and coverage (via https://coveralls.io)
2015-12-18 07:23:56 +00:00
John Bowler
69ff249bc4 Merge branch 'libpng17' into libpng17-filter-selection 2015-12-17 20:06:48 -08:00
Glenn Randers-Pehrson
844e264234 [libpng17] Updated CHANGES and ANNOUNCE 2015-12-17 20:53:54 -06:00
John Bowler
61acc4c9ed Prototype implementation of filter selection
This rewrites the code used previously in the heuristics to make it easier to
debug and introduces the 'methodical' method, which is intended to be an
expensive but reliable way of reducing image size.

The code in this commit does not work; the 'methodical' test for success does
not take account of data buffered inside zlib and, anyway, it changes the
results of pngtest so that the test fails.  This commit is just a checkpoint of
the current state; another commit will temporarily disable the 'methodical'
code.

Signed-off-by: John Bowler <jbowler@acm.org>
2015-12-17 17:47:29 -08:00
John Bowler
bd0bb3ca7f Fix undefined behavior in pngvalid.c
Undefined because (png_byte) << shift is undefined if it changes the signed bit
(because png_byte is promoted to int).  The libpng exported functions
png_get_uint_32 and png_get_uint_16 handle this.

Bug reported by David Drysdale as a result of reports from UBSAN in clang 3.8.

This changes pngvalid to use BE random numbers; this used to produce errors but
these should not be fixed as a result of the previous changes.

Signed-off-by: John Bowler <jbowler@acm.org>
2015-12-17 12:58:36 -08:00
Glenn Randers-Pehrson
386b2b0a7b [libng17] Update CHANGES and ANNOUNCE 2015-12-15 12:26:54 -06:00
John Bowler
d103609ac5 pngvalid with 'limit' checks disabled in RC+
This widens the 'limit' check on the internally calculated error limits in the
'DIGITIZE' case (the code used prior to 1.7 for rgb_to_gray error checks) and it
changes the check to only operate in non-release builds (base build type not RC
or RELEASE.)

Signed-off-by: John Bowler <jbowler@acm.org>
2015-12-15 08:33:18 -08:00
Glenn Randers-Pehrson
639f8a4668 [libpng17] Update CHANGES and ANNOUNCE, fix date in pngvalid.c 2015-12-14 06:56:49 -06:00
John Bowler
aed7f7aaf9 Merge branch 'libpng17' of ../../libpng into libpng17 2015-12-13 22:28:27 -08:00
Glenn Randers-Pehrson
15b6717221 [libpng17] Update copyright years in source files. 2015-12-13 22:37:27 -06:00
Glenn Randers-Pehrson
c9fda22f76 [libpng16] Fix typo in "last-changed" date. 2015-12-13 18:25:36 -08:00
John Bowler
4891f1a5a8 Fix rgb_to_gray graylo==0 errors, build issues
Fixes to pngvalid for various reduced build configurations (eliminate unused
statics) and a fix for the case in rgb_to_gray when the digitize option reduces
graylo to 0, producing a large error.

Signed-off-by: John Bowler <jbowler@acm.org>
2015-12-13 18:02:31 -08:00
John Bowler
abe4a4f049 Remove LE/BE dependencies in pngvalid
This 'fixes' the current problem in the BE tests by not testing it, making the
BE code the same as the LE version.

Signed-off-by: John Bowler <jbowler@acm.org>
2015-12-13 18:00:21 -08:00
Glenn Randers-Pehrson
f3fa5dce47 [libpng17] Bump version to 1.7.0beta74 2015-12-11 16:13:00 -06:00
Glenn Randers-Pehrson
17bfbce61c [libpng17] Imported from libpng-1.7.0beta73.tar 2015-12-11 16:07:31 -06:00
Glenn Randers-Pehrson
2933c2e361 [libpng17] Changed png_struct->options from png_byte to png_uint_32, to hold
up to 16 2-bit options.
2015-12-11 14:53:54 -06:00
Glenn Randers-Pehrson
69f21bc6eb [libpng17] Combine tests for info_ptr==NULL in png_handle_PLTE(). 2015-12-11 14:28:54 -06:00
Glenn Randers-Pehrson
454408799b [libpng17] Updated ANNOUNCE and CHANGES to describe recent fix more accurately. 2015-12-09 15:55:11 -06:00
Glenn Randers-Pehrson
4c1ee27962 [libpng17] Fixed a syntax error in tests/pngstest that some shells other than
bash could not parse (Bug report by Nelson Beebe).
2015-12-09 13:29:02 -06:00
Glenn Randers-Pehrson
26090a5f43 [libpng17] Bump version to 1.7.0beta73 2015-12-08 13:03:30 -06:00
Glenn Randers-Pehrson
bfd8446816 [libpng17] Imported from libpng-1.7.0beta72.tar 2015-12-08 12:56:55 -06:00
Glenn Randers-Pehrson
605f8d046f [libpng17] Update CHANGES and ANNOUNCE 2015-12-06 20:12:23 -06:00
John Bowler
b8ab93dc6f Fix stack smaller in write png_copy_row
This also resulted in PNG data with random row bytes.

Signed-off-by: John Bowler <jbowler@acm.org>
2015-12-06 11:12:17 -08:00
John Bowler
66b53bdd37 Merge remote-tracking branch 'code/libpng17-20151204' into libpng17-71-1 2015-12-06 10:41:58 -08:00
Glenn Randers-Pehrson
dcbc357c46 [libpng17] Bump version to 1.7.0beta72 2015-12-05 13:58:01 -06:00
Glenn Randers-Pehrson
8ac1821831 [libpng17] Imported from libpng-1.7.0beta71.tar 2015-12-05 13:52:36 -06:00
Glenn Randers-Pehrson
3407d0f7c4 [libpng17] Updated CHANGES and ANNOUNCE 2015-12-05 13:51:07 -06:00
John Bowler
c8d2efcb50 Fix g++ builds
enums are (int), G++ objects to (int) and (unsigned) being used together in ?:

Signed-off-by: John Bowler <jbowler@acm.org>
2015-12-03 17:17:42 -08:00
Glenn Randers-Pehrson
99436a407e [libpng17] Bump version to 1.7.0beta71 2015-12-03 17:54:53 -06:00
John Bowler
59136cc3b3 Fix build break in no-write-filters cases
Signed-off-by: John Bowler <jbowler@acm.org>
2015-12-03 14:12:05 -08:00
John Bowler
afbaf7150b Merge branch 'libpng17' into libpng17-20151201
MASSIVE merge conflicts; way beyond those reported here:

Conflicts:
	pngstruct.h
	pngwutil.c
	scripts/pnglibconf.h.prebuilt
2015-12-03 13:47:39 -08:00
John Bowler
86499967c3 Checkpoint for 'methodical' filter selection
This checkpoint is to allow the massive merge with the recent mainline libpng17
changes.

Signed-off-by: John Bowler <jbowler@acm.org>
2015-12-03 13:25:11 -08:00
Glenn Randers-Pehrson
028d2c3fd6 [libpng17] Bump version to 1.7.0beta71 2015-12-03 10:15:25 -06:00
Glenn Randers-Pehrson
47ed19dfce [libpng17] Bump version to 1.7.0beta71 2015-12-02 22:31:19 -06:00
Glenn Randers-Pehrson
94a5189b1c [libpng17] Imported from libpng-1.7.0beta70.tar 2015-12-02 22:30:47 -06:00
John Bowler
9fce04fcd6 Change option (SUPPORTED) names, dummy code
The filter selection options are made more intuitive (IMO, but I am not an
Intuitive User).  Dummy code added for methodical filter selection.

Signed-off-by: John Bowler <jbowler@acm.org>
2015-12-02 19:03:28 -08:00
John Bowler
71c5123a4d Merge branch 'libpng17' into libpng17-20151201 2015-12-02 17:10:45 -08:00
John Bowler
e9d567d9ec Filter heuristic implementation
This implements the heuristic part of filter selction, the methodic testing
approach is still not implemented.  png_set_option methods are incomplete.

Signed-off-by: John Bowler <jbowler@acm.org>
2015-12-02 17:08:17 -08:00
Glenn Randers-Pehrson
37a50281cf [libpng17] Reverted recent manual change. The additional restrictions
on the order of png_set_PLTE, png_set_tRNS, and png_set_hIST are
not necessary.
2015-12-01 17:23:54 -06:00
Glenn Randers-Pehrson
aacda27449 [libpng17] Updated ANNOUNCE and CHANGES 2015-12-01 11:35:57 -06:00
Glenn Randers-Pehrson
b427d7216d Merge branch 'libpng17-20151130' of git://github.com/jbowler/libpng-1 into libpng17 2015-12-01 11:20:41 -06:00
Glenn Randers-Pehrson
c46bd30b51 [libpng17] Updated manual to require png_set_PLTE() to precede png_set_tRNS()
and png_set_hIST() if either is present.
2015-12-01 11:13:44 -06:00
John Bowler
0f2f0f7bbd Merge branch 'libpng17' into libpng17-20151130 2015-12-01 08:41:45 -08:00
John Bowler
84a8bb8244 Make png_struct palette, trans_alpha private
This removes the side-effect on the png_struct palette of calling png_set_PLTE
or png_set_tRNS.  NOTE: this is a quiet API change, it was possible before to
alter the palette on a PNG image by using png_set_PLTE, but this was unintended
and inconsistent with the other png_set APIs.

Fix a bug in palette index checking; png_struct::num_palette could, in
principle, get changed by the transformations (e.g. png_set_quantize) and this
would invalidate the check.  The palette checking init function now makes a copy
of png_struct::num_palette.

Fix a bug in pngvalid error handling.  A png_error in png_write_info is not
continuable (a valid image cannot necessarily be written afterward) because the
png_error aborts the write of subsequent pre-IDAT chunks.  In particular an
abort as a result of a bogus colorspace information (gAMA, cHRM, sBIT etc)
prevents the write of the PLTE chunk.

Signed-off-by: John Bowler <jbowler@acm.org>
2015-12-01 08:16:53 -08:00
John Bowler
8fe2eac47f Separate png_compress_IDAT into w/c
I.e. write/compress, also remove some trailing spaces and clean up pnglibconf
stuff.

Signed-off-by: John Bowler <jbowler@acm.org>
2015-11-30 21:00:22 -08:00
Glenn Randers-Pehrson
cb3402221b [libpng17] Updated PNG_ZBUF_SIZE definition in scripts/pnglibconf.h.prebuilt 2015-11-30 17:50:39 -06:00
Glenn Randers-Pehrson
8978eba436 [libpng17] Update CHANGES and ANNOUNCE, update dates in png.c and png.h 2015-11-30 16:57:23 -06:00
John Bowler
4792c8a751 compression code unification
Unify the compression code so that inflate calls are localized to a common
routine.  Ground work for filter selection support.  Minor API changes to use
void* not byte* for data parameters.  Unification of some of the compression
code with the decompression code; IDAT_size replaces IDAT_read_size and
zbuffer_size, IDAT reading and writing is no longer controlled by the size of
the compression buffer.

Signed-off-by: John Bowler <jbowler@acm.org>
2015-11-30 13:39:49 -08:00
John Bowler
6bbc74d880 pngunknown fix for multiple IDAT chunks
Fixes the case where IDAT is treated as unknown and saved; the first IDAT chunk
ends up 'before' IDAT, the rest 'after', pngunknown has to take this into
account since it checks before and after.
2015-11-28 08:42:54 -08:00
John Bowler
b3a18efebf Filter code change prep.
This commit moves code round and changes the filter write interfaces that took
png_uint_32 buffer pixel counts to unsigned int.  Also moves compression code
and definitions into pngwutil.c so that the compression code is isolated from
other definitions.

Signed-off-by: John Bowler <jbowler@acm.org>
2015-11-27 15:42:52 -08:00
John Bowler
14d11b9f35 contrib space removal
Remove all trailing spaces from source files in contrib

Signed-off-by: John Bowler <jbowler@acm.org>
2015-11-26 09:55:37 -08:00
John Bowler
e41820cd0b Merge branch 'libpng17' into libpng17-20151124.0001 2015-11-25 16:08:20 -08:00
John Bowler
18211df70b [libpng17] Fix CMINFO bug in contrib/tools/pngfix.c 2015-11-25 16:03:47 -06:00
John Bowler
1775bdeb24 Better filter checking
Improve pngvalid coverage of filter combinations, remove the (new in 1.7) code
which disabled previous-row filters on the first row of an image in some cases.

Signed-off-by: John Bowler <jbowler@acm.org>
2015-11-24 22:24:18 -08:00
John Bowler
8bffb48bc1 Add new pngvalid test case
This tests the 'size' images in the sequential reader, the existing test case
only uses the progressive reader which means that important parts of the filter
code never got tested.

Signed-off-by: John Bowler <jbowler@acm.org>
2015-11-24 21:45:10 -08:00
Glenn Randers-Pehrson
edec44bfc4 [libpng17] Update CHANGES and ANNOUNCE 2015-11-24 20:45:26 -06:00
John Bowler
1c514557b6 Merge branch 'libpng17' of ../../libpng into libpng17 2015-11-24 18:17:31 -08:00
John Bowler
85d7eca204 Fix first row init on read.
The code failed to zero out the row buffer at the start of a pass where the AVG
filter is used because 'row_number' is not always zero (on interlaced images)
and, apparently, the assertion that the buffer had been zeroed when allocated
was not always correct for non-interlaced images.  Revealed by pngvalid --size
with a hack to make it always use AVG.

Signed-off-by: John Bowler <jbowler@acm.org>
2015-11-24 17:56:06 -08:00
John Bowler
5357dd77f0 Fix significant bracketing problem
This error prevents the read of non-interlaced PNG files with height 1.  A
simple bracket problem caused by hasty multiple edits.

Signed-off-by: John Bowler <jbowler@acm.org>
2015-11-24 17:18:46 -08:00
Glenn Randers-Pehrson
5db709d83c [libpng17] Updated CHANGES and ANNOUNCE, removed trailing blanks from *.c *.h 2015-11-24 14:38:52 -06:00
Glenn Randers-Pehrson
616ed1197b [libpng17] Bump version to 1.7.0beta70 2015-11-24 13:37:41 -06:00
Glenn Randers-Pehrson
0cb0a45721 [libpng17] Imported from libpng-1.7.0beta69.tar 2015-11-24 09:51:46 -06:00
Glenn Randers-Pehrson
f476f13488 [libpng17] Updated CHANGES and ANNOUNCE 2015-11-23 21:44:18 -06:00
John Bowler
8d93ec2eca pngvalid fixes and backward compat
This fix is to the PNG_MAX_GAMMA_8 handling and png_set_rgb_to_gray, which had
bugs which were likely to expose end cases of rgb-to-gray conversion errors.
This might explain some of the machine math dependencies we are seeing
(*might*).

Signed-off-by: John Bowler <jbowler@acm.org>
2015-11-23 18:45:28 -08:00
John Bowler
b0076faf1f Backward compatibility with 1.6
1.6 did not define PNG_READ_PNG_SUPPORTED, ever; it doesn't matter there.

Signed-off-by: John Bowler <jbowler@acm.org>
2015-11-23 18:14:57 -08:00
John Bowler
fa86bd2a61 Backward compatibility for pngtest.c
This version can be used in 1.6 and 1.5 with appropriate changes to the last
line.

Signed-off-by: John Bowler <jbowler@acm.org>
2015-11-23 18:13:39 -08:00
John Bowler
961d60b067 Correct end-of-image test in pngread.c
This only changes the detection of invalid application behavior (too many calls
to png_read_row) from an affirm to a png_app_error.

Signed-off-by: John Bowler <jbowler@acm.org>
2015-11-23 18:12:17 -08:00
John Bowler
764ae07652 Merge branch 'libpng17' into libpng17-buffer-enhancements 2015-11-22 21:40:13 -08:00
John Bowler
6803b09cb7 Fixes for !READ_INTERLACE/!READ_PNG interpendencies
The reliance of png_read_png on interlace handling and some minor issues in the
test programs where they failed to correctly check for interlace handling were
exposed by the ability to write interlaced images even if WRITE_INTERLACING is
turned off.  This is fixed here.

Signed-off-by: John Bowler <jbowler@acm.org>
2015-11-22 21:37:16 -08:00
Glenn Randers-Pehrson
7a7e4367d0 [libpng17] Updated CHANGES and ANNOUNCE 2015-11-22 23:16:01 -06:00
John Bowler
b69df74b8e Re-remove PNG_WRITE_INTERLACE
Previous change backed out.

Signed-off-by: John Bowler <jbowler@acm.org>
2015-11-22 20:48:23 -08:00
John Bowler
a42416de9c Merge branch 'libpng17' into libpng17-buffer-enhancements 2015-11-22 20:43:56 -08:00
Glenn Randers-Pehrson
e51652b4db [libpng17] Reverted 12 -> 12U again. 2015-11-22 22:41:10 -06:00
Glenn Randers-Pehrson
771eb7d01e [libpng17] Update CHANGES, ANNOUNCE, pnglibconf.h.prebuilt 2015-11-22 22:35:35 -06:00
John Bowler
368bb1b241 Fix certain minimal config builds
The removal of png_struct::row_buffer and png_struct::row_format from write
builds configured without filter or transform support (respectively) wasn't
complete; some of the png.c and pngwrite.c cleanup code needed to handle the
potentially removed members.

Signed-off-by: John Bowler <jbowler@acm.org>
2015-11-22 20:34:00 -08:00
John Bowler
504ebd427d Back out READ/WRITE_INTERLACING changes
Now that the code works consistently so that these just switch off the support
for having libpng do the interlace/deinterlace the old names make more sense,
restoring them avoids cruft in the configuration file and avoids an unnecessary
version specific change.

Signed-off-by: John Bowler <jbowler@acm.org>
2015-11-22 20:25:24 -08:00
John Bowler
caa716d859 Fix build break introduced from libpng17
12->12U in a compare when the other side is signed.

Signed-off-by: John Bowler <jbowler@acm.org>
2015-11-22 19:52:12 -08:00
John Bowler
0f2554a5e6 Squashed commit of the following:
commit fc4b42b1d56f95efeb1b9fe42dc35b7d98d246bb
Merge: 74516c7 9eb1413
Author: John Bowler <jbowler@acm.org>
Date:   Sun Nov 22 19:37:54 2015 -0800

    Merge branch 'libpng17' into libpng17-filter-enhancements

commit 74516c7257f1a28a69985684c5673caa390c700a
Author: John Bowler <jbowler@acm.org>
Date:   Sun Nov 22 19:32:43 2015 -0800

    Make check full pass on gcc/g++ x86_64

    Signed-off-by: John Bowler <jbowler@acm.org>

commit e891e34737fc0bc9ee873a5d56b83c1e777b990c
Author: John Bowler <jbowler@acm.org>
Date:   Sun Nov 22 12:01:37 2015 -0800

    Checkpoint: write buffering changes

    This version fails in pngvalid --size because of an error handling very narrow
    images, otherwise a standard build passes make check.

    Signed-off-by: John Bowler <jbowler@acm.org>

commit 457a046ebdab737eefb477126cf855e49df6de50
Author: John Bowler <jbowler@acm.org>
Date:   Sun Nov 22 06:39:36 2015 -0800

    Fix previous bad merge

commit b4f426c97267317637d43f41fe0b05d1659bc63d
Merge: 07b9b90 a3458a6
Author: John Bowler <jbowler@acm.org>
Date:   Sun Nov 22 06:32:34 2015 -0800

    Merge branch 'libpng17' into libpng17-filter-enhancements

commit 07b9b90dfd653b744dbc3710b096facf6b4605f6
Merge: ed43306 5592e0b
Author: John Bowler <jbowler@acm.org>
Date:   Sat Nov 21 17:07:23 2015 -0800

    Merge branch 'libpng17' into libpng17-filter-enhancements

commit ed43306599f7039a90187862db82273fca3a4c3d
Merge: 772aed7 d3c0359
Author: John Bowler <jbowler@acm.org>
Date:   Tue Nov 17 17:47:26 2015 -0800

    Merge branch 'libpng17' into libpng17-filter-enhancements

commit 772aed72378df9c8fccc5a4594b095d02d410a9c
Merge: 73ae431 801608f
Author: John Bowler <jbowler@acm.org>
Date:   Mon Nov 16 14:26:38 2015 -0800

    Merge branch 'libpng17' into libpng17-filter-enhancements

commit 73ae4316cb6db7d7f6756583a1c213c35ca4e3f4
Merge: 687e6e3 c09b3ab
Author: John Bowler <jbowler@acm.org>
Date:   Sun Nov 15 09:31:30 2015 -0800

    Merge branch 'libpng17' into libpng17-filter-enhancements

commit 687e6e393e9d0220c2a12ec474aa01b83c5e9f25
Merge: fedd6da e916d9b
Author: John Bowler <jbowler@acm.org>
Date:   Thu Nov 5 08:45:14 2015 -0800

    Merge branch 'libpng17' into libpng17-filter-enhancements

commit fedd6da8798a14b2e002b0bc1379f5a09a03598a
Merge: 2e2fc5f ea41fd2
Author: John Bowler <jbowler@acm.org>
Date:   Tue Nov 3 21:05:01 2015 -0800

    Merge branch 'libpng17' into libpng17-filter-enhancements

commit 2e2fc5f6d7678b710c52b7ea081ac4add677d8d5
Merge: 990d5f8 5b05197
Author: John Bowler <jbowler@acm.org>
Date:   Mon Oct 12 08:28:30 2015 -0700

    Merge branch 'libpng17' into libpng17-filter-enhancements

commit 990d5f88688635dc0888657b689e30ffe7e7a7b3
Author: John Bowler <jbowler@acm.org>
Date:   Sun Oct 4 17:04:53 2015 -0700

    Read row buffer changes

    The read code now allocates one row buffer of the size of the input PNG row and,
    only if required, one buffer of the size of the output.

    The output buffer is required for the progressive reader (always) and for the
    sequential reader if libpng is de-interlacing an image (because the output row
    is used multiple times if png_read_row is called with a display row parameter.)

    This should reduce memory utilization by libpng significantly, but it has no
    detectable effect on overall performance figures of the test programs, these are
    probably dominated by memory allocations for the whole image within the test
    programs.

    Signed-off-by: John Bowler <jbowler@acm.org>

commit 527bf989bf0e30440f9e07a5544a6ebb1d6fd039
Merge: 50ebbc2 9099254
Author: John Bowler <jbowler@acm.org>
Date:   Sat Oct 3 13:39:17 2015 -0700

    Merge branch 'libpng17' into libpng17-filter-enhancements

commit 50ebbc2c9a24cf1a6b428db53d55fbd5af4d6be6
Merge: 21a7f40 2cd6d56
Author: John Bowler <jbowler@acm.org>
Date:   Sat Oct 3 11:16:32 2015 -0700

    Merge branch 'libpng17' into libpng17-filter-enhancements

commit 21a7f401ab40c79ead9e35882a8066e2cf1d6902
Merge: b512e1c 15a143e
Author: John Bowler <jbowler@acm.org>
Date:   Wed Sep 30 19:01:23 2015 -0700

    Merge branch 'libpng17' into libpng17-filter-enhancements

commit b512e1c2c5bfe6df8b6dca32f862d325ec22115e
Author: John Bowler <jbowler@acm.org>
Date:   Wed Sep 30 17:33:34 2015 -0700

    Transform rewrite: perform transforms in small chunks

    The intent of this change is to reduce the memory footprint during transform
    sequences by performing transforms in fixed (small) sized blocks of pixels.
    The change is incomplete; the filter code still works row-by-row, so the whole
    tranform also works row-by-row, the intent is to fix this so that everything
    works in small(ish) chunks.

    At present the change has no discernable effect on pngvalid --speed or pngstest
    with (e.g.) rgb-8-1.8.png; user time and (minor) page faults are the same in old
    and new versions.  The same applies to real-world 15MP PNG images; even on these
    the presence of the filter code causes a cyclical progress through memory which
    will interfere with any caching otherwise possible (useful word, 'otherwise'.)

    Signed-off-by: John Bowler <jbowler@acm.org>

commit 781cb3699b92beb0e6bc5e03cef8fba820267082
Author: John Bowler <jbowler@acm.org>
Date:   Wed Sep 30 17:12:53 2015 -0700

    Fix NO_WRITE_INTERLACE in pngvalid.c

    The support for writing interlaced images directly from libpng 1.7 was
    unintentionally disabled (INTERLACE_LAST was defined incorrectly, excluding the
    interlaced images).  This obscured the fact that the transform and error test
    case generators lacked the support for writing interlaced images from libpng.

    Signed-off-by: John Bowler <jbowler@acm.org>

commit 406ee2fd7946a384f1d7713712dc646080c5c52c
Author: John Bowler <jbowler@acm.org>
Date:   Wed Sep 30 17:11:40 2015 -0700

    Add pngvalid --transform --interlace test

    This increases code coverage by generating test cases with smaller length rows
    as a result of the interlacing.  Without this packswap handling was incompletely
    tested.

    Signed-off-by: John Bowler <jbowler@acm.org>

Signed-off-by: John Bowler <jbowler@acm.org>
2015-11-22 19:41:41 -08:00
Glenn Randers-Pehrson
9eb14136d8 [libpng17] Fixed bug recently introduced in png_set_PLTE() that uses png_ptr
not info_ptr.
2015-11-22 20:44:58 -06:00
Glenn Randers-Pehrson
09c90236f4 [libpng17] Refactored conditional compilation in png_init_row_info(). 2015-11-22 09:19:06 -06:00
Glenn Randers-Pehrson
a3458a6ba0 [libpng17] Refactor conditional compilation of png_get_compression_buffer_size()
for readability
2015-11-22 07:18:05 -06:00
Glenn Randers-Pehrson
daf4b9dd18 [libpng17] Clean up some conditional compilation of parts of statements
and fixed some indentation
2015-11-21 19:14:37 -06:00
Glenn Randers-Pehrson
3a866cb451 [libpng17] Avoid conditionally compiling parts of statements in png.c (suggested
by flaviommedeiros).
2015-11-21 18:18:26 -06:00
Glenn Randers-Pehrson
5592e0bc96 [libpng17] Use unsigned constants in pngrutil.c buffer length comparisons 2015-11-21 14:30:35 -06:00
John Bowler
57e92a8432 [libpng17] Use "1U" not "1" in pointer calculations in png_handle_sPLT(). 2015-11-19 21:13:29 -06:00
Glenn Randers-Pehrson
d3c0359b23 [libpng17] Removed a redundant new check in png_handle_pCAL(). 2015-11-17 16:14:35 -06:00
Glenn Randers-Pehrson
801608f8f4 [libpng17] Rearrange terms to make it self-evident that overflow cannot happen 2015-11-16 09:34:20 -06:00
Glenn Randers-Pehrson
c09b3ab2c7 [lbpng17] Avoid potential pointer overflow in png_handle_sPLT() and
png_handle_pCAL() (Bug report by John Regehr).
2015-11-13 22:25:03 -06:00
Glenn Randers-Pehrson
722645fec5 [libpng17] Bump version to 1.7.0beta69 2015-11-13 10:19:36 -06:00
Glenn Randers-Pehrson
f72d0d01eb [libpng17] Imported from libpng-1.7.0beta68.tar 2015-11-12 07:13:47 -06:00
Glenn Randers-Pehrson
97c4072cce [libpng17] Clean up coding style in png_set_PLTE() 2015-11-05 11:20:12 -06:00
Glenn Randers-Pehrson
7a92725e17 [libpng17] Update ANNOUNCE and CHANGES 2015-11-05 07:06:01 -06:00
Glenn Randers-Pehrson
e916d9bb60 [libpng17] Fixed new bug with CRC error after reading an over-length palette. 2015-11-04 23:49:01 -06:00
Glenn Randers-Pehrson
ea41fd2161 [libpng17] Bump version to 1.7.0beta68 2015-11-03 09:55:12 -06:00
Glenn Randers-Pehrson
dbd98b8c68 [libpng17] Imported from libpng-1.7.0beta67.tar 2015-11-03 09:55:02 -06:00
Glenn Randers-Pehrson
5cf6ed45c8 [libpng17] Clarified COPYRIGHT information to state explicitly that versions
are derived from previous versions.
Removed much of the long list of previous versions from png.h and
    libpng.3.
2015-11-03 09:47:54 -06:00
Glenn Randers-Pehrson
9f7d5aa973 [libpng17] Prevent setting or writing over-length PLTE chunk (Cosmin Truta).
Silently truncate over-length PLTE chunk while reading.
2015-11-01 13:01:56 -06:00
Glenn Randers-Pehrson
5b05197604 [libpng17] Added sPLT support to pngtest.c 2015-10-10 12:04:50 -05:00
Glenn Randers-Pehrson
90992547c7 [libng17] Updated CHANGES and ANNOUNCE 2015-10-03 15:11:12 -05:00
John Bowler
13ce05daaf Fix 'pow' macros in pngvalid.c
It is legal for 'pow' to be a macro, therefore the argument list cannot contain
preprocessing directives.  Make sure pow is a function where this happens (this
is a minimal safe fix, the issue only arises in non-performance-critical code.)

Signed-off-by: John Bowler <jbowler@acm.org>
2015-10-03 11:08:03 -07:00
John Bowler
2cd6d56ff6 Merge remote-tracking branch 'local/libpng17' into libpng17 2015-10-03 11:04:31 -07:00
Glenn Randers-Pehrson
1af270dc19 [libpng17] Bump version to 1.7.0beta67 2015-10-02 14:06:12 -05:00
Glenn Randers-Pehrson
2ddd06c392 [libpng17] Imported from libpng-1.7.0beta66.tar 2015-10-02 13:44:50 -05:00
Glenn Randers-Pehrson
33d4b5b66d [libpng17] Another attempt (successful this time) to quiet the Coverity issue. 2015-10-02 13:43:36 -05:00
John Bowler
15a143e85e Merge remote-tracking branch 'local/libpng17' into libpng17 2015-09-30 19:00:43 -07:00
Glenn Randers-Pehrson
bd55022b2d [libng17] Stifle the last remaining Coverity issue in libpng17. 2015-09-28 15:41:47 -05:00
John Bowler
c5bc9b668d Fix (work round) rgb-to-gray issues in libpng 1.6
The previous attempts to ignore the errors in the code aren't quite enough to
deal with the 'channel selection' encoding added to libpng 1.7; abort.
pngvalid.c is changed to drop this encoding in prior versions.

Signed-off-by: John Bowler <jbowler@acm.org>
2015-09-26 21:43:07 -07:00
Glenn Randers-Pehrson
975d8fac6d [libpng17] Update CHANGES and ANNOUNCE 2015-09-26 21:14:36 -05:00
John Bowler
e76a320539 Fix missing prototype for READ_GAMMA+!SIMPLIFIED_API
Signed-off-by: John Bowler <jbowler@acm.org>
2015-09-26 17:17:13 -07:00
John Bowler
eab2c419fa makepng fixes for the palette case
Also allow extra command line arguments; convenient for testing odd things.

Signed-off-by: John Bowler <jbowler@acm.org>
2015-09-26 16:44:29 -07:00
John Bowler
23324b8559 sBIT code coverage and fixes
Fixes for sBIT handling in the low-bit-depth gray and pngstest cases, extends
sBIT handling to the colormap code in the simplified API which is separately
implemented in pngread.c

Signed-off-by: John Bowler <jbowler@acm.org>
2015-09-26 15:24:20 -07:00
John Bowler
8dfa93beed Merge remote-tracking branch 'local/libpng17' into libpng17 2015-09-26 15:17:27 -07:00
Glenn Randers-Pehrson
ed44394ad0 [libpng17] Added "option READ_IMAGE on" to contrib/pngminim/decoder/pngusr.dfa
due to the new PNG_READ_IMAGE_SUPPORTED configuration in libpng-1.7.0beta65.
2015-09-26 07:55:54 -05:00
Glenn Randers-Pehrson
c23bdb1445 [libpng17] #ifdef out some dead code in pngrtran.c when sBIT is disabled. 2015-09-25 22:33:41 -05:00
John Bowler
cbf4adee5c Merge remote-tracking branch 'local/libpng17' into libpng17 2015-09-25 17:04:06 -07:00
John Bowler
1bc0781245 Merge remote-tracking branch 'local/libpng17' into libpng17 2015-09-25 17:01:16 -07:00
Glenn Randers-Pehrson
7441965463 [libpng17] Update CHANGES and ANNOUNCE 2015-09-25 18:54:12 -05:00
John Bowler
8d6c21ce96 pngvalid tests: add --strict, fix test names
Signed-off-by: John Bowler <jbowler@acm.org>
2015-09-25 16:43:34 -07:00
Glenn Randers-Pehrson
8c94b1295f Merge branch 'libpng17' of https://github.com/jbowler/libpng-1 into libpng17 2015-09-25 18:43:07 -05:00
Glenn Randers-Pehrson
1932e16c21 [libpng17] Restored license output to pngstest.c 2015-09-25 18:37:44 -05:00
John Bowler
a6278e7c87 Merge remote-tracking branch 'glennrp/libpng17' into libpng17 2015-09-25 16:25:11 -07:00
John Bowler
a5b993aaed Enable low-bit-depth gray tests in pngvalid 2015-09-25 16:22:59 -07:00
John Bowler
53e537439f Fix png_set_tRNS_to_alpha for low-bit-depth gray
Signed-off-by: John Bowler <jbowler@acm.org>
2015-09-25 16:22:17 -07:00
Glenn Randers-Pehrson
f1eec0ba62 [libng17] Updated CHANGES and ANNOUNCE, restored license info in
pngtest-errors.h
2015-09-25 17:40:48 -05:00
John Bowler
1e563f689c New test PNG files incorporated into make check
tests/pngstest-* are changed so that the new test files are divided into 8
groups by gamma and alpha channel.  This makes each test take just under 5
seconds on a moderately up-to-date x86_64 system using libpng16 (test times are
somewhat variable under libpng17 at present because of the lack of optimization
in some gamma processing paths.)

These tests have considerably better code and pixel-value coverage than
contrib/pngsuite however coverage is still incomplete.

Signed-off-by: John Bowler <jbowler@acm.org>
2015-09-25 12:21:10 -07:00
John Bowler
0301cc2627 Update pngstest-errors.h for new make check tests
Signed-off-by: John Bowler <jbowler@acm.org>
2015-09-25 12:20:36 -07:00
Glenn Randers-Pehrson
9ee0b63b09 [libpng17] Updated CHANGES and ANNOUNCE 2015-09-24 23:09:12 -05:00
John Bowler
2c13de800f Merge remote-tracking branch 'glennrp/libpng17' into libpng17
Changes from Glenn for legal reasons
2015-09-24 17:44:05 -07:00
John Bowler
d394d889e1 png_rgb_to_gray optimization fixes
This fixes the code that optimizes RGB to Gray transformations that only
selected on channel and clarifies the handling of max_depth in the transform
code.  It eliminates some UNTESTED cases and removes the write 'invert alpha'
UNTESTED macro because, while there are no test cases for it, code review
some months after writing it suggests it is ok.

Signed-off-by: John Bowler <jbowler@acm.org>
2015-09-24 17:33:32 -07:00
Glenn Randers-Pehrson
40d90d34a8 [libpng17] Add copyright and license to contrib/testpngs/makepngs.sh 2015-09-22 16:04:26 -05:00
John Bowler
3f6efbd8e2 Squashed commit of the following:
commit bf51c644f7d29400d884e20def9a0bee74904308
Author: John Bowler <jbowler@acm.org>
Date:   Tue Sep 22 09:05:13 2015 -0700

    Updated contrib/testpngs/*.png

    Corrected copyright/licensing information, corrected filtering.

    Signed-off-by: John Bowler <jbowler@acm.org>

commit 05399c8c82d7b188357dc6fa05a8cdd89426b155
Author: John Bowler <jbowler@acm.org>
Date:   Tue Sep 22 09:04:03 2015 -0700

    makepng.c: correct the first row filter setting

    It needs to include the "UP" filter so that libpng knows to retain the first
    line for the UP filter on the next one.  Without this libpng ended up using NONE
    for the second line.

    Signed-off-by: John Bowler <jbowler@acm.org>

commit 8fae6609c063c7e0a5eeb592f8eec15849617ae9
Author: John Bowler <jbowler@acm.org>
Date:   Mon Sep 21 17:15:45 2015 -0700

    makepng: spelling corrections, single test output

    Corrections to some obvious mistakes, plus one output file.

    Signed-off-by: John Bowler <jbowler@acm.org>

commit a2245a2c54a679d25f8f1609f85654d155936863
Author: John Bowler <jbowler@acm.org>
Date:   Mon Sep 21 13:39:48 2015 -0700

    Updated testpngs files with new Licensing tag

    Signed-off-by: John Bowler <jbowler@acm.org>

commit 46d3f863cace5b7aa769c9b882fca49e2a821138
Author: John Bowler <jbowler@acm.org>
Date:   Mon Sep 21 13:38:34 2015 -0700

    Updated makepng.c

    This supports more test cases and a reduced licence keyword (now licensing).
    The extra text cases require more slack in pngstest.c

    Signed-off-by: John Bowler <jbowler@acm.org>

commit 7c9a08b8bc5e2542184d4abb25c33c516bc0adc7
Author: John Bowler <jbowler@acm.org>
Date:   Sun Sep 20 20:55:19 2015 -0700

    Test PNG files

    These files were generated by contrib/testpngs/makepngs.sh --small with MAKEPNG
    set to the makepng compiled from the current contrib/libtests/makepngs.sh

    Signed-off-by: John Bowler <jbowler@acm.org>

commit c2a8a01b2ac733b8029478d10f700f5ab8a713f2
Author: John Bowler <jbowler@acm.org>
Date:   Sun Sep 20 20:51:06 2015 -0700

    makepng --small

    This patch adds code to 'makepng' to allow the generation of smaller images that
    also give better test case coverage.  It also adds copyright and licence to the
    generated images, reflecting the fact that they are original works of the author
    of the code.  The licence used is the Creative Commons Public Domain one,
    appropriate to a non-source-code work.

    The resultant image were used to generate the updated pngstest-errors.h file in
    a prior commit.

    Signed-off-by: John Bowler <jbowler@acm.org>

commit 8c025bcf3fdfb68fb8b1e5fab4b7deb0f94453f6
Author: John Bowler <jbowler@acm.org>
Date:   Sun Sep 20 20:40:52 2015 -0700

    Simplified API sRGB gamma handling correction

    If a gamma encoded file that has a gamma not matching that of sRGB is passed to
    the simplified API the previous code simply interpreted it as a power law
    encoding.  However old Mac files had a power law correction of 1.45 built in to
    the encoding, even though the display devices were consistent with sRGB.
    Assuming a power law encoding results in substantial differences in the
    interpretation of low 8-bit values; below 10.  For example an Apple '5' which is
    equivalent to an sRGB '17' ends up as the value '8'.

    This patch provides some measure of correction for this by making the gamma
    correction done within the simplified API assume that any encoded data is
    encoded relative to an sRGB-like transfer function; the data is corrected back
    to the PNG-nominal 2.2 value then decoded to linear (if required) using the sRGB
    transfer function.

    This reduces the errors reported by pngstest for such files (colormapped ones)
    but still leaves the issue with files where the standard libpng code does the
    gamma decoding.  To cope with the latter cases the patch also includes a new
    pngstest-errors which allows the result, however this is still a
    work-in-progress; a better solution is possible.

    Signed-off-by: John Bowler <jbowler@acm.org>
2015-09-22 13:46:19 -05:00
John Bowler
bf51c644f7 Updated contrib/testpngs/*.png
Corrected copyright/licensing information, corrected filtering.

Signed-off-by: John Bowler <jbowler@acm.org>
2015-09-22 09:05:13 -07:00
John Bowler
05399c8c82 makepng.c: correct the first row filter setting
It needs to include the "UP" filter so that libpng knows to retain the first
line for the UP filter on the next one.  Without this libpng ended up using NONE
for the second line.

Signed-off-by: John Bowler <jbowler@acm.org>
2015-09-22 09:04:03 -07:00
John Bowler
8fae6609c0 makepng: spelling corrections, single test output
Corrections to some obvious mistakes, plus one output file.

Signed-off-by: John Bowler <jbowler@acm.org>
2015-09-21 17:15:45 -07:00
John Bowler
a2245a2c54 Updated testpngs files with new Licensing tag
Signed-off-by: John Bowler <jbowler@acm.org>
2015-09-21 13:39:48 -07:00
John Bowler
46d3f863ca Updated makepng.c
This supports more test cases and a reduced licence keyword (now licensing).
The extra text cases require more slack in pngstest.c

Signed-off-by: John Bowler <jbowler@acm.org>
2015-09-21 13:38:34 -07:00
John Bowler
7c9a08b8bc Test PNG files
These files were generated by contrib/testpngs/makepngs.sh --small with MAKEPNG
set to the makepng compiled from the current contrib/libtests/makepngs.sh

Signed-off-by: John Bowler <jbowler@acm.org>
2015-09-20 20:55:19 -07:00
John Bowler
c2a8a01b2a makepng --small
This patch adds code to 'makepng' to allow the generation of smaller images that
also give better test case coverage.  It also adds copyright and licence to the
generated images, reflecting the fact that they are original works of the author
of the code.  The licence used is the Creative Commons Public Domain one,
appropriate to a non-source-code work.

The resultant image were used to generate the updated pngstest-errors.h file in
a prior commit.

Signed-off-by: John Bowler <jbowler@acm.org>
2015-09-20 20:51:06 -07:00
John Bowler
8c025bcf3f Simplified API sRGB gamma handling correction
If a gamma encoded file that has a gamma not matching that of sRGB is passed to
the simplified API the previous code simply interpreted it as a power law
encoding.  However old Mac files had a power law correction of 1.45 built in to
the encoding, even though the display devices were consistent with sRGB.
Assuming a power law encoding results in substantial differences in the
interpretation of low 8-bit values; below 10.  For example an Apple '5' which is
equivalent to an sRGB '17' ends up as the value '8'.

This patch provides some measure of correction for this by making the gamma
correction done within the simplified API assume that any encoded data is
encoded relative to an sRGB-like transfer function; the data is corrected back
to the PNG-nominal 2.2 value then decoded to linear (if required) using the sRGB
transfer function.

This reduces the errors reported by pngstest for such files (colormapped ones)
but still leaves the issue with files where the standard libpng code does the
gamma decoding.  To cope with the latter cases the patch also includes a new
pngstest-errors which allows the result, however this is still a
work-in-progress; a better solution is possible.

Signed-off-by: John Bowler <jbowler@acm.org>
2015-09-20 20:40:52 -07:00
Glenn Randers-Pehrson
d555056b24 [libng17] Suppressed bogus Coverity issues in pngrutil.c and pngwutil.c. 2015-09-19 22:47:59 -05:00
Glenn Randers-Pehrson
69f2152c0f [libpng17] Added license info to pngstest-errors.h and its generator. 2015-09-19 20:18:49 -05:00
Glenn Randers-Pehrson
e6a3e2456c [libpng17] Update CHANGES and ANNOUNCE with changes from pull request #20 2015-09-19 19:45:24 -05:00
John Bowler
493bfd14a2 gamma handling fixes
One serious bug; 8 was forced as a bit depth when caching a palette, even though
the palette have been expanded.  One less serious bug, the optimization for
avoiding gamma correction introduced significant errors if the app subsequently
did further corrections, only shown by using gAMA 1/1.52 files in pngstest.

Signed-off-by: John Bowler <jbowler@acm.org>
2015-09-19 16:36:22 -07:00
John Bowler
8a9a3fb4dd pngstest: make error limits version specific
Splitting the machine generated error structs out to a file allows the values to
be updated without changing pngstest.c itself, sine libpng 1.6 and 1.7 have
slightly different error limits this simplifies maintenance.

makepngs.sh has also been updated to more accurately reflect current problems in
libpng 1.7

Signed-off-by: John Bowler <jbowler@acm.org>
2015-09-19 16:21:36 -07:00
John Bowler
3e46c31961 Coverity bug fix: dead code
Also fix the previous fix attempt; the intent was to limit the calls to crc32 to
ZLIB_IO_MAX, although it is not clear that this is optimal.

Signed-off-by: John Bowler <jbowler@acm.org>
2015-09-19 16:19:18 -07:00
Glenn Randers-Pehrson
714515bc0c [libpng17] Improved description of filler-byte bug fix in CHANGES and ANNOUNCE. 2015-09-18 23:39:51 -05:00
John Bowler
38647d4b21 [libpng17] Fixed makepng.c so that it compiles with GCC 5.1.0.
Added contrib/testspngs/: a directory for additional test png files
2015-09-18 16:36:57 -05:00
John Bowler
f8d3e854cb Coverity related changes
These should fix most of the reported Coverity issues.  The remaining issues
should be the back_b etc assignments, which look like a Coverity bug, and
passing a pointer to a byte to a function that expects a pointer to one or more
bytes, which should (I believe) be fixed in one case and not the other
(next_filter) case; the latter case will probably go away as I am going to
rewrite that piece of code to avoid a spurious buffer allocation.

Signed-off-by: John Bowler <jbowler@acm.org>
2015-09-17 22:04:30 -05:00
Glenn Randers-Pehrson
d280c3a6da [libpng17] Updated CHANGES and ANNOUNCE 2015-09-17 07:34:38 -05:00
John Bowler
62dff2f97e Merge branch 'libpng17' of /home/jbowler/src/libpng/libpng into libpng17 2015-09-16 21:42:04 -07:00
John Bowler
fea86b1c29 Remove memcpy of png_transform_background
Replaced by a structure copy which is safer since it doesn't depend on knowing
the first member to be copied, also the copies are improved to copy the
transform args too; not required at present but it may prevent a bug being
introduced in the future.

Signed-off-by: John Bowler <jbowler@acm.org>
2015-09-16 21:33:43 -07:00
John Bowler
601ae5387e [libpng17] correct low-depth-gray code and enable tests
The low-bit-depth gray tests were disabled in prior versions of libpng because
of problems which should have been fixed by the recent changes to libpng17,
enabling the tests reveals bugs in those changes which are fixed by this commit.

Signed-off-by: John Bowler <jbowler@acm.org>
2015-09-16 21:09:10 -07:00
Glenn Randers-Pehrson
36ada4acae [libpng17] Add pngchunk.h to contrib/pngminim makefiles. 2015-09-16 11:09:25 -05:00
Glenn Randers-Pehrson
bfc7affa0d [libpng17] Imported from libpng-1.7.0beta65.tar 2015-09-16 10:19:29 -05:00
Glenn Randers-Pehrson
dba870122c [libpng17] Updated makefiles to handle pngchunk.h 2015-09-16 08:34:56 -05:00
Glenn Randers-Pehrson
35abfe72d6 [libpng17] Fix debug statement in pngread.c 2015-09-15 23:54:55 -05:00
Glenn Randers-Pehrson
497ff3400c [libpng17] moved scripts/chunkdesc.h to pngchunk.h 2015-09-15 23:53:49 -05:00
Glenn Randers-Pehrson
bb4e79c947 [libpng17] Updated configure.ac was omitted from previous commit 2015-09-15 19:53:08 -05:00
Glenn Randers-Pehrson
b00bb570f8 [libpng17] Fix file permission for contrib/tools/intgamma.sh 2015-09-15 18:35:26 -05:00
Glenn Randers-Pehrson
c68de14844 [libpng17] Merge contrib/libtests and contrib/tools with libpng16. 2015-09-15 17:11:43 -05:00
Glenn Randers-Pehrson
cc7fa5e23f [libpng17] Added public domain declaration to contrib/libtests/fakepng.c 2015-09-15 15:21:12 -05:00
John Bowler
ec99b373dd Merge 3184947a25b78dee14b0dda09f368ab3f6107c8f into 1fc5345bff82118fd6f3138138805083e66656ca 2015-09-15 03:52:31 +00:00
John Bowler
3184947a25 chunk handling and transform rewrite
This implements a new chunk parse implementation that can be shared, it
is currently shared by the progressive reader and the sequential one
(not, yet, the writer).

The patch also implements shared transform handling that is used
throughout.

Signed-off-by: John Bowler <jbowler@acm.org>
2015-09-14 20:42:40 -07:00
John Bowler
c5ead5d2cd Test changes
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>
2015-09-14 17:57:40 -07:00
John Bowler
76c5c11168 Test corrections: minor fixes to the test scripts
pngimage: add --list-combos
pngunknown: add --strict to catch warnings
pngvalid-standard: remove the spurious --progressive read (compare with
pngvalid-progressive-standard!)
This patch probably applies to 1.5 and 1.6 (where the tests exist) too.

Signed-off-by: John Bowler <jbowler@acm.org>
2015-09-14 17:51:06 -07:00
John Bowler
ddcca52933 ARM NEON code moved to contrib
This patch contains changes to the build (configure) system and the code
required to support the move.  The patch is provided to isolate the
changes from the others that follow it; the code won't necessarily
compile after this patch (the next changes are required.)

Signed-off-by: John Bowler <jbowler@acm.org>
2015-09-14 17:31:51 -07:00
John Bowler
3bd90db79f Rename arm -> contrib/neon
libpng will not compile if ARM NEON support is enabled with this commit;
the commit is provided to isolate the rename of the directory from the
rest of the required changes.

Signed-off-by: John Bowler <jbowler@acm.org>
2015-09-14 17:18:50 -07:00
Glenn Randers-Pehrson
1fc5345bff [libpng17] Mention dropping support for 16-bit platforms in libpng16.
Update some comments, fix example.c usage of png_set_sig_bytes().
2015-08-18 10:45:16 -05:00
Glenn Randers-Pehrson
81b1cff052 [libpng17] Fix links in man page 2015-08-11 15:35:17 -05:00
Glenn Randers-Pehrson
bc1d2b7d23 [libpng17] Fix links in man page 2015-08-11 13:04:50 -05:00
Glenn Randers-Pehrson
a16d1ef27a [libpng17] Update dead link in the man page 2015-08-11 12:16:36 -05:00
Glenn Randers-Pehrson
4b9fe200db [libpng17 Moved config.h.in~ from the "libpng_autotools_files" list to the
"libpng_autotools_extra" list in autogen.sh because it was causing a
false positive for missing files (bug report by Robert C. Seacord).
2015-08-02 21:52:21 -05:00
Glenn Randers-Pehrson
223aed9f90 [libpng17 Use nanosleep() instead of usleep() in contrib/gregbook/rpng2-x.c
because usleep() is deprecated (port from libpng16).
Fixed potential leak of png_pixels in contrib/pngminus/pnm2png.c
Fixed uninitialized variable in contrib/gregbook/rpng2-x.c
2015-07-30 11:41:47 -05:00
Glenn Randers-Pehrson
064ededa0f [libpng17] Bump version to 1.7.0beta65 2015-07-25 21:24:46 -05:00
Glenn Randers-Pehrson
92d7dd1ede [libpng17] Imported from libpng-1.7.0beta64.tar 2015-07-25 21:17:14 -05:00
Glenn Randers-Pehrson
1b3d312513 [libpng17] Belatedly added Mans Rullgard and James Yu to the list of
Contributing Authors.
2015-07-25 21:06:28 -05:00
Glenn Randers-Pehrson
47b6a93924 [libpng17] Rearranged png.h to put the major sections in the same order as
in libpng16.
2015-07-25 20:59:09 -05:00
Glenn Randers-Pehrson
e1ff1cc930 [libpng17] Revise comment about deprecated skip function in pngpread.c. 2015-06-11 21:55:19 -05:00
Glenn Randers-Pehrson
9acee8b4b2 [libpng17] Unlink temporary file immediately in pngstest (PNG_USE_MKSTEMP) 2015-06-11 16:30:44 -05:00
Glenn Randers-Pehrson
8ffa92dc25 [libpng17] Removed some unused WEIGHTED_FILTER macros from png.h and pngstruct.h 2015-06-10 07:02:36 -05:00
Glenn Randers-Pehrson
24382d838c [libpng17] Eliminated the final two Coverity defects (insecure temporary file
handling in contrib/libtests/pngstest.c; possible overflow of
unsigned char in contrib/tools/png-fix-itxt.c). To use the "secure"
file handling, define PNG_USE_MKSTEMP, otherwise "tmpfile()" will
be used.
2015-06-10 06:59:18 -05:00
John Bowler
9307eef199 [libpng17] Removed non-working progressive reader 'skip' function. This
function has apparently never been used. It was implemented
to support back-door modification of png_struct in libpng-1.4.x
but (because it does nothing and cannot do anything) was apparently
never tested (John Bowler).
2015-06-06 20:14:38 -05:00
Glenn Randers-Pehrson
3d1fec50e8 [libpng17] Bump version to 1.7.0beta64 2015-06-06 17:02:10 -05:00
Glenn Randers-Pehrson
0781bc4905 [libpng17] Imported from libpng-1.7.0beta63.tar 2015-06-06 16:30:46 -05:00
Glenn Randers-Pehrson
188962a93b [libpng17] Added #ifdef's to contrib/examples programs so people don't try
to compile them without the minimum required support enabled
(suggested by Flavio Medeiros).
2015-06-05 21:26:31 -05:00
John Bowler
e55c190818 [libpng17] Completed AArch64 support. Previous change to recognize __ARM_NEON
didn't touch all the required preprocessor lines. This change removes
support for __ARM_NEON__ completely and makes this consistent.
2015-06-04 21:55:35 -05:00
John Bowler
1a9eb510eb [libpng17] Moved READ_GAMMA to pngrtran.c. This makes everything in pngrtrans.c
depend on READ_TRANSFORMS and moves all the transform gamma (READ_GAMMA)
code from elsewhere to png_tran.c.  There are no code changes.
There is one remaining use of the gamma (16-bit) code in the simplified
API in pngread.c but that is because of a long-standing libpng bug,
namely that the gamma corrected palette is no produced by
png_read_update_info (John Bowler).
2015-06-04 21:49:54 -05:00
Glenn Randers-Pehrson
77476d3c37 [libpng16] Quieted Coverity issues in pngfix.c, png-fix-itxt.c, pngvalid.c,
pngstest.c, and pngimage.c. Most seem harmless, but png-fix-itxt
would only work with iTXt chunks with length 255 or less.

Fixed cexcept.h in which GCC 5 reported that one of the auto
variables in the Try macro needs to be volatile to prevent value
being lost over the setjmp, and fixed g++ build breaks (John Bowler).
2015-06-03 22:52:33 -05:00
Glenn Randers-Pehrson
a671f8baea [libpng17] Quieted Coverity issues in pngfix.c, png-fix-itxt.c, pngvalid.c,
pngstest.c, and pngimage.c. Most seem harmless, but png-fix-itxt
would only work with iTXt chunks with length 255 or less.
2015-06-03 16:21:57 -05:00
Glenn Randers-Pehrson
f32c657fc7 [libpng17] Bump version to 1.7.0beta63 2015-06-01 09:32:03 -05:00
Glenn Randers-Pehrson
381283fb5f [libpng17] Imported from libpng-1.7.0beta62.tar 2015-06-01 08:36:42 -05:00
Glenn Randers-Pehrson
3dd43ae670 [libpng17] Fix typo in CHANGES and ANNOUNCE. 2015-05-31 22:38:34 -05:00
Glenn Randers-Pehrson
13d83c6948 [libpng17] Removed WRITE_WEIGHTED_FILTERED code, to save a few kbytes of the
compiled library size. It never worked properly and as far as we can
tell, no one uses it. The png_set_filter_heuristics() and
png_set_filter_heuristics_fixed() APIs are retained but deprecated.
2015-05-31 16:22:44 -05:00
Glenn Randers-Pehrson
f19f7a6c95 [libpng17] Bump version to 1.7.0beta62 2015-05-30 23:08:34 -05:00
Glenn Randers-Pehrson
e0fea61cd8 [libpng17] Imported from libpng-1.7.0beta61.tar 2015-05-30 23:03:01 -05:00
Glenn Randers-Pehrson
689b9c58fe [libpng17] Avoid a harmless potential integer overflow in png_XYZ_from_xy(). 2015-05-20 13:18:54 -05:00
Glenn Randers-Pehrson
dc6cddd798 [libng17] Avoid Coverity issue 80858 (REVERSE NULL) in pngtest.c
PNG_DEBUG builds
2015-05-09 21:55:40 -05:00
Glenn Randers-Pehrson
5d2841d272 [libpng17] Document PNG_RELEASE_BUILD macro in the man page. 2015-05-06 20:36:12 -05:00
Glenn Randers-Pehrson
9012e3d108 [libpng17] Bump version to 1.7.0beta61 2015-05-06 16:17:19 -05:00
Glenn Randers-Pehrson
81d58f913e [libpng17] Imported from libpng-1.7.0beta60.tar 2015-05-06 15:59:29 -05:00
Glenn Randers-Pehrson
0ee7a07a85 [libpng17] merge pngpriv.h and pngset.c with libpng-1.6.18beta03. 2015-04-29 11:39:12 -05:00
Glenn Randers-Pehrson
6acc280403 [libpng17] Bump version to 1.7.0beta60 2015-04-19 06:32:37 -05:00
Glenn Randers-Pehrson
01358ecec2 [libpng17] Imported from libpng-1.7.0beta59.tar 2015-04-19 06:32:30 -05:00
Glenn Randers-Pehrson
7a35bcac1a [libpng17] Suppressed some warnings from the Borland C++ 5.5.1/5.82 compiler
(Bug report by Viktor Szaka'ts).
2015-04-04 08:45:34 -05:00
John Bowler
673ae608ab [libpng17] Transformed rewrite: changed row_info, added checks. This introduces an
internal struct (png_transform_control) to replace row_info and uses
    that to implement affirms correctly.  The change also adds checks on
    the rowbytes calculation and additional checks on most transform
    implementations.
Added png_uint_16 range checking, pngvalid tRNS, fixed png_uint_16:
    review of previous checks, removal of some where SAFE. pngvalid: add
    testing of tRNS for better code coverage pngvalid: correct rgb-to-gray
    error calculations. Code coverage is still incomplete: see /*UNTESTED*/
    in pngrtran.c
2015-03-30 21:32:41 -05:00
Glenn Randers-Pehrson
73ea393ab2 [libpng17] Bump version to 1.7.0beta59 2015-03-25 08:26:11 -05:00
Glenn Randers-Pehrson
dff4a834ce [libpng17] Imported from libpng-1.7.0beta58.tar 2015-03-25 08:26:02 -05:00
Glenn Randers-Pehrson
ad817b9b2b [libpng17] Revised comment about PNG_RELEASE_BUILD in pngpriv.h, to say
Use -DPNG_RELEASE_BUILD in CFLAGS or "#define PNG_RELEASE_BUILD 1" in
pngusr.h to turn on the release compile path.
2015-03-23 11:11:08 -05:00
Glenn Randers-Pehrson
218b2d7c70 [libpng17] Comment that PNG_RELEASE_BUILD has to be 0 or 1; illustrate
usage in contrib/pngminim/*/pngusr.h
2015-03-23 10:02:56 -05:00
Glenn Randers-Pehrson
67890a19f3 [libpng17] Committed pngvalid.c omitted from previous commit; fix trivial typos 2015-03-22 21:01:48 -05:00
John Bowler
53097f5bbb [libpng17] Check (png_uint_16) casts for overflow. Also removed png_muldiv_warn,
added RELEASE/!RELEASE convenience macros. png_muldiv_warn was used in
only one place, and the overflow condition is a genuine warning not
an internal error.  Four macros allow code or function parameters to be
condition on RELEASE (or not) builds and tidy up the #ifdef handling of
functions.
2015-03-22 20:26:13 -05:00
John Bowler
36562c1032 [libpng17] Improved some overflow handling. PNG_RELEASE_BUILD replaces tests
where the code depended on the build base type and can be defined on
the command line, allowing testing in beta builds.  Overflows previously
handled by png_warning in png.c have been changed to use new
macros/affirm functions so that beta builds will abort on overflow and
release builds will quietly ignore it.  This avoids release builds
producing warnings that are of no use to end users.
2015-03-22 16:05:56 -05:00
John Bowler
82fa6aed0e [libpng17] Added byte, short and other overflow checking
Added 'assert' based overflow checking for debug builds for char
and short assignments. Simply ignore the error in release builds
(a truncated value will be used without warning). Controlled by
PNG_RANGE_CHECK_SUPPORTED.
2015-03-22 15:57:53 -05:00
Glenn Randers-Pehrson
382de60042 [libpng17] Document affirm() and impossible() in the manual page. 2015-03-21 21:46:00 -05:00
Glenn Randers-Pehrson
06963c7841 [libpng16] Renamed "assert" to "affirm", not affected by NDEBUG. 2015-03-21 21:33:42 -05:00
Glenn Randers-Pehrson
9f2fb72c67 [libpng16] Made assert (and impossible) removeable by defining NDEBUG. 2015-03-21 16:04:23 -05:00
Glenn Randers-Pehrson
10ea5caef2 [libpng17] Remove pnglibconf.dfn and pnglibconf.pre with "make clean". 2015-03-21 15:57:21 -05:00
John Bowler
2460d9494d [libpng17] Implemented assert support and usage. 2015-03-20 16:39:56 -05:00
Glenn Randers-Pehrson
e8e7b6681e [libpng17] Restore missing ")" in pngerror.c 2015-03-18 14:34:47 -05:00
Glenn Randers-Pehrson
033dd3f20a [libpng17] Bump version to 1.7.0beta58 2015-03-17 08:13:42 -05:00
Glenn Randers-Pehrson
341e23c009 [libpng17] Imported from libpng-1.7.0beta57.tar 2015-03-17 08:00:27 -05:00
John Bowler
e4521a073c [libpng17] Revert change to png_default_read_data() made in libpng-1.7.0beta55. 2015-03-16 19:41:43 -05:00
Glenn Randers-Pehrson
5ff2d472e8 [libpng17] Also remove pnglibconf.c and pnglibconf.out 2015-03-15 16:55:42 -05:00
Cosmin Truta
f8eeac2b11 [libpng17] Remove pnglibconf.h, not pnglibconf.* in "make clean" (Cosmin). 2015-03-15 16:27:11 -05:00
Glenn Randers-Pehrson
e57ab4311b [libpng17] Bump version to 1.7.0beta57 2015-03-11 18:14:01 -05:00
Glenn Randers-Pehrson
9015c44736 [libpng17] Imported from libpng-1.7.0beta56.tar 2015-03-11 17:50:01 -05:00
Glenn Randers-Pehrson
1d7f037627 [libpng17] Updated CMakeLists.txt to add OSX framework, change YES/NO to ON/OFF
for consistency (Alexey Petruchik).
2015-03-11 11:37:59 -05:00
Glenn Randers-Pehrson
c4c28d7251 [libpng17] Bump version to 1.7.0beta56 2015-03-09 09:28:06 -05:00
Glenn Randers-Pehrson
0fba15c567 [libpng17] Imported from libpng-1.7.0beta55.tar 2015-03-09 09:16:18 -05:00
Glenn Randers-Pehrson
c062330846 [libpng16] Free the unknown_chunks structure even when it contains no data. 2015-03-09 09:05:39 -05:00
Glenn Randers-Pehrson
0448d90f01 [libpng17] Merged png_free_data() with libpng-1.6.17rc02. 2015-03-09 09:04:02 -05:00
Glenn Randers-Pehrson
127bede89c [libpng17] Reverted incorrect test on unknown chunk location. 2015-03-08 08:15:19 -05:00
Glenn Randers-Pehrson
3e4bd8c261 [libpng17] Spelling fixes ("then", "occured") reported by Lauri Nurmi. 2015-03-07 14:00:13 -06:00
Glenn Randers-Pehrson
cc085343ec [libpng17] Stopped a potential memory leak in png_set_unknown_chunks(). Breaks
tests/pngunknown-sAPI so it's temporarily marked SKIP.
2015-03-07 12:24:35 -06:00
Glenn Randers-Pehrson
ea0197a3e3 [libpng17] Removed some comments that the configure script did not handle
properly from scripts/pnglibconf.dfa and pnglibconf.h.prebuilt.
2015-03-05 21:20:32 -06:00
Glenn Randers-Pehrson
c2f0c9683f [libpng17] Work in progress, merging with libpng-1.6.17rc01. 2015-03-04 14:24:54 -06:00
Glenn Randers-Pehrson
79a332afd0 [libpng17] Bump version to 1.7.0beta55 2015-03-04 11:25:05 -06:00
Glenn Randers-Pehrson
352e2fe4c7 [libpng17] Imported from libpng-1.7.0beta54.tar 2015-03-04 11:19:43 -06:00
Glenn Randers-Pehrson
3077b5e049 [libpng17] Merged pngwrite.c with libpng-1.6.17beta06/pngwrite.c 2015-03-04 08:50:20 -06:00
Sergey Kosarevsky
98043c79a2 [libpng17] Avoid runtime checks when converting integer to png_byte with
Visual Studio (Sergey Kosarevsky)
2015-02-27 19:22:27 -06:00
Glenn Randers-Pehrson
2bf96d75ec [libpng17] Fixed some typos in the pngfix usage message. 2015-02-26 10:35:25 -06:00
Glenn Randers-Pehrson
678020ae18 [libpng17] Bump version to 1.7.0beta54 2015-02-25 15:42:29 -06:00
Glenn Randers-Pehrson
58e69e45ff [libpng17] Imported from libpng-1.7.0beta53.tar 2015-02-25 15:17:50 -06:00
Glenn Randers-Pehrson
7b51b8c13b [libng17] Put #ifdef/#endif around png_set_compression_level in pngwrite.c 2015-02-22 19:37:34 -06:00
Glenn Randers-Pehrson
5f7e71fa78 [libpng17] Restored compiling of png_reciprocal2 with PNG_NO_16BIT. 2015-02-22 16:42:54 -06:00
Glenn Randers-Pehrson
0cd3d25ae8 [libpng17] Bump version to 1.7.0beta53 2015-02-21 12:50:08 -06:00
Glenn Randers-Pehrson
83a2959908 [libpng17] Imported from libpng-1.7.0beta52.tar 2015-02-21 12:49:54 -06:00
Glenn Randers-Pehrson
ab2ef2ceb1 [libpng17] Minor editing of man page 2015-02-18 12:22:13 -06:00
Glenn Randers-Pehrson
f0341bae80 [libpng17] Corrected information recently added to the man page about row
pointer usage.
2015-02-17 21:29:22 -06:00
Glenn Randers-Pehrson
ed3543679a [libpng17] Added information about setjmp/simplified API interaction in the
manual page and INSTALL file. Added information about using
row_pointers with a single height*width*bpp allocated block
2015-02-17 20:15:21 -06:00
Glenn Randers-Pehrson
9c7aee825c [libpng17] Bump version to 1.7.0beta52 2015-02-17 10:52:59 -06:00
Glenn Randers-Pehrson
d8055d7123 [libpng17] Imported from libpng-1.7.0beta51.tar 2015-02-17 10:52:45 -06:00
Glenn Randers-Pehrson
92ef42d5e1 [libpng17] Display user limits in the output from pngtest. 2015-02-16 22:46:16 -06:00
Glenn Randers-Pehrson
1d3a1e36a7 [libpng17] Revised overflow detection in pngwutil.c 2015-02-16 22:43:52 -06:00
Glenn Randers-Pehrson
d368235da4 [libpng17] Bump version to 1.7.0beta51 2015-02-15 14:27:48 -06:00
Glenn Randers-Pehrson
06b0c83920 [libpng17] Imported from libpng-1.7.0beta50.tar 2015-02-15 13:20:53 -06:00
Glenn Randers-Pehrson
2130a3cd20 [libpng17] Combined several redundant lines of code in pngwutil.c 2015-02-15 13:18:50 -06:00
Glenn Randers-Pehrson
f1e4acb5b1 [libpng17] Combined sub_row, up_row, avg_row, and paeth_row buffers into a
single try_row buffer and in cases where two or more of those are
being tested, a second tst_row buffer.  This improves CPU speed
over that achieved by libpng-1.7.0beta49.
2015-02-15 12:44:16 -06:00
Glenn Randers-Pehrson
7e56f5858d [libpng17] Bump version to 1.7.0beta50 2015-02-11 07:25:31 -06:00
Glenn Randers-Pehrson
82fca45d27 [libpng17] Imported from libpng-1.7.0beta49.tar 2015-02-11 07:25:24 -06:00
Glenn Randers-Pehrson
f55ee011a2 [libpng17] Make some parameters "const" in new functions. 2015-02-11 06:18:30 -06:00
Glenn Randers-Pehrson
9c9009ec7d [libpng17] Deal with integer overflow of sum in pngwutil.c 2015-02-11 06:09:54 -06:00
Glenn Randers-Pehrson
01d91b4370 [libpng17] Consolidated redundant code in pngwutil.c 2015-02-10 22:49:31 -06:00
Glenn Randers-Pehrson
1fd10de101 [libpng17] Removed now-obsolete comments. 2015-02-10 19:55:20 -06:00
Glenn Randers-Pehrson
9149259041 [libpng17] Added PNG_WRITE_CUSTOMIZE_COMPRESSION_SUPPORTED macro, on by default. 2015-02-10 17:09:48 -06:00
Glenn Randers-Pehrson
8bc832389a [libpng17] Combined sub_row, up_row, avg_row, and paeth_row buffers into a
single try_row buffer.
2015-02-10 17:03:27 -06:00
Glenn Randers-Pehrson
ba22b208ed [libpng17] Bump version to 1.7.0beta49 2015-02-07 09:16:28 -06:00
Glenn Randers-Pehrson
0f6d60e672 [libpng17] Imported from libpng-1.7.0beta48.tar 2015-02-07 09:07:19 -06:00
Glenn Randers-Pehrson
6ce2d220b4 [lipng17] Do not build png_product2() when it is unused and work around
one more Coverity-scan dead-code warning.
2015-02-07 08:54:07 -06:00
Glenn Randers-Pehrson
d7312be749 [libpng17] Improved the comments on some #ifdef lines. 2015-02-03 19:11:50 -06:00
Glenn Randers-Pehrson
125eac0ee4 [libpng17] Bump version to 1.7.0beta48 2015-01-28 19:30:45 -06:00
Glenn Randers-Pehrson
ab95226db8 [libpng17] Imported from libpng-1.7.0beta47.tar 2015-01-28 19:25:43 -06:00
Glenn Randers-Pehrson
3043819fb2 [libpng17] Quieted some Coverity warnings 2015-01-27 15:54:37 -06:00
Glenn Randers-Pehrson
565e1bc1ae [libpng17] Added #ifndef __COVERITY__ where needed in png.c, pngrutil.c and
pngset.c to avoid warnings about dead code.
2015-01-27 07:00:59 -06:00
Glenn Randers-Pehrson
5bdcb914a4 [libpng17] Updated CHANGES and ANNOUNCE 2015-01-13 09:05:53 -06:00
Glenn Randers-Pehrson
e8213aa68f [libpng17] Add recent CVE numbers to CHANGES and ANNOUNCE. 2015-01-10 19:12:46 -06:00
Glenn Randers-Pehrson
d4ac328617 [libpng17] Quiet a GCC compiler warning about sample_max in pngset.c 2015-01-09 13:10:14 -06:00
Glenn Randers-Pehrson
56e6741b25 [libpng17] Made the check for out-of-range values in png_set_tRNS() work on
16-bit platforms.
2015-01-07 18:59:10 -06:00
Glenn Randers-Pehrson
3e04e189d8 [libpng17] Bump version to 1.7.0beta47 2015-01-02 09:23:24 -06:00
Glenn Randers-Pehrson
eb67f8bcb1 [libpng17] Imported from libpng-1.7.0beta46.tar 2015-01-02 09:18:28 -06:00
Glenn Randers-Pehrson
9c078fb7d2 [libpng17] Allow calling png_get_IHDR() with NULL arguments (Reuben Hawkins). 2015-01-02 08:23:24 -06:00
Glenn Randers-Pehrson
ae31a1ebdb [libpng17] Happy 2014, continued. 2014-12-31 19:08:04 -06:00
Glenn Randers-Pehrson
b1d49de5bc [libpng17] Happy New Year -- update copyright year. 2014-12-31 18:43:44 -06:00
John Bowler
d7e9c1c584 [libpng17] Fixed byte order in 2-byte filler, in png_do_read_filler(). 2014-12-29 16:06:32 -06:00
John Bowler
28451a8797 [libpng17] Implement previously untested libpng transforms in pngvalid.c 2014-12-29 14:18:50 -06:00
Glenn Randers-Pehrson
e6eb1d6fda [libpng17] Bump version to 1.7.0beta46 2014-12-28 13:30:20 -06:00
Glenn Randers-Pehrson
82dd5d3575 [libpng17] Imported from libpng-1.7.0beta45.tar 2014-12-28 13:30:06 -06:00
John Bowler
a5b6764cea [libpng17] Added testing of png_set_packing() to pngvalid.c 2014-12-27 19:11:41 -06:00
John Bowler
56850aba35 [libpng17] Removed user limits from pngfix. Also pass NULL pointers to
png_read_row to skip the unnecessary row de-interlace stuff.
2014-12-24 17:45:38 -06:00
Glenn Randers-Pehrson
13f025c29a [libpng17] Restored the old 1-million default limit on rows and columns 2014-12-24 08:28:30 -06:00
Glenn Randers-Pehrson
d92b0f23e6 [libpng17] Updated comments and manual with elimination of PNG_SAFE_LIMITS 2014-12-23 22:43:57 -06:00
Glenn Randers-Pehrson
eeab1cfefc [libpng17] Eliminated the PNG_SAFE_LIMITS macro and set default limits in
pnglibconf.dfa, that can be reset by the user at build time or run time.
This provides a more robust defense against DOS and as-yet undiscovered
overflows.
2014-12-23 22:13:40 -06:00
Glenn Randers-Pehrson
38d22ef928 [libpng17] Bump version to 1.7.0beta45 2014-12-23 14:15:30 -06:00
Glenn Randers-Pehrson
ab1ad88ecc [libpng17] Imported from libpng-1.7.0beta44.tar 2014-12-23 14:15:23 -06:00
Glenn Randers-Pehrson
caa59e0007 [libpng17] Removed extraneous PNG_SAFE_LIMITS_SUPPORTED handling from pngconf.h 2014-12-23 14:13:35 -06:00
John Bowler
310ffb25f8 [libpng17] Corrected the width limit calculation in png_check_IHDR(). 2014-12-21 19:33:02 -06:00
John Bowler
c026b07529 [libpng17] Restored a test on width that was removed from png.c at libpng-1.6.9
(Bug report by Alex Eubanks).
Fixed an overflow in png_combine_row with very wide interlaced images.
2014-12-21 18:42:37 -06:00
Glenn Randers-Pehrson
6988b31244 [libpng17] Bump version to 1.7.0beta44 2014-12-18 09:00:26 -06:00
Glenn Randers-Pehrson
b23a10f565 [libpng17] Imported from libpng-1.7.0beta43.tar 2014-12-18 09:00:17 -06:00
John Bowler
201e9144a6 [libpng17] Quiet a "comparison always true" warning in pngstest.c (John Bowler). 2014-12-16 19:16:18 -06:00
Glenn Randers-Pehrson
ba8495bba9 [libpng17] Revised Makefile.am and scripts/*.dfn to work with MinGW/MSYS;
renamed scripts/*.dfn to scripts/*.c (Bob Friesenhahn and John Bowler).
2014-12-14 22:14:48 -06:00
Glenn Randers-Pehrson
3393042627 [libpng17] Update arm/*.c to libpng coding style. 2014-11-29 17:10:55 -06:00
Glenn Randers-Pehrson
a072dfee8e [libpng17] Added ".align 2" to arm/filter_neon.S to support old GAS assemblers
that don't do alignment correctly.
2014-11-29 16:25:15 -06:00
Glenn Randers-Pehrson
e39e182357 [libpng17] Bump version to 1.7.0beta43 2014-11-21 08:25:41 -06:00
Glenn Randers-Pehrson
ab71e135e7 [libpng17] Imported from libpng-1.7.0beta42.tar 2014-11-20 10:23:06 -06:00
Glenn Randers-Pehrson
1b577e9bc6 [libpng17] Merged clang no-warning fix from libpng-1.6.13: png_digit was defined
but never used in pngerror.c.
2014-11-17 13:46:27 -06:00
Cosmin Truta
238fdc197d [libpng17] Added "-D_CRT_SECURE_NO_WARNINGS" to CFLAGS in
scripts/makefile.vcwin32.
Removed the obsolete $ARCH variable from scripts/makefile.darwin.
2014-11-16 19:59:24 -06:00
Cosmin Truta
8cfee5fa78 [libpng17] The macros passed in the command line to Borland make were ignored if
similarly-named macros were already defined in makefiles. This behavior
is different from POSIX make and other make programs.  Surround the
macro definitions with ifndef guards (Cosmin).
2014-11-14 09:56:33 -06:00
Glenn Randers-Pehrson
44a9af81b0 [libpng17] Bump version to 1.7.0beta42 2014-11-07 07:58:35 -06:00
Glenn Randers-Pehrson
755f92fc41 [libpng17] Imported from libpng-1.7.0beta41.tar 2014-11-07 07:58:23 -06:00
Glenn Randers-Pehrson
d9d1c997d8 [libpng17] More "#endif" housecleaning, in *.h 2014-11-07 07:39:41 -06:00
Glenn Randers-Pehrson
aeb4a22975 [libpng17] Changed "#endif /* PNG_FEATURE_SUPPORTED */" to "#endif /* FEATURE */" 2014-11-06 23:09:14 -06:00
Glenn Randers-Pehrson
9c0b5ab848 [libpng17] Removed #ifdef PNG_16BIT_SUPPORTED/#endif around png_product2(); it is
needed by png_reciprocal2().
Added #ifdef PNG_16BIT_SUPPORTED/#endif around png_log16bit() and
    png_do_swap().
2014-11-06 21:14:16 -06:00
Glenn Randers-Pehrson
05dcaffd38 [libpng17] Bump version to 1.7.0beta41 2014-11-05 19:07:47 -06:00
Glenn Randers-Pehrson
cca25b182f [libpng17] Imported from libpng-1.7.0beta40.tar 2014-11-05 19:07:37 -06:00
John Bowler
f87df31c8c [libpng17] Fixed GCC unsigned int->float warnings. Various versions of GCC
seem to generate warnings when an unsigned value is implicitly
    converted to double. This is probably a GCC bug but this change
    avoids the issue by explicitly converting to (int) where safe.
  Free all allocated memory in pngimage. The file buffer cache was left
    allocated at the end of the program, harmless but it causes memory
    leak reports from clang.
  Fixed array size calculations to avoid warnings. At various points
    in the code the number of elements in an array is calculated using
    sizeof.  This generates a compile time constant of type (size_t) which
    is then typically assigned to an (unsigned int) or (int). Some versions
    of GCC on 64-bit systems warn about the apparent narrowing, even though
    the same compiler does apparently generate the correct, in-range,
    numeric constant.  This adds appropriate, safe, casts to make the
    warnings go away.
2014-11-05 18:53:01 -06:00
Glenn Randers-Pehrson
41547820e8 [libpng17] Simplified and future-proofed png_user_version_check(). 2014-11-05 15:08:31 -06:00
Glenn Randers-Pehrson
e5d462d829 [libpng17] Made a one-line revision to configure.ac to support ARM on aarch64
(bug report by Marcin Juszkiewicz, fix by John Bowler).
2014-11-04 08:43:34 -06:00
Glenn Randers-Pehrson
6f46730cb7 [libpng17] Bump version to 1.7.0beta40 2014-11-01 18:58:59 -05:00
Glenn Randers-Pehrson
67b88b8ee0 [libpng17] Imported from libpng-1.7.0beta39.tar 2014-11-01 18:58:47 -05:00
Glenn Randers-Pehrson
7a4bfbdec1 [libpng17] Ported cosmetic changes from libpng-1.6.15beta02. 2014-11-01 13:57:38 -05:00
Glenn Randers-Pehrson
859254054a [libpng17] Merge pngtest.c with libpng-1.6.15beta01 2014-10-28 10:29:44 -05:00
Glenn Randers-Pehrson
515659d638 [libpng17] Changed "if (!x)" to "if (x == 0)" and "if (x)" to "if (x !== 0)" 2014-10-25 19:30:02 -05:00
Glenn Randers-Pehrson
fd409c8019 [libpng17] Revised INSTALL document. 2014-10-24 22:33:51 -05:00
Glenn Randers-Pehrson
9ee6678e1f [libpng17] Bump version to 1.7.0beta39 2014-10-17 10:02:01 -05:00
Glenn Randers-Pehrson
9b36280e31 [libpng17] Imported from libpng-1.7.0beta38.tar 2014-10-17 09:57:47 -05:00
Glenn Randers-Pehrson
eaad9f9177 [libpng17] Minor editing of README and comments in example.c and pngtest.c. 2014-10-17 09:55:43 -05:00
Glenn Randers-Pehrson
70cd1a10f2 [libpng17] Also don't mark text chunks as written in the end_ptr until written. 2014-10-05 18:04:25 -05:00
Glenn Randers-Pehrson
7974d60f54 [libpng17] Merge with libpng-1.6.14beta07
Removed "option READ_COMPRESSED_TEXT enables READ_TEXT" from pnglibconf.dfa,
  to make it possible to configure a libpng that supports iCCP but not TEXT.
Removed "option WRITE_COMPRESSED_TEXT enables WRITE_TEXT" from pnglibconf.dfa
Only mark text chunks as written after successfully writing them.
2014-10-05 16:25:17 -05:00
Glenn Randers-Pehrson
c7e743d385 [libpng17] Merge recent changes from libpng-1.6.14beta06:
Added "option READ_iCCP enables READ_COMPRESSED_TEXT" to pnglibconf.dfa
Removed unused "text_len" parameter from private function png_write_zTXt().
Conditionally compile some code in png_deflate_claim(), when
  PNG_WARNINGS_SUPPORTED and PNG_ERROR_TEXT_SUPPORTED are disabled.
Replaced repeated code in pngpread.c with PNG_PUSH_SAVE_BUFFER_IF_FULL.
Added "chunk iTXt enables TEXT" and "chunk zTXt enables TEXT"
  to pnglibconf.dfa.
Edit and fix typos in comments.
2014-10-04 12:41:26 -05:00
Glenn Randers-Pehrson
b2e89f1af6 [libpng17] Bump version to libpng-1.7.0beta38.tar 2014-09-28 13:36:54 -05:00
Glenn Randers-Pehrson
ad30a1262b [libpng17] Imported from libpng-1.7.0beta37.tar 2014-09-28 13:33:11 -05:00
Glenn Randers-Pehrson
35f88c1341 [libpng17] Merged scripts/* with libpng-1.6.14beta04. 2014-09-28 12:49:42 -05:00
Glenn Randers-Pehrson
4f8050416f [libpng17] Merge pngvalid.c and pngfix.c with libpng-1.6.14beta04 2014-09-28 10:37:26 -05:00
Glenn Randers-Pehrson
776d1768aa [libpng17] Merge pngvalid.c with libpng-1.6.14beta04. 2014-09-27 19:30:35 -05:00
Glenn Randers-Pehrson
d7078c52e2 [libpng17] Bump version to 1.7.0beta37 2014-09-27 19:00:32 -05:00
Glenn Randers-Pehrson
4a67ac3f1e [libpng17] Imported from libpng-1.7.0beta36.tar 2014-09-27 18:52:47 -05:00
Glenn Randers-Pehrson
2799bf9a4f [libpng17] Merge recent changes to the manual and pngrutil.c from libpng-1.6.14beta04. 2014-09-27 18:49:42 -05:00
Glenn Randers-Pehrson
34e49ae1bc [libpng17] Updated scripts/makefiles from libpng-1.6.13beta04. 2014-08-08 09:30:23 -05:00
Glenn Randers-Pehrson
cea01951da [libpng17] Bump version to 1.7.0beta36 2014-08-06 09:10:16 -05:00
Glenn Randers-Pehrson
1a9c06b11a [libpng17] Imported from libpng-1.7.0beta35.tar 2014-08-06 09:10:02 -05:00
Glenn Randers-Pehrson
f3b1eb68a6 [libpng17] Added some CVE numbers to the January 2013 CHANGES and ANNOUNCE files 2014-04-10 16:40:40 -05:00
Glenn Randers-Pehrson
12845bc947 [libpng17] Fixed a typo in pngrutil.c, introduced in libpng-1.5.6, that
interferes with "blocky" expansion of sub-8-bit interlaced PNG files
(Eric Huss).
2014-04-06 09:40:04 -05:00
Glenn Randers-Pehrson
3ac960f128 [libpng17] Fixed syntax of Copy command in makefile.amiga 2014-03-22 18:35:25 -05:00
Glenn Randers-Pehrson
eb2b0248e2 [libpng17] Complete the update of scripts/makefile.ne12bsd. 2014-03-22 13:47:31 -05:00
Cosmin Truta
e529698d38 [libpng17] Allow an easy replacement of the default pre-built configuration
header with a custom header, via the make PNGLIBCONF_H_PREBUILT macro.
2014-03-22 13:08:31 -05:00
Cosmin Truta
1a9e897289 [libpng17] Port recent changes from libpng16 branch:
Silence 'unused parameter' build warnings (Cosmin).
  $(CP) is now used alongside $(RM_F).  Also, use 'copy' instead
    of 'cp' where applicable, and applied other minor makefile changes.
  Don't warn about invalid dimensions exceeding user limits.
2014-03-22 11:09:18 -05:00
Glenn Randers-Pehrson
3a81956ffe [libpng17] Mention scripts/pnglibconf.h.prebuilt in INSTALL. 2014-03-21 12:47:04 -05:00
Glenn Randers-Pehrson
0acf4f9770 [libpng17] Bump version to 1.7.0beta35 2014-03-17 13:21:10 -05:00
Glenn Randers-Pehrson
b407af6503 [libpng17] Imported from libpng-1.7.0beta34.tar 2014-03-17 13:19:20 -05:00
Glenn Randers-Pehrson
0fb41f05df [libpng17] Moved configuration information from the manual to the INSTALL
file.
2014-03-16 21:45:07 -05:00
Glenn Randers-Pehrson
8ebdaa0700 [libpng17] Changed ZlibSrcDir from 1.2.5 to 1.2.8 in projects/vstudio. 2014-03-09 18:32:05 -05:00
Glenn Randers-Pehrson
4e61b58980 [libpng17] Use "if (value != 0)" instead of "if (value)" consistently. 2014-03-08 13:25:55 -06:00
Glenn Randers-Pehrson
88e7d62fbc [libpng17] Remove CALLOC_SUPPORTED from scripts/pnglibconf.dfa and prebuilt 2014-03-07 11:54:59 -06:00
Glenn Randers-Pehrson
43cd0a0bb5 [libpng17] Treat CRC error handling with png_set_crc_action(), instead of with
png_set_benign_errors(), which has been the case since libpng-1.6.0beta18.
2014-02-27 15:40:30 -06:00
Glenn Randers-Pehrson
1345c5bff8 [libpng17] Bump version to 1.7.0beta34 2014-02-27 09:07:25 -06:00
Glenn Randers-Pehrson
39c420834f [libpng17] Imported from libpng-1.7.0beta33.tar 2014-02-27 08:27:24 -06:00
Glenn Randers-Pehrson
f898f69f46 [libpng17] Fixed typos in the manual and in scripts/pnglibconf.dfa
(CFLAGS -> CPPFLAGS and PNG_USR_CONFIG -> PNG_USER_CONFIG).
2014-02-26 22:24:20 -06:00
Glenn Randers-Pehrson
352f43cdc6 [libpng17] Bump version to 1.7.0beta33 2014-02-26 13:24:57 -06:00
Glenn Randers-Pehrson
f99393490d [libpng17] Imported from libpng-1.7.0beta32.tar 2014-02-26 12:54:47 -06:00
Glenn Randers-Pehrson
deb920b4a7 [libpng17] Don't recognize known sRGB profiles as sRGB if they have been hacked,
but don't reject them and don't issue a copyright violation warning.
2014-02-26 11:52:00 -06:00
Glenn Randers-Pehrson
148cdac18f [libpng17] Moved some documentation from png.h to libpng.3 and libpng-manual.txt
Minor editing of contrib/arm-neon/README and contrib/examples/*.c
2014-02-26 11:50:02 -06:00
Glenn Randers-Pehrson
51ecc14a8a [libpng17] Document how to use different crc_action after reading the image
data in the sequential reader.
2014-02-23 13:36:31 -06:00
Glenn Randers-Pehrson
713a20c57d [libpng17] Added png_ptr->process_mode = PNG_READ_IDAT_MODE in
png_push_read_chunk after recognizing the IDAT chunk, which avoids an
infinite loop while reading a datastream whose first IDAT chunk is of
zero-length.
2014-02-23 10:09:57 -06:00
Glenn Randers-Pehrson
4526f546ba [libpng17] Use a user warning handler in contrib/gregbook/readpng2.c instead
of default, so warnings will be put on stderr even if libpng has CONSOLE_IO
disabled.
2014-02-23 10:08:50 -06:00
Glenn Randers-Pehrson
0c5acfa19e [libpng17] Check for __has_extension before using it in pngconf.h, to
support older Clang versions (Jeremy Sequoia).
2014-02-20 07:11:17 -06:00
Glenn Randers-Pehrson
848eeacb41 [libpng17] Check for info_ptr == NULL early in png_read_end() so we don't need
to run all the png_handle_*() and depend on them to return if info_ptr == NULL.
This improves the performance of png_read_end(png_ptr, NULL) and makes
it more robust against future programming errors.
2014-02-17 11:53:35 -06:00
John Bowler
2ced844b0e [libpng17] Deleted a now-redundant #define png_error from pngvalid.c 2014-02-16 22:51:23 -06:00
Glenn Randers-Pehrson
e2c5ed8d1d [libpng17] Removed "#define PNG_NO_WARNINGS" from contrib/pngminim/*/pngusr.h
because warnings are already turned off in the *.dfa files.
2014-02-16 15:48:58 -06:00
John Bowler
76004ce6ed [libpng17] Moved OS dependent code from arm/arm_init.c, to allow the included
implementation of the ARM NEON discovery function to be set at
build-time and provide sample implementations from the current code in the
contrib/arm-neon subdirectory. The __linux__ code has also been changed to
compile and link on Android by using /proc/cpuinfo, and the old linux code
is in contrib/arm-neon/linux-auxv.c.  The new code avoids POSIX and Linux
dependencies apart from opening /proc/cpuinfo and is C90 compliant.
2014-02-16 15:41:51 -06:00
Glenn Randers-Pehrson
258b986917 [libpng17] Moved redefines of png_error(), png_warning(), png_chunk_error(),
and png_chunk_warning() from pngpriv.h to png.h to make them visible
to libpng-calling applications.
2014-02-16 08:36:28 -06:00
Glenn Randers-Pehrson
50a09830b8 [libpng17] Bump version to 1.7.0beta32 2014-02-05 23:32:25 -06:00
Glenn Randers-Pehrson
9a3f244085 [libpng17] Imported from libpng-1.7.0beta31.tar 2014-02-05 22:46:04 -06:00
John Bowler
fb1305faeb [libpng17] Support builds with unsupported PNG_TRANSFORM_* values. All of the
PNG_TRANSFORM_* values are always defined in png.h and, because they
are used for both read and write in some cases, it is not reliable
to #if out ones that are totally unsupported. This change adds error
detection in png_read_image() and png_write_image() to do a
png_app_error() if the app requests something that cannot be done
and it adds corresponding code to pngimage.c to handle such options
by not attempting to test them.
2014-02-05 20:13:19 -06:00
Glenn Randers-Pehrson
3d7f3bbab7 [libpng17] Deleted the other instance of "c = b;" which is the one that
triggered a scan-build warning in pngrutil.c.
2014-02-05 16:54:37 -06:00
Glenn Randers-Pehrson
2d032e966d [libpng17' Restored a line, "c = b;", that was inadvertently deleted from the
PAETH filtering code from libpng-1.7.0beta24/pngrutil.c and reenabled
the pngimage tests.
2014-02-05 15:19:13 -06:00
Glenn Randers-Pehrson
8dd3784f7c [libpng17] Disabled pngimage tests temporarily. 2014-02-05 13:22:13 -06:00
Glenn Randers-Pehrson
98b9371115 [libpng17] Fixed some typos in commentary of pngimage.c 2014-02-05 13:21:41 -06:00
John Bowler
d29413a2a9 [libpng17] Do not read invalid sBIT chunks. Previously libpng only checked sBIT
values on write, so a malicious PNG writer could therefore cause
the read code to return an invalid sBIT chunk, which might lead to
application errors or crashes.  Such chunks are now skipped (with
chunk_benign_error).
2014-02-05 12:15:42 -06:00
John Bowler
dc63b03da1 [libpng17] Completed full working pngimage test program and added two test
scripts.  Fixed combination of ~alpha with shift. On read invert alpha,
processing occurred after shift processing, which causes the final values to be
outside the range that should be produced by the shift. Reversing the
order on read makes the two transforms work together correctly and mirrors
the order used on write.
2014-02-05 11:39:59 -06:00
John Bowler
cf354c2c82 [libpng17] Make png_read_png() and png_write_png() prototypes in png.h depend
upon PNG_READ_SUPPORTED and PNG_WRITE_SUPPORTED.
Removed dependence on !PNG_READ_EXPAND_SUPPORTED for calling
png_set_packing() in png_read_png().
2014-02-05 10:55:35 -06:00
Glenn Randers-Pehrson
484dad1a19 [libpng17] Bump version to 1.7.0beta31 2014-02-02 15:27:04 -06:00
Glenn Randers-Pehrson
1695471118 [libpng17] Imported from libpng-1.7.0beta30.tar 2014-02-02 15:26:55 -06:00
Glenn Randers-Pehrson
ae14dcd404 [libpng17] Updated documentation about sCAL_s support. 2014-02-01 11:14:06 -06:00
Glenn Randers-Pehrson
302c58b8cf [libpng17] Added pngimage test program for png_read_png and png_write_png.
This is a work-in-progress; no tests are run automatically at present and
the program by virtue of exhaustively testing all the transforms is
very slow.
2014-01-31 22:00:27 -06:00
Glenn Randers-Pehrson
39fee3cee1 [libpng17] Fixed a large number of instances where PNGCBAPI was omitted from
function definitions.
2014-01-31 21:55:27 -06:00
Glenn Randers-Pehrson
b7362c6738 [libpng17] Bump version to 1.7.0beta30 2014-01-30 14:52:37 -06:00
Glenn Randers-Pehrson
f2d8561fdc [libpng17] Imported from libpng-1.7.0beta29.tar 2014-01-30 14:52:28 -06:00
Glenn Randers-Pehrson
1bd81ffa21 [libpng17] Quiet an uninitialized memory warning from VS2013 in png_get_png(). 2014-01-30 14:44:07 -06:00
Glenn Randers-Pehrson
6d2b1a7dbc [libpng17] Bump version to 1.7.0beta29 2014-01-20 13:57:46 -06:00
Glenn Randers-Pehrson
5daa97c2eb [libpng17] Imported from libpng-1.7.0beta28.tar 2014-01-20 13:57:38 -06:00
Glenn Randers-Pehrson
9e441e96b9 [libpng17] Checked in clang attribute support. 2014-01-18 19:55:44 -06:00
Glenn Randers-Pehrson
a0d314ce84 [libpng17] Correct a comment in pngconf.h 2014-01-13 21:40:47 -06:00
Glenn Randers-Pehrson
b871b25997 [libpng17] Added clang attribute support (Cosmin). 2014-01-13 21:13:16 -06:00
Glenn Randers-Pehrson
d38ebc9ded [libpng17] Updated scripts/makefile.* to use CPPFLAGS (Cosmin) 2014-01-12 12:28:20 -06:00
Glenn Randers-Pehrson
995402ca6e [libpng17] Fix typo in CHANGES and ANNOUNCE 2014-01-10 12:58:47 -06:00
Glenn Randers-Pehrson
1982968dad [libpng17] Bump version to 1.7.0beta28 2014-01-10 08:11:36 -06:00
Glenn Randers-Pehrson
32cd66d619 [libpng17] Imported from libpng-1.7.0beta27.tar 2014-01-10 08:11:26 -06:00
Glenn Randers-Pehrson
03a53fa429 [libpng17] Removed potentially misleading warning from png_check_IHDR(). 2014-01-10 06:22:41 -06:00
Glenn Randers-Pehrson
441de8f4fd [libpng17] Revised png_check_IHDR() to use PNG_SIZE_MAX instead of
PNG_UINT_32_MAX in the test for potential overflow in PNG_ROWBYTES.
2014-01-09 20:19:36 -06:00
Glenn Randers-Pehrson
4e5c80034e [libpng17] Only issue a warning about image width if an error has not already
been found in IHDR.
2014-01-08 11:44:48 -06:00
Glenn Randers-Pehrson
879d63156a [libpng17] Updated warning in png_check_IHDR() to say "may be too large"
instead of "is too large".
2014-01-07 11:44:41 -06:00
Glenn Randers-Pehrson
eb021245d0 [libpng17] Bump version to 1.7.0beta27 2014-01-01 11:19:28 -06:00
Glenn Randers-Pehrson
6607a3b905 [libpng17] Imported from libpng-1.7.0beta26.tar 2014-01-01 11:19:08 -06:00
Glenn Randers-Pehrson
28711dff2a [libpng17] Updated copyright year in recently-changed files. 2013-12-31 21:15:11 -06:00
John Bowler
4413d5dcd2 [libpng17] Allow unversioned links created on install to be disabled in
configure.  In configure builds 'make install' changes/adds links like png.h
and libpng.a to point to the newly installed, versioned, files (e.g.
libpng17/png.h and libpng17.a). Three new configure options and some
rearrangement of Makefile.am allow creation of these links to be disabled.
2013-12-29 19:40:13 -06:00
John Bowler
206d1eed42 [libpng17] Changed pngvalid.c to support libpng 1.5, which does not support
the PNG_MAXIMUM_INFLATE_WINDOW option, so #define it out when
appropriate in pngvalid.c
2013-12-29 15:57:30 -06:00
John Bowler
114fa16ab3 [libpng17] Fixed test programs for interlace options. Made pngvalid.c and
pngtest.c work correctly when READ_INTERLACING and/or WRITE_INTERLACING
are switched off.
2013-12-29 10:33:58 -06:00
Glenn Randers-Pehrson
eb2af04bd3 [libpng16] Merged pngrio.c, pngtrans.c, and pngwio.c with libpng-1.6.9 2013-12-28 13:11:47 -06:00
Glenn Randers-Pehrson
200fc68f52 [libpng17] Removed #error macro from contrib/tools/pngfix.c (Thomas Klausner). 2013-12-27 20:18:50 -06:00
John Bowler
4cfd01a288 [libpng17] Added dSIG to chunk list in png.h 2013-12-27 11:50:52 -06:00
John Bowler
e98229ceb0 [libpng17] Merged with 1.5 and 1.6 changes to create a single pngvalid.c 2013-12-27 08:04:49 -06:00
John Bowler
ad1a4c8cc3 [libpng17] Added libpng 1.5 checks to pngvalid.c 2013-12-27 07:53:50 -06:00
Glenn Randers-Pehrson
8df7c46e5b [libpng17] Removed configure-generated "compile" file. 2013-12-26 14:44:48 -06:00
Glenn Randers-Pehrson
99078ec8bd [libpng17] Bump version to 1.7.0beta26 2013-12-26 11:53:16 -06:00
Glenn Randers-Pehrson
a2c5f56e77 [libpng17] Imported from libpng-1.7.0beta25.tar 2013-12-26 11:53:02 -06:00
Glenn Randers-Pehrson
9e168ea2c9 [libpng17] Merged files with version 1.6.8 that have not changed since then. 2013-12-19 20:33:08 -06:00
Glenn Randers-Pehrson
06be739941 [libpng17] Bump version to 1.7.0beta25 2013-12-15 11:22:59 -06:00
Glenn Randers-Pehrson
448092b8eb [libpng17] Imported from libpng-1.7.0beta24.tar 2013-12-15 11:22:49 -06:00
Glenn Randers-Pehrson
1faa6ff32c [libpng17] Handle zero-length PLTE chunk or NULL palette with png_error()
instead of png_chunk_report(), which by default issues a warning
rather than an error, leading to later reading from a NULL pointer
(png_ptr->palette) in png_do_expand_palette().
2013-12-15 08:47:52 -06:00
John Bowler
3adf438f39 [libpng17] Made transform implementation functions static. This makes the
internal functions called by png_do_{read|write}_transformations static.
On an x86-64 DLL build (Gentoo Linux) this reduces the size of the text
segment of the DLL by 1208 bytes, about 0.6%. It also simplifies
maintenance by removing the declarations from pngpriv.h and allowing
easier changes to the internal interfaces.
2013-12-13 23:55:41 -06:00
John Bowler
d45a632529 [libpng17] Bookkeeping: Moved functions around (no changes). Moved transform
function definitions before the place where they are called so that
they can be masde static. Move the intrapixel functions and the
grayscale palette builder out of the png?tran.c files. The latter
isn't a transform function and is no longer used internally, and the
former MNG specific functions are better placed in pngread/pngwrite.c
2013-12-13 23:50:30 -06:00
John Bowler
5a1b8d106d [libpng17] Tidied up pngfix inits and fixed pngtest no-write builds. 2013-12-01 15:50:03 -06:00
Glenn Randers-Pehrson
05f896004f [libpng17] Changed tabs to 3 spaces in png_debug macros and changed '"%s"m'
to '"%s" m' to improve portability among compilers.
Changed png_free_default() to free() in pngtest.c
2013-11-28 16:14:03 -06:00
Glenn Randers-Pehrson
a4f1de9109 [libpng17] Avoid a scan-build warning in pngtest.c 2013-11-25 13:13:32 -06:00
Glenn Randers-Pehrson
7ebb353944 [libpng17] Removed or marked PNG_UNUSED some harmless "dead assignments"
reported by clang scan-build.
2013-11-25 11:08:56 -06:00
Glenn Randers-Pehrson
b1f0c7d0e5 [libpng17] Revised manual about handling of zlib CMF 2013-11-24 13:31:26 -06:00
Glenn Randers-Pehrson
55df049962 [libpng17] Updated CHANGES and ANNOUNCE 2013-11-23 19:26:57 -06:00
Glenn Randers-Pehrson
219ba1370e [libpng17] Bump version to 1.7.0beta24 2013-11-23 19:02:56 -06:00
Glenn Randers-Pehrson
4dc4471bb5 [libpng17] Imported from libpng-1.7.0beta23.tar 2013-11-23 19:01:01 -06:00
Glenn Randers-Pehrson
a199a15b28 [libpng17] Added another "assert()" to pngfix.c 2013-11-23 12:58:32 -06:00
Glenn Randers-Pehrson
e9446f2f95 [libpng17] Added an "assert()" to pngfix.c to quiet a clang scanner warning. 2013-11-23 12:14:02 -06:00
John Bowler
f70f2fcf48 [libpng17] Finished merging with libpng16 (pngrutil.c and pnglibconf.dfa) 2013-11-23 08:20:39 -06:00
John Bowler
158c947ce2 [libpng17] Revert recent change to pngvalid.c. 2013-11-22 18:34:37 -06:00
John Bowler
7e2707e2af [libpng17] Ported recent changes from libpng16 to libpng17
Fixed 'minimal' builds. Various obviously useful minimal configurations
  don't build because of missing contrib/libtests test programs and overly
  complex dependencies in scripts/pnglibconf.dfa. This change adds
  contrib/conftest/*.dfa files that can be used in automatic build
  scripts to ensure that these configurations continue to build.
Enabled WRITE_INVERT and WRITE_PACK in contrib/pngminim/encoder.
2013-11-22 18:01:30 -06:00
Glenn Randers-Pehrson
81824079b5 [libpng17] Added "-Wall" to CFLAGS in contrib/pngminim/*/makefile 2013-11-18 17:03:24 -06:00
Glenn Randers-Pehrson
e8e1add0a8 [libpng17] Moved prototype for png_handle_unknown() in pngpriv.h outside of
the #ifdef PNG_SET_UNKNOWN_CHUNKS_SUPPORTED/#endif block.
2013-11-18 15:35:55 -06:00
Glenn Randers-Pehrson
a549223f91 [libpng17] Added #ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED/#endif in pngpread.c 2013-11-17 11:09:57 -06:00
Glenn Randers-Pehrson
ebe7945b96 [libpng17] Bump version to 1.7.0beta23 2013-11-07 08:33:41 -06:00
Glenn Randers-Pehrson
e3e35aa980 [libpng17] Imported from libpng-1.7.0beta22.tar 2013-11-07 08:33:31 -06:00
John Bowler
9f2fbcf5d8 [libpng17] Fixed #include in filter_neon_intrinsics.c and ctype macros. The
ctype char checking macros take an unsigned char argument, not a signed char.
2013-11-04 13:50:20 -06:00
Glenn Randers-Pehrson
264ba68afe [libpng17] Restored a line to the libpng-1.7.0beta21 entry in ANNOUNCE 2013-11-03 20:56:03 -06:00
Glenn Randers-Pehrson
3ef99c9316 [libpng17] Bump version to 1.7.0beta22 2013-11-02 15:39:27 -05:00
John Bowler
4b29f97f9b [libpng17] Port recent libpng-1.6.7beta03, beta04 changes to 1.7.0beta21
(mainly ARMv8 support)
2013-11-02 15:29:45 -05:00
Glenn Randers-Pehrson
fe6e6cf130 [libpng17] Fixed some typos in autogen.s that don't affect its behavior 2013-10-13 17:12:44 -05:00
Glenn Randers-Pehrson
547df4b9ca [libpng17] Bump version to 1.7.0beta21 2013-10-13 14:10:23 -05:00
Glenn Randers-Pehrson
a0d4a0b971 [libpng17] Imported from libpng-1.7.0beta20.tar 2013-10-13 14:02:50 -05:00
John Bowler
72c2577302 [libpng17] Make autogen.sh work with automake 1.13 as well as 1.14. Do this
by always removing the 1.14 'compile' script but never checking for it.
2013-10-06 09:02:09 -05:00
John Bowler
091fab713c [libpng17] Simplified error message code in pngunknown. The simplification has
the useful side effect of avoiding a bogus warning generated by the latest
version of the Intel C compiler (it objects to
condition ? string-literal : string-literal).
2013-10-06 08:51:42 -05:00
John Bowler
32aeb2cd4e [libpng17] Cleaned up (char*) casts of zlib messages. The latest version
of the Intel C compiler complains about casting a string literal as (char*),
so copied the treatment of z_const from the library code into pngfix.c
2013-10-06 08:47:43 -05:00
John Bowler
c1bcdc3a86 [libpng17] Made changes for compatibility with automake 1.14:
1) Added the 'compile' program to the list of programs that must be cleaned
       in autogen.sh
    2) Added 'subdir-objects' which causes .c files in sub-directories to be
       compiled such that the corresponding .o files are also in the
       sub-directory.  This is because automake 1.14 warns that the
       current behavior of compiling to the top level directory may be removed
       in the future.
    3) Updated dependencies on pnglibconf.h to match the new .o locations and
       added all the files in contrib/libtests and contrib/tools that depend
       on pnglibconf.h
    4) Added 'BUILD_SOURCES = pnglibconf.h'; this is the automake recommended
       way of handling the dependencies of sources that are machine generated;
       unfortunately it only works if the user does 'make all' or 'make check',
       so the dependencies (3) are still required.
2013-10-06 08:18:31 -05:00
Glenn Randers-Pehrson
553b8f85d3 [libpng17] Bump version to 1.7.0beta20 2013-10-02 13:47:20 -05:00
Glenn Randers-Pehrson
30666a6097 [libpng17] Imported from libpng-1.7.0beta19.tar 2013-09-30 17:17:59 -05:00
John Bowler
0bfa63cd0d [libpng17] Checked in missing update to pnglibconf.dfa 2013-09-30 15:58:53 -05:00
John Bowler
b37a7c6674 [libpng17] Updated pngunknown.c 2013-09-30 13:11:44 -05:00
John Bowler
7657ac14f2 [libpng17] Catch up with recent libpng16 changes; unknown handling and spelling
corrections
2013-09-30 11:18:13 -05:00
John Bowler
d9f60caf72 [libpng17] Fixed default behavior of ARM_NEON_API. If the ARM NEON API option is
compiled without the CHECK option it defaulted to on, not off.
2013-09-30 08:07:18 -05:00
Glenn Randers-Pehrson
88c20ada06 [libpng17] Reverted the change to unknown handling #defines; the change
breaks 'NOREAD' builds.
2013-09-20 14:30:16 -05:00
Glenn Randers-Pehrson
f3bfc4a142 [libpng17] Bump version to 1.7.0beta19 2013-09-16 11:47:36 -05:00
Glenn Randers-Pehrson
3fdef04d55 [libpng17] Imported from libpng-1.7.0beta18.tar 2013-09-16 11:47:26 -05:00
Glenn Randers-Pehrson
eae431e514 [libpng17] Bump version to 1.7.0beta18 2013-08-21 19:13:27 -05:00
Glenn Randers-Pehrson
003590c361 [libpng17] Imported from libpng-1.7.0beta17.tar 2013-08-21 19:13:18 -05:00
Glenn Randers-Pehrson
8e23262b2b [libpng17] Update comment in png_init_filter_functions() 2013-08-21 17:53:15 -05:00
Glenn Randers-Pehrson
157e0649e0 [libpng17] Delay calling png_init_filter_functions() until a row with nonzero
filter is found.
2013-08-20 21:28:19 -05:00
Glenn Randers-Pehrson
83f1287c02 [libpng17] Mention png_set_option() in the manual. 2013-08-17 15:56:01 -05:00
Glenn Randers-Pehrson
a1124a574a [libpng17] Use minus signs, not hyphens, in "--i" in libpng.3 2013-08-13 18:59:21 -05:00
Glenn Randers-Pehrson
6f27254a7e [libpng17] Change some hyphens to minus signs and fix other typos in libpng.3 2013-08-06 17:25:37 -05:00
Glenn Randers-Pehrson
79fc8fa0d9 [libpng17] Exit loop over tRNS array once a transparent pixel is found
(performance report by PoChun Chang).
2013-08-04 14:05:39 -05:00
Glenn Randers-Pehrson
394bc6cdee [libpng17] Port recent /*SAFE*/ comments and manual changes from libpng16 2013-07-15 10:28:48 -05:00
Glenn Randers-Pehrson
bb06552075 [libpng17] Bump version to 1.7.0beta17 2013-07-04 22:42:35 -05:00
Glenn Randers-Pehrson
a14071d814 [libpng17] Imported from libpng-1.7.0beta16.tar 2013-07-04 22:31:06 -05:00
John Bowler
23f3e46518 [libpng17] Ported pngfix.c patches from libpng16. 2013-07-03 07:50:24 -05:00
John Bowler
f97b2a6cde [libpng17] Ported ARM no-read patch from libpng16. 2013-07-03 07:46:02 -05:00
John Bowler
23f4320775 [libpng17] Added perfect hash code generation for lists of PNG chunks. This is
a work in progress; checked in for use in pngfix.c
2013-07-03 07:41:04 -05:00
Glenn Randers-Pehrson
fb411867b0 [libpng17] Updated documentation to show default behavior of benign errors
correctly.
2013-07-02 09:54:05 -05:00
Glenn Randers-Pehrson
5aa2ca454d [libpng17] Revised pngfix.c to use PNG_U32() instead of PNG_CHUNK() 2013-07-02 09:52:09 -05:00
Glenn Randers-Pehrson
7905286ffa [libpng17] Renamed contrib/tools/png-fix-too-far-back.c to pngfix.c and revised
it to check all compressed chunks known to libpng.
2013-07-01 15:11:36 -05:00
Glenn Randers-Pehrson
2edcb6ad0f [libpng17] Revised example.c to illustrate use of PNG_DEFAULT_sRGB and
PNG_GAMMA_MAC_18 as parameters for png_set_gamma().
2013-06-25 19:43:16 -05:00
Glenn Randers-Pehrson
0f1599e6e5 [libpng17] Fix spelling of "doclifter" in CHANGES and ANNOUNCE 2013-06-18 15:10:32 -05:00
Glenn Randers-Pehrson
cbf22f30b4 [libpng17] Bump version to 1.7.0beta16 2013-06-18 13:22:10 -05:00
Glenn Randers-Pehrson
9bf3c70730 [libpng17] Imported from libpng-1.7.0beta15.tar 2013-06-18 13:14:34 -05:00
Glenn Randers-Pehrson
1bc5747713 [libpng17] Bump version to 1.7.0beta15 2013-06-08 21:00:45 -05:00
Glenn Randers-Pehrson
4a7796faca [libpng17] Imported from libpng-1.7.0beta14.tar 2013-06-08 21:00:36 -05:00
John Bowler
34081a0e2f [libpng17] Port recent changes to ARM support from libpng-1.6.3beta07. 2013-06-08 14:20:46 -05:00
John Bowler
b88c94208a [libpng17] Make ARM NEON support work at compile time (not just configure time).
This moves the test on __ARM_NEON__ into pngconf.h to avoid issues when
using a compiler that compiles for multiple architectures at one time.
2013-06-06 14:57:14 -05:00
Glenn Randers-Pehrson
30662f5e92 [libpng17] Enclose the prototypes for the simplified write API in 2013-06-05 23:25:14 -05:00
Glenn Randers-Pehrson
46ad4c5bd4 [libpng17] Deleted contrib/tools/fixitxt.c, which has been renamed. 2013-06-05 17:03:38 -05:00
Glenn Randers-Pehrson
5c32606ec0 [libpng17] Update README to delete CompuServ and add simplesystems.org 2013-06-05 17:01:14 -05:00
John Bowler
a08ac031fc [libpng17] Fixed ICC compiler warning in tools/png-fix-itxt.c 2013-06-05 16:48:18 -05:00
John Bowler
c233ec8743 [libpng17] Deleted set(CMAKE_BUILD_TYPE) block from CMakeLists.txt 2013-06-05 11:45:55 -05:00
Glenn Randers-Pehrson
d594be641a [libpng17] Added set(CMAKE_CONFIGURATION_TYPES ...) to CMakeLists.txt
(Andrew Hundt)
2013-06-05 11:05:34 -05:00
Glenn Randers-Pehrson
4c9168875b [libpng17] Removed a redundant test in png_set_IHDR(). 2013-06-04 15:09:06 -05:00
Glenn Randers-Pehrson
3c051ee282 [libpng17] Update README with current info about arm, contrib, and projects
directories
2013-06-03 21:02:46 -05:00
Glenn Randers-Pehrson
e1ded944f0 [libpng17] Bump version to 1.7.0beta14 2013-05-12 19:25:30 -05:00
Glenn Randers-Pehrson
c09dddc0cd [libpng17] Imported from libpng-1.7.0beta13.tar 2013-05-12 19:25:16 -05:00
Glenn Randers-Pehrson
bd56d76417 [libpng17] Port recent zlib windowBits handling from libpng-1.6.3beta06 2013-05-10 17:43:59 -05:00
Glenn Randers-Pehrson
0cc23ac171 [libpng17] Updated contrib/pngminus/pnm2png.c (Paul Stewart):
Fixed whitespace handling
Added a call to png_set_packing()
Initialize dimension values so if sscanf fails at least we have known
      invalid values.
2013-05-09 23:30:46 -05:00
Glenn Randers-Pehrson
cb10e19725 [libpng17] Added a needed #ifdef/#endif pair. 2013-05-09 23:18:10 -05:00
Glenn Randers-Pehrson
9dba7219a0 [libpng17] Revised contrib/pngminim/*/makefile to generate pnglibconf.h with the
right zlib header files.
2013-05-09 22:59:08 -05:00
Glenn Randers-Pehrson
17c6af8c40 [libpng17] Check for EOF in contrib/pngminus/pnm2png.c (Paul Stewart).
Ignore "#" delimited comments in input file to pnm2png.c.
2013-05-07 14:38:19 -05:00
Glenn Randers-Pehrson
6a02eb6d2c [libpng17] Bump version to 1.7.0beta13 2013-04-29 21:32:33 -05:00
Glenn Randers-Pehrson
40d41fe6f8 [libpng17] Imported from libpng-1.7.0beta12.tar 2013-04-29 21:32:12 -05:00
Glenn Randers-Pehrson
7073d26e51 [libpng17] Avoid dereferencing NULL pointer possibly returned from
png_create_write_struct() (Andrew Church).
2013-04-29 08:58:15 -05:00
Glenn Randers-Pehrson
cf76fe8654 [libpng17] Expanded manual paragraph about writing private chunks. 2013-04-28 21:04:12 -05:00
Glenn Randers-Pehrson
b780b64fbf [libpng17] Bump version to 1.7.0beta12 2013-04-26 08:46:11 -05:00
Glenn Randers-Pehrson
b1876ab6e2 [libpng17] Imported from libpng-1.7.0beta11.tar 2013-04-26 08:46:00 -05:00
John Bowler
28a95d125f [libpng17] Test for 'arm*' not just 'arm' in the host_cpu configure variable. 2013-04-25 22:51:21 -05:00
Glenn Randers-Pehrson
993f68c006 [libpng17] Bump version to 1.7.0beta11 2013-04-24 08:34:00 -05:00
Glenn Randers-Pehrson
8d23524359 [libpng17] Imported from libpng-1.7.0beta10.tar 2013-04-24 08:33:48 -05:00
John Bowler
e0f4aaa668 [libpng17] Attempt to fix the arm-neon configuration mess. 2013-04-24 00:07:59 -05:00
Glenn Randers-Pehrson
3de174cd2f [libpng17] Imported from libpng-1.7.0beta10.tar 2013-04-23 23:52:30 -05:00
Glenn Randers-Pehrson
eaf2f1dcbe [libpng17] Imported from libpng-1.7.0beta09.tar 2013-04-23 20:43:09 -05:00
John Bowler
ea0b4c602e [libpng17] Port recent changes from libpng-1.6.2. 2013-04-23 20:40:42 -05:00
John Bowler
371c3d4dfd [libpng17] Install missing patch to contrib/libtests/pngunknown.c 2013-04-19 21:56:00 -05:00
John Bowler
0bcf5fb451 [libpng17] Exposed PNG chunk types in png.h, modified png_uint_32 macros/code
to make as few assumptions as possible
2013-04-19 07:06:02 -05:00
Glenn Randers-Pehrson
57d6907d89 [libpng17] Bump version to 1.7.0beta09 2013-04-18 07:40:10 -05:00
Glenn Randers-Pehrson
6cf97e37af [libpng17] Bump version to 1.7.0beta08 2013-04-18 07:39:57 -05:00
Glenn Randers-Pehrson
8ef61c4693 [libpng17] Added contrib/tools/fixitxt.c, to repair the erroneous iTXt
chunk length written by libpng-1.6.0 and 1.6.1.
2013-04-16 23:09:35 -05:00
Glenn Randers-Pehrson
25a116f97d [libpng17] Imported from libpng-1.7.0beta08.tar 2013-04-13 21:27:16 -05:00
Glenn Randers-Pehrson
d6d41c847a [libpng17] Imported from libpng-1.7.0beta07.tar 2013-04-13 20:54:54 -05:00
Glenn Randers-Pehrson
9e0297546f [libpng17] Removed extra line left over from recent patch to pngwutil.c 2013-04-13 20:07:29 -05:00
John Bowler
d529363d13 [libpng17] Revised last patch to work on 64-bit platforms. 2013-04-13 16:42:37 -05:00
Glenn Randers-Pehrson
55e93d7090 [libpng17] Fixed length written to uncompressed iTXt chunks (Samuli Suominen). 2013-04-13 16:23:48 -05:00
John Bowler
23674b75be [libpng17] Added "{ }" that were omitted from previous patch to pngtrans.c 2013-04-13 12:28:30 -05:00
Glenn Randers-Pehrson
0ddf350360 [libpng17] Corrected a misplaced closing bracket in contrib/libtests/pngvalid.c
(Flavio Medeiros).
2013-04-13 11:42:52 -05:00
John Bowler
066f9862f0 [libpng17] Corrected the test on user transform changes on read. It was in the
png_set of the transform function, but that doesn't matter unless the
transform function changes the rowbuf size, and that is only valid if
transform_info is called.
2013-04-12 22:10:38 -05:00
Glenn Randers-Pehrson
ae1a5c811c [libpng17] Updated the URL of the GIT repository in the manual. 2013-04-11 19:00:10 -05:00
John Bowler
5a1ce92c0c [libpng16] Fixed incorrect warning of excess deflate data. End condition - the
warning would be produced if the end of the deflate stream wasn't read
in the last row.  The warning is harmless.
2013-04-07 21:37:52 -05:00
Glenn Randers-Pehrson
7a498039c5 [libpng17]Updated documentation of 1.5.x to 1.6.x changes in iCCP chunk
handling.
2013-03-31 23:03:32 -05:00
Glenn Randers-Pehrson
40a93652aa [libpng17] Bump version to 1.7.0beta07 2013-03-13 09:52:06 -05:00
Glenn Randers-Pehrson
a1362f38de [libpng17] Imported from libpng-1.7.0beta06.tar 2013-03-13 09:51:58 -05:00
John Bowler
30bc0333fe [libpng17] Eliminated two warnings from the Intel C compiler. 2013-03-13 09:50:48 -05:00
Claudio Bley
55794013d4 [libpng16] Fixed CMakelists.txt to allow building a single variant of the
library (Claudio Bley):
  Introduced a PNG_LIB_TARGETS variable that lists all activated library
    targets.  It is an error if this variable ends up empty, ie. you have
    to build at least one library variant.
  Made the *_COPY targets only depend on library targets actually being build.
  Use PNG_LIB_TARGETS to unify a code path.
  Changed the CREATE_SYMLINK macro to expect the full path to a file as the
    first argument. When symlinking the filename component of that path is
    determined and used as the link target.
  Use copy_if_different in the CREATE_SYMLINK macro.
2013-03-07 11:23:12 -06:00
John Bowler
2e92b4dfa0 [libpng16] Corrected simplified API default gamma for color-mapped output, added
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.
2013-03-06 22:23:40 -06:00
Glenn Randers-Pehrson
f46106fa04 [libpng17] Bump version to 1.7.0beta06 2013-03-04 18:23:04 -06:00
Glenn Randers-Pehrson
0dcd32f39c [libpng17] Imported from libpng-1.7.0beta05.tar 2013-03-04 18:22:54 -06:00
John Bowler
808ea281a4 [libpng17] Corrected Android builds and corrected libpng.vers with symbol
prefixing. This adds an API to set optimization options externally,
providing an alternative and general solution for the non-portable
run-time tests used by the ARM Neon code.  It also makes those tests
compile and link on Android.  The order of settings vs options in
pnglibconf.h is reversed to allow settings to depend on options and
options can now set (or override) the defaults for settings.
2013-03-03 21:29:36 -06:00
John Bowler
ec89aefb44 [libpng17] Changed user chunk callback API to respect global and per chunk
defaults.  Previously a return of 0 from a user chunk callback would result in
the chunk being saved (if this was safe, even if the chunk was unsafe-to-copy);
this change respects the defaults set by the application, so unknown chunks
can be discarded by default and known-safe ones preserved.
2013-03-02 21:39:44 -06:00
Glenn Randers-Pehrson
6152dbd424 [libpng17] Fixed bug introduced in libpng-1.6.0beta28 that causes libpng to
handle chunks even when they have been tagged PNG_HANDLE_CHUNK_NEVER.
Also fixed two typos (SUPPOPRTED should be SUPPORTED) in pngrutil.c
2013-03-01 20:08:33 -06:00
Glenn Randers-Pehrson
fe18c0d9ea [libpng17] Avoid a possible memory leak in contrib/gregbook/readpng.c 2013-03-01 13:28:20 -06:00
Glenn Randers-Pehrson
1b0358302d [libpng17] Bump version to 1.7.0beta05 2013-02-27 14:53:47 -06:00
Glenn Randers-Pehrson
d20f9d5030 [libpng17] Imported from libpng-1.7.0beta04.tar 2013-02-27 14:40:40 -06:00
John Bowler
fc447311aa [libpng17] Revised scripts/dfn.awk to work with the buggy MSYS awk that
has trouble with CRLF line endings.
2013-02-27 13:30:52 -06:00
Glenn Randers-Pehrson
8e30e43587 [libpng17] Add info about order of png_set_* calls to the manual. 2013-02-26 08:34:45 -06:00
Glenn Randers-Pehrson
0403ccf1de [libpng16] Revised INSTALL to recommend using CPPFLAGS instead of INCLUDES.
Revised scripts/makefile.freebsd to respect ZLIBDIR and ZLIBINC.
2013-02-22 20:32:03 -06:00
Glenn Randers-Pehrson
1a321cc088 [libpng17] Bump version to 1.7.0beta04 2013-02-22 17:29:54 -06:00
Glenn Randers-Pehrson
c9f99f487b [libpng17] Imported from libpng-1.7.0beta03.tar 2013-02-22 17:29:03 -06:00
Glenn Randers-Pehrson
8360e60abc [libpng17] Update scripts/pnglibconf.h.prebuilt 2013-02-19 10:07:56 -06:00
John Bowler
2799f74489 [libpng17] Fixed ALIGNED_MEMORY support and
Allow run-time ARM NEON checking to be disabled. A new configure option:
--enable-arm-neon=always will stop the run-time checks. New checks
within arm/arm_init.c will cause the code not to be compiled unless
__ARM_NEON__ is set. This should make it fail safe (if someone asks
for it on then the build will fail if it can't be done.)
2013-02-19 09:52:30 -06:00
John Bowler
7363babe4f [libpng17] Reenabled code to allow zero length PLTE chunks for MNG. 2013-02-18 21:36:25 -06:00
Glenn Randers-Pehrson
e3a526f789 [libpng17] Eliminated references to "png_sizeof()" in the documentation. 2013-02-18 15:25:08 -06:00
Glenn Randers-Pehrson
8f0935b8dc [libpng17] Bump version to 1.7.0beta03 2013-02-18 13:02:33 -06:00
Glenn Randers-Pehrson
ae6503fe0e [libpng17] Imported from libpng-1.7.0beta02.tar 2013-02-18 13:02:25 -06:00
Glenn Randers-Pehrson
851a6265a8 [libpng17] Use parentheses consistently with #if defined()
and wrapped some long lines.
2013-02-17 15:25:29 -06:00
Glenn Randers-Pehrson
ffa24d4108 [libpng17] Fixed double-underscore typo in an #ifdef in png.c 2013-02-16 16:38:24 -06:00
John Bowler
206f4d2678 [libpng17] Use approved/supported Android method to check for NEON, use
Linux/POSIX 1003.1 API to check /proc/self/auxv avoiding buffer allocation
and other library calls (ported from libpng15).
2013-02-16 07:53:19 -06:00
John Bowler
bb040784c2 [libpng17] Fixed a race condition in the creation of the build 'scripts'
directory while building with a parallel make.
2013-02-16 07:52:15 -06:00
Glenn Randers-Pehrson
70e1af50ed [libpng17] Bump version to 1.7.0beta02 2013-02-15 11:00:16 -06:00
Glenn Randers-Pehrson
eb4a645eda [libpng17] Imported from libpng-1.7.0beta01.tar 2013-02-15 11:00:07 -06:00
John Bowler
9f7f03a3c4 [libpng17] Accept "," as separator in options.awk 2013-02-10 18:04:16 -06:00
John Bowler
395ddbd318 [libpng17] Fix typos of PNG_GET_PALLETE_MAX_SUPPORTED
in png.h and pnglibconf.dfa
2013-02-10 17:24:46 -06:00
Glenn Randers-Pehrson
9f0d36c85f [libpng17] Fix typo, indentation of #ifdef PNG_GET_PALETTE_MAX_SUPPORTED
in png.h and pnglibconf.dfa
2013-02-10 16:57:38 -06:00
Glenn Randers-Pehrson
e9760e5e95 [libpng17] Enclosed the new png_get_palette_max API
in #ifdef PNG_GET_PALETTE_MAX_SUPPORTED
block, and revised pnglibconf.h and pnglibconf.h.prebuilt accordingly.
2013-02-10 15:59:15 -06:00
John Bowler
b96b2b7e90 [libpng17] Fixed missing dependency in --prefix builds. The intermediate
internal 'prefix.h' file can only be generated correctly after pnglibconf.h,
however the dependency was not in Makefile.am.  The symptoms are
unpredictable depending on the order make chooses to build pngprefix.h and
pnglibconf.h, often the error goes unnoticed because there is a system
pnglibconf.h to use instead.
2013-02-09 07:53:57 -06:00
John Bowler
9bb705e0a8 [libpng17] Fixed make distcheck to skip over the test result files. They were
being included because the whole of the 'tests' directory is included,
fixed to just include the actual test files and tests/pngstest.  Also
reverted the previous erroneous change to remove the ${srcdir} from the
front of contrib, scripts, projects and added an explanation of what is
going on to Makefile.am
2013-02-08 11:16:06 -06:00
Glenn Randers-Pehrson
e860f77393 [libpng17] Updated manual page about png_get_palette_max() API. 2013-02-08 09:24:35 -06:00
Glenn Randers-Pehrson
b5a7565908 [libpng17] Removed some obsolete test scripts. 2013-02-08 08:00:11 -06:00
John Bowler
e88e221d91 [libpng17] Make tests/pngstest* work with the original Bourne shell 2013-02-07 21:59:36 -06:00
Glenn Randers-Pehrson
b10867cdc2 [libpng17] Enable parallel tests and rearrange TESTS order to take advantage of
the massive speed improvements use a make capable of parallel builds
on a multi-CPU machine and pass the right arguments to make (-j10000
for GNU make) to get the build to run in parallel.
2013-02-07 08:26:34 -06:00
Glenn Randers-Pehrson
bf7084b80d [libpng17] Bump version to 1.7.0alpha11 2013-02-06 22:23:37 -06:00
Glenn Randers-Pehrson
6afcee826f [libpng17] Imported from libpng-1.7.0alpha10.tar 2013-02-06 19:51:21 -06:00
John Bowler
f15a5006c8 [libpng17] Removed cc -E workround, corrected png_get_palette_max API. Tested
on SUN OS cc 5.9, which demonstrates the tokenization problem previously
avoided by using /lib/cpp.  Since all .dfn output is now protected
in double quotes unless it is to be macro substituted the fix should work
everywhere.
2013-02-06 17:52:30 -06:00
John Bowler
cdbd5174bd [libpng17] Minor fixes to assembler changes, verified with a dummy .S file 2013-02-06 17:40:52 -06:00
John Bowler
7a9b6203ef [libpng16] Removed new test-driver from autogen.sh 2013-02-06 17:16:49 -06:00
John Bowler
803493e19c [libpng17] Ported libpng 1.5 options.awk/dfn file handling to 1.7, fixed one
bug.
2013-02-05 10:16:42 -06:00
Mans Rullgard
4245e6b1b2 [libpng17] Fixed ARM support (Mans Rullgard).
Also removed stray out-of-order #endif and #ifdef
2013-02-05 09:55:36 -06:00
John Bowler
81892f6b90 [libpng17] Fix typos in png_get_palette_max name and prototype 2013-02-05 08:10:01 -06:00
John Bowler
862993827d [libpng17] Changed png_size_t to size_t throughout headers, make sRGB check
numbers consistent.
2013-02-04 20:04:10 -06:00
Glenn Randers-Pehrson
d304125332 [libpng17] Added png_get_palette_max() function. 2013-02-04 19:55:53 -06:00
John Bowler
9124f3e29a [libpng17] Make symbol prefixing work with the ARM neon optimizations. Also
allow pngpriv.h to be included for preprocessor definitions only, so
it can be used in non-C/C++ files.
2013-02-04 18:00:34 -06:00
Glenn Randers-Pehrson
2969375aa6 [libpng17] Restored a "return" statement accidentally deleted from pngset.c 2013-01-22 07:03:51 -06:00
Glenn Randers-Pehrson
5e8ba1cbbf [libpng17] Set counter to prevent additional attempts to cache a chunk
after running out of memory or reaching a potential overflow condition.
2013-01-21 16:37:54 -06:00
Glenn Randers-Pehrson
8aee43d10a [libpng17] Bump version to 1.7.0alpha10 2013-01-21 09:21:36 -06:00
Glenn Randers-Pehrson
e355657bbe [libpng17] Imported from libpng-1.7.0alpha09.tar 2013-01-21 09:21:21 -06:00
John Bowler
fb6ba9acf4 [libpng17] Pulled changes to multi-chunk handling from libpng-1.6.0beta40. 2013-01-21 09:11:17 -06:00
Glenn Randers-Pehrson
815173a0b5 [libpng17] Bump version to 1.7.0alpha09 2013-01-17 13:50:32 -06:00
Glenn Randers-Pehrson
7f489a77bb [libpng17] Imported from libpng-1.7.0alpha08.tar 2013-01-17 13:50:23 -06:00
John Bowler
8ec8e8fcd5 [libpng17] Corrected previous attempt at overflow detection in
png_set_unknown_chunks().
2013-01-17 13:42:42 -06:00
Glenn Randers-Pehrson
a4e606dd5f [libpng17] Bump version to 1.7.0alpha08 2013-01-10 12:05:08 -06:00
Glenn Randers-Pehrson
646de7962b [libpng17] Imported from libpng-1.7.0alpha07.tar 2013-01-10 12:04:54 -06:00
John Bowler
4accd423c2 [libpng17]Fixed conceivable but difficult to repro overflow. Also added
two test programs to generate and test a PNG which should have the problem.
2013-01-10 11:01:00 -06:00
Glenn Randers-Pehrson
f62caaf4dc [libpng17] Fixed typo in copyright year and version in pngmem.c 2013-01-01 10:55:18 -06:00
Glenn Randers-Pehrson
b789bb84bb [libpng17] Bump version to 1.7.0alpha07 2013-01-01 09:02:35 -06:00
Glenn Randers-Pehrson
ce60ad642b [libpng17] Imported from libpng-1.7.0alpha06.tar 2013-01-01 09:02:25 -06:00
Glenn Randers-Pehrson
ab097b1168 [libpng17] Updated copyright year to 2013 in changed files. 2013-01-01 08:54:06 -06:00
John Bowler
3a737d86c7 [libpng17] Fixed 'make distcheck' on SUN OS - libpng.so was not being removed 2012-12-27 09:46:33 -06:00
Glenn Randers-Pehrson
a1337e57a8 [libpng17] Bump version to 1.7.0alpha06 2012-12-23 21:00:36 -06:00
Glenn Randers-Pehrson
247b3fcf49 [libpng17] Imported from libpng-1.7.0alpha05.tar 2012-12-23 21:00:22 -06:00
Glenn Randers-Pehrson
f01273b25c [libpng17] Bump version to 1.7.0alpha05 2012-12-22 18:23:22 -06:00
Glenn Randers-Pehrson
8cb1a2ac6d [libpng17] Imported from libpng-1.7.0alpha04.tar 2012-12-22 18:13:34 -06:00
Glenn Randers-Pehrson
e6e5ac8cb7 [libpng17] Added missing dependency on pnglibconf.h in scripts/makefile.linux 2012-12-22 17:53:18 -06:00
Glenn Randers-Pehrson
a4798fb83e [libpng17] Reformatted latest CHANGES/ANNOUNCE entry to 80 character lines. 2012-12-22 17:13:02 -06:00
John Bowler
46369f35c5 [libpng17] Fixed Windows build issues, enabled ARM compilation. Various warnings issued
by earlier versions of GCC fixed for Cygwin and Min/GW (which both use old GCCs.)
ARM support is enabled by default in zlib.props (unsupported by Microsoft) and
ARM compilation is made possible by deleting the check for x86. The test programs
cannot be run because they are not signed.
2012-12-20 22:58:13 -06:00
John Bowler
e699993d70 [libpng17] Made default Zlib compression settings be configurable. This adds #defines to
pnglibconf.h to control the defaults.
2012-12-20 22:21:02 -06:00
Glenn Randers-Pehrson
5a0afcfa63 [libpng17] Added scripts/makefile.msys contributed by Christipher M. Wheeler 2012-12-19 23:06:12 -06:00
Glenn Randers-Pehrson
3fc9cbf126 [libpng17] Bump version to 1.7.0alpha04 2012-12-19 16:06:17 -06:00
Glenn Randers-Pehrson
36b628b19e [libpng17] Imported from libpng-1.7.0alpha03.tar 2012-12-19 15:53:18 -06:00
Glenn Randers-Pehrson
2c31365fd4 [libpng16] Announce that git repository location at SourceForge has changed. 2012-12-18 21:45:58 -06:00
Glenn Randers-Pehrson
e1e3c1a2a2 [libpng17] Fixed typo in contrib/pngminim/encoder/README 2012-12-18 14:58:44 -06:00
John Bowler
b940e5dc5d [libpng17] Disassembled the version number in scripts/options.awk (necessary
for building on SunOs)
2012-12-17 23:36:08 -06:00
John Bowler
fbbbc620b8 [libpng16] Fixed previous support for Z_PREFIX in configure builds, corrected
sCAL APIs; some of these use floating point arithmetic so they need to be
disabled if floating point arithmetic is switched off.  This is a quiet API
change - previously it appeared that the APIs were supported if fixed point
arithmetic was used internally, however they required certain APIs (floor,
modf, frexp, atof) that are part of C floating point support. Changed
png_fixed and the gamma code specific version of the same to avoid floor(),
which may be a library function (not an intrinsic). Removed unused #if 0
code.
2012-12-17 21:07:30 -06:00
Glenn Randers-Pehrson
9b99600c4d [libpng17] Fixed several more whitespace errors in libpng.3 2012-12-17 20:00:44 -06:00
Glenn Randers-Pehrson
3129d7426e [libpng16] Cleaned up whitespace in the synopsis portion of the manpage. 2012-12-17 19:21:14 -06:00
Glenn Randers-Pehrson
325ceea971 [libpng17] Bump version to 1.7.0alpha03 2012-12-17 12:25:13 -06:00
Glenn Randers-Pehrson
ac39fc3024 [libpng17] Bump version to 1.7.0alpha03 2012-12-17 12:16:32 -06:00
Glenn Randers-Pehrson
99343407e6 [libpng17] Add #ifdef PNG_WRITE_FILTERED_ROW around a use of prev_row. 2012-12-17 12:12:49 -06:00
Glenn Randers-Pehrson
3e23f45ba9 [libpng17] Document new PNG_ABORT behavior in libpng-1.7.x 2012-12-17 11:53:34 -06:00
John Bowler
72389dec42 [libpng17] Cleaned up and enhanced the configure option; libpng now correctly
links and tests against zlib with a prefix; tests have been clarified; and
irrelevant or obsolete things (as defined by the autotools man page) have
been removed.
2012-12-17 09:20:02 -06:00
Glenn Randers-Pehrson
1f0853f47e [libpng17] Bump version to 1.7.0alpha03 2012-12-16 19:43:18 -06:00
Glenn Randers-Pehrson
32a60a4885 [libpng17] Imported from libpng-1.7.0alpha02.tar 2012-12-16 19:43:10 -06:00
Glenn Randers-Pehrson
5e07dc6970 [libpng17] Updated documentation about functions deprecated in 1.6.0 2012-12-16 16:47:07 -06:00
John Bowler
4b90a8d416 [libpng17] Build fixes (trailing ;, missing/misplaced PNG_REMOVED) in png.h 2012-12-16 15:56:18 -06:00
John Bowler
d59c19b64c [libpng17] Removed more functions that were deprecated in libpng-1.6.0:
png_malloc_default png_free_default.
  Updated some left over "1.6.0beta32" in code sources.
  Fixed a "png_structp" prototype (should be png_structrp) in arm_init.c
  Updated the version-number hack in pngvalid.c
2012-12-15 21:41:31 -06:00
Glenn Randers-Pehrson
bbabd977d1 [libpng17] Fixed some typos in comments; updated manual. 2012-12-15 17:12:48 -06:00
John Bowler
0cf9c7d63d [libpng17] Removed some duplicated code from png.c and contrib/tools/scale.c
and changed some png_warning() calls to png_app_error() calls in pngwutil.c
2012-12-15 16:04:28 -06:00
Glenn Randers-Pehrson
b4e241559e [libpng17] Removed no-longer-exported functions from scripts/symbols.def 2012-12-15 16:02:24 -06:00
Glenn Randers-Pehrson
1e15aee6be [libpng17] Removed functions that were deprecated in libpng-1.6.0:
png_reset_zstream(), png_info_init_3(), and png_data_freer() and its
associated flags.
2012-12-15 15:40:56 -06:00
Glenn Randers-Pehrson
d59e60d0fb [libpng17] Bump version to 1.7.0alpha02 2012-12-15 12:33:51 -06:00
Glenn Randers-Pehrson
ec1d13a1d4 [libpng17] Imported from libpng-1.7.0alpha01.tar 2012-12-15 12:33:44 -06:00
Glenn Randers-Pehrson
d9002f94cb [libpng17] Rebuilt Makefile.in, configure, etc., with autoconf-2.69
and automake-1.12.5 in the tar distributions.
2012-12-15 10:12:36 -06:00
John Bowler
1fa858db48 [libpng17] Fixed cases of unquoted DESTDIR in Makefile.am. 2012-12-15 09:48:10 -06:00
John Bowler
0f2a5bac64 [libpng17] Rearranged ARM-NEON optimizations to isolate the machine specific
code to the hardware subdirectory, and add comments to pngrutil.c so that
implementors of other optimizations will know what to do.
2012-12-14 23:12:16 -06:00
John Bowler
eac85878bf [libpng17] Clean up USER_LIMITS feature, removing members from png_struct
when not required.
2012-12-14 22:56:00 -06:00
John Bowler
240ac287eb [libpng17]Rearranged png_struct, remove unused members, change png_set_filter
handling png_struct members rearranged - partly to reorder to avoid packing,
partly to put frequently accessed members at the start and partly to make
the grouping more clear. png_set_filter code has been rewritten and the
code shared with png_write_start_row moved to a common function.  Comments
in png.h have been made more clear. Minor fixes to
contrib/libtests/timepng.c and some of the png_*_tRNS logic, including
more error detection in png_set_tRNS.
2012-12-14 22:31:50 -06:00
John Bowler
3e42c81193 [libpng17] Made 8-bit compose and rgb_to_grayscale accuracy improvements.
These changes cause 16-bit arithmetic to be used for 8-bit data in the gamma
    corrected compose and grayscale operations.  The arithmetic errors have
    three sources all of which are fixed in this commit:
    1) 8-bit linear calculations produce massive errors for lower intensity
       values.
    2) The old 16-bit "16 to 8" gamma table code erroneously wrote the lowest
       output value into a table entry which corresponded to multiple output
       values (so where the value written should have been the closest to the
       transformed input value.)
    3) In a number of cases the code to access the 16-bit table did not round;
       it did a simple shift, which was wrong and made the side effects of (2)
       even worse.
  The new gamma code does not have the 16-to-8 problem at the cost of slighly
    more calculations and the algorithm used to minimize the number of
    calculations has been extended to all the 16-bit tables; it has advantages
    for any significant gamma correction.
2012-12-14 22:17:54 -06:00
Glenn Randers-Pehrson
ac3b4d9b69 [libpng17] Bump version to 1.7.0alpha01 2012-12-10 16:21:25 -06:00
348 changed files with 53517 additions and 24720 deletions

99
.travis.yml Normal file
View File

@ -0,0 +1,99 @@
language: c
sudo: false
cache:
directories:
- $HOME/.cache/pip
- $HOME/deps
matrix:
include:
- os: linux
compiler: gcc
env: BUILD_TYPE=normal
- os: linux
compiler: clang
env: BUILD_TYPE=normal
- os: linux
compiler: gcc
env: BUILD_TYPE=coverage
- os: linux
compiler: clang
env: BUILD_TYPE=ubsan
- os: linux
compiler: clang
env: BUILD_TYPE=asan
- os: linux
compiler: clang
env: BUILD_TYPE=lsan
- os: linux
compiler: clang
env: BUILD_TYPE=msan
- os: osx
compiler: gcc
env: BUILD_TYPE=normal
- os: osx
compiler: clang
env: BUILD_TYPE=normal
install:
- pip install --user 'requests[security]'
- pip install --user cpp-coveralls
- |
mkdir -p deps
pushd deps
export PREFIXDIR=`pwd`
if [ ! -f "libtool-2.4.6.tar.xz" ]; then
wget http://ftpmirror.gnu.org/libtool/libtool-2.4.6.tar.xz
fi
if [ ! -f "automake-1.15.tar.xz" ]; then
wget http://ftp.gnu.org/gnu/automake/automake-1.15.tar.xz
fi
if [ ! -d "libtool-2.4.6" ]; then
tar xf libtool-2.4.6.tar.xz
pushd libtool-2.4.6/
./configure --prefix=$PREFIXDIR
make && make install
popd
cp $PREFIXDIR/bin/libtool $PREFIXDIR/bin/glibtool
cp $PREFIXDIR/bin/libtoolize $PREFIXDIR/bin/glibtoolize
fi
if [ ! -d "automake-1.15" ]; then
tar xf automake-1.15.tar.xz
pushd automake-1.15/
./configure --prefix=$PREFIXDIR
make && make install
popd
fi
export PATH="$PREFIXDIR/bin:$PATH"
popd
before_script:
- |
if [ "$BUILD_TYPE" = "coverage" ]; then
export CFLAGS="-fprofile-arcs -ftest-coverage"
export LDFLAGS="-fprofile-arcs -ftest-coverage"
fi
- |
if [ "$BUILD_TYPE" = "asan" ]; then
export CFLAGS=-fsanitize=address
export LDFLAGS=-fsanitize=address
fi
- |
if [ "$BUILD_TYPE" = "lsan" ]; then
export CFLAGS=-fsanitize=leak
export LDFLAGS=-fsanitize=leak
fi
- |
if [ "$BUILD_TYPE" = "msan" ]; then
export CFLAGS=-fsanitize=memory
export LDFLAGS=-fsanitize=memory
fi
- |
if [ "$BUILD_TYPE" = "ubsan" ]; then
export CFLAGS="-fsanitize=undefined -fno-sanitize-recover"
export LDFLAGS="-fsanitize=undefined"
fi
script:
- ./autogen.sh && ./configure && make && make check
- |
if [ "$BUILD_TYPE" = "coverage" ]; then
cpp-coveralls --gcov-options '\-lp'
fi

1894
ANNOUNCE

File diff suppressed because it is too large Load Diff

1497
CHANGES

File diff suppressed because it is too large Load Diff

View File

@ -1,40 +1,41 @@
# CMakeLists.txt
# Copyright (C) 2007-2011 Glenn Randers-Pehrson
# Copyright (C) 2007,2009-2016 Glenn Randers-Pehrson
# Written by Christian Ehrlicher, 2007
# Revised by Roger Lowman, 2009-2010
# Revised by Clifford Yapp, 2011-2012
# Revised by Roger Leigh, 2016
# Revised by Andreas Franek, 2016
# This code is released under the libpng license.
# For conditions of distribution and use, see the disclaimer
# and license in png.h
cmake_minimum_required(VERSION 2.4.4)
set(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS true)
cmake_minimum_required(VERSION 2.8.3)
cmake_policy(VERSION 2.8.3)
if(UNIX AND NOT DEFINED CMAKE_BUILD_TYPE)
if(CMAKE_MAJOR_VERSION EQUAL 2 AND CMAKE_MINOR_VERSION EQUAL 4)
# workaround CMake 2.4.x bug
set(CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE STRING
"Choose the type of build, options are:
None(CMAKE_CXX_FLAGS or CMAKE_C_FLAGS used)
Debug
Release
RelWithDebInfo
MinSizeRel.")
else()
set(CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE STRING
"Choose the type of build, options are:
None(CMAKE_CXX_FLAGS or CMAKE_C_FLAGS used)
Debug
Release
RelWithDebInfo
MinSizeRel.")
endif()
endif()
# Set MacOSX @rpath usage globally.
if (POLICY CMP0020)
cmake_policy(SET CMP0020 NEW)
endif(POLICY CMP0020)
if (POLICY CMP0042)
cmake_policy(SET CMP0042 NEW)
endif(POLICY CMP0042)
# Use new variable expansion policy.
if (POLICY CMP0053)
cmake_policy(SET CMP0053 NEW)
endif(POLICY CMP0053)
if (POLICY CMP0054)
cmake_policy(SET CMP0054 NEW)
endif(POLICY CMP0054)
set(CMAKE_CONFIGURATION_TYPES "Release;Debug;MinSizeRel;RelWithDebInfo")
project(libpng C)
enable_testing()
set(PNGLIB_MAJOR 1)
set(PNGLIB_MINOR 6)
set(PNGLIB_MINOR 7)
set(PNGLIB_RELEASE 0)
set(PNGLIB_NAME libpng${PNGLIB_MAJOR}${PNGLIB_MINOR})
set(PNGLIB_VERSION ${PNGLIB_MAJOR}.${PNGLIB_MINOR}.${PNGLIB_RELEASE})
@ -49,8 +50,7 @@ if(NOT WIN32)
PATHS /usr/lib /usr/local/lib
)
if(NOT M_LIBRARY)
message(STATUS
"math library 'libm' not found - floating point support disabled")
message(STATUS "math lib 'libm' not found; floating point support disabled")
endif()
else()
# not needed on windows
@ -58,22 +58,47 @@ else()
endif()
# COMMAND LINE OPTIONS
if(DEFINED PNG_SHARED)
option(PNG_SHARED "Build shared lib" ${PNG_SHARED})
else()
option(PNG_SHARED "Build shared lib" ON)
endif()
if(DEFINED PNG_STATIC)
option(PNG_STATIC "Build static lib" ${PNG_STATIC})
else()
option(PNG_STATIC "Build static lib" ON)
endif()
option(PNG_TESTS "Build libpng tests" YES)
option(PNG_SHARED "Build shared lib" ON)
option(PNG_STATIC "Build static lib" ON)
option(PNG_TESTS "Build libpng tests" ON)
# Many more configuration options could be added here
option(PNG_DEBUG "Build with debug output" NO)
option(PNGARG "Disable ANSI-C prototypes" NO)
option(PNG_FRAMEWORK "Build OS X framework" OFF)
option(PNG_DEBUG "Build with debug output" OFF)
option(PNGARG "Disable ANSI-C prototypes" OFF)
set(PNG_PREFIX "" CACHE STRING "Prefix to add to the API function names")
set(DFA_XTRA "" CACHE FILEPATH "File containing extra configuration settings")
# set definitions and sources for arm
if(${CMAKE_SYSTEM_PROCESSOR} MATCHES "^arm" OR
${CMAKE_SYSTEM_PROCESSOR} MATCHES "^aarch64")
set(PNG_ARM_NEON_POSSIBLE_VALUES check on off)
set(PNG_ARM_NEON "check" CACHE STRING "Enable ARM NEON optimizations:
check: (default) use internal checking code;
off: disable the optimizations;
on: turn on unconditionally.")
set_property(CACHE PNG_ARM_NEON PROPERTY STRINGS
${PNG_ARM_NEON_POSSIBLE_VALUES})
list(FIND PNG_ARM_NEON_POSSIBLE_VALUES ${PNG_ARM_NEON} index)
if(index EQUAL -1)
message(FATAL_ERROR
" PNG_ARM_NEON must be one of [${PNG_ARM_NEON_POSSIBLE_VALUES}]")
elseif(NOT ${PNG_ARM_NEON} STREQUAL "no")
set(libpng_arm_sources
arm/arm_init.c
arm/filter_neon.S
arm/filter_neon_intrinsics.c)
if(${PNG_ARM_NEON} STREQUAL "on")
add_definitions(-DPNG_ARM_NEON_OPT=2)
elseif(${PNG_ARM_NEON} STREQUAL "check")
add_definitions(-DPNG_ARM_NEON_CHECK_SUPPORTED)
endif()
else()
add_definitions(-DPNG_ARM_NEON_OPT=0)
endif()
endif()
# SET LIBNAME
set(PNG_LIB_NAME png${PNGLIB_MAJOR}${PNGLIB_MINOR})
@ -81,26 +106,276 @@ set(PNG_LIB_NAME png${PNGLIB_MAJOR}${PNGLIB_MINOR})
# to distinguish between debug and release lib
set(CMAKE_DEBUG_POSTFIX "d")
# Use the prebuilt pnglibconf.h file from the scripts folder
# TODO: fix this by building with awk; without this no cmake build can be
# configured directly (to do so indirectly use your local awk to build a
# pnglibconf.h in the build directory.)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/scripts/pnglibconf.h.prebuilt
${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.h)
include(CheckCSourceCompiles)
option(ld-version-script "Enable linker version script" ON)
if(ld-version-script AND NOT APPLE)
# Check if LD supports linker scripts.
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/conftest.map" "VERS_1 {
global: sym;
local: *;
};
VERS_2 {
global: sym2;
main;
} VERS_1;
")
set(CMAKE_REQUIRED_FLAGS_SAVE ${CMAKE_REQUIRED_FLAGS})
set(CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS} "-Wl,--version-script='${CMAKE_CURRENT_BINARY_DIR}/conftest.map'")
check_c_source_compiles("void sym(void) {}
void sym2(void) {}
int main(void) {return 0;}
" HAVE_LD_VERSION_SCRIPT)
if(NOT HAVE_LD_VERSION_SCRIPT)
set(CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS_SAVE} "-Wl,-M -Wl,${CMAKE_CURRENT_BINARY_DIR}/conftest.map")
check_c_source_compiles("void sym(void) {}
void sym2(void) {}
int main(void) {return 0;}
" HAVE_SOLARIS_LD_VERSION_SCRIPT)
endif()
set(CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS_SAVE})
file(REMOVE "${CMAKE_CURRENT_BINARY_DIR}/conftest.map")
endif()
# Find symbol prefix. Likely obsolete and unnecessary with recent
# toolchains (it's not done in many other projects).
function(symbol_prefix)
set(SYMBOL_PREFIX)
execute_process(COMMAND "${CMAKE_C_COMPILER}" "-E" "-"
INPUT_FILE /dev/null
OUTPUT_VARIABLE OUT
RESULT_VARIABLE STATUS)
if(CPP_FAIL)
message(WARNING "Failed to run the C preprocessor")
endif()
string(REPLACE "\n" ";" OUT "${OUT}")
foreach(line ${OUT})
string(REGEX MATCH "^PREFIX=" found_match "${line}")
if(found_match)
STRING(REGEX REPLACE "^PREFIX=(.*\)" "\\1" prefix "${line}")
string(REGEX MATCH "__USER_LABEL_PREFIX__" found_match "${prefix}")
if(found_match)
STRING(REGEX REPLACE "(.*)__USER_LABEL_PREFIX__(.*)" "\\1\\2" prefix "${prefix}")
endif()
set(SYMBOL_PREFIX "${prefix}")
endif()
endforeach()
message(STATUS "Symbol prefix: ${SYMBOL_PREFIX}")
set(SYMBOL_PREFIX "${SYMBOL_PREFIX}" PARENT_SCOPE)
endfunction()
if(UNIX)
symbol_prefix()
endif()
find_program(AWK NAMES gawk awk)
include_directories(${CMAKE_CURRENT_BINARY_DIR})
if(NOT AWK)
# No awk available to generate sources; use pre-built pnglibconf.h
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/scripts/pnglibconf.h.prebuilt
${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.h)
add_custom_target(genfiles) # Dummy
else()
include(CMakeParseArguments)
# Generate .chk from .out with awk
# generate_chk(INPUT inputfile OUTPUT outputfile [DEPENDS dep1 [dep2...]])
function(generate_chk)
set(options)
set(oneValueArgs INPUT OUTPUT)
set(multiValueArgs DEPENDS)
cmake_parse_arguments(_GC "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
if (NOT _GC_INPUT)
message(FATAL_ERROR "Invalid arguments. generate_out requires input.")
endif()
if (NOT _GC_OUTPUT)
message(FATAL_ERROR "Invalid arguments. generate_out requires output.")
endif()
add_custom_command(OUTPUT "${_GC_OUTPUT}"
COMMAND "${CMAKE_COMMAND}"
"-DINPUT=${_GC_INPUT}"
"-DOUTPUT=${_GC_OUTPUT}"
-P "${CMAKE_CURRENT_BINARY_DIR}/scripts/genchk.cmake"
DEPENDS "${_GC_INPUT}" ${_GC_DEPENDS}
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}")
endfunction()
# Generate .out from .c with awk
# generate_out(INPUT inputfile OUTPUT outputfile [DEPENDS dep1 [dep2...]])
function(generate_out)
set(options)
set(oneValueArgs INPUT OUTPUT)
set(multiValueArgs DEPENDS)
cmake_parse_arguments(_GO "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
if (NOT _GO_INPUT)
message(FATAL_ERROR "Invalid arguments. generate_out requires input.")
endif()
if (NOT _GO_OUTPUT)
message(FATAL_ERROR "Invalid arguments. generate_out requires output.")
endif()
add_custom_command(OUTPUT "${_GO_OUTPUT}"
COMMAND "${CMAKE_COMMAND}"
"-DINPUT=${_GO_INPUT}"
"-DOUTPUT=${_GO_OUTPUT}"
-P "${CMAKE_CURRENT_BINARY_DIR}/scripts/genout.cmake"
DEPENDS "${_GO_INPUT}" ${_GO_DEPENDS}
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}")
endfunction()
# Generate specific source file with awk
# generate_source(OUTPUT outputfile [DEPENDS dep1 [dep2...]])
function(generate_source)
set(options)
set(oneValueArgs OUTPUT)
set(multiValueArgs DEPENDS)
cmake_parse_arguments(_GSO "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
if (NOT _GSO_OUTPUT)
message(FATAL_ERROR "Invalid arguments. generate_source requires output.")
endif()
add_custom_command(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${_GSO_OUTPUT}"
COMMAND "${CMAKE_COMMAND}"
"-DOUTPUT=${_GSO_OUTPUT}"
-P "${CMAKE_CURRENT_BINARY_DIR}/scripts/gensrc.cmake"
DEPENDS ${_GSO_DEPENDS}
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}")
endfunction()
# Copy file
function(generate_copy source destination)
add_custom_command(OUTPUT "${destination}"
COMMAND "${CMAKE_COMMAND}" -E remove "${destination}"
COMMAND "${CMAKE_COMMAND}" -E copy "${source}"
"${destination}"
DEPENDS "${source}")
endfunction()
# Generate scripts/pnglibconf.h
generate_source(OUTPUT "scripts/pnglibconf.c"
DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/scripts/pnglibconf.dfa"
"${CMAKE_CURRENT_SOURCE_DIR}/scripts/options.awk"
"${CMAKE_CURRENT_SOURCE_DIR}/pngconf.h")
# Generate pnglibconf.c
generate_source(OUTPUT "pnglibconf.c"
DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/scripts/pnglibconf.dfa"
"${CMAKE_CURRENT_SOURCE_DIR}/scripts/options.awk"
"${CMAKE_CURRENT_SOURCE_DIR}/pngconf.h")
if(PNG_PREFIX)
set(PNGLIBCONF_H_EXTRA_DEPENDS
"${CMAKE_CURRENT_BINARY_DIR}/scripts/prefix.out"
"${CMAKE_CURRENT_SOURCE_DIR}/scripts/macro.lst")
set(PNGPREFIX_H_EXTRA_DEPENDS
"${CMAKE_CURRENT_BINARY_DIR}/scripts/intprefix.out")
endif()
generate_out(INPUT "${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.c"
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.out")
# Generate pnglibconf.h
generate_source(OUTPUT "pnglibconf.h"
DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.out"
${PNGLIBCONF_H_EXTRA_DEPENDS})
generate_out(INPUT "${CMAKE_CURRENT_SOURCE_DIR}/scripts/intprefix.c"
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/scripts/intprefix.out"
DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.h")
generate_out(INPUT "${CMAKE_CURRENT_SOURCE_DIR}/scripts/prefix.c"
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/scripts/prefix.out"
DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/png.h"
"${CMAKE_CURRENT_SOURCE_DIR}/pngconf.h"
"${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.out")
# Generate pngprefix.h
generate_source(OUTPUT "pngprefix.h"
DEPENDS ${PNGPREFIX_H_EXTRA_DEPENDS})
generate_out(INPUT "${CMAKE_CURRENT_SOURCE_DIR}/scripts/sym.c"
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/scripts/sym.out"
DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.h")
generate_out(INPUT "${CMAKE_CURRENT_SOURCE_DIR}/scripts/symbols.c"
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/scripts/symbols.out"
DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/png.h"
"${CMAKE_CURRENT_SOURCE_DIR}/pngconf.h"
"${CMAKE_CURRENT_SOURCE_DIR}/scripts/pnglibconf.h.prebuilt")
generate_out(INPUT "${CMAKE_CURRENT_SOURCE_DIR}/scripts/vers.c"
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/scripts/vers.out"
DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/png.h"
"${CMAKE_CURRENT_SOURCE_DIR}/pngconf.h"
"${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.h")
generate_chk(INPUT "${CMAKE_CURRENT_BINARY_DIR}/scripts/symbols.out"
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/scripts/symbols.chk"
DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/scripts/checksym.awk"
"${CMAKE_CURRENT_SOURCE_DIR}/scripts/symbols.def")
add_custom_target(symbol-check DEPENDS
"${CMAKE_CURRENT_BINARY_DIR}/scripts/symbols.chk")
generate_copy("${CMAKE_CURRENT_BINARY_DIR}/scripts/sym.out"
"${CMAKE_CURRENT_BINARY_DIR}/libpng.sym")
generate_copy("${CMAKE_CURRENT_BINARY_DIR}/scripts/vers.out"
"${CMAKE_CURRENT_BINARY_DIR}/libpng.vers")
add_custom_target(genvers DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/libpng.vers")
add_custom_target(gensym DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/libpng.sym")
add_custom_target("genprebuilt"
COMMAND "${CMAKE_COMMAND}"
"-DOUTPUT=scripts/pnglibconf.h.prebuilt"
-P "${CMAKE_CURRENT_BINARY_DIR}/scripts/gensrc.cmake"
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}")
# A single target handles generation of all generated files. If
# they are dependend upon separately by multiple targets, this
# confuses parallel make (it would require a separate top-level
# target for each file to track the dependencies properly).
add_custom_target(genfiles DEPENDS
"${CMAKE_CURRENT_BINARY_DIR}/libpng.sym"
"${CMAKE_CURRENT_BINARY_DIR}/libpng.vers"
"${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.c"
"${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.h"
"${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.out"
"${CMAKE_CURRENT_BINARY_DIR}/pngprefix.h"
"${CMAKE_CURRENT_BINARY_DIR}/scripts/intprefix.out"
"${CMAKE_CURRENT_BINARY_DIR}/scripts/pnglibconf.c"
"${CMAKE_CURRENT_BINARY_DIR}/scripts/prefix.out"
"${CMAKE_CURRENT_BINARY_DIR}/scripts/sym.out"
"${CMAKE_CURRENT_BINARY_DIR}/scripts/symbols.chk"
"${CMAKE_CURRENT_BINARY_DIR}/scripts/symbols.out"
"${CMAKE_CURRENT_BINARY_DIR}/scripts/vers.out")
endif(NOT AWK)
# OUR SOURCES
set(libpng_public_hdrs
png.h
pngconf.h
${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.h
"${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.h"
)
set(libpng_sources
${libpng_public_hdrs}
set(libpng_private_hdrs
pngpriv.h
pngdebug.h
pnginfo.h
pngpriv.h
pngstruct.h
pngchunk.h
)
if(AWK)
list(APPEND libpng_private_hdrs "${CMAKE_CURRENT_BINARY_DIR}/pngprefix.h")
endif()
set(libpng_sources
${libpng_public_hdrs}
${libpng_private_hdrs}
png.c
pngerror.c
pngget.c
@ -116,6 +391,7 @@ set(libpng_sources
pngwrite.c
pngwtran.c
pngwutil.c
${libpng_arm_sources}
)
set(pngtest_sources
pngtest.c
@ -126,7 +402,18 @@ set(pngvalid_sources
set(pngstest_sources
contrib/libtests/pngstest.c
)
# SOME NEEDED DEFINITIONS
set(pngunknown_sources
contrib/libtests/pngunknown.c
)
set(pngimage_sources
contrib/libtests/pngimage.c
)
set(pngfix_sources
contrib/tools/pngfix.c
)
set(png_fix_itxt_sources
contrib/tools/png-fix-itxt.c
)
if(MSVC)
add_definitions(-D_CRT_SECURE_NO_DEPRECATE)
@ -139,74 +426,245 @@ endif()
# NOW BUILD OUR TARGET
include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${ZLIB_INCLUDE_DIR})
unset(PNG_LIB_TARGETS)
if(PNG_SHARED)
add_library(${PNG_LIB_NAME} SHARED ${libpng_sources})
add_library(png SHARED ${libpng_sources})
set(PNG_LIB_TARGETS png)
set_target_properties(png PROPERTIES OUTPUT_NAME ${PNG_LIB_NAME})
add_dependencies(png genfiles)
if(MSVC)
# msvc does not append 'lib' - do it here to have consistent name
set_target_properties(${PNG_LIB_NAME} PROPERTIES PREFIX "lib")
set_target_properties(${PNG_LIB_NAME} PROPERTIES IMPORT_PREFIX "lib")
set_target_properties(png PROPERTIES PREFIX "lib")
set_target_properties(png PROPERTIES IMPORT_PREFIX "lib")
endif()
target_link_libraries(png ${ZLIB_LIBRARY} ${M_LIBRARY})
if(UNIX AND AWK)
if(HAVE_LD_VERSION_SCRIPT)
set_target_properties(png PROPERTIES LINK_FLAGS
"-Wl,--version-script='${CMAKE_CURRENT_BINARY_DIR}/libpng.vers'")
elseif(HAVE_SOLARIS_LD_VERSION_SCRIPT)
set_target_properties(png PROPERTIES LINK_FLAGS
"-Wl,-M -Wl,'${CMAKE_CURRENT_BINARY_DIR}/libpng.vers'")
endif()
endif()
target_link_libraries(${PNG_LIB_NAME} ${ZLIB_LIBRARY} ${M_LIBRARY})
endif()
if(PNG_STATIC)
# does not work without changing name
set(PNG_LIB_NAME_STATIC ${PNG_LIB_NAME}_static)
add_library(${PNG_LIB_NAME_STATIC} STATIC ${libpng_sources})
# does not work without changing name
set(PNG_LIB_NAME_STATIC png_static)
add_library(png_static STATIC ${libpng_sources})
add_dependencies(png_static genfiles)
# MSVC doesn't use a different file extension for shared vs. static
# libs. We are able to change OUTPUT_NAME to remove the _static
# for all other platforms.
if(NOT MSVC)
set_target_properties(png_static PROPERTIES
OUTPUT_NAME "${PNG_LIB_NAME}"
CLEAN_DIRECT_OUTPUT 1)
else()
set_target_properties(png_static PROPERTIES
OUTPUT_NAME "${PNG_LIB_NAME}_static"
CLEAN_DIRECT_OUTPUT 1)
endif()
list(APPEND PNG_LIB_TARGETS png_static)
if(MSVC)
# msvc does not append 'lib' - do it here to have consistent name
set_target_properties(${PNG_LIB_NAME_STATIC} PROPERTIES PREFIX "lib")
set_target_properties(png_static PROPERTIES PREFIX "lib")
endif()
target_link_libraries(${PNG_LIB_NAME_STATIC} ${ZLIB_LIBRARY} ${M_LIBRARY})
target_link_libraries(png_static ${ZLIB_LIBRARY} ${M_LIBRARY})
endif()
if(PNG_FRAMEWORK)
set(PNG_LIB_NAME_FRAMEWORK png_framework)
add_library(png_framework SHARED ${libpng_sources})
add_dependencies(png_framework genfiles)
list(APPEND PNG_LIB_TARGETS png_framework)
set_target_properties(png_framework PROPERTIES
FRAMEWORK TRUE
FRAMEWORK_VERSION ${PNGLIB_VERSION}
MACOSX_FRAMEWORK_SHORT_VERSION_STRING ${PNGLIB_MAJOR}.${PNGLIB_MINOR}
MACOSX_FRAMEWORK_BUNDLE_VERSION ${PNGLIB_VERSION}
MACOSX_FRAMEWORK_IDENTIFIER org.libpng.libpng
XCODE_ATTRIBUTE_INSTALL_PATH "@rpath"
PUBLIC_HEADER "${libpng_public_hdrs}"
OUTPUT_NAME png)
target_link_libraries(png_framework ${ZLIB_LIBRARY} ${M_LIBRARY})
endif()
if(NOT PNG_LIB_TARGETS)
message(SEND_ERROR
"No library variant selected to build. "
"Please enable at least one of the following options: "
" PNG_STATIC, PNG_SHARED, PNG_FRAMEWORK")
endif()
if(PNG_SHARED AND WIN32)
set_target_properties(${PNG_LIB_NAME} PROPERTIES DEFINE_SYMBOL PNG_BUILD_DLL)
set_target_properties(png PROPERTIES DEFINE_SYMBOL PNG_BUILD_DLL)
endif()
function(png_add_test)
set(options)
set(oneValueArgs NAME COMMAND)
set(multiValueArgs OPTIONS FILES)
cmake_parse_arguments(_PAT "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
if (NOT _PAT_NAME)
message(FATAL_ERROR "Invalid arguments. png_add_test requires name.")
endif()
if (NOT _PAT_COMMAND)
message(FATAL_ERROR "Invalid arguments. png_add_test requires command.")
endif()
set(TEST_OPTIONS "${_PAT_OPTIONS}")
set(TEST_FILES "${_PAT_FILES}")
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/scripts/test.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/tests/${_PAT_NAME}.cmake" @ONLY)
if(CMAKE_MAJOR_VERSION GREATER 2) # have generator expressions
add_test(NAME "${_PAT_NAME}"
COMMAND "${CMAKE_COMMAND}"
"-DLIBPNG=$<TARGET_FILE:png>"
"-DTEST_COMMAND=$<TARGET_FILE:${_PAT_COMMAND}>"
-P "${CMAKE_CURRENT_BINARY_DIR}/tests/${_PAT_NAME}.cmake")
else() # old 2.x add_test; limited and won't work well on Windows
# Note LIBPNG is a dummy value as there are no generator expressions
add_test("${_PAT_NAME}" "${CMAKE_COMMAND}"
"-DLIBPNG=${CMAKE_CURRENT_BINARY_DIR}/libpng.so"
"-DTEST_COMMAND=./${_PAT_COMMAND}"
-P "${CMAKE_CURRENT_BINARY_DIR}/tests/${_PAT_NAME}.cmake")
endif()
endfunction()
if(PNG_TESTS AND PNG_SHARED)
# does not work with msvc due to png_lib_ver issue
# Find test PNG files by globbing, but sort lists to ensure
# consistency between different filesystems.
file(GLOB PNGSUITE_PNGS "${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/*.png")
list(SORT PNGSUITE_PNGS)
file(GLOB TEST_PNGS "${CMAKE_CURRENT_SOURCE_DIR}/contrib/testpngs/*.png")
list(SORT TEST_PNGS)
set(PNGTEST_PNG "${CMAKE_CURRENT_SOURCE_DIR}/pngtest.png")
add_executable(pngtest ${pngtest_sources})
target_link_libraries(pngtest ${PNG_LIB_NAME})
add_test(pngtest ./pngtest ${CMAKE_CURRENT_SOURCE_DIR}/pngtest.png)
#
target_link_libraries(pngtest png)
png_add_test(NAME pngtest COMMAND pngtest FILES "${PNGTEST_PNG}")
add_executable(pngvalid ${pngvalid_sources})
target_link_libraries(pngvalid ${PNG_LIB_NAME})
add_test(pngvalid ./pngvalid)
target_link_libraries(pngvalid png)
png_add_test(NAME pngvalid-gamma-16-to-8
COMMAND pngvalid OPTIONS --gamma-16-to-8)
png_add_test(NAME pngvalid-gamma-alpha-mode
COMMAND pngvalid OPTIONS --gamma-alpha-mode)
png_add_test(NAME pngvalid-gamma-background
COMMAND pngvalid OPTIONS --gamma-background)
png_add_test(NAME pngvalid-gamma-expand16-alpha-mode
COMMAND pngvalid OPTIONS --gamma-alpha-mode --expand16)
png_add_test(NAME pngvalid-gamma-expand16-background
COMMAND pngvalid OPTIONS --gamma-background --expand16)
png_add_test(NAME pngvalid-gamma-expand16-transform
COMMAND pngvalid OPTIONS --gamma-transform --expand16)
png_add_test(NAME pngvalid-gamma-sbit
COMMAND pngvalid OPTIONS --gamma-sbit)
png_add_test(NAME pngvalid-gamma-threshold
COMMAND pngvalid OPTIONS --gamma-threshold)
png_add_test(NAME pngvalid-gamma-transform
COMMAND pngvalid OPTIONS --gamma-transform)
png_add_test(NAME pngvalid-progressive-interlace-standard
COMMAND pngvalid OPTIONS --standard --progressive-read --interlace)
png_add_test(NAME pngvalid-progressive-size
COMMAND pngvalid OPTIONS --size --progressive-read)
png_add_test(NAME pngvalid-progressive-standard
COMMAND pngvalid OPTIONS --standard --progressive-read)
png_add_test(NAME pngvalid-standard
COMMAND pngvalid OPTIONS --standard)
png_add_test(NAME pngvalid-transform
COMMAND pngvalid OPTIONS --transform)
add_executable(pngstest ${pngstest_sources})
target_link_libraries(pngstest ${PNG_LIB_NAME})
add_test(pngstest ./pngstest
${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/basn0g01.png
${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/basn0g02.png
${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/basn0g04.png
${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/basn0g08.png
${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/basn0g16.png
${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/basn2c08.png
${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/basn2c16.png
${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/basn3p01.png
${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/basn3p02.png
${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/basn3p04.png
${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/basn3p08.png
${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/basn4a08.png
${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/basn4a16.png
${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/basn6a08.png
${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/basn6a16.png
${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/ftbbn0g01.png
${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/ftbbn0g02.png
${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/ftbbn0g04.png
${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/ftbbn2c16.png
${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/ftbbn3p08.png
${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/ftbgn2c16.png
${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/ftbgn3p08.png
${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/ftbrn2c08.png
${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/ftbwn0g16.png
${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/ftbwn3p08.png
${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/ftbyn3p08.png
${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/ftp0n0g08.png
${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/ftp0n2c08.png
${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/ftp0n3p08.png
${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/ftp1n3p08.png
)
target_link_libraries(pngstest png)
foreach(gamma_type 1.8 linear none sRGB)
foreach(alpha_type none alpha)
set(PNGSTEST_FILES)
foreach(test_png ${TEST_PNGS})
string(REGEX MATCH ".*-linear[-.].*" TEST_PNG_LINEAR "${test_png}")
string(REGEX MATCH ".*-sRGB[-.].*" TEST_PNG_SRGB "${test_png}")
string(REGEX MATCH ".*-1.8[-.].*" TEST_PNG_G18 "${test_png}")
string(REGEX MATCH ".*-alpha-.*" TEST_PNG_ALPHA "${test_png}")
set(TEST_PNG_VALID TRUE)
if(TEST_PNG_ALPHA)
if (NOT "${alpha_type}" STREQUAL "alpha")
set(TEST_PNG_VALID FALSE)
endif()
else()
if ("${alpha_type}" STREQUAL "alpha")
set(TEST_PNG_VALID FALSE)
endif()
endif()
if(TEST_PNG_LINEAR)
if(NOT "${gamma_type}" STREQUAL "linear")
set(TEST_PNG_VALID FALSE)
endif()
elseif(TEST_PNG_SRGB)
if(NOT "${gamma_type}" STREQUAL "sRGB")
set(TEST_PNG_VALID FALSE)
endif()
elseif(TEST_PNG_G18)
if(NOT "${gamma_type}" STREQUAL "1.8")
set(TEST_PNG_VALID FALSE)
endif()
else()
if(NOT "${gamma_type}" STREQUAL "none")
set(TEST_PNG_VALID FALSE)
endif()
endif()
if(TEST_PNG_VALID)
list(APPEND PNGSTEST_FILES "${test_png}")
endif()
endforeach()
# Should already be sorted, but sort anyway to be certain.
list(SORT PNGSTEST_FILES)
png_add_test(NAME pngstest-${gamma_type}-${alpha_type}
COMMAND pngstest
OPTIONS --tmpfile "${gamma_type}-${alpha_type}-" --log
FILES ${PNGSTEST_FILES})
endforeach()
endforeach()
add_executable(pngunknown ${pngunknown_sources})
target_link_libraries(pngunknown png)
png_add_test(NAME pngunknown-discard COMMAND pngunknown OPTIONS --strict default=discard FILES "${PNGTEST_PNG}")
png_add_test(NAME pngunknown-IDAT COMMAND pngunknown OPTIONS --strict default=discard IDAT=save FILES "${PNGTEST_PNG}")
png_add_test(NAME pngunknown-if-safe COMMAND pngunknown OPTIONS --strict default=if-safe FILES "${PNGTEST_PNG}")
png_add_test(NAME pngunknown-sAPI COMMAND pngunknown OPTIONS --strict bKGD=save cHRM=save gAMA=save all=discard iCCP=save sBIT=save sRGB=save FILES "${PNGTEST_PNG}")
png_add_test(NAME pngunknown-save COMMAND pngunknown OPTIONS --strict default=save FILES "${PNGTEST_PNG}")
png_add_test(NAME pngunknown-sTER COMMAND pngunknown OPTIONS --strict sTER=if-safe FILES "${PNGTEST_PNG}")
png_add_test(NAME pngunknown-vpAg COMMAND pngunknown OPTIONS --strict vpAg=if-safe FILES "${PNGTEST_PNG}")
add_executable(pngimage ${pngimage_sources})
target_link_libraries(pngimage png)
png_add_test(NAME pngimage-quick COMMAND pngimage OPTIONS --list-combos --log FILES ${PNGSUITE_PNGS})
png_add_test(NAME pngimage-full COMMAND pngimage OPTIONS --exhaustive --list-combos --log FILES ${PNGSUITE_PNGS})
endif()
if(PNG_SHARED)
add_executable(pngfix ${pngfix_sources})
target_link_libraries(pngfix png)
set(PNG_BIN_TARGETS pngfix)
add_executable(png-fix-itxt ${png_fix_itxt_sources})
target_link_libraries(png-fix-itxt ${ZLIB_LIBRARY} ${M_LIBRARY})
list(APPEND PNG_BIN_TARGETS png-fix-itxt)
endif()
# Ensure the CMAKE_LIBRARY_OUTPUT_DIRECTORY is set
@ -222,17 +680,28 @@ macro(CREATE_SYMLINK SRC_FILE DEST_FILE)
if(WIN32 AND NOT CYGWIN AND NOT MSYS)
ADD_CUSTOM_COMMAND(
OUTPUT ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${DEST_FILE} ${CMAKE_CURRENT_BINARY_DIR}/${DEST_FILE}
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/${SRC_FILE} ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${DEST_FILE}
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/${SRC_FILE} ${CMAKE_CURRENT_BINARY_DIR}/${DEST_FILE}
DEPENDS ${PNG_LIB_NAME} ${PNG_LIB_NAME_STATIC}
COMMAND ${CMAKE_COMMAND} -E copy_if_different "${SRC_FILE}" ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${DEST_FILE}
COMMAND ${CMAKE_COMMAND} -E copy_if_different "${SRC_FILE}" ${CMAKE_CURRENT_BINARY_DIR}/${DEST_FILE}
DEPENDS ${PNG_LIB_TARGETS}
)
ADD_CUSTOM_TARGET(${DEST_FILE}_COPY ALL DEPENDS ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${DEST_FILE})
else(WIN32 AND NOT CYGWIN AND NOT MSYS)
execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink ${SRC_FILE} ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${DEST_FILE} WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink ${SRC_FILE} ${DEST_FILE} WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
get_filename_component(LINK_TARGET "${SRC_FILE}" NAME)
execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_LIBRARY_OUTPUT_DIRECTORY})
execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink "${LINK_TARGET}" ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${DEST_FILE} WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink "${LINK_TARGET}" ${DEST_FILE} WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
endif(WIN32 AND NOT CYGWIN AND NOT MSYS)
endmacro()
# Create source generation scripts.
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/scripts/genchk.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/scripts/genchk.cmake @ONLY)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/scripts/genout.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/scripts/genout.cmake @ONLY)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/scripts/gensrc.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/scripts/gensrc.cmake @ONLY)
# libpng is a library so default to 'lib'
if(NOT DEFINED CMAKE_INSTALL_LIBDIR)
set(CMAKE_INSTALL_LIBDIR lib)
@ -259,22 +728,12 @@ endif(NOT WIN32 OR CYGWIN OR MINGW)
# SET UP LINKS
if(PNG_SHARED)
set_target_properties(${PNG_LIB_NAME} PROPERTIES
# VERSION 16.${PNGLIB_RELEASE}.1.6.0beta33
VERSION 16.${PNGLIB_RELEASE}.0
SOVERSION 16
set_target_properties(png PROPERTIES
# VERSION 17.${PNGLIB_RELEASE}.1.7.0beta88
VERSION 17.${PNGLIB_RELEASE}.0
SOVERSION 17
CLEAN_DIRECT_OUTPUT 1)
endif()
if(PNG_STATIC)
# MSVC doesn't use a different file extension for shared vs. static
# libs. We are able to change OUTPUT_NAME to remove the _static
# for all other platforms.
if(NOT MSVC)
set_target_properties(${PNG_LIB_NAME_STATIC} PROPERTIES
OUTPUT_NAME ${PNG_LIB_NAME}
CLEAN_DIRECT_OUTPUT 1)
endif()
endif()
# If CMake > 2.4.x, we set a variable used below to export
# targets to an export file.
@ -287,40 +746,34 @@ endif()
# INSTALL
if(NOT SKIP_INSTALL_LIBRARIES AND NOT SKIP_INSTALL_ALL )
if(PNG_SHARED)
install(TARGETS ${PNG_LIB_NAME}
${PNG_EXPORT_RULE}
RUNTIME DESTINATION bin
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
install(TARGETS ${PNG_LIB_TARGETS}
${PNG_EXPORT_RULE}
RUNTIME DESTINATION bin
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
FRAMEWORK DESTINATION ${CMAKE_INSTALL_LIBDIR})
# Create a symlink for libpng.dll.a => libpng16.dll.a on Cygwin
if(PNG_SHARED)
# Create a symlink for libpng.dll.a => libpng17.dll.a on Cygwin
if(CYGWIN OR MINGW)
get_target_property(BUILD_TARGET_LOCATION ${PNG_LIB_NAME} LOCATION_${CMAKE_BUILD_TYPE})
get_filename_component(BUILD_TARGET_FILE ${BUILD_TARGET_LOCATION} NAME)
CREATE_SYMLINK(${BUILD_TARGET_FILE} libpng${CMAKE_IMPORT_LIBRARY_SUFFIX})
get_target_property(BUILD_TARGET_LOCATION png LOCATION_${CMAKE_BUILD_TYPE})
CREATE_SYMLINK(${BUILD_TARGET_LOCATION} libpng${CMAKE_IMPORT_LIBRARY_SUFFIX})
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libpng${CMAKE_IMPORT_LIBRARY_SUFFIX}
DESTINATION ${CMAKE_INSTALL_LIBDIR})
endif(CYGWIN OR MINGW)
if(NOT WIN32)
get_target_property(BUILD_TARGET_LOCATION ${PNG_LIB_NAME} LOCATION_${CMAKE_BUILD_TYPE})
get_filename_component(BUILD_TARGET_FILE ${BUILD_TARGET_LOCATION} NAME)
CREATE_SYMLINK(${BUILD_TARGET_FILE} libpng${CMAKE_SHARED_LIBRARY_SUFFIX})
get_target_property(BUILD_TARGET_LOCATION png LOCATION_${CMAKE_BUILD_TYPE})
CREATE_SYMLINK(${BUILD_TARGET_LOCATION} libpng${CMAKE_SHARED_LIBRARY_SUFFIX})
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libpng${CMAKE_SHARED_LIBRARY_SUFFIX}
DESTINATION ${CMAKE_INSTALL_LIBDIR})
endif(NOT WIN32)
endif(PNG_SHARED)
if(PNG_STATIC)
install(TARGETS ${PNG_LIB_NAME_STATIC}
${PNG_EXPORT_RULE}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
if(NOT WIN32 OR CYGWIN OR MINGW)
get_target_property(BUILD_TARGET_LOCATION ${PNG_LIB_NAME_STATIC} LOCATION_${CMAKE_BUILD_TYPE})
get_filename_component(BUILD_TARGET_FILE ${BUILD_TARGET_LOCATION} NAME)
CREATE_SYMLINK(${BUILD_TARGET_FILE} libpng${CMAKE_STATIC_LIBRARY_SUFFIX})
get_target_property(BUILD_TARGET_LOCATION png_static LOCATION_${CMAKE_BUILD_TYPE})
CREATE_SYMLINK(${BUILD_TARGET_LOCATION} libpng${CMAKE_STATIC_LIBRARY_SUFFIX})
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libpng${CMAKE_STATIC_LIBRARY_SUFFIX}
DESTINATION ${CMAKE_INSTALL_LIBDIR})
endif(NOT WIN32 OR CYGWIN OR MINGW)
@ -339,6 +792,11 @@ if(NOT SKIP_INSTALL_EXECUTABLES AND NOT SKIP_INSTALL_ALL )
endif(NOT WIN32 OR CYGWIN OR MINGW)
endif()
if(NOT SKIP_INSTALL_PROGRAMS AND NOT SKIP_INSTALL_ALL )
install(TARGETS ${PNG_BIN_TARGETS}
RUNTIME DESTINATION bin)
endif()
if(NOT SKIP_INSTALL_FILES AND NOT SKIP_INSTALL_ALL )
# Install man pages
if(NOT PNG_MAN_DIR)
@ -365,7 +823,7 @@ if(PNG_EXPORT_RULE AND NOT SKIP_INSTALL_EXPORT AND NOT SKIP_INSTALL_ALL )
install(EXPORT libpng DESTINATION lib/libpng FILE lib${PNG_LIB_NAME}.cmake)
endif()
# what's with libpng-$VER%.txt and all the extra files?
# what's with libpng-manual.txt and all the extra files?
# UNINSTALL
# do we need this?

362
INSTALL
View File

@ -1,5 +1,27 @@
Installing libpng
Installing libpng
Contents
I. Simple installation
II. Rebuilding the configure scripts
III. Using scripts/makefile*
IV. Using cmake
V. Directory structure
VI. Building with project files
VII. Building with makefiles
VIII. Configuring libpng for 16-bit platforms
IX. Configuring for DOS
X. Configuring for Medium Model
XI. Prepending a prefix to exported symbols
XII. Configuring for compiler xxx:
XIII. Removing unwanted object code
XIV. Changes to the build and configuration of libpng in libpng-1.5.x
XV. Setjmp/longjmp issues
XVI. Common linking failures
XVII. Other sources of information about libpng
I. Simple installation
On Unix/Linux and similar systems, you can simply type
@ -7,13 +29,28 @@ On Unix/Linux and similar systems, you can simply type
make check
make install
and ignore the rest of this document.
and ignore the rest of this document. "/path" is the path to the directory
where you want to install the libpng "lib", "include", and "bin"
subdirectories.
If you downloaded a GIT clone, you will need to run ./autogen.sh before
running ./configure, to create "configure" and "Makefile.in" which are
not included in the GIT repository.
Note that "configure" is only included in the "*.tar" distributions and not
in the "*.zip" or "*.7z" distributions. If you downloaded one of those
distributions, see "Building with project files" or "Building with makefiles",
below.
II. Rebuilding the configure scripts
If configure does not work on your system, or if you have a need to
change configure.ac or Makefile.am, and you have a reasonably
up-to-date set of tools, running ./autogen.sh in a git clone before
running ./configure may fix the problem. To be really sure that you
aren't using any of the included pre-built scripts, you can do this:
aren't using any of the included pre-built scripts, especially if you
are building from a tar distribution instead of a git distribution,
do this:
./configure --enable-maintainer-mode
make maintainer-clean
@ -24,9 +61,12 @@ aren't using any of the included pre-built scripts, you can do this:
make install
make check
III. Using scripts/makefile*
Instead, you can use one of the custom-built makefiles in the
"scripts" directory
cp scripts/pnglibconf.h.prebuilt pnglibconf.h
cp scripts/makefile.system makefile
make test
make install
@ -38,31 +78,54 @@ Or you can use one of the "projects" in the "projects" directory.
Before installing libpng, you must first install zlib, if it
is not already on your system. zlib can usually be found
wherever you got libpng. zlib can be placed in another directory,
at the same level as libpng.
If you want to use "cmake" (see www.cmake.org), type
cmake . -DCMAKE_INSTALL_PREFIX=/path
make
make install
wherever you got libpng; otherwise go to http://zlib.net. You can place
zlib in the same directory as libpng or in another directory.
If your system already has a preinstalled zlib you will still need
to have access to the zlib.h and zconf.h include files that
correspond to the version of zlib that's installed.
If you wish to test with a particular zlib that is not first in the
standard library search path, put ZLIBLIB, ZLIBINC, CPPFLAGS, LDFLAGS,
and LD_LIBRARY_PATH in your environment before running "make test"
or "make distcheck":
ZLIBLIB=/path/to/lib export ZLIBLIB
ZLIBINC=/path/to/include export ZLIBINC
CPPFLAGS="-I$ZLIBINC" export CPPFLAGS
LDFLAGS="-L$ZLIBLIB" export LDFLAGS
LD_LIBRARY_PATH="$ZLIBLIB:$LD_LIBRARY_PATH" export LD_LIBRARY_PATH
If you are using one of the makefile scripts, put ZLIBLIB and ZLIBINC
in your environment and type
make ZLIBLIB=$ZLIBLIB ZLIBINC=$ZLIBINC test
IV. Using cmake
If you want to use "cmake" (see www.cmake.org), type
cmake . -DCMAKE_INSTALL_PREFIX=/path
make
make install
As when using the simple configure method described above, "/path" points to
the installation directory where you want to put the libpng "lib", "include",
and "bin" subdirectories.
V. Directory structure
You can rename the directories that you downloaded (they
might be called "libpng-x.y.z" or "libpngNN" and "zlib-1.2.5"
or "zlib125") so that you have directories called "zlib" and "libpng".
might be called "libpng-x.y.z" or "libpngNN" and "zlib-1.2.8"
or "zlib128") so that you have directories called "zlib" and "libpng".
Your directory structure should look like this:
.. (the parent directory)
libpng (this directory)
.. (the parent directory)
libpng (this directory)
INSTALL (this file)
README
*.h
*.c
*.h, *.c => libpng source files
CMakeLists.txt => "cmake" script
configuration files:
configure.ac, configure, Makefile.am, Makefile.in,
@ -70,14 +133,10 @@ Your directory structure should look like this:
libpng-config.in, aclocal.m4, config.h.in, config.sub,
depcomp, install-sh, mkinstalldirs, test-pngtest.sh
contrib
gregbook
pngminim
pngminus
pngsuite
visupng
arm-neon, conftest, examples, gregbook, libtests, pngminim,
pngminus, pngsuite, tools, visupng
projects
visualc71
vstudio
cbuilder5, owatcom, visualc71, vstudio, xcode
scripts
makefile.*
*.def (module definition files)
@ -85,29 +144,36 @@ Your directory structure should look like this:
pngtest.png
etc.
zlib
README
*.h
*.c
contrib
etc.
README, *.h, *.c contrib, etc.
If the line endings in the files look funny, you may wish to get the other
distribution of libpng. It is available in both tar.gz (UNIX style line
endings) and zip (DOS style line endings) formats.
VI. Building with project files
If you are building libpng with MSVC, you can enter the
libpng projects\visualc6 or visualc71 directory and follow the instructions
libpng projects\visualc71 or vstudio directory and follow the instructions
in README.txt.
Otherwise enter the zlib directory and follow the instructions in zlib/README,
then come back here and run "configure" or choose the appropriate
makefile.sys in the scripts directory.
VII. Building with makefiles
Copy the file (or files) that you need from the
scripts directory into this directory, for example
MSDOS example: copy scripts\makefile.msc makefile
UNIX example: cp scripts/makefile.std makefile
MSDOS example:
copy scripts\makefile.msc makefile
copy scripts\pnglibconf.h.prebuilt pnglibconf.h
UNIX example:
cp scripts/makefile.std makefile
cp scripts/pnglibconf.h.prebuilt pnglibconf.h
Read the makefile to see if you need to change any source or
target directories to match your preferences.
@ -130,26 +196,220 @@ do that, run "make install" in the zlib directory first if necessary).
Some also allow you to run "make test-installed" after you have
run "make install".
VIII. Configuring libpng for 16-bit platforms
You will want to look into zconf.h to tell zlib (and thus libpng) that
it cannot allocate more than 64K at a time. Even if you can, the memory
won't be accessible. So limit zlib and libpng to 64K by defining MAXSEG_64K.
IX. Configuring for DOS
For DOS users who only have access to the lower 640K, you will
have to limit zlib's memory usage via a png_set_compression_mem_level()
call. See zlib.h or zconf.h in the zlib library for more information.
X. Configuring for Medium Model
Libpng's support for medium model has been tested on most of the popular
compilers. Make sure MAXSEG_64K gets defined, USE_FAR_KEYWORD gets
defined, and FAR gets defined to far in pngconf.h, and you should be
all set. Everything in the library (except for zlib's structure) is
expecting far data. You must use the typedefs with the p or pp on
the end for pointers (or at least look at them and be careful). Make
note that the rows of data are defined as png_bytepp, which is
an "unsigned char far * far *".
XI. Prepending a prefix to exported symbols
Starting with libpng-1.6.0, you can configure libpng (when using the
"configure" script) to prefix all exported symbols by means of the
configuration option "--with-libpng-prefix=FOO_", where FOO_ can be any
string beginning with a letter and containing only uppercase
and lowercase letters, digits, and the underscore (i.e., a C language
identifier). This creates a set of macros in pnglibconf.h, so this is
transparent to applications; their function calls get transformed by
the macros to use the modified names.
XII. Configuring for compiler xxx:
All includes for libpng are in pngconf.h. If you need to add, change
or delete an include, this is the place to do it.
The includes that are not needed outside libpng are placed in pngpriv.h,
which is only used by the routines inside libpng itself.
The files in libpng proper only include pngpriv.h and png.h, which
in turn includes pngconf.h and, as of libpng-1.5.0, pnglibconf.h.
As of libpng-1.5.0, pngpriv.h also includes three other private header
files, pngstruct.h, pnginfo.h, and pngdebug.h, which contain material
that previously appeared in the public headers. As of libpng-1.7.0,
pngchunk.h is also included, and is used privately by pngrutil.c.
XIII. Removing unwanted object code
There are a bunch of #define's in pngconf.h that control what parts of
libpng are compiled. All the defines end in _SUPPORTED. If you are
never going to use a capability, you can change the #define to #undef
before recompiling libpng and save yourself code and data space, or
you can turn off individual capabilities with defines that begin with
"PNG_NO_".
In libpng-1.5.0 and later, the #define's are in pnglibconf.h instead.
You can also turn all of the transforms and ancillary chunk capabilities
off en masse with compiler directives that define
PNG_NO_READ[or WRITE]_TRANSFORMS, or PNG_NO_READ[or WRITE]_ANCILLARY_CHUNKS,
or all four, along with directives to turn on any of the capabilities that
you do want. The PNG_NO_READ[or WRITE]_TRANSFORMS directives disable the
extra transformations but still leave the library fully capable of reading
and writing PNG files with all known public chunks. Use of the
PNG_NO_READ[or WRITE]_ANCILLARY_CHUNKS directive produces a library
that is incapable of reading or writing ancillary chunks. If you are
not using the progressive reading capability, you can turn that off
with PNG_NO_PROGRESSIVE_READ (don't confuse this with the INTERLACING
capability, which you'll still have).
All the reading and writing specific code are in separate files, so the
linker should only grab the files it needs. However, if you want to
make sure, or if you are building a stand alone library, all the
reading files start with "pngr" and all the writing files start with "pngw".
The files that don't match either (like png.c, pngtrans.c, etc.)
are used for both reading and writing, and always need to be included.
The progressive reader is in pngpread.c
If you are creating or distributing a dynamically linked library (a .so
or DLL file), you should not remove or disable any parts of the library,
as this will cause applications linked with different versions of the
library to fail if they call functions not available in your library.
The size of the library itself should not be an issue, because only
those sections that are actually used will be loaded into memory.
XIV. Changes to the build and configuration of libpng in libpng-1.5.x
Details of internal changes to the library code can be found in the CHANGES
file and in the GIT repository logs. These will be of no concern to the vast
majority of library users or builders; however, the few who configure libpng
to a non-default feature set may need to change how this is done.
There should be no need for library builders to alter build scripts if
these use the distributed build support - configure or the makefiles -
however, users of the makefiles may care to update their build scripts
to build pnglibconf.h where the corresponding makefile does not do so.
Building libpng with a non-default configuration has changed completely.
The old method using pngusr.h should still work correctly even though the
way pngusr.h is used in the build has been changed; however, library
builders will probably want to examine the changes to take advantage of
new capabilities and to simplify their build system.
A. Specific changes to library configuration capabilities
The exact mechanism used to control attributes of API functions has
changed. A single set of operating system independent macro definitions
is used and operating system specific directives are defined in
pnglibconf.h
As part of this the mechanism used to choose procedure call standards on
those systems that allow a choice has been changed. At present this only
affects certain Microsoft (DOS, Windows) and IBM (OS/2) operating systems
running on Intel processors. As before, PNGAPI is defined where required
to control the exported API functions; however, two new macros, PNGCBAPI
and PNGCAPI, are used instead for callback functions (PNGCBAPI) and
(PNGCAPI) for functions that must match a C library prototype (currently
only png_longjmp_ptr, which must match the C longjmp function.) The new
approach is documented in pngconf.h
Despite these changes, libpng 1.5.0 only supports the native C function
calling standard on those platforms tested so far ("__cdecl" on Microsoft
Windows). This is because the support requirements for alternative
calling conventions seem to no longer exist. Developers who find it
necessary to set PNG_API_RULE to 1 should advise the mailing list
(png-mng-implement) of this and library builders who use Openwatcom and
therefore set PNG_API_RULE to 2 should also contact the mailing list.
B. Changes to the configuration mechanism
Prior to libpng-1.5.0 library builders who needed to configure libpng
had either to modify the exported pngconf.h header file to add system
specific configuration or had to write feature selection macros into
pngusr.h and cause this to be included into pngconf.h by defining
PNG_USER_CONFIG. The latter mechanism had the disadvantage that an
application built without PNG_USER_CONFIG defined would see the
unmodified, default, libpng API and thus would probably fail to link.
These mechanisms still work in the configure build and in any makefile
build that builds pnglibconf.h, although the feature selection macros
have changed somewhat as described above. In 1.5.0, however, pngusr.h is
processed only once, at the time the exported header file pnglibconf.h is
built. pngconf.h no longer includes pngusr.h; therefore, pngusr.h is ignored
after the build of pnglibconf.h and it is never included in an application
build.
The formerly used alternative of adding a list of feature macros to the
CPPFLAGS setting in the build also still works; however, the macros will be
copied to pnglibconf.h and this may produce macro redefinition warnings
when the individual C files are compiled.
All configuration now only works if pnglibconf.h is built from
scripts/pnglibconf.dfa. This requires the program awk. Brian Kernighan
(the original author of awk) maintains C source code of that awk and this
and all known later implementations (often called by subtly different
names - nawk and gawk for example) are adequate to build pnglibconf.h.
The Sun Microsystems (now Oracle) program 'awk' is an earlier version
and does not work; this may also apply to other systems that have a
functioning awk called 'nawk'.
Configuration options are now documented in scripts/pnglibconf.dfa. This
file also includes dependency information that ensures a configuration is
consistent; that is, if a feature is switched off, dependent features are
also switched off. As a recommended alternative to using feature macros in
pngusr.h a system builder may also define equivalent options in pngusr.dfa
(or, indeed, any file) and add that to the configuration by setting
DFA_XTRA to the file name. The makefiles in contrib/pngminim illustrate
how to do this, and also illustrate a case where pngusr.h is still required.
After you have built libpng, the definitions that were recorded in
pnglibconf.h are available to your application (pnglibconf.h is included
in png.h and gets installed alongside png.h and pngconf.h in your
$PREFIX/include directory). Do not edit pnglibconf.h after you have built
libpng, because than the settings would not accurately reflect the settings
that were used to build libpng.
XV. Setjmp/longjmp issues
Libpng uses setjmp()/longjmp() for error handling. Unfortunately setjmp()
is known to be not thread-safe on some platforms and we don't know of
any platform where it is guaranteed to be thread-safe. Therefore, if
your application is going to be using multiple threads, you should
configure libpng with PNG_NO_SETJMP in your pngusr.dfa file, with
-DPNG_NO_SETJMP on your compile line, or with
#undef PNG_SETJMP_SUPPORTED
in your pnglibconf.h or pngusr.h.
Starting with libpng-1.6.0, the library included a "simplified API".
This requires setjmp/longjmp, so you must either build the library
with PNG_SETJMP_SUPPORTED defined, or with PNG_SIMPLIFIED_READ_SUPPORTED
and PNG_SIMPLIFIED_WRITE_SUPPORTED undefined.
XVI. Common linking failures
If your application fails to find libpng or zlib entries while linking:
Be sure "-lz" appears after "-lpng" on your linking command.
Be sure you have built libpng, zlib, and your application for the
same platform (e.g., 32-bit or 64-bit).
If you are using the vstudio project, observe the WARNING in
project/vstudio/README.txt.
XVII. Other sources of information about libpng:
Further information can be found in the README and libpng-manual.txt
files, in the individual makefiles, in png.h, and the manual pages
libpng.3 and png.5.
Using the ./configure script -- 16 December 2002.
=================================================
The ./configure script should work compatibly with what scripts/makefile.*
did, however there are some options you might need to add to configure
explicitly, which previously was done semi-automatically (if you didn't edit
scripts/makefile.* yourself, that is)
CFLAGS="-Wall -O -funroll-loops \
-malign-loops=2 -malign-functions=2" ./configure --prefix=/usr/include \
--with-pkgconfigdir=/usr/lib/pkgconfig --includedir=/usr/include
You can alternatively specify --includedir=/usr/include, /usr/local/include,
/usr/include/libpng%NN%, or whatever.
If you find that the configure script is out-of-date or is not supporting
your platform properly, try running autogen.sh to regenerate "configure",
"Makefile.in", and the other configuration files. Then try configure again.
Copyright (c) 1998-2002,2006-2016 Glenn Randers-Pehrson
This document is released under the libpng license.
For conditions of distribution and use, see the disclaimer
and license in png.h.

81
LICENSE
View File

@ -10,21 +10,18 @@ this sentence.
This code is released under the libpng license.
libpng versions 1.2.6, August 15, 2004, through 1.6.0beta33, December 10, 2012, are
Copyright (c) 2004, 2006-2012 Glenn Randers-Pehrson, and are
distributed according to the same disclaimer and license as libpng-1.2.5
with the following individual added to the list of Contributing Authors
Cosmin Truta
libpng versions 1.0.7, July 1, 2000, through 1.2.5 - October 3, 2002, are
Copyright (c) 2000-2002 Glenn Randers-Pehrson, and are
distributed according to the same disclaimer and license as libpng-1.0.6
with the following individuals added to the list of Contributing Authors
libpng versions 1.0.7, July 1, 2000 through 1.7.0beta88, August 6, 2017 are
Copyright (c) 2000-2002, 2004, 2006-2017 Glenn Randers-Pehrson, are
derived from libpng-1.0.6, and are distributed according to the same
disclaimer and license as libpng-1.0.6 with the following individuals
added to the list of Contributing Authors:
Simon-Pierre Cadieux
Eric S. Raymond
Mans Rullgard
Cosmin Truta
Gilles Vollant
James Yu
and with the following additions to the disclaimer:
@ -35,19 +32,25 @@ and with the following additions to the disclaimer:
risk of satisfactory quality, performance, accuracy, and effort is with
the user.
Some files in the "contrib" directory and some configure-generated
files that are distributed with libpng have other copyright owners and
are released under other open source licenses.
libpng versions 0.97, January 1998, through 1.0.6, March 20, 2000, are
Copyright (c) 1998, 1999 Glenn Randers-Pehrson, and are
distributed according to the same disclaimer and license as libpng-0.96,
with the following individuals added to the list of Contributing Authors:
Copyright (c) 1998-2000 Glenn Randers-Pehrson, are derived from
libpng-0.96, and are distributed according to the same disclaimer and
license as libpng-0.96, with the following individuals added to the list
of Contributing Authors:
Tom Lane
Glenn Randers-Pehrson
Willem van Schaik
libpng versions 0.89, June 1996, through 0.96, May 1997, are
Copyright (c) 1996, 1997 Andreas Dilger
Distributed according to the same disclaimer and license as libpng-0.88,
with the following individuals added to the list of Contributing Authors:
Copyright (c) 1996-1997 Andreas Dilger, are derived from libpng-0.88,
and are distributed according to the same disclaimer and license as
libpng-0.88, with the following individuals added to the list of
Contributing Authors:
John Bowler
Kevin Bracey
@ -56,8 +59,11 @@ with the following individuals added to the list of Contributing Authors:
Greg Roelofs
Tom Tanner
Some files in the "scripts" directory have other copyright owners
but are released under this license.
libpng versions 0.5, May 1995, through 0.88, January 1996, are
Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.
Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
For the purposes of this copyright and license, "Contributing Authors"
is defined as the following set of individuals:
@ -80,13 +86,13 @@ Permission is hereby granted to use, copy, modify, and distribute this
source code, or portions hereof, for any purpose, without fee, subject
to the following restrictions:
1. The origin of this source code must not be misrepresented.
1. The origin of this source code must not be misrepresented.
2. Altered versions must be plainly marked as such and must not
be misrepresented as being the original source.
2. Altered versions must be plainly marked as such and must not
be misrepresented as being the original source.
3. This Copyright notice may not be removed or altered from any
source or altered source distribution.
3. This Copyright notice may not be removed or altered from any
source or altered source distribution.
The Contributing Authors and Group 42, Inc. specifically permit, without
fee, and encourage the use of this source code as a component to
@ -94,18 +100,31 @@ supporting the PNG file format in commercial products. If you use this
source code in a product, acknowledgment is not required but would be
appreciated.
END OF COPYRIGHT NOTICE, DISCLAIMER, and LICENSE.
A "png_get_copyright" function is available, for convenient use in "about"
boxes and the like:
TRADEMARK:
printf("%s",png_get_copyright(NULL));
The name "libpng" has not been registered by the Copyright owner
as a trademark in any jurisdiction. However, because libpng has
been distributed and maintained world-wide, continually since 1995,
the Copyright owner claims "common-law trademark protection" in any
jurisdiction where common-law trademark is recognized.
Also, the PNG logo (in PNG format, of course) is supplied in the
files "pngbar.png" and "pngbar.jpg (88x31) and "pngnow.png" (98x31).
OSI CERTIFICATION:
Libpng is OSI Certified Open Source Software. OSI Certified Open Source is a
certification mark of the Open Source Initiative.
Libpng is OSI Certified Open Source Software. OSI Certified Open Source is
a certification mark of the Open Source Initiative. OSI has not addressed
the additional disclaimers inserted at version 1.0.7.
EXPORT CONTROL:
The Copyright owner believes that the Export Control Classification
Number (ECCN) for libpng is EAR99, which means not subject to export
controls or International Traffic in Arms Regulations (ITAR) because
it is open source, publicly available software, that does not contain
any encryption software. See the EAR, paragraphs 734.3(b)(3) and
734.7(b).
Glenn Randers-Pehrson
glennrp at users.sourceforge.net
December 10, 2012
August 6, 2017

View File

@ -1,30 +1,80 @@
# Makefile.am:
# Source file for Makefile.in (and hence Makefile)
# Makefile.am, the source file for Makefile.in (and hence Makefile), is
#
# Copyright (c) 2004-2016 Glenn Randers-Pehrson
# Last changed in libpng 1.7.0 [(PENDING RELEASE)]
#
# This code is released under the libpng license.
# For conditions of distribution and use, see the disclaimer
# and license in png.h
PNGLIB_BASENAME= libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@
ACLOCAL_AMFLAGS = -I scripts
# test programs - run on make check, make distcheck
TESTS_ENVIRONMENT= srcdir=$(srcdir)
check_PROGRAMS= pngtest
check_PROGRAMS= pngtest pngunknown pngstest pngvalid pngimage pngcp
if HAVE_CLOCK_GETTIME
check_PROGRAMS += timepng
endif
# Utilities - installed
bin_PROGRAMS= pngfix png-fix-itxt
# This ensures that pnglibconf.h gets built at the start of 'make all' or
# 'make check', but it does not add dependencies to the individual programs,
# this is done below.
#
# IMPORTANT: always add the object modules of new programs to the list below
# because otherwise the sequence 'configure; make new-program' will *sometimes*
# result in the installed (system) pnglibconf.h being used and the result is
# always wrong and always very confusing.
BUILT_SOURCES = pnglibconf.h
pngtest_SOURCES = pngtest.c
pngtest_LDADD = libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@.la
TESTS = test-pngtest.sh
# Only do the following if the contrib directory is present.
check_PROGRAMS+= pngvalid pngstest pngunknown
pngvalid_SOURCES = contrib/libtests/pngvalid.c
pngstest_SOURCES = contrib/libtests/pngstest.c
pngunknown_SOURCES = contrib/libtests/pngunknown.c
pngvalid_LDADD = libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@.la
pngstest_SOURCES = contrib/libtests/pngstest.c
pngstest_LDADD = libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@.la
pngunknown_SOURCES = contrib/libtests/pngunknown.c
pngunknown_LDADD = libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@.la
TESTS += contrib/libtests/test-pngunknown.sh\
contrib/libtests/test-pngvalid-simple.sh\
contrib/libtests/test-pngvalid-full.sh\
contrib/libtests/test-pngstest.sh
pngimage_SOURCES = contrib/libtests/pngimage.c
pngimage_LDADD = libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@.la
pngfix_SOURCES = contrib/tools/pngfix.c
pngfix_LDADD = libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@.la
png_fix_itxt_SOURCES = contrib/tools/png-fix-itxt.c
timepng_SOURCES = contrib/libtests/timepng.c
timepng_LDADD = libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@.la
pngcp_SOURCES = contrib/tools/pngcp.c
pngcp_LDADD = libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@.la
# Generally these are single line shell scripts to run a test with a particular
# set of parameters:
TESTS =\
tests/pngtest\
tests/pngvalid-gamma-16-to-8 tests/pngvalid-gamma-alpha-mode\
tests/pngvalid-gamma-background tests/pngvalid-gamma-expand16-alpha-mode\
tests/pngvalid-gamma-expand16-background\
tests/pngvalid-gamma-expand16-transform tests/pngvalid-gamma-sbit\
tests/pngvalid-gamma-threshold tests/pngvalid-gamma-transform\
tests/pngvalid-progressive-size tests/pngvalid-size\
tests/pngvalid-progressive-interlace-standard\
tests/pngvalid-transform tests/pngvalid-interlace-transform\
tests/pngvalid-progressive-standard tests/pngvalid-standard\
tests/pngstest-1.8 tests/pngstest-1.8-alpha tests/pngstest-linear\
tests/pngstest-linear-alpha tests/pngstest-none tests/pngstest-none-alpha\
tests/pngstest-sRGB tests/pngstest-sRGB-alpha tests/pngunknown-IDAT\
tests/pngunknown-discard tests/pngunknown-if-safe tests/pngunknown-sAPI\
tests/pngunknown-sTER tests/pngunknown-save tests/pngunknown-vpAg\
tests/pngimage-quick tests/pngimage-full
# man pages
dist_man_MANS= libpng.3 libpngpf.3 png.5
@ -40,10 +90,15 @@ lib_LTLIBRARIES=libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@.la
libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_SOURCES = png.c pngerror.c\
pngget.c pngmem.c pngpread.c pngread.c pngrio.c pngrtran.c pngrutil.c\
pngset.c pngtrans.c pngwio.c pngwrite.c pngwtran.c pngwutil.c\
png.h pngconf.h pngdebug.h pnginfo.h pngpriv.h pngstruct.h pngusr.dfa
png.h pngconf.h pngdebug.h pnginfo.h pngpriv.h pngstruct.h pngchunk.h \
pngusr.dfa
if PNG_ARM_NEON
libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_SOURCES += arm/filter_neon.S
# Include libpng extensions, if appropriate. This uses a Makefile.am fragment,
# pre-set things that might be changed by addition:
AM_CPPFLAGS =
DFA_EXTENSION =
if LIBPNG_EXTENSIONS
include $(top_srcdir)/contrib/extensions.am
endif
nodist_libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_SOURCES = pnglibconf.h
@ -76,19 +131,22 @@ nodist_pkginclude_HEADERS= pnglibconf.h
pkgconfigdir = @pkgconfigdir@
pkgconfig_DATA = libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@.pc
#extra source distribution files.
# Extra source distribution files, '${srcdir}' is used below to stop build files
# from those directories being included. This only works if the configure is
# not done in the source directory!
EXTRA_DIST= \
ANNOUNCE CHANGES INSTALL LICENSE README TODO \
pngtest.png pngbar.png pngnow.png pngbar.jpg autogen.sh \
${srcdir}/contrib ${srcdir}/projects ${srcdir}/scripts \
$(TESTS) \
$(TESTS) $(XFAIL_TESTS) tests/pngstest \
CMakeLists.txt example.c libpng-manual.txt
SCRIPT_CLEANFILES=scripts/*.out scripts/*.chk scripts/pnglibconf.dfn
SCRIPT_CLEANFILES=scripts/*.out scripts/*.chk scripts/pnglibconf.c
CLEANFILES= *.tf? pngout.png libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@.pc \
libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@-config libpng.vers libpng.sym \
check.new pnglibconf.* pngprefix.h symbols.new pngtest-log.txt \
check.new pnglibconf.h pngprefix.h symbols.new pngtest-log.txt \
pnglibconf.out pnglibconf.c pnglibconf.dfn pnglibconf.pre \
$(SCRIPT_CLEANFILES)
MAINTAINERCLEANFILES = Makefile.in aclocal.m4 config.guess config.h.in \
@ -100,14 +158,14 @@ config.sub configure depcomp install-sh ltmain.sh missing
PNG_COPTS = @PNG_COPTS@
AM_CFLAGS = ${PNG_COPTS}
# DFNCPP is normally just CPP - the C preprocessor - but on Solaris and maybe
# other operating systems (NeXT?) the C preprocessor selected by configure
# DFNCPP is normally just "CPP -E" - the C preprocessor - but on Solaris and
# maybe other operating systems (NeXT?) the C preprocessor selected by configure
# checks input tokens for validity - effectively it performs part of the ANSI-C
# parsing - and therefore fails with the .df files. configure.ac has special
# checks for this and sets DFNCPP appropriately.
DFNCPP = @DFNCPP@
SUFFIXES = .chk .dfn .out
SUFFIXES = .chk .out
$(PNGLIB_BASENAME).pc: libpng.pc
cp libpng.pc $@
@ -118,6 +176,9 @@ $(PNGLIB_BASENAME)-config: libpng-config
scripts/sym.out scripts/vers.out: png.h pngconf.h pnglibconf.h
scripts/prefix.out: png.h pngconf.h pnglibconf.out
scripts/symbols.out: png.h pngconf.h $(srcdir)/scripts/pnglibconf.h.prebuilt
scripts/intprefix.out: pnglibconf.h
pnglibconf.out: config.h
libpng.sym: scripts/sym.out
rm -f $@
@ -130,7 +191,7 @@ if DO_PNG_PREFIX
# Rename functions in scripts/prefix.out with a PNG_PREFIX prefix.
# Rename macros in scripts/macro.lst from PNG_PREFIXpng_ to PNG_ (the actual
# implementation of the macro).
pnglibconf.h: pnglibconf.out scripts/prefix.out scripts/macro.lst
pnglibconf.h: pnglibconf.out scripts/prefix.out scripts/macro.lst config.h
rm -f $@
$(AWK) 's==0 && NR>1{print prev}\
s==0{prev=$$0}\
@ -156,14 +217,29 @@ endif
$(srcdir)/scripts/pnglibconf.h.prebuilt:
@echo "Attempting to build $@" >&2
@echo "This is a machine generated file, but if you want to make" >&2
@echo "a new one simply make 'scripts/pnglibconf.out' and copy that" >&2
@echo "a new one simply make 'scripts/pnglibconf.out', copy that" >&2
@echo "AND set PNG_ZLIB_VERNUM to 0 (you MUST do this)" >&2
@exit 1
# The following is necessary to ensure that the local pnglibconf.h is used, not
# an installed one (this can happen immediately after on a clean system if
# 'make test' is the first thing the user does.)
contrib/libtests/pngstest.o contrib/libtests/pngvalid.o pngtest.o: pnglibconf.h
# 'make test' is the first thing the user does.) Only files which include
# one of the png source files (typically png.h or pngpriv.h) need to be listed
# here:
pngtest.o: pnglibconf.h
contrib/libtests/makepng.o: pnglibconf.h
contrib/libtests/pngstest.o: pnglibconf.h
contrib/libtests/pngunknown.o: pnglibconf.h
contrib/libtests/pngimage.o: pnglibconf.h
contrib/libtests/pngvalid.o: pnglibconf.h
contrib/libtests/readpng.o: pnglibconf.h
contrib/libtests/tarith.o: pnglibconf.h
contrib/libtests/timepng.o: pnglibconf.h
contrib/tools/makesRGB.o: pnglibconf.h
contrib/tools/pngfix.o: pnglibconf.h
contrib/tools/pngcp.o: pnglibconf.h
# We must use -DPNG_NO_USE_READ_MACROS here even when the library may actually
# be built with PNG_USE_READ_MACROS; this prevents the read macros from
@ -177,24 +253,21 @@ if DO_PNG_PREFIX
SYMBOL_CFLAGS += -DPNG_PREFIX='@PNG_PREFIX@'
endif
.dfn.out:
rm -f $@ $*.c $*.tf[123]
test -d scripts || mkdir scripts
echo '#include "$<"' >$*.c
.c.out:
rm -f $@ $*.tf[12]
test -d scripts || mkdir scripts || test -d scripts
$(DFNCPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES)\
$(CPPFLAGS) $(SYMBOL_CFLAGS) $*.c > $*.tf1
$(SED) -n -e 's|^.*PNG_DEFN_MAGIC *-\(.*\)- *PNG_DEFN_END.*$$|\1|p'\
$*.tf1 >$*.tf2
$(SED) -e 's| *PNG_JOIN *||g' -e 's| *$$||' $*.tf2 >$*.tf3
rm -f $*.c $*.tf[12]
mv $*.tf3 $@
$(AM_CPPFLAGS) $(CPPFLAGS) $(SYMBOL_CFLAGS) $< > $*.tf1
$(AWK) -f "${srcdir}/scripts/dfn.awk" out="$*.tf2" $*.tf1 1>&2
rm -f $*.tf1
mv $*.tf2 $@
# The .dfn file for pnglibconf.h is machine generated
pnglibconf.dfn: scripts/pnglibconf.dfa scripts/options.awk pngconf.h pngusr.dfa $(DFA_XTRA)
# The .c file for pnglibconf.h is machine generated
pnglibconf.c: scripts/pnglibconf.dfa scripts/options.awk pngconf.h pngusr.dfa $(DFA_EXTENSION) $(DFA_XTRA)
rm -f $@ $*.tf[45]
$(AWK) -f ${srcdir}/scripts/options.awk out=$*.tf4 version=search\
${srcdir}/pngconf.h ${srcdir}/scripts/pnglibconf.dfa\
${srcdir}/pngusr.dfa $(DFA_XTRA) 1>&2
$(DFA_EXTENSION) ${srcdir}/pngusr.dfa $(DFA_XTRA) 1>&2
$(AWK) -f ${srcdir}/scripts/options.awk out=$*.tf5 $*.tf4 1>&2
rm $*.tf4
mv $*.tf5 $@
@ -210,10 +283,11 @@ scripts/symbols.chk: scripts/checksym.awk scripts/symbols.def scripts/symbols.ou
# used on demand to regenerate the standard header, CPPFLAGS should
# be empty - no non-standard defines
scripts/pnglibconf.dfn: scripts/pnglibconf.dfa scripts/options.awk pngconf.h
scripts/pnglibconf.c: scripts/pnglibconf.dfa scripts/options.awk pngconf.h
rm -f $@ pnglibconf.tf[67]
test -z "$(CPPFLAGS)"
echo "com @PNGLIB_VERSION@ STANDARD API DEFINITION" |\
test -z "$(CPPFLAGS)" -a -z "$(AM_CPPFLAGS)"
(echo "com libpng @PNGLIB_VERSION@ STANDARD API DEFINITION";\
echo "com") |\
$(AWK) -f ${srcdir}/scripts/options.awk out=pnglibconf.tf6\
logunsupported=1 version=search ${srcdir}/pngconf.h -\
${srcdir}/scripts/pnglibconf.dfa 1>&2
@ -222,7 +296,7 @@ scripts/pnglibconf.dfn: scripts/pnglibconf.dfa scripts/options.awk pngconf.h
rm pnglibconf.tf6
mv pnglibconf.tf7 $@
$(libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_OBJECTS): png.h pngconf.h \
$(libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_OBJECTS): png.h pngconf.h pngchunk.h \
pnglibconf.h pngpriv.h pngdebug.h pnginfo.h pngstruct.h pngprefix.h
test: check-am
@ -234,34 +308,76 @@ check: scripts/symbols.chk
dist-hook:
cd '$(top_distdir)'; rm -f $(SCRIPT_CLEANFILES)
# install the .../include headers as links to the new ones
install-data-hook:
cd $(DESTDIR)$(includedir); rm -f png.h pngconf.h pnglibconf.h
cd $(DESTDIR)$(includedir); $(LN_S) $(PNGLIB_BASENAME)/png.h png.h
cd $(DESTDIR)$(includedir); $(LN_S) $(PNGLIB_BASENAME)/pngconf.h \
pngconf.h
cd $(DESTDIR)$(includedir); $(LN_S) $(PNGLIB_BASENAME)/pnglibconf.h \
pnglibconf.h
cd $(DESTDIR)$(pkgconfigdir); rm -f libpng.pc
cd $(DESTDIR)$(pkgconfigdir); $(LN_S) $(PNGLIB_BASENAME).pc libpng.pc
# Make links between installed files with release-specific names and the generic
# file names. If this install rule is run the generic names will be deleted and
# recreated - this has obvious issues for systems with multiple installations.
# do evil things to libpng to cause libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@ to be used
install-exec-hook:
cd $(DESTDIR)$(bindir); rm -f libpng-config
cd $(DESTDIR)$(bindir); $(LN_S) $(PNGLIB_BASENAME)-config libpng-config
@set -x;\
cd $(DESTDIR)$(libdir);\
for ext in a la so so.@PNGLIB_MAJOR@@PNGLIB_MINOR@.@PNGLIB_RELEASE@ sl dylib dll.a; do\
rm -f libpng.$$ext;\
if test -f $(PNGLIB_BASENAME).$$ext; then\
$(LN_S) $(PNGLIB_BASENAME).$$ext libpng.$$ext;\
fi;\
install-header-links:
@set -ex; cd '$(DESTDIR)$(includedir)'; for f in $(HEADERS); do \
rm -f "$$f"; $(LN_S) "$(PNGLIB_BASENAME)/$$f" "$$f"; done
uninstall-header-links:
cd '$(DESTDIR)$(includedir)'; rm -f $(HEADERS)
install-libpng-pc:
@set -ex; cd '$(DESTDIR)$(pkgconfigdir)'; rm -f libpng.pc; \
$(LN_S) '$(PNGLIB_BASENAME).pc' libpng.pc
uninstall-libpng-pc:
rm -f '$(DESTDIR)$(pkgconfigdir)/libpng.pc'
# EXT_LIST is a list of the possibly library directory extensions, this exists
# because we can't find a good way of discovering the file extensions that are
# actually installed on a given system, so instead we check for every extension
# we have seen.
EXT_LIST = a dll.a so so.@PNGLIB_MAJOR@@PNGLIB_MINOR@.@PNGLIB_RELEASE@ la sl dylib
install-library-links:
@set -x; cd '$(DESTDIR)$(libdir)';\
for ext in $(EXT_LIST); do\
rm -f "libpng.$$ext";\
if test -f "$(PNGLIB_BASENAME).$$ext"; then\
$(LN_S) "$(PNGLIB_BASENAME).$$ext" "libpng.$$ext" || exit 1;\
fi;\
done
uninstall-hook:
cd $(DESTDIR)$(includedir); rm -f png.h pngconf.h pnglibconf.h
rm -f $(DESTDIR)$(pkgconfigdir)/libpng.pc
rm -f $(DESTDIR)$(bindir)/libpng-config
rm -f $(DESTDIR)$(libdir)/libpng.a
rm -f $(DESTDIR)$(libdir)/libpng.la
rm -f $(DESTDIR)$(libdir)/libpng.dll.a
uninstall-library-links:
@set -x; cd '$(DESTDIR)$(libdir)'; for ext in $(EXT_LIST); do\
rm -f "libpng.$$ext"; done
install-libpng-config:
@set -ex; cd '$(DESTDIR)$(bindir)'; rm -f libpng-config; \
$(LN_S) '$(PNGLIB_BASENAME)-config' libpng-config
uninstall-libpng-config:
rm -f '$(DESTDIR)$(bindir)/libpng-config'
if DO_INSTALL_LINKS
# If --enable-unversioned-links is specified the header and lib file links
# will be automatically made on a 'make install':
install-data-hook: install-header-links
uninstall-hook: uninstall-header-links
install-exec-hook: install-library-links
uninstall-hook: uninstall-library-links
endif
if DO_INSTALL_LIBPNG_PC
# Likewise, --install-pc causes libpng.pc to be constructed:
install-data-hook: install-libpng-pc
uninstall-hook: uninstall-libpng-pc
endif
if DO_INSTALL_LIBPNG_CONFIG
# And --install-config:
install-exec-hook: install-libpng-config
uninstall-hook: uninstall-libpng-config
endif
# The following addition ensures that 'make all' always builds the test programs
# too. It used to, but some change either in libpng or configure stopped this
# working.
all-am: $(check_PROGRAMS)

66
README
View File

@ -1,11 +1,11 @@
README for libpng version 1.6.0beta33 - December 10, 2012 (shared library 16.0)
README for libpng version 1.7.0beta88 - August 6, 2017 (shared library 17.0)
See the note about version numbers near the top of png.h
See INSTALL for instructions on how to install libpng.
Libpng comes in several distribution formats. Get libpng-*.tar.gz,
libpng-*.tar.xz or libpng-*.tar.bz2 if you want UNIX-style line endings
in the text files, or lpng*.zip if you want DOS-style line endings.
Libpng comes in several distribution formats. Get libpng-*.tar.gz or
libpng-*.tar.xz or if you want UNIX-style line endings in the text files,
or lpng*.7z or lpng*.zip if you want DOS-style line endings.
Version 0.89 was the first official release of libpng. Don't let the
fact that it's the first release fool you. The libpng library has been in
@ -23,18 +23,25 @@ earlier versions if you are using a shared library. The type of the
png_uint_32, which will affect shared-library applications that use
this function.
To avoid problems with changes to the internals of png_info_struct,
To avoid problems with changes to the internals of the png info_struct,
new APIs have been made available in 0.95 to avoid direct application
access to info_ptr. These functions are the png_set_<chunk> and
png_get_<chunk> functions. These functions should be used when
accessing/storing the info_struct data, rather than manipulating it
directly, to avoid such problems in the future.
It is important to note that the APIs do not make current programs
It is important to note that the APIs did not make current programs
that access the info struct directly incompatible with the new
library. However, it is strongly suggested that new programs use
the new APIs (as shown in example.c and pngtest.c), and older programs
be converted to the new format, to facilitate upgrades in the future.
library, through libpng-1.2.x. In libpng-1.4.x, which was meant to
be a transitional release, members of the png_struct and the
info_struct can still be accessed, but the compiler will issue a
warning about deprecated usage. Since libpng-1.5.0, direct access
to these structs is not allowed, and the definitions of the structs
reside in private pngstruct.h and pnginfo.h header files that are not
accessible to applications. It is strongly suggested that new
programs use the new APIs (as shown in example.c and pngtest.c), and
older programs be converted to the new format, to facilitate upgrades
in the future.
****
Additions since 0.90 include the ability to compile libpng as a
@ -77,17 +84,21 @@ compression library that is useful for more things than just PNG files.
You can use zlib as a drop-in replacement for fread() and fwrite() if
you are so inclined.
zlib should be available at the same place that libpng is, or at.
ftp://ftp.info-zip.org/pub/infozip/zlib
zlib should be available at the same place that libpng is, or at zlib.net.
You may also want a copy of the PNG specification. It is available
as an RFC, a W3C Recommendation, and an ISO/IEC Standard. You can find
these at http://www.libpng.org/pub/png/documents/
these at http://www.libpng.org/pub/png/pngdocs.html .
This code is currently being archived at libpng.sf.net in the
[DOWNLOAD] area, and on CompuServe, Lib 20 (PNG SUPPORT)
at GO GRAPHSUP. If you can't find it in any of those places,
e-mail me, and I'll help you find it.
This code is currently being archived at libpng.sourceforge.io in the
[DOWNLOAD] area, and at ftp://ftp-osl.osuosl.org/pub/libpng/src . If you
can't find it in any of those places, e-mail me, and I'll help you find it.
I am not a lawyer, but I believe that the Export Control Classification
Number (ECCN) for libpng is EAR99, which means not subject to export
controls or International Traffic in Arms Regulations (ITAR) because it
is open source, publicly available software, that does not contain any
encryption software. See the EAR, paragraphs 734.3(b)(3) and 734.7(b).
If you have any code changes, requests, problems, etc., please e-mail
them to me. Also, I'd appreciate any make files or project files,
@ -123,7 +134,7 @@ and ...". If in doubt, send questions to me. I'll bounce them
to others, if necessary.
Please do not send suggestions on how to change PNG. We have
been discussing PNG for sixteen years now, and it is official and
been discussing PNG for twenty years now, and it is official and
finished. If you have suggestions for libpng, however, I'll
gladly listen. Even if your suggestion is not used immediately,
it may be used later.
@ -149,6 +160,7 @@ Files in this distribution:
pngstruct.h => png_struct declaration (private)
pnginfo.h => png_info struct declaration (private)
pngdebug.h => debugging macros (private)
pngchunk.h => PNG chunk descriptions (private, new in libpng17)
pngerror.c => Error/warning message I/O functions
pngget.c => Functions for retrieving info from struct
pngmem.c => Memory handling functions
@ -167,23 +179,25 @@ Files in this distribution:
pngwrite.c => High-level write functions
pngwtran.c => Write data transformations
pngwutil.c => Write utility functions
arm => Contains optimized code for the ARM platform
contrib => Contributions
examples => Example programs
gregbook => source code for PNG reading and writing, from
Greg Roelofs' "PNG: The Definitive Guide",
O'Reilly, 1999
msvctest => Builds and runs pngtest using a MSVC workspace
pngminus => Simple pnm2png and png2pnm programs
pngsuite => Test images
visupng => Contains a MSVC workspace for VisualPng
libtests => Test programs
pngminim => Minimal decoder, encoder, and progressive decoder
programs demonstrating use of pngusr.dfa
pngminus => Simple pnm2png and png2pnm programs
pngsuite => Test images
tools => Various tools
visupng => Contains a MSVC workspace for VisualPng
projects => Contains project files and workspaces for
building a DLL
cbuilder5 => Contains a Borland workspace for building
libpng and zlib
visualc6 => Contains a Microsoft Visual C++ (MSVC)
workspace for building libpng and zlib
owatcom => Contains a WATCOM project for building libpng
visualc71 => Contains a Microsoft Visual C++ (MSVC)
workspace for building libpng and zlib
xcode => Contains an Apple xcode
vstudio => Contains a Microsoft Visual C++ (MSVC)
workspace for building libpng and zlib
scripts => Directory containing scripts for building libpng:
(see scripts/README.txt for the list of scripts)

8
TODO
View File

@ -5,7 +5,10 @@ Final bug fixes.
Better C++ wrapper/full C++ implementation?
Fix problem with C++ and EXTERN "C".
cHRM transformation.
Remove setjmp/longjmp usage in favor of returning error codes.
Remove setjmp/longjmp usage in favor of returning error codes. As a start on
this, minimize the use of png_error(), replacing them with
png_warning(); return(0); or similar.
Palette creation.
Add "grayscale->palette" transformation and "palette->grayscale" detection.
Improved dithering.
Multi-lingual error and warning message support.
@ -21,7 +24,8 @@ Use greater precision when changing to linear gamma for compositing against
background and doing rgb-to-gray transformation.
Investigate pre-incremented loop counters and other loop constructions.
Add interpolated method of handling interlacing.
Switch to the simpler zlib (zlib/libpng) license if legally possible.
Extend pngvalid.c to validate more of the libpng transformations.
Refactor preprocessor conditionals to compile entire statements
Quiet compiler warnings (mostly -Wconversion warnings).
*/

View File

@ -9,15 +9,15 @@
#
# For regular ("tarball") distributions all the files should exist. We do not
# want them to be updated *under any circumstances*. It should never be
# necessary to rune autogen.sh because ./configure --enable-maintainer-mode says
# what to do if Makeile.am or configure.ac are changed.
# necessary to run autogen.sh because ./configure --enable-maintainer-mode says
# what to do if Makefile.am or configure.ac are changed.
#
# It is *probably* OK to update the files on a GIT checkout, because they have
# come from the local tools, but leave that to the user who is assumed to know
# whether it is ok or required.
#
# This script is intended to work without arguments, there are, however, hidden
# arguments for (a) use while testing the script and (b) to fix up systems that
# arguments (a) for use while testing the script and (b) to fix up systems that
# have been broken. If (b) is required the script prompts for the correct
# options. For this reason the options are *NOT* documented in the help; this
# is deliberate; UTSL.
@ -73,8 +73,13 @@ done
# present bad things are happening.
#
# The autotools generated files:
libpng_autotools_files="Makefile.in aclocal.m4 config.guess config.h.in\
config.sub configure depcomp install-sh ltmain.sh missing"
libpng_autotools_files="Makefile.in aclocal.m4 config.guess config.h.in
config.sub configure depcomp install-sh ltmain.sh missing\
test-driver"
#
# Files generated by versions of configue >2.68 or automake >1.13 (i.e. later
# versions than those required by configure.ac):
libpng_autotools_extra="compile config.h.in~"
#
# These are separate because 'maintainer-clean' does not remove them.
libpng_libtool_files="scripts/libtool.m4 scripts/ltoptions.m4\
@ -94,6 +99,7 @@ libpng_configure_dirs=".deps"
# of Makefile. These functions do the two bits of cleaning.
clean_autotools(){
rm -rf $libpng_autotools_files $libpng_libtool_files $libpng_autotools_dirs
rm -rf $libpng_autotools_extra
}
clean_configure(){
@ -198,7 +204,7 @@ case "$mode" in
echo " You can run autoreconf yourself if you don't like maintainer"
echo " mode and you can also just run autoreconf -f -i to initialize"
echo " everything in the first place; this script is only for"
echo " compatiblity with prior releases."
echo " compatibility with prior releases."
exit 1
else
exec >&2

View File

@ -1,5 +1,13 @@
# configure.ac
# Copyright (c) 2004-2016 Glenn Randers-Pehrson
# Last changed in libpng 1.7.0 [(PENDING RELEASE)]
# This code is released under the libpng license.
# For conditions of distribution and use, see the disclaimer
# and license in png.h
dnl Process this file with autoconf to produce a configure script.
dnl
dnl Minor upgrades (compatible ABI): increment the package version
@ -18,7 +26,7 @@ AC_PREREQ([2.68])
dnl Version number stuff here:
AC_INIT([libpng],[1.6.0beta33],[png-mng-implement@lists.sourceforge.net])
AC_INIT([libpng],[1.7.0beta88],[png-mng-implement@lists.sourceforge.net])
AC_CONFIG_MACRO_DIR([scripts])
# libpng does not follow GNU file name conventions (hence 'foreign')
@ -26,9 +34,12 @@ AC_CONFIG_MACRO_DIR([scripts])
# silent-rules requires automake 1.11 or later
# dist-xz requires automake 1.11 or later
# 1.12.2 fixes a security issue in 1.11.2 and 1.12.1
AM_INIT_AUTOMAKE([1.12.2 foreign dist-xz dist-bzip2 color-tests silent-rules])
# was:
# AM_INIT_AUTOMAKE
# 1.13 is required for parallel tests
# 1.14.1 is required for %reldir% support
AM_INIT_AUTOMAKE([1.15 foreign dist-xz color-tests silent-rules subdir-objects])
# The following line causes --disable-maintainer-mode to be the default to
# configure. This is necessary because libpng distributions cannot rely on the
# time stamps of the autotools generated files being correct
AM_MAINTAINER_MODE
dnl configure.ac and Makefile.am expect automake 1.11.2 or a compatible later
@ -37,9 +48,9 @@ dnl automake, so the following is not necessary (and is not defined anyway):
dnl AM_PREREQ([1.11.2])
dnl stop configure from automagically running automake
PNGLIB_VERSION=1.6.0beta33
PNGLIB_VERSION=1.7.0beta88
PNGLIB_MAJOR=1
PNGLIB_MINOR=6
PNGLIB_MINOR=7
PNGLIB_RELEASE=0
dnl End of version number stuff
@ -53,41 +64,33 @@ AC_PROG_CC
AM_PROG_AS
LT_PATH_LD
AC_PROG_CPP
AC_CHECK_TOOL(SED, sed, :)
AC_CHECK_TOOL(AWK, awk, :)
AC_PROG_AWK
AC_PROG_INSTALL
AC_PROG_LN_S
AC_PROG_MAKE_SET
dnl libtool/libtoolize; version 2.4.2 is the tested version, this or any
dnl libtool/libtoolize; version 2.4.4 is the tested version, this or any
dnl compatible later version may be used
LT_INIT([win32-dll])
LT_PREREQ([2.4.2])
LT_PREREQ([2.4.4])
# On Solaris 10 and 12 CPP gets set to cc -E, however this still
# does some input parsing. We need strict ANSI-C style tokenization,
# check this:
AC_REQUIRE_CPP
AC_MSG_CHECKING([for a C preprocessor that does not parse its input])
AC_PREPROC_IFELSE([AC_LANG_SOURCE([[1.1.1 16BIT]])],
[DFNCPP="$CPP"],
[ DFNCPP=""
sav_CPP="$CPP"
for CPP in "${CC-cc} -E" "${CC-cc} -E -traditional-cpp" "/lib/cpp" "cpp"
do
AC_PREPROC_IFELSE([AC_LANG_SOURCE([[1.1.1 16BIT]])],
[DFNCPP="$CPP"]
[break],,)
done
CPP="$sav_CPP"
])
if test -n "$DFNCPP"; then
AC_MSG_RESULT([$DFNCPP])
AC_SUBST(DFNCPP)
# Some awks crash when confronted with pnglibconf.dfa, do a test run now
# to make sure this doesn't happen
AC_MSG_CHECKING([that AWK works])
if ${AWK} -f ${srcdir}/scripts/options.awk out="/dev/null" version=search\
${srcdir}/pngconf.h ${srcdir}/scripts/pnglibconf.dfa\
${srcdir}/pngusr.dfa 1>&2
then
AC_MSG_RESULT([ok])
else
AC_MSG_FAILURE([not found], 1)
AC_MSG_FAILURE([failed], 1)
fi
# This is a remnant of the old cc -E validation, where it may have been
# necessary to use a different preprocessor for .dfn files
DFNCPP="$CPP -E"
AC_SUBST(DFNCPP)
# -Werror cannot be passed to GCC in CFLAGS because configure will fail (it
# checks the compiler with a program that generates a warning), add the
# following option to deal with this
@ -115,31 +118,151 @@ AC_ARG_ENABLE(werror,
# Checks for header files.
AC_HEADER_STDC
AC_CHECK_HEADERS([malloc.h stdlib.h string.h strings.h])
# Headers used in pngpriv.h:
AC_CHECK_HEADERS([assert.h stdlib.h string.h float.h fp.h math.h m68881.h])
# Additional headers used in pngconf.h:
AC_CHECK_HEADERS([limits.h stddef.h stdio.h setjmp.h time.h])
# Used by pngread.c (for the simplified API):
AC_CHECK_HEADERS([errno.h])
# The following are not required for the standard 'make' build of libpng:
# Additional requirements of contrib/libtests/makepng.c:
AC_CHECK_HEADERS([ctype.h])
# Additional requirements of contrib/libtests/pngvalid.c:
AC_CHECK_HEADERS([fenv.h])
# Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST
AC_TYPE_SIZE_T
AC_STRUCT_TM
# Most of these have been removed from 1.7.0 because they checked for non-ANSI-C
# behaviors and the result were, anyway, not used by earlier versions of libpng.
AC_C_RESTRICT
# Checks for library functions.
AC_FUNC_STRTOD
AC_CHECK_FUNCS([memset], , AC_MSG_ERROR(memset not found in libc))
AC_CHECK_FUNCS([pow], , AC_CHECK_LIB(m, pow, , AC_MSG_ERROR(cannot find pow)) )
AC_ARG_WITH(zlib-prefix,
AS_HELP_STRING([[[--with-zlib-prefix]]],
[prefix that may have been used in installed zlib]),
[ZPREFIX=${withval}],
[ZPREFIX='z_'])
AC_CHECK_LIB(z, zlibVersion, ,
AC_CHECK_LIB(z, ${ZPREFIX}zlibVersion, , AC_MSG_ERROR(zlib not installed)))
# Checks for library functions; these need to be in order, least demanding to
# most because the -l directives are added to the head of the list at each
# check.
# ANSI-C functions: all are required but they don't have to be implemented in
# libc, it is perfectly ok to configure with an extra, wrapper, library preset
# in LIBS. NOTE: this list may not be complete
AC_CHECK_FUNCS([memset memcpy strncpy],,
AC_MSG_FAILURE([missing ANSI-C functions]))
# Some later POSIX 1003.1 functions are required for test programs, failure here
# is soft (the corresponding test program is not built).
AC_CHECK_FUNC([clock_gettime],,[AC_MSG_WARN([not building timepng])])
AM_CONDITIONAL([HAVE_CLOCK_GETTIME], [test "$ac_cv_func_clock_gettime" = "yes"])
# floor and ceil are required for FLOATING_POINT, but they can be turned off on
# the configure command line (and they are independent.) Default is to 'on'
AC_ARG_ENABLE([floating-point],
AS_HELP_STRING([[[--enabled-floating-point]]],
[Enable floating point APIs (default: yes)]),,
[enable_floating_point=yes])
AC_ARG_ENABLE([fixed-point],
AS_HELP_STRING([[[--enable-fixed-point]]],
[Enable fixed point APIs (default: yes)]),,
[enable_fixed_point=yes])
AC_ARG_ENABLE([floating-arithmetic],
AS_HELP_STRING([[[--enable-floating-arithmetic]]],
[Use floating point arithmetic internally (default: yes)]),,
[enable_floating_arithmetic=yes])
# Check for a requirement for math library support
if test "$enable_floating_arithmetic" = yes
then
AC_SEARCH_LIBS([floor],[m],,
[AC_MSG_WARN([not found])
enable_floating_arithmetic=no])
AC_SEARCH_LIBS([frexp],[m],,
[AC_MSG_WARN([not found])
enable_floating_arithmetic=no])
AC_SEARCH_LIBS([modf],[m],,
[AC_MSG_WARN([not found])
enable_floating_arithmetic=no])
AC_SEARCH_LIBS([atof],[m],,
[AC_MSG_WARN([not found])
enable_floating_arithmetic=no])
AC_SEARCH_LIBS([pow],[m],,
[AC_MSG_WARN([not found])
enable_floating_arithmetic=no])
fi
# Set the relevant defines if required (only if required). This will override
# anything on the command line.
if test "$enable_floating_point" != yes
then
AC_MSG_NOTICE([Floating point APIs disabled])
AC_DEFINE([PNG_NO_FLOATING_POINT],[1],
[No support for floating point APIs])
fi
if test "$enable_fixed_point" != yes
then
AC_MSG_NOTICE([Fixed point APIs disabled])
AC_DEFINE([PNG_NO_FIXED_POINT],[1],
[No support for fixed point APIs])
fi
if test "$enable_floating_arithmetic" != yes
then
AC_MSG_NOTICE([Fixed point arithmetic will be used])
AC_DEFINE([PNG_NO_FLOATING_ARITHMETIC],[1],
[No support for floating point arithmetic])
fi
# The following is for pngvalid, to ensure it catches FP errors even on
# platforms that don't enable FP exceptions, the function appears in the math
# library (typically), it's not an error if it is not found.
AC_CHECK_LIB([m], [feenableexcept])
AC_CHECK_FUNCS([feenableexcept])
AC_SEARCH_LIBS([feenableexcept],[m],AC_DEFINE([HAVE_FEENABLEEXCEPT],[1],
[Define to 1 if the feenableexcept function is available]))
# Required by pngvalid:
AC_SEARCH_LIBS([ceil],[m])
# zlib checks and arguments;
# package zlib: argument is the name of the library
# zlib-header: the name of the header file
# zlib-prefix: the prefix for library functions, if any
AC_ARG_WITH([zlib],
AS_HELP_STRING([[[--with-zlib=<name>]]],
[base name of the zlib implementation (e.g. 'z')]),,
[with_zlib='z'])
z_prefix=
AC_ARG_WITH([zlib-prefix],
AS_HELP_STRING([[[--with-zlib-prefix=<prefix>]]],
[prefix for zlib API functions]),
[if test "$withval" = "" -o "$withval" = yes; then
with_zlib_prefix='z_'
AC_DEFINE([PNG_ZLIB_PREFIX],[z_],[Standard zlib prefix])
elif test "${withval}" != "no"; then
AC_DEFINE_UNQUOTED([PNG_ZLIB_PREFIX],[${withval}],
[User defined zlib prefix])
else
with_zlib_prefix=
fi
if test "$with_zlib_prefix" != ""; then
AC_DEFINE([Z_PREFIX],[1],[Tell zlib.h to prefix function names])
z_prefix="#define Z_PREFIX 1"
fi])
AC_ARG_WITH([zlib-header],
AS_HELP_STRING([[[--with-zlib-header='<file>' or '"file"']]],
[C include argument to locate zlib header file, e.g. <zlib.h>, take
care to put single quotes round this on the command line]),
[AC_DEFINE_UNQUOTED([PNG_ZLIB_HEADER],[${withval}],[Zlib header file])],
with_zlib_header='<zlib.h>')
# AC_CHECK_LIB isn't quite enough for this because we need the special header
# file too.
LIBS="-l${with_zlib} $LIBS"
AC_MSG_CHECKING(
[[Library '${with_zlib}' and #include ${with_zlib_header} for symbol '${with_zlib_prefix}zlibVersion']])
AC_LINK_IFELSE(
[AC_LANG_PROGRAM(
[[
${z_prefix}
#include ${with_zlib_header}
]],
[[(void)${with_zlib_prefix}zlibVersion();]])],
AC_MSG_RESULT([ok]),
AC_MSG_FAILURE([not found]))
AC_MSG_CHECKING([if using Solaris linker])
SLD=`$LD --version 2>&1 | grep Solaris`
@ -185,7 +308,7 @@ AM_CONDITIONAL(HAVE_LD_VERSION_SCRIPT, test "$have_ld_version_script" = "yes")
if test "$have_ld_version_script" = "yes"; then
AC_MSG_CHECKING([for symbol prefix])
SYMBOL_PREFIX=`echo "PREFIX=__USER_LABEL_PREFIX__" \
| ${CPP-${CC-gcc} -E} - 2>&1 \
| ${DFNCPP-${CC-gcc -E}} - 2>&1 \
| ${EGREP-grep} "^PREFIX=" \
| ${SED-sed} -e "s:^PREFIX=::" -e "s:__USER_LABEL_PREFIX__::"`
AC_SUBST(SYMBOL_PREFIX)
@ -233,24 +356,55 @@ AC_ARG_WITH(libpng-prefix,
fi])
AM_CONDITIONAL([DO_PNG_PREFIX], [test "${with_libpng_prefix:-no}" != "no"])
# Because GCC by default assembles code with an executable stack, even though it
# compiles C code with a non-executable stack, it is necessary to do a fixup
# here (this may by GCC specific)
AC_SUBST([AM_CCASFLAGS], [-Wa,--noexecstack])
# Control over what links are made for installed files. Versioned files are
# always installed, when the following options are turned on corresponding
# unversioned links are also created (normally as symbolic links):
AC_ARG_ENABLE([unversioned-links],
AS_HELP_STRING([[[--enable-unversioned-links]]],
[Installed libpng header files are placed in a versioned subdirectory]
[and installed libpng library (including DLL) files are versioned.]
[If this option is enabled unversioned links will be created pointing to]
[the corresponding installed files. If you use libpng.pc or]
[libpng-config for all builds you do not need these links, but if you]
[compile programs directly they will typically #include <png.h> and]
[link with -lpng; in that case you need the links.]
[The links can be installed manually using 'make install-header-links']
[and 'make install-library-links' and can be removed using the]
[corresponding uninstall- targets. If you do enable this option every]
[libpng 'make install' will recreate the links to point to the just]
[installed version of libpng. The default is to create the links;]
[use --disable-unversioned-links to change this]))
AC_ARG_ENABLE([arm-neon],
AS_HELP_STRING([[[--enable-arm-neon]]], [Enable ARM NEON optimizations]),
[if test "${enableval}" = "yes"; then
AC_DEFINE([PNG_ARM_NEON], [1], [Enable ARM NEON optimizations])
AC_DEFINE([PNG_ALIGNED_MEMORY_SUPPORTED], [1], [Align row buffers])
fi])
AM_CONDITIONAL([PNG_ARM_NEON], [test "${enable_arm_neon:-no}" = yes])
# The AM_CONDITIONAL test is written so that the default is enabled;
# --disable-unversioned-links must be given to turn the option off.
AM_CONDITIONAL([DO_INSTALL_LINKS],[test "$enable_unversioned_links" != "no"])
AC_ARG_ENABLE([unversioned-libpng-pc],
AS_HELP_STRING([[[--enable-unversioned-libpng-pc]]],
[Install the configuration file 'libpng.pc' as a link to the versioned]
[version. This is done by default - use --disable-unversioned-libpng-pc]
[to change this.]))
AM_CONDITIONAL([DO_INSTALL_LIBPNG_PC],
[test "$enable_unversioned_libpng_pc" != "no"])
AC_ARG_ENABLE([unversioned-libpng-config],
AS_HELP_STRING([[[--enable-unversioned-libpng-config]]],
[Install the configuration file 'libpng-config' as a link to the]
[versioned version. This is done by default - use]
[--disable-unversioned-libpng-config to change this.]))
AM_CONDITIONAL([DO_INSTALL_LIBPNG_CONFIG],
[test "$enable_unversioned_libpng_config" != "no"])
# EXTENSIONS
# Configure (and all other) support for extensions is included when autoconf is
# run by virtue of the existence (or not) of the following file:
sinclude([contrib/extensions.ac])
AM_CONDITIONAL([LIBPNG_EXTENSIONS],[test -n "$libpng_automake_extensions"])
AC_MSG_NOTICE([[Extra options for compiler: $PNG_COPTS]])
# Config files, substituting as above
AC_CONFIG_FILES([Makefile libpng.pc:libpng.pc.in])
AC_CONFIG_FILES([libpng-config:libpng-config.in],
[chmod +x libpng-config])
AC_CONFIG_FILES([Makefile libpng.pc])
AC_CONFIG_FILES([libpng-config], [chmod +x libpng-config])
AC_OUTPUT

View File

@ -1,4 +1,5 @@
This "contrib" directory contains contributions which are not necessarily under
the libpng license, although all are open source. They are not part of
libpng proper and are not used for building the library.
libpng proper and are not used for building the library, although some are used
for testing the library via "make check".

83
contrib/arm-neon/README Normal file
View File

@ -0,0 +1,83 @@
OPERATING SYSTEM SPECIFIC ARM NEON DETECTION
--------------------------------------------
Detection of the ability to execute ARM NEON on an ARM processor requires
operating system support. (The information is not available in user mode.)
HOW TO USE THIS
---------------
This directory contains C code fragments that can be included in arm/arm_init.c
by setting the macro PNG_ARM_NEON_FILE to the file name in "" or <> at build
time. This setting is not recorded in pnglibconf.h and can be changed simply by
rebuilding arm/arm_init.o with the required macro definition.
For any of this code to be used the ARM NEON code must be enabled and run time
checks must be supported. I.e.:
#if PNG_ARM_NEON_OPT > 0
#ifdef PNG_ARM_NEON_CHECK_SUPPORTED
This is done in a 'configure' build by passing configure the argument:
--enable-arm-neon=check
Apart from the basic Linux implementation in contrib/arm-neon/linux.c this code
is unsupported. That means that it is not even compiled on a regular basis and
may be broken in any given minor release.
FILE FORMAT
-----------
Each file documents its testing status as of the last time it was tested (which
may have been a long time ago):
STATUS: one of:
SUPPORTED: This indicates that the file is included in the regularly
performed test builds and bugs are fixed when discovered.
COMPILED: This indicates that the code did compile at least once. See the
more detailed description for the extent to which the result was
successful.
TESTED: This means the code was fully compiled into the libpng test programs
and these were run at least once.
BUG REPORTS: an email address to which to send reports of problems
The file is a fragment of C code. It should not define any 'extern' symbols;
everything should be static. It must define the function:
static int png_have_neon(png_structp png_ptr);
That function must return 1 if ARM NEON instructions are supported, 0 if not.
It must not execute png_error unless it detects a bug. A png_error will prevent
the reading of the PNG and in the future, writing too.
BUG REPORTS
-----------
If you mail a bug report for any file that is not SUPPORTED there may only be
limited response. Consider fixing it and sending a patch to fix the problem -
this is more likely to result in action.
CONTRIBUTIONS
-------------
You may send contributions of new implementations to
png-mng-implement@sourceforge.net. Please write code in strict C90 C where
possible. Obviously OS dependencies are to be expected. If you submit code you
must have the authors permission and it must have a license that is acceptable
to the current maintainer; in particular that license must permit modification
and redistribution.
Please try to make the contribution a single file and give the file a clear and
unambiguous name that identifies the target OS. If multiple files really are
required put them all in a sub-directory.
You must also be prepared to handle bug reports from users of the code, either
by joining the png-mng-implement mailing list or by providing an email for the
"BUG REPORTS" entry or both. Please make sure that the header of the file
contains the STATUS and BUG REPORTS fields as above.
Please list the OS requirements as precisely as possible. Ideally you should
also list the environment in which the code has been tested and certainly list
any environments where you suspect it might not work.

View File

@ -0,0 +1,39 @@
/* contrib/arm-neon/android-ndk.c
*
* Copyright (c) 2014 Glenn Randers-Pehrson
* Written by John Bowler, 2014.
* Last changed in libpng 1.6.10 [March 6, 2014]
*
* This code is released under the libpng license.
* For conditions of distribution and use, see the disclaimer
* and license in png.h
*
* SEE contrib/arm-neon/README before reporting bugs
*
* STATUS: COMPILED, UNTESTED
* BUG REPORTS: png-mng-implement@sourceforge.net
*
* png_have_neon implemented for the Android NDK, see:
*
* Documentation:
* http://www.kandroid.org/ndk/docs/CPU-ARM-NEON.html
* https://code.google.com/p/android/issues/detail?id=49065
*
* NOTE: this requires that libpng is built against the Android NDK and linked
* with an implementation of the Android ARM 'cpu-features' library. The code
* has been compiled only, not linked: no version of the library has been found,
* only the header files exist in the NDK.
*/
#include <cpu-features.h>
static int
png_have_neon(png_structp png_ptr)
{
/* This is a whole lot easier than the linux code, however it is probably
* implemented as below, therefore it is better to cache the result (these
* function calls may be slow!)
*/
PNG_UNUSED(png_ptr)
return android_getCpuFamily() == ANDROID_CPU_FAMILY_ARM &&
(android_getCpuFeatures() & ANDROID_CPU_ARM_FEATURE_NEON) != 0;
}

View File

@ -0,0 +1,120 @@
/* contrib/arm-neon/linux-auxv.c
*
* Copyright (c) 2014 Glenn Randers-Pehrson
* Written by Mans Rullgard, 2011.
* Last changed in libpng 1.6.10 [March 6, 2014]
*
* This code is released under the libpng license.
* For conditions of distribution and use, see the disclaimer
* and license in png.h
*
* SEE contrib/arm-neon/README before reporting bugs
*
* STATUS: COMPILED, TESTED
* BUG REPORTS: png-mng-implement@sourceforge.net
*
* png_have_neon implemented for Linux versions which allow access to
* /proc/self/auxv. This is probably faster, cleaner and safer than the code to
* read /proc/cpuinfo in contrib/arm-neon/linux, however it is yet another piece
* of potentially untested code and has more complex dependencies than the code
* to read cpuinfo.
*
* This generic __linux__ implementation requires reading /proc/self/auxv and
* looking at each element for one that records NEON capabilities.
*/
#include <unistd.h> /* for POSIX 1003.1 */
#include <errno.h> /* for EINTR */
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <elf.h>
#include <asm/hwcap.h>
/* A read call may be interrupted, in which case it returns -1 and sets errno to
* EINTR if nothing was done, otherwise (if something was done) a partial read
* may result.
*/
static size_t
safe_read(png_structp png_ptr, int fd, void *buffer_in, size_t nbytes)
{
size_t ntotal = 0;
char *buffer = png_voidcast(char*, buffer_in);
while (nbytes > 0)
{
unsigned int nread;
int iread;
/* Passing nread > INT_MAX to read is implementation defined in POSIX
* 1003.1, therefore despite the unsigned argument portable code must
* limit the value to INT_MAX!
*/
if (nbytes > INT_MAX)
nread = INT_MAX;
else
nread = (unsigned int)/*SAFE*/nbytes;
iread = read(fd, buffer, nread);
if (iread == -1)
{
/* This is the devil in the details, a read can terminate early with 0
* bytes read because of EINTR, yet it still returns -1 otherwise end
* of file cannot be distinguished.
*/
if (errno != EINTR)
{
png_warning(png_ptr, "/proc read failed");
return 0; /* I.e., a permanent failure */
}
}
else if (iread < 0)
{
/* Not a valid 'read' result: */
png_warning(png_ptr, "OS /proc read bug");
return 0;
}
else if (iread > 0)
{
/* Continue reading until a permanent failure, or EOF */
buffer += iread;
nbytes -= (unsigned int)/*SAFE*/iread;
ntotal += (unsigned int)/*SAFE*/iread;
}
else
return ntotal;
}
return ntotal; /* nbytes == 0 */
}
static int
png_have_neon(png_structp png_ptr)
{
int fd = open("/proc/self/auxv", O_RDONLY);
Elf32_auxv_t aux;
/* Failsafe: failure to open means no NEON */
if (fd == -1)
{
png_warning(png_ptr, "/proc/self/auxv open failed");
return 0;
}
while (safe_read(png_ptr, fd, &aux, sizeof aux) == sizeof aux)
{
if (aux.a_type == AT_HWCAP && (aux.a_un.a_val & HWCAP_NEON) != 0)
{
close(fd);
return 1;
}
}
close(fd);
return 0;
}

161
contrib/arm-neon/linux.c Normal file
View File

@ -0,0 +1,161 @@
/* contrib/arm-neon/linux.c
*
* Copyright (c) 2014 Glenn Randers-Pehrson
* Written by John Bowler, 2014.
* Last changed in libpng 1.6.16 [December 22, 2014]
*
* This code is released under the libpng license.
* For conditions of distribution and use, see the disclaimer
* and license in png.h
*
* SEE contrib/arm-neon/README before reporting bugs
*
* STATUS: SUPPORTED
* BUG REPORTS: png-mng-implement@sourceforge.net
*
* png_have_neon implemented for Linux by reading the widely available
* pseudo-file /proc/cpuinfo.
*
* This code is strict ANSI-C and is probably moderately portable; it does
* however use <stdio.h> and it assumes that /proc/cpuinfo is never localized.
*/
#include <stdio.h>
static int
png_have_neon(png_structp png_ptr)
{
FILE *f = fopen("/proc/cpuinfo", "rb");
if (f != NULL)
{
/* This is a simple state machine which reads the input byte-by-byte until
* it gets a match on the 'neon' feature or reaches the end of the stream.
*/
static const char ch_feature[] = { 70, 69, 65, 84, 85, 82, 69, 83 };
static const char ch_neon[] = { 78, 69, 79, 78 };
enum
{
StartLine, Feature, Colon, StartTag, Neon, HaveNeon, SkipTag, SkipLine
} state;
int counter;
for (state=StartLine, counter=0;;)
{
int ch = fgetc(f);
if (ch == EOF)
{
/* EOF means error or end-of-file, return false; neon at EOF is
* assumed to be a mistake.
*/
fclose(f);
return 0;
}
switch (state)
{
case StartLine:
/* Match spaces at the start of line */
if (ch <= 32) /* skip control characters and space */
break;
counter=0;
state = Feature;
/* FALL THROUGH */
case Feature:
/* Match 'FEATURE', ASCII case insensitive. */
if ((ch & ~0x20) == ch_feature[counter])
{
if (++counter == (sizeof ch_feature))
state = Colon;
break;
}
/* did not match 'feature' */
state = SkipLine;
/* FALL THROUGH */
case SkipLine:
skipLine:
/* Skip everything until we see linefeed or carriage return */
if (ch != 10 && ch != 13)
break;
state = StartLine;
break;
case Colon:
/* Match any number of space or tab followed by ':' */
if (ch == 32 || ch == 9)
break;
if (ch == 58) /* i.e. ':' */
{
state = StartTag;
break;
}
/* Either a bad line format or a 'feature' prefix followed by
* other characters.
*/
state = SkipLine;
goto skipLine;
case StartTag:
/* Skip space characters before a tag */
if (ch == 32 || ch == 9)
break;
state = Neon;
counter = 0;
/* FALL THROUGH */
case Neon:
/* Look for 'neon' tag */
if ((ch & ~0x20) == ch_neon[counter])
{
if (++counter == (sizeof ch_neon))
state = HaveNeon;
break;
}
state = SkipTag;
/* FALL THROUGH */
case SkipTag:
/* Skip non-space characters */
if (ch == 10 || ch == 13)
state = StartLine;
else if (ch == 32 || ch == 9)
state = StartTag;
break;
case HaveNeon:
/* Have seen a 'neon' prefix, but there must be a space or new
* line character to terminate it.
*/
if (ch == 10 || ch == 13 || ch == 32 || ch == 9)
{
fclose(f);
return 1;
}
state = SkipTag;
break;
default:
png_error(png_ptr, "png_have_neon: internal error (bug)");
}
}
}
#ifdef PNG_WARNINGS_SUPPORTED
else
png_warning(png_ptr, "/proc/cpuinfo open failed");
#endif
return 0;
}

49
contrib/conftest/README Normal file
View File

@ -0,0 +1,49 @@
This directory contains test configuration files, currently always '.dfa' files
intended to be used in the build by setting the make macro DFA_XTRA to the name
of the file.
These files are used in release validation of the 'configure' builds of libpng
by building 'make check', or 'make all-am' for cross-builds, with each .dfa
file.
The files in this directory may change between minor releases, however
contributions describing specific builds of libpng are welcomed. There is no
guarantee that libpng will continue to build with such configurations; support
for given configurations can be, and has been, dropped between successive minor
releases. However if a .dfa file describing a configuration is not in this
directory it is very unlikely that it will be tested before a minor release!
You can use these .dfa files as the basis of new configurations. Files in this
directory should not have any use restrictions or restrictive licenses.
This directory is not included in the .zip and .7z distributions, which do
not contain 'configure' scripts.
DOCUMENTATION
=============
Examples:
${srcdir}/pngusr.dfa
${srcdir}/contrib/pngminim/*/pngusr.dfa
Documentation of the options:
${srcdir}/scripts/pnglibconf.dfa
Documentation of the file format:
${srcdir}/scripts/options.awk
FILE NAMING
===========
File names in this directory may NOT contain any of the five characters:
- , + * ?
Neither may they contain any space character.
While other characters may be used it is strongly suggested that file names be
limited to lower case Latiin alphabetic characters (a-z), digits (0-9) and, if
necessary the underscore (_) character. File names should be about 8 characters
long (excluding the .dfa extension). Submitted .dfa files should have names
between 7 and 16 characters long, shorter names (6 characters or less) are
reserved for standard tests.

View File

@ -0,0 +1,38 @@
# pngcp.dfa
# Build time configuration of libpng
#
# Author: John Bowler
# Copyright: (c) John Bowler, 2016
# Usage rights:
# To the extent possible under law, the author has waived all copyright and
# related or neighboring rights to this work. This work is published from:
# United States.
#
# Build libpng with support for pngcp. This means just png_read_png,
# png_write_png and small number of configuration settings.
#
everything = off
# Options to turn on png_read_png and png_write_png:
option WRITE_PNG on
option READ_PNG on
option EASY_ACCESS on
option WRITE_16BIT on
option SELECT_FILTER on
# pngcp needs this to preserve unknown chunks, switching all these on means that
# pngcp can work without explicit known chunk reading suppport
option SAVE_UNKNOWN_CHUNKS on
option WRITE_UNKNOWN_CHUNKS on
# pngcp needs this to handle palette files with invalid indices:
option CHECK_FOR_INVALID_INDEX on
option GET_PALETTE_MAX on
# this is used to turn off limits:
option USER_LIMITS on
option SET_USER_LIMITS on
# these are are just required for specific customizations
option WRITE_CUSTOMIZE_ZTXT_COMPRESSION on
option WRITE_CUSTOMIZE_COMPRESSION on

58
contrib/conftest/read.dfa Normal file
View File

@ -0,0 +1,58 @@
# read.dfa
# Build time configuration of libpng
#
# Author: John Bowler
# Copyright: (c) John Bowler, 2013
# Usage rights:
# To the extent possible under law, the author has waived all copyright and
# related or neighboring rights to this work. This work is published from:
# United States.
#
# Build libpng with basic read support. This enables the lowest level libpng
# read API - the one where the calling code has to use a loop to read each row.
# At present this is the API used by most programs.
#
# Support is enabled only for those chunks and transformations that are
# typically required - others can be added easily.
#
everything = off
# The sequential read code is enabled here; the progressive code can be used
# instead but there is no point enabling both.
option SEQUENTIAL_READ on
# Likewise it is pointless enabling both fixed and floating point APIs. Choose
# one or the other for both the API and the internal math.
#Fixed point:
#option FIXED_POINT on
#option FLOATING_ARITHMETIC off
#Floating point:
option FLOATING_POINT on
option FLOATING_ARITHMETIC on
# Basic error handling, IO and user memory support. The latter allows the
# application program to provide its own implementations of 'malloc' and 'free'.
option SETJMP on
option STDIO on
option USER_MEM on
# To read the full set of PNG images correctly interlace, transparency and
# 16-bit support is required. The application can implement interlace itself,
# but very few do and it's no longer possible to disable it when READ is
# enabled.
option READ_tRNS on
option READ_16BIT on
# Everything else is application dependent. This file assumes the app handles
# all the native PNG bit layouts, so it doesn't need any of layout change
# transforms, but needs libpng to perform gamma correction. It doesn't do any
# colorspace stuff and ignores the 'significant bit' information.
#
# If your app always expands the image to a limited set of bit layouts you
# probably want to consider using the simplified API instead of the low level
# one - see png.h and s_read.dfa.
option READ_GAMMA on

View File

@ -0,0 +1,35 @@
# s_read.dfa
# Build time configuration of libpng
#
# Author: John Bowler
# Copyright: (c) John Bowler, 2013
# Usage rights:
# To the extent possible under law, the author has waived all copyright and
# related or neighboring rights to this work. This work is published from:
# United States.
#
# Build libpng with simplified read support (only). This builds a minimal
# libpng able to read all PNG formats and convert them into a small number of
# well understood memory formats.
#
everything = off
option SIMPLIFIED_READ on
# It isn't necessary to chose fixed or floating point for the APIs because the
# simplified API doesn't need fixed or floating point numbers. It is necessary
# to chose an internal math implementation. The default (because of 'everything
# = off') is fixed point - turn the floating point implementation on if you have
# hardware floating point or prefer your software floating point implementation.
option FLOATING_ARITHMETIC on
# This is not strictly necessary, but without it the message strings in the API
# will not be filled in
option ERROR_TEXT on
# Switching these options on enables the 'AFIRST' and 'BGR' formats - you don't
# need this if you don't use them, they just allow the in-memory layout to be
# changed to match common hardware formats.
option SIMPLIFIED_READ_AFIRST on
option SIMPLIFIED_READ_BGR on

View File

@ -0,0 +1,33 @@
# s_write.dfa
# Build time configuration of libpng
#
# Author: John Bowler
# Copyright: (c) John Bowler, 2013
# Usage rights:
# To the extent possible under law, the author has waived all copyright and
# related or neighboring rights to this work. This work is published from:
# United States.
#
# Build libpng with (just) simplified write support
#
everything = off
option SIMPLIFIED_WRITE on
# It isn't necessary to chose fixed or floating point for the APIs because the
# simplified API doesn't need fixed or floating point numbers. It is necessary
# to chose an internal math implementation. The default (because of 'everything
# = off') is fixed point - turn the floating point implementation on if you have
# hardware floating point or prefer your software floating point implementation.
option FLOATING_ARITHMETIC on
# This is not strictly necessary, but without it the message strings in the API
# will not be filled in
option ERROR_TEXT on
# Switching these options on enables the 'AFIRST' and 'BGR' formats - you don't
# need this if you don't use them, they just allow the in-memory layout to be
# changed to match common hardware formats.
option SIMPLIFIED_WRITE_AFIRST on
option SIMPLIFIED_WRITE_BGR on

View File

@ -0,0 +1,36 @@
# simple.dfa
# Build time configuration of libpng
#
# Author: John Bowler
# Copyright: (c) John Bowler, 2013
# Usage rights:
# To the extent possible under law, the author has waived all copyright and
# related or neighboring rights to this work. This work is published from:
# United States.
#
# Build libpng with just the simplified APIs (read and write).
#
everything = off
option SIMPLIFIED_WRITE on
option SIMPLIFIED_READ on
# It isn't necessary to chose fixed or floating point for the APIs because the
# simplified API doesn't need fixed or floating point numbers. It is necessary
# to chose an internal math implementation. The default (because of 'everything
# = off') is fixed point - turn the floating point implementation on if you have
# hardware floating point or prefer your software floating point implementation.
option FLOATING_ARITHMETIC on
# This is not strictly necessary, but without it the message strings in the API
# will not be filled in
option ERROR_TEXT on
# Switching these options on enables the 'AFIRST' and 'BGR' formats - you don't
# need this if you don't use them, they just allow the in-memory layout to be
# changed to match common hardware formats.
option SIMPLIFIED_READ_AFIRST on
option SIMPLIFIED_READ_BGR on
option SIMPLIFIED_WRITE_AFIRST on
option SIMPLIFIED_WRITE_BGR on

View File

@ -0,0 +1,45 @@
# write.dfa
# Build time configuration of libpng
#
# Author: John Bowler
# Copyright: (c) John Bowler, 2013
# Usage rights:
# To the extent possible under law, the author has waived all copyright and
# related or neighboring rights to this work. This work is published from:
# United States.
#
# Build libpng with no read support and minimal write support.
#
everything = off
# Switch on the write code - this makes a minimalist encoder
option WRITE on
# Choose fixed or floating point APIs and arithmetic. The choices are
# independent but normally they will match. It is typically better to use the
# floating point if you have floating point hardware. If you don't know, or
# (perhaps) to make libpng smaller used fixed point throughout.
#Fixed point:
#option FIXED_POINT on
#option FLOATING_ARITHMETIC off
#Floating point:
option FLOATING_POINT on
option FLOATING_ARITHMETIC on
# Basic error handling, IO and user memory support. The latter allows the
# application program to provide its own implementations of 'malloc' and 'free'.
option SETJMP on
option STDIO on
option USER_MEM on
# Everything else is optional. Unlike the read code in libpng the write code
# does not need to deal with arbitrary formats, so only add support for things
# you really do write! For example you might only write sRGB images, sometimes
# with transparency and never write 16 bit images, so:
option WRITE_sRGB on
option WRITE_tRNS on
#option WRITE_16BIT off (this is the default with 'everything = off')

View File

@ -6,9 +6,9 @@
* United States.
*
* Extract any icc profiles found in the given PNG files. This is a simple
* example of a program which extracts information from the header of a PNG file
* example of a program that extracts information from the header of a PNG file
* without processing the image. Notice that some header information may occur
* after the image data, textual data and comments are an example; the approach
* after the image data. Textual data and comments are an example; the approach
* in this file won't work reliably for such data because it only looks for the
* information in the section of the file that preceeds the image data.
*
@ -26,6 +26,10 @@
#include <png.h>
#if defined(PNG_READ_SUPPORTED) && defined(PNG_STDIO_SUPPORTED) && \
defined (PNG_iCCP_SUPPORTED)
static int verbose = 1;
static png_byte no_profile[] = "no profile";
@ -178,3 +182,4 @@ main(int argc, char **argv)
/* Exit code is true if any extract succeeds */
return extracted == 0;
}
#endif /* READ && STDIO && iCCP */

View File

@ -8,7 +8,7 @@
* Read a single pixel value from a PNG file.
*
* This code illustrates basic 'by-row' reading of a PNG file using libpng.
* Rows are read until a particular pixel is found, the value of this pixel is
* Rows are read until a particular pixel is found; the value of this pixel is
* then printed on stdout.
*
* The code illustrates how to do this on interlaced as well as non-interlaced
@ -27,6 +27,8 @@
*/
#include "../../png.h"
#if defined(PNG_READ_SUPPORTED) && defined(PNG_SEQUENTIAL_READ_SUPPORTED)
/* Return component 'c' of pixel 'x' from the given row. */
static unsigned int
component(png_const_bytep row, png_uint_32 x, unsigned int c,
@ -37,7 +39,7 @@ component(png_const_bytep row, png_uint_32 x, unsigned int c,
* bytes wide. Since the row fitted into memory, however, the following must
* work:
*/
png_uint_32 bit_offset_hi = bit_depth * ((x >> 6) * channels + c);
png_uint_32 bit_offset_hi = bit_depth * ((x >> 6) * channels);
png_uint_32 bit_offset_lo = bit_depth * ((x & 0x3f) * channels + c);
row = (png_const_bytep)(((PNG_CONST png_byte (*)[8])row) + bit_offset_hi);
@ -56,7 +58,7 @@ component(png_const_bytep row, png_uint_32 x, unsigned int c,
case 8: return row[0];
case 16: return (row[0] << 8) + row[1];
default:
/* This should never happen, it indicates a bug in this program or in
/* This should never happen; it indicates a bug in this program or in
* libpng itself:
*/
fprintf(stderr, "pngpixel: invalid bit depth %u\n", bit_depth);
@ -85,7 +87,7 @@ print_pixel(png_structp png_ptr, png_infop info_ptr, png_const_bytep row,
*/
case PNG_COLOR_TYPE_PALETTE:
{
PNG_CONST unsigned int index = component(row, x, 0, bit_depth, 1);
PNG_CONST int index = component(row, x, 0, bit_depth, 1);
png_colorp palette = NULL;
int num_palette = 0;
@ -132,7 +134,7 @@ print_pixel(png_structp png_ptr, png_infop info_ptr, png_const_bytep row,
return;
default:
png_error(png_ptr, "invalid color type");
png_error(png_ptr, "pngpixel: invalid color type");
}
}
@ -366,3 +368,4 @@ int main(int argc, const char **argv)
return result;
}
#endif /* READ && SEQUENTIAL_READ */

View File

@ -1,10 +1,12 @@
/*- pngtopng
*
* COPYRIGHT: Written by John Cunningham Bowler, 2011.
* COPYRIGHT: Written by John Cunningham Bowler, 2011, 2017.
* To the extent possible under law, the author has waived all copyright and
* related or neighboring rights to this work. This work is published from:
* United States.
*
* Last changed in libpng 1.6.29 [%RDATE%]
*
* Read a PNG and write it out in a fixed format, using the 'simplified API'
* that was introduced in libpng-1.6.0.
*
@ -20,6 +22,8 @@
* ensure the code picks up the local libpng implementation:
*/
#include "../../png.h"
#if defined(PNG_SIMPLIFIED_READ_SUPPORTED) && \
defined(PNG_SIMPLIFIED_WRITE_SUPPORTED)
int main(int argc, const char **argv)
{
@ -57,26 +61,27 @@ int main(int argc, const char **argv)
else
fprintf(stderr, "pngtopng: write %s: %s\n", argv[2],
image.message);
free(buffer);
}
else
{
fprintf(stderr, "pngtopng: read %s: %s\n", argv[1],
image.message);
/* This is the only place where a 'free' is required; libpng does
* the cleanup on error and success, but in this case we couldn't
* complete the read because of running out of memory.
*/
png_image_free(&image);
}
free(buffer);
}
else
{
fprintf(stderr, "pngtopng: out of memory: %lu bytes\n",
(unsigned long)PNG_IMAGE_SIZE(image));
/* This is the only place where a 'free' is required; libpng does
* the cleanup on error and success, but in this case we couldn't
* complete the read because of running out of memory and so libpng
* has not got to the point where it can do cleanup.
*/
png_image_free(&image);
}
}
else
@ -90,3 +95,4 @@ int main(int argc, const char **argv)
return result;
}
#endif /* READ && WRITE */

View File

@ -0,0 +1,648 @@
/*- simpleover
*
* COPYRIGHT: Written by John Cunningham Bowler, 2015.
* To the extent possible under law, the author has waived all copyright and
* related or neighboring rights to this work. This work is published from:
* United States.
*
* Read several PNG files, which should have an alpha channel or transparency
* information, and composite them together to produce one or more 16-bit linear
* RGBA intermediates. This involves doing the correct 'over' composition to
* combine the alpha channels and corresponding data.
*
* Finally read an output (background) PNG using the 24-bit RGB format (the
* PNG will be composited on green (#00ff00) by default if it has an alpha
* channel), and apply the intermediate image generated above to specified
* locations in the image.
*
* The command line has the general format:
*
* simpleover <background.png> [output.png]
* {--sprite=width,height,name {[--at=x,y] {sprite.png}}}
* {--add=name {x,y}}
*
* The --sprite and --add options may occur multiple times. They are executed
* in order. --add may refer to any sprite already read.
*
* This code is intended to show how to composite multiple images together
* correctly. Apart from the libpng Simplified API the only work done in here
* is to combine multiple input PNG images into a single sprite; this involves
* a Porter-Duff 'over' operation and the input PNG images may, as a result,
* be regarded as being layered one on top of the other with the first (leftmost
* on the command line) being at the bottom and the last on the top.
*/
#include <stddef.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <errno.h>
/* Normally use <png.h> here to get the installed libpng, but this is done to
* ensure the code picks up the local libpng implementation, so long as this
* file is linked against a sufficiently recent libpng (1.6+) it is ok to
* change this to <png.h>:
*/
#include "../../png.h"
#ifdef PNG_SIMPLIFIED_READ_SUPPORTED
#define sprite_name_chars 15
struct sprite {
FILE *file;
png_uint_16p buffer;
unsigned int width;
unsigned int height;
char name[sprite_name_chars+1];
};
#if 0 /* div by 65535 test program */
#include <math.h>
#include <stdio.h>
int main(void) {
double err = 0;
unsigned int xerr = 0;
unsigned int r = 32769;
{
unsigned int x = 0;
do {
unsigned int t = x + (x >> 16) /*+ (x >> 31)*/ + r;
double v = x, errtest;
if (t < x) {
fprintf(stderr, "overflow: %u+%u -> %u\n", x, r, t);
return 1;
}
v /= 65535;
errtest = v;
t >>= 16;
errtest -= t;
if (errtest > err) {
err = errtest;
xerr = x;
if (errtest >= .5) {
fprintf(stderr, "error: %u/65535 = %f, not %u, error %f\n",
x, v, t, errtest);
return 0;
}
}
} while (++x <= 65535U*65535U);
}
printf("error %f @ %u\n", err, xerr);
return 0;
}
#endif /* div by 65535 test program */
static void
sprite_op(const struct sprite *sprite, int x_offset, int y_offset,
png_imagep image, const png_uint_16 *buffer)
{
/* This is where the Porter-Duff 'Over' operator is evaluated; change this
* code to change the operator (this could be parameterized). Any other
* image processing operation could be used here.
*/
/* Check for an x or y offset that pushes any part of the image beyond the
* right or bottom of the sprite:
*/
if ((y_offset < 0 || (unsigned)/*SAFE*/y_offset < sprite->height) &&
(x_offset < 0 || (unsigned)/*SAFE*/x_offset < sprite->width))
{
unsigned int y = 0;
if (y_offset < 0)
y = -y_offset; /* Skip to first visible row */
do
{
unsigned int x = 0;
if (x_offset < 0)
x = -x_offset;
do
{
/* In and out are RGBA values, so: */
const png_uint_16 *in_pixel = buffer + (y * image->width + x)*4;
png_uint_32 in_alpha = in_pixel[3];
/* This is the optimized Porter-Duff 'Over' operation, when the
* input alpha is 0 the output is not changed.
*/
if (in_alpha > 0)
{
png_uint_16 *out_pixel = sprite->buffer +
((y+y_offset) * sprite->width + (x+x_offset))*4;
/* This is the weight to apply to the output: */
in_alpha = 65535-in_alpha;
if (in_alpha > 0)
{
/* The input must be composed onto the output. This means
* multiplying the current output pixel value by the inverse
* of the input alpha (1-alpha). A division is required but
* it is by the constant 65535. Approximate this as:
*
* (x + (x >> 16) + 32769) >> 16;
*
* This is exact (and does not overflow) for all values of
* x in the range 0..65535*65535. (Note that the calculation
* produces the closest integer; the maximum error is <0.5).
*/
png_uint_32 tmp;
# define compose(c)\
tmp = out_pixel[c] * in_alpha;\
tmp = (tmp + (tmp >> 16) + 32769) >> 16;\
out_pixel[c] = tmp + in_pixel[c]
/* The following is very vectorizable... */
compose(0);
compose(1);
compose(2);
compose(3);
}
else
out_pixel[0] = in_pixel[0],
out_pixel[1] = in_pixel[1],
out_pixel[2] = in_pixel[2],
out_pixel[3] = in_pixel[3];
}
}
while (++x < image->width);
}
while (++y < image->height);
}
}
static int
create_sprite(struct sprite *sprite, int *argc, const char ***argv)
{
/* Read the arguments and create this sprite. The sprite buffer has already
* been allocated. This reads the input PNGs one by one in linear format,
* composes them onto the sprite buffer (the code in the function above)
* then saves the result, converting it on the fly to PNG RGBA 8-bit format.
*/
while (*argc > 0)
{
char tombstone;
int x = 0, y = 0;
if ((*argv)[0][0] == '-' && (*argv)[0][1] == '-')
{
/* The only supported option is --at. */
if (sscanf((*argv)[0], "--at=%d,%d%c", &x, &y, &tombstone) != 2)
break; /* success; caller will parse this option */
++*argv, --*argc;
}
else
{
/* The argument has to be a file name */
png_image image;
image.version = PNG_IMAGE_VERSION;
image.opaque = NULL;
if (png_image_begin_read_from_file(&image, (*argv)[0]))
{
png_uint_16p buffer;
image.format = PNG_FORMAT_LINEAR_RGB_ALPHA;
buffer = malloc(PNG_IMAGE_SIZE(image));
if (buffer != NULL)
{
if (png_image_finish_read(&image, NULL/*background*/, buffer,
0/*row_stride*/,
NULL/*colormap for PNG_FORMAT_FLAG_COLORMAP*/))
{
/* This is the place where the Porter-Duff 'Over' operator
* needs to be done by this code. In fact, any image
* processing required can be done here; the data is in
* the correct format (linear, 16-bit) and source and
* destination are in memory.
*/
sprite_op(sprite, x, y, &image, buffer);
free(buffer);
++*argv, --*argc;
/* And continue to the next argument */
continue;
}
else
{
free(buffer);
fprintf(stderr, "simpleover: read %s: %s\n", (*argv)[0],
image.message);
}
}
else
{
fprintf(stderr, "simpleover: out of memory: %lu bytes\n",
(unsigned long)PNG_IMAGE_SIZE(image));
/* png_image_free must be called if we abort the Simplified API
* read because of a problem detected in this code. If problems
* are detected in the Simplified API it cleans up itself.
*/
png_image_free(&image);
}
}
else
{
/* Failed to read the first argument: */
fprintf(stderr, "simpleover: %s: %s\n", (*argv)[0], image.message);
}
return 0; /* failure */
}
}
/* All the sprite operations have completed successfully. Save the RGBA
* buffer as a PNG using the simplified write API.
*/
sprite->file = tmpfile();
if (sprite->file != NULL)
{
png_image save;
memset(&save, 0, sizeof save);
save.version = PNG_IMAGE_VERSION;
save.opaque = NULL;
save.width = sprite->width;
save.height = sprite->height;
save.format = PNG_FORMAT_LINEAR_RGB_ALPHA;
save.flags = PNG_IMAGE_FLAG_FAST;
save.colormap_entries = 0;
if (png_image_write_to_stdio(&save, sprite->file, 1/*convert_to_8_bit*/,
sprite->buffer, 0/*row_stride*/, NULL/*colormap*/))
{
/* Success; the buffer is no longer needed: */
free(sprite->buffer);
sprite->buffer = NULL;
return 1; /* ok */
}
else
fprintf(stderr, "simpleover: write sprite %s: %s\n", sprite->name,
save.message);
}
else
fprintf(stderr, "simpleover: sprite %s: could not allocate tmpfile: %s\n",
sprite->name, strerror(errno));
return 0; /* fail */
}
static int
add_sprite(png_imagep output, png_bytep out_buf, struct sprite *sprite,
int *argc, const char ***argv)
{
/* Given a --add argument naming this sprite, perform the operations listed
* in the following arguments. The arguments are expected to have the form
* (x,y), which is just an offset at which to add the sprite to the
* output.
*/
while (*argc > 0)
{
char tombstone;
int x, y;
if ((*argv)[0][0] == '-' && (*argv)[0][1] == '-')
return 1; /* success */
if (sscanf((*argv)[0], "%d,%d%c", &x, &y, &tombstone) == 2)
{
/* Now add the new image into the sprite data, but only if it
* will fit.
*/
if (x < 0 || y < 0 ||
(unsigned)/*SAFE*/x >= output->width ||
(unsigned)/*SAFE*/y >= output->height ||
sprite->width > output->width-x ||
sprite->height > output->height-y)
{
fprintf(stderr, "simpleover: sprite %s @ (%d,%d) outside image\n",
sprite->name, x, y);
/* Could just skip this, but for the moment it is an error */
return 0; /* error */
}
else
{
/* Since we know the sprite fits we can just read it into the
* output using the simplified API.
*/
png_image in;
in.version = PNG_IMAGE_VERSION;
rewind(sprite->file);
if (png_image_begin_read_from_stdio(&in, sprite->file))
{
in.format = PNG_FORMAT_RGB; /* force compose */
if (png_image_finish_read(&in, NULL/*background*/,
out_buf + (y*output->width + x)*3/*RGB*/,
output->width*3/*row_stride*/,
NULL/*colormap for PNG_FORMAT_FLAG_COLORMAP*/))
{
++*argv, --*argc;
continue;
}
}
/* The read failed: */
fprintf(stderr, "simpleover: add sprite %s: %s\n", sprite->name,
in.message);
return 0; /* error */
}
}
else
{
fprintf(stderr, "simpleover: --add='%s': invalid position %s\n",
sprite->name, (*argv)[0]);
return 0; /* error */
}
}
return 1; /* ok */
}
static int
simpleover_process(png_imagep output, png_bytep out_buf, int argc,
const char **argv)
{
int result = 1; /* success */
# define csprites 10/*limit*/
# define str(a) #a
int nsprites = 0;
struct sprite sprites[csprites];
while (argc > 0)
{
result = 0; /* fail */
if (strncmp(argv[0], "--sprite=", 9) == 0)
{
char tombstone;
if (nsprites < csprites)
{
int n;
sprites[nsprites].width = sprites[nsprites].height = 0;
sprites[nsprites].name[0] = 0;
n = sscanf(argv[0], "--sprite=%u,%u,%" str(sprite_name_chars) "s%c",
&sprites[nsprites].width, &sprites[nsprites].height,
sprites[nsprites].name, &tombstone);
if ((n == 2 || n == 3) &&
sprites[nsprites].width > 0 && sprites[nsprites].height > 0)
{
size_t buf_size, tmp;
/* Default a name if not given. */
if (sprites[nsprites].name[0] == 0)
sprintf(sprites[nsprites].name, "sprite-%d", nsprites+1);
/* Allocate a buffer for the sprite and calculate the buffer
* size:
*/
buf_size = sizeof (png_uint_16 [4]);
buf_size *= sprites[nsprites].width;
buf_size *= sprites[nsprites].height;
/* This can overflow a (size_t); check for this: */
tmp = buf_size;
tmp /= sprites[nsprites].width;
tmp /= sprites[nsprites].height;
if (tmp == sizeof (png_uint_16 [4]))
{
sprites[nsprites].buffer = malloc(buf_size);
/* This buffer must be initialized to transparent: */
memset(sprites[nsprites].buffer, 0, buf_size);
if (sprites[nsprites].buffer != NULL)
{
sprites[nsprites].file = NULL;
++argv, --argc;
if (create_sprite(sprites+nsprites++, &argc, &argv))
{
result = 1; /* still ok */
continue;
}
break; /* error */
}
}
/* Overflow, or OOM */
fprintf(stderr, "simpleover: %s: sprite too large\n", argv[0]);
break;
}
else
{
fprintf(stderr, "simpleover: %s: invalid sprite (%u,%u)\n",
argv[0], sprites[nsprites].width, sprites[nsprites].height);
break;
}
}
else
{
fprintf(stderr, "simpleover: %s: too many sprites\n", argv[0]);
break;
}
}
else if (strncmp(argv[0], "--add=", 6) == 0)
{
const char *name = argv[0]+6;
int isprite = nsprites;
++argv, --argc;
while (--isprite >= 0)
{
if (strcmp(sprites[isprite].name, name) == 0)
{
if (!add_sprite(output, out_buf, sprites+isprite, &argc, &argv))
goto out; /* error in add_sprite */
break;
}
}
if (isprite < 0) /* sprite not found */
{
fprintf(stderr, "simpleover: --add='%s': sprite not found\n", name);
break;
}
}
else
{
fprintf(stderr, "simpleover: %s: unrecognized operation\n", argv[0]);
break;
}
result = 1; /* ok */
}
/* Clean up the cache of sprites: */
out:
while (--nsprites >= 0)
{
if (sprites[nsprites].buffer != NULL)
free(sprites[nsprites].buffer);
if (sprites[nsprites].file != NULL)
(void)fclose(sprites[nsprites].file);
}
return result;
}
int main(int argc, const char **argv)
{
int result = 1; /* default to fail */
if (argc >= 2)
{
int argi = 2;
const char *output = NULL;
png_image image;
if (argc > 2 && argv[2][0] != '-'/*an operation*/)
{
output = argv[2];
argi = 3;
}
image.version = PNG_IMAGE_VERSION;
image.opaque = NULL;
if (png_image_begin_read_from_file(&image, argv[1]))
{
png_bytep buffer;
image.format = PNG_FORMAT_RGB; /* 24-bit RGB */
buffer = malloc(PNG_IMAGE_SIZE(image));
if (buffer != NULL)
{
png_color background = {0, 0xff, 0}; /* fully saturated green */
if (png_image_finish_read(&image, &background, buffer,
0/*row_stride*/, NULL/*colormap for PNG_FORMAT_FLAG_COLORMAP */))
{
/* At this point png_image_finish_read has cleaned up the
* allocated data in png_image, and only the buffer needs to be
* freed.
*
* Perform the remaining operations:
*/
if (simpleover_process(&image, buffer, argc-argi, argv+argi))
{
/* Write the output: */
if ((output != NULL &&
png_image_write_to_file(&image, output,
0/*convert_to_8bit*/, buffer, 0/*row_stride*/,
NULL/*colormap*/)) ||
(output == NULL &&
png_image_write_to_stdio(&image, stdout,
0/*convert_to_8bit*/, buffer, 0/*row_stride*/,
NULL/*colormap*/)))
result = 0;
else
fprintf(stderr, "simpleover: write %s: %s\n",
output == NULL ? "stdout" : output, image.message);
}
/* else simpleover_process writes an error message */
}
else
fprintf(stderr, "simpleover: read %s: %s\n", argv[1],
image.message);
free(buffer);
}
else
{
fprintf(stderr, "simpleover: out of memory: %lu bytes\n",
(unsigned long)PNG_IMAGE_SIZE(image));
/* This is the only place where a 'free' is required; libpng does
* the cleanup on error and success, but in this case we couldn't
* complete the read because of running out of memory.
*/
png_image_free(&image);
}
}
else
{
/* Failed to read the first argument: */
fprintf(stderr, "simpleover: %s: %s\n", argv[1], image.message);
}
}
else
{
/* Usage message */
fprintf(stderr,
"simpleover: usage: simpleover background.png [output.png]\n"
" Output 'background.png' as a 24-bit RGB PNG file in 'output.png'\n"
" or, if not given, stdout. 'background.png' will be composited\n"
" on fully saturated green.\n"
"\n"
" Optionally, before output, process additional PNG files:\n"
"\n"
" --sprite=width,height,name {[--at=x,y] {sprite.png}}\n"
" Produce a transparent sprite of size (width,height) and with\n"
" name 'name'.\n"
" For each sprite.png composite it using a Porter-Duff 'Over'\n"
" operation at offset (x,y) in the sprite (defaulting to (0,0)).\n"
" Input PNGs will be truncated to the area of the sprite.\n"
"\n"
" --add='name' {x,y}\n"
" Optionally, before output, composite a sprite, 'name', which\n"
" must have been previously produced using --sprite, at each\n"
" offset (x,y) in the output image. Each sprite must fit\n"
" completely within the output image.\n"
"\n"
" PNG files are processed in the order they occur on the command\n"
" line and thus the first PNG processed appears as the bottommost\n"
" in the output image.\n");
}
return result;
}
#endif /* SIMPLIFIED_READ */

16
contrib/extensions.ac Normal file
View File

@ -0,0 +1,16 @@
# CONTRIBUTED EXTENSIONS
#
# The following extensions are part of a standard libpng distribution. They are
# not supported parts of libpng and they are not necessarily released under the
# same license as libpng. Please consult the relevant directory for copyright
# and support information before uncommenting any of the lines below.
#
# After you change this file you MUST re-run "autoreconf" to regenerate the
# configure script, otherwise the change may have no effect.
#
# Include the ARM NEON extension:
#sinclude([contrib/neon/neon.ac])
#
# If any of the extensions require automake support (this is likely) automake
# must include the file contrib/extensions.am
#libpng_automake_extensions="yes"

7
contrib/extensions.am Normal file
View File

@ -0,0 +1,7 @@
# CONTRIBUTED EXTENSIONS
#
# Please read the file "contrib/extensions.ac" before making changes to this
# file.
#
# Include the ARM NEON extension:
#include %reldir%/neon/neon.am

View File

@ -47,7 +47,8 @@ CC = gcc
#CC = i386-mingw32msvc-gcc # e.g., Linux -> Win32 cross-compilation
LD = $(CC)
RM = rm -f
CFLAGS = -O -Wall $(INCS) $(MINGW_CCFLAGS)
CPPFLAGS = $(INCS)
CFLAGS = -O -Wall $(MINGW_CCFLAGS)
# [note that -Wall is a gcc-specific compilation flag ("most warnings on")]
# [-ansi, -pedantic and -W can also be used]
LDFLAGS = $(MINGW_LDFLAGS)
@ -85,10 +86,10 @@ EXES = $(STATIC_EXES) $(DYNAMIC_EXES)
# implicit make rules -------------------------------------------------------
.c$(O):
$(CC) -c $(CFLAGS) $<
$(CC) -c $(CPPFLAGS) $(CFLAGS) $<
%.pic$(O): %.c
$(CC) -c $(CFLAGS) -DPNG_BUILD_DLL -o $@ $<
$(CC) -c $(CPPFLAGS) $(CFLAGS) -DPNG_BUILD_DLL -o $@ $<
# dependencies --------------------------------------------------------------

View File

@ -23,9 +23,9 @@
# macros --------------------------------------------------------------------
PNGINC = -I/usr/local/include/libpng16
PNGLIB = -L/usr/local/lib -lpng16 # dynamically linked against libpng
#PNGLIB = /usr/local/lib/libpng16.a # statically linked against libpng
PNGINC = -I/usr/local/include/libpng17
PNGLIB = -L/usr/local/lib -lpng17 # dynamically linked against libpng
#PNGLIB = /usr/local/lib/libpng17.a # statically linked against libpng
# or:
#PNGINC = -I../..
#PNGLIB = -L../.. -lpng
@ -53,7 +53,8 @@ CC = cc
LD = cc
RM = rm -f
# ABI must be the same as that used to build libpng.
ABI=
ABI =
CPPFLAGS =
CFLAGS = $(ABI) -O -fullwarn $(INCS)
LDFLAGS = $(ABI)
O = .o
@ -73,7 +74,7 @@ EXES = $(RPNG)$(E) $(RPNG2)$(E) $(WPNG)$(E)
# implicit make rules -------------------------------------------------------
.c$(O):
$(CC) -c $(CFLAGS) $<
$(CC) -c $(CPPFLAGS) $(CFLAGS) $<
# dependencies --------------------------------------------------------------

View File

@ -26,14 +26,14 @@
# macros --------------------------------------------------------------------
#PNGDIR = /usr/local/lib
#PNGINC = -I/usr/local/include/libpng16
#PNGLIBd = -L$(PNGDIR) -lpng16 # dynamically linked, installed libpng
#PNGLIBs = $(PNGDIR)/libpng16.a # statically linked, installed libpng
#PNGINC = -I/usr/local/include/libpng17
#PNGLIBd = -L$(PNGDIR) -lpng17 # dynamically linked, installed libpng
#PNGLIBs = $(PNGDIR)/libpng17.a # statically linked, installed libpng
# or:
PNGDIR = ../..# this one is for libpng-x.y.z/contrib/gregbook builds
#PNGDIR = ../libpng
PNGINC = -I$(PNGDIR)
PNGLIBd = -Wl,-rpath,$(PNGDIR) -L$(PNGDIR) -lpng16 # dynamically linked
PNGLIBd = -Wl,-rpath,$(PNGDIR) -L$(PNGDIR) -lpng17 # dynamically linked
PNGLIBs = $(PNGDIR)/libpng.a # statically linked, local libpng
ZDIR = /usr/local/lib
@ -64,7 +64,8 @@ WLIBSs = $(PNGLIBs) $(ZLIBs)
CC = gcc
LD = gcc
RM = rm -f
CFLAGS = -O -Wall $(INCS) -DFEATURE_LOOP
CPPFLAGS = $(INCS) -DFEATURE_LOOP
CFLAGS = -O -Wall
# [note that -Wall is a gcc-specific compilation flag ("most warnings on")]
# [-ansi, -pedantic and -W can also be used]
LDFLAGS =
@ -92,7 +93,7 @@ EXES = $(STATIC_EXES) $(DYNAMIC_EXES)
# implicit make rules -------------------------------------------------------
.c$(O):
$(CC) -c $(CFLAGS) $<
$(CC) -c $(CPPFLAGS) $(CFLAGS) $<
# dependencies --------------------------------------------------------------

View File

@ -53,7 +53,8 @@ WLIBS = $(PNGLIB) $(ZLIB)
CC = cl
LD = link
RM = del
CFLAGS = -nologo -O -W3 $(INCS) $(cvars)
CPPFLAGS = $(INCS)
CFLAGS = -nologo -O -W3 $(cvars)
# [note that -W3 is an MSVC-specific compilation flag ("all warnings on")]
# [see %devstudio%\vc\include\win32.mak for cvars macro definition]
O = .obj
@ -76,7 +77,7 @@ EXES = $(RPNG)$(E) $(RPNG2)$(E) $(WPNG)$(E)
# implicit make rules -------------------------------------------------------
.c$(O):
$(CC) -c $(CFLAGS) $<
$(CC) -c $(CPPFLAGS) $(CFLAGS) $<
# dependencies --------------------------------------------------------------

View File

@ -55,7 +55,7 @@ mation and links to the latest version of the source code, and Chapters
13-15 of the book for detailed discussion of the three programs.
Greg Roelofs
http://pobox.com/~newt/greg_contact.html
https://pobox.com/~newt/greg_contact.html
16 March 2008
@ -63,7 +63,7 @@ BUILD INSTRUCTIONS
- Prerequisites (in order of compilation):
- zlib http://zlib.net/
- zlib https://zlib.net/
- libpng http://www.libpng.org/pub/png/libpng.html
- pngbook http://www.libpng.org/pub/png/book/sources.html

View File

@ -215,6 +215,10 @@ uch *readpng_get_image(double display_exponent, int *pChannels, ulg *pRowbytes)
* libpng function */
if (setjmp(png_jmpbuf(png_ptr))) {
free(image_data);
image_data = NULL;
free(row_pointers);
row_pointers = NULL;
png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
return NULL;
}

View File

@ -4,7 +4,7 @@
---------------------------------------------------------------------------
Copyright (c) 1998-2007 Greg Roelofs. All rights reserved.
Copyright (c) 1998-2015 Greg Roelofs. All rights reserved.
This software is provided "as is," without warranty of any kind,
express or implied. In no event shall the author or contributors
@ -51,6 +51,11 @@
along with this program; if not, write to the Free Software Foundation,
Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
---------------------------------------------------------------------------
Changelog:
%RDATE% - Check return value of png_get_bKGD() (Glenn R-P)
---------------------------------------------------------------------------*/
@ -69,6 +74,7 @@ static void readpng2_row_callback(png_structp png_ptr, png_bytep new_row,
png_uint_32 row_num, int pass);
static void readpng2_end_callback(png_structp png_ptr, png_infop info_ptr);
static void readpng2_error_handler(png_structp png_ptr, png_const_charp msg);
static void readpng2_warning_handler(png_structp png_ptr, png_const_charp msg);
@ -103,8 +109,8 @@ int readpng2_init(mainprog_info *mainprog_ptr)
/* could also replace libpng warning-handler (final NULL), but no need: */
png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING, mainprog_ptr,
readpng2_error_handler, NULL);
png_ptr = png_create_read_struct(png_get_libpng_ver(NULL), mainprog_ptr,
readpng2_error_handler, readpng2_warning_handler);
if (!png_ptr)
return 4; /* out of memory */
@ -260,36 +266,38 @@ static void readpng2_info_callback(png_structp png_ptr, png_infop info_ptr)
/* since we know we've read all of the PNG file's "header" (i.e., up
* to IDAT), we can check for a background color here */
if (mainprog_ptr->need_bgcolor &&
png_get_valid(png_ptr, info_ptr, PNG_INFO_bKGD))
if (mainprog_ptr->need_bgcolor)
{
png_color_16p pBackground;
/* it is not obvious from the libpng documentation, but this function
* takes a pointer to a pointer, and it always returns valid red,
* green and blue values, regardless of color_type: */
png_get_bKGD(png_ptr, info_ptr, &pBackground);
if (png_get_bKGD(png_ptr, info_ptr, &pBackground))
{
/* however, it always returns the raw bKGD data, regardless of any
* bit-depth transformations, so check depth and adjust if necessary */
if (bit_depth == 16) {
mainprog_ptr->bg_red = pBackground->red >> 8;
mainprog_ptr->bg_green = pBackground->green >> 8;
mainprog_ptr->bg_blue = pBackground->blue >> 8;
} else if (color_type == PNG_COLOR_TYPE_GRAY && bit_depth < 8) {
if (bit_depth == 1)
mainprog_ptr->bg_red = mainprog_ptr->bg_green =
mainprog_ptr->bg_blue = pBackground->gray? 255 : 0;
else if (bit_depth == 2)
mainprog_ptr->bg_red = mainprog_ptr->bg_green =
mainprog_ptr->bg_blue = (255/3) * pBackground->gray;
else /* bit_depth == 4 */
mainprog_ptr->bg_red = mainprog_ptr->bg_green =
mainprog_ptr->bg_blue = (255/15) * pBackground->gray;
} else {
mainprog_ptr->bg_red = (uch)pBackground->red;
mainprog_ptr->bg_green = (uch)pBackground->green;
mainprog_ptr->bg_blue = (uch)pBackground->blue;
/* however, it always returns the raw bKGD data, regardless of any
* bit-depth transformations, so check depth and adjust if necessary
*/
if (bit_depth == 16) {
mainprog_ptr->bg_red = pBackground->red >> 8;
mainprog_ptr->bg_green = pBackground->green >> 8;
mainprog_ptr->bg_blue = pBackground->blue >> 8;
} else if (color_type == PNG_COLOR_TYPE_GRAY && bit_depth < 8) {
if (bit_depth == 1)
mainprog_ptr->bg_red = mainprog_ptr->bg_green =
mainprog_ptr->bg_blue = pBackground->gray? 255 : 0;
else if (bit_depth == 2)
mainprog_ptr->bg_red = mainprog_ptr->bg_green =
mainprog_ptr->bg_blue = (255/3) * pBackground->gray;
else /* bit_depth == 4 */
mainprog_ptr->bg_red = mainprog_ptr->bg_green =
mainprog_ptr->bg_blue = (255/15) * pBackground->gray;
} else {
mainprog_ptr->bg_red = (uch)pBackground->red;
mainprog_ptr->bg_green = (uch)pBackground->green;
mainprog_ptr->bg_blue = (uch)pBackground->blue;
}
}
}
@ -447,6 +455,8 @@ static void readpng2_end_callback(png_structp png_ptr, png_infop info_ptr)
/* all done */
(void)info_ptr; /* Unused */
return;
}
@ -467,7 +477,12 @@ void readpng2_cleanup(mainprog_info *mainprog_ptr)
}
static void readpng2_warning_handler(png_structp png_ptr, png_const_charp msg)
{
fprintf(stderr, "readpng2 libpng warning: %s\n", msg);
fflush(stderr);
(void)png_ptr; /* Unused */
}
static void readpng2_error_handler(png_structp png_ptr, png_const_charp msg)

View File

@ -163,8 +163,12 @@ uch *readpng_get_image(double display_exponent, int *pChannels, ulg *pRowbytes)
/* now we can go ahead and just read the whole image */
fread(image_data, 1L, rowbytes*height, saved_infile);
if (fread(image_data, 1L, rowbytes*height, saved_infile) <
rowbytes*height) {
free (image_data);
image_data = NULL;
return NULL;
}
return image_data;
}

View File

@ -41,10 +41,12 @@
unexpected-EOF and file-read-error cases; fixed Trace() cut-and-
paste bugs
- 2.03: deleted runtime MMX-enabling/disabling and obsolete -mmx* options
- 2.04: Added "void(foo);" statements to quiet pedantic compiler warnings
about unused variables (GR-P)
- 2.05: Use nanosleep() instead of usleep(), which is deprecated (GR-P).
---------------------------------------------------------------------------
Copyright (c) 1998-2008 Greg Roelofs. All rights reserved.
Copyright (c) 1998-2010, 2014-2015 Greg Roelofs. All rights reserved.
This software is provided "as is," without warranty of any kind,
express or implied. In no event shall the author or contributors
@ -95,7 +97,7 @@
#define PROGNAME "rpng2-x"
#define LONGNAME "Progressive PNG Viewer for X"
#define VERSION "2.03 of 25 February 2010"
#define VERSION "2.04 of 15 June 2014"
#define RESNAME "rpng2" /* our X resource application name */
#define RESCLASS "Rpng" /* our X resource class name */
@ -111,6 +113,19 @@
#include <X11/Xos.h>
#include <X11/keysym.h> /* defines XK_* macros */
#if _POSIX_C_SOURCE >= 199309L /* have nanosleep() */
# undef usleep
# define usleep(usec) { \
struct timespec ts; \
ts.tv_sec = 0; \
ts.tv_nsec = (usec) * 1000; \
nanosleep(&ts, NULL); }
# endif
#ifndef usleep /* have neither nanosleep() nor usleep() */
# define usleep(x) sleep(((x)+499999)/1000000)
#endif
#ifdef VMS
# include <unistd.h>
#endif
@ -456,40 +471,47 @@ int main(int argc, char **argv)
fprintf(stderr, "\n%s %s: %s\n\n", PROGNAME, VERSION, appname);
readpng2_version_info();
fprintf(stderr, "\n"
"Usage: %s [-display xdpy] [-gamma exp] [-bgcolor bg | -bgpat pat]\n"
"Usage: ");
fprintf(stderr,
"%s [-display xdpy] [-gamma exp] [-bgcolor bg | -bgpat pat]\n"
" %*s [-usleep dur | -timing] [-pause]\n",
PROGNAME, (int)strlen(PROGNAME), " ");
fprintf(stderr,
#ifdef FEATURE_LOOP
" %*s [-usleep dur | -timing] [-pause] [-loop [sec]] file.png\n\n"
#else
" %*s [-usleep dur | -timing] [-pause] file.png\n\n"
" [-loop [sec]]"
#endif
" file.png\n\n");
fprintf(stderr,
" xdpy\tname of the target X display (e.g., ``hostname:0'')\n"
" exp \ttransfer-function exponent (``gamma'') of the display\n"
"\t\t system in floating-point format (e.g., ``%.1f''); equal\n"
"\t\t to the product of the lookup-table exponent (varies)\n"
"\t\t to the product of the lookup-table exponent (varies)\n",
default_display_exponent);
fprintf(stderr,
"\t\t and the CRT exponent (usually 2.2); must be positive\n"
" bg \tdesired background color in 7-character hex RGB format\n"
"\t\t (e.g., ``#ff7700'' for orange: same as HTML colors);\n"
"\t\t used with transparent images; overrides -bgpat\n"
" pat \tdesired background pattern number (0-%d); used with\n"
"\t\t transparent images; overrides -bgcolor\n"
"\t\t transparent images; overrides -bgcolor\n",
num_bgpat-1);
#ifdef FEATURE_LOOP
fprintf(stderr,
" -loop\tloops through background images after initial display\n"
"\t\t is complete (depends on -bgpat)\n"
" sec \tseconds to display each background image (default = 2)\n"
" sec \tseconds to display each background image (default = 2)\n");
#endif
fprintf(stderr,
" dur \tduration in microseconds to wait after displaying each\n"
"\t\t row (for demo purposes)\n"
" -timing\tenables delay for every block read, to simulate modem\n"
"\t\t download of image (~36 Kbps)\n"
" -pause\tpauses after displaying each pass until mouse clicked\n"
"\nPress Q, Esc or mouse button 1 (within image window, after image\n"
"is displayed) to quit.\n"
"\n", PROGNAME,
(int)strlen(PROGNAME), " ", default_display_exponent, num_bgpat-1);
"is displayed) to quit.\n");
exit(1);
}
if (!(infile = fopen(filename, "rb"))) {
fprintf(stderr, PROGNAME ": can't open PNG file [%s]\n", filename);
++error;
@ -735,6 +757,8 @@ int main(int argc, char **argv)
Trace((stderr, "about to call rpng2_x_cleanup()\n"))
rpng2_x_cleanup();
(void)argc; /* Unused */
return 0;
}
@ -1826,6 +1850,9 @@ static void rpng2_x_redisplay_image(ulg startcol, ulg startrow,
XFlush(display);
}
(void)startcol;
(void)width;
} /* end function rpng2_x_redisplay_image() */

View File

@ -0,0 +1,65 @@
/* Fake a PNG - just write it out directly.
*
* COPYRIGHT: Written by John Cunningham Bowler, 2014.
* To the extent possible under law, the author has waived all copyright and
* related or neighboring rights to this work. This work is published from:
* United States.
*
*/
#include <stdio.h>
#include <zlib.h> /* for crc32 */
void
put_uLong(uLong val)
{
putchar(val >> 24);
putchar(val >> 16);
putchar(val >> 8);
putchar(val >> 0);
}
void
put_chunk(const unsigned char *chunk, uInt length)
{
uLong crc;
put_uLong(length-4); /* Exclude the tag */
fwrite(chunk, length, 1, stdout);
crc = crc32(0, Z_NULL, 0);
put_uLong(crc32(crc, chunk, length));
}
const unsigned char signature[] =
{
137, 80, 78, 71, 13, 10, 26, 10
};
const unsigned char IHDR[] =
{
73, 72, 68, 82, /* IHDR */
0, 0, 0, 1, /* width */
0, 0, 0, 1, /* height */
1, /* bit depth */
0, /* color type: greyscale */
0, /* compression method */
0, /* filter method */
0 /* interlace method: none */
};
const unsigned char unknown[] =
{
'u', 'n', 'K', 'n' /* "unKn" - private safe to copy */
};
int
main(void)
{
fwrite(signature, sizeof signature, 1, stdout);
put_chunk(IHDR, sizeof IHDR);
for (;;)
put_chunk(unknown, sizeof unknown);
}

View File

@ -1,8 +1,8 @@
#!/bin/sh
#
# Copyright (c) 2012 John Cunningham Bowler
# Copyright (c) 2013 John Cunningham Bowler
#
# Last changed in libpng 1.6.0 [(PENDING RELEASE)]
# Last changed in libpng 1.6.0 [February 14, 2013]
#
# This code is released under the libpng license.
# For conditions of distribution and use, see the disclaimer

View File

@ -1,8 +1,9 @@
/* makepng.c
*
* Copyright (c) 2012 John Cunningham Bowler
*
* Last changed in libpng 1.6.0 [(PENDING RELEASE)]
/* makepng.c */
#define _ISOC99_SOURCE
/* Copyright: */
#define COPYRIGHT "\251 2013,2015 John Cunningham Bowler"
/*
* Last changed in libpng 1.6.20 [November 24, 2015]
*
* This code is released under the libpng license.
* For conditions of distribution and use, see the disclaimer
@ -10,8 +11,8 @@
*
* Make a test PNG image. The arguments are as follows:
*
* makepng [--sRGB|--linear|--1.8] [--color=<color>] color-type bit-depth \
* [file-name]
* makepng [--sRGB|--linear|--1.8] [--tRNS] [--nofilters] \
* color-type bit-depth [file-name]
*
* The color-type may be numeric (and must match the numbers used by the PNG
* specification) or one of the format names listed below. The bit-depth is the
@ -39,8 +40,8 @@
* 4 channels: linear combinations of, from the top-left corner clockwise,
* transparent, red, green, blue.
*
* For color-mapped images a four channel color-map is used and the PNG file has
* a tRNS chunk, as follows:
* For color-mapped images a four channel color-map is used and if --tRNS is
* given the PNG file has a tRNS chunk, as follows:
*
* 1-bit: entry 0 is transparent-red, entry 1 is opaque-white
* 2-bit: entry 0: transparent-green
@ -53,6 +54,9 @@
* The palette always has 2^bit-depth entries and the tRNS chunk one fewer. The
* image is the 1-channel diamond, but using palette index, not luminosity.
*
* For formats other than color-mapped ones if --tRNS is specified a tRNS chunk
* is generated with all channels equal to the low bits of 0x0101.
*
* Image size is determined by the final pixel depth in bits, i.e. channels x
* bit-depth, as follows:
*
@ -60,20 +64,64 @@
* 16 bits: 256x256
* More than 16 bits: 1024x1024
*
* Row filtering is turned off (the 'none' filter is used on every row) and the
* images are not interlaced.
* Row filtering is the libpng default but may be turned off (the 'none' filter
* is used on every row) with the --nofilters option.
*
* The images are not interlaced.
*
* If file-name is given then the PNG is written to that file, else it is
* written to stdout. Notice that stdout is not supported on systems where, by
* default, it assumes text output; this program makes no attempt to change the
* text mode of stdout!
*
* makepng --color=<color> ...
*
* If --color is given then the whole image has that color, color-mapped images
* will have exactly one palette entry and all image files with be 16x16 in
* size. The color value is 1 to 4 decimal numbers as appropriate for the color
* type.
*
* If file-name is given then the PNG is written to that file, else it is
* written to stdout. Notice that stdout is not supported on systems where, by
* default, it assumes text output; this program makes no attempt to change the
* text mode of stdout!
* makepng --small ...
*
* If --small is given the images are no larger than required to include every
* possible pixel value for the format.
*
* For formats with pixels 8 bits or fewer in size the images consist of a
* single row with 2^pixel-depth pixels, one of every possible value.
*
* For formats with 16-bit pixels a 256x256 image is generated containing every
* possible pixel value.
*
* For larger pixel sizes a 256x256 image is generated where the first row
* consists of each pixel that has identical byte values throughout the pixel
* followed by rows where the byte values differ within the pixel.
*
* In all cases the pixel values are arranged in such a way that the SUB and UP
* filters give byte sequences for maximal zlib compression. By default (if
* --nofilters is not given) the SUB filter is used on the first row and the UP
* filter on all following rows.
*
* The --small option is meant to provide good test-case coverage, however the
* images are not easy to examine visually. Without the --small option the
* images contain identical color values; the pixel values are adjusted
* according to the gamma encoding with no gamma encoding being interpreted as
* sRGB.
*
* LICENSING
* =========
*
* This code is copyright of the authors, see the COPYRIGHT define above. The
* code is licensed as above, using the libpng license. The code generates
* images which are solely the product of the code; the options choose which of
* the many possibilities to generate. The images that result (but not the code
* which generates them) are licensed as defined here:
*
* IMPORTANT: the COPYRIGHT #define must contain ISO-Latin-1 characters, the
* IMAGE_LICENSING #define must contain UTF-8 characters. The 'copyright'
* symbol 0xA9U (\251) in ISO-Latin-1 encoding and 0xC20xA9 (\302\251) in UTF-8.
*/
#define _ISOC99_SOURCE /* for strtoull */
#define IMAGE_LICENSING "Dedicated to the public domain per Creative Commons "\
"license \"CC0 1.0\"; https://creativecommons.org/publicdomain/zero/1.0/"
#include <stddef.h> /* for offsetof */
#include <stdlib.h>
@ -82,8 +130,10 @@
#include <ctype.h>
#include <math.h>
#include <errno.h>
#include <assert.h>
#include <stdint.h>
#if (defined HAVE_CONFIG_H) && !(defined PNG_NO_CONFIG_H)
#if defined(HAVE_CONFIG_H) && !defined(PNG_NO_CONFIG_H)
# include <config.h>
#endif
@ -96,6 +146,25 @@
# include "../../png.h"
#endif
#include <zlib.h>
/* Work round for GCC complaints about casting a (double) function result to
* an unsigned:
*/
static unsigned int
flooru(double d)
{
d = floor(d);
return (unsigned int)d;
}
static png_byte
floorb(double d)
{
d = floor(d);
return (png_byte)d;
}
/* This structure is used for inserting extra chunks (the --insert argument, not
* documented above.)
*/
@ -107,7 +176,7 @@ typedef struct chunk_insert
png_charp parameters[1];
} chunk_insert;
static int
static unsigned int
channels_of_type(int color_type)
{
if (color_type & PNG_COLOR_MASK_PALETTE)
@ -128,14 +197,15 @@ channels_of_type(int color_type)
}
}
static int
static unsigned int
pixel_depth_of_type(int color_type, int bit_depth)
{
return channels_of_type(color_type) * bit_depth;
}
static unsigned int
image_size_of_type(int color_type, int bit_depth, unsigned int *colors)
image_size_of_type(int color_type, int bit_depth, unsigned int *colors,
int small)
{
if (*colors)
return 16;
@ -144,7 +214,16 @@ image_size_of_type(int color_type, int bit_depth, unsigned int *colors)
{
int pixel_depth = pixel_depth_of_type(color_type, bit_depth);
if (pixel_depth < 8)
if (small)
{
if (pixel_depth <= 8) /* there will be one row */
return 1 << pixel_depth;
else
return 256;
}
else if (pixel_depth < 8)
return 64;
else if (pixel_depth > 16)
@ -217,7 +296,8 @@ generate_palette(png_colorp palette, png_bytep trans, int bit_depth,
else
{
unsigned int size = 1U << (bit_depth/2); /* 2, 4 or 16 */
unsigned int x, y, ip;
unsigned int x, y;
volatile unsigned int ip = 0;
for (x=0; x<size; ++x) for (y=0; y<size; ++y)
{
@ -281,7 +361,7 @@ set_value(png_bytep row, size_t rowbytes, png_uint_32 x, unsigned int bit_depth,
exit(1);
case 16:
value = (unsigned int)floor(65535*pow(value/65535.,conv)+.5);
value = flooru(65535*pow(value/65535.,conv)+.5);
*row++ = (png_byte)(value >> 8);
*row = (png_byte)value;
return;
@ -306,15 +386,148 @@ set_value(png_bytep row, size_t rowbytes, png_uint_32 x, unsigned int bit_depth,
}
}
static void
static int /* filter mask for row */
generate_row(png_bytep row, size_t rowbytes, unsigned int y, int color_type,
int bit_depth, png_const_bytep gamma_table, double conv,
unsigned int *colors)
unsigned int *colors, int small)
{
png_uint_32 size_max = image_size_of_type(color_type, bit_depth, colors)-1;
int filters = 0; /* file *MASK*, 0 means the default, not NONE */
png_uint_32 size_max =
image_size_of_type(color_type, bit_depth, colors, small)-1;
png_uint_32 depth_max = (1U << bit_depth)-1; /* up to 65536 */
if (colors[0] == 0) switch (channels_of_type(color_type))
if (colors[0] == 0) if (small)
{
unsigned int pixel_depth = pixel_depth_of_type(color_type, bit_depth);
/* For pixel depths less than 16 generate a single row containing all the
* possible pixel values. For 16 generate all 65536 byte pair
* combinations in a 256x256 pixel array.
*/
switch (pixel_depth)
{
case 1:
assert(y == 0 && rowbytes == 1 && size_max == 1);
row[0] = 0x6CU; /* binary: 01101100, only top 2 bits used */
filters = PNG_FILTER_NONE;
break;
case 2:
assert(y == 0 && rowbytes == 1 && size_max == 3);
row[0] = 0x1BU; /* binary 00011011, all bits used */
filters = PNG_FILTER_NONE;
break;
case 4:
assert(y == 0 && rowbytes == 8 && size_max == 15);
row[0] = 0x01U;
row[1] = 0x23U; /* SUB gives 0x22U for all following bytes */
row[2] = 0x45U;
row[3] = 0x67U;
row[4] = 0x89U;
row[5] = 0xABU;
row[6] = 0xCDU;
row[7] = 0xEFU;
filters = PNG_FILTER_SUB;
break;
case 8:
/* The row will have all the pixel values in order starting with
* '1', the SUB filter will change every byte into '1' (including
* the last, which generates pixel value '0'). Since the SUB filter
* has value 1 this should result in maximum compression.
*/
assert(y == 0 && rowbytes == 256 && size_max == 255);
for (;;)
{
row[size_max] = 0xFFU & (size_max+1);
if (size_max == 0)
break;
--size_max;
}
filters = PNG_FILTER_SUB;
break;
case 16:
/* Rows are generated such that each row has a constant difference
* between the first and second byte of each pixel and so that the
* difference increases by 1 at each row. The rows start with the
* first byte value of 0 and the value increases to 255 across the
* row.
*
* The difference starts at 1, so the first row is:
*
* 0 1 1 2 2 3 3 4 ... 254 255 255 0
*
* This means that running the SUB filter on the first row produces:
*
* [SUB==1] 0 1 0 1 0 1...
*
* Then the difference is 2 on the next row, giving:
*
* 0 2 1 3 2 4 3 5 ... 254 0 255 1
*
* When the UP filter is run on this libpng produces:
*
* [UP ==2] 0 1 0 1 0 1...
*
* And so on for all the remain rows to the final two * rows:
*
* row 254: 0 255 1 0 2 1 3 2 4 3 ... 254 253 255 254
* row 255: 0 0 1 1 2 2 3 3 4 4 ... 254 254 255 255
*/
assert(rowbytes == 512 && size_max == 255);
for (;;)
{
row[2*size_max ] = 0xFFU & size_max;
row[2*size_max+1] = 0xFFU & (size_max+y+1);
if (size_max == 0)
break;
--size_max;
}
/* The first row must include PNG_FILTER_UP so that libpng knows we
* need to keep it for the following row:
*/
filters = (y == 0 ? PNG_FILTER_SUB+PNG_FILTER_UP : PNG_FILTER_UP);
break;
case 24:
case 32:
case 48:
case 64:
/* The rows are filled by an alogorithm similar to the above, in the
* first row pixel bytes are all equal, increasing from 0 by 1 for
* each pixel. In the second row the bytes within a pixel are
* incremented 1,3,5,7,... from the previous row byte. Using an odd
* number ensures all the possible byte values are used.
*/
assert(size_max == 255 && rowbytes == 256*(pixel_depth>>3));
pixel_depth >>= 3; /* now in bytes */
while (rowbytes > 0)
{
const size_t pixel_index = --rowbytes/pixel_depth;
if (y == 0)
row[rowbytes] = 0xFFU & pixel_index;
else
{
const size_t byte_offset =
rowbytes - pixel_index * pixel_depth;
row[rowbytes] =
0xFFU & (pixel_index + (byte_offset * 2*y) + 1);
}
}
filters = (y == 0 ? PNG_FILTER_SUB+PNG_FILTER_UP : PNG_FILTER_UP);
break;
default:
assert(0/*NOT REACHED*/);
}
}
else switch (channels_of_type(color_type))
{
/* 1 channel: a square image with a diamond, the least luminous colors are on
* the edge of the image, the most luminous in the center.
@ -440,7 +653,7 @@ generate_row(png_bytep row, size_t rowbytes, unsigned int y, int color_type,
/* Palette with fixed color: the image rows are all 0 and the image width
* is 16.
*/
memset(row, rowbytes, 0);
memset(row, 0, rowbytes);
}
else if (colors[0] == channels_of_type(color_type))
@ -526,6 +739,8 @@ generate_row(png_bytep row, size_t rowbytes, unsigned int y, int color_type,
colors[0], channels_of_type(color_type));
exit(1);
}
return filters;
}
@ -554,7 +769,7 @@ makepng_error(png_structp png_ptr, png_const_charp message)
static int /* 0 on success, else an error code */
write_png(const char **name, FILE *fp, int color_type, int bit_depth,
volatile png_fixed_point gamma, chunk_insert * volatile insert,
unsigned int filters, unsigned int *colors)
unsigned int filters, unsigned int *colors, int small, int tRNS)
{
png_structp png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING,
name, makepng_error, makepng_warning);
@ -581,6 +796,15 @@ write_png(const char **name, FILE *fp, int color_type, int bit_depth,
/* Allow benign errors so that we can write PNGs with errors */
png_set_benign_errors(png_ptr, 1/*allowed*/);
/* Max out the text compression level in an attempt to make the license
* small. If --small then do the same for the IDAT.
*/
if (small)
png_set_compression_level(png_ptr, Z_BEST_COMPRESSION);
png_set_text_compression_level(png_ptr, Z_BEST_COMPRESSION);
png_init_io(png_ptr, fp);
info_ptr = png_create_info_struct(png_ptr);
@ -588,11 +812,37 @@ write_png(const char **name, FILE *fp, int color_type, int bit_depth,
png_error(png_ptr, "OOM allocating info structure");
{
unsigned int size = image_size_of_type(color_type, bit_depth, colors);
const unsigned int size =
image_size_of_type(color_type, bit_depth, colors, small);
unsigned int ysize;
png_fixed_point real_gamma = 45455; /* For sRGB */
png_byte gamma_table[256];
double conv;
/* Normally images are square, but with 'small' we want to simply generate
* all the pixel values, or all that we reasonably can:
*/
if (small)
{
const unsigned int pixel_depth =
pixel_depth_of_type(color_type, bit_depth);
if (pixel_depth <= 8U)
{
assert(size == (1U<<pixel_depth));
ysize = 1U;
}
else
{
assert(size == 256U);
ysize = 256U;
}
}
else
ysize = size;
/* This function uses the libpng values used on read to carry extra
* information about the gamma:
*/
@ -624,14 +874,14 @@ write_png(const char **name, FILE *fp, int color_type, int bit_depth,
gamma_table[0] = 0;
for (i=0; i<255; ++i)
gamma_table[i] = (png_byte)floor(pow(i/255.,conv) * 255 + 127.5);
for (i=1; i<255; ++i)
gamma_table[i] = floorb(pow(i/255.,conv) * 255 + .5);
gamma_table[255] = 255;
}
}
png_set_IHDR(png_ptr, info_ptr, size, size, bit_depth, color_type,
png_set_IHDR(png_ptr, info_ptr, size, ysize, bit_depth, color_type,
PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE);
if (color_type & PNG_COLOR_MASK_PALETTE)
@ -643,14 +893,26 @@ write_png(const char **name, FILE *fp, int color_type, int bit_depth,
npalette = generate_palette(palette, trans, bit_depth, gamma_table,
colors);
png_set_PLTE(png_ptr, info_ptr, palette, npalette);
png_set_tRNS(png_ptr, info_ptr, trans, npalette-1,
NULL/*transparent color*/);
if (tRNS)
png_set_tRNS(png_ptr, info_ptr, trans, npalette-1,
NULL/*transparent color*/);
/* Reset gamma_table to prevent the image rows being changed */
for (npalette=0; npalette<256; ++npalette)
gamma_table[npalette] = (png_byte)npalette;
}
else if (tRNS)
{
png_color_16 col;
col.red = col.green = col.blue = col.gray =
0x0101U & ((1U<<bit_depth)-1U);
col.index = 0U;
png_set_tRNS(png_ptr, info_ptr, NULL/*trans*/, 1U, &col);
}
if (gamma == PNG_DEFAULT_sRGB)
png_set_sRGB(png_ptr, info_ptr, PNG_sRGB_INTENT_ABSOLUTE);
@ -682,7 +944,11 @@ write_png(const char **name, FILE *fp, int color_type, int bit_depth,
png_set_filter(png_ptr, PNG_FILTER_TYPE_BASE, filters);
{
int passes = png_set_interlace_handling(png_ptr);
# ifdef PNG_WRITE_INTERLACING_SUPPORTED
int passes = png_set_interlace_handling(png_ptr);
# else /* !WRITE_INTERLACING */
int passes = 1;
# endif /* !WRITE_INTERLACING */
int pass;
png_size_t rowbytes = png_get_rowbytes(png_ptr, info_ptr);
@ -695,10 +961,15 @@ write_png(const char **name, FILE *fp, int color_type, int bit_depth,
{
unsigned int y;
for (y=0; y<size; ++y)
for (y=0; y<ysize; ++y)
{
generate_row(row, rowbytes, y, color_type, bit_depth,
gamma_table, conv, colors);
unsigned int row_filters =
generate_row(row, rowbytes, y, color_type, bit_depth,
gamma_table, conv, colors, small);
if (row_filters != 0 && filters == PNG_ALL_FILTERS)
png_set_filter(png_ptr, PNG_FILTER_TYPE_BASE, row_filters);
png_write_row(png_ptr, row);
}
}
@ -827,7 +1098,7 @@ static png_size_t
load_fake(png_charp param, png_bytepp profile)
{
char *endptr = NULL;
unsigned long long int size = strtoull(param, &endptr, 0/*base*/);
uint64_t size = strtoull(param, &endptr, 0/*base*/);
/* The 'fake' format is <number>*[string] */
if (endptr != NULL && *endptr == '*')
@ -1062,7 +1333,8 @@ insert_iTXt(png_structp png_ptr, png_infop info_ptr, int nparams,
}
static void
insert_hIST(png_structp png_ptr, png_infop info_ptr, int nparams, png_charpp params)
insert_hIST(png_structp png_ptr, png_infop info_ptr, int nparams,
png_charpp params)
{
int i;
png_uint_16 freq[256];
@ -1089,6 +1361,56 @@ insert_hIST(png_structp png_ptr, png_infop info_ptr, int nparams, png_charpp par
png_set_hIST(png_ptr, info_ptr, freq);
}
static png_byte
bval(png_const_structrp png_ptr, png_charp param, unsigned int maxval)
{
char *endptr = NULL;
unsigned long int l = strtoul(param, &endptr, 0/*base*/);
if (param[0] && *endptr == 0 && l <= maxval)
return (png_byte)l;
else
png_error(png_ptr, "sBIT: invalid sBIT value");
}
static void
insert_sBIT(png_structp png_ptr, png_infop info_ptr, int nparams,
png_charpp params)
{
const int ct = png_get_color_type(png_ptr, info_ptr);
const int c = (ct & PNG_COLOR_MASK_COLOR ? 3 : 1) +
(ct & PNG_COLOR_MASK_ALPHA ? 1 : 0);
const unsigned int maxval =
ct & PNG_COLOR_MASK_PALETTE ? 8U : png_get_bit_depth(png_ptr, info_ptr);
png_color_8 sBIT;
if (nparams != c)
png_error(png_ptr, "sBIT: incorrect parameter count");
if (ct & PNG_COLOR_MASK_COLOR)
{
sBIT.red = bval(png_ptr, params[0], maxval);
sBIT.green = bval(png_ptr, params[1], maxval);
sBIT.blue = bval(png_ptr, params[2], maxval);
sBIT.gray = 42;
}
else
{
sBIT.red = sBIT.green = sBIT.blue = 42;
sBIT.gray = bval(png_ptr, params[0], maxval);
}
if (ct & PNG_COLOR_MASK_ALPHA)
sBIT.alpha = bval(png_ptr, params[nparams-1], maxval);
else
sBIT.alpha = 42;
png_set_sBIT(png_ptr, info_ptr, &sBIT);
}
#if 0
static void
insert_sPLT(png_structp png_ptr, png_infop info_ptr, int nparams, png_charpp params)
@ -1216,6 +1538,11 @@ find_insert(png_const_charp what, png_charp param)
return make_insert(what, insert_hIST, nparams, parameter_list);
break;
case CHUNK(115,66,73,84): /* sBIT */
if (nparams <= 4)
return make_insert(what, insert_sBIT, nparams, parameter_list);
break;
#if 0
case CHUNK(115,80,76,84): /* sPLT */
return make_insert(what, insert_sPLT, nparams, parameter_list);
@ -1231,6 +1558,80 @@ find_insert(png_const_charp what, png_charp param)
return NULL;
}
/* This is necessary because libpng expects writeable strings for things like
* text chunks (maybe this should be fixed...)
*/
static png_charp
strstash(png_const_charp foo)
{
/* The program indicates a memory allocation error by crashing, this is by
* design.
*/
if (foo != NULL)
{
png_charp bar = malloc(strlen(foo)+1);
return strcpy(bar, foo);
}
return NULL;
}
static png_charp
strstash_list(const png_const_charp *text)
{
size_t foo = 0;
png_charp result, bar;
const png_const_charp *line = text;
while (*line != NULL)
foo += strlen(*line++);
result = bar = malloc(foo+1);
line = text;
while (*line != NULL)
{
foo = strlen(*line);
memcpy(bar, *line++, foo);
bar += foo;
}
*bar = 0;
return result;
}
/* These are used to insert Copyright and Licence fields, they allow the text to
* have \n unlike the --insert option.
*/
static chunk_insert *
add_tEXt(const char *key, const png_const_charp *text)
{
static char what[5] = { 116, 69, 88, 116, 0 };
png_charp parameter_list[3];
parameter_list[0] = strstash(key);
parameter_list[1] = strstash_list(text);
parameter_list[2] = NULL;
return make_insert(what, insert_tEXt, 2, parameter_list);
}
static chunk_insert *
add_iTXt(const char *key, const char *language, const char *language_key,
const png_const_charp *text)
{
static char what[5] = { 105, 84, 88, 116, 0 };
png_charp parameter_list[5];
parameter_list[0] = strstash(key);
parameter_list[1] = strstash(language);
parameter_list[2] = strstash(language_key);
parameter_list[3] = strstash_list(text);
parameter_list[4] = NULL;
return make_insert(what, insert_iTXt, 4, parameter_list);
}
/* This is a not-very-good parser for a sequence of numbers (including 0). It
* doesn't accept some apparently valid things, but it accepts all the sensible
* combinations.
@ -1280,6 +1681,8 @@ main(int argc, char **argv)
const char *file_name = NULL;
int color_type = 8; /* invalid */
int bit_depth = 32; /* invalid */
int small = 0; /* make full size images */
int tRNS = 0; /* don't output a tRNS chunk */
unsigned int colors[5];
unsigned int filters = PNG_ALL_FILTERS;
png_fixed_point gamma = 0; /* not set */
@ -1292,6 +1695,18 @@ main(int argc, char **argv)
{
char *arg = *++argv;
if (strcmp(arg, "--small") == 0)
{
small = 1;
continue;
}
if (strcmp(arg, "--tRNS") == 0)
{
tRNS = 1;
continue;
}
if (strcmp(arg, "--sRGB") == 0)
{
gamma = PNG_DEFAULT_sRGB;
@ -1432,9 +1847,10 @@ main(int argc, char **argv)
if (color_type == 8 || bit_depth == 32)
{
fprintf(stderr, "usage: makepng [--sRGB|--linear|--1.8] "
fprintf(stderr, "usage: makepng [--small] [--sRGB|--linear|--1.8] "
"[--color=...] color-type bit-depth [file-name]\n"
" Make a test PNG file, by default writes to stdout.\n");
" Make a test PNG file, by default writes to stdout.\n"
" Other options are available, UTSL.\n");
exit(1);
}
@ -1453,10 +1869,19 @@ main(int argc, char **argv)
}
}
/* small and colors are incomparible (will probably crash if both are used at
* the same time!)
*/
if (small && colors[0] != 0)
{
fprintf(stderr, "makepng: --color --small: only one at a time!\n");
exit(1);
}
/* Restrict the filters for more speed to those we know are used for the
* generated images.
*/
if (filters == PNG_ALL_FILTERS)
if (filters == PNG_ALL_FILTERS && !small/*small provides defaults*/)
{
if ((color_type & PNG_COLOR_MASK_PALETTE) != 0 || bit_depth < 8)
filters = PNG_FILTER_NONE;
@ -1474,9 +1899,39 @@ main(int argc, char **argv)
filters &= ~PNG_FILTER_NONE;
}
/* Insert standard copyright and licence text. */
{
static png_const_charp copyright[] =
{
COPYRIGHT, /* ISO-Latin-1 */
NULL
};
static png_const_charp licensing[] =
{
IMAGE_LICENSING, /* UTF-8 */
NULL
};
chunk_insert *new_insert;
new_insert = add_tEXt("Copyright", copyright);
if (new_insert != NULL)
{
*insert_ptr = new_insert;
insert_ptr = &new_insert->next;
}
new_insert = add_iTXt("Licensing", "en", NULL, licensing);
if (new_insert != NULL)
{
*insert_ptr = new_insert;
insert_ptr = &new_insert->next;
}
}
{
int ret = write_png(&file_name, fp, color_type, bit_depth, gamma,
head_insert, filters, colors);
head_insert, filters, colors, small, tRNS);
if (ret != 0 && file_name != NULL)
remove(file_name);

1712
contrib/libtests/pngimage.c Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,165 @@
/* contrib/libtests/pngstest-errors.h
*
* BUILT USING: libpng version 1.7.0beta66 - September 18, 2015
*
* This code is released under the libpng license.
* For conditions of distribution and use, see the disclaimer
* and license in png.h
*
* THIS IS A MACHINE GENERATED FILE: do not edit it directly!
* Instead run:
*
* pngstest --accumulate
*
* on as many PNG files as possible; at least PNGSuite and
* contrib/libtests/testpngs.
*/
static png_uint_16 gpc_error[16/*in*/][16/*out*/][4/*a*/] =
{
{ /* input: sRGB-gray */
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 },
{ 0, 0, 372, 0 }, { 0, 0, 372, 0 }, { 0, 0, 372, 0 }, { 0, 0, 372, 0 },
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 },
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }
}, { /* input: sRGB-gray+alpha */
{ 0, 19, 1, 0 }, { 0, 0, 0, 0 }, { 0, 20, 1, 0 }, { 0, 0, 0, 0 },
{ 0, 897, 788, 0 }, { 0, 897, 788, 0 }, { 0, 897, 788, 0 }, { 0, 897, 788, 0 },
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 },
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }
}, { /* input: sRGB-rgb */
{ 0, 0, 19, 0 }, { 0, 0, 19, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 },
{ 0, 0, 893, 0 }, { 0, 0, 893, 0 }, { 0, 0, 811, 0 }, { 0, 0, 811, 0 },
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 },
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }
}, { /* input: sRGB-rgb+alpha */
{ 0, 14, 13, 0 }, { 0, 15, 13, 0 }, { 0, 19, 1, 0 }, { 0, 0, 0, 0 },
{ 0, 832, 764, 0 }, { 0, 832, 764, 0 }, { 0, 897, 788, 0 }, { 0, 897, 788, 0 },
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 },
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }
}, { /* input: linear-gray */
{ 0, 0, 9, 0 }, { 0, 0, 9, 0 }, { 0, 0, 9, 0 }, { 0, 0, 9, 0 },
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 },
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 },
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }
}, { /* input: linear-gray+alpha */
{ 0, 74, 9, 0 }, { 0, 20, 9, 0 }, { 0, 74, 9, 0 }, { 0, 20, 9, 0 },
{ 0, 0, 0, 0 }, { 0, 1, 0, 0 }, { 0, 0, 0, 0 }, { 0, 1, 0, 0 },
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 },
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }
}, { /* input: linear-rgb */
{ 0, 0, 9, 0 }, { 0, 0, 9, 0 }, { 0, 0, 9, 0 }, { 0, 0, 9, 0 },
{ 0, 0, 4, 0 }, { 0, 0, 4, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 },
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 },
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }
}, { /* input: linear-rgb+alpha */
{ 0, 126, 143, 0 }, { 0, 11, 7, 0 }, { 0, 74, 9, 0 }, { 0, 17, 9, 0 },
{ 0, 4, 4, 0 }, { 0, 5, 4, 0 }, { 0, 0, 0, 0 }, { 0, 1, 0, 0 },
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 },
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }
}, { /* input: color-mapped-sRGB-gray */
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 },
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 },
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 },
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }
}, { /* input: color-mapped-sRGB-gray+alpha */
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 },
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 },
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 },
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }
}, { /* input: color-mapped-sRGB-rgb */
{ 0, 0, 13, 0 }, { 0, 0, 13, 0 }, { 0, 0, 8, 0 }, { 0, 0, 8, 0 },
{ 0, 0, 673, 0 }, { 0, 0, 673, 0 }, { 0, 0, 674, 0 }, { 0, 0, 674, 0 },
{ 0, 0, 1, 0 }, { 0, 0, 1, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 },
{ 0, 0, 460, 0 }, { 0, 0, 460, 0 }, { 0, 0, 263, 0 }, { 0, 0, 263, 0 }
}, { /* input: color-mapped-sRGB-rgb+alpha */
{ 0, 6, 8, 0 }, { 0, 7, 8, 0 }, { 0, 75, 8, 0 }, { 0, 9, 8, 0 },
{ 0, 585, 427, 0 }, { 0, 585, 427, 0 }, { 0, 717, 584, 0 }, { 0, 717, 584, 0 },
{ 0, 1, 1, 0 }, { 0, 1, 1, 0 }, { 0, 1, 0, 0 }, { 0, 0, 0, 0 },
{ 0, 13323, 460, 0 }, { 0, 427, 460, 0 }, { 0, 16480, 263, 0 }, { 0, 243, 263, 0 }
}, { /* input: color-mapped-linear-gray */
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 },
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 },
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 },
{ 0, 0, 282, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }
}, { /* input: color-mapped-linear-gray+alpha */
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 },
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 },
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 },
{ 0, 0, 0, 0 }, { 0, 253, 282, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }
}, { /* input: color-mapped-linear-rgb */
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 },
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 },
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 },
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 265, 0 }, { 0, 0, 0, 0 }
}, { /* input: color-mapped-linear-rgb+alpha */
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 },
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 },
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 },
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 243, 265, 0 }
}
};
static png_uint_16 gpc_error_via_linear[16][4/*out*/][4] =
{
{ /* input: sRGB-gray */
{ 0, 0, 7, 0 }, { 0, 0, 7, 0 }, { 0, 0, 7, 0 }, { 0, 0, 7, 0 }
}, { /* input: sRGB-gray+alpha */
{ 0, 15, 15, 0 }, { 0, 186, 15, 0 }, { 0, 15, 15, 0 }, { 0, 186, 15, 0 }
}, { /* input: sRGB-rgb */
{ 0, 0, 20, 0 }, { 0, 0, 20, 0 }, { 0, 0, 15, 0 }, { 0, 0, 15, 0 }
}, { /* input: sRGB-rgb+alpha */
{ 0, 12, 14, 0 }, { 0, 180, 14, 0 }, { 0, 15, 15, 0 }, { 0, 186, 15, 0 }
}, { /* input: linear-gray */
{ 0, 0, 1, 0 }, { 0, 0, 1, 0 }, { 0, 0, 1, 0 }, { 0, 0, 1, 0 }
}, { /* input: linear-gray+alpha */
{ 0, 1, 1, 0 }, { 0, 1, 1, 0 }, { 0, 1, 1, 0 }, { 0, 1, 1, 0 }
}, { /* input: linear-rgb */
{ 0, 0, 1, 0 }, { 0, 0, 1, 0 }, { 0, 0, 1, 0 }, { 0, 0, 1, 0 }
}, { /* input: linear-rgb+alpha */
{ 0, 1, 1, 0 }, { 0, 9, 1, 0 }, { 0, 1, 1, 0 }, { 0, 1, 1, 0 }
}, { /* input: color-mapped-sRGB-gray */
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }
}, { /* input: color-mapped-sRGB-gray+alpha */
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }
}, { /* input: color-mapped-sRGB-rgb */
{ 0, 0, 13, 0 }, { 0, 0, 13, 0 }, { 0, 0, 14, 0 }, { 0, 0, 14, 0 }
}, { /* input: color-mapped-sRGB-rgb+alpha */
{ 0, 4, 8, 0 }, { 0, 9, 8, 0 }, { 0, 9, 9, 0 }, { 0, 32, 9, 0 }
}, { /* input: color-mapped-linear-gray */
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }
}, { /* input: color-mapped-linear-gray+alpha */
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }
}, { /* input: color-mapped-linear-rgb */
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }
}, { /* input: color-mapped-linear-rgb+alpha */
{ 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }, { 0, 0, 0, 0 }
}
};
static png_uint_16 gpc_error_to_colormap[8/*i*/][8/*o*/][4] =
{
{ /* input: sRGB-gray */
{ 0, 0, 9, 0 }, { 0, 0, 9, 0 }, { 0, 0, 9, 0 }, { 0, 0, 9, 0 },
{ 0, 0, 742, 0 }, { 0, 0, 742, 0 }, { 0, 0, 742, 0 }, { 0, 0, 742, 0 }
}, { /* input: sRGB-gray+alpha */
{ 0, 19, 6, 0 }, { 0, 255, 6, 25 }, { 0, 88, 6, 0 }, { 0, 255, 6, 25 },
{ 0, 1012, 911, 0 }, { 0, 16026, 911, 6425 }, { 0, 1012, 911, 0 }, { 0, 16026, 911, 6425 }
}, { /* input: sRGB-rgb */
{ 0, 0, 19, 0 }, { 0, 0, 19, 0 }, { 0, 0, 25, 0 }, { 0, 0, 25, 0 },
{ 0, 0, 962, 0 }, { 0, 0, 962, 0 }, { 0, 0, 13677, 0 }, { 0, 0, 13677, 0 }
}, { /* input: sRGB-rgb+alpha */
{ 0, 63, 77, 0 }, { 0, 255, 19, 25 }, { 0, 225, 25, 0 }, { 0, 255, 25, 67 },
{ 0, 17534, 18491, 0 }, { 0, 15998, 2824, 6425 }, { 0, 14103, 13677, 0 }, { 0, 50115, 13677, 17219 }
}, { /* input: linear-gray */
{ 0, 0, 73, 0 }, { 0, 0, 73, 0 }, { 0, 0, 73, 0 }, { 0, 0, 73, 0 },
{ 0, 0, 18817, 0 }, { 0, 0, 18817, 0 }, { 0, 0, 18817, 0 }, { 0, 0, 18817, 0 }
}, { /* input: linear-gray+alpha */
{ 0, 74, 74, 0 }, { 0, 255, 74, 25 }, { 0, 100, 74, 0 }, { 0, 255, 74, 25 },
{ 0, 18919, 18907, 0 }, { 0, 24549, 18907, 6553 }, { 0, 18919, 18907, 0 }, { 0, 24549, 18907, 6553 }
}, { /* input: linear-rgb */
{ 0, 0, 73, 0 }, { 0, 0, 73, 0 }, { 0, 0, 98, 0 }, { 0, 0, 98, 0 },
{ 0, 0, 18664, 0 }, { 0, 0, 18664, 0 }, { 0, 0, 24998, 0 }, { 0, 0, 24998, 0 }
}, { /* input: linear-rgb+alpha */
{ 0, 181, 196, 0 }, { 0, 255, 61, 25 }, { 206, 192, 98, 0 }, { 0, 255, 98, 67 },
{ 0, 18141, 18137, 0 }, { 0, 17494, 17504, 6553 }, { 0, 24979, 24992, 0 }, { 0, 49172, 24992, 17347 }
}
};
/* END MACHINE GENERATED */

File diff suppressed because it is too large Load Diff

View File

@ -1,8 +1,8 @@
/* pngunknown.c - test the read side unknown chunk handling
*
* Last changed in libpng 1.6.0 [(PENDING RELEASE)]
* Copyright (c) 2012 Glenn Randers-Pehrson
* Last changed in libpng 1.6.26 [October 20, 2016]
* Copyright (c) 2015,2016 Glenn Randers-Pehrson
* Written by John Cunningham Bowler
*
* This code is released under the libpng license.
@ -30,7 +30,30 @@
# include "../../png.h"
#endif
#ifdef PNG_READ_SUPPORTED
/* 1.6.1 added support for the configure test harness, which uses 77 to indicate
* a skipped test, in earlier versions we need to succeed on a skipped test, so:
*/
#if PNG_LIBPNG_VER >= 10601 && defined(HAVE_CONFIG_H)
# define SKIP 77
#else
# define SKIP 0
#endif
/* Since this program tests the ability to change the unknown chunk handling
* these must be defined:
*/
#if defined(PNG_SET_UNKNOWN_CHUNKS_SUPPORTED) &&\
defined(PNG_STDIO_SUPPORTED) &&\
defined(PNG_READ_SUPPORTED)
/* One of these must be defined to allow us to find out what happened. It is
* still useful to set unknown chunk handling without either of these in order
* to cause *known* chunks to be discarded. This can be a significant
* efficiency gain, but it can't really be tested here.
*/
#if defined(PNG_READ_USER_CHUNKS_SUPPORTED) ||\
defined(PNG_SAVE_UNKNOWN_CHUNKS_SUPPORTED)
#if PNG_LIBPNG_VER < 10500
/* This deliberately lacks the PNG_CONST. */
@ -75,43 +98,74 @@ typedef png_byte *png_const_bytep;
# define png_const_structp png_structp
#endif
#if PNG_LIBPNG_VER < 10700
/* Copied from libpng 1.7.0 png.h */
#define PNG_u2(b1, b2) (((unsigned int)(b1) << 8) + (b2))
/* Copied from pngpriv.h */
#define PNG_32b(b,s) ((png_uint_32)(b) << (s))
#define PNG_CHUNK(b1,b2,b3,b4) \
(PNG_32b(b1,24) | PNG_32b(b2,16) | PNG_32b(b3,8) | PNG_32b(b4,0))
#define PNG_U16(b1, b2) ((png_uint_16)PNG_u2(b1, b2))
#define PNG_U32(b1, b2, b3, b4)\
(((png_uint_32)PNG_u2(b1, b2) << 16) + PNG_u2(b3, b4))
#define png_IHDR PNG_CHUNK( 73, 72, 68, 82)
#define png_IDAT PNG_CHUNK( 73, 68, 65, 84)
#define png_IEND PNG_CHUNK( 73, 69, 78, 68)
#define png_PLTE PNG_CHUNK( 80, 76, 84, 69)
#define png_bKGD PNG_CHUNK( 98, 75, 71, 68)
#define png_cHRM PNG_CHUNK( 99, 72, 82, 77)
#define png_gAMA PNG_CHUNK(103, 65, 77, 65)
#define png_hIST PNG_CHUNK(104, 73, 83, 84)
#define png_iCCP PNG_CHUNK(105, 67, 67, 80)
#define png_iTXt PNG_CHUNK(105, 84, 88, 116)
#define png_oFFs PNG_CHUNK(111, 70, 70, 115)
#define png_pCAL PNG_CHUNK(112, 67, 65, 76)
#define png_sCAL PNG_CHUNK(115, 67, 65, 76)
#define png_pHYs PNG_CHUNK(112, 72, 89, 115)
#define png_sBIT PNG_CHUNK(115, 66, 73, 84)
#define png_sPLT PNG_CHUNK(115, 80, 76, 84)
#define png_sRGB PNG_CHUNK(115, 82, 71, 66)
#define png_sTER PNG_CHUNK(115, 84, 69, 82)
#define png_tEXt PNG_CHUNK(116, 69, 88, 116)
#define png_tIME PNG_CHUNK(116, 73, 77, 69)
#define png_tRNS PNG_CHUNK(116, 82, 78, 83)
#define png_zTXt PNG_CHUNK(122, 84, 88, 116)
#define png_vpAg PNG_CHUNK('v', 'p', 'A', 'g')
/* Constants for known chunk types.
*/
#define png_IDAT PNG_U32( 73, 68, 65, 84)
#define png_IEND PNG_U32( 73, 69, 78, 68)
#define png_IHDR PNG_U32( 73, 72, 68, 82)
#define png_PLTE PNG_U32( 80, 76, 84, 69)
#define png_bKGD PNG_U32( 98, 75, 71, 68)
#define png_cHRM PNG_U32( 99, 72, 82, 77)
#define png_fRAc PNG_U32(102, 82, 65, 99) /* registered, not defined */
#define png_gAMA PNG_U32(103, 65, 77, 65)
#define png_gIFg PNG_U32(103, 73, 70, 103)
#define png_gIFt PNG_U32(103, 73, 70, 116) /* deprecated */
#define png_gIFx PNG_U32(103, 73, 70, 120)
#define png_hIST PNG_U32(104, 73, 83, 84)
#define png_iCCP PNG_U32(105, 67, 67, 80)
#define png_iTXt PNG_U32(105, 84, 88, 116)
#define png_oFFs PNG_U32(111, 70, 70, 115)
#define png_pCAL PNG_U32(112, 67, 65, 76)
#define png_pHYs PNG_U32(112, 72, 89, 115)
#define png_sBIT PNG_U32(115, 66, 73, 84)
#define png_sCAL PNG_U32(115, 67, 65, 76)
#define png_sPLT PNG_U32(115, 80, 76, 84)
#define png_sRGB PNG_U32(115, 82, 71, 66)
#define png_sTER PNG_U32(115, 84, 69, 82)
#define png_tEXt PNG_U32(116, 69, 88, 116)
#define png_tIME PNG_U32(116, 73, 77, 69)
#define png_tRNS PNG_U32(116, 82, 78, 83)
#define png_zTXt PNG_U32(122, 84, 88, 116)
/* Test on flag values as defined in the spec (section 5.4): */
#define PNG_CHUNK_ANCILLARY(c ) (1 & ((c) >> 29))
#define PNG_CHUNK_ANCILLARY(c) (1 & ((c) >> 29))
#define PNG_CHUNK_CRITICAL(c) (!PNG_CHUNK_ANCILLARY(c))
#define PNG_CHUNK_PRIVATE(c) (1 & ((c) >> 21))
#define PNG_CHUNK_RESERVED(c) (1 & ((c) >> 13))
#define PNG_CHUNK_SAFE_TO_COPY(c) (1 & ((c) >> 5))
#endif /* PNG_LIBPNG_VER < 10700 */
#ifdef __cplusplus
# define this not_the_cpp_this
# define new not_the_cpp_new
# define voidcast(type, value) static_cast<type>(value)
#else
# define voidcast(type, value) (value)
#endif /* __cplusplus */
/* Unused formal parameter errors are removed using the following macro which is
* expected to have no bad effects on performance.
*/
#ifndef UNUSED
# if defined(__GNUC__) || defined(_MSC_VER)
# define UNUSED(param) (void)param;
# else
# define UNUSED(param)
# endif
#endif
/* Types of chunks not known to libpng */
#define png_vpAg PNG_U32(118, 112, 65, 103)
/* Chunk information */
#define PNG_INFO_tEXt 0x10000000U
#define PNG_INFO_iTXt 0x20000000U
@ -139,23 +193,128 @@ static struct
{ "PLTE", PNG_INFO_PLTE, png_PLTE, 0, 0, ABSENT, 0 },
/* Non-critical chunks that libpng handles */
{ "bKGD", PNG_INFO_bKGD, png_bKGD, 0, 1, START, 0 },
{ "cHRM", PNG_INFO_cHRM, png_cHRM, 0, 1, START, 0 },
{ "gAMA", PNG_INFO_gAMA, png_gAMA, 0, 1, START, 0 },
{ "hIST", PNG_INFO_hIST, png_hIST, 0, 1, ABSENT, 0 },
{ "iCCP", PNG_INFO_iCCP, png_iCCP, 0, 1, ABSENT, 0 },
{ "iTXt", PNG_INFO_iTXt, png_iTXt, 0, 1, ABSENT, 0 },
{ "oFFs", PNG_INFO_oFFs, png_oFFs, 0, 1, START, 0 },
{ "pCAL", PNG_INFO_pCAL, png_pCAL, 0, 1, START, 0 },
{ "pHYs", PNG_INFO_pHYs, png_pHYs, 0, 1, START, 0 },
{ "sBIT", PNG_INFO_sBIT, png_sBIT, 0, 1, START, 0 },
{ "sCAL", PNG_INFO_sCAL, png_sCAL, 0, 1, START, 0 },
{ "sPLT", PNG_INFO_sPLT, png_sPLT, 0, 1, ABSENT, 0 },
{ "sRGB", PNG_INFO_sRGB, png_sRGB, 0, 1, START, 0 },
{ "tEXt", PNG_INFO_tEXt, png_tEXt, 0, 1, START, 0 },
{ "tIME", PNG_INFO_tIME, png_tIME, 0, 1, START, 0 },
{ "tRNS", PNG_INFO_tRNS, png_tRNS, 0, 0, ABSENT, 0 },
{ "zTXt", PNG_INFO_zTXt, png_zTXt, 0, 1, END, 0 },
/* This is a mess but it seems to be the only way to do it - there is no way
* to check for a definition outside a #if.
*/
{ "bKGD", PNG_INFO_bKGD, png_bKGD,
# ifdef PNG_READ_bKGD_SUPPORTED
0,
# else
1,
# endif
1, START, 0 },
{ "cHRM", PNG_INFO_cHRM, png_cHRM,
# ifdef PNG_READ_cHRM_SUPPORTED
0,
# else
1,
# endif
1, START, 0 },
{ "gAMA", PNG_INFO_gAMA, png_gAMA,
# ifdef PNG_READ_gAMA_SUPPORTED
0,
# else
1,
# endif
1, START, 0 },
{ "hIST", PNG_INFO_hIST, png_hIST,
# ifdef PNG_READ_hIST_SUPPORTED
0,
# else
1,
# endif
1, ABSENT, 0 },
{ "iCCP", PNG_INFO_iCCP, png_iCCP,
# ifdef PNG_READ_iCCP_SUPPORTED
0,
# else
1,
# endif
1, ABSENT, 0 },
{ "iTXt", PNG_INFO_iTXt, png_iTXt,
# ifdef PNG_READ_iTXt_SUPPORTED
0,
# else
1,
# endif
1, ABSENT, 0 },
{ "oFFs", PNG_INFO_oFFs, png_oFFs,
# ifdef PNG_READ_oFFs_SUPPORTED
0,
# else
1,
# endif
1, START, 0 },
{ "pCAL", PNG_INFO_pCAL, png_pCAL,
# ifdef PNG_READ_pCAL_SUPPORTED
0,
# else
1,
# endif
1, START, 0 },
{ "pHYs", PNG_INFO_pHYs, png_pHYs,
# ifdef PNG_READ_pHYs_SUPPORTED
0,
# else
1,
# endif
1, START, 0 },
{ "sBIT", PNG_INFO_sBIT, png_sBIT,
# ifdef PNG_READ_sBIT_SUPPORTED
0,
# else
1,
# endif
1, START, 0 },
{ "sCAL", PNG_INFO_sCAL, png_sCAL,
# ifdef PNG_READ_sCAL_SUPPORTED
0,
# else
1,
# endif
1, START, 0 },
{ "sPLT", PNG_INFO_sPLT, png_sPLT,
# ifdef PNG_READ_sPLT_SUPPORTED
0,
# else
1,
# endif
1, ABSENT, 0 },
{ "sRGB", PNG_INFO_sRGB, png_sRGB,
# ifdef PNG_READ_sRGB_SUPPORTED
0,
# else
1,
# endif
1, START, 0 },
{ "tEXt", PNG_INFO_tEXt, png_tEXt,
# ifdef PNG_READ_tEXt_SUPPORTED
0,
# else
1,
# endif
1, START, 0 },
{ "tIME", PNG_INFO_tIME, png_tIME,
# ifdef PNG_READ_tIME_SUPPORTED
0,
# else
1,
# endif
1, START, 0 },
{ "tRNS", PNG_INFO_tRNS, png_tRNS,
# ifdef PNG_READ_tRNS_SUPPORTED
0,
# else
1,
# endif
0, ABSENT, 0 },
{ "zTXt", PNG_INFO_zTXt, png_zTXt,
# ifdef PNG_READ_zTXt_SUPPORTED
0,
# else
1,
# endif
1, END, 0 },
/* No libpng handling */
{ "sTER", PNG_INFO_sTER, png_sTER, 1, 1, START, 0 },
@ -212,14 +371,16 @@ find_by_flag(png_uint_32 flag)
static int
ancillary(const char *name)
{
return PNG_CHUNK_ANCILLARY(PNG_CHUNK(name[0], name[1], name[2], name[3]));
return PNG_CHUNK_ANCILLARY(PNG_U32(name[0], name[1], name[2], name[3]));
}
#ifdef PNG_SAVE_UNKNOWN_CHUNKS_SUPPORTED
static int
ancillaryb(const png_byte *name)
{
return PNG_CHUNK_ANCILLARY(PNG_CHUNK(name[0], name[1], name[2], name[3]));
return PNG_CHUNK_ANCILLARY(PNG_U32(name[0], name[1], name[2], name[3]));
}
#endif
/* Type of an error_ptr */
typedef struct
@ -227,8 +388,11 @@ typedef struct
jmp_buf error_return;
png_structp png_ptr;
png_infop info_ptr, end_ptr;
png_uint_32 before_IDAT;
png_uint_32 after_IDAT;
int error_count;
int warning_count;
int keep; /* the default value */
const char *program;
const char *file;
const char *test;
@ -261,9 +425,6 @@ clean_display(display *d)
d->test);
exit(1);
}
/* Invalidate the test */
d->test = init;
}
PNG_FUNCTION(void, display_exit, (display *d), static PNG_NORETURN)
@ -289,7 +450,7 @@ display_rc(const display *d, int strict)
}
/* libpng error and warning callbacks */
PNG_FUNCTION(void, error, (png_structp png_ptr, const char *message),
PNG_FUNCTION(void, (PNGCBAPI error), (png_structp png_ptr, const char *message),
static PNG_NORETURN)
{
display *d = (display*)png_get_error_ptr(png_ptr);
@ -298,7 +459,7 @@ PNG_FUNCTION(void, error, (png_structp png_ptr, const char *message),
display_exit(d);
}
static void
static void PNGCBAPI
warning(png_structp png_ptr, const char *message)
{
display *d = (display*)png_get_error_ptr(png_ptr);
@ -308,7 +469,7 @@ warning(png_structp png_ptr, const char *message)
}
static png_uint_32
get_valid(display *d, png_const_infop info_ptr)
get_valid(display *d, png_infop info_ptr)
{
png_uint_32 flags = png_get_valid(d->png_ptr, info_ptr, (png_uint_32)~0);
@ -317,7 +478,7 @@ get_valid(display *d, png_const_infop info_ptr)
png_textp text;
png_uint_32 ntext = png_get_text(d->png_ptr, info_ptr, &text, NULL);
while (ntext-- > 0) switch (text[ntext].compression)
while (ntext > 0) switch (text[--ntext].compression)
{
case -1:
flags |= PNG_INFO_tEXt;
@ -339,11 +500,88 @@ get_valid(display *d, png_const_infop info_ptr)
return flags;
}
#ifdef PNG_READ_USER_CHUNKS_SUPPORTED
static int PNGCBAPI
read_callback(png_structp pp, png_unknown_chunkp pc)
{
/* This function mimics the behavior of png_set_keep_unknown_chunks by
* returning '0' to keep the chunk and '1' to discard it.
*/
display *d = voidcast(display*, png_get_user_chunk_ptr(pp));
int chunk = findb(pc->name);
int keep, discard;
if (chunk < 0) /* not one in our list, so not a known chunk */
keep = d->keep;
else
{
keep = chunk_info[chunk].keep;
if (keep == PNG_HANDLE_CHUNK_AS_DEFAULT)
{
/* See the comments in png.h - use the default for unknown chunks,
* do not keep known chunks.
*/
if (chunk_info[chunk].unknown)
keep = d->keep;
else
keep = PNG_HANDLE_CHUNK_NEVER;
}
}
switch (keep)
{
default:
fprintf(stderr, "%s(%s): %d: unrecognized chunk option\n", d->file,
d->test, chunk_info[chunk].keep);
display_exit(d);
case PNG_HANDLE_CHUNK_AS_DEFAULT:
case PNG_HANDLE_CHUNK_NEVER:
discard = 1/*handled; discard*/;
break;
case PNG_HANDLE_CHUNK_IF_SAFE:
case PNG_HANDLE_CHUNK_ALWAYS:
discard = 0/*not handled; keep*/;
break;
}
/* Also store information about this chunk in the display, the relevant flag
* is set if the chunk is to be kept ('not handled'.)
*/
if (chunk >= 0) if (!discard) /* stupidity to stop a GCC warning */
{
png_uint_32 flag = chunk_info[chunk].flag;
if (pc->location & PNG_AFTER_IDAT)
d->after_IDAT |= flag;
else
d->before_IDAT |= flag;
}
/* However if there is no support to store unknown chunks don't ask libpng to
* do it; there will be an png_error.
*/
# ifdef PNG_SAVE_UNKNOWN_CHUNKS_SUPPORTED
return discard;
# else
return 1; /*handled; discard*/
# endif
}
#endif /* READ_USER_CHUNKS_SUPPORTED */
#ifdef PNG_SAVE_UNKNOWN_CHUNKS_SUPPORTED
static png_uint_32
get_unknown(display *d, int def, png_const_infop info_ptr)
get_unknown(display *d, png_infop info_ptr, int after_IDAT)
{
/* Create corresponding 'unknown' flags */
png_uint_32 flags = 0;
UNUSED(after_IDAT)
{
png_unknown_chunkp unknown;
int num_unknown = png_get_unknown_chunks(d->png_ptr, info_ptr, &unknown);
@ -353,16 +591,16 @@ get_unknown(display *d, int def, png_const_infop info_ptr)
int chunk = findb(unknown[num_unknown].name);
/* Chunks not known to pngunknown must be validated here; since they
* must also be unknown to libpng the 'def' behavior should have been
* used.
* must also be unknown to libpng the 'display->keep' behavior should
* have been used.
*/
if (chunk < 0) switch (def)
if (chunk < 0) switch (d->keep)
{
default: /* impossible */
case PNG_HANDLE_CHUNK_AS_DEFAULT:
case PNG_HANDLE_CHUNK_NEVER:
fprintf(stderr, "%s(%s): %s: %s: unknown chunk saved\n",
d->file, d->test, def ? "discard" : "default",
d->file, d->test, d->keep ? "discard" : "default",
unknown[num_unknown].name);
++(d->error_count);
break;
@ -388,14 +626,39 @@ get_unknown(display *d, int def, png_const_infop info_ptr)
return flags;
}
#else /* SAVE_UNKNOWN_CHUNKS */
static png_uint_32
get_unknown(display *d, png_infop info_ptr, int after_IDAT)
/* Otherwise this will return the cached values set by any user callback */
{
UNUSED(info_ptr);
if (after_IDAT)
return d->after_IDAT;
else
return d->before_IDAT;
}
# ifndef PNG_READ_USER_CHUNKS_SUPPORTED
/* The #defines above should mean this is never reached, it's just here as
* a check to ensure the logic is correct.
*/
# error No store support and no user chunk support, this will not work
# endif /* READ_USER_CHUNKS */
#endif /* SAVE_UNKNOWN_CHUNKS */
static int
check(FILE *fp, int argc, const char **argv, png_uint_32p flags/*out*/,
display *d)
display *d, int set_callback)
{
int i, def = PNG_HANDLE_CHUNK_AS_DEFAULT, npasses, ipass;
int i, npasses, ipass;
png_uint_32 height;
d->keep = PNG_HANDLE_CHUNK_AS_DEFAULT;
d->before_IDAT = 0;
d->after_IDAT = 0;
/* Some of these errors are permanently fatal and cause an exit here, others
* are per-test and cause an error return.
*/
@ -421,6 +684,16 @@ check(FILE *fp, int argc, const char **argv, png_uint_32p flags/*out*/,
png_init_io(d->png_ptr, fp);
# ifdef PNG_READ_USER_CHUNKS_SUPPORTED
/* This is only done if requested by the caller; it interferes with the
* standard store/save mechanism.
*/
if (set_callback)
png_set_read_user_chunk_fn(d->png_ptr, d, read_callback);
# else
UNUSED(set_callback)
# endif
/* Handle each argument in turn; multiple settings are possible for the same
* chunk and multiple calls will occur (the last one should override all
* preceding ones).
@ -460,13 +733,17 @@ check(FILE *fp, int argc, const char **argv, png_uint_32p flags/*out*/,
* in this case, so we just check the arguments! This could
* be improved in the future by using the read callback.
*/
# ifdef PNG_SAVE_UNKNOWN_CHUNKS_SUPPORTED
# if PNG_LIBPNG_VER >= 10700 &&\
!defined(PNG_SAVE_UNKNOWN_CHUNKS_SUPPORTED)
if (option < PNG_HANDLE_CHUNK_IF_SAFE)
# endif /* 1.7+ SAVE_UNKNOWN_CHUNKS */
{
png_byte name[5];
memcpy(name, chunk_info[chunk].name, 5);
png_set_keep_unknown_chunks(d->png_ptr, option, name, 1);
chunk_info[chunk].keep = option;
# endif
}
continue;
}
@ -475,10 +752,13 @@ check(FILE *fp, int argc, const char **argv, png_uint_32p flags/*out*/,
case 7: /* default */
if (memcmp(argv[i], "default", 7) == 0)
{
# ifdef PNG_SAVE_UNKNOWN_CHUNKS_SUPPORTED
# if PNG_LIBPNG_VER >= 10700 &&\
!defined(PNG_SAVE_UNKNOWN_CHUNKS_SUPPORTED)
if (option < PNG_HANDLE_CHUNK_IF_SAFE)
# endif /* 1.7+ SAVE_UNKNOWN_CHUNKS */
png_set_keep_unknown_chunks(d->png_ptr, option, NULL, 0);
# endif
def = option;
d->keep = option;
continue;
}
@ -487,14 +767,17 @@ check(FILE *fp, int argc, const char **argv, png_uint_32p flags/*out*/,
case 3: /* all */
if (memcmp(argv[i], "all", 3) == 0)
{
# ifdef PNG_SAVE_UNKNOWN_CHUNKS_SUPPORTED
# if PNG_LIBPNG_VER >= 10700 &&\
!defined(PNG_SAVE_UNKNOWN_CHUNKS_SUPPORTED)
if (option < PNG_HANDLE_CHUNK_IF_SAFE)
# endif /* 1.7+ SAVE_UNKNOWN_CHUNKS */
png_set_keep_unknown_chunks(d->png_ptr, option, NULL, -1);
def = option;
for (chunk = 0; chunk < NINFO; ++chunk)
if (chunk_info[chunk].all)
chunk_info[chunk].keep = option;
# endif
d->keep = option;
for (chunk = 0; chunk < NINFO; ++chunk)
if (chunk_info[chunk].all)
chunk_info[chunk].keep = option;
continue;
}
@ -568,18 +851,18 @@ check(FILE *fp, int argc, const char **argv, png_uint_32p flags/*out*/,
png_read_end(d->png_ptr, d->end_ptr);
flags[0] = get_valid(d, d->info_ptr);
flags[1] = get_unknown(d, def, d->info_ptr);
flags[1] = get_unknown(d, d->info_ptr, 0/*before IDAT*/);
/* Only png_read_png sets PNG_INFO_IDAT! */
flags[chunk_info[0/*IDAT*/].keep != PNG_HANDLE_CHUNK_AS_DEFAULT] |=
PNG_INFO_IDAT;
flags[2] = get_valid(d, d->end_ptr);
flags[3] = get_unknown(d, def, d->end_ptr);
flags[3] = get_unknown(d, d->end_ptr, 1/*after IDAT*/);
clean_display(d);
return def;
return d->keep;
}
static void
@ -600,7 +883,7 @@ check_error(display *d, png_uint_32 flags, const char *message)
static void
check_handling(display *d, int def, png_uint_32 chunks, png_uint_32 known,
png_uint_32 unknown, const char *position)
png_uint_32 unknown, const char *position, int set_callback)
{
while (chunks)
{
@ -707,8 +990,9 @@ check_handling(display *d, int def, png_uint_32 chunks, png_uint_32 known,
if (errorx != NULL)
{
++(d->error_count);
fprintf(stderr, "%s(%s): %s %s %s: %s\n",
d->file, d->test, type, chunk_info[i].name, position, errorx);
fprintf(stderr, "%s(%s%s): %s %s %s: %s\n", d->file, d->test,
set_callback ? ",callback" : "",
type, chunk_info[i].name, position, errorx);
}
chunks &= ~flag;
@ -717,7 +1001,7 @@ check_handling(display *d, int def, png_uint_32 chunks, png_uint_32 known,
static void
perform_one_test(FILE *fp, int argc, const char **argv,
png_uint_32 *default_flags, display *d)
png_uint_32 *default_flags, display *d, int set_callback)
{
int def;
png_uint_32 flags[2][4];
@ -726,7 +1010,21 @@ perform_one_test(FILE *fp, int argc, const char **argv,
clear_keep();
memcpy(flags[0], default_flags, sizeof flags[0]);
def = check(fp, argc, argv, flags[1], d);
def = check(fp, argc, argv, flags[1], d, set_callback);
/* If IDAT is being handled as unknown the image read is skipped and all the
* IDATs after the first end up in the end info struct, so in this case add
* IDAT to the list of unknowns. (Do this after 'check' above sets the
* chunk_info 'keep' fields.)
*
* Note that the flag setting has to be in the 'known' field to avoid
* triggering the consistency check below and the flag must only be set if
* there are multiple IDATs, so if the check above did find an unknown IDAT
* after IDAT.
*/
if (chunk_info[0/*IDAT*/].keep != PNG_HANDLE_CHUNK_AS_DEFAULT &&
(flags[1][3] & PNG_INFO_IDAT) != 0)
flags[0][2] |= PNG_INFO_IDAT;
/* Chunks should either be known or unknown, never both and this should apply
* whether the chunk is before or after the IDAT (actually, the app can
@ -761,9 +1059,9 @@ perform_one_test(FILE *fp, int argc, const char **argv,
* it or not.
*/
check_handling(d, def, flags[0][0] | flags[0][1], flags[1][0], flags[1][1],
"before IDAT");
"before IDAT", set_callback);
check_handling(d, def, flags[0][2] | flags[0][3], flags[1][2], flags[1][3],
"after IDAT");
"after IDAT", set_callback);
}
static void
@ -773,7 +1071,12 @@ perform_one_test_safe(FILE *fp, int argc, const char **argv,
if (setjmp(d->error_return) == 0)
{
d->test = test; /* allow use of d->error_return */
perform_one_test(fp, argc, argv, default_flags, d);
# ifdef PNG_SAVE_UNKNOWN_CHUNKS_SUPPORTED
perform_one_test(fp, argc, argv, default_flags, d, 0);
# endif
# ifdef PNG_READ_USER_CHUNKS_SUPPORTED
perform_one_test(fp, argc, argv, default_flags, d, 1);
# endif
d->test = init; /* prevent use of d->error_return */
}
}
@ -797,7 +1100,7 @@ usage(const char *program, const char *reason)
fprintf(stderr, "pngunknown: %s: usage:\n %s [--strict] "
"--default|{(CHNK|default|all)=(default|discard|if-safe|save)} "
"testfile.png\n", reason, program);
exit(2);
exit(99);
}
int
@ -845,11 +1148,6 @@ main(int argc, const char **argv)
else if (default_tests) if (argc != 1)
usage(d.program, "extra arguments");
# ifndef PNG_SAVE_UNKNOWN_CHUNKS_SUPPORTED
fprintf(stderr, "%s: warning: no 'save' support so arguments ignored\n",
d.program);
# endif
/* The name of the test file is the last argument; remove it. */
d.file = argv[--argc];
@ -857,24 +1155,40 @@ main(int argc, const char **argv)
if (fp == NULL)
{
perror(d.file);
exit(2);
exit(99);
}
/* First find all the chunks, known and unknown, in the test file, a failure
* here aborts the whole test.
*
* If 'save' is supported then the normal saving method should happen,
* otherwise if 'read' is supported then the read callback will do the
* same thing. If both are supported the 'read' callback won't be
* instantiated by default. If 'save' is *not* supported then a user
* callback is required even though we can call png_get_unknown_chunks.
*/
if (check(fp, 1, &count_argv, default_flags, &d) !=
PNG_HANDLE_CHUNK_ALWAYS)
if (check(fp, 1, &count_argv, default_flags, &d,
# ifdef PNG_SAVE_UNKNOWN_CHUNKS_SUPPORTED
0
# else
1
# endif
) != PNG_HANDLE_CHUNK_ALWAYS)
{
fprintf(stderr, "%s: %s: internal error\n", d.program, d.file);
exit(3);
exit(99);
}
/* Now find what the various supplied options cause to change: */
if (!default_tests)
{
d.test = cmd; /* acts as a flag to say exit, do not longjmp */
perform_one_test(fp, argc, argv, default_flags, &d);
# ifdef PNG_SAVE_UNKNOWN_CHUNKS_SUPPORTED
perform_one_test(fp, argc, argv, default_flags, &d, 0);
# endif
# ifdef PNG_READ_USER_CHUNKS_SUPPORTED
perform_one_test(fp, argc, argv, default_flags, &d, 1);
# endif
d.test = init;
}
@ -932,14 +1246,14 @@ main(int argc, const char **argv)
if (fclose(fsuccess) || err)
{
fprintf(stderr, "%s: write failed\n", touch_file);
exit(1);
exit(99);
}
}
else
{
fprintf(stderr, "%s: open failed\n", touch_file);
exit(1);
exit(99);
}
}
@ -949,12 +1263,24 @@ main(int argc, const char **argv)
return 1;
}
#else
#else /* !(READ_USER_CHUNKS || SAVE_UNKNOWN_CHUNKS) */
int
main(void)
{
fprintf(stderr,
" test ignored because libpng was not built with unknown chunk support\n");
return 0;
" test ignored: no support to find out about unknown chunks\n");
/* So the test is skipped: */
return SKIP;
}
#endif
#endif /* READ_USER_CHUNKS || SAVE_UNKNOWN_CHUNKS */
#else /* !(SET_UNKNOWN_CHUNKS && READ) */
int
main(void)
{
fprintf(stderr,
" test ignored: no support to modify unknown chunk handling\n");
/* So the test is skipped: */
return SKIP;
}
#endif /* SET_UNKNOWN_CHUNKS && READ*/

File diff suppressed because it is too large Load Diff

115
contrib/libtests/readpng.c Normal file
View File

@ -0,0 +1,115 @@
/* readpng.c
*
* Copyright (c) 2013 John Cunningham Bowler
*
* Last changed in libpng 1.6.1 [March 28, 2013]
*
* This code is released under the libpng license.
* For conditions of distribution and use, see the disclaimer
* and license in png.h
*
* Load an arbitrary number of PNG files (from the command line, or, if there
* are no arguments on the command line, from stdin) then run a time test by
* reading each file by row. The test does nothing with the read result and
* does no transforms. The only output is a time as a floating point number of
* seconds with 9 decimal digits.
*/
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#if defined(HAVE_CONFIG_H) && !defined(PNG_NO_CONFIG_H)
# include <config.h>
#endif
/* Define the following to use this test against your installed libpng, rather
* than the one being built here:
*/
#ifdef PNG_FREESTANDING_TESTS
# include <png.h>
#else
# include "../../png.h"
#endif
static int
read_png(FILE *fp)
{
png_structp png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING,0,0,0);
png_infop info_ptr = NULL;
png_bytep row = NULL, display = NULL;
if (png_ptr == NULL)
return 0;
if (setjmp(png_jmpbuf(png_ptr)))
{
png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
if (row != NULL) free(row);
if (display != NULL) free(display);
return 0;
}
png_init_io(png_ptr, fp);
info_ptr = png_create_info_struct(png_ptr);
if (info_ptr == NULL)
png_error(png_ptr, "OOM allocating info structure");
png_set_keep_unknown_chunks(png_ptr, PNG_HANDLE_CHUNK_ALWAYS, NULL, 0);
png_read_info(png_ptr, info_ptr);
{
png_size_t rowbytes = png_get_rowbytes(png_ptr, info_ptr);
/* Failure to initialize these is harmless */
row = malloc(rowbytes);
display = malloc(rowbytes);
if (row == NULL || display == NULL)
png_error(png_ptr, "OOM allocating row buffers");
{
png_uint_32 height = png_get_image_height(png_ptr, info_ptr);
# ifdef PNG_READ_INTERLACING_SUPPORTED
int passes = png_set_interlace_handling(png_ptr);
# else /* !READ_INTERLACING */
int passes = png_get_interlace_type(png_ptr, info_ptr) ==
PNG_INTERLACE_ADAM7 ? PNG_INTERLACE_ADAM7_PASSES : 1;
# endif /* !READ_INTERLACING */
int pass;
png_start_read_image(png_ptr);
for (pass = 0; pass < passes; ++pass)
{
png_uint_32 y = height;
# ifndef PNG_READ_INTERLACING_SUPPORTED
if (passes == PNG_INTERLACE_ADAM7_PASSES)
y = PNG_PASS_ROWS(y, pass);
# endif /* READ_INTERLACING */
/* NOTE: this trashes the row each time; interlace handling won't
* work, but this avoids memory thrashing for speed testing.
*/
while (y-- > 0)
png_read_row(png_ptr, row, display);
}
}
}
/* Make sure to read to the end of the file: */
png_read_end(png_ptr, info_ptr);
png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
free(row);
free(display);
return 1;
}
int
main(void)
{
/* Exit code 0 on success. */
return !read_png(stdin);
}

View File

@ -1,9 +1,9 @@
/* tarith.c
*
* Copyright (c) 2011,2012 John Cunningham Bowler
* Copyright (c) 2011-2013 John Cunningham Bowler
*
* Last changed in libpng 1.6.0 [(PENDING RELEASE)]
* Last changed in libpng 1.6.0 [February 14, 2013]
*
* This code is released under the libpng license.
* For conditions of distribution and use, see the disclaimer
@ -634,7 +634,7 @@ int validation_muldiv(int count, int argc, char **argv)
{
png_fixed_point result;
/* NOTE: your mileage may vary, a type is required below that can
* hold 64 bits or more, if floating point is used a 64 bit or
* hold 64 bits or more, if floating point is used a 64-bit or
* better mantissa is required.
*/
long long int fp, fpround;
@ -721,7 +721,7 @@ int validation_muldiv(int count, int argc, char **argv)
}
while (--count > 0);
printf("%d tests including %d overflows, %d passed, %d failed (%d 64 bit "
printf("%d tests including %d overflows, %d passed, %d failed (%d 64-bit "
"errors)\n", tested, overflow, passed, error, error64);
return 0;
}
@ -799,13 +799,13 @@ int validation_gamma(int argc, char **argv)
if (i == 0 && png_log8bit(i) != 0xffffffff ||
i != 0 && png_log8bit(i) != floor(correct+.5))
{
fprintf(stderr, "8 bit log error: %d: got %u, expected %f\n",
fprintf(stderr, "8-bit log error: %d: got %u, expected %f\n",
i, png_log8bit(i), correct);
}
}
if (!silent)
printf("maximum 8 bit log error = %f\n", maxerr);
printf("maximum 8-bit log error = %f\n", maxerr);
maxerr = 0;
for (i=0; i<65536; ++i)
@ -821,14 +821,14 @@ int validation_gamma(int argc, char **argv)
{
if (error > .68) /* By experiment error is less than .68 */
{
fprintf(stderr, "16 bit log error: %d: got %u, expected %f"
fprintf(stderr, "16-bit log error: %d: got %u, expected %f"
" error: %f\n", i, png_log16bit(i), correct, error);
}
}
}
if (!silent)
printf("maximum 16 bit log error = %f\n", maxerr);
printf("maximum 16-bit log error = %f\n", maxerr);
/* Now exponentiations. */
maxerr = 0;
@ -841,13 +841,13 @@ int validation_gamma(int argc, char **argv)
maxerr = fabs(error);
if (fabs(error) > 1883) /* By experiment. */
{
fprintf(stderr, "32 bit exp error: %d: got %u, expected %f"
fprintf(stderr, "32-bit exp error: %d: got %u, expected %f"
" error: %f\n", i, png_exp(i), correct, error);
}
}
if (!silent)
printf("maximum 32 bit exp error = %f\n", maxerr);
printf("maximum 32-bit exp error = %f\n", maxerr);
maxerr = 0;
for (i=0; i<=0xfffff; ++i)
@ -859,13 +859,13 @@ int validation_gamma(int argc, char **argv)
maxerr = fabs(error);
if (fabs(error) > .50002) /* By experiment */
{
fprintf(stderr, "8 bit exp error: %d: got %u, expected %f"
fprintf(stderr, "8-bit exp error: %d: got %u, expected %f"
" error: %f\n", i, png_exp8bit(i), correct, error);
}
}
if (!silent)
printf("maximum 8 bit exp error = %f\n", maxerr);
printf("maximum 8-bit exp error = %f\n", maxerr);
maxerr = 0;
for (i=0; i<=0xfffff; ++i)
@ -877,13 +877,13 @@ int validation_gamma(int argc, char **argv)
maxerr = fabs(error);
if (fabs(error) > .524) /* By experiment */
{
fprintf(stderr, "16 bit exp error: %d: got %u, expected %f"
fprintf(stderr, "16-bit exp error: %d: got %u, expected %f"
" error: %f\n", i, png_exp16bit(i), correct, error);
}
}
if (!silent)
printf("maximum 16 bit exp error = %f\n", maxerr);
printf("maximum 16-bit exp error = %f\n", maxerr);
} /* !onlygamma */
/* Test the overall gamma correction. */
@ -913,7 +913,7 @@ int validation_gamma(int argc, char **argv)
}
if (!silent)
printf("gamma %f: maximum 8 bit error %f\n", g, maxerr);
printf("gamma %f: maximum 8-bit error %f\n", g, maxerr);
maxerr = 0;
for (j=0; j<65536; ++j)
@ -932,7 +932,7 @@ int validation_gamma(int argc, char **argv)
}
if (!silent)
printf("gamma %f: maximum 16 bit error %f\n", g, maxerr);
printf("gamma %f: maximum 16-bit error %f\n", g, maxerr);
}
return 0;

View File

@ -1,24 +0,0 @@
#!/bin/sh
#
# Run the simplified API tests
err=0
echo >> pngtest-log.txt
echo "============ pngstest.sh ==============" >> pngtest-log.txt
echo "Running test-pngstest.sh"
for image in ${srcdir}/contrib/pngsuite/*.png
do
for opts in ""
do
if ./pngstest --strict --log "$@" $opts $image >>pngtest-log.txt 2>&1
then
echo " PASS: pngstest $opts $image"
else
echo " FAIL: pngstest $opts $image"
err=1
fi
done
done
exit $err

View File

@ -1,38 +0,0 @@
#!/bin/sh
#
# Run the unknown API tests
err=0
image="${srcdir}/pngtest.png"
#
# stream 4 is used for the output of the shell, pngtest-log.txt gets all the
# normal program output.
exec 4>&1 1>>pngtest-log.txt 2>&1
echo
echo "============ test-pngunknown.sh =============="
echo "Running test-pngunknown.sh" >&4
for tests in \
"discard default=discard"\
"save default=save"\
"if-safe default=if-safe"\
"vpAg vpAg=if-safe"\
"sTER sTER=if-safe"\
"IDAT default=discard IDAT=save"\
"sAPI bKGD=save cHRM=save gAMA=save all=discard iCCP=save sBIT=save sRGB=save"
do
set $tests
test="$1"
shift
if ./pngunknown "$@" "$image" 4>&-
then
echo " PASS: test-pngunknown $test" >&4
else
echo " FAIL: test-pngunknown $test" >&4
err=1
fi
done
exit $err

View File

@ -1,21 +0,0 @@
#!/bin/sh
#
# Run a sequence of gamma tests quietly
err=0
echo >> pngtest-log.txt
echo "============ pngvalid-full.sh ==============" >> pngtest-log.txt
echo "Running test-pngvalid-full.sh"
for gamma in threshold transform sbit 16-to-8 background alpha-mode "transform --expand16" "background --expand16" "alpha-mode --expand16"
do
if ./pngvalid "$@" --gamma-$gamma >> pngtest-log.txt 2>&1
then
echo " PASS: pngvalid" "$@" "--gamma-$gamma"
else
echo " FAIL: pngvalid" "$@" "--gamma-$gamma"
err=1
fi
done
exit $err

View File

@ -1,30 +0,0 @@
#!/bin/sh
#
# Run a sequence of tests quietly, without the slow
# gamma tests
err=0
echo >> pngtest-log.txt
echo "============ pngvalid-simple.sh ==============" >> pngtest-log.txt
echo "Running test-pngvalid-simple.sh"
# The options to test are:
#
# standard tests with and without progressive reading and interlace
# size images with and without progressive reading
# transform tests (standard, non-interlaced only)
#
for opts in "--standard" "--standard --progressive-read" \
"--standard --interlace" "--standard --progressive-read --interlace" \
"--size" "--size --progressive-read" \
"--transform"
do
if ./pngvalid "$@" $opts >> pngtest-log.txt 2>&1
then
echo " PASS: pngvalid" "$@" $opts
else
echo " FAIL: pngvalid" "$@" $opts
err=1
fi
done
exit $err

View File

@ -1,8 +1,8 @@
/* timepng.c
*
* Copyright (c) 2012 John Cunningham Bowler
* Copyright (c) 2013,2016 John Cunningham Bowler
*
* Last changed in libpng 1.6.0 [(PENDING RELEASE)]
* Last changed in libpng 1.6.22 [May 26, 2016]
*
* This code is released under the libpng license.
* For conditions of distribution and use, see the disclaimer
@ -10,19 +10,21 @@
*
* Load an arbitrary number of PNG files (from the command line, or, if there
* are no arguments on the command line, from stdin) then run a time test by
* reading each file by row. The test does nothing with the read result and
* does no transforms. The only output is a time as a floating point number of
* seconds with 9 decimal digits.
* reading each file by row or by image (possibly with transforms in the latter
* case). The only output is a time as a floating point number of seconds with
* 9 decimal digits.
*/
#define _POSIX_C_SOURCE 199309L /* for clock_gettime */
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <limits.h>
#include <time.h>
#if (defined HAVE_CONFIG_H) && !(defined PNG_NO_CONFIG_H)
#if defined(HAVE_CONFIG_H) && !defined(PNG_NO_CONFIG_H)
# include <config.h>
#endif
@ -35,36 +37,73 @@
# include "../../png.h"
#endif
static int read_png(FILE *fp)
/* The following is to support direct compilation of this file as C++ */
#ifdef __cplusplus
# define voidcast(type, value) static_cast<type>(value)
#else
# define voidcast(type, value) (value)
#endif /* __cplusplus */
/* 'CLOCK_PROCESS_CPUTIME_ID' is one of the clock timers for clock_gettime. It
* need not be supported even when clock_gettime is available. It returns the
* 'CPU' time the process has consumed. 'CPU' time is assumed to include time
* when the CPU is actually blocked by a pending cache fill but not time
* waiting for page faults. The attempt is to get a measure of the actual time
* the implementation takes to read a PNG ignoring the potentially very large IO
* overhead.
*/
#if defined (CLOCK_PROCESS_CPUTIME_ID) && defined(PNG_STDIO_SUPPORTED) &&\
defined(PNG_EASY_ACCESS_SUPPORTED) &&\
(PNG_LIBPNG_VER >= 10700 ? defined(PNG_READ_PNG_SUPPORTED) :\
defined (PNG_SEQUENTIAL_READ_SUPPORTED) &&\
defined(PNG_INFO_IMAGE_SUPPORTED))
typedef struct
{
png_structp png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING,0,0,0);
png_infop info_ptr = NULL;
png_bytep row = NULL, display = NULL;
FILE *input;
FILE *output;
} io_data;
if (png_ptr == NULL)
return 0;
static PNG_CALLBACK(void, read_and_copy,
(png_structp png_ptr, png_bytep buffer, png_size_t cb))
{
io_data *io = (io_data*)png_get_io_ptr(png_ptr);
if (setjmp(png_jmpbuf(png_ptr)))
if (fread(buffer, cb, 1, io->input) != 1)
png_error(png_ptr, strerror(errno));
if (fwrite(buffer, cb, 1, io->output) != 1)
{
png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
if (row != NULL) free(row);
if (display != NULL) free(display);
return 0;
perror("temporary file");
fprintf(stderr, "temporary file PNG write failed\n");
exit(1);
}
}
png_init_io(png_ptr, fp);
static void read_by_row(png_structp png_ptr, png_infop info_ptr,
FILE *write_ptr, FILE *read_ptr)
{
/* These don't get freed on error, this is fine; the program immediately
* exits.
*/
png_bytep row = NULL, display = NULL;
io_data io_copy;
info_ptr = png_create_info_struct(png_ptr);
if (info_ptr == NULL)
png_error(png_ptr, "OOM allocating info structure");
if (write_ptr != NULL)
{
/* Set up for a copy to the temporary file: */
io_copy.input = read_ptr;
io_copy.output = write_ptr;
png_set_read_fn(png_ptr, &io_copy, read_and_copy);
}
png_read_info(png_ptr, info_ptr);
{
png_size_t rowbytes = png_get_rowbytes(png_ptr, info_ptr);
row = malloc(rowbytes);
display = malloc(rowbytes);
row = voidcast(png_bytep,malloc(rowbytes));
display = voidcast(png_bytep,malloc(rowbytes));
if (row == NULL || display == NULL)
png_error(png_ptr, "OOM allocating row buffers");
@ -81,7 +120,8 @@ static int read_png(FILE *fp)
png_uint_32 y = height;
/* NOTE: this trashes the row each time; interlace handling won't
* work, but this avoids memory thrashing for speed testing.
* work, but this avoids memory thrashing for speed testing and is
* somewhat representative of an application that works row-by-row.
*/
while (y-- > 0)
png_read_row(png_ptr, row, display);
@ -91,9 +131,51 @@ static int read_png(FILE *fp)
/* Make sure to read to the end of the file: */
png_read_end(png_ptr, info_ptr);
png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
/* Free this up: */
free(row);
free(display);
}
static PNG_CALLBACK(void, no_warnings, (png_structp png_ptr,
png_const_charp warning))
{
(void)png_ptr;
(void)warning;
}
static int read_png(FILE *fp, png_int_32 transforms, FILE *write_file)
{
png_structp png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING,0,0,
no_warnings);
png_infop info_ptr = NULL;
if (png_ptr == NULL)
return 0;
if (setjmp(png_jmpbuf(png_ptr)))
{
png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
return 0;
}
# ifdef PNG_BENIGN_ERRORS_SUPPORTED
png_set_benign_errors(png_ptr, 1/*allowed*/);
# endif
png_init_io(png_ptr, fp);
info_ptr = png_create_info_struct(png_ptr);
if (info_ptr == NULL)
png_error(png_ptr, "OOM allocating info structure");
if (transforms < 0)
read_by_row(png_ptr, info_ptr, write_file, fp);
else
png_read_png(png_ptr, info_ptr, transforms, NULL/*params*/);
png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
return 1;
}
@ -108,7 +190,7 @@ static int mytime(struct timespec *t)
return 0;
}
static int perform_one_test(FILE *fp, int nfiles)
static int perform_one_test(FILE *fp, int nfiles, png_int_32 transforms)
{
int i;
struct timespec before, after;
@ -120,7 +202,7 @@ static int perform_one_test(FILE *fp, int nfiles)
{
for (i=0; i<nfiles; ++i)
{
if (read_png(fp))
if (read_png(fp, transforms, NULL/*write*/))
{
if (ferror(fp))
{
@ -184,120 +266,343 @@ static int add_one_file(FILE *fp, char *name)
if (ip != NULL)
{
int ch;
for (;;)
/* Read the file using libpng; this detects errors and also deals with
* files which contain data beyond the end of the file.
*/
int ok = 0;
fpos_t pos;
if (fgetpos(fp, &pos))
{
ch = getc(ip);
if (ch == EOF) break;
putc(ch, fp);
/* Fatal error reading the start: */
perror("temporary file");
fprintf(stderr, "temporary file fgetpos error\n");
exit(1);
}
if (ferror(ip))
if (read_png(ip, -1/*by row*/, fp/*output*/))
{
perror(name);
fprintf(stderr, "%s: read error\n", name);
return 0;
if (ferror(ip))
{
perror(name);
fprintf(stderr, "%s: read error\n", name);
}
else
ok = 1; /* read ok */
}
else
fprintf(stderr, "%s: file not added\n", name);
(void)fclose(ip);
/* An error in the output is fatal; exit immediately: */
if (ferror(fp))
{
perror("temporary file");
fprintf(stderr, "temporary file write error\n");
return 0;
exit(1);
}
if (ok)
return 1;
/* Did not read the file successfully, simply rewind the temporary
* file. This must happen after the ferror check above to avoid clearing
* the error.
*/
if (fsetpos(fp, &pos))
{
perror("temporary file");
fprintf(stderr, "temporary file fsetpos error\n");
exit(1);
}
}
else
{
/* file open error: */
perror(name);
fprintf(stderr, "%s: open failed\n", name);
return 0;
}
return 1;
return 0; /* file not added */
}
static void
usage(FILE *fp)
{
if (fp != NULL) fclose(fp);
fprintf(stderr,
"Usage:\n"
" timepng --assemble <assembly> {files}\n"
" Read the files into <assembly>, output the count. Options are ignored.\n"
" timepng --dissemble <assembly> <count> [options]\n"
" Time <count> files from <assembly>, additional files may not be given.\n"
" Otherwise:\n"
" Read the files into a temporary file and time the decode\n"
"Transforms:\n"
" --by-image: read by image with png_read_png\n"
" --<transform>: implies by-image, use PNG_TRANSFORM_<transform>\n"
" Otherwise: read by row using png_read_row (to a single row buffer)\n"
/* ISO C90 string length max 509 */);fprintf(stderr,
"{files}:\n"
" PNG files to copy into the assembly and time. Invalid files are skipped\n"
" with appropriate error messages. If no files are given the list of files\n"
" is read from stdin with each file name terminated by a newline\n"
"Output:\n"
" For --assemble the output is the name of the assembly file followed by the\n"
" count of the files it contains; the arguments for --dissemble. Otherwise\n"
" the output is the total decode time in seconds.\n");
exit(99);
}
int main(int argc, char **argv)
{
int ok = 0;
FILE *fp = tmpfile();
int err = 0;
int nfiles = 0;
int transforms = -1; /* by row */
const char *assembly = NULL;
FILE *fp;
if (fp != NULL)
if (argc > 2 && strcmp(argv[1], "--assemble") == 0)
{
int err = 0;
int nfiles = 0;
if (argc > 1)
/* Just build the test file, argv[2] is the file name. */
assembly = argv[2];
fp = fopen(assembly, "wb");
if (fp == NULL)
{
int i;
perror(assembly);
fprintf(stderr, "timepng --assemble %s: could not open for write\n",
assembly);
usage(NULL);
}
for (i=1; i<argc; ++i)
argv += 2;
argc -= 2;
}
else if (argc > 3 && strcmp(argv[1], "--dissemble") == 0)
{
fp = fopen(argv[2], "rb");
if (fp == NULL)
{
perror(argv[2]);
fprintf(stderr, "timepng --dissemble %s: could not open for read\n",
argv[2]);
usage(NULL);
}
nfiles = atoi(argv[3]);
if (nfiles <= 0)
{
fprintf(stderr,
"timepng --dissemble <file> <count>: %s is not a count\n",
argv[3]);
exit(99);
}
#ifdef __COVERITY__
else
{
nfiles &= PNG_UINT_31_MAX;
}
#endif
argv += 3;
argc -= 3;
}
else /* Else use a temporary file */
{
#ifndef __COVERITY__
fp = tmpfile();
#else
/* Experimental. Coverity says tmpfile() is insecure because it
* generates predictable names.
*
* It is possible to satisfy Coverity by using mkstemp(); however,
* any platform supporting mkstemp() undoubtedly has a secure tmpfile()
* implementation as well, and doesn't need the fix. Note that
* the fix won't work on platforms that don't support mkstemp().
*
* https://www.securecoding.cert.org/confluence/display/c/
* FIO21-C.+Do+not+create+temporary+files+in+shared+directories
* says that most historic implementations of tmpfile() provide
* only a limited number of possible temporary file names
* (usually 26) before file names are recycled. That article also
* provides a secure solution that unfortunately depends upon mkstemp().
*/
char tmpfile[] = "timepng-XXXXXX";
int filedes;
umask(0177);
filedes = mkstemp(tmpfile);
if (filedes < 0)
fp = NULL;
else
{
fp = fdopen(filedes,"w+");
/* Hide the filename immediately and ensure that the file does
* not exist after the program ends
*/
(void) unlink(tmpfile);
}
#endif
if (fp == NULL)
{
perror("tmpfile");
fprintf(stderr, "timepng: could not open the temporary file\n");
exit(1); /* not a user error */
}
}
/* Handle the transforms: */
while (argc > 1 && argv[1][0] == '-' && argv[1][1] == '-')
{
const char *opt = *++argv + 2;
--argc;
/* Transforms turn on the by-image processing and maybe set some
* transforms:
*/
if (transforms == -1)
transforms = PNG_TRANSFORM_IDENTITY;
if (strcmp(opt, "by-image") == 0)
{
/* handled above */
}
# define OPT(name) else if (strcmp(opt, #name) == 0)\
transforms |= PNG_TRANSFORM_ ## name
OPT(STRIP_16);
OPT(STRIP_ALPHA);
OPT(PACKING);
OPT(PACKSWAP);
OPT(EXPAND);
OPT(INVERT_MONO);
OPT(SHIFT);
OPT(BGR);
OPT(SWAP_ALPHA);
OPT(SWAP_ENDIAN);
OPT(INVERT_ALPHA);
OPT(STRIP_FILLER);
OPT(STRIP_FILLER_BEFORE);
OPT(STRIP_FILLER_AFTER);
OPT(GRAY_TO_RGB);
OPT(EXPAND_16);
OPT(SCALE_16);
else
{
fprintf(stderr, "timepng %s: unrecognized transform\n", opt);
usage(fp);
}
}
/* Handle the files: */
if (argc > 1 && nfiles > 0)
usage(fp); /* Additional files not valid with --dissemble */
else if (argc > 1)
{
int i;
for (i=1; i<argc; ++i)
{
if (nfiles == INT_MAX)
{
if (add_one_file(fp, argv[i]))
fprintf(stderr, "%s: skipped, too many files\n", argv[i]);
break;
}
else if (add_one_file(fp, argv[i]))
++nfiles;
}
}
else if (nfiles == 0) /* Read from stdin withoout --dissemble */
{
char filename[FILENAME_MAX+1];
while (fgets(filename, FILENAME_MAX+1, stdin))
{
size_t len = strlen(filename);
if (filename[len-1] == '\n')
{
filename[len-1] = 0;
if (nfiles == INT_MAX)
{
fprintf(stderr, "%s: skipped, too many files\n", filename);
break;
}
else if (add_one_file(fp, filename))
++nfiles;
}
else
{
fprintf(stderr, "timepng: file name too long: ...%s\n",
filename+len-32);
err = 1;
break;
}
}
if (ferror(stdin))
{
fprintf(stderr, "timepng: stdin: read error\n");
err = 1;
}
}
/* Perform the test, or produce the --assemble output: */
if (!err)
{
if (nfiles > 0)
{
if (assembly != NULL)
{
if (fflush(fp) && !ferror(fp) && fclose(fp))
{
perror(assembly);
fprintf(stderr, "%s: close failed\n", assembly);
}
else
{
err = 1;
break;
printf("%s %d\n", assembly, nfiles);
fflush(stdout);
ok = !ferror(stdout);
}
}
else
{
ok = perform_one_test(fp, nfiles, transforms);
(void)fclose(fp);
}
}
else
{
char filename[FILENAME_MAX+1];
while (fgets(filename, FILENAME_MAX+1, stdin))
{
int len = strlen(filename);
if (filename[len-1] == '\n')
{
filename[len-1] = 0;
if (add_one_file(fp, filename))
++nfiles;
else
{
err = 1;
break;
}
}
else
{
fprintf(stderr, "timepng: truncated file name ...%s\n",
filename+len-32);
err = 1;
break;
}
}
if (ferror(stdin))
{
fprintf(stderr, "timepng: stdin: read error\n");
err = 1;
}
}
if (!err)
{
if (nfiles > 0)
ok = perform_one_test(fp, nfiles);
else
fprintf(stderr, "usage: timepng {files} or ls files | timepng\n");
}
(void)fclose(fp);
usage(fp);
}
else
fprintf(stderr, "timepng: could not open temporary file\n");
(void)fclose(fp);
/* Exit code 0 on success. */
return ok == 0;
}
#else /* !sufficient support */
int main(void) { return 77; }
#endif /* !sufficient support */

135
contrib/neon/arm_init.c Normal file
View File

@ -0,0 +1,135 @@
/* arm_init.c - NEON optimised filter functions
*
* Copyright (c) 2014 Glenn Randers-Pehrson
* Written by Mans Rullgard, 2011.
* Last changed in libpng 1.6.16 [December 22, 2014]
*
* This code is released under the libpng license.
* For conditions of distribution and use, see the disclaimer
* and license in png.h
*/
/* Below, after checking __linux__, various non-C90 POSIX 1003.1 functions are
* called.
*/
#define _POSIX_SOURCE 1
#include "../../pngpriv.h"
#define PNG_SRC_FILE PNG_SRC_FILE_arm_arm_init
#ifdef PNG_READ_SUPPORTED
#if PNG_ARM_NEON_OPT > 0
#ifdef PNG_ARM_NEON_CHECK_SUPPORTED /* Do run-time checks */
/* WARNING: it is strongly recommended that you do not build libpng with
* run-time checks for CPU features if at all possible. In the case of the ARM
* NEON instructions there is no processor-specific way of detecting the
* presence of the required support, therefore run-time detection is extremely
* OS specific.
*
* You may set the macro PNG_ARM_NEON_FILE to the file name of file containing
* a fragment of C source code which defines the png_have_neon function. There
* are a number of implementations in contrib/arm-neon, but the only one that
* has partial support is contrib/arm-neon/linux.c - a generic Linux
* implementation which reads /proc/cpufino.
*/
#ifndef PNG_ARM_NEON_FILE
# ifdef __linux__
# define PNG_ARM_NEON_FILE "contrib/arm-neon/linux.c"
# endif
#endif
#ifdef PNG_ARM_NEON_FILE
#include <signal.h> /* for sig_atomic_t */
static int png_have_neon(png_structp png_ptr);
#include PNG_ARM_NEON_FILE
#else /* PNG_ARM_NEON_FILE */
# error "PNG_ARM_NEON_FILE undefined: no support for run-time ARM NEON checks"
#endif /* PNG_ARM_NEON_FILE */
#endif /* PNG_ARM_NEON_CHECK_SUPPORTED */
#ifndef PNG_ALIGNED_MEMORY_SUPPORTED
# error "ALIGNED_MEMORY is required; set: -DPNG_ALIGNED_MEMORY_SUPPORTED"
#endif
void
png_init_filter_functions_neon(png_structp pp, unsigned int bpp)
{
/* The switch statement is compiled in for ARM_NEON_API, the call to
* png_have_neon is compiled in for ARM_NEON_CHECK. If both are defined
* the check is only performed if the API has not set the NEON option on
* or off explicitly. In this case the check controls what happens.
*
* If the CHECK is not compiled in and the option is UNSET the behavior prior
* to 1.6.7 was to use the NEON code - this was a bug caused by having the
* wrong order of the 'ON' and 'default' cases. UNSET now defaults to OFF,
* as documented in png.h
*/
#ifdef PNG_ARM_NEON_API_SUPPORTED
switch ((pp->options >> PNG_ARM_NEON) & 3)
{
case PNG_OPTION_UNSET:
/* Allow the run-time check to execute if it has been enabled -
* thus both API and CHECK can be turned on. If it isn't supported
* this case will fall through to the 'default' below, which just
* returns.
*/
#endif /* PNG_ARM_NEON_API_SUPPORTED */
#ifdef PNG_ARM_NEON_CHECK_SUPPORTED
{
static volatile sig_atomic_t no_neon = -1; /* not checked */
if (no_neon < 0)
no_neon = !png_have_neon(pp);
if (no_neon)
return;
}
#ifdef PNG_ARM_NEON_API_SUPPORTED
break;
#endif
#endif /* PNG_ARM_NEON_CHECK_SUPPORTED */
#ifdef PNG_ARM_NEON_API_SUPPORTED
default: /* OFF or INVALID */
return;
case PNG_OPTION_ON:
/* Option turned on */
break;
}
#endif
/* IMPORTANT: any new external functions used here must be declared using
* PNG_INTERNAL_FUNCTION in ../pngpriv.h. This is required so that the
* 'prefix' option to configure works:
*
* ./configure --with-libpng-prefix=foobar_
*
* Verify you have got this right by running the above command, doing a build
* and examining pngprefix.h; it must contain a #define for every external
* function you add. (Notice that this happens automatically for the
* initialization function.)
*/
pp->read_filter[PNG_FILTER_VALUE_UP-1] = png_read_filter_row_up_neon;
if (bpp == 3)
{
pp->read_filter[PNG_FILTER_VALUE_SUB-1] = png_read_filter_row_sub3_neon;
pp->read_filter[PNG_FILTER_VALUE_AVG-1] = png_read_filter_row_avg3_neon;
pp->read_filter[PNG_FILTER_VALUE_PAETH-1] =
png_read_filter_row_paeth3_neon;
}
else if (bpp == 4)
{
pp->read_filter[PNG_FILTER_VALUE_SUB-1] = png_read_filter_row_sub4_neon;
pp->read_filter[PNG_FILTER_VALUE_AVG-1] = png_read_filter_row_avg4_neon;
pp->read_filter[PNG_FILTER_VALUE_PAETH-1] =
png_read_filter_row_paeth4_neon;
}
}
#endif /* PNG_ARM_NEON_OPT > 0 */
#endif /* READ */

View File

@ -0,0 +1,10 @@
# To just this extension either copy the 'sinclude' line and the setting of
# libpng_automake_extensions into contrib/extensions.am or link/copy the whole
# file there. Do the same with the associated file extensions.am
#
# Include the ARM NEON extension:
sinclude([contrib/neon/neon.ac])
#
# If any of the extensions require automake support (this is likely) automake
# must include the file contrib/extensions.am
libpng_automake_extensions="yes"

View File

@ -0,0 +1,5 @@
# To just this extension either copy the 'include' line into
# contrib/extensions.am or link/copy the whole file there. Do the same with the
# associated file extensions.ac
# Include the ARM NEON extension:
include %reldir%/neon/neon.am

View File

@ -1,18 +1,36 @@
/* filter_neon.S - NEON optimised filter functions
*
* Copyright (c) 2011 Glenn Randers-Pehrson
* Copyright (c) 2014 Glenn Randers-Pehrson
* Written by Mans Rullgard, 2011.
* Last changed in libpng 1.6.16 [(PENDING RELEASE)]
*
* This code is released under the libpng license.
* For conditions of distribution and use, see the disclaimer
* and license in png.h
*/
/* This is required to get the symbol renames, which are #defines, and the
* definitions (or not) of PNG_ARM_NEON_OPT and PNG_ARM_NEON_IMPLEMENTATION.
*/
#define PNG_VERSION_INFO_ONLY
#include "../../pngpriv.h"
#if defined(__linux__) && defined(__ELF__)
.section .note.GNU-stack,"",%progbits /* mark stack as non-executable */
#endif
#ifdef PNG_READ_SUPPORTED
/* Assembler NEON support - only works for 32-bit ARM (i.e. it does not work for
* ARM64). The code in arm/filter_neon_intrinsics.c supports ARM64, however it
* only works if -mfpu=neon is specified on the GCC command line. See pngpriv.h
* for the logic which sets PNG_USE_ARM_NEON_ASM:
*/
#if PNG_ARM_NEON_IMPLEMENTATION == 2 /* hand-coded assembler */
#if PNG_ARM_NEON_OPT > 0
#ifdef __ELF__
# define ELF
#else
@ -29,6 +47,13 @@ ELF .size \name, . - \name
.purgem endfunc
.endm
.text
/* Explicitly specifying alignment here because some versions of
* GAS don't align code correctly. This is harmless in correctly
* written versions of GAS.
*/
.align 2
.if \export
.global \name
.endif
@ -223,3 +248,6 @@ func png_read_filter_row_paeth3_neon, export=1
pop {r4,pc}
endfunc
#endif /* PNG_ARM_NEON_OPT > 0 */
#endif /* PNG_ARM_NEON_IMPLEMENTATION == 2 (assembler) */
#endif /* READ */

View File

@ -0,0 +1,384 @@
/* filter_neon_intrinsics.c - NEON optimised filter functions
*
* Copyright (c) 2014 Glenn Randers-Pehrson
* Written by James Yu <james.yu at linaro.org>, October 2013.
* Based on filter_neon.S, written by Mans Rullgard, 2011.
*
* Last changed in libpng 1.6.16 [December 22, 2014]
*
* This code is released under the libpng license.
* For conditions of distribution and use, see the disclaimer
* and license in png.h
*/
#include "../../pngpriv.h"
#define PNG_SRC_FILE PNG_SRC_FILE_arm_filter_neon_intrinsics
#ifdef PNG_READ_SUPPORTED
/* This code requires -mfpu=neon on the command line: */
#if PNG_ARM_NEON_IMPLEMENTATION == 1 /* intrinsics code from pngpriv.h */
#include <arm_neon.h>
/* libpng row pointers are not necessarily aligned to any particular boundary,
* however this code will only work with appropriate alignment. arm/arm_init.c
* checks for this (and will not compile unless it is done). This code uses
* variants of png_aligncast to avoid compiler warnings.
*/
#define png_ptr(type,pointer) png_aligncast(type *,pointer)
#define png_ptrc(type,pointer) png_aligncastconst(const type *,pointer)
/* The following relies on a variable 'temp_pointer' being declared with type
* 'type'. This is written this way just to hide the GCC strict aliasing
* warning; note that the code is safe because there never is an alias between
* the input and output pointers.
*/
#define png_ldr(type,pointer)\
(temp_pointer = png_ptr(type,pointer), *temp_pointer)
#if PNG_ARM_NEON_OPT > 0
void
png_read_filter_row_up_neon(png_alloc_size_t rowbytes, unsigned int bpp,
png_bytep row, png_const_bytep prev_row)
{
png_bytep rp = row;
png_bytep rp_stop = row + rowbytes;
png_const_bytep pp = prev_row;
for (; rp < rp_stop; rp += 16, pp += 16)
{
uint8x16_t qrp, qpp;
qrp = vld1q_u8(rp);
qpp = vld1q_u8(pp);
qrp = vaddq_u8(qrp, qpp);
vst1q_u8(rp, qrp);
}
PNG_UNUSED(bpp)
}
void
png_read_filter_row_sub3_neon(png_alloc_size_t rowbytes, unsigned int bpp, png_bytep row, png_const_bytep prev_row)
{
png_bytep rp = row;
png_bytep rp_stop = row + rowbytes;
uint8x16_t vtmp = vld1q_u8(rp);
uint8x8x2_t *vrpt = png_ptr(uint8x8x2_t, &vtmp);
uint8x8x2_t vrp = *vrpt;
uint8x8x4_t vdest;
vdest.val[3] = vdup_n_u8(0);
for (; rp < rp_stop;)
{
uint8x8_t vtmp1, vtmp2;
uint32x2_t *temp_pointer;
vtmp1 = vext_u8(vrp.val[0], vrp.val[1], 3);
vdest.val[0] = vadd_u8(vdest.val[3], vrp.val[0]);
vtmp2 = vext_u8(vrp.val[0], vrp.val[1], 6);
vdest.val[1] = vadd_u8(vdest.val[0], vtmp1);
vtmp1 = vext_u8(vrp.val[1], vrp.val[1], 1);
vdest.val[2] = vadd_u8(vdest.val[1], vtmp2);
vdest.val[3] = vadd_u8(vdest.val[2], vtmp1);
vtmp = vld1q_u8(rp + 12);
vrpt = png_ptr(uint8x8x2_t, &vtmp);
vrp = *vrpt;
vst1_lane_u32(png_ptr(uint32_t,rp), png_ldr(uint32x2_t,&vdest.val[0]), 0);
rp += 3;
vst1_lane_u32(png_ptr(uint32_t,rp), png_ldr(uint32x2_t,&vdest.val[1]), 0);
rp += 3;
vst1_lane_u32(png_ptr(uint32_t,rp), png_ldr(uint32x2_t,&vdest.val[2]), 0);
rp += 3;
vst1_lane_u32(png_ptr(uint32_t,rp), png_ldr(uint32x2_t,&vdest.val[3]), 0);
rp += 3;
}
PNG_UNUSED(bpp)
PNG_UNUSED(prev_row)
}
void
png_read_filter_row_sub4_neon(png_alloc_size_t rowbytes, unsigned int bpp,
png_bytep row, png_const_bytep prev_row)
{
png_bytep rp = row;
png_bytep rp_stop = row + rowbytes;
uint8x8x4_t vdest;
vdest.val[3] = vdup_n_u8(0);
for (; rp < rp_stop; rp += 16)
{
uint32x2x4_t vtmp = vld4_u32(png_ptr(uint32_t,rp));
uint8x8x4_t *vrpt = png_ptr(uint8x8x4_t,&vtmp);
uint8x8x4_t vrp = *vrpt;
uint32x2x4_t *temp_pointer;
vdest.val[0] = vadd_u8(vdest.val[3], vrp.val[0]);
vdest.val[1] = vadd_u8(vdest.val[0], vrp.val[1]);
vdest.val[2] = vadd_u8(vdest.val[1], vrp.val[2]);
vdest.val[3] = vadd_u8(vdest.val[2], vrp.val[3]);
vst4_lane_u32(png_ptr(uint32_t,rp), png_ldr(uint32x2x4_t,&vdest), 0);
}
PNG_UNUSED(bpp)
PNG_UNUSED(prev_row)
}
void
png_read_filter_row_avg3_neon(png_alloc_size_t rowbytes, unsigned int bpp,
png_bytep row, png_const_bytep prev_row)
{
png_bytep rp = row;
png_const_bytep pp = prev_row;
png_bytep rp_stop = row + rowbytes;
uint8x16_t vtmp;
uint8x8x2_t *vrpt;
uint8x8x2_t vrp;
uint8x8x4_t vdest;
vdest.val[3] = vdup_n_u8(0);
vtmp = vld1q_u8(rp);
vrpt = png_ptr(uint8x8x2_t,&vtmp);
vrp = *vrpt;
for (; rp < rp_stop; pp += 12)
{
uint8x8_t vtmp1, vtmp2, vtmp3;
uint8x8x2_t *vppt;
uint8x8x2_t vpp;
uint32x2_t *temp_pointer;
vtmp = vld1q_u8(pp);
vppt = png_ptr(uint8x8x2_t,&vtmp);
vpp = *vppt;
vtmp1 = vext_u8(vrp.val[0], vrp.val[1], 3);
vdest.val[0] = vhadd_u8(vdest.val[3], vpp.val[0]);
vdest.val[0] = vadd_u8(vdest.val[0], vrp.val[0]);
vtmp2 = vext_u8(vpp.val[0], vpp.val[1], 3);
vtmp3 = vext_u8(vrp.val[0], vrp.val[1], 6);
vdest.val[1] = vhadd_u8(vdest.val[0], vtmp2);
vdest.val[1] = vadd_u8(vdest.val[1], vtmp1);
vtmp2 = vext_u8(vpp.val[0], vpp.val[1], 6);
vtmp1 = vext_u8(vrp.val[1], vrp.val[1], 1);
vtmp = vld1q_u8(rp + 12);
vrpt = png_ptr(uint8x8x2_t,&vtmp);
vrp = *vrpt;
vdest.val[2] = vhadd_u8(vdest.val[1], vtmp2);
vdest.val[2] = vadd_u8(vdest.val[2], vtmp3);
vtmp2 = vext_u8(vpp.val[1], vpp.val[1], 1);
vdest.val[3] = vhadd_u8(vdest.val[2], vtmp2);
vdest.val[3] = vadd_u8(vdest.val[3], vtmp1);
vst1_lane_u32(png_ptr(uint32_t,rp), png_ldr(uint32x2_t,&vdest.val[0]), 0);
rp += 3;
vst1_lane_u32(png_ptr(uint32_t,rp), png_ldr(uint32x2_t,&vdest.val[1]), 0);
rp += 3;
vst1_lane_u32(png_ptr(uint32_t,rp), png_ldr(uint32x2_t,&vdest.val[2]), 0);
rp += 3;
vst1_lane_u32(png_ptr(uint32_t,rp), png_ldr(uint32x2_t,&vdest.val[3]), 0);
rp += 3;
}
PNG_UNUSED(bpp)
}
void
png_read_filter_row_avg4_neon(png_alloc_size_t rowbytes, unsigned int bpp,
png_bytep row, png_const_bytep prev_row)
{
png_bytep rp = row;
png_bytep rp_stop = row + rowbytes;
png_const_bytep pp = prev_row;
uint8x8x4_t vdest;
vdest.val[3] = vdup_n_u8(0);
for (; rp < rp_stop; rp += 16, pp += 16)
{
uint32x2x4_t vtmp;
uint8x8x4_t *vrpt, *vppt;
uint8x8x4_t vrp, vpp;
uint32x2x4_t *temp_pointer;
vtmp = vld4_u32(png_ptr(uint32_t,rp));
vrpt = png_ptr(uint8x8x4_t,&vtmp);
vrp = *vrpt;
vtmp = vld4_u32(png_ptrc(uint32_t,pp));
vppt = png_ptr(uint8x8x4_t,&vtmp);
vpp = *vppt;
vdest.val[0] = vhadd_u8(vdest.val[3], vpp.val[0]);
vdest.val[0] = vadd_u8(vdest.val[0], vrp.val[0]);
vdest.val[1] = vhadd_u8(vdest.val[0], vpp.val[1]);
vdest.val[1] = vadd_u8(vdest.val[1], vrp.val[1]);
vdest.val[2] = vhadd_u8(vdest.val[1], vpp.val[2]);
vdest.val[2] = vadd_u8(vdest.val[2], vrp.val[2]);
vdest.val[3] = vhadd_u8(vdest.val[2], vpp.val[3]);
vdest.val[3] = vadd_u8(vdest.val[3], vrp.val[3]);
vst4_lane_u32(png_ptr(uint32_t,rp), png_ldr(uint32x2x4_t,&vdest), 0);
}
PNG_UNUSED(bpp)
}
static uint8x8_t
paeth(uint8x8_t a, uint8x8_t b, uint8x8_t c)
{
uint8x8_t d, e;
uint16x8_t p1, pa, pb, pc;
p1 = vaddl_u8(a, b); /* a + b */
pc = vaddl_u8(c, c); /* c * 2 */
pa = vabdl_u8(b, c); /* pa */
pb = vabdl_u8(a, c); /* pb */
pc = vabdq_u16(p1, pc); /* pc */
p1 = vcleq_u16(pa, pb); /* pa <= pb */
pa = vcleq_u16(pa, pc); /* pa <= pc */
pb = vcleq_u16(pb, pc); /* pb <= pc */
p1 = vandq_u16(p1, pa); /* pa <= pb && pa <= pc */
d = vmovn_u16(pb);
e = vmovn_u16(p1);
d = vbsl_u8(d, b, c);
e = vbsl_u8(e, a, d);
return e;
}
void
png_read_filter_row_paeth3_neon(png_alloc_size_t rowbytes, unsigned int bpp,
png_bytep row, png_const_bytep prev_row)
{
png_bytep rp = row;
png_const_bytep pp = prev_row;
png_bytep rp_stop = row + rowbytes;
uint8x16_t vtmp;
uint8x8x2_t *vrpt;
uint8x8x2_t vrp;
uint8x8_t vlast = vdup_n_u8(0);
uint8x8x4_t vdest;
vdest.val[3] = vdup_n_u8(0);
vtmp = vld1q_u8(rp);
vrpt = png_ptr(uint8x8x2_t,&vtmp);
vrp = *vrpt;
for (; rp < rp_stop; pp += 12)
{
uint8x8x2_t *vppt;
uint8x8x2_t vpp;
uint8x8_t vtmp1, vtmp2, vtmp3;
uint32x2_t *temp_pointer;
vtmp = vld1q_u8(pp);
vppt = png_ptr(uint8x8x2_t,&vtmp);
vpp = *vppt;
vdest.val[0] = paeth(vdest.val[3], vpp.val[0], vlast);
vdest.val[0] = vadd_u8(vdest.val[0], vrp.val[0]);
vtmp1 = vext_u8(vrp.val[0], vrp.val[1], 3);
vtmp2 = vext_u8(vpp.val[0], vpp.val[1], 3);
vdest.val[1] = paeth(vdest.val[0], vtmp2, vpp.val[0]);
vdest.val[1] = vadd_u8(vdest.val[1], vtmp1);
vtmp1 = vext_u8(vrp.val[0], vrp.val[1], 6);
vtmp3 = vext_u8(vpp.val[0], vpp.val[1], 6);
vdest.val[2] = paeth(vdest.val[1], vtmp3, vtmp2);
vdest.val[2] = vadd_u8(vdest.val[2], vtmp1);
vtmp1 = vext_u8(vrp.val[1], vrp.val[1], 1);
vtmp2 = vext_u8(vpp.val[1], vpp.val[1], 1);
vtmp = vld1q_u8(rp + 12);
vrpt = png_ptr(uint8x8x2_t,&vtmp);
vrp = *vrpt;
vdest.val[3] = paeth(vdest.val[2], vtmp2, vtmp3);
vdest.val[3] = vadd_u8(vdest.val[3], vtmp1);
vlast = vtmp2;
vst1_lane_u32(png_ptr(uint32_t,rp), png_ldr(uint32x2_t,&vdest.val[0]), 0);
rp += 3;
vst1_lane_u32(png_ptr(uint32_t,rp), png_ldr(uint32x2_t,&vdest.val[1]), 0);
rp += 3;
vst1_lane_u32(png_ptr(uint32_t,rp), png_ldr(uint32x2_t,&vdest.val[2]), 0);
rp += 3;
vst1_lane_u32(png_ptr(uint32_t,rp), png_ldr(uint32x2_t,&vdest.val[3]), 0);
rp += 3;
}
PNG_UNUSED(bpp)
}
void
png_read_filter_row_paeth4_neon(png_alloc_size_t rowbytes, unsigned int bpp,
png_bytep row, png_const_bytep prev_row)
{
png_bytep rp = row;
png_bytep rp_stop = row + rowbytes;
png_const_bytep pp = prev_row;
uint8x8_t vlast = vdup_n_u8(0);
uint8x8x4_t vdest;
vdest.val[3] = vdup_n_u8(0);
for (; rp < rp_stop; rp += 16, pp += 16)
{
uint32x2x4_t vtmp;
uint8x8x4_t *vrpt, *vppt;
uint8x8x4_t vrp, vpp;
uint32x2x4_t *temp_pointer;
vtmp = vld4_u32(png_ptr(uint32_t,rp));
vrpt = png_ptr(uint8x8x4_t,&vtmp);
vrp = *vrpt;
vtmp = vld4_u32(png_ptrc(uint32_t,pp));
vppt = png_ptr(uint8x8x4_t,&vtmp);
vpp = *vppt;
vdest.val[0] = paeth(vdest.val[3], vpp.val[0], vlast);
vdest.val[0] = vadd_u8(vdest.val[0], vrp.val[0]);
vdest.val[1] = paeth(vdest.val[0], vpp.val[1], vpp.val[0]);
vdest.val[1] = vadd_u8(vdest.val[1], vrp.val[1]);
vdest.val[2] = paeth(vdest.val[1], vpp.val[2], vpp.val[1]);
vdest.val[2] = vadd_u8(vdest.val[2], vrp.val[2]);
vdest.val[3] = paeth(vdest.val[2], vpp.val[3], vpp.val[2]);
vdest.val[3] = vadd_u8(vdest.val[3], vrp.val[3]);
vlast = vpp.val[3];
vst4_lane_u32(png_ptr(uint32_t,rp), png_ldr(uint32x2x4_t,&vdest), 0);
}
PNG_UNUSED(bpp)
}
#endif /* PNG_ARM_NEON_OPT > 0 */
#endif /* PNG_ARM_NEON_IMPLEMENTATION == 1 (intrinsics) */
#endif /* READ */

47
contrib/neon/neon.ac Normal file
View File

@ -0,0 +1,47 @@
# LIBPNG EXTENSION: NEON
#
# ARM NEON (SIMD) support.
#
# This file contains configure.ac additions to libpng configure to enable
# building of the ARM NEON filter optimizations.
#
AC_ARG_ENABLE([arm-neon],
AS_HELP_STRING([[[--enable-arm-neon]]],
[Enable ARM NEON optimizations: =no/off, check, api, yes/on:]
[no/off: disable the optimizations; check: use internal checking code]
[(deprecated and poorly supported); api: disable by default, enable by]
[a call to png_set_option; yes/on: turn on unconditionally.]
[If not specified: determined by the compiler.]),
[case "$enableval" in
no|off)
# disable the default enabling on __ARM_NEON__ systems:
AC_DEFINE([PNG_ARM_NEON_OPT], [0],
[Disable ARM Neon optimizations])
# Prevent inclusion of the assembler files below:
enable_arm_neon=no;;
check)
AC_DEFINE([PNG_ARM_NEON_CHECK_SUPPORTED], [],
[Check for ARM Neon support at run-time]);;
api)
AC_DEFINE([PNG_ARM_NEON_API_SUPPORTED], [],
[Turn on ARM Neon optimizations at run-time]);;
yes|on)
AC_DEFINE([PNG_ARM_NEON_OPT], [2],
[Enable ARM Neon optimizations])
AC_MSG_WARN([--enable-arm-neon: please specify 'check' or 'api', if]
[you want the optimizations unconditionally pass -mfpu=neon]
[to the compiler.]);;
*)
AC_MSG_ERROR([--enable-arm-neon=${enable_arm_neon}: invalid value])
esac])
# Add ARM specific files to all builds where the host_cpu is arm ('arm*') or
# where ARM optimizations were explicitly requested (this allows a fallback if a
# future host CPU does not match 'arm*')
AM_CONDITIONAL([PNG_ARM_NEON],
[test "$enable_arm_neon" != 'no' &&
case "$host_cpu" in
arm*|aarch64*) :;;
*) test "$enable_arm_neon" != '';;
esac])

27
contrib/neon/neon.am Normal file
View File

@ -0,0 +1,27 @@
# contrib/neon/neon.am
#
# This is an automake fragment included by the top-level Makefile.am if
# contrib/neon/neon.ac is included in configure
#
# It builds the source files in this directory into ARM hardware support for
# libpng.
#
if PNG_ARM_NEON
libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_SOURCES += %D%/arm_init.c\
%D%/filter_neon.S %D%/filter_neon_intrinsics.c
DFA_EXTENSION += ${srcdir}/%D%/neon.dfa
# This causes pngpriv.h to include the named header. It is VERY important to
# understand that this MUST be defined and the header MUST define internal
# 'extern' functions with PNG_INTERNAL_FUNCTION. This allows vendors to use
# static library builds of libpng without clashing with the installed system
# libpng; see the libpng-prefix option in configure.ac The value of this
# #define is included in pnglibconf.h
#
# NOTE: you must include the double quotes in the value and you must therefore
# support the whole thing with single quotes. If you need to use <> for a
# header be aware that if you miss out the single quotes you will create a
# random file.
AM_CPPFLAGS += -DPNG_EXTENSION_HEADER='"%D%/neon.h"'
endif

41
contrib/neon/neon.dfa Normal file
View File

@ -0,0 +1,41 @@
# contrib/arm/neon.dfa
#
# This is a dfa fragment that is added to DFA_HARDWARE in Makefile.am and
# consequently is inserted after scripts/pnglibconf.dfa to define extra,
# hardware, options.
#
# The following are required in any fragment to record the copyright holder of
# the *changes* and the appropriate email for bug reports. Note that the
# copyright here is just for the specific configuration; additional files may
# have additional and/or different copyrights.
#
# Later settings (e.g. in user.dfa) will override these settings.
#
setting USER_PRIVATEBUILD default "John Bowler"
setting USER_BUG_REPORTS default "jbowler@acm.org"
#
# These options are specific to the ARM NEON hardware optimizations. At present
# these optimizations depend on GCC specific pre-processing of an assembler (.S)
# file so they probably won't work with other compilers.
#
# ARM_NEON_OPT: unset: check at compile time (__ARM_NEON__ must be defined by
# the compiler, typically as a result of specifying
# CC="gcc -mfpu=neon".)
# 0: disable (even if the CPU has a NEON FPU.)
# 1: check at run time (via ARM_NEON_{API,CHECK})
# 2: switch on unconditionally (inadvisable - instead pass
# -mfpu=neon to GCC in CC)
# When building libpng avoid using any setting other than '0'; '1' is
# set automatically when either 'API' or 'CHECK' are configured in,
# '2' should not be necessary as -mfpu=neon will achieve the same
# effect as well as applying NEON optimizations to the rest of the
# libpng code.
# NOTE: any setting other than '0' requires ALIGNED_MEMORY
# ARM_NEON_API: (PNG_ARM_NEON == 1) allow the optimization to be switched on
# with png_set_option
# ARM_NEON_CHECK: (PNG_ARM_NEON == 1) compile a run-time check to see if Neon
# extensions are supported. This is poorly supported and
# deprecated - use the png_set_option API.
setting ARM_NEON_OPT
option ARM_NEON_API disabled enables SET_OPTION sets ARM_NEON_OPT 1
option ARM_NEON_CHECK disabled sets ARM_NEON_OPT 1

124
contrib/neon/neon.h Normal file
View File

@ -0,0 +1,124 @@
/* Compile time options.
* =====================
* In a multi-arch build the compiler may compile the code several times for the
* same object module, producing different binaries for different architectures.
* When this happens configure-time setting of the target host options cannot be
* done. An example is iOS vs Android compilation of ARM NEON support.
*
* NOTE: symbol prefixing does not pass $(CFLAGS) to the preprocessor, because
* this is not possible with certain compilers (Oracle SUN OS CC), as a result
* it is necessary to ensure that all extern functions that *might* be used
* regardless of $(CFLAGS) get declared in this file. The test on __ARM_NEON
* below is one example of this behavior because it is controlled by the
* presence or not of -mfpu=neon on the GCC command line, it is possible to do
* this in $(CC), e.g. "CC=gcc -mfpu=neon", but people who build libpng rarely
* do this.
*/
#ifndef PNG_ARM_NEON_OPT
/* ARM NEON optimizations are being controlled by the compiler settings,
* typically the target FPU. If the FPU supports NEON instructions then the
* compiler will define __ARM_NEON and we can rely unconditionally on NEON
* instructions not crashing, otherwise we must disable use of NEON
* instructions.
*
* NOTE: at present these optimizations depend on 'ALIGNED_MEMORY', so they
* can only be turned on automatically if that is supported too. If
* PNG_ARM_NEON_OPT is set in CPPFLAGS (to >0) then arm/arm_init.c will fail
* to compile with an appropriate #error if ALIGNED_MEMORY has been turned
* off.
*
* Note that older versions of GCC defined __ARM_NEON__; this is no longer
* supported. Also 32-bit ARM versions of GCC required the NEON FPU mode to
* be turned on explicitly on the command line. If this is not done (on
* 32-bit ARM) NEON code will not be included.
*
* To disable ARM_NEON optimizations entirely, and skip compiling the
* associated assembler code, pass --enable-arm-neon=no to configure
* or put -DPNG_ARM_NEON_OPT=0 in CPPFLAGS.
*/
# if defined(__ARM_NEON) && defined(PNG_ALIGNED_MEMORY_SUPPORTED)
# define PNG_ARM_NEON_OPT 2
# else
# define PNG_ARM_NEON_OPT 0
# endif
#endif
#if PNG_ARM_NEON_OPT > 0
/* NEON optimizations are to be at least considered by libpng, so enable the
* callbacks to do this.
*/
# define PNG_FILTER_OPTIMIZATIONS png_init_filter_functions_neon
/* By default the 'intrinsics' code in arm/filter_neon_intrinsics.c is used
* if possible - if __ARM_NEON is set and the compiler version is not known
* to be broken. This is controlled by PNG_ARM_NEON_IMPLEMENTATION which can
* be:
*
* 1 The intrinsics code (the default with __ARM_NEON)
* 2 The hand coded assembler (the default without __ARM_NEON)
*
* It is possible to set PNG_ARM_NEON_IMPLEMENTATION in CPPFLAGS, however
* this is *NOT* supported and may cease to work even after a minor revision
* to libpng. It *is* valid to do this for testing purposes, e.g. speed
* testing or a new compiler, but the results should be communicated to the
* libpng implementation list for incorporation in the next minor release.
*/
# ifndef PNG_ARM_NEON_IMPLEMENTATION
# ifdef __ARM_NEON
# if defined(__clang__)
/* At present it is unknown by the libpng developers which versions
* of clang support the intrinsics, however some or perhaps all
* versions do not work with the assembler so this may be
* irrelevant, so just use the default (do nothing here.)
*/
# elif defined(__GNUC__)
/* GCC 4.5.4 NEON support is known to be broken. 4.6.3 is known to
* work, so if this *is* GCC, or G++, look for a version >4.5
*/
# if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 6)
# define PNG_ARM_NEON_IMPLEMENTATION 2
# endif /* no GNUC support */
# endif /* __GNUC__ */
# else /* !defined __ARM_NEON */
/* The 'intrinsics' code simply won't compile without compiler support
* and that support switches on __ARM_NEON, so use the assembler:
*/
# define PNG_ARM_NEON_IMPLEMENTATION 2
# endif /* __ARM_NEON */
# endif /* !defined PNG_ARM_NEON_IMPLEMENTATION */
# ifndef PNG_ARM_NEON_IMPLEMENTATION
/* Use the intrinsics code by default. */
# define PNG_ARM_NEON_IMPLEMENTATION 1
# endif
#endif /* PNG_ARM_NEON_OPT > 0 */
#ifdef PNG_SET_OPTION_SUPPORTED
#ifdef PNG_ARM_NEON_API_SUPPORTED
# define PNG_ARM_NEON 0 /* HARDWARE: ARM Neon SIMD instructions supported */
#endif
#endif /* SET_OPTION */
#if PNG_ARM_NEON_OPT > 0
PNG_INTERNAL_FUNCTION(void,png_read_filter_row_up_neon,
(png_alloc_size_t row_bytes, unsigned int bpp, png_bytep row,
png_const_bytep prev_row),PNG_EMPTY);
PNG_INTERNAL_FUNCTION(void,png_read_filter_row_sub3_neon,
(png_alloc_size_t row_bytes, unsigned int bpp, png_bytep row,
png_const_bytep prev_row),PNG_EMPTY);
PNG_INTERNAL_FUNCTION(void,png_read_filter_row_sub4_neon,
(png_alloc_size_t row_bytes, unsigned int bpp, png_bytep row,
png_const_bytep prev_row),PNG_EMPTY);
PNG_INTERNAL_FUNCTION(void,png_read_filter_row_avg3_neon,
(png_alloc_size_t row_bytes, unsigned int bpp, png_bytep row,
png_const_bytep prev_row),PNG_EMPTY);
PNG_INTERNAL_FUNCTION(void,png_read_filter_row_avg4_neon,
(png_alloc_size_t row_bytes, unsigned int bpp, png_bytep row,
png_const_bytep prev_row),PNG_EMPTY);
PNG_INTERNAL_FUNCTION(void,png_read_filter_row_paeth3_neon,
(png_alloc_size_t row_bytes, unsigned int bpp, png_bytep row,
png_const_bytep prev_row),PNG_EMPTY);
PNG_INTERNAL_FUNCTION(void,png_read_filter_row_paeth4_neon,
(png_alloc_size_t row_bytes, unsigned int bpp, png_bytep row,
png_const_bytep prev_row),PNG_EMPTY);
#endif

View File

@ -14,7 +14,8 @@ LD=$(CC)
RM=rm -f
COPY=cp
CFLAGS=-DPNG_USER_CONFIG -DNO_GZCOMPRESS -DZ_SOLO -DNO_GZIP -I. -O1
CPPFLAGS=-I. -DPNG_USER_CONFIG -DNO_GZCOMPRESS -DZ_SOLO -DNO_GZIP
CFLAGS=-O1 -Wall
C=.c
O=.o
@ -55,7 +56,7 @@ PNGSRCS=png$(C) pngerror$(C) pngget$(C) pngmem$(C) \
pngset$(C) pngtrans$(C)
# Standard headers
PNGH =png.h pngconf.h pngdebug.h pnginfo.h pngpriv.h pngstruct.h
PNGH =png.h pngconf.h pngdebug.h pnginfo.h pngpriv.h pngstruct.h pngchunk.h
# Machine generated headers
PNGCONF=pnglibconf.h
@ -81,7 +82,7 @@ OBJS = $(PROGOBJS) $(PNGOBJS) $(ZOBJS)
# note: dependencies do not work on implicit rule lines
.c$(O):
$(CC) -c $(CFLAGS) $<
$(CC) -c $(CPPFLAGS) $(CFLAGS) $<
# dependencies
@ -95,16 +96,16 @@ pngm2pnm$(E): $(OBJS)
# The CPP_FLAGS setting causes pngusr.h to be included in
# both the build of pnglibconf.h and, subsequently, when
# building libpng itself.
$(PNGCONF): $(PNGSRC)/scripts/pnglibconf.mak\
$(PNGCONF): $(PNGSRC)/scripts/pnglibconf.mak $(ZH)\
$(PNGSRC)/scripts/pnglibconf.dfa \
$(PNGSRC)/scripts/options.awk pngusr.h pngusr.dfa
$(RM) pnglibconf.h pnglibconf.dfn
$(MAKE) $(MAKEFLAGS) -f $(PNGSRC)/scripts/pnglibconf.mak\
srcdir=$(PNGSRC) CPPFLAGS="-DPNG_USER_CONFIG"\
$(MAKE) -f $(PNGSRC)/scripts/pnglibconf.mak $(MAKEFLAGS)\
srcdir=$(PNGSRC) CPPFLAGS="-DPNG_USER_CONFIG -I."\
DFA_XTRA="pngusr.dfa" $@
clean:
$(MAKE) $(MAKEFLAGS) -f $(PNGSRC)/scripts/pnglibconf.mak\
$(MAKE) -f $(PNGSRC)/scripts/pnglibconf.mak $(MAKEFLAGS)\
srcdir=$(PNGSRC) clean
$(RM) pngm2pnm$(O)
$(RM) pngm2pnm$(E)

View File

@ -1,6 +1,6 @@
# pngminim/decoder/pngusr.dfa
#
# Copyright (c) 2010-2011 Glenn Randers-Pehrson
# Copyright (c) 2010-2013 Glenn Randers-Pehrson
#
# This code is released under the libpng license.
# For conditions of distribution and use, see the disclaimer
@ -36,5 +36,7 @@ option FLOATING_ARITHMETIC off
option SETJMP on
option STDIO on
option READ_EXPAND on
option READ_IMAGE on
option READ_INTERLACING on
option READ_STRIP_16_TO_8 on
option USER_LIMITS on

View File

@ -1,6 +1,6 @@
/* minrdpngconf.h: headers to make a minimal png-read-only library
*
* Copyright (c) 2007, 2010-2011 Glenn Randers-Pehrson
* Copyright (c) 2007, 2010-2013 Glenn Randers-Pehrson
*
* This code is released under the libpng license.
* For conditions of distribution and use, see the disclaimer
@ -18,7 +18,7 @@
* affect the API (so are not recorded in pnglibconf.h)
*/
#define PNG_NO_WARNINGS
#define PNG_RELEASE_BUILD 1
#define PNG_ALIGN_TYPE PNG_ALIGN_NONE
#endif /* MINRDPNGCONF_H */

View File

@ -1,6 +1,6 @@
This demonstrates the use of PNG_USER_CONFIG and pngusr.h
The makefile builds a minimal write-only decoder with embedded libpng
The makefile builds a minimal write-only encoder with embedded libpng
and zlib.
Specify the location of the zlib source (1.2.1 or later) as ZLIBSRC

View File

@ -14,7 +14,8 @@ LD=$(CC)
RM=rm -f
COPY=cp
CFLAGS=-DPNG_USER_CONFIG -DZ_SOLO -DNO_GZIP -I. -O1
CPPFLAGS=-I. -DPNG_USER_CONFIG -DNO_GZCOMPRESS -DZ_SOLO -DNO_GZIP
CFLAGS=-O1 -Wall
C=.c
O=.o
@ -55,7 +56,7 @@ PNGSRCS=png$(C) pngerror$(C) pngget$(C) pngmem$(C) \
pngwtran$(C) pngwutil$(C)
# Standard headers
PNGH =png.h pngconf.h pngdebug.h pnginfo.h pngpriv.h pngstruct.h
PNGH =png.h pngconf.h pngdebug.h pnginfo.h pngpriv.h pngstruct.h pngchunk.h
# Machine generated headers
PNGCONF=pnglibconf.h
@ -80,7 +81,7 @@ OBJS = $(PROGOBJS) $(PNGOBJS) $(ZOBJS)
# implicit make rules -------------------------------------------------------
.c$(O):
$(CC) -c $(CFLAGS) $<
$(CC) -c $(CPPFLAGS) $(CFLAGS) $<
# dependencies
@ -94,16 +95,16 @@ pnm2pngm$(E): $(OBJS)
# The CPP_FLAGS setting causes pngusr.h to be included in
# both the build of pnglibconf.h and, subsequently, when
# building libpng itself.
$(PNGCONF): $(PNGSRC)/scripts/pnglibconf.mak\
$(PNGCONF): $(PNGSRC)/scripts/pnglibconf.mak $(ZH)\
$(PNGSRC)/scripts/pnglibconf.dfa \
$(PNGSRC)/scripts/options.awk pngusr.h pngusr.dfa
$(RM) pnglibconf.h pnglibconf.dfn
$(MAKE) $(MAKEFLAGS) -f $(PNGSRC)/scripts/pnglibconf.mak\
srcdir=$(PNGSRC) CPPFLAGS="-DPNG_USER_CONFIG"\
$(MAKE) -f $(PNGSRC)/scripts/pnglibconf.mak $(MAKEFLAGS)\
srcdir=$(PNGSRC) CPPFLAGS="-DPNG_USER_CONFIG -I."\
DFA_XTRA="pngusr.dfa" $@
clean:
$(MAKE) $(MAKEFLAGS) -f $(PNGSRC)/scripts/pnglibconf.mak\
$(MAKE) -f $(PNGSRC)/scripts/pnglibconf.mak $(MAKEFLAGS)\
srcdir=$(PNGSRC) clean
$(RM) pnm2pngm$(O)
$(RM) pnm2pngm$(E)

View File

@ -1,6 +1,6 @@
# pngminim/encoder/pngusr.dfa
#
# Copyright (c) 2010-2011 Glenn Randers-Pehrson
# Copyright (c) 2010-2013 Glenn Randers-Pehrson
#
# This code is released under the libpng license.
# For conditions of distribution and use, see the disclaimer
@ -14,6 +14,10 @@ everything = off
option WRITE on
# These 2 options are required if you need to read PBM (P1 or P4) files.
option WRITE_INVERT on
option WRITE_PACK on
# You must choose fixed or floating point arithmetic:
# option FLOATING_POINT on

View File

@ -1,6 +1,6 @@
/* minwrpngconf.h: headers to make a minimal png-write-only library
*
* Copyright (c) 2007, 2010-2011 Glenn Randers-Pehrson
* Copyright (c) 2007, 2010-2013 Glenn Randers-Pehrson
*
* This code is released under the libpng license.
* For conditions of distribution and use, see the disclaimer
@ -18,7 +18,7 @@
* affect the API (so are not recorded in pnglibconf.h)
*/
#define PNG_NO_WARNINGS
#define PNG_RELEASE_BUILD 1
#define PNG_ALIGN_TYPE PNG_ALIGN_NONE
#endif /* MINWRPNGCONF_H */

View File

@ -30,7 +30,8 @@ XLIB = -L/usr/X11R6/lib -lX11
#LIBS = $(XLIB)
LIBS = $(XLIB) -lm #platforms that need libm
CFLAGS=-DPNG_USER_CONFIG -DNO_GZCOMPRESS -DZ_SOLO -DNO_GZIP -I. $(XINC) -O1
CPPFLAGS=-I. $(XINC) -DPNG_USER_CONFIG -DNO_GZCOMPRESS -DZ_SOLO -DNO_GZIP
CFLAGS=-O1 -Wall
C=.c
O=.o
@ -71,7 +72,7 @@ PNGSRCS=png$(C) pngerror$(C) pngget$(C) pngmem$(C) \
pngset$(C) pngtrans$(C)
# Standard headers
PNGH =png.h pngconf.h pngdebug.h pnginfo.h pngpriv.h pngstruct.h
PNGH =png.h pngconf.h pngdebug.h pnginfo.h pngpriv.h pngstruct.h pngchunk.h
# Machine generated headers
PNGCONF=pnglibconf.h
@ -96,7 +97,7 @@ OBJS = $(PROGOBJS) $(PNGOBJS) $(ZOBJS)
# implicit make rules -------------------------------------------------------
.c$(O):
$(CC) -c $(CFLAGS) $<
$(CC) -c $(CPPFLAGS) $(CFLAGS) $<
# dependencies
@ -110,16 +111,16 @@ rpng2-x$(E): $(OBJS)
# The CPP_FLAGS setting causes pngusr.h to be included in
# both the build of pnglibconf.h and, subsequently, when
# building libpng itself.
$(PNGCONF): $(PNGSRC)/scripts/pnglibconf.mak\
$(PNGCONF): $(PNGSRC)/scripts/pnglibconf.mak $(ZH)\
$(PNGSRC)/scripts/pnglibconf.dfa \
$(PNGSRC)/scripts/options.awk pngusr.h pngusr.dfa
$(RM) pnglibconf.h pnglibconf.dfn
$(MAKE) $(MAKEFLAGS) -f $(PNGSRC)/scripts/pnglibconf.mak\
srcdir=$(PNGSRC) CPPFLAGS="-DPNG_USER_CONFIG"\
$(MAKE) -f $(PNGSRC)/scripts/pnglibconf.mak $(MAKEFLAGS)\
srcdir=$(PNGSRC) CPPFLAGS="-DPNG_USER_CONFIG -I."\
DFA_XTRA="pngusr.dfa" $@
clean:
$(MAKE) $(MAKEFLAGS) -f $(PNGSRC)/scripts/pnglibconf.mak\
$(MAKE) -f $(PNGSRC)/scripts/pnglibconf.mak $(MAKEFLAGS)\
srcdir=$(PNGSRC) clean
$(RM) rpng2-x$(O)
$(RM) rpng2-x$(E)

View File

@ -1,6 +1,6 @@
# pngminim/preader/pngusr.dfa
#
# Copyright (c) 2010-2011 Glenn Randers-Pehrson
# Copyright (c) 2010-2013 Glenn Randers-Pehrson
#
# This code is released under the libpng license.
# For conditions of distribution and use, see the disclaimer
@ -36,5 +36,6 @@ option STDIO on
option READ_bKGD on
option READ_GAMMA on
option READ_EXPAND on
option READ_INTERLACING on
option READ_STRIP_16_TO_8 on
option READ_GRAY_TO_RGB on

View File

@ -1,6 +1,6 @@
/* minrdpngconf.h: headers to make a minimal png-read-only library
*
* Copyright (c) 2009, 2010-2011 Glenn Randers-Pehrson
* Copyright (c) 2009, 2010-2013 Glenn Randers-Pehrson
*
* This code is released under the libpng license.
* For conditions of distribution and use, see the disclaimer
@ -18,7 +18,7 @@
* affect the API (so are not recorded in pnglibconf.h)
*/
#define PNG_NO_WARNINGS
#define PNG_RELEASE_BUILD 1
#define PNG_ALIGN_TYPE PNG_ALIGN_NONE
#endif /* MINPRDPNGCONF_H */

View File

@ -8,9 +8,9 @@ LD=$(CC)
RM=rm -f
#PNGPATH = /usr/local
#PNGINC = -I$(PNGPATH)/include/libpng16
#PNGLIB = -L$(PNGPATH)/lib -lpng16
#PNGLIBS = $(PNGPATH)/lib/libpng16.a
#PNGINC = -I$(PNGPATH)/include/libpng17
#PNGLIB = -L$(PNGPATH)/lib -lpng17
#PNGLIBS = $(PNGPATH)/lib/libpng17.a
PNGINC = -I../..
PNGLIB = -L../.. -lpng
PNGLIBS = ../../libpng.a

0
contrib/pngminus/png2pnm.bat Normal file → Executable file
View File

0
contrib/pngminus/png2pnm.sh Normal file → Executable file
View File

0
contrib/pngminus/pngminus.bat Normal file → Executable file
View File

0
contrib/pngminus/pngminus.sh Normal file → Executable file
View File

0
contrib/pngminus/pnm2png.bat Normal file → Executable file
View File

View File

@ -1,8 +1,9 @@
/*
* pnm2png.c --- conversion from PBM/PGM/PPM-file to PNG-file
* copyright (C) 1999 by Willem van Schaik <willem@schaik.com>
* copyright (C) 1999,2015 by Willem van Schaik <willem@schaik.com>
*
* version 1.0 - 1999.10.15 - First version.
* version 1.1 - 2015.07.29 - Fixed leaks (Glenn Randers-Pehrson)
*
* Permission to use, copy, modify, and distribute this software and
* its documentation for any purpose and without fee is hereby granted,
@ -50,7 +51,8 @@
int main (int argc, char *argv[]);
void usage ();
BOOL pnm2png (FILE *pnm_file, FILE *png_file, FILE *alpha_file, BOOL interlace, BOOL alpha);
BOOL pnm2png (FILE *pnm_file, FILE *png_file, FILE *alpha_file, BOOL interlace,
BOOL alpha);
void get_token(FILE *pnm_file, char *token);
png_uint_32 get_data (FILE *pnm_file, int depth);
png_uint_32 get_value (FILE *pnm_file, int depth);
@ -176,7 +178,8 @@ void usage()
fprintf (stderr, " or: ... | pnm2png [options]\n");
fprintf (stderr, "Options:\n");
fprintf (stderr, " -i[nterlace] write png-file with interlacing on\n");
fprintf (stderr, " -a[lpha] <file>.pgm read PNG alpha channel as pgm-file\n");
fprintf (stderr,
" -a[lpha] <file>.pgm read PNG alpha channel as pgm-file\n");
fprintf (stderr, " -h | -? print this help-information\n");
}
@ -184,32 +187,36 @@ void usage()
* pnm2png
*/
BOOL pnm2png (FILE *pnm_file, FILE *png_file, FILE *alpha_file, BOOL interlace, BOOL alpha)
BOOL pnm2png (FILE *pnm_file, FILE *png_file, FILE *alpha_file, BOOL interlace,
BOOL alpha)
{
png_struct *png_ptr = NULL;
png_info *info_ptr = NULL;
png_byte *png_pixels = NULL;
png_byte **row_pointers = NULL;
png_byte *pix_ptr = NULL;
png_uint_32 row_bytes;
volatile png_uint_32 row_bytes;
char type_token[16];
char width_token[16];
char height_token[16];
char maxval_token[16];
int color_type;
unsigned long ul_width, ul_alpha_width;
unsigned long ul_height, ul_alpha_height;
unsigned long ul_maxval;
png_uint_32 width, alpha_width;
png_uint_32 height, alpha_height;
volatile int color_type=1;
unsigned long ul_width=0, ul_alpha_width=0;
unsigned long ul_height=0, ul_alpha_height=0;
unsigned long ul_maxval=0;
volatile png_uint_32 width=0, height=0;
volatile png_uint_32 alpha_width=0, alpha_height=0;
png_uint_32 maxval;
int bit_depth = 0;
int channels;
volatile int bit_depth = 0;
int channels=0;
int alpha_depth = 0;
int alpha_present;
int alpha_present=0;
int row, col;
BOOL raw, alpha_raw = FALSE;
#if defined(PNG_WRITE_INVERT_SUPPORTED) || defined(PNG_WRITE_PACK_SUPPORTED)
BOOL packed_bitmap = FALSE;
#endif
png_uint_32 tmp16;
int i;
@ -222,9 +229,21 @@ BOOL pnm2png (FILE *pnm_file, FILE *png_file, FILE *alpha_file, BOOL interlace,
}
else if ((type_token[1] == '1') || (type_token[1] == '4'))
{
#if defined(PNG_WRITE_INVERT_SUPPORTED) || defined(PNG_WRITE_PACK_SUPPORTED)
raw = (type_token[1] == '4');
color_type = PNG_COLOR_TYPE_GRAY;
get_token(pnm_file, width_token);
sscanf (width_token, "%lu", &ul_width);
width = (png_uint_32) ul_width;
get_token(pnm_file, height_token);
sscanf (height_token, "%lu", &ul_height);
height = (png_uint_32) ul_height;
bit_depth = 1;
packed_bitmap = TRUE;
#else
fprintf (stderr, "PNM2PNG built without PNG_WRITE_INVERT_SUPPORTED and \n");
fprintf (stderr, "PNG_WRITE_PACK_SUPPORTED can't read PBM (P1,P4) files\n");
#endif
}
else if ((type_token[1] == '2') || (type_token[1] == '5'))
{
@ -338,76 +357,108 @@ BOOL pnm2png (FILE *pnm_file, FILE *png_file, FILE *alpha_file, BOOL interlace,
channels = 3;
else if (color_type == PNG_COLOR_TYPE_RGB_ALPHA)
channels = 4;
#if 0
else
channels = 0; /* should not happen */
channels = 0; /* cannot happen */
#endif
alpha_present = (channels - 1) % 2;
/* row_bytes is the width x number of channels x (bit-depth / 8) */
row_bytes = width * channels * ((bit_depth <= 8) ? 1 : 2);
#if defined(PNG_WRITE_INVERT_SUPPORTED) || defined(PNG_WRITE_PACK_SUPPORTED)
if (packed_bitmap)
/* row data is as many bytes as can fit width x channels x bit_depth */
row_bytes = (width * channels * bit_depth + 7) / 8;
else
#endif
/* row_bytes is the width x number of channels x (bit-depth / 8) */
row_bytes = width * channels * ((bit_depth <= 8) ? 1 : 2);
if ((png_pixels = (png_byte *) malloc (row_bytes * height * sizeof (png_byte))) == NULL)
if ((png_pixels = (png_byte *)
malloc (row_bytes * height * sizeof (png_byte))) == NULL)
return FALSE;
/* read data from PNM file */
pix_ptr = png_pixels;
for (row = 0; row < height; row++)
for (row = 0; row < (int) height; row++)
{
for (col = 0; col < width; col++)
#if defined(PNG_WRITE_INVERT_SUPPORTED) || defined(PNG_WRITE_PACK_SUPPORTED)
if (packed_bitmap) {
for (i = 0; i < (int) row_bytes; i++)
/* png supports this format natively so no conversion is needed */
*pix_ptr++ = get_data (pnm_file, 8);
} else
#endif
{
for (i = 0; i < (channels - alpha_present); i++)
for (col = 0; col < (int) width; col++)
{
if (raw)
*pix_ptr++ = get_data (pnm_file, bit_depth);
else
if (bit_depth <= 8)
*pix_ptr++ = get_value (pnm_file, bit_depth);
for (i = 0; i < (channels - alpha_present); i++)
{
if (raw)
*pix_ptr++ = get_data (pnm_file, bit_depth);
else
{
tmp16 = get_value (pnm_file, bit_depth);
*pix_ptr = (png_byte) ((tmp16 >> 8) & 0xFF);
pix_ptr++;
*pix_ptr = (png_byte) (tmp16 & 0xFF);
pix_ptr++;
}
}
if (bit_depth <= 8)
*pix_ptr++ = get_value (pnm_file, bit_depth);
else
{
tmp16 = get_value (pnm_file, bit_depth);
*pix_ptr = (png_byte) ((tmp16 >> 8) & 0xFF);
pix_ptr++;
*pix_ptr = (png_byte) (tmp16 & 0xFF);
pix_ptr++;
}
}
if (alpha) /* read alpha-channel from pgm file */
{
if (alpha_raw)
*pix_ptr++ = get_data (alpha_file, alpha_depth);
else
if (alpha_depth <= 8)
*pix_ptr++ = get_value (alpha_file, bit_depth);
if (alpha) /* read alpha-channel from pgm file */
{
if (alpha_raw)
*pix_ptr++ = get_data (alpha_file, alpha_depth);
else
{
tmp16 = get_value (alpha_file, bit_depth);
*pix_ptr++ = (png_byte) ((tmp16 >> 8) & 0xFF);
*pix_ptr++ = (png_byte) (tmp16 & 0xFF);
}
} /* if alpha */
if (alpha_depth <= 8)
*pix_ptr++ = get_value (alpha_file, bit_depth);
else
{
tmp16 = get_value (alpha_file, bit_depth);
*pix_ptr++ = (png_byte) ((tmp16 >> 8) & 0xFF);
*pix_ptr++ = (png_byte) (tmp16 & 0xFF);
}
} /* if alpha */
} /* if packed_bitmap */
} /* end for col */
} /* end for row */
/* prepare the standard PNG structures */
png_ptr = png_create_write_struct (PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
png_ptr = png_create_write_struct (png_get_libpng_ver(NULL), NULL, NULL,
NULL);
if (!png_ptr)
{
free (png_pixels);
png_pixels = NULL;
return FALSE;
}
info_ptr = png_create_info_struct (png_ptr);
if (!info_ptr)
{
png_destroy_write_struct (&png_ptr, (png_infopp) NULL);
free (png_pixels);
png_pixels = NULL;
return FALSE;
}
#if defined(PNG_WRITE_INVERT_SUPPORTED) || defined(PNG_WRITE_PACK_SUPPORTED)
if (packed_bitmap == TRUE)
{
png_set_packing (png_ptr);
png_set_invert_mono (png_ptr);
}
#endif
/* setjmp() must be called in every function that calls a PNG-reading libpng function */
if (setjmp (png_jmpbuf(png_ptr)))
{
png_destroy_write_struct (&png_ptr, (png_infopp) NULL);
png_destroy_write_struct (&png_ptr, &info_ptr);
free (png_pixels);
png_pixels = NULL;
return FALSE;
}
@ -425,25 +476,28 @@ BOOL pnm2png (FILE *pnm_file, FILE *png_file, FILE *alpha_file, BOOL interlace,
/* if needed we will allocate memory for an new array of row-pointers */
if (row_pointers == (unsigned char**) NULL)
{
if ((row_pointers = (png_byte **) malloc (height * sizeof (png_bytep))) == NULL)
if ((row_pointers = (png_byte **)
malloc (height * sizeof (png_bytep))) == NULL)
{
png_destroy_write_struct (&png_ptr, (png_infopp) NULL);
png_destroy_write_struct (&png_ptr, &info_ptr);
free (png_pixels);
png_pixels = NULL;
return FALSE;
}
}
/* set the individual row_pointers to point at the correct offsets */
for (i = 0; i < (height); i++)
for (i = 0; i < (int) height; i++)
row_pointers[i] = png_pixels + i * row_bytes;
/* write out the entire image data in one call */
png_write_image (png_ptr, row_pointers);
/* write the additional chuncks to the PNG file (not really needed) */
/* write the additional chunks to the PNG file (not really needed) */
png_write_end (png_ptr, info_ptr);
/* clean up after the write, and free any memory allocated */
png_destroy_write_struct (&png_ptr, (png_infopp) NULL);
png_destroy_write_struct (&png_ptr, &info_ptr);
if (row_pointers != (unsigned char**) NULL)
free (row_pointers);
@ -460,19 +514,32 @@ BOOL pnm2png (FILE *pnm_file, FILE *png_file, FILE *alpha_file, BOOL interlace,
void get_token(FILE *pnm_file, char *token)
{
int i = 0;
int ret;
/* remove white-space */
/* remove white-space and comment lines */
do
{
token[i] = (unsigned char) fgetc (pnm_file);
ret = fgetc(pnm_file);
if (ret == '#') {
/* the rest of this line is a comment */
do
{
ret = fgetc(pnm_file);
}
while ((ret != '\n') && (ret != '\r') && (ret != EOF));
}
if (ret == EOF) break;
token[i] = (unsigned char) ret;
}
while ((token[i] == '\n') || (token[i] == '\r') || (token[i] == ' '));
/* read string */
do
{
ret = fgetc(pnm_file);
if (ret == EOF) break;
i++;
token[i] = (unsigned char) fgetc (pnm_file);
token[i] = (unsigned char) ret;
}
while ((token[i] != '\n') && (token[i] != '\r') && (token[i] != ' '));

0
contrib/pngminus/pnm2png.sh Normal file → Executable file
View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 325 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 311 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 325 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 311 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 278 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 264 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 265 B

BIN
contrib/testpngs/gray-1.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 251 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 744 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 744 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 744 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 744 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 697 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 697 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 684 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 684 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 325 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 311 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 325 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 311 B

Some files were not shown because too many files have changed in this diff Show More