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