Commit Graph

525 Commits

Author SHA1 Message Date
Cosmin Truta
70d122aac4 Fix a memory leak in the riffled palette optimization on ARM; refactor
Move deallocation of riffled_palette from png_write_destroy to
png_read_destroy. The reader (not the writer) is the owner of
riffled_palette.

Move allocation and initialization of riffled_palette from
png_do_read_transformations to png_init_palette_transformations.

Allow riffled_palette inside png_struct only if the ARM Neon
optimizations are enabled.

Rename png_riffle_palette_rgba to png_riffle_palette_rgba8, etc.,
to better indicate the strict applicability of these routines.

Fix an unused parameter warning in the build configurations where
riffled palette optimization is not enabled.

Fix indentation.
2019-02-03 19:51:18 -05:00
Richard Townsend
7734cda20c Optimize png_do_expand_palette for ARM
ARM-specific optimization processes 8 or 4 pixels at once.
Improves performance by around 10-22% on a recent ARM Chromebook.
2018-09-04 00:04:58 -04:00
Cosmin Truta
ceb327789b Remove top-level const from function-scope variables
As per the const correctness rules, top-level const-ness of data
in automatic scopes does not propagate outside of these scopes
(unlike const-ness at lower levels, such as pointers to const data).

Previously, const was used liberally, but inconsistently across the
libpng codebase. Using const wherever applicable is not incorrect.
However, _consistent_ use of const is difficult to maintain in such
conditions.

In conclusion, we shall continue to use const only where doing so is
strictly necessary:

1. If a function guarantees that it will not modify an argument
   passed by pointer, the corresponding function parameter should be
   a pointer-to-const (const T *).

2. Static data should not be modified, therefore it should be const.

