4449 Commits

Author SHA1 Message Date
Cosmin Truta
cf59edd364 Bump version to 1.6.51.git 2025-07-02 20:24:24 +03:00
Cosmin Truta
2b978915d8 Release libpng version 1.6.50 v1.6.50 2025-07-01 23:50:00 +03:00
Cosmin Truta
254a64ec30 doc: Update the man pages to the final PNG-3 specification
Also make editorial changes regarding the previous PNG specifications.
2025-07-01 22:57:36 +03:00
Cosmin Truta
9eb25bd899 chore: Rerun ./autogen.sh --maintainer 2025-06-30 23:46:32 +03:00
Cosmin Truta
8087a21d0a build: Fix the CMake file for cross-platform builds that require libm
Detect the availability of `libm` on the target platform.
Previously, `libm` was detected on the host platform only.

Also introduce the variable `PNG_LINK_LIBRARIES`.
Stop using `M_LIBRARY`, which was not namespace-clean.
2025-06-30 22:27:17 +03:00
John Bowler
2e5f296bfa fix: Prevent unknown chunks from causing out-of-place IEND errors
PNG_AFTER_IDAT was not set by the IDAT read code if unknown chunk
handling was turned on.  This was hidden in the current tests by checks
within the text handling chunks. (For example, pngtest.png has a zTXt
chunk after IDAT.)

This change modifies both the sequential and the progressive reader to
reliably set PNG_AFTER_IDAT when the first non-IDAT chunk is seen and
before that chunk is processed.

The change is minimalist; PNG_HAVE_CHUNK_AFTER_IDAT can probably be
removed and replaced with PNG_AFTER_IDAT.  Making the latter change is
something to be considered in libpng2.

Co-authored-by: Cosmin Truta <ctruta@gmail.com>
Signed-off-by: John Bowler <jbowler@acm.org>
Signed-off-by: Cosmin Truta <ctruta@gmail.com>
2025-06-30 16:27:22 +03:00
Filip Wasil
4266c75f40 riscv: Remove unused argument
Signed-off-by: Cosmin Truta <ctruta@gmail.com>
2025-06-28 16:19:11 +03:00
Filip Wasil
f451a4de09 riscv: Simplify the runtime check to always be present
Signed-off-by: Cosmin Truta <ctruta@gmail.com>
2025-06-28 16:19:11 +03:00
Filip Wasil
6aa47debba riscv: Do not overwrite -march when testing against SIMD availability
Signed-off-by: Cosmin Truta <ctruta@gmail.com>
2025-06-28 16:19:11 +03:00
Filip Wasil
3391bb98e3 riscv: Use C intrinsics
Signed-off-by: Cosmin Truta <ctruta@gmail.com>
2025-06-28 16:19:11 +03:00
Filip Wasil
21895b05ab riscv: Clearly separate the build flow for autotools and cmake
Signed-off-by: Cosmin Truta <ctruta@gmail.com>
2025-06-18 14:43:36 +03:00
Cosmin Truta
be81ebe1a4 chore: Rerun ./autogen.sh --maintainer 2025-06-17 11:41:32 +03:00
Filip Wasil
edf46621f3 riscv: Improve the RVV availability check
In some cases, the vector extension is not supported, although the
compiler allows the "v" flag in `-march` and includes `<riscv_vector>`
without raising an error.

Signed-off-by: Cosmin Truta <ctruta@gmail.com>
2025-06-17 11:40:57 +03:00
Cosmin Truta
5dc5937b30 chore: Update .gitignore
This is a cherry-pick of commit df3b9173277aae60b08a216dc23484f6ec171ef5
from branch 'libpng18'.
2025-06-14 18:35:46 +03:00
Cosmin Truta
7084241c75 Bump version to 1.6.50.git 2025-06-14 17:13:02 +03:00
Cosmin Truta
640204280f Release libpng version 1.6.49 v1.6.49 2025-06-12 20:05:46 +03:00
Cosmin Truta
740366c32b doc: Update the png.5 man page to the latest PNG-3 draft 2025-06-12 19:58:06 +03:00
Cosmin Truta
5d53dfd20c chore: Rerun ./autogen.sh --maintainer 2025-06-12 18:46:04 +03:00
Filip Wasil
5b62726ced riscv: Fix autodetection of RVV support
Signed-off-by: Cosmin Truta <ctruta@gmail.com>
2025-06-12 18:44:02 +03:00
Cosmin Truta
a5830bfcb1 build: Fix the detection of the math library in the CMake file
This is a fix of commit 5631b9b952e6940c67d4b48c00882e99229aa31b
"build: Implement various improvements to the CMake file"
2025-06-11 21:38:01 +03:00
Cosmin Truta
3bca02e274 examples: Refactor and reformat using clang-format
Add contrib/examples/.clang-format, tailored to fit the existing code
as closely as possible. The end goal is to set up automatic formatting
for the entire libpng source tree. We're doing this experiment in this
subdirectory, for now.

