[master] Imported from libpng-1.6.19.tar

This commit is contained in:
Glenn Randers-Pehrson 2015-11-12 07:00:12 -06:00
parent 287fb89248
commit b9c62013ef
217 changed files with 2530 additions and 1725 deletions

153
ANNOUNCE
View File

@ -1,4 +1,4 @@
Libpng 1.6.18 - July 23, 2015
Libpng 1.6.19 - November 12, 2015
This is a public release of libpng, intended for use in production codes.
@ -7,79 +7,104 @@ Files available for download:
Source files with LF line endings (for Unix/Linux) and with a
"configure" script
libpng-1.6.18.tar.xz (LZMA-compressed, recommended)
libpng-1.6.18.tar.gz
libpng-1.6.19.tar.xz (LZMA-compressed, recommended)
libpng-1.6.19.tar.gz
Source files with CRLF line endings (for Windows), without the
"configure" script
lpng1618.7z (LZMA-compressed, recommended)
lpng1618.zip
lpng1619.7z (LZMA-compressed, recommended)
lpng1619.zip
Other information:
libpng-1.6.18-README.txt
libpng-1.6.18-LICENSE.txt
libpng-1.6.18-*.asc (armored detached GPG signatures)
libpng-1.6.19-README.txt
libpng-1.6.19-LICENSE.txt
libpng-1.6.19-*.asc (armored detached GPG signatures)
Changes since the last public release (1.6.17):
Removed PNG_SET_CHUNK_[CACHE|MALLOC]_LIMIT_SUPPORTED macros. They
have been combined with PNG_SET_USER_LIMITS_SUPPORTED (resolves
bug report by Andrew Church).
Fixed rgb_to_gray checks and added tRNS checks to pngvalid.c. This
fixes some arithmetic errors that caused some tests to fail on
some 32-bit platforms (Bug reports by Peter Breitenlohner [i686]
and Petr Gajdos [i586]).
Changes since the last public release (1.6.18):
Updated obsolete information about the simplified API macros in the
manual pages (Bug report by Arc Riley).
Avoid potentially dereferencing NULL info_ptr in png_info_init_3().
Rearranged png.h to put the major sections in the same order as
in libpng17.
Eliminated unused PNG_COST_SHIFT, PNG_WEIGHT_SHIFT, PNG_COST_FACTOR, and
PNG_WEIGHT_FACTOR macros.
Suppressed some warnings from the Borland C++ 5.5.1/5.82 compiler
(Bug report by Viktor Szaka'ts).
Replaced "unexpected" with an integer (0xabadca11) in pngset.c
where a long was expected, to avoid a compiler warning when PNG_DEBUG > 1.
Added contrib/examples/simpleover.c, to demonstrate how to handle
alpha compositing of multiple images, using the "simplified API"
and an example PNG generation tool, contrib/examples/genpng.c
(Bug report by Viktor Szakats). Several warnings remain and are
unavoidable, where we test for overflow.
Fixed potential leak of png_pixels in contrib/pngminus/pnm2png.c
Fixed uninitialized variable in contrib/gregbook/rpng2-x.c
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).
Removed unreachable "break" statements in png.c, pngread.c, and pngrtran.c
to suppress clang warnings (Bug report by Viktor Szakats).
Fixed some bad links in the man page.
Changed "n bit" to "n-bit" in comments.
Added signed/unsigned 16-bit safety net. This removes the dubious
0x8000 flag definitions on 16-bit systems. They aren't supported
yet the defs *probably* work, however it seems much safer to do this
and be advised if anyone, contrary to advice, is building libpng 1.6
on a 16-bit system. It also adds back various switch default clauses
for GCC; GCC errors out if they are not present (with an appropriately
high level of warnings).
Safely convert num_bytes to a png_byte in png_set_sig_bytes() (Robert
Seacord).
Fixed the recently reported 1's complement security issue by replacing
the value that is illegal in the PNG spec, in both signed and unsigned
values, with 0. Illegal unsigned values (anything greater than or equal
to 0x80000000) can still pass through, but since these are not illegal
in ANSI-C (unlike 0x80000000 in the signed case) the checking that
occurs later can catch them (John Bowler).
Fixed png_save_int_32 when int is not 2's complement (John Bowler).
Updated libpng16 with all the recent test changes from libpng17,
including changes to pngvalid.c to ensure that the original,
distributed, version of contrib/visupng/cexcept.h can be used
(John Bowler).
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 (John Bowler).
Avoid Coverity issue 80858 (REVERSE NULL) in pngtest.c
Avoid a harmless potential integer overflow in png_XYZ_from_xy() (Bug
report from Christopher Ferris).
Backport filter selection code from libpng-1.7.0beta51, to combine
sub_row, up_row, avg_row, and paeth_row into try_row and tst_row.
Changed png_voidcast(), etc., to voidcast(), etc., in contrib/tools/pngfix.c
to avoid confusion with the libpng private macros.
Fixed old cut&paste bug in the weighted filter selection code in
pngwutil.c, introduced in libpng-0.95, March 1997.
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
and do nothing.
Quieted some 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.
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).
Fixed cexcept.h in which GCC 5 now reports that one of the auto
variables in the Try macro needs to be volatile to prevent value
being lost over the setjmp (John Bowler).
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).
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.
Removed some unused WEIGHTED_FILTER macros from pngstruct.h
Replaced arbitrary use of 'extern' with #define PNG_LINKAGE_*. To
preserve API compatibility, the new defines all default to "extern"
(requested by Jan Nijtmans).
Belatedly added Mans Rullgard and James Yu to the list of Contributing
Authors.
pngvalid contains the correction to the use of SAVE/STORE_
UNKNOWN_CHUNKS; a bug revealed by changes in libpng 1.7. More
tests contain the --strict option to detect warnings and the
pngvalid-standard test has been corrected so that it does not
turn on progressive-read. There is a separate test which does
that. (John Bowler)
Also made some signed/unsigned fixes.
Make pngstest 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. Since libpng 1.6 and 1.7 have
slightly different error limits this simplifies maintenance. The
makepngs.sh script has also been updated to more accurately reflect
current problems in libpng 1.7 (John Bowler).
Incorporated new test PNG files into make check. tests/pngstest-*
are changed so that the new test files are divided into 8 groups by
gamma and alpha channel. These tests have considerably better code
and pixel-value coverage than contrib/pngsuite; however,coverage is
still incomplete (John Bowler).
Removed the '--strict' in 1.6 because of the double-gamma-correction
warning, updated pngstest-errors.h for the errors detected with the
new contrib/testspngs PNG test files (John Bowler).
Worked around 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.
Fixed '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 (bug report by Curtis Leach, fix by John Bowler).
Added sPLT support to pngtest.c
Prevent setting or writing over-length PLTE chunk (Cosmin Truta).
Silently truncate over-length PLTE chunk while reading.
Libpng incorrectly calculated the output rowbytes when the application
decreased either the number of channels or the bit depth (or both) in
a user transform. This was safe; libpng overallocated buffer space
(potentially by quite a lot; up to 4 times the amount required) but,
from 1.5.4 on, resulted in a png_error (John Bowler).
Fixed some inconsequential cut-and-paste typos in png_set_cHRM_XYZ_fixed().
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.
Send comments/corrections/commendations to png-mng-implement at lists.sf.net
(subscription required; visit

139
CHANGES
View File

@ -3756,8 +3756,9 @@ Version 1.5.7beta04 [November 17, 2011]
Version 1.5.7beta05 [November 25, 2011]
Removed "zTXt" from warning in generic chunk decompression function.
Validate time settings passed to pngset() and png_convert_to_rfc1123()
(Frank Busse).
Validate time settings passed to png_set_tIME() and png_convert_to_rfc1123()
(Frank Busse). Note: This prevented CVE-2015-7981 from affecting
libpng-1.5.7 and later.
Added MINGW support to CMakeLists.txt
Reject invalid compression flag or method when reading the iTXt chunk.
Backed out 'simplified' API changes. The API seems too complex and there
@ -3803,12 +3804,13 @@ Version 1.6.0beta01 [December 15, 2011]
(the other two required headers aren't used). Non-ANSI systems that don't
have stddef.h or limits.h will have to provide an appropriate fake
containing the relevant types and #defines.
The use of FAR/far has been eliminated and the definition of png_alloc_size_t
is now controlled by a flag so that 'small size_t' systems can select it
if necessary. Libpng 1.6 may not currently work on such systems -- it
seems likely that it will ask 'malloc' for more than 65535 bytes with any
image that has a sufficiently large row size (rather than simply failing
to read such images).
Dropped support for 16-bit platforms. The use of FAR/far has been eliminated
and the definition of png_alloc_size_t is now controlled by a flag so
that 'small size_t' systems can select it if necessary. Libpng 1.6 may
not currently work on such systems -- it seems likely that it will
ask 'malloc' for more than 65535 bytes with any image that has a
sufficiently large row size (rather than simply failing to read such
images).
New tools directory containing tools used to generate libpng code.
Fixed race conditions in parallel make builds. With higher degrees of
parallelism during 'make' the use of the same temporary file names such
@ -4420,7 +4422,7 @@ Version 1.6.1beta02 [February 19, 2013]
Version 1.6.1beta03 [February 22, 2013]
Fixed ALIGNED_MEMORY support.
Allow run-time ARM NEON checking to be disabled. A new configure option:
Added 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
@ -4439,10 +4441,10 @@ Version 1.6.1beta05 [March 1, 2013]
Version 1.6.1beta06 [March 4, 2013]
Better documentation of unknown handling API interactions.
Corrected Android builds and corrected libpng.vers with symbol
prefixing. This adds an API to set optimization options externally,
prefixing. It also makes those tests compile and link on Android.
Added an API png_set_option() 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.
run-time tests used by the ARM Neon code, using the PNG_ARM_NEON option.
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.
@ -4540,7 +4542,8 @@ Version 1.6.3beta05 [May 9, 2013]
Calculate our own zlib windowBits when decoding rather than trusting the
CMF bytes in the PNG datastream.
Added an option to force maximum window size for inflating, which was
the behavior of libpng15 and earlier.
the behavior of libpng15 and earlier, via a new PNG_MAXIMUM_INFLATE_WINDOW
option for png_set_options().
Added png-fix-itxt and png-fix-too-far-back to the built programs and
removed warnings from the source code and timepng that are revealed as
a result.
@ -5143,7 +5146,9 @@ Version 1.6.17beta01 [January 29, 2015]
Added testing of png_set_packing() to pngvalid.c
Regenerated configure scripts in the *.tar distributions with libtool-2.4.4
Implement previously untested cases of libpng transforms in pngvalid.c
Fixed byte order in 2-byte filler, in png_do_read_filler().
Fixed byte order in png_do_read_filler() with 16-bit input. Previously
the high and low bytes of the filler, from png_set_filler() or from
png_set_add_alpha(), were read in the wrong order.
Made the check for out-of-range values in png_set_tRNS() detect
values that are exactly 2^bit_depth, and work on 16-bit platforms.
Merged some parts of libpng-1.6.17beta01 and libpng-1.7.0beta47.
@ -5225,7 +5230,7 @@ Version 1.6.18beta01 [April 1, 2015]
Version 1.6.18beta02 [April 26, 2015]
Suppressed some warnings from the Borland C++ 5.5.1/5.82 compiler
(Bug report by Viktor Szaka'ts).
(Bug report by Viktor Szakats).
Version 1.6.18beta03 [May 6, 2015]
Replaced "unexpected" with an integer (0xabadca11) in pngset.c
@ -5305,6 +5310,110 @@ Version 1.6.18rc03 [July 15, 2015]
Version 1.6.18 [July 23, 2015]
No changes.
Version 1.6.19beta01 [July 30, 2015]
Updated obsolete information about the simplified API macros in the
manual pages (Bug report by Arc Riley).
Avoid potentially dereferencing NULL info_ptr in png_info_init_3().
Rearranged png.h to put the major sections in the same order as
in libpng17.
Eliminated unused PNG_COST_SHIFT, PNG_WEIGHT_SHIFT, PNG_COST_FACTOR, and
PNG_WEIGHT_FACTOR macros.
Suppressed some warnings from the Borland C++ 5.5.1/5.82 compiler
(Bug report by Viktor Szakats). Several warnings remain and are
unavoidable, where we test for overflow.
Fixed potential leak of png_pixels in contrib/pngminus/pnm2png.c
Fixed uninitialized variable in contrib/gregbook/rpng2-x.c
Version 1.6.19beta02 [August 19, 2015]
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).
Removed unreachable "break" statements in png.c, pngread.c, and pngrtran.c
to suppress clang warnings (Bug report by Viktor Szakats).
Fixed some bad links in the man page.
Changed "n bit" to "n-bit" in comments.
Added signed/unsigned 16-bit safety net. This removes the dubious
0x8000 flag definitions on 16-bit systems. They aren't supported
yet the defs *probably* work, however it seems much safer to do this
and be advised if anyone, contrary to advice, is building libpng 1.6
on a 16-bit system. It also adds back various switch default clauses
for GCC; GCC errors out if they are not present (with an appropriately
high level of warnings).
Safely convert num_bytes to a png_byte in png_set_sig_bytes() (Robert
Seacord).
Fixed the recently reported 1's complement security issue by replacing
the value that is illegal in the PNG spec, in both signed and unsigned
values, with 0. Illegal unsigned values (anything greater than or equal
to 0x80000000) can still pass through, but since these are not illegal
in ANSI-C (unlike 0x80000000 in the signed case) the checking that
occurs later can catch them (John Bowler).
Version 1.6.19beta03 [September 26, 2015]
Fixed png_save_int_32 when int is not 2's complement (John Bowler).
Updated libpng16 with all the recent test changes from libpng17,
including changes to pngvalid.c to ensure that the original,
distributed, version of contrib/visupng/cexcept.h can be used
(John Bowler).
pngvalid contains the correction to the use of SAVE/STORE_
UNKNOWN_CHUNKS; a bug revealed by changes in libpng 1.7. More
tests contain the --strict option to detect warnings and the
pngvalid-standard test has been corrected so that it does not
turn on progressive-read. There is a separate test which does
that. (John Bowler)
Also made some signed/unsigned fixes.
Make pngstest 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. Since libpng 1.6 and 1.7 have
slightly different error limits this simplifies maintenance. The
makepngs.sh script has also been updated to more accurately reflect
current problems in libpng 1.7 (John Bowler).
Incorporated new test PNG files into make check. tests/pngstest-*
are changed so that the new test files are divided into 8 groups by
gamma and alpha channel. These tests have considerably better code
and pixel-value coverage than contrib/pngsuite; however,coverage is
still incomplete (John Bowler).
Removed the '--strict' in 1.6 because of the double-gamma-correction
warning, updated pngstest-errors.h for the errors detected with the
new contrib/testspngs PNG test files (John Bowler).
Version 1.6.19beta04 [October 15, 2015]
Worked around 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.
Fixed '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 (bug report by Curtis Leach, fix by John Bowler).
Added sPLT support to pngtest.c
Version 1.6.19rc01 [October 23, 2015]
No changes.
Version 1.6.19rc02 [October 31, 2015]
Prevent setting or writing over-length PLTE chunk (Cosmin Truta).
Silently truncate over-length PLTE chunk while reading.
Libpng incorrectly calculated the output rowbytes when the application
decreased either the number of channels or the bit depth (or both) in
a user transform. This was safe; libpng overallocated buffer space
(potentially by quite a lot; up to 4 times the amount required) but,
from 1.5.4 on, resulted in a png_error (John Bowler).
Version 1.6.19rc03 [November 3, 2015]
Fixed some inconsequential cut-and-paste typos in png_set_cHRM_XYZ_fixed().
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.
Version 1.6.19rc04 [November 5, 2015]
Fixed new bug with CRC error after reading an over-length palette
(bug report by Cosmin Truta).
Version 1.6.19 [November 12, 2015]
Cleaned up coding style in png_handle_PLTE().
Send comments/corrections/commendations to png-mng-implement at lists.sf.net
(subscription required; visit
https://lists.sourceforge.net/lists/listinfo/png-mng-implement

View File

@ -16,7 +16,7 @@ enable_testing()
set(PNGLIB_MAJOR 1)
set(PNGLIB_MINOR 6)
set(PNGLIB_RELEASE 18)
set(PNGLIB_RELEASE 19)
set(PNGLIB_NAME libpng${PNGLIB_MAJOR}${PNGLIB_MINOR})
set(PNGLIB_VERSION ${PNGLIB_MAJOR}.${PNGLIB_MINOR}.${PNGLIB_RELEASE})
@ -261,7 +261,7 @@ 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.18
# VERSION 16.${PNGLIB_RELEASE}.1.6.19
VERSION 16.${PNGLIB_RELEASE}.0
SOVERSION 16
CLEAN_DIRECT_OUTPUT 1)

27
LICENSE
View File

@ -10,10 +10,11 @@ this sentence.
This code is released under the libpng license.
libpng versions 1.0.7, July 1, 2000, through 1.6.18, July 23, 2015, are
Copyright (c) 2000-2002, 2004, 2006-2015 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.6.19, November 12, 2015, are
Copyright (c) 2000-2002, 2004, 2006-2015 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
@ -32,18 +33,20 @@ and with the following additions to the disclaimer:
the user.
libpng versions 0.97, January 1998, through 1.0.6, March 20, 2000, are
Copyright (c) 1998-2000 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, 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:
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
@ -90,6 +93,8 @@ 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:
@ -104,4 +109,4 @@ the additional disclaimers inserted at version 1.0.7.
Glenn Randers-Pehrson
glennrp at users.sourceforge.net
July 23, 2015
November 12, 2015

View File

@ -51,23 +51,17 @@ TESTS =\
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-interlace-size\
tests/pngvalid-progressive-size\
tests/pngvalid-progressive-interlace-standard\
tests/pngvalid-progressive-interlace-transform\
tests/pngvalid-transform\
tests/pngvalid-progressive-standard tests/pngvalid-standard\
tests/pngstest-0g01 tests/pngstest-0g02 tests/pngstest-0g04\
tests/pngstest-0g08 tests/pngstest-0g16 tests/pngstest-2c08\
tests/pngstest-2c16 tests/pngstest-3p01 tests/pngstest-3p02\
tests/pngstest-3p04 tests/pngstest-3p08 tests/pngstest-4a08\
tests/pngstest-4a16 tests/pngstest-6a08 tests/pngstest-6a16\
tests/pngstest-error tests/pngunknown-IDAT\
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
# These tests are expected, and required, to fail:
XFAIL_TESTS = tests/pngstest-error
# man pages
dist_man_MANS= libpng.3 libpngpf.3 png.5

2
README
View File

@ -1,4 +1,4 @@
README for libpng version 1.6.18 - July 23, 2015 (shared library 16.0)
README for libpng version 1.6.19 - November 12, 2015 (shared library 16.0)
See the note about version numbers near the top of png.h
See INSTALL for instructions on how to install libpng.

View File

@ -74,12 +74,12 @@ done
#
# The autotools generated files:
libpng_autotools_files="Makefile.in aclocal.m4 config.guess config.h.in
config.h.in~ config.sub configure depcomp install-sh ltmain.sh missing\
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"
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\

View File

@ -18,7 +18,7 @@ AC_PREREQ([2.68])
dnl Version number stuff here:
AC_INIT([libpng],[1.6.18],[png-mng-implement@lists.sourceforge.net])
AC_INIT([libpng],[1.6.19],[png-mng-implement@lists.sourceforge.net])
AC_CONFIG_MACRO_DIR([scripts])
# libpng does not follow GNU file name conventions (hence 'foreign')
@ -39,10 +39,10 @@ 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.18
PNGLIB_VERSION=1.6.19
PNGLIB_MAJOR=1
PNGLIB_MINOR=6
PNGLIB_RELEASE=18
PNGLIB_RELEASE=19
dnl End of version number stuff

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".

View File

@ -87,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;

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)
---------------------------------------------------------------------------*/
@ -261,18 +266,19 @@ 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 */
* 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;
@ -293,6 +299,7 @@ static void readpng2_info_callback(png_structp png_ptr, png_infop info_ptr)
mainprog_ptr->bg_blue = (uch)pBackground->blue;
}
}
}
/* as before, let libpng expand palette images to RGB, low-bit-depth

View File

@ -43,12 +43,10 @@
- 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)
TO DO:
use nanosleep() instead of usleep(), which is obsolete/deprecated.
- 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
@ -119,6 +117,7 @@
# undef usleep
# define usleep(usec) { \
struct timespec ts; \
ts.tv_sec = 0; \
ts.tv_nsec = (usec) * 1000; \
nanosleep(&ts, NULL); }
# endif

View File

@ -1,4 +1,12 @@
/* Fake a PNG - just write it out directly. */
/* 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 */

