519 Commits

Author SHA1 Message Date
Cosmin Truta
f20e66aa93 chore: Apply some of the missed updates to the copyright year 2025-02-19 13:15:14 +02:00
John Bowler
68e090e700 fix: png_write_iCCP check on profile length
This is a regression of commit a8242dd9473a8da4d851623cf0b514a8ee4bee34
"PNGv3 colourspace precedence rules conformance".

Previously, `png_write_iCCP` used the length from the first four bytes
of the profile set by `png_set_iCCP`, rather than the actual data length
recorded by `png_set_iCCP`.

If the profile data were less than 4 bytes long, it would have caused
a read-beyond-end-of-malloc error.  This bug was in the libpng code even
before the changes introduced in the above-mentioned commit, but it was
inaccessible.  It became accessible when we removed the pre-PNGv3 colour
space checks in `png_set_iCCP`.

Reported-by: Bob Friesenhahn <bobjfriesenhahn@gmail.com>
Reviewed-by: Cosmin Truta <ctruta@gmail.com>
Signed-off-by: John Bowler <jbowler@acm.org>
Signed-off-by: Cosmin Truta <ctruta@gmail.com>
2025-01-30 23:22:42 +02:00
John Bowler
92e8581f12 api(PNGv3): Add support for mDCV and cLLI
This adds APIs to get/set the two remaining new PNG-v3 colour space
chunks.  The mDCV API matches that of cHRM.  Both chunks support
floating point APIs (all values in the two chunks are real numbers).

Both chunks have a new encoded type, a four-digit-precision fixed-point
number, which cannot be represented in the existing `png_fixed_point`
type, so a `png_uint_32` is used.

Test examples for cICP, cLLI and mDCV are now in pngtest.png, and a
necessary change to the pngunknown.c test program has been made to
accomodate the additions.

Reviewed-by: Cosmin Truta <ctruta@gmail.com>
Signed-off-by: John Bowler <jbowler@acm.org>
Signed-off-by: Cosmin Truta <ctruta@gmail.com>
2025-01-08 23:22:50 +02:00
Cosmin Truta
823c2d80dc [libpng16] fix: Update the cICP support for better compliance with PNG-3
Apply the following corrections and improvements:
 * Add a validity check in `png_set_cICP`.
 * Fix the ordering check in `png_handle_cICP`.
 * Add a multiplicity check in `png_handle_cICP`.
 * Optimize the implementation of `png_write_cICP`.
 * Remove an unnecessary preprocessor guard from pngtest.c.
 * Update the dependency declaration in pnglibconf.dfa.
 * Fix the indentation where necessary.

This is a cherry-pick of commit c2a02691df1ecf51b7c97142752a7034350cb1f6
from branch 'libpng18'.
2025-01-02 11:15:20 +02:00
Lucas CHOLLET
75748d93ce [libpng16] Add support for reading and writing the cICP chunk
This chunk was added in the third edition of the PNG specification and
contains Coding Independent Code Points (related to color space
description). It is fairly simple as it only contains four fields of one
byte each: Colour Primaries, Transfer Function, Matrix Coefficients,
Video Full Range Flag.

The test file originally comes from the related WPT test case:
https://github.com/web-platform-tests/wpt/blob/master/png/support/cicp-display-p3.png

Note that I reencoded the file to make it match libpng's default
encoding parameters (it only modifies the IDAT chunk).

This is a cherry-pick of commit 65925ad4b2cbed934d5d850fe764dc46c4becbcb
from branch 'libpng18'.

Reviewed-by: John Bowler <jbowler@acm.org>
Reviewed-by: Chris Blume <ProgramMax@gmail.com>
Reviewed-by: Cosmin Truta <ctruta@gmail.com>
Signed-off-by: Cosmin Truta <ctruta@gmail.com>
2025-01-02 11:15:20 +02:00
Cosmin Truta
d9d70e6506 [libpng16] refactor: Deduplicate the interlace arrays png_pass_*
Move the definitions of interlace arrays to the top of their respective
translation units, to reduce their repeated copying in various places of
the codebase.

TODO:
As they still exist in three copies, in pngpread.c, in pngrutil.c, and
in pngwutil.c, they should all be further moved to a common place.

This is a cherry-pick of commit 620a2b73b22df66ed099e1faacac2d92f48252b7
from branch 'libpng18'.
2024-10-17 14:18:52 +03:00
John Bowler
d7d950e8bd [libpng16] chore: Clean up the leading blank lines from all source files
The leading blank lines are apparently an artefact of an older source
control system.  They are not required and they look like accidents,
because starting a source file with a blank line is not a regular habit
of software developers nowadays.

This is a cherry-pick of commit 37cc20add8fb5b83bb5299a26cd3b41e0f776017
from branch 'libpng18'.