Also make refactoring changes, as follows:

 * Rewrite the preprocessor checks `#if PNG_FOO_SUPPORTED` to stop
   compilation immediately, with a descriptive `#error` about what
   needs to be supported.

 * Rewrite and reflow comments, add braces and brackets, and make other
   minor modifications that are suited for the clang-format'ed code.
2025-06-01 22:40:38 +03:00
Sanjay Jangid
197bbfe0d5 examples: Fix file descriptor leak in iccfrompng.c by closing input file
Reviewed-by: Cosmin Truta <ctruta@gmail.com>
Signed-off-by: Cosmin Truta <ctruta@gmail.com>
2025-05-31 17:06:28 +03:00
Cosmin Truta
0cc6436ef5 build: Repair and reduce the CMake build dependency graph
A funny thing happened while refactoring the function argument parsing
in the `PNGGenConfig` module: the processing of dependencies inside
the CMake function `generate_copy` got fixed, thanks to an inadvertent
typo correction!

Going down the rabbit hole, we uncovered two issues:

 1. A typo in `scripts/cmake/PNGGenConfig.cmake` caused a dependency
    declaration to disappear, disrupting the graph. Fortunately, this
    disruption was being mitigated by an additional set of (redundant)
    symbolic target declarations that kept the CMake build going.

 2. The exact string matching inside `scripts/cmake/gensrc.cmake.in`
    imposed an artificial limitation, disallowing the use of absolute
    file paths.

The typo correction in (1), and the use of regex matching instead of
exact string matching in (2), allowed us to use absolute file paths
in the main CMake file, consistently, thus allowing CMake to recognize
them as uniquely-identifiable nodes in the dependency graph. There
should be no further need to have extra symbolic targets for proper
node identification.

In the end, we shaved off the redundant symbolic target declarations,
retaining only `png_genfiles` and `png_genprebuilt`.
2025-05-29 22:55:00 +03:00
Cosmin Truta
f04c457a51 build: Remove the PNG_DEBUG option from CMake files and project files
Counter-intuitively, defining the PNG_DEBUG macro as 1 (i.e. setting
the debug verbosity level to 1) does *not* cause any of the existing
debug traces to show up. This setting would have worked if we had trace
statements like `png_debug(0, message)`, but we don't have any.

Debug traces do show up for verbosity levels from 2 to 5. The libpng
manual describes in detail how they are meant to be used.

According to the history of the CMake file, as well as the history of
other project files, PNG_DEBUG was never set to a numeric value larger
than 1. In other words, these debug settings inside these build files
never produced any output in any (unmodified) libpng version.

(As for the configure build, PNG_DEBUG has no special treatment there.)

Considering the plethora of alternative methods to pass C preprocessor
options through our build files, scripts and projects onto libpng, we'd
rather discontinue PNG_DEBUG as a dedicated build option.
2025-05-29 19:47:03 +03:00
Cosmin Truta
5631b9b952 build: Implement various improvements to the CMake file
Allow the CMake build to work properly, even if file paths (in the
source directory, in the build directory, or in the install directory)
might contain whitespace characters.

Improve the check for compilers that might use MSVC Runtime library
headers on Windows. We use POSIX-ish ("deprecated") functions, even
on Windows, and we want no spurious warnings.

Tidy up the CMake file: rearrange declarations, rewrite comments, etc.
2025-05-29 18:28:16 +03:00
Joost Nieuwenhuijse
dc71f481ff build: Fix apple-non-apple cross building
When cross compiling for an apple platform on a non-apple platform
(or the reverse), `if(APPLE)` in line 32 should refer to the target
platform. Without importing the `APPLE` variable, it refers to the
host platform.