View File

@ -1,8 +1,9 @@
/* makepng.c
*
* Copyright (c) 2013 John Cunningham Bowler
*
* Last changed in libpng 1.6.1 [March 28, 2013]
/* makepng.c */
#define _ISOC99_SOURCE
/* Copyright: */
#define COPYRIGHT "\251 2013,2015 John Cunningham Bowler"
/*
* 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
@ -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,6 +130,8 @@
#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)
# include <config.h>
@ -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.
@ -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:
*/
@ -625,13 +875,13 @@ write_png(const char **name, FILE *fp, int color_type, int bit_depth,
gamma_table[0] = 0;
for (i=1; i<255; ++i)
gamma_table[i] = (png_byte)floor(pow(i/255.,conv) * 255 + .5);
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,6 +893,8 @@ 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);
if (tRNS)
png_set_tRNS(png_ptr, info_ptr, trans, npalette-1,
NULL/*transparent color*/);
@ -651,6 +903,16 @@ write_png(const char **name, FILE *fp, int color_type, int bit_depth,
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);
{
# 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)
{
unsigned int row_filters =
generate_row(row, rowbytes, y, color_type, bit_depth,
gamma_table, conv, colors);
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];
@ -1231,6 +1503,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 +1626,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 +1640,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 +1792,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 +1814,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 +1844,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);