Signed-off-by: John Bowler <jbowler@acm.org>
Signed-off-by: Cosmin Truta <ctruta@gmail.com>
2024-10-11 11:51:04 +03:00
Cosmin Truta
27e548af25 chore: Clean up the return statements and update example.c accordingly 2024-01-23 21:25:03 +02:00
Cosmin Truta
689e06516b Clean up vestigial uses of png_size_tp 2022-11-20 17:51:33 +02: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
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
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
68cb0aaee3 [libpng16] Implement eXIf chunk support 2017-07-13 11:22:48 -05:00
Glenn Randers-Pehrson
5aaf6e889c [libpng16] Imported from libpng-1.6.30beta04.tar 2017-06-06 19:38:17 -05:00
Glenn Randers-Pehrson
c548328904 [libpng16] Avoid writing an empty IDAT when the last IDAT exactly fills the
compression buffer (bug report by Brian Baird).  This bug was introduced in
libpng-1.6.0.
2017-06-06 18:40:45 -05:00
Glenn Randers-Pehrson
f604c74a5f [libpng16] Avoid conditional directives that break statements in pngrutil.c (Romero
Malaquias)
2017-01-20 14:46:21 -06:00
Romero B. de S. Malaquias
c3f4e5fb1a Avoiding conditional directives that break statements 2017-01-20 16:31:54 -03:00
Glenn Randers-Pehrson
0c440812db [libpng16] Imported from libpng-1.6.26.tar 2016-10-19 19:11:38 -05:00
Glenn Randers-Pehrson
565a751ca2 [libpng16] Quieted (bogus?) clang warnings about "absolute value has no effect". 2016-10-02 20:16:36 -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
Glenn Randers-Pehrson
1b363fa6b0 [libpng16] Quieted 116 (out of 288) -Wconversion compiler warnings by changing
flag definitions in pngpriv.h from 0xnnnn to 0xnnnnU and trivial changes
in png.c, pngread.c, and pngwutil.c.
2016-09-30 17:19:12 -05:00
Glenn Randers-Pehrson
217546ae43 [libpng16] Imported from libpng-1.6.26beta01.tar 2016-09-26 08:57:44 -05: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
Glenn Randers-Pehrson
5d7c7d5132 [libpng16] Fixed a harmless typo in pngwutil.c 2016-07-13 14:45:10 -05:00
Glenn Randers-Pehrson
f7d5419816 [libpng16] Avoid filter-selection heuristic sum calculations in cases where
only one filter is a candidate for selection. This trades off code size (added
png_setup_*_row_only() functions) for speed.
2016-07-08 10:09:25 -05:00
Glenn Randers-Pehrson
d9779744f9 [libpng16] Optimized absolute value calculation in filter selection, similar to
code in the PAETH decoder in pngrutil.c. Build with PNG_USE_ABS to use this.
2016-06-29 21:53:57 -05:00
Glenn Randers-Pehrson
3f2879bf60 [libpng16] Imported from libpng-1.6.24beta02.tar 2016-06-23 11:26:59 -05:00
Glenn Randers-Pehrson
4b4a9583b4 [libpng16] Imported from libpng-1.6.24beta02.tar 2016-06-23 11:08:06 -05:00
John Bowler
1df0ace0b4 Fix MSVC Level 2 warning
MSVC doesn't like '-(unsigned)', so replace it by 0U-(unsigned) (in 1.6).

Signed-off-by: John Bowler <jbowler@acm.org>
2016-06-22 17:35:49 -07:00
Glenn Randers-Pehrson
147dc568da [libpng16] Backed out previous optimization; the compiler should handle that. 2016-06-19 22:20:52 -05:00
Glenn Randers-Pehrson
29135161d7 [libpng16] Avoid filter-selection heuristic sum calculations in cases where
only one filter is a candidate for selection. This trades off code size (added
png_setup_*_row_only() functions) for speed.
2016-06-19 18:43:35 -05:00
John Bowler
9c04f57cab [libpng15] Corrected filter heuristic overflow handling. 2016-06-19 18:01:33 -05:00
Glenn Randers-Pehrson
ac43a87820 [libpng16] Imported from libpng-1.6.22.tar 2016-05-26 07:25:14 -05:00
Glenn Randers-Pehrson
1a3fa1e091 [libpng16] Imported from libpng-1.6.22beta03.tar 2016-03-09 12:04:40 -06:00
Glenn Randers-Pehrson
baf301d122 [libpng16] Restored "& 0xff" in png_save_uint_16() and png_save_uint_32() that
were accidentally removed from libpng-1.6.17.
2016-02-13 12:01:35 -06:00
Glenn Randers-Pehrson
5031c77d85 [libpng16] Bump version to 1.6.22beta01 2016-01-16 08:00:09 -06:00
Glenn Randers-Pehrson
fc0786a442 [libpng16] Imported from libpng-1.6.21.tar 2016-01-15 13:51:06 -06:00
Glenn Randers-Pehrson
66db757dd4 [libpng16] Happy 2016! Updated copyright year 2016-01-02 13:40:27 -06:00
Glenn Randers-Pehrson
975cbbb029 [libpng16] Moved png_check_keyword() from pngwutil.c to pngset.c 2015-12-13 15:04:18 -06:00
Glenn Randers-Pehrson
92ec30a3b1 [libpng16] Imported from libpng-1.6.20beta03.tar 2015-11-24 09:34:02 -06:00
Glenn Randers-Pehrson
415d26805a [libpng16] Imported from libpng-1.6.19.tar 2015-11-12 07:13:31 -06:00