Unify the compression code so that inflate calls are localized to a common
routine. Ground work for filter selection support. Minor API changes to use
void* not byte* for data parameters. Unification of some of the compression
code with the decompression code; IDAT_size replaces IDAT_read_size and
zbuffer_size, IDAT reading and writing is no longer controlled by the size of
the compression buffer.
Signed-off-by: John Bowler <jbowler@acm.org>
This commit moves code round and changes the filter write interfaces that took
png_uint_32 buffer pixel counts to unsigned int. Also moves compression code
and definitions into pngwutil.c so that the compression code is isolated from
other definitions.
Signed-off-by: John Bowler <jbowler@acm.org>
Now that the code works consistently so that these just switch off the support
for having libpng do the interlace/deinterlace the old names make more sense,
restoring them avoids cruft in the configuration file and avoids an unnecessary
version specific change.
Signed-off-by: John Bowler <jbowler@acm.org>
commit fc4b42b1d56f95efeb1b9fe42dc35b7d98d246bb
Merge: 74516c7 9eb1413
Author: John Bowler <jbowler@acm.org>
Date: Sun Nov 22 19:37:54 2015 -0800
Merge branch 'libpng17' into libpng17-filter-enhancements
commit 74516c7257f1a28a69985684c5673caa390c700a
Author: John Bowler <jbowler@acm.org>
Date: Sun Nov 22 19:32:43 2015 -0800
Make check full pass on gcc/g++ x86_64
Signed-off-by: John Bowler <jbowler@acm.org>
commit e891e34737fc0bc9ee873a5d56b83c1e777b990c
Author: John Bowler <jbowler@acm.org>
Date: Sun Nov 22 12:01:37 2015 -0800
Checkpoint: write buffering changes
This version fails in pngvalid --size because of an error handling very narrow
images, otherwise a standard build passes make check.
Signed-off-by: John Bowler <jbowler@acm.org>
commit 457a046ebdab737eefb477126cf855e49df6de50
Author: John Bowler <jbowler@acm.org>
Date: Sun Nov 22 06:39:36 2015 -0800
Fix previous bad merge
commit b4f426c97267317637d43f41fe0b05d1659bc63d
Merge: 07b9b90 a3458a6
Author: John Bowler <jbowler@acm.org>
Date: Sun Nov 22 06:32:34 2015 -0800
Merge branch 'libpng17' into libpng17-filter-enhancements
commit 07b9b90dfd653b744dbc3710b096facf6b4605f6
Merge: ed43306 5592e0b
Author: John Bowler <jbowler@acm.org>
Date: Sat Nov 21 17:07:23 2015 -0800
Merge branch 'libpng17' into libpng17-filter-enhancements
commit ed43306599f7039a90187862db82273fca3a4c3d
Merge: 772aed7 d3c0359
Author: John Bowler <jbowler@acm.org>
Date: Tue Nov 17 17:47:26 2015 -0800
Merge branch 'libpng17' into libpng17-filter-enhancements
commit 772aed72378df9c8fccc5a4594b095d02d410a9c
Merge: 73ae431 801608f
Author: John Bowler <jbowler@acm.org>
Date: Mon Nov 16 14:26:38 2015 -0800
Merge branch 'libpng17' into libpng17-filter-enhancements
commit 73ae4316cb6db7d7f6756583a1c213c35ca4e3f4
Merge: 687e6e3 c09b3ab
Author: John Bowler <jbowler@acm.org>
Date: Sun Nov 15 09:31:30 2015 -0800
Merge branch 'libpng17' into libpng17-filter-enhancements
commit 687e6e393e9d0220c2a12ec474aa01b83c5e9f25
Merge: fedd6da e916d9b
Author: John Bowler <jbowler@acm.org>
Date: Thu Nov 5 08:45:14 2015 -0800
Merge branch 'libpng17' into libpng17-filter-enhancements
commit fedd6da8798a14b2e002b0bc1379f5a09a03598a
Merge: 2e2fc5f ea41fd2
Author: John Bowler <jbowler@acm.org>
Date: Tue Nov 3 21:05:01 2015 -0800
Merge branch 'libpng17' into libpng17-filter-enhancements
commit 2e2fc5f6d7678b710c52b7ea081ac4add677d8d5
Merge: 990d5f8 5b05197
Author: John Bowler <jbowler@acm.org>
Date: Mon Oct 12 08:28:30 2015 -0700
Merge branch 'libpng17' into libpng17-filter-enhancements
commit 990d5f88688635dc0888657b689e30ffe7e7a7b3
Author: John Bowler <jbowler@acm.org>
Date: Sun Oct 4 17:04:53 2015 -0700
Read row buffer changes
The read code now allocates one row buffer of the size of the input PNG row and,
only if required, one buffer of the size of the output.
The output buffer is required for the progressive reader (always) and for the
sequential reader if libpng is de-interlacing an image (because the output row
is used multiple times if png_read_row is called with a display row parameter.)
This should reduce memory utilization by libpng significantly, but it has no
detectable effect on overall performance figures of the test programs, these are
probably dominated by memory allocations for the whole image within the test
programs.
Signed-off-by: John Bowler <jbowler@acm.org>
commit 527bf989bf0e30440f9e07a5544a6ebb1d6fd039
Merge: 50ebbc2 9099254
Author: John Bowler <jbowler@acm.org>
Date: Sat Oct 3 13:39:17 2015 -0700
Merge branch 'libpng17' into libpng17-filter-enhancements
commit 50ebbc2c9a24cf1a6b428db53d55fbd5af4d6be6
Merge: 21a7f40 2cd6d56
Author: John Bowler <jbowler@acm.org>
Date: Sat Oct 3 11:16:32 2015 -0700
Merge branch 'libpng17' into libpng17-filter-enhancements
commit 21a7f401ab40c79ead9e35882a8066e2cf1d6902
Merge: b512e1c 15a143e
Author: John Bowler <jbowler@acm.org>
Date: Wed Sep 30 19:01:23 2015 -0700
Merge branch 'libpng17' into libpng17-filter-enhancements
commit b512e1c2c5bfe6df8b6dca32f862d325ec22115e
Author: John Bowler <jbowler@acm.org>
Date: Wed Sep 30 17:33:34 2015 -0700
Transform rewrite: perform transforms in small chunks
The intent of this change is to reduce the memory footprint during transform
sequences by performing transforms in fixed (small) sized blocks of pixels.
The change is incomplete; the filter code still works row-by-row, so the whole
tranform also works row-by-row, the intent is to fix this so that everything
works in small(ish) chunks.
At present the change has no discernable effect on pngvalid --speed or pngstest
with (e.g.) rgb-8-1.8.png; user time and (minor) page faults are the same in old
and new versions. The same applies to real-world 15MP PNG images; even on these
the presence of the filter code causes a cyclical progress through memory which
will interfere with any caching otherwise possible (useful word, 'otherwise'.)
Signed-off-by: John Bowler <jbowler@acm.org>
commit 781cb3699b92beb0e6bc5e03cef8fba820267082
Author: John Bowler <jbowler@acm.org>
Date: Wed Sep 30 17:12:53 2015 -0700
Fix NO_WRITE_INTERLACE in pngvalid.c
The support for writing interlaced images directly from libpng 1.7 was
unintentionally disabled (INTERLACE_LAST was defined incorrectly, excluding the
interlaced images). This obscured the fact that the transform and error test
case generators lacked the support for writing interlaced images from libpng.
Signed-off-by: John Bowler <jbowler@acm.org>
commit 406ee2fd7946a384f1d7713712dc646080c5c52c
Author: John Bowler <jbowler@acm.org>
Date: Wed Sep 30 17:11:40 2015 -0700
Add pngvalid --transform --interlace test
This increases code coverage by generating test cases with smaller length rows
as a result of the interlacing. Without this packswap handling was incompletely
tested.
Signed-off-by: John Bowler <jbowler@acm.org>
Signed-off-by: John Bowler <jbowler@acm.org>
This implements a new chunk parse implementation that can be shared, it
is currently shared by the progressive reader and the sequential one
(not, yet, the writer).
The patch also implements shared transform handling that is used
throughout.
Signed-off-by: John Bowler <jbowler@acm.org>
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
single try_row buffer and in cases where two or more of those are
being tested, a second tst_row buffer. This improves CPU speed
over that achieved by libpng-1.7.0beta49.
prefixing. This adds an API to set optimization options externally,
providing an alternative and general solution for the non-portable
run-time tests used by the ARM Neon code. It also makes those tests
compile and link on Android. The order of settings vs options in
pnglibconf.h is reversed to allow settings to depend on options and
options can now set (or override) the defaults for settings.
by earlier versions of GCC fixed for Cygwin and Min/GW (which both use old GCCs.)
ARM support is enabled by default in zlib.props (unsupported by Microsoft) and
ARM compilation is made possible by deleting the check for x86. The test programs
cannot be run because they are not signed.
links and tests against zlib with a prefix; tests have been clarified; and
irrelevant or obsolete things (as defined by the autotools man page) have
been removed.
These changes cause 16-bit arithmetic to be used for 8-bit data in the gamma
corrected compose and grayscale operations. The arithmetic errors have
three sources all of which are fixed in this commit:
1) 8-bit linear calculations produce massive errors for lower intensity
values.
2) The old 16-bit "16 to 8" gamma table code erroneously wrote the lowest
output value into a table entry which corresponded to multiple output
values (so where the value written should have been the closest to the
transformed input value.)
3) In a number of cases the code to access the 16-bit table did not round;
it did a simple shift, which was wrong and made the side effects of (2)
even worse.
The new gamma code does not have the 16-to-8 problem at the cost of slighly
more calculations and the algorithm used to minimize the number of
calculations has been extended to all the 16-bit tables; it has advantages
for any significant gamma correction.
management system (CMS). In practice it is not possible to obtain cHRM
information reliably using just the end-point tags because they do not exist
in the vast majority of profiles. Instead it is necessary to run the endpoints
through the ICC colorimetric intent transform (as described in the v4
spec). Since this is likely to be too much code inside libpng for too
little gain (it implies a fairly complete CMS implementation) the code
has been changed to allow an external CMS to be used. This code is
temporarily disabled until a suitable set of test cases using one or more
external CMS implementations have been implemented.
Glenn thought the "adopted" were typos and changed them all to "adapted".
This reverts the spelling and adds parenthetical comments when each
word first appears in png.h.
fixed Cygwin+MSVC build errors. The ICC profile handling now includes more
checking. Several errors that caused rejection of the profile are now
handled with a warning in such a way that the invalid profiles will be
read by default in release (but not pre-RC) builds but will not be
written by default. The easy part of handling a cHRM chunk is written,
where the ICC profile contains the required data. The more difficult
part plus guessing a gAMA value requires code to pass selected RGB values
through the profile.
control of the unknown handling, corrects the pre-existing bug where
the per-chunk 'keep' setting is ignored and makes it possible to skip
IDAT chunks in the sequential reader (broken in earlier 1.6 versions).
There is a new test program, test-unknown.c, which is a work in progress
(not currently part of the test suite). Comments in the header files now
explain how the unknown handling works.
on read and write. In libpng 1.6 the two cases can be distinguished and
considerable code cleanup, and extra error checking, is possible. This
makes calls on the write side that have no effect be ignored with a
png_app_error(), which can be disabled in the app using
png_set_benign_errors(), and removes the spurious use of usr_channels
on the read side.
functions [rw]util.c. A new shared keyword check routine was also added
and the 'zbuf' is no longer allocated on progressive read. It is now
possible to call png_inflate() incrementally.
read code now claims and releases png_ptr->zstream, like the write code.
The bug whereby the progressive reader failed to release the zstream
is now fixed, all initialization is delayed, and the code checks for
changed parameters on deflate rather than always calling
deflatedEnd/deflateInit.
those uses of png_memcpy that were doing a simple assignment to assignments
(all those cases where the thing being copied is a non-array C L-value.)
Added some error checking to png_set_*() routines and removed the
reference to the non-exported function png_memcpy() from example.c. Fixed
the Visual C 64-bit build - it requires jmp_buf to be aligned, but it had
become misaligned.
changes alter how the tricky allocation of the initial png_struct and png_info
structures are handled. png_info is now handled in pretty much the same
way as everything else, except that the allocations handle NULL return
silently. png_struct is changed in a similar way on allocation and on
deallocation a 'safety' error handler is put in place (which should never
be required). The error handler itself is changed to permit mismatches
in the application and libpng error buffer size; however, this means a
silent change to the API to return the jmp_buf if the size doesn't match
the size from the libpng compilation; libpng now allocates the memory and
this may fail. Overall these changes result in slight code size
reductions; however, this is a reduction in code that is always executed
so is particularly valuable. Overall on a 64-bit system the libpng DLL
decreases in code size by 1733 bytes. pngerror.o increases in size by
about 465 bytes because of the new functionality.
These changes alter how the tricky allocation of the initial png_struct and
png_info structures are handled. png_info is now handled in pretty much the
same way as everything else, except that the allocations handle NULL return
silently. png_struct is changed in a similar way on allocation and on
deallocation a 'safety' error handler is put in place (which should never
be required). The error handler itself is changed to permit mismatches
in the application and libpng error buffer size; however, this means a
silent change to the API to return the jmp_buf if the size doesn't match
the size from the libpng compilation; libpng now allocates the memory and
this may fail. Overall these changes result in slight code size
reductions; however, this is a reduction in code that is always executed
so is particularly valuable. Overall on a 64-bit system the libpng DLL
decreases in code size by 1733 bytes. pngerror.o increases in size by
about 465 bytes because of the new functionality.
These fixes attend to most of the errors revealed in pngvalid, however doing
the gamma work twice results in inaccuracies that can't be easily fixed.
There is now a warning in the code if this is going to happen.