Reviewed-by: John Bowler <jbowler@acm.org>
Signed-off-by: Cosmin Truta <ctruta@gmail.com>
2025-05-28 17:24:21 +03:00
Cosmin Truta
e2c1579816 ci: Add action-editorconfig-checker to the GitHub Action for linting
The editorconfig-checker program is not installed by default in the OS
used by GitHub Actions. Fortunately, the editorconfig-checker authors
have kindly provided the action-editorconfig-checker repository, which
we are now using.
2025-05-28 11:02:47 +03:00
Cosmin Truta
cff8620272 chore: Add riscv/.editorconfig and pacify editorconfig-checker
Also tidy up the new RISC-V code to comply with our coding style,
and rearrange comments inside png.h to improve readability within
the configured editing limits.
2025-05-27 11:28:56 +03:00
Cosmin Truta
5be32eb35c chore: Rerun ./autogen.sh --maintainer 2025-05-26 22:37:06 +03:00
Filip Wasil
611bf1016c riscv: autotools update 2025-05-19 15:58:44 +02:00
Filip Wasil
0e37c0b477 riscv: Fix more comments
Signed-off-by: Cosmin Truta <ctruta@gmail.com>
2025-05-14 22:35:47 +03:00
Filip Wasil
7108843467 riscv: Fix the run-time checking of the RVV availability
Signed-off-by: Cosmin Truta <ctruta@gmail.com>
2025-05-14 10:24:58 +03:00
Filip Wasil
2b0eb78656 riscv: Fix autotools definitions and comments
Signed-off-by: Cosmin Truta <ctruta@gmail.com>
2025-05-14 10:24:58 +03:00
Filip Wasil
ffb8e8b26f Fix and improve the RISC-V Vector (RVV) implementation
Changes include manually merged code from Manfred SCHLAEGL.

Co-authored-by: Manfred SCHLAEGL <manfred.schlaegl@gmx.at>
Signed-off-by: Cosmin Truta <ctruta@gmail.com>
2025-05-01 17:44:00 +03:00
Dragoș Tiselice
cc5ee6b213 Add optimized RISC-V Vector functions
Largely based off of the ARM NEON implementation.

Signed-off-by: Cosmin Truta <ctruta@gmail.com>
2025-05-01 17:44:00 +03:00
Cosmin Truta
b4800bae33 Bump version to 1.6.49.git 2025-05-01 14:50:23 +03:00
Cosmin Truta
ea12796820 Release libpng version 1.6.48 v1.6.48 2025-04-30 16:51:46 +03:00
Cosmin Truta
643dbda7d6 doc: Update the png.5 man page to the latest PNG-3 draft specification
Also update libpngpf.3 to explicitly state that the internal functions
should not be used by applications.
2025-04-30 16:30:24 +03:00
Cosmin Truta
34e3f7a65b Remove the config for Travis CI (and thank them for their support!)
Signed-off-by: Cosmin Truta <ctruta@gmail.com>
2025-04-30 11:49:37 +03:00
Cosmin Truta
3e67531078 chore: Add a TODO note in .cmake-format.yaml; reformat CMakeLists.txt
Apply some (but not all) of the suggestions made by the cmake-format
program. Meanwhile, the cmake-lint program is (still) happy.
2025-04-29 17:30:30 +03:00
Cosmin Truta
23bdc7a6c4 build: Add the CMake build option PNG_LIBCONF_HEADER
Running the pnglibconf scripts (script/*.awk) is not always possible.
An AWK interpreter is not always guaranteed to be available; and even
if it is, there are limitations when making cross-platform libpng
builds, especially when the differences between the host platform and
the target platform are significant. For example:
 * Building for the Windows (MinGW) target on a Unix development host;
 * Building for the iOS target on a macOS development host;
 * Building for the Android target on any development host.

In such scenarios, a preconfigured (i.e. prebuilt) pnglibconf.h file,
either taken from the libpng source tree or provided by the user who
wants to make a custom libpng build, becomes a necessity.

In this commit we introduce the build option `PNG_LIBCONF_HEADER` in
order to address this specific use case.

We also specify a version range (3.14...4.0) for the minimum required
CMake program, to future-proof the CMake build for just a little bit
longer.

Signed-off-by: Cosmin Truta <ctruta@gmail.com>
2025-04-28 20:44:53 +03:00
Cosmin Truta
69a3e5bfd1 chore: Clean up the error directives
Make the error directives uniformly consistent with one another.
Remove surrounding quotes and trailing punctuation, and rephrase
some of the error messages and some of their associated comments
for either brevity or clarity.
2025-04-25 16:19:30 +03:00
Cosmin Truta
c90491724e Discourage the inclusion of private headers outside libpng
Add checks inside the private png*.h header files, in order to reduce
unintentional occurences of application backdoors.

Such backdoors might occur, for example, when we make changes to the
internal data structures that might somehow "leak" from the libpng
code into the user code. The applications that use the libpng API must
pretend not to know that these headers exist at all.

Co-authored-by: John Bowler <jbowler@acm.org>
Signed-off-by: John Bowler <jbowler@acm.org>
Signed-off-by: Cosmin Truta <ctruta@gmail.com>
2025-04-25 15:35:11 +03:00
John Bowler
98448e372d Remove unused function from write-only configurations
`png_icc_profile_error` is no longer used when writing iCCP chunks,
therefore it can be compiled out when the reading is disabled.

This change includes two `minconfig` files to test read-only and
write-only "full" configurations, to supplement the existing tests
for "minimal" configurations.

Signed-off-by: John Bowler <jbowler@acm.org>
Signed-off-by: Cosmin Truta <ctruta@gmail.com>
2025-04-22 19:35:01 +03:00
John Bowler
f2b0f5fe1c fix(mDCv): Correct the floating-point setter png_set_mDCv
In the floating-point API function `png_set_mDCv` we incorrectly
divided by two the chromaticity values before passing them on to
`png_set_mDCv_fixed`.

Reported-by: Mohit Bakshi <mohitbakshi2205@gmail.com>
Signed-off-by: John Bowler <jbowler@acm.org>
Signed-off-by: Cosmin Truta <ctruta@gmail.com>
2025-04-22 18:08:39 +03:00
Chris Blume
7101a5569f Correct mistake in example.c 2025-04-22 18:04:46 +03:00
Cosmin Truta
e046c0dc3b Revert "Recover from errors in ancillary chunks"
This reverts commit 34005e3d3d373c0c36898cc55eae48a79c8238a1.

Although I agreed with Lucas Chollet initially, I finally understood
the objection brought forth by John Bowler: "[...] it's not an
ancillary chunk type if it's not a chunk type in the first place."

I feel that more deliberation is needed on what a robust PNG decoder
should do when it stumbles upon a chunk type that fails to meet its
basic requirements. A clarifying recommendation for decoders may or
may not need to be stipulated in the PNG specification as well.

Signed-off-by: Cosmin Truta <ctruta@gmail.com>
2025-04-22 16:39:01 +03:00
Lucas CHOLLET
34005e3d3d Recover from errors in ancillary chunks
As per the third edition of the spec, decoders should recover from
errors in ancillary chunks.

In section 13.1 Error handling [1]:
> Anomalous situations other than syntax errors shall be treated as
> follows:
>  1. Encountering an unknown ancillary chunk is never an error. The
>     chunk can simply be ignored.

More specifically, in this commit, if a chunk that is detected as
ancillary, does not pass the `check_chunk_name()` function, only a
_benign_ is issued, instead of an error.

This allows libpng to fully decode images like [2] and [3]. It has been
tested by passing them to both pngtest and Gnome's image viewer. Note
that invalid-unknown-ancillary-after-IDAT.png could already be displayed
but not fully decoded.

[1] https://w3c.github.io/png/#13Decoders.Errors
[2] https://github.com/web-platform-tests/wpt/blob/master/png/errors/support/invalid-unknown-ancillary.png
[3] https://github.com/web-platform-tests/wpt/blob/master/png/errors/support/invalid-unknown-ancillary-after-IDAT.png
2025-03-04 15:13:19 -07:00
Cosmin Truta
44f97f08d7 [libpng18] chore: Clean up the FILE * formulations in code and in documentation
We should use `FILE *` instead of `FILE*` or `(FILE*)`, consistently,
as we should for all other pointer types. Moreover, when we refer to
standard stdio file objects in comments and in documentation, we should
use the term "FILE objects" consistently.

Lastly, we clarify in a comment in example.c that `PNG_STDIO_SUPPORTED`
is true only when the stdio support is both available in the system and
accessible in the user's libpng build.

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

Reviewed-by: John Bowler <jbowler@acm.org>
Signed-off-by: Cosmin Truta <ctruta@gmail.com>
2025-02-26 19:46:08 +02:00
Cosmin Truta
044536de92 [libpng18] chore: Clean up remnants of the long-discontinued Win16 support
Remove #ifdef sections and other workarounds for old Windows compilers
that lacked proper support for Win32, including, especially, support
for the Win32 stdio API.

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

Reviewed-by: John Bowler <jbowler@acm.org>
Signed-off-by: Cosmin Truta <ctruta@gmail.com>
2025-02-26 19:42:28 +02:00