View File

@ -2,7 +2,7 @@
*
* Copyright (c) 2015 John Cunningham Bowler
*
* Last changed in libpng 1.6.18 [July 23, 2015]
* Last changed in libpng 1.6.19 [November 12, 2015]
*
* This code is released under the libpng license.
* For conditions of distribution and use, see the disclaimer
@ -236,10 +236,12 @@ static struct transform_info
*/
#endif
#ifdef PNG_READ_SCALE_16_TO_8_SUPPORTED
T(SCALE_16, NONE, X, X, 16, R)
T(SCALE_16, NONE, X, X, 16, R),
/* scales 16-bit components to 8-bits. */
#endif
{ NULL /*name*/, 0, 0, 0, 0, 0, 0, 0/*!tested*/ }
#undef T
};
@ -294,7 +296,7 @@ transform_name(int t)
t &= -t; /* first set bit */
for (i=0; i<TTABLE_SIZE; ++i)
for (i=0; i<TTABLE_SIZE; ++i) if (transform_info[i].name != NULL)
{
if ((transform_info[i].transform & t) != 0)
return transform_info[i].name;
@ -315,7 +317,7 @@ validate_T(void)
{
unsigned int i;
for (i=0; i<TTABLE_SIZE; ++i)
for (i=0; i<TTABLE_SIZE; ++i) if (transform_info[i].name != NULL)
{
if (transform_info[i].when & TRANSFORM_R)
read_transforms |= transform_info[i].transform;
@ -505,6 +507,7 @@ typedef enum
#define SKIP_BUGS 0x100 /* Skip over known bugs */
#define LOG_SKIPPED 0x200 /* Log skipped bugs */
#define FIND_BAD_COMBOS 0x400 /* Attempt to deduce bad combos */
#define LIST_COMBOS 0x800 /* List combos by name */
/* Result masks apply to the result bits in the 'results' field below; these
* bits are simple 1U<<error_level. A pass requires either nothing worse than
@ -690,7 +693,35 @@ display_log(struct display *dp, error_level level, const char *fmt, ...)
int tr = dp->transforms;
if (is_combo(tr))
{
if (dp->options & LIST_COMBOS)
{
int trx = tr;
fprintf(stderr, "(");
if (trx)
{
int start = 0;
while (trx)
{
int trz = trx & -trx;
if (start) fprintf(stderr, "+");
fprintf(stderr, "%s", transform_name(trz));
start = 1;
trx &= ~trz;
}
}
else
fprintf(stderr, "-");
fprintf(stderr, ")");
}
else
fprintf(stderr, "(0x%x)", tr);
}
else
fprintf(stderr, "(%s)", transform_name(tr));
@ -910,7 +941,7 @@ update_display(struct display *dp)
int bd = dp->bit_depth;
unsigned int i;
for (i=0; i<TTABLE_SIZE; ++i)
for (i=0; i<TTABLE_SIZE; ++i) if (transform_info[i].name != NULL)
{
int transform = transform_info[i].transform;
@ -935,9 +966,6 @@ update_display(struct display *dp)
dp->active_transforms = active;
dp->ignored_transforms = inactive; /* excluding write-only transforms */
if (active == 0)
display_log(dp, INTERNAL_ERROR, "bad transform table");
}
}
@ -1588,6 +1616,12 @@ main(const int argc, const char * const * const argv)
else if (strcmp(name, "--nofind-bad-combos") == 0)
d.options &= ~FIND_BAD_COMBOS;
else if (strcmp(name, "--list-combos") == 0)
d.options |= LIST_COMBOS;
else if (strcmp(name, "--nolist-combos") == 0)
d.options &= ~LIST_COMBOS;
else if (name[0] == '-' && name[1] == '-')
{
fprintf(stderr, "pngimage: %s: unknown option\n", name);

View File

@ -0,0 +1,165 @@
/* contrib/libtests/pngstest-errors.h
*
* BUILT USING: libpng version 1.6.19beta03 - September 25, 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, 0, 0 }, { 0, 0, 0, 0 }, { 0, 20, 0, 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, 16, 17, 0 }, { 0, 17, 17, 0 }, { 0, 19, 0, 0 }, { 0, 0, 0, 0 },
{ 0, 850, 875, 0 }, { 0, 850, 875, 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, 9, 0 }, { 0, 0, 9, 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, 9, 0 }, { 0, 9, 9, 0 },
{ 0, 585, 427, 0 }, { 0, 585, 427, 0 }, { 0, 717, 514, 0 }, { 0, 717, 514, 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, 16, 17, 0 }, { 0, 187, 17, 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, 5, 0 }, { 0, 32, 5, 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, 560, 0 }, { 0, 0, 560, 0 }, { 0, 0, 560, 0 }, { 0, 0, 560, 0 }
}, { /* input: sRGB-gray+alpha */
{ 0, 19, 9, 0 }, { 0, 255, 9, 25 }, { 0, 88, 9, 0 }, { 0, 255, 9, 25 },
{ 0, 1012, 928, 0 }, { 0, 16026, 928, 6425 }, { 0, 1012, 928, 0 }, { 0, 16026, 928, 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, 15736, 2824, 6425 }, { 0, 14019, 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, 99, 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, 187, 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 */

View File

@ -3,7 +3,7 @@
*
* Copyright (c) 2013-2015 John Cunningham Bowler
*
* Last changed in libpng 1.6.18 [July 23, 2015]
* Last changed in libpng 1.6.19 [(PENDING RELEASE)]
*
* This code is released under the libpng license.
* For conditions of distribution and use, see the disclaimer
@ -1984,156 +1984,7 @@ static void (* const gpc_fn_colormapped[8/*in*/][8/*out*/])
* gpc_error_to_colormap.
*/
#if PNG_FORMAT_FLAG_COLORMAP == 8 /* extra check also required */
/* START MACHINE GENERATED */
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, 18, 0, 0 }, { 0, 0, 0, 0 }, { 0, 20, 0, 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, 4, 13, 0 }, { 0, 14, 13, 0 }, { 0, 19, 0, 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, 9, 7, 0 }, { 0, 74, 9, 0 }, { 0, 16, 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, 409, 0 }, { 0, 717, 409, 0 },
{ 0, 1, 1, 0 }, { 0, 1, 1, 0 }, { 0, 1, 0, 0 }, { 0, 0, 0, 0 },
{ 0, 13323, 460, 0 }, { 0, 334, 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, 19, 0 }, { 0, 0, 19, 0 }, { 0, 0, 15, 0 }, { 0, 0, 15, 0 }
}, { /* input: sRGB-rgb+alpha */
{ 0, 12, 14, 0 }, { 0, 180, 14, 0 }, { 0, 14, 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, 8, 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, 8, 3, 0 }, { 0, 32, 3, 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, 560, 0 }, { 0, 0, 560, 0 }, { 0, 0, 560, 0 }, { 0, 0, 560, 0 }
}, { /* input: sRGB-gray+alpha */
{ 0, 19, 2, 0 }, { 0, 255, 2, 25 }, { 0, 88, 2, 0 }, { 0, 255, 2, 25 },
{ 0, 1012, 745, 0 }, { 0, 16026, 745, 6425 }, { 0, 1012, 745, 0 }, { 0, 16026, 745, 6425 }
}, { /* input: sRGB-rgb */
{ 0, 0, 19, 0 }, { 0, 0, 19, 0 }, { 0, 0, 25, 0 }, { 0, 0, 25, 0 },
{ 0, 0, 937, 0 }, { 0, 0, 937, 0 }, { 0, 0, 13677, 0 }, { 0, 0, 13677, 0 }
}, { /* input: sRGB-rgb+alpha */
{ 0, 63, 77, 0 }, { 0, 255, 19, 25 }, { 0, 220, 25, 0 }, { 0, 255, 25, 67 },
{ 0, 17534, 18491, 0 }, { 0, 15614, 2824, 6425 }, { 0, 14019, 13677, 0 }, { 0, 48573, 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, 97, 74, 0 }, { 0, 255, 74, 25 },
{ 0, 18919, 18907, 0 }, { 0, 24549, 18907, 6552 }, { 0, 18919, 18907, 0 }, { 0, 24549, 18907, 6552 }
}, { /* 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, 187, 98, 0 }, { 0, 255, 98, 67 },
{ 0, 18141, 18137, 0 }, { 0, 17494, 17504, 6553 }, { 0, 24979, 24992, 0 }, { 0, 46509, 24992, 17347 }
}
};
/* END MACHINE GENERATED */
# include "pngstest-errors.h" /* machine generated */
#endif /* COLORMAP flag check */
#endif /* flag checks */
@ -2154,7 +2005,7 @@ typedef struct
int in_opaque; /* Value of input alpha that is opaque */
int is_palette; /* Sample values come from the palette */
int accumulate; /* Accumlate component errors (don't log) */
int output_8bit; /* Output is 8 bit (else 16 bit) */
int output_8bit; /* Output is 8-bit (else 16-bit) */
void (*in_gp)(Pixel*, png_const_voidp);
void (*out_gp)(Pixel*, png_const_voidp);
@ -3722,6 +3573,23 @@ main(int argc, char **argv)
{
unsigned int in;
printf("/* contrib/libtests/pngstest-errors.h\n");
printf(" *\n");
printf(" * BUILT USING:" PNG_HEADER_VERSION_STRING);
printf(" *\n");
printf(" * This code is released under the libpng license.\n");
printf(" * For conditions of distribution and use, see the disclaimer\n");
printf(" * and license in png.h\n");
printf(" *\n");
printf(" * THIS IS A MACHINE GENERATED FILE: do not edit it directly!\n");
printf(" * Instead run:\n");
printf(" *\n");
printf(" * pngstest --accumulate\n");
printf(" *\n");
printf(" * on as many PNG files as possible; at least PNGSuite and\n");
printf(" * contrib/libtests/testpngs.\n");
printf(" */\n");
printf("static png_uint_16 gpc_error[16/*in*/][16/*out*/][4/*a*/] =\n");
printf("{\n");
for (in=0; in<16; ++in)
@ -3811,6 +3679,7 @@ main(int argc, char **argv)
putchar('\n');
}
printf("};\n");
printf("/* END MACHINE GENERATED */\n");
}
if (retval == 0 && touch != NULL)

View File

@ -363,7 +363,7 @@ ancillary(const char *name)
return PNG_CHUNK_ANCILLARY(PNG_U32(name[0], name[1], name[2], name[3]));
}
#ifdef PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED
#ifdef PNG_SAVE_UNKNOWN_CHUNKS_SUPPORTED
static int
ancillaryb(const png_byte *name)
{
@ -554,7 +554,7 @@ read_callback(png_structp pp, png_unknown_chunkp pc)
/* 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_STORE_UNKNOWN_CHUNKS_SUPPORTED
# ifdef PNG_SAVE_UNKNOWN_CHUNKS_SUPPORTED
return discard;
# else
return 1; /*handled; discard*/
@ -562,7 +562,7 @@ read_callback(png_structp pp, png_unknown_chunkp pc)
}
#endif /* READ_USER_CHUNKS_SUPPORTED */
#ifdef PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED
#ifdef PNG_SAVE_UNKNOWN_CHUNKS_SUPPORTED
static png_uint_32
get_unknown(display *d, png_infop info_ptr, int after_IDAT)
{
@ -722,11 +722,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.
*/
# 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;
}
continue;
}
@ -735,7 +741,12 @@ check(FILE *fp, int argc, const char **argv, png_uint_32p flags/*out*/,
case 7: /* default */
if (memcmp(argv[i], "default", 7) == 0)
{
# 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);
d->keep = option;
continue;
}
@ -745,7 +756,12 @@ check(FILE *fp, int argc, const char **argv, png_uint_32p flags/*out*/,
case 3: /* all */
if (memcmp(argv[i], "all", 3) == 0)
{
# 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);
d->keep = option;
for (chunk = 0; chunk < NINFO; ++chunk)
@ -1242,4 +1258,4 @@ main(void)
/* So the test is skipped: */
return 77;
}
#endif /* SET_UNKNOWN_CHUNKS && READ */
#endif /* SET_UNKNOWN_CHUNKS && READ*/

File diff suppressed because it is too large Load Diff

View File

@ -31,6 +31,13 @@
# include "../../png.h"
#endif
#if PNG_LIBPNG_VER < 10700
/* READ_INTERLACING was used instead of READ_DEINTERLACE. */
# ifdef PNG_READ_INTERLACING_SUPPORTED
# define PNG_READ_DEINTERLACE_SUPPORTED
# endif
#endif
static int
read_png(FILE *fp)
{
@ -70,7 +77,12 @@ read_png(FILE *fp)
{
png_uint_32 height = png_get_image_height(png_ptr, info_ptr);
# ifdef PNG_READ_DEINTERLACE_SUPPORTED
int passes = png_set_interlace_handling(png_ptr);
# else
int passes = png_get_interlace_type(png_ptr, info_ptr) ==
PNG_INTERLACE_ADAM7 ? PNG_INTERLACE_ADAM7_PASSES : 1;
# endif
int pass;
png_start_read_image(png_ptr);
@ -79,6 +91,11 @@ read_png(FILE *fp)
{
png_uint_32 y = height;
# ifndef PNG_READ_DEINTERLACE_SUPPORTED
if (passes == PNG_INTERLACE_ADAM7_PASSES)
y = PNG_PASS_ROWS(y, pass);
# endif
/* NOTE: this trashes the row each time; interlace handling won't
* work, but this avoids memory thrashing for speed testing.
*/

View File

@ -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

@ -266,7 +266,7 @@ BOOL png2pnm (FILE *png_file, FILE *pnm_file, FILE *alpha_file,
png_set_expand (png_ptr);
#ifdef NJET
/* downgrade 16-bit images to 8 bit */
/* downgrade 16-bit images to 8-bit */
if (bit_depth == 16)
png_set_strip_16 (png_ptr);
/* transform grayscale images into full-color */

View File

@ -3,6 +3,7 @@
* copyright (C) 1999 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,
@ -200,17 +201,17 @@ BOOL pnm2png (FILE *pnm_file, FILE *png_file, FILE *alpha_file, BOOL interlace,
char width_token[16];
char height_token[16];
char maxval_token[16];
volatile int color_type;
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, height;
volatile png_uint_32 alpha_width, alpha_height;
volatile png_uint_32 width=0, height=0;
volatile png_uint_32 alpha_width=0, alpha_height=0;
png_uint_32 maxval;
volatile int bit_depth = 0;
int channels;
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)
@ -356,8 +357,10 @@ 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;
@ -429,12 +432,16 @@ BOOL pnm2png (FILE *pnm_file, FILE *png_file, FILE *alpha_file, BOOL interlace,
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;
}
@ -449,7 +456,9 @@ BOOL pnm2png (FILE *pnm_file, FILE *png_file, FILE *alpha_file, BOOL interlace,
/* 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;
}
@ -470,7 +479,9 @@ BOOL pnm2png (FILE *pnm_file, FILE *png_file, FILE *alpha_file, BOOL interlace,
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;
}
}
@ -486,7 +497,7 @@ BOOL pnm2png (FILE *pnm_file, FILE *png_file, FILE *alpha_file, BOOL interlace,
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);

View File

@ -1,8 +1,8 @@
pngsuite
--------
(c) Willem van Schaik, 1999, 2011, 2012
Two images are by Glenn Randers-Pehrson, 2012
Copyright (c) Willem van Schaik, 1999, 2011, 2012
Two images (ftbbn0g01.png and ftbbn0g02.png) are by Glenn Randers-Pehrson, 2012
Permission to use, copy, modify, and distribute these images for any
purpose and without fee is hereby granted.

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

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-2.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 251 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 327 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 313 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 327 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 313 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 280 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 266 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 267 B

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 253 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 327 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 313 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 327 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 313 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 280 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 266 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 267 B

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 253 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 919 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 919 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 872 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 859 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: 684 B

94
contrib/testpngs/makepngs.sh Executable file
View File

@ -0,0 +1,94 @@
#!/bin/sh
#
# Make a set of test PNG files, MAKEPNG is the name of the makepng executable
# built from contrib/libtests/makepng.c
# Copyright (c) 2015 John Cunningham Bowler
# 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
# The arguments say whether to build all the files or whether just to build the
# ones that extend the code-coverage of libpng from the existing test files in
# contrib/pngsuite.
test -n "$MAKEPNG" || MAKEPNG=./makepng
opts=
mp(){
${MAKEPNG} $opts $1 "$3" "$4" "$3-$4$2.png"
}
mpg(){
if test "$1" = "none"
then
mp "" "" "$2" "$3"
else
mp "--$1" "-$1" "$2" "$3"
fi
}
mptrans(){
if test "$1" = "none"
then
mp "--tRNS" "-tRNS" "$2" "$3"
else
mp "--tRNS --$1" "-$1-tRNS" "$2" "$3"
fi
}
case "$1" in
--small)
opts="--small";;&
--all|--small)
for g in none sRGB linear 1.8
do
for c in gray palette
do
for b in 1 2 4
do
mpg "$g" "$c" "$b"
mptrans "$g" "$c" "$b"
done
done
mpg "$g" palette 8
mptrans "$g" palette 8
for b in 8 16
do
for c in gray gray-alpha rgb rgb-alpha
do
mpg "$g" "$c" "$b"
done
for c in gray rgb
do
mptrans "$g" "$c" "$b"
done
done
done;;
--coverage)
# Comments below indicate cases known to be required and not duplicated
# in other (required) cases; the aim is to get a minimal set that gives
# the maxium code coverage.
mpg none gray-alpha 8 # required: code coverage, sRGB opaque component
mpg none palette 8 # required: basic palette read
mpg 1.8 gray 2 # required: tests gamma threshold code
mpg 1.8 palette 2 # required: code coverage
mpg 1.8 palette 4 # required: code coverage
mpg 1.8 palette 8 # error limits only
mpg linear palette 8 # error limits only
mpg linear rgb-alpha 16 # error limits only
mpg sRGB palette 1 # required: code coverage
mpg sRGB rgb-alpha 16 # required: code coverage: pngread.c:2422 untested
:;;
*)
echo "$0 $1: unknown argument, usage:" >&2
echo " $0 [--all|--coverage|--small]" >&2
exit 1
esac

Binary file not shown.

After

Width:  |  Height:  |  Size: 342 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 329 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 342 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 329 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 295 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 282 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 282 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 269 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 350 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 335 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 350 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 335 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 303 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 288 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 290 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 275 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 400 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 373 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 400 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 373 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 353 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 326 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 340 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 313 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

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