Reference:
Google C++ Style Guide
https://google.github.io/styleguide/cppguide.html#Use_of_const
2018-08-18 22:47:16 -04:00
Cosmin Truta
1ef8882814 Replace the remaining uses of PNG_CONST with const
In v1.6.0, compiler support for const became a requirement.
It should be used consistently. To maintain backwards compatibility,
PNG_CONST is still maintained in deprecated form.
2018-08-18 21:01:02 -04:00
Cosmin Truta
a873893279 Remove the "last changed" version information from source comments
This information is maintained by the version control system.
2018-07-28 18:47:21 -04:00
Cosmin Truta
46aedd8961 Release libpng version 1.6.35 2018-07-15 23:58:00 -04:00
Cosmin Truta
2471434d29 [libpng16] Added missing parentheses to a macro definition
(Contributed by github.com/irwir)
2018-07-01 23:32:08 -04:00
Cosmin Truta
a74aa9a002 [libpng16] Replace the remaining uses of png_size_t with size_t
In v1.6.0, size_t became a required type. It should be used
consistently. To maintain backwards compatibility, png_size_t
is still maintained in deprecated form.
2018-06-17 22:37:44 -04:00
Glenn Randers-Pehrson
90dd185aed [libpng16] Removed more redundant tests (suggested by "irwir" in Github issue #180). 2017-09-22 17:29:59 -05:00
Glenn Randers-Pehrson
58720d3c06 [libpng16] Fix "last changed" dates 2017-08-29 12:29:03 -05:00
Glenn Randers-Pehrson
f6ca33d42c [libpng16] Bump version to 1.6.33beta01 2017-08-25 18:54:30 -05:00
Glenn Randers-Pehrson
df7e9dae0c [libpng16] Imported from libpng-1.6.32.tar 2017-08-24 16:39:02 -05:00
Glenn Randers-Pehrson
3524b0d201 [libpng16] Update "Last changed" dates and some copyright years 2017-07-31 17:03:17 -05:00
Glenn Randers-Pehrson
40afb68570 [libpng16] Added calls to png_handle_eXIf(() in pngread.c and png_write_eXIf()
in pngwrite.c, and made various other fixes to png_write_eXIf().
Eliminated png_ptr->num_exif member from pngstruct.h and added num_exif
  to arguments for png_get_eXIf() and png_set_eXIf().
2017-07-31 14:21:46 -05:00
Glenn Randers-Pehrson
9fcb846402 [libpng16] Imported from libpng-1.6.31.tar 2017-07-27 05:27:17 -05:00
John Bowler
72d07d3202 [libpng16] Removed one of the GCC-7.1.0 'strict-overflow' warnings that
result when integers appear on both sides of a compare.  Worked around the
  others by forcing the strict-overflow setting in the relevant functions to
  a level where they are not reported.
Changed "FALL THROUGH" comments to "FALLTHROUGH" because GCC doesn't like
  the space.
Worked around some C-style casts from (void*) because g++ 5.4.0 objects
  to them.
Increased the buffer size for 'sprint' to pass the gcc 7.1.0 'sprint
  overflow' check that is on by default with -Wall -Wextra.
2017-07-11 08:47:05 -05:00
Glenn Randers-Pehrson
0c440812db [libpng16] Imported from libpng-1.6.26.tar 2016-10-19 19:11:38 -05:00
Glenn Randers-Pehrson
13bdd8bcdf [libpng16] Imported from libpng-1.6.26beta05.tar 2016-10-05 19:43:35 -05:00
Glenn Randers-Pehrson
761d833372 [libpng16] Quieted all remaining -Wconversion compiler warnings 2016-10-02 18:46:35 -05:00
Glenn Randers-Pehrson
ad3318ddc8 [libpng16] Bump version to 1.6.26beta03 2016-10-01 19:44:42 -05:00
John Bowler
319c9852bf Unsigned overflow
Remove all currently detected cases of unsigned overflow.  Detection is
runtime, so test case dependent.  The changes to pngvalid.c eliminate
spurious and probably invalid tests with one while loop exception.

Apart from that and the change to the dependence on the intended
unsigned overflow in pngtrans.c the changes are limited to altering the
meme for an unsigned 'x' from:

   while (x-- > 0)

to

   for (; x > 0; --x)

This works because, in all cases, the control variable is not used in
the loop.  The 'while' meme was, at one time, warn'ed by GCC so it is
probably a good change, for some weird religious value of good.

Signed-off-by: John Bowler <jbowler@acm.org>
2016-09-30 18:37:22 -07:00
Glenn Randers-Pehrson
b50d5cea2b [libpng16] Imported from libpng-1.6.24.tar 2016-08-03 21:32:26 -05:00
Glenn Randers-Pehrson
dd70604cec [libpng16] Fixed more indentation 2016-07-15 11:20:46 -05:00
John Bowler
175a126a1a Simplified API: write-to-memory, overflow handling
This implements an API and provides a number of assist macros to allow an
application which uses the simplified API write to bypass stdio and write
directly to memory.

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

Signed-off-by: John Bowler <jbowler@acm.org>
2016-01-18 09:53:38 -08:00
Glenn Randers-Pehrson
4d8de33979 [libpng16] Update copyright uears in source files. 2015-12-13 22:41:17 -06:00
Glenn Randers-Pehrson
415d26805a [libpng16] Imported from libpng-1.6.19.tar 2015-11-12 07:13:31 -06:00
Glenn Randers-Pehrson
81f44665cc [libpng16] Reject attempt to write over-length PLTE chunk 2015-10-29 09:26:41 -05:00
Glenn Randers-Pehrson
01a0e8062d [libpng16] Reverted addition of png_set_filler_16 and png_set_add_alpha_16()
functions. They unnecessarily duplicate png_set_filler() and png_set_add_alpha()
which now work properly with 16-bit images.
2015-09-24 22:39:53 -05:00
Glenn Randers-Pehrson
efe4e5d10d [libpng16] Reverted the fix of byte order in png_do_read_filler() with 16-bit
input that was made in version 1.6.17beta01, to preserve legacy
behavior even though it was incorrect.  Instead, added new API
png_set_filter_16() and png_set_add_alpha_16() that set a flag to
make png_do_read_filter() interpret the filler bytes properly.
2015-09-23 22:08:04 -05:00
Glenn Randers-Pehrson
a8242fe6fb [libng16] Reverted recent mistaken change of 0xnnnn to 0xnnnnUL 2015-08-17 20:46:27 -05:00
Glenn Randers-Pehrson
268c7bf68b [libpng16] Use unsigned hex constants in "reciprocal" computations 2015-08-17 12:40:19 -05:00
Glenn Randers-Pehrson
8ba4b13c55 [libpng16] Changed 0xnnnn constants to 0xnnnnUL. 2015-08-16 22:49:58 -05:00
Glenn Randers-Pehrson
8b83ff3704 [libpng16] Change "n bit" to "n-bit" in comments. 2015-08-13 20:57:18 -05:00
Glenn Randers-Pehrson
e6172809bd [libpng16] Imported from libpng-1.6.18.tar 2015-07-22 22:40:52 -05:00
Glenn Randers-Pehrson
f86720c6c0 [libpng16] Fix some indentation. 2015-06-11 22:00:14 -05:00
John Bowler
7023d871e8 [libpng16] Fix g++ build breaks 2015-06-03 15:04:03 -05:00
John Bowler
2dfcf65981 [libpng16] Fixed NO_WRITE_FILTER and -Wconversion build breaks (John Bowler). 2015-06-03 14:58:18 -05:00
Glenn Randers-Pehrson
89edbf8317 [libpng16] 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.
2015-05-31 22:40:36 -05:00
Glenn Randers-Pehrson
20a2f9b9be [libpng16] Imported from libpng-1.6.18beta05.tar 2015-05-31 10:20:13 -05:00
Glenn Randers-Pehrson
e6877671f1 [libpng16] Backported 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.
2015-05-30 11:54:45 -05:00
John Bowler
8ee821e69a [libpng16] 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. Back
ported from libpng17.
2015-05-06 20:03:14 -05:00
Glenn Randers-Pehrson
d8d18fbb02 [libpng16] Imported from libpng-1.6.18beta03.tar 2015-05-06 16:39:31 -05:00
Glenn Randers-Pehrson
c98f7fb4e3 [libpng16] Imported from libpng-1.6.17.tar 2015-03-26 08:11:12 -05:00
Glenn Randers-Pehrson
c5370ede95 [libpng16] Reverted "& 0xff" additions of version 1.6.17beta01. Libpng passes
the Coverity scan without them.
2015-03-21 11:54:32 -05:00
Glenn Randers-Pehrson
3e0bef6da4 [libpng16] Imported from libpng-1.6.17rc01.tar 2015-03-04 11:19:32 -06:00
Glenn Randers-Pehrson
4029db9aac [libpng16] Imported from libpng-1.6.17beta06.tar 2015-02-27 19:01:02 -06:00
Glenn Randers-Pehrson
7011a8cec3 [libpng16] Added "& 0xff" to things being typecast to "png_byte". 2015-02-27 18:53:44 -06:00
Glenn Randers-Pehrson
c6b29ff896 [libpng16] Put #ifdef/#endif around png_set_compression_level in pngwrite.c 2015-02-22 19:39:17 -06:00
Glenn Randers-Pehrson
d3ff44f0d5 [libpng16] Added PNG_WRITE_CUSTOMIZE_COMPRESSION_SUPPORTED macro, on by default. 2015-02-17 21:06:23 -06:00
Glenn Randers-Pehrson
e8ef689cb9 [libpng16] Imported from libpng-1.6.15.tar 2014-11-20 10:22:57 -06:00