summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAkira Kakuto <kakuto@fuk.kindai.ac.jp>2024-01-26 03:44:51 +0000
committerAkira Kakuto <kakuto@fuk.kindai.ac.jp>2024-01-26 03:44:51 +0000
commit3cedc5fd080731a3cd2c47e2f40fc140bba1accb (patch)
treee0530823f7d1ae5e33f4aeb5b5a6e8f873a1ad68
parentc5b2b6fde7be60e4ef155aa1f6bef99621e26efc (diff)
libpng 1.6.41
git-svn-id: svn://tug.org/texlive/trunk@69596 c570f23f-e606-0410-a88d-b1316a301751
-rw-r--r--Build/source/libs/README2
-rw-r--r--Build/source/libs/libpng/ChangeLog5
-rw-r--r--Build/source/libs/libpng/README4
-rw-r--r--Build/source/libs/libpng/TLpatches/ChangeLog4
-rw-r--r--Build/source/libs/libpng/TLpatches/TL-Changes5
-rwxr-xr-xBuild/source/libs/libpng/configure20
-rw-r--r--Build/source/libs/libpng/libpng-src/ANNOUNCE50
-rw-r--r--Build/source/libs/libpng/libpng-src/AUTHORS30
-rw-r--r--Build/source/libs/libpng/libpng-src/CHANGES32
-rw-r--r--Build/source/libs/libpng/libpng-src/CMakeLists.txt421
-rw-r--r--Build/source/libs/libpng/libpng-src/LICENSE4
-rw-r--r--Build/source/libs/libpng/libpng-src/Makefile.am46
-rw-r--r--Build/source/libs/libpng/libpng-src/README2
-rwxr-xr-xBuild/source/libs/libpng/libpng-src/autogen.sh5
-rw-r--r--Build/source/libs/libpng/libpng-src/ci/.shellcheckrc11
-rw-r--r--Build/source/libs/libpng/libpng-src/ci/LICENSE_MIT.txt19
-rw-r--r--Build/source/libs/libpng/libpng-src/ci/ci_lint_ci.sh88
-rw-r--r--Build/source/libs/libpng/libpng-src/ci/ci_verify_cmake.sh156
-rw-r--r--Build/source/libs/libpng/libpng-src/ci/ci_verify_configure.sh140
-rw-r--r--Build/source/libs/libpng/libpng-src/ci/ci_verify_makefiles.sh99
-rw-r--r--Build/source/libs/libpng/libpng-src/ci/lib/ci.lib.sh90
-rw-r--r--Build/source/libs/libpng/libpng-src/config.h.in24
-rw-r--r--Build/source/libs/libpng/libpng-src/configure.ac150
-rw-r--r--Build/source/libs/libpng/libpng-src/contrib/mips-mmi/linux.c142
-rw-r--r--Build/source/libs/libpng/libpng-src/contrib/mips-msa/linux.c58
-rw-r--r--Build/source/libs/libpng/libpng-src/contrib/pngminus/.gitignore11
-rw-r--r--Build/source/libs/libpng/libpng-src/contrib/pngminus/CHANGES.txt3
-rw-r--r--Build/source/libs/libpng/libpng-src/contrib/pngminus/CMakeLists.txt53
-rw-r--r--Build/source/libs/libpng/libpng-src/contrib/pngminus/png2pnm.c222
-rw-r--r--Build/source/libs/libpng/libpng-src/contrib/pngminus/pnm2png.c503
-rw-r--r--Build/source/libs/libpng/libpng-src/contrib/pngminus/test_png2pnm.bat (renamed from Build/source/libs/libpng/libpng-src/contrib/pngminus/png2pnm.bat)0
-rw-r--r--[-rwxr-xr-x]Build/source/libs/libpng/libpng-src/contrib/pngminus/test_png2pnm.sh (renamed from Build/source/libs/libpng/libpng-src/contrib/pngminus/png2pnm.sh)0
-rw-r--r--Build/source/libs/libpng/libpng-src/contrib/pngminus/test_pngminus.bat (renamed from Build/source/libs/libpng/libpng-src/contrib/pngminus/pngminus.bat)0
-rw-r--r--[-rwxr-xr-x]Build/source/libs/libpng/libpng-src/contrib/pngminus/test_pngminus.sh (renamed from Build/source/libs/libpng/libpng-src/contrib/pngminus/pngminus.sh)0
-rw-r--r--Build/source/libs/libpng/libpng-src/contrib/pngminus/test_pnm2png.bat (renamed from Build/source/libs/libpng/libpng-src/contrib/pngminus/pnm2png.bat)0
-rw-r--r--[-rwxr-xr-x]Build/source/libs/libpng/libpng-src/contrib/pngminus/test_pnm2png.sh (renamed from Build/source/libs/libpng/libpng-src/contrib/pngminus/pnm2png.sh)0
-rw-r--r--Build/source/libs/libpng/libpng-src/contrib/testpngs/badpal/regression-palette-8.pngbin0 -> 1033 bytes
-rw-r--r--Build/source/libs/libpng/libpng-src/contrib/testpngs/badpal/small-palette-1.pngbin0 -> 271 bytes
-rw-r--r--Build/source/libs/libpng/libpng-src/contrib/testpngs/badpal/small-palette-2.pngbin0 -> 277 bytes
-rw-r--r--Build/source/libs/libpng/libpng-src/contrib/testpngs/badpal/small-palette-4.pngbin0 -> 315 bytes
-rw-r--r--Build/source/libs/libpng/libpng-src/contrib/testpngs/badpal/small-palette-8.pngbin0 -> 1035 bytes
-rw-r--r--Build/source/libs/libpng/libpng-src/contrib/testpngs/badpal/test-palette-1.pngbin0 -> 432 bytes
-rw-r--r--Build/source/libs/libpng/libpng-src/contrib/testpngs/badpal/test-palette-2.pngbin0 -> 499 bytes
-rw-r--r--Build/source/libs/libpng/libpng-src/contrib/testpngs/badpal/test-palette-4.pngbin0 -> 591 bytes
-rw-r--r--Build/source/libs/libpng/libpng-src/contrib/testpngs/badpal/test-palette-8.pngbin0 -> 2728 bytes
-rwxr-xr-xBuild/source/libs/libpng/libpng-src/contrib/testpngs/makepngs.sh2
-rwxr-xr-xBuild/source/libs/libpng/libpng-src/contrib/tools/intgamma.sh2
-rw-r--r--Build/source/libs/libpng/libpng-src/contrib/tools/pngcp.c32
-rw-r--r--Build/source/libs/libpng/libpng-src/contrib/tools/pngfix.c38
-rw-r--r--Build/source/libs/libpng/libpng-src/example.c38
-rw-r--r--Build/source/libs/libpng/libpng-src/libpng-manual.txt6
-rw-r--r--Build/source/libs/libpng/libpng-src/libpng.310
-rw-r--r--Build/source/libs/libpng/libpng-src/libpngpf.34
-rw-r--r--Build/source/libs/libpng/libpng-src/loongarch/filter_lsx_intrinsics.c412
-rw-r--r--Build/source/libs/libpng/libpng-src/loongarch/loongarch_lsx_init.c65
-rw-r--r--Build/source/libs/libpng/libpng-src/mips/filter_mmi_inline_assembly.c525
-rw-r--r--Build/source/libs/libpng/libpng-src/mips/filter_msa_intrinsics.c14
-rw-r--r--Build/source/libs/libpng/libpng-src/mips/mips_init.c86
-rw-r--r--Build/source/libs/libpng/libpng-src/png.52
-rw-r--r--Build/source/libs/libpng/libpng-src/png.c73
-rw-r--r--Build/source/libs/libpng/libpng-src/png.h50
-rw-r--r--Build/source/libs/libpng/libpng-src/pngconf.h4
-rw-r--r--Build/source/libs/libpng/libpng-src/pngerror.c34
-rw-r--r--Build/source/libs/libpng/libpng-src/pngget.c245
-rw-r--r--Build/source/libs/libpng/libpng-src/pnglibconf.h9
-rw-r--r--Build/source/libs/libpng/libpng-src/pngpread.c8
-rw-r--r--Build/source/libs/libpng/libpng-src/pngpriv.h110
-rw-r--r--Build/source/libs/libpng/libpng-src/pngread.c8
-rw-r--r--Build/source/libs/libpng/libpng-src/pngrtran.c6
-rw-r--r--Build/source/libs/libpng/libpng-src/pngrutil.c19
-rw-r--r--Build/source/libs/libpng/libpng-src/pngset.c22
-rw-r--r--Build/source/libs/libpng/libpng-src/pngtest.c64
-rw-r--r--Build/source/libs/libpng/libpng-src/pngtrans.c14
-rw-r--r--Build/source/libs/libpng/libpng-src/pngwrite.c19
-rw-r--r--Build/source/libs/libpng/libpng-src/pngwutil.c10
-rw-r--r--Build/source/libs/libpng/libpng-src/scripts/autoconf/README.md7
-rw-r--r--Build/source/libs/libpng/libpng-src/scripts/autoconf/libtool.m4 (renamed from Build/source/libs/libpng/libpng-src/scripts/libtool.m4)0
-rw-r--r--Build/source/libs/libpng/libpng-src/scripts/autoconf/ltoptions.m4 (renamed from Build/source/libs/libpng/libpng-src/scripts/ltoptions.m4)0
-rw-r--r--Build/source/libs/libpng/libpng-src/scripts/autoconf/ltsugar.m4 (renamed from Build/source/libs/libpng/libpng-src/scripts/ltsugar.m4)0
-rw-r--r--Build/source/libs/libpng/libpng-src/scripts/autoconf/ltversion.m4 (renamed from Build/source/libs/libpng/libpng-src/scripts/ltversion.m4)0
-rw-r--r--Build/source/libs/libpng/libpng-src/scripts/autoconf/lt~obsolete.m4 (renamed from Build/source/libs/libpng/libpng-src/scripts/lt~obsolete.m4)0
-rw-r--r--Build/source/libs/libpng/libpng-src/scripts/cmake/AUTHORS.md35
-rw-r--r--Build/source/libs/libpng/libpng-src/scripts/cmake/README.md35
-rw-r--r--Build/source/libs/libpng/libpng-src/scripts/cmake/genchk.cmake.in (renamed from Build/source/libs/libpng/libpng-src/scripts/genchk.cmake.in)16
-rw-r--r--Build/source/libs/libpng/libpng-src/scripts/cmake/genout.cmake.in (renamed from Build/source/libs/libpng/libpng-src/scripts/genout.cmake.in)16
-rw-r--r--Build/source/libs/libpng/libpng-src/scripts/cmake/gensrc.cmake.in (renamed from Build/source/libs/libpng/libpng-src/scripts/gensrc.cmake.in)26
-rw-r--r--Build/source/libs/libpng/libpng-src/scripts/cmake/test.cmake.in (renamed from Build/source/libs/libpng/libpng-src/scripts/test.cmake.in)17
-rw-r--r--Build/source/libs/libpng/libpng-src/scripts/libpng-config-head.in2
-rw-r--r--Build/source/libs/libpng/libpng-src/scripts/libpng.pc.in2
-rw-r--r--Build/source/libs/libpng/libpng-src/scripts/pnglibconf.dfa79
-rw-r--r--Build/source/libs/libpng/libpng-src/scripts/pnglibconf.h.prebuilt9
-rw-r--r--Build/source/libs/libpng/libpng-src/tests/pngtest-all99
-rw-r--r--Build/source/libs/libpng/version.ac2
93 files changed, 3374 insertions, 1301 deletions
diff --git a/Build/source/libs/README b/Build/source/libs/README
index 0b2bed987c5..e3ca06995fb 100644
--- a/Build/source/libs/README
+++ b/Build/source/libs/README
@@ -37,7 +37,7 @@ icu 74.2 - checked 22dec23
libpaper 1.1.29 - checked 07jan24
https://ftp.debian.org/debian/pool/main/libp/libpaper/
-libpng 1.6.40 - checked 22jun23
+libpng 1.6.41 - checked 26jan24
https://sourceforge.net/projects/libpng/files/ - used by many
lua 5.2.4
diff --git a/Build/source/libs/libpng/ChangeLog b/Build/source/libs/libpng/ChangeLog
index 785886a5c39..836e6228b79 100644
--- a/Build/source/libs/libpng/ChangeLog
+++ b/Build/source/libs/libpng/ChangeLog
@@ -1,3 +1,8 @@
+2024-01-26 Akira Kakuto <kakuto@jcom.zaq.ne.jp>
+
+ Import libpng-1.6.41.
+ * version.ac: Adjust.
+
2023-06-22 Akira Kakuto <kakuto@jcom.zaq.ne.jp>
Import libpng-1.6.40.
diff --git a/Build/source/libs/libpng/README b/Build/source/libs/libpng/README
index 66265a5c9ab..653c0a5bbf6 100644
--- a/Build/source/libs/libpng/README
+++ b/Build/source/libs/libpng/README
@@ -1,4 +1,4 @@
- Building libpng-1.6.40 as part of the TL tree
+ Building libpng-1.6.41 as part of the TL tree
=============================================
This directory libs/libpng/ uses a proxy Makefile.am to build the libpng library
@@ -14,4 +14,4 @@ copied to libs/libpng/configure.ac.
=============================
2009-07-23 Peter Breitenlohner <peb@mppmu.mpg.de>
-2023-06-22 Akira Kakuto <kakuto@jcom.zaq.ne.jp>
+2024-01-26 Akira Kakuto <kakuto@jcom.zaq.ne.jp>
diff --git a/Build/source/libs/libpng/TLpatches/ChangeLog b/Build/source/libs/libpng/TLpatches/ChangeLog
index 2234b2f77d9..e54ee2828c9 100644
--- a/Build/source/libs/libpng/TLpatches/ChangeLog
+++ b/Build/source/libs/libpng/TLpatches/ChangeLog
@@ -1,3 +1,7 @@
+2024-01-26 Akira Kakuto <kakuto@jcom.zaq.ne.jp>
+
+ Import libpng-1.6.41.
+
2023-06-22 Akira Kakuto <kakuto@jcom.zaq.ne.jp>
Import libpng-1.6.40.
diff --git a/Build/source/libs/libpng/TLpatches/TL-Changes b/Build/source/libs/libpng/TLpatches/TL-Changes
index 652780ea971..cceb5667d3f 100644
--- a/Build/source/libs/libpng/TLpatches/TL-Changes
+++ b/Build/source/libs/libpng/TLpatches/TL-Changes
@@ -1,5 +1,5 @@
-Changes applied to the libpng-1.6.40/ tree as obtained from:
- https://sourceforge.net/projects/libpng/files/libpng16/1.6.40/
+Changes applied to the libpng-1.6.41/ tree as obtained from:
+ https://sourceforge.net/projects/libpng/files/libpng16/1.6.41/
Copied:
scripts/pnglibconf.h.prebuilt -> pnglibconf.h
@@ -8,6 +8,7 @@ Removed:
.appveyor.yml
.gitignore
.travis.yml
+ .yamllint.yml
Makefile.in
aclocal.m4
compile
diff --git a/Build/source/libs/libpng/configure b/Build/source/libs/libpng/configure
index dbcdb6482c2..68978e46a52 100755
--- a/Build/source/libs/libpng/configure
+++ b/Build/source/libs/libpng/configure
@@ -1,6 +1,6 @@
#! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.72 for libpng (TeX Live) 1.6.40.
+# Generated by GNU Autoconf 2.72 for libpng (TeX Live) 1.6.41.
#
# Report bugs to <tex-k@tug.org>.
#
@@ -604,8 +604,8 @@ MAKEFLAGS=
# Identity of this package.
PACKAGE_NAME='libpng (TeX Live)'
PACKAGE_TARNAME='libpng--tex-live-'
-PACKAGE_VERSION='1.6.40'
-PACKAGE_STRING='libpng (TeX Live) 1.6.40'
+PACKAGE_VERSION='1.6.41'
+PACKAGE_STRING='libpng (TeX Live) 1.6.41'
PACKAGE_BUGREPORT='tex-k@tug.org'
PACKAGE_URL=''
@@ -1338,7 +1338,7 @@ if test "$ac_init_help" = "long"; then
# Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF
-'configure' configures libpng (TeX Live) 1.6.40 to adapt to many kinds of systems.
+'configure' configures libpng (TeX Live) 1.6.41 to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]...
@@ -1410,7 +1410,7 @@ fi
if test -n "$ac_init_help"; then
case $ac_init_help in
- short | recursive ) echo "Configuration of libpng (TeX Live) 1.6.40:";;
+ short | recursive ) echo "Configuration of libpng (TeX Live) 1.6.41:";;
esac
cat <<\_ACEOF
@@ -1530,7 +1530,7 @@ fi
test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then
cat <<\_ACEOF
-libpng (TeX Live) configure 1.6.40
+libpng (TeX Live) configure 1.6.41
generated by GNU Autoconf 2.72
Copyright (C) 2023 Free Software Foundation, Inc.
@@ -1857,7 +1857,7 @@ cat >config.log <<_ACEOF
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
-It was created by libpng (TeX Live) $as_me 1.6.40, which was
+It was created by libpng (TeX Live) $as_me 1.6.41, which was
generated by GNU Autoconf 2.72. Invocation command line was
$ $0$ac_configure_args_raw
@@ -4456,7 +4456,7 @@ fi
# Define the identity of the package.
PACKAGE='libpng--tex-live-'
- VERSION='1.6.40'
+ VERSION='1.6.41'
printf "%s\n" "#define PACKAGE \"$PACKAGE\"" >>confdefs.h
@@ -7474,7 +7474,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
# report actual input values of CONFIG_FILES etc. instead of their
# values after options handling.
ac_log="
-This file was extended by libpng (TeX Live) $as_me 1.6.40, which was
+This file was extended by libpng (TeX Live) $as_me 1.6.41, which was
generated by GNU Autoconf 2.72. Invocation command line was
CONFIG_FILES = $CONFIG_FILES
@@ -7542,7 +7542,7 @@ ac_cs_config_escaped=`printf "%s\n" "$ac_cs_config" | sed "s/^ //; s/'/'\\\\\\\\
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
ac_cs_config='$ac_cs_config_escaped'
ac_cs_version="\\
-libpng (TeX Live) config.status 1.6.40
+libpng (TeX Live) config.status 1.6.41
configured by $0, generated by GNU Autoconf 2.72,
with options \\"\$ac_cs_config\\"
diff --git a/Build/source/libs/libpng/libpng-src/ANNOUNCE b/Build/source/libs/libpng/libpng-src/ANNOUNCE
index 404cbb0de9a..800446b059b 100644
--- a/Build/source/libs/libpng/libpng-src/ANNOUNCE
+++ b/Build/source/libs/libpng/libpng-src/ANNOUNCE
@@ -1,5 +1,5 @@
-libpng 1.6.40 - June 21, 2023
-=============================
+libpng 1.6.41 - January 24, 2024
+================================
This is a public release of libpng, intended for use in production code.
@@ -9,13 +9,13 @@ Files available for download
Source files with LF line endings (for Unix/Linux):
- * libpng-1.6.40.tar.xz (LZMA-compressed, recommended)
- * libpng-1.6.40.tar.gz
+ * libpng-1.6.41.tar.xz (LZMA-compressed, recommended)
+ * libpng-1.6.41.tar.gz (deflate-compressed)
Source files with CRLF line endings (for Windows):
- * lpng1640.7z (LZMA-compressed, recommended)
- * lpng1640.zip
+ * lpng1641.7z (LZMA-compressed, recommended)
+ * lpng1641.zip (deflate-compressed)
Other information:
@@ -25,15 +25,39 @@ Other information:
* TRADEMARK.md
-Changes from version 1.6.39 to version 1.6.40
+Changes from version 1.6.40 to version 1.6.41
---------------------------------------------
- * Fixed the eXIf chunk multiplicity checks.
- * Fixed a memory leak in pCAL processing.
- * Corrected the validity report about tRNS inside png_get_valid().
- * Fixed various build issues on *BSD, Mac and Windows.
- * Updated the configurations and the scripts for continuous integration.
- * Cleaned up the code, the build scripts, and the documentation.
+ * Added SIMD-optimized code for the Loongarch LSX hardware.
+ (Contributed by GuXiWei, JinBo and ZhangLixia)
+ * Fixed the run-time discovery of MIPS MSA hardware.
+ (Contributed by Sui Jingfeng)
+ * Fixed an off-by-one error in the function `png_do_check_palette_indexes`,
+ which failed to recognize errors that might have existed in the first
+ column of a broken palette-encoded image. This was a benign regression
+ accidentally introduced in libpng-1.6.33. No pixel was harmed.
+ (Contributed by Adam Richter; reviewed by John Bowler)
+ * Fixed, improved and modernized the contrib/pngminus programs, i.e.,
+ png2pnm.c and pnm2png.c
+ * Removed old and peculiar portability hacks that were meant to silence
+ warnings issued by gcc version 7.1 alone.
+ (Contributed by John Bowler)
+ * Fixed and modernized the CMake file, and raised the minimum required
+ CMake version from 3.1 to 3.6.
+ (Contributed by Clinton Ingram, Timothy Lyanguzov, Tyler Kropp, et al.)
+ * Allowed the configure script to disable the building of auxiliary tools
+ and tests, thus catching up with the CMake file.
+ (Contributed by Carlo Bramini)
+ * Fixed a build issue on Mac.
+ (Contributed by Zixu Wang)
+ * Moved the Autoconf macro files to scripts/autoconf.
+ * Moved the CMake files (except for the main CMakeLists.txt) to
+ scripts/cmake and moved the list of their contributing authors to
+ scripts/cmake/AUTHORS.md
+ * Updated the CI configurations and scripts.
+ * Relicensed the CI scripts to the MIT License.
+ * Improved the test coverage.
+ (Contributed by John Bowler)
Send comments/corrections/commendations to png-mng-implement at lists.sf.net.
diff --git a/Build/source/libs/libpng/libpng-src/AUTHORS b/Build/source/libs/libpng/libpng-src/AUTHORS
index 60f41e5c651..bf962f6e163 100644
--- a/Build/source/libs/libpng/libpng-src/AUTHORS
+++ b/Build/source/libs/libpng/libpng-src/AUTHORS
@@ -4,6 +4,7 @@ PNG REFERENCE LIBRARY AUTHORS
This is the list of PNG Reference Library ("libpng") Contributing
Authors, for copyright and licensing purposes.
+ * Adam Richter
* Andreas Dilger
* Cosmin Truta
* Dave Martindale
@@ -33,20 +34,27 @@ Authors, for copyright and licensing purposes.
* Vadim Barkov
* Willem van Schaik
* Zhijie Liang
+ * Apple Inc.
+ - Zixu Wang (王子旭)
* Arm Holdings
- - Richard Townsend
+ - Richard Townsend
* Google Inc.
- - Dan Field
- - Leon Scroggins III
- - Matt Sarett
- - Mike Klein
- - Sami Boukortt
- - Wan-Teh Chang
+ - Dan Field
+ - Leon Scroggins III
+ - Matt Sarett
+ - Mike Klein
+ - Sami Boukortt
+ - Wan-Teh Chang
+ * Loongson Technology Corporation Ltd.
+ - GuXiWei (顾希伟)
+ - JinBo (金波)
+ - ZhangLixia (张利霞)
The build projects, the build scripts, the test scripts, and other
-files in the "ci", "projects", "scripts" and "tests" directories, have
+files in the "projects", "scripts" and "tests" directories, have
other copyright owners, but are released under the libpng license.
-Some files in the "contrib" directory, and some tools-generated files
-that are distributed with libpng, have other copyright owners, and are
-released under other open source licenses.
+Some files in the "ci" and "contrib" directories, as well as some
+of the tools-generated files that are distributed with libpng, have
+other copyright owners, and are released under other open source
+licenses.
diff --git a/Build/source/libs/libpng/libpng-src/CHANGES b/Build/source/libs/libpng/libpng-src/CHANGES
index 2d8c585c0e7..2d9a57e439e 100644
--- a/Build/source/libs/libpng/libpng-src/CHANGES
+++ b/Build/source/libs/libpng/libpng-src/CHANGES
@@ -6129,6 +6129,38 @@ Version 1.6.40 [June 21, 2023]
Updated the configurations and the scripts for continuous integration.
Cleaned up the code, the build scripts, and the documentation.
+Version 1.6.41 [January 24, 2024]
+ Added SIMD-optimized code for the Loongarch LSX hardware.
+ (Contributed by GuXiWei, JinBo and ZhangLixia)
+ Fixed the run-time discovery of MIPS MSA hardware.
+ (Contributed by Sui Jingfeng)
+ Fixed an off-by-one error in the function `png_do_check_palette_indexes`,
+ which failed to recognize errors that might have existed in the first
+ column of a broken palette-encoded image. This was a benign regression
+ accidentally introduced in libpng-1.6.33. No pixel was harmed.
+ (Contributed by Adam Richter; reviewed by John Bowler)
+ Fixed, improved and modernized the contrib/pngminus programs, i.e.,
+ png2pnm.c and pnm2png.c
+ Removed old and peculiar portability hacks that were meant to silence
+ warnings issued by gcc version 7.1 alone.
+ (Contributed by John Bowler)
+ Fixed and modernized the CMake file, and raised the minimum required
+ CMake version from 3.1 to 3.6.
+ (Contributed by Clinton Ingram, Timothy Lyanguzov, Tyler Kropp, et al.)
+ Allowed the configure script to disable the building of auxiliary tools
+ and tests, thus catching up with the CMake file.
+ (Contributed by Carlo Bramini)
+ Fixed a build issue on Mac.
+ (Contributed by Zixu Wang)
+ Moved the Autoconf macro files to scripts/autoconf.
+ Moved the CMake files (except for the main CMakeLists.txt) to
+ scripts/cmake and moved the list of their contributing authors to
+ scripts/cmake/AUTHORS.md
+ Updated the CI configurations and scripts.
+ Relicensed the CI scripts to the MIT License.
+ Improved the test coverage.
+ (Contributed by John Bowler)
+
Send comments/corrections/commendations to png-mng-implement at lists.sf.net.
Subscription is required; visit
https://lists.sourceforge.net/lists/listinfo/png-mng-implement
diff --git a/Build/source/libs/libpng/libpng-src/CMakeLists.txt b/Build/source/libs/libpng/libpng-src/CMakeLists.txt
index e355e4dfdf3..0d40ce0b776 100644
--- a/Build/source/libs/libpng/libpng-src/CMakeLists.txt
+++ b/Build/source/libs/libpng/libpng-src/CMakeLists.txt
@@ -1,54 +1,43 @@
-# CMakeLists.txt
-
-# Copyright (c) 2018-2023 Cosmin Truta
-# Copyright (c) 2007,2009-2018 Glenn Randers-Pehrson
-# Written by Christian Ehrlicher, 2007
-# Revised by Roger Lowman, 2009-2010
-# Revised by Clifford Yapp, 2011-2012,2017
-# Revised by Claudio Bley, 2013
-# Revised by Roger Leigh, 2016
-# Revised by Andreas Franek, 2016
-# Revised by Sam Serrels, 2017
-# Revised by Vadim Barkov, 2017
-# Revised by Vicky Pfau, 2018
-# Revised by Cameron Cawley, 2018,2021
-# Revised by Kyle Bentley, 2018
-# Revised by David Callu, 2020
-# Revised by Steve Robinson, 2020
-# Revised by Simon Hausmann, 2020
-# Revised by Alex Gaynor, 2020
-# Revised by Owen Rudge, 2020
-# Revised by Gleb Mazovetskiy, 2021
-# Revised by Christopher Sean Morrison, 2022
-# Revised by B. Scott Michel, 2022
-# Revised by Jeremy Maitin-Shepard, 2022
-# Revised by Martin Storsjo, 2022
-# Revised by Jon Creighton, 2023
-# Revised by Gunther Nikl, 2023
-
-# This code is released under the libpng license.
-# For conditions of distribution and use, see the disclaimer
-# and license in png.h
-
-cmake_minimum_required(VERSION 3.1)
-cmake_policy(VERSION 3.1)
-
-project(libpng C ASM)
-enable_testing()
-
-include(CMakeParseArguments)
-include(CheckCSourceCompiles)
-include(GNUInstallDirs)
+
+# CMakeLists.txt - CMake lists for libpng
+#
+# Copyright (c) 2018-2024 Cosmin Truta.
+# Copyright (c) 2007-2018 Glenn Randers-Pehrson.
+# Originally written by Christian Ehrlicher, 2007.
+#
+# Use, modification and distribution are subject to
+# the same licensing terms and conditions as libpng.
+# Please see the copyright notice in png.h or visit
+# http://libpng.org/pub/png/src/libpng-LICENSE.txt
+#
+# For copyright and licensing purposes, please see
+# the accompanying file scripts/cmake/AUTHORS.md
+#
+# SPDX-License-Identifier: libpng-2.0
+
+cmake_minimum_required(VERSION 3.6)
set(PNGLIB_MAJOR 1)
set(PNGLIB_MINOR 6)
-set(PNGLIB_REVISION 40)
+set(PNGLIB_REVISION 41)
set(PNGLIB_SUBREVISION 0)
#set(PNGLIB_SUBREVISION "git")
set(PNGLIB_VERSION ${PNGLIB_MAJOR}.${PNGLIB_MINOR}.${PNGLIB_REVISION})
set(PNGLIB_ABI_VERSION ${PNGLIB_MAJOR}${PNGLIB_MINOR})
set(PNGLIB_SHARED_VERSION ${PNGLIB_ABI_VERSION}.${PNGLIB_REVISION}.${PNGLIB_SUBREVISION})
+project(libpng
+ VERSION ${PNGLIB_VERSION}
+ LANGUAGES C ASM)
+
+if(POLICY CMP0074)
+ # Allow find_package() to use the ZLIB_ROOT variable, if available.
+ cmake_policy(SET CMP0074 NEW)
+endif()
+
+include(CheckCSourceCompiles)
+include(GNUInstallDirs)
+
# Allow the users to specify an application-specific API prefix for libpng
# vendoring purposes. A standard libpng build should have no such prefix.
set(PNG_PREFIX ""
@@ -65,31 +54,61 @@ set(PNG_DEBUG_POSTFIX "d"
set(DFA_XTRA ""
CACHE FILEPATH "File containing extra configuration settings")
-# Allow the users to configure the following build options.
-option(PNG_SHARED "Build libpng as a shared lib" ON)
-option(PNG_STATIC "Build libpng as a static lib" ON)
-option(PNG_FRAMEWORK "Build libpng as a Mac OS X framework" OFF)
-option(PNG_EXECUTABLES "Build libpng executables" ON)
-option(PNG_TESTS "Build libpng tests" ON)
+# Allow the users to switch on/off various library build types.
+option(PNG_SHARED "Build libpng as a shared library" ON)
+option(PNG_STATIC "Build libpng as a static library" ON)
+if(APPLE)
+ option(PNG_FRAMEWORK "Build libpng as a framework bundle" ON)
+endif()
+
+# Allow the users to switch on/off the auxiliary build and test artifacts.
+# NOTE: These artifacts are NOT part of libpng proper, and are subject to change at any time.
+option(PNG_TESTS "Build the libpng tests" ON)
+option(PNG_TOOLS "Build the libpng tools" ON)
+
+# Maintain backwards compatibility with the deprecated option PNG_EXECUTABLES.
+option(PNG_EXECUTABLES "[Deprecated; please use PNG_TOOLS]" ON)
+if(NOT PNG_EXECUTABLES)
+ message(DEPRECATION "The option PNG_EXECUTABLES has been deprecated in favour of PNG_TOOLS")
+ if(PNG_TOOLS)
+ message(AUTHOR_WARNING
+ "Setting PNG_TOOLS to ${PNG_EXECUTABLES}, to stay compatible with PNG_EXECUTABLES")
+ set(PNG_TOOLS "${PNG_EXECUTABLES}")
+ endif()
+endif()
+
+# Allow the users to configure various compilation options.
option(PNG_DEBUG "Enable debug output" OFF)
option(PNG_HARDWARE_OPTIMIZATIONS "Enable hardware optimizations" ON)
-# Allow the users to specify a location of zlib.
-# Useful if zlib is being built alongside this as a sub-project.
+# Allow the users to specify a custom location of zlib.
+# This option is deprecated, and no longer needed with CMake 3.12 and newer.
+# Under the CMake policy CMP0074, if zlib is being built alongside libpng as a
+# subproject, its location can be passed on to CMake via the ZLIB_ROOT variable.
option(PNG_BUILD_ZLIB "Custom zlib location, else find_package is used" OFF)
if(NOT PNG_BUILD_ZLIB)
find_package(ZLIB REQUIRED)
- include_directories(${ZLIB_INCLUDE_DIRS})
+elseif(POLICY CMP0074)
+ # TODO: Remove the policy check if CMake version 3.12 or greater becomes the minimum required.
+ if("x${ZLIB_ROOT}" STREQUAL "x")
+ message(DEPRECATION
+ "The option PNG_BUILD_ZLIB has been deprecated; please use ZLIB_ROOT instead")
+ else()
+ message(SEND_ERROR
+ "The option PNG_BUILD_ZLIB=${PNG_BUILD_ZLIB} and "
+ "the variable ZLIB_ROOT=\"${ZLIB_ROOT}\" are mutually exclusive")
+ endif()
endif()
if(UNIX AND NOT APPLE AND NOT BEOS AND NOT HAIKU AND NOT EMSCRIPTEN)
find_library(M_LIBRARY m)
- if(NOT M_LIBRARY)
+ if(M_LIBRARY)
+ set(M_LIBRARY m)
+ else()
set(M_LIBRARY "")
endif()
else()
- # libm is not needed and/or not available.
- set(M_LIBRARY "")
+ # libm is not available or not needed.
endif()
# CMake currently sets CMAKE_SYSTEM_PROCESSOR to one of x86_64 or arm64 on macOS,
@@ -106,10 +125,8 @@ endif()
if(PNG_HARDWARE_OPTIMIZATIONS)
# Set definitions and sources for ARM.
-if(TARGET_ARCH MATCHES "^arm" OR
- TARGET_ARCH MATCHES "^aarch64")
- if(TARGET_ARCH MATCHES "^arm64" OR
- TARGET_ARCH MATCHES "^aarch64")
+if(TARGET_ARCH MATCHES "^(ARM|arm|aarch)")
+ if(TARGET_ARCH MATCHES "^(ARM64|arm64|aarch64)")
set(PNG_ARM_NEON_POSSIBLE_VALUES on off)
set(PNG_ARM_NEON "on"
CACHE STRING "Enable ARM NEON optimizations: on|off; on is default")
@@ -123,15 +140,17 @@ if(TARGET_ARCH MATCHES "^arm" OR
list(FIND PNG_ARM_NEON_POSSIBLE_VALUES ${PNG_ARM_NEON} index)
if(index EQUAL -1)
message(FATAL_ERROR "PNG_ARM_NEON must be one of [${PNG_ARM_NEON_POSSIBLE_VALUES}]")
- elseif(NOT ${PNG_ARM_NEON} STREQUAL "off")
+ elseif(NOT PNG_ARM_NEON STREQUAL "off")
set(libpng_arm_sources
arm/arm_init.c
- arm/filter_neon.S
arm/filter_neon_intrinsics.c
arm/palette_neon_intrinsics.c)
- if(${PNG_ARM_NEON} STREQUAL "on")
+ if(NOT MSVC)
+ list(APPEND libpng_arm_sources arm/filter_neon.S)
+ endif()
+ if(PNG_ARM_NEON STREQUAL "on")
add_definitions(-DPNG_ARM_NEON_OPT=2)
- elseif(${PNG_ARM_NEON} STREQUAL "check")
+ elseif(PNG_ARM_NEON STREQUAL "check")
add_definitions(-DPNG_ARM_NEON_CHECK_SUPPORTED)
endif()
else()
@@ -140,8 +159,7 @@ if(TARGET_ARCH MATCHES "^arm" OR
endif()
# Set definitions and sources for PowerPC.
-if(TARGET_ARCH MATCHES "^powerpc*" OR
- TARGET_ARCH MATCHES "^ppc64*")
+if(TARGET_ARCH MATCHES "^(powerpc|ppc64)")
set(PNG_POWERPC_VSX_POSSIBLE_VALUES on off)
set(PNG_POWERPC_VSX "on"
CACHE STRING "Enable POWERPC VSX optimizations: on|off; on is default")
@@ -150,11 +168,11 @@ if(TARGET_ARCH MATCHES "^powerpc*" OR
list(FIND PNG_POWERPC_VSX_POSSIBLE_VALUES ${PNG_POWERPC_VSX} index)
if(index EQUAL -1)
message(FATAL_ERROR "PNG_POWERPC_VSX must be one of [${PNG_POWERPC_VSX_POSSIBLE_VALUES}]")
- elseif(NOT ${PNG_POWERPC_VSX} STREQUAL "off")
+ elseif(NOT PNG_POWERPC_VSX STREQUAL "off")
set(libpng_powerpc_sources
powerpc/powerpc_init.c
powerpc/filter_vsx_intrinsics.c)
- if(${PNG_POWERPC_VSX} STREQUAL "on")
+ if(PNG_POWERPC_VSX STREQUAL "on")
add_definitions(-DPNG_POWERPC_VSX_OPT=2)
endif()
else()
@@ -163,8 +181,7 @@ if(TARGET_ARCH MATCHES "^powerpc*" OR
endif()
# Set definitions and sources for Intel.
-if(TARGET_ARCH MATCHES "^i?86" OR
- TARGET_ARCH MATCHES "^x86_64*")
+if(TARGET_ARCH MATCHES "^(i[3-6]86|x86|AMD64)")
set(PNG_INTEL_SSE_POSSIBLE_VALUES on off)
set(PNG_INTEL_SSE "on"
CACHE STRING "Enable INTEL_SSE optimizations: on|off; on is default")
@@ -173,11 +190,11 @@ if(TARGET_ARCH MATCHES "^i?86" OR
list(FIND PNG_INTEL_SSE_POSSIBLE_VALUES ${PNG_INTEL_SSE} index)
if(index EQUAL -1)
message(FATAL_ERROR "PNG_INTEL_SSE must be one of [${PNG_INTEL_SSE_POSSIBLE_VALUES}]")
- elseif(NOT ${PNG_INTEL_SSE} STREQUAL "off")
+ elseif(NOT PNG_INTEL_SSE STREQUAL "off")
set(libpng_intel_sources
intel/intel_init.c
intel/filter_sse2_intrinsics.c)
- if(${PNG_INTEL_SSE} STREQUAL "on")
+ if(PNG_INTEL_SSE STREQUAL "on")
add_definitions(-DPNG_INTEL_SSE_OPT=1)
endif()
else()
@@ -186,51 +203,71 @@ if(TARGET_ARCH MATCHES "^i?86" OR
endif()
# Set definitions and sources for MIPS.
-if(TARGET_ARCH MATCHES "mipsel*" OR
- TARGET_ARCH MATCHES "mips64el*")
+if(TARGET_ARCH MATCHES "^(mipsel|mips64el)")
set(PNG_MIPS_MSA_POSSIBLE_VALUES on off)
set(PNG_MIPS_MSA "on"
CACHE STRING "Enable MIPS_MSA optimizations: on|off; on is default")
set_property(CACHE PNG_MIPS_MSA
PROPERTY STRINGS ${PNG_MIPS_MSA_POSSIBLE_VALUES})
- list(FIND PNG_MIPS_MSA_POSSIBLE_VALUES ${PNG_MIPS_MSA} index)
- if(index EQUAL -1)
+ list(FIND PNG_MIPS_MSA_POSSIBLE_VALUES ${PNG_MIPS_MSA} index_msa)
+ if(index_msa EQUAL -1)
message(FATAL_ERROR "PNG_MIPS_MSA must be one of [${PNG_MIPS_MSA_POSSIBLE_VALUES}]")
- elseif(NOT ${PNG_MIPS_MSA} STREQUAL "off")
+ endif()
+
+ set(PNG_MIPS_MMI_POSSIBLE_VALUES on off)
+ set(PNG_MIPS_MMI "on"
+ CACHE STRING "Enable MIPS_MMI optimizations: on|off; on is default")
+ set_property(CACHE PNG_MIPS_MMI
+ PROPERTY STRINGS ${PNG_MIPS_MMI_POSSIBLE_VALUES})
+ list(FIND PNG_MIPS_MMI_POSSIBLE_VALUES ${PNG_MIPS_MMI} index_mmi)
+ if(index_mmi EQUAL -1)
+ message(FATAL_ERROR "PNG_MIPS_MMI must be one of [${PNG_MIPS_MMI_POSSIBLE_VALUES}]")
+ endif()
+
+ if(PNG_MIPS_MSA STREQUAL "on" AND PNG_MIPS_MMI STREQUAL "on")
+ set(libpng_mips_sources
+ mips/mips_init.c
+ mips/filter_msa_intrinsics.c
+ mips/filter_mmi_inline_assembly.c)
+ add_definitions(-DPNG_MIPS_MSA_OPT=2)
+ add_definitions(-DPNG_MIPS_MMI_OPT=1)
+ elseif(PNG_MIPS_MSA STREQUAL "on")
set(libpng_mips_sources
mips/mips_init.c
mips/filter_msa_intrinsics.c)
- if(${PNG_MIPS_MSA} STREQUAL "on")
- add_definitions(-DPNG_MIPS_MSA_OPT=2)
- endif()
- else()
+ add_definitions(-DPNG_MIPS_MSA_OPT=2)
+ add_definitions(-DPNG_MIPS_MMI_OPT=0)
+ elseif(PNG_MIPS_MMI STREQUAL "on")
+ set(libpng_mips_sources
+ mips/mips_init.c
+ mips/filter_mmi_inline_assembly.c)
add_definitions(-DPNG_MIPS_MSA_OPT=0)
- endif()
+ add_definitions(-DPNG_MIPS_MMI_OPT=1)
+ else()
+ add_definitions(-DPNG_MIPS_MSA_OPT=0)
+ add_definitions(-DPNG_MIPS_MMI_OPT=0)
+ endif()
endif()
else(PNG_HARDWARE_OPTIMIZATIONS)
# Set definitions and sources for ARM.
-if(TARGET_ARCH MATCHES "^arm" OR
- TARGET_ARCH MATCHES "^aarch64")
+if(TARGET_ARCH MATCHES "^(ARM|arm|aarch)")
add_definitions(-DPNG_ARM_NEON_OPT=0)
endif()
# Set definitions and sources for PowerPC.
-if(TARGET_ARCH MATCHES "^powerpc*" OR
- TARGET_ARCH MATCHES "^ppc64*")
+if(TARGET_ARCH MATCHES "^(powerpc|ppc64)")
add_definitions(-DPNG_POWERPC_VSX_OPT=0)
endif()
# Set definitions and sources for Intel.
-if(TARGET_ARCH MATCHES "^i?86" OR
- TARGET_ARCH MATCHES "^x86_64*")
+if(TARGET_ARCH MATCHES "^(i[3-6]86|x86|AMD64)")
add_definitions(-DPNG_INTEL_SSE_OPT=0)
endif()
# Set definitions and sources for MIPS.
-if(TARGET_ARCH MATCHES "mipsel*" OR
- TARGET_ARCH MATCHES "mips64el*")
+if(TARGET_ARCH MATCHES "^(mipsel|mips64el)")
add_definitions(-DPNG_MIPS_MSA_OPT=0)
endif()
@@ -244,7 +281,7 @@ VERS_1 { global: sym1; local: *; };
VERS_2 { global: sym2; main; } VERS_1;
")
set(_SAVED_CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS})
- if(NOT CMAKE_HOST_SYSTEM_NAME MATCHES "^SunOS")
+ if(NOT CMAKE_HOST_SOLARIS)
# Avoid using CMAKE_SHARED_LIBRARY_C_FLAGS in version script checks on
# Solaris, because of an incompatibility with the Solaris link editor.
list(APPEND CMAKE_REQUIRED_FLAGS ${CMAKE_SHARED_LIBRARY_C_FLAGS})
@@ -257,7 +294,7 @@ int main(void) { return 0; }
" HAVE_LD_VERSION_SCRIPT)
if(NOT HAVE_LD_VERSION_SCRIPT)
set(CMAKE_REQUIRED_FLAGS ${_SAVED_CMAKE_REQUIRED_FLAGS})
- if(NOT CMAKE_HOST_SYSTEM_NAME MATCHES "^SunOS")
+ if(NOT CMAKE_HOST_SOLARIS)
# Again, avoid using CMAKE_SHARED_LIBRARY_C_FLAGS in version script
# checks on Solaris.
list(APPEND CMAKE_REQUIRED_FLAGS ${CMAKE_SHARED_LIBRARY_C_FLAGS})
@@ -273,41 +310,6 @@ int main(void) { return 0; }
file(REMOVE "${CMAKE_CURRENT_BINARY_DIR}/conftest.map")
endif()
-# Find symbol prefix. Likely obsolete and unnecessary with recent
-# toolchains (it's not done in many other projects).
-function(find_symbol_prefix)
- set(SYMBOL_PREFIX)
-
- execute_process(COMMAND "${CMAKE_C_COMPILER}" -E -
- INPUT_FILE /dev/null
- OUTPUT_VARIABLE OUT
- RESULT_VARIABLE STATUS)
-
- if(CPP_FAIL)
- message(WARNING "Failed to run the C preprocessor")
- endif()
-
- string(REPLACE "\n" ";" OUT "${OUT}")
- foreach(line ${OUT})
- string(REGEX MATCH "^PREFIX=" found_match "${line}")
- if(found_match)
- string(REGEX REPLACE "^PREFIX=(.*\)" "\\1" prefix "${line}")
- string(REGEX MATCH "__USER_LABEL_PREFIX__" found_match "${prefix}")
- if(found_match)
- string(REGEX REPLACE "(.*)__USER_LABEL_PREFIX__(.*)" "\\1\\2" prefix "${prefix}")
- endif()
- set(SYMBOL_PREFIX "${prefix}")
- endif()
- endforeach()
-
- message(STATUS "Symbol prefix: ${SYMBOL_PREFIX}")
- set(SYMBOL_PREFIX "${SYMBOL_PREFIX}" PARENT_SCOPE)
-endfunction()
-
-if(UNIX)
- find_symbol_prefix()
-endif()
-
find_program(AWK NAMES gawk awk)
include_directories(${CMAKE_CURRENT_BINARY_DIR})
@@ -350,7 +352,7 @@ else()
COMMAND "${CMAKE_COMMAND}"
"-DINPUT=${_GC_INPUT}"
"-DOUTPUT=${_GC_OUTPUT}"
- -P "${CMAKE_CURRENT_BINARY_DIR}/scripts/genchk.cmake"
+ -P "${CMAKE_CURRENT_BINARY_DIR}/genchk.cmake"
DEPENDS "${_GC_INPUT}" ${_GC_DEPENDS}
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}")
endfunction()
@@ -373,7 +375,7 @@ else()
COMMAND "${CMAKE_COMMAND}"
"-DINPUT=${_GO_INPUT}"
"-DOUTPUT=${_GO_OUTPUT}"
- -P "${CMAKE_CURRENT_BINARY_DIR}/scripts/genout.cmake"
+ -P "${CMAKE_CURRENT_BINARY_DIR}/genout.cmake"
DEPENDS "${_GO_INPUT}" ${_GO_DEPENDS}
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}")
endfunction()
@@ -392,7 +394,7 @@ else()
add_custom_command(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${_GSO_OUTPUT}"
COMMAND "${CMAKE_COMMAND}"
"-DOUTPUT=${_GSO_OUTPUT}"
- -P "${CMAKE_CURRENT_BINARY_DIR}/scripts/gensrc.cmake"
+ -P "${CMAKE_CURRENT_BINARY_DIR}/gensrc.cmake"
DEPENDS ${_GSO_DEPENDS}
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}")
endfunction()
@@ -522,7 +524,7 @@ else()
add_custom_target(png_genprebuilt
COMMAND "${CMAKE_COMMAND}"
"-DOUTPUT=scripts/pnglibconf.h.prebuilt"
- -P "${CMAKE_CURRENT_BINARY_DIR}/scripts/gensrc.cmake"
+ -P "${CMAKE_CURRENT_BINARY_DIR}/gensrc.cmake"
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}")
# A single target handles generation of all generated files.
@@ -602,7 +604,7 @@ set(png_fix_itxt_sources
contrib/tools/png-fix-itxt.c
)
-if(MSVC OR (WIN32 AND (CMAKE_C_COMPILER_ID MATCHES ".*Clang")))
+if(MSVC OR (WIN32 AND (CMAKE_C_COMPILER_ID MATCHES "Clang")))
add_definitions(-D_CRT_NONSTDC_NO_DEPRECATE)
add_definitions(-D_CRT_SECURE_NO_DEPRECATE)
endif()
@@ -612,15 +614,14 @@ if(PNG_DEBUG)
endif()
# Now build our targets.
-include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${ZLIB_INCLUDE_DIRS})
# Initialize the list of libpng library targets.
set(PNG_LIBRARY_TARGETS "")
# Initialize the libpng library file names.
if(UNIX
- OR (WIN32 AND NOT "${CMAKE_SHARED_LIBRARY_PREFIX}" STREQUAL "")
- OR (WIN32 AND NOT "${CMAKE_STATIC_LIBRARY_PREFIX}" STREQUAL ""))
+ OR (WIN32 AND NOT CMAKE_SHARED_LIBRARY_PREFIX STREQUAL "")
+ OR (WIN32 AND NOT CMAKE_STATIC_LIBRARY_PREFIX STREQUAL ""))
# We are on a Unix or Unix-like toolchain like the GNU toolchain on Windows.
# Library file names are expected to have an implicit prefix such as "lib".
# Let CMake prepend and append its usual prefixes and suffixes by default.
@@ -653,10 +654,19 @@ if(PNG_SHARED)
LINK_FLAGS "-Wl,-M -Wl,'${CMAKE_CURRENT_BINARY_DIR}/libpng.vers'")
endif()
endif()
- if(WIN32)
+ if(APPLE)
+ # Avoid CMake's implicit compile definition "png_shared_EXPORTS".
+ set_target_properties(png_shared PROPERTIES DEFINE_SYMBOL "")
+ elseif(WIN32)
+ # Use the explicit compile definition "PNG_BUILD_DLL" for Windows DLLs.
set_target_properties(png_shared PROPERTIES DEFINE_SYMBOL PNG_BUILD_DLL)
endif()
- target_link_libraries(png_shared ${ZLIB_LIBRARIES} ${M_LIBRARY})
+ target_include_directories(png_shared
+ PUBLIC
+ $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/libpng${PNGLIB_ABI_VERSION}>
+ $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
+ PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
+ target_link_libraries(png_shared PUBLIC ZLIB::ZLIB ${M_LIBRARY})
endif()
if(PNG_STATIC)
@@ -666,10 +676,15 @@ if(PNG_STATIC)
set_target_properties(png_static PROPERTIES
OUTPUT_NAME "${PNG_STATIC_OUTPUT_NAME}"
DEBUG_POSTFIX "${PNG_DEBUG_POSTFIX}")
- target_link_libraries(png_static ${ZLIB_LIBRARIES} ${M_LIBRARY})
+ target_include_directories(png_static
+ PUBLIC
+ $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/libpng${PNGLIB_ABI_VERSION}>
+ $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
+ PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
+ target_link_libraries(png_static PUBLIC ZLIB::ZLIB ${M_LIBRARY})
endif()
-if(PNG_FRAMEWORK)
+if(PNG_FRAMEWORK AND APPLE)
add_library(png_framework SHARED ${libpng_sources})
add_dependencies(png_framework png_genfiles)
list(APPEND PNG_LIBRARY_TARGETS png_framework)
@@ -681,8 +696,16 @@ if(PNG_FRAMEWORK)
MACOSX_FRAMEWORK_IDENTIFIER "org.libpng.libpng"
XCODE_ATTRIBUTE_INSTALL_PATH "@rpath"
PUBLIC_HEADER "${libpng_public_hdrs}"
- OUTPUT_NAME "png")
- target_link_libraries(png_framework ${ZLIB_LIBRARIES} ${M_LIBRARY})
+ OUTPUT_NAME "png"
+ DEBUG_POSTFIX "${PNG_DEBUG_POSTFIX}")
+ # Avoid CMake's implicit compile definition "-Dpng_framework_EXPORTS".
+ set_target_properties(png_framework PROPERTIES DEFINE_SYMBOL "")
+ target_include_directories(png_framework
+ PUBLIC
+ $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/libpng${PNGLIB_ABI_VERSION}>
+ $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
+ PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
+ target_link_libraries(png_framework PUBLIC ZLIB::ZLIB ${M_LIBRARY})
endif()
if(NOT PNG_LIBRARY_TARGETS)
@@ -691,32 +714,34 @@ if(NOT PNG_LIBRARY_TARGETS)
"PNG_SHARED, PNG_STATIC, PNG_FRAMEWORK")
endif()
-function(png_add_test)
- set(options)
- set(oneValueArgs NAME COMMAND)
- set(multiValueArgs OPTIONS FILES)
- cmake_parse_arguments(_PAT "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
- if(NOT _PAT_NAME)
- message(FATAL_ERROR "png_add_test: Missing NAME argument")
- endif()
- if(NOT _PAT_COMMAND)
- message(FATAL_ERROR "png_add_test: Missing COMMAND argument")
- endif()
+if(PNG_TESTS AND PNG_SHARED)
+ enable_testing()
- set(TEST_OPTIONS "${_PAT_OPTIONS}")
- set(TEST_FILES "${_PAT_FILES}")
+ function(png_add_test)
+ set(options)
+ set(oneValueArgs NAME COMMAND)
+ set(multiValueArgs OPTIONS FILES)
+ cmake_parse_arguments(_PAT "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
+ if(NOT _PAT_NAME)
+ message(FATAL_ERROR "png_add_test: Missing NAME argument")
+ endif()
+ if(NOT _PAT_COMMAND)
+ message(FATAL_ERROR "png_add_test: Missing COMMAND argument")
+ endif()
- configure_file("${CMAKE_CURRENT_SOURCE_DIR}/scripts/test.cmake.in"
- "${CMAKE_CURRENT_BINARY_DIR}/tests/${_PAT_NAME}.cmake"
- @ONLY)
- add_test(NAME "${_PAT_NAME}"
- COMMAND "${CMAKE_COMMAND}"
- "-DLIBPNG=$<TARGET_FILE:png_shared>"
- "-DTEST_COMMAND=$<TARGET_FILE:${_PAT_COMMAND}>"
- -P "${CMAKE_CURRENT_BINARY_DIR}/tests/${_PAT_NAME}.cmake")
-endfunction()
+ set(TEST_OPTIONS "${_PAT_OPTIONS}")
+ set(TEST_FILES "${_PAT_FILES}")
+
+ configure_file("${CMAKE_CURRENT_SOURCE_DIR}/scripts/cmake/test.cmake.in"
+ "${CMAKE_CURRENT_BINARY_DIR}/tests/${_PAT_NAME}.cmake"
+ @ONLY)
+ add_test(NAME "${_PAT_NAME}"
+ COMMAND "${CMAKE_COMMAND}"
+ "-DLIBPNG=$<TARGET_FILE:png_shared>"
+ "-DTEST_COMMAND=$<TARGET_FILE:${_PAT_COMMAND}>"
+ -P "${CMAKE_CURRENT_BINARY_DIR}/tests/${_PAT_NAME}.cmake")
+ endfunction()
-if(PNG_TESTS AND PNG_SHARED)
# Find test PNG files by globbing, but sort lists to ensure
# consistency between different filesystems.
file(GLOB PNGSUITE_PNGS "${CMAKE_CURRENT_SOURCE_DIR}/contrib/pngsuite/*.png")
@@ -727,14 +752,14 @@ if(PNG_TESTS AND PNG_SHARED)
set(PNGTEST_PNG "${CMAKE_CURRENT_SOURCE_DIR}/pngtest.png")
add_executable(pngtest ${pngtest_sources})
- target_link_libraries(pngtest png_shared)
+ target_link_libraries(pngtest PRIVATE png_shared)
png_add_test(NAME pngtest
COMMAND pngtest
FILES "${PNGTEST_PNG}")
add_executable(pngvalid ${pngvalid_sources})
- target_link_libraries(pngvalid png_shared)
+ target_link_libraries(pngvalid PRIVATE png_shared)
png_add_test(NAME pngvalid-gamma-16-to-8
COMMAND pngvalid
@@ -780,43 +805,43 @@ if(PNG_TESTS AND PNG_SHARED)
OPTIONS --transform)
add_executable(pngstest ${pngstest_sources})
- target_link_libraries(pngstest png_shared)
+ target_link_libraries(pngstest PRIVATE png_shared)
foreach(gamma_type 1.8 linear none sRGB)
foreach(alpha_type none alpha)
set(PNGSTEST_FILES)
foreach(test_png ${TEST_PNGS})
- string(REGEX MATCH ".*-linear[-.].*" TEST_PNG_LINEAR "${test_png}")
- string(REGEX MATCH ".*-sRGB[-.].*" TEST_PNG_SRGB "${test_png}")
- string(REGEX MATCH ".*-1.8[-.].*" TEST_PNG_G18 "${test_png}")
- string(REGEX MATCH ".*-alpha-.*" TEST_PNG_ALPHA "${test_png}")
+ string(REGEX MATCH "-linear[-.]" TEST_PNG_LINEAR "${test_png}")
+ string(REGEX MATCH "-sRGB[-.]" TEST_PNG_SRGB "${test_png}")
+ string(REGEX MATCH "-1.8[-.]" TEST_PNG_G18 "${test_png}")
+ string(REGEX MATCH "-alpha-" TEST_PNG_ALPHA "${test_png}")
set(TEST_PNG_VALID TRUE)
if(TEST_PNG_ALPHA)
- if(NOT "${alpha_type}" STREQUAL "alpha")
+ if(NOT alpha_type STREQUAL "alpha")
set(TEST_PNG_VALID FALSE)
endif()
else()
- if("${alpha_type}" STREQUAL "alpha")
+ if(alpha_type STREQUAL "alpha")
set(TEST_PNG_VALID FALSE)
endif()
endif()
if(TEST_PNG_LINEAR)
- if(NOT "${gamma_type}" STREQUAL "linear")
+ if(NOT gamma_type STREQUAL "linear")
set(TEST_PNG_VALID FALSE)
endif()
elseif(TEST_PNG_SRGB)
- if(NOT "${gamma_type}" STREQUAL "sRGB")
+ if(NOT gamma_type STREQUAL "sRGB")
set(TEST_PNG_VALID FALSE)
endif()
elseif(TEST_PNG_G18)
- if(NOT "${gamma_type}" STREQUAL "1.8")
+ if(NOT gamma_type STREQUAL "1.8")
set(TEST_PNG_VALID FALSE)
endif()
else()
- if(NOT "${gamma_type}" STREQUAL "none")
+ if(NOT gamma_type STREQUAL "none")
set(TEST_PNG_VALID FALSE)
endif()
endif()
@@ -835,7 +860,7 @@ if(PNG_TESTS AND PNG_SHARED)
endforeach()
add_executable(pngunknown ${pngunknown_sources})
- target_link_libraries(pngunknown png_shared)
+ target_link_libraries(pngunknown PRIVATE png_shared)
png_add_test(NAME pngunknown-discard
COMMAND pngunknown
@@ -867,7 +892,7 @@ if(PNG_TESTS AND PNG_SHARED)
FILES "${PNGTEST_PNG}")
add_executable(pngimage ${pngimage_sources})
- target_link_libraries(pngimage png_shared)
+ target_link_libraries(pngimage PRIVATE png_shared)
png_add_test(NAME pngimage-quick
COMMAND pngimage
@@ -879,13 +904,13 @@ if(PNG_TESTS AND PNG_SHARED)
FILES ${PNGSUITE_PNGS})
endif()
-if(PNG_SHARED AND PNG_EXECUTABLES)
+if(PNG_SHARED AND PNG_TOOLS)
add_executable(pngfix ${pngfix_sources})
- target_link_libraries(pngfix png_shared)
+ target_link_libraries(pngfix PRIVATE png_shared)
set(PNG_BIN_TARGETS pngfix)
add_executable(png-fix-itxt ${png_fix_itxt_sources})
- target_link_libraries(png-fix-itxt ${ZLIB_LIBRARIES} ${M_LIBRARY})
+ target_link_libraries(png-fix-itxt PRIVATE ZLIB::ZLIB ${M_LIBRARY})
list(APPEND PNG_BIN_TARGETS png-fix-itxt)
endif()
@@ -927,7 +952,7 @@ function(create_symlink DEST_FILE)
POST_BUILD
COMMAND "${CMAKE_COMMAND}"
-E copy_if_different
- $<TARGET_LINKER_FILE_NAME:${_SYM_TARGET}>
+ $<TARGET_LINKER_FILE_DIR:${_SYM_TARGET}>/$<TARGET_LINKER_FILE_NAME:${_SYM_TARGET}>
$<TARGET_LINKER_FILE_DIR:${_SYM_TARGET}>/${DEST_FILE})
else()
add_custom_command(TARGET ${_SYM_TARGET}
@@ -941,14 +966,14 @@ function(create_symlink DEST_FILE)
endfunction()
# Create source generation scripts.
-configure_file(${CMAKE_CURRENT_SOURCE_DIR}/scripts/genchk.cmake.in
- ${CMAKE_CURRENT_BINARY_DIR}/scripts/genchk.cmake
+configure_file(${CMAKE_CURRENT_SOURCE_DIR}/scripts/cmake/genchk.cmake.in
+ ${CMAKE_CURRENT_BINARY_DIR}/genchk.cmake
@ONLY)
-configure_file(${CMAKE_CURRENT_SOURCE_DIR}/scripts/genout.cmake.in
- ${CMAKE_CURRENT_BINARY_DIR}/scripts/genout.cmake
+configure_file(${CMAKE_CURRENT_SOURCE_DIR}/scripts/cmake/genout.cmake.in
+ ${CMAKE_CURRENT_BINARY_DIR}/genout.cmake
@ONLY)
-configure_file(${CMAKE_CURRENT_SOURCE_DIR}/scripts/gensrc.cmake.in
- ${CMAKE_CURRENT_BINARY_DIR}/scripts/gensrc.cmake
+configure_file(${CMAKE_CURRENT_SOURCE_DIR}/scripts/cmake/gensrc.cmake.in
+ ${CMAKE_CURRENT_BINARY_DIR}/gensrc.cmake
@ONLY)
# libpng is a library so default to 'lib'
@@ -980,20 +1005,14 @@ endif()
if(NOT SKIP_INSTALL_LIBRARIES AND NOT SKIP_INSTALL_ALL)
install(TARGETS ${PNG_LIBRARY_TARGETS}
EXPORT libpng
- RUNTIME DESTINATION bin
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
FRAMEWORK DESTINATION ${CMAKE_INSTALL_LIBDIR})
if(PNG_SHARED)
# Create a symlink for libpng.dll.a => libpng16.dll.a on Cygwin
- if(CYGWIN OR MINGW)
- create_symlink(libpng${CMAKE_IMPORT_LIBRARY_SUFFIX} TARGET png_shared)
- install(FILES $<TARGET_LINKER_FILE_DIR:png_shared>/libpng${CMAKE_IMPORT_LIBRARY_SUFFIX}
- DESTINATION ${CMAKE_INSTALL_LIBDIR})
- endif()
-
- if(NOT WIN32)
+ if(NOT WIN32 OR CYGWIN OR MINGW)
create_symlink(libpng${CMAKE_SHARED_LIBRARY_SUFFIX} TARGET png_shared)
install(FILES $<TARGET_LINKER_FILE_DIR:png_shared>/libpng${CMAKE_SHARED_LIBRARY_SUFFIX}
DESTINATION ${CMAKE_INSTALL_LIBDIR})
@@ -1011,22 +1030,22 @@ endif()
if(NOT SKIP_INSTALL_HEADERS AND NOT SKIP_INSTALL_ALL)
install(FILES ${libpng_public_hdrs}
- DESTINATION include)
+ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
install(FILES ${libpng_public_hdrs}
- DESTINATION include/libpng${PNGLIB_ABI_VERSION})
+ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/libpng${PNGLIB_ABI_VERSION})
endif()
if(NOT SKIP_INSTALL_EXECUTABLES AND NOT SKIP_INSTALL_ALL)
if(NOT WIN32 OR CYGWIN OR MINGW)
install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/libpng-config
- DESTINATION bin)
+ DESTINATION ${CMAKE_INSTALL_BINDIR})
install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/libpng${PNGLIB_ABI_VERSION}-config
- DESTINATION bin)
+ DESTINATION ${CMAKE_INSTALL_BINDIR})
endif()
endif()
if(NOT SKIP_INSTALL_PROGRAMS AND NOT SKIP_INSTALL_ALL)
install(TARGETS ${PNG_BIN_TARGETS}
- RUNTIME DESTINATION bin)
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
endif()
if(NOT SKIP_INSTALL_FILES AND NOT SKIP_INSTALL_ALL)
@@ -1051,7 +1070,7 @@ endif()
# Create an export file that CMake users can include() to import our targets.
if(NOT SKIP_INSTALL_EXPORT AND NOT SKIP_INSTALL_ALL)
install(EXPORT libpng
- DESTINATION lib/libpng
+ DESTINATION ${CMAKE_INSTALL_LIBDIR}/libpng
FILE libpng${PNGLIB_ABI_VERSION}.cmake)
endif()
diff --git a/Build/source/libs/libpng/libpng-src/LICENSE b/Build/source/libs/libpng/libpng-src/LICENSE
index 086d1c2fda6..25f298f0fcf 100644
--- a/Build/source/libs/libpng/libpng-src/LICENSE
+++ b/Build/source/libs/libpng/libpng-src/LICENSE
@@ -4,8 +4,8 @@ COPYRIGHT NOTICE, DISCLAIMER, and LICENSE
PNG Reference Library License version 2
---------------------------------------
- * Copyright (c) 1995-2023 The PNG Reference Library Authors.
- * Copyright (c) 2018-2023 Cosmin Truta.
+ * Copyright (c) 1995-2024 The PNG Reference Library Authors.
+ * Copyright (c) 2018-2024 Cosmin Truta.
* Copyright (c) 2000-2002, 2004, 2006-2018 Glenn Randers-Pehrson.
* Copyright (c) 1996-1997 Andreas Dilger.
* Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
diff --git a/Build/source/libs/libpng/libpng-src/Makefile.am b/Build/source/libs/libpng/libpng-src/Makefile.am
index f21107e65ee..1f06c703a18 100644
--- a/Build/source/libs/libpng/libpng-src/Makefile.am
+++ b/Build/source/libs/libpng/libpng-src/Makefile.am
@@ -1,6 +1,6 @@
# Makefile.am, the source file for Makefile.in (and hence Makefile), is
#
-# Copyright (c) 2018 Cosmin Truta
+# Copyright (c) 2018-2024 Cosmin Truta
# Copyright (c) 2004-2016 Glenn Randers-Pehrson
#
# This code is released under the libpng license.
@@ -9,16 +9,24 @@
PNGLIB_BASENAME= libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@
-ACLOCAL_AMFLAGS = -I scripts
+ACLOCAL_AMFLAGS = -I scripts/autoconf
# test programs - run on make check, make distcheck
+if ENABLE_TESTS
check_PROGRAMS= pngtest pngunknown pngstest pngvalid pngimage pngcp
if HAVE_CLOCK_GETTIME
check_PROGRAMS += timepng
endif
+else
+check_PROGRAMS=
+endif
# Utilities - installed
+if ENABLE_TOOLS
bin_PROGRAMS= pngfix png-fix-itxt
+else
+bin_PROGRAMS=
+endif
# This ensures that pnglibconf.h gets built at the start of 'make all' or
# 'make check', but it does not add dependencies to the individual programs,
@@ -30,6 +38,7 @@ bin_PROGRAMS= pngfix png-fix-itxt
# always wrong and always very confusing.
BUILT_SOURCES = pnglibconf.h
+if ENABLE_TESTS
pngtest_SOURCES = pngtest.c
pngtest_LDADD = libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@.la
@@ -48,16 +57,20 @@ pngimage_LDADD = libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@.la
timepng_SOURCES = contrib/libtests/timepng.c
timepng_LDADD = libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@.la
+pngcp_SOURCES = contrib/tools/pngcp.c
+pngcp_LDADD = libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@.la
+endif
+
+if ENABLE_TOOLS
pngfix_SOURCES = contrib/tools/pngfix.c
pngfix_LDADD = libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@.la
png_fix_itxt_SOURCES = contrib/tools/png-fix-itxt.c
-
-pngcp_SOURCES = contrib/tools/pngcp.c
-pngcp_LDADD = libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@.la
+endif
# Generally these are single line shell scripts to run a test with a particular
# set of parameters:
+if ENABLE_TESTS
TESTS =\
tests/pngtest-all\
tests/pngvalid-gamma-16-to-8 tests/pngvalid-gamma-alpha-mode\
@@ -75,6 +88,7 @@ TESTS =\
tests/pngunknown-discard tests/pngunknown-if-safe tests/pngunknown-sAPI\
tests/pngunknown-sTER tests/pngunknown-save tests/pngunknown-vpAg\
tests/pngimage-quick tests/pngimage-full
+endif
# man pages
dist_man_MANS= libpng.3 libpngpf.3 png.5
@@ -103,6 +117,13 @@ libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_SOURCES += mips/mips_init.c\
mips/filter_msa_intrinsics.c
endif
+if PNG_MIPS_MMI
+if !PNG_MIPS_MSA
+libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_SOURCES += mips/mips_init.c
+endif
+libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_SOURCES += mips/filter_mmi_inline_assembly.c
+endif
+
if PNG_INTEL_SSE
libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_SOURCES += intel/intel_init.c\
intel/filter_sse2_intrinsics.c
@@ -113,6 +134,15 @@ libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_SOURCES += powerpc/powerpc_init.c\
powerpc/filter_vsx_intrinsics.c
endif
+if PNG_LOONGARCH_LSX
+noinst_LTLIBRARIES= libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@lsx.la
+libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@lsx_la_SOURCES = loongarch/loongarch_lsx_init.c\
+ loongarch/filter_lsx_intrinsics.c
+libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@lsx_la_CFLAGS = -mlsx
+libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_LIBADD = libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@lsx.la
+# libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_DEPENDENCIES = libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@lsx.la
+endif
+
nodist_libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_SOURCES = pnglibconf.h
libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_LDFLAGS = -no-undefined -export-dynamic \
@@ -133,6 +163,10 @@ else
libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_DEPENDENCIES = libpng.sym
endif
+if PNG_LOONGARCH_LSX
+ libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@_la_DEPENDENCIES += libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@lsx.la
+endif
+
#distribute headers in /usr/include/libpng/*
pkgincludedir= $(includedir)/$(PNGLIB_BASENAME)
pkginclude_HEADERS= png.h pngconf.h
@@ -149,7 +183,7 @@ pkgconfig_DATA = libpng@PNGLIB_MAJOR@@PNGLIB_MINOR@.pc
EXTRA_DIST= \
ANNOUNCE AUTHORS CHANGES INSTALL LICENSE README TODO TRADEMARK \
pngtest.png pngbar.png pngnow.png pngbar.jpg autogen.sh \
- ${srcdir}/contrib ${srcdir}/projects ${srcdir}/scripts \
+ ${srcdir}/ci ${srcdir}/contrib ${srcdir}/projects ${srcdir}/scripts \
$(TESTS) $(XFAIL_TESTS) tests/pngstest \
CMakeLists.txt example.c libpng-manual.txt
diff --git a/Build/source/libs/libpng/libpng-src/README b/Build/source/libs/libpng/libpng-src/README
index dedd2c1639e..1f51a808f7f 100644
--- a/Build/source/libs/libpng/libpng-src/README
+++ b/Build/source/libs/libpng/libpng-src/README
@@ -1,4 +1,4 @@
-README for libpng version 1.6.40
+README for libpng version 1.6.41
================================
See the note about version numbers near the top of `png.h`.
diff --git a/Build/source/libs/libpng/libpng-src/autogen.sh b/Build/source/libs/libpng/libpng-src/autogen.sh
index 9c8830a6e37..4ac8f4b9e5d 100755
--- a/Build/source/libs/libpng/libpng-src/autogen.sh
+++ b/Build/source/libs/libpng/libpng-src/autogen.sh
@@ -82,8 +82,9 @@ libpng_autotools_files="Makefile.in aclocal.m4 config.guess config.h.in
libpng_autotools_extra="compile config.h.in~"
#
# These are separate because 'maintainer-clean' does not remove them.
-libpng_libtool_files="scripts/libtool.m4 scripts/ltoptions.m4\
- scripts/ltsugar.m4 scripts/ltversion.m4 scripts/lt~obsolete.m4"
+libpng_libtool_files="scripts/autoconf/libtool.m4 scripts/autoconf/ltoptions.m4\
+ scripts/autoconf/ltsugar.m4 scripts/autoconf/ltversion.m4\
+ scripts/autoconf/lt~obsolete.m4"
libpng_autotools_dirs="autom4te.cache" # not required
#
diff --git a/Build/source/libs/libpng/libpng-src/ci/.shellcheckrc b/Build/source/libs/libpng/libpng-src/ci/.shellcheckrc
new file mode 100644
index 00000000000..0260dcca30f
--- /dev/null
+++ b/Build/source/libs/libpng/libpng-src/ci/.shellcheckrc
@@ -0,0 +1,11 @@
+# Disable the "variable appears unused" warning caused by the use of getopts
+# with an obligatory (but unused) variable name in the main function.
+disable=SC2034
+
+# Disable all the "quote to prevent globbing or word splitting" advice.
+# We need word splitting for well-known variables like MAKEFLAGS and CFLAGS.
+disable=SC2086,SC2206
+
+# Disable the "possible misspelling" warnings that might be flagged, e.g.,
+# inside function ci_trace_build.
+disable=SC2153
diff --git a/Build/source/libs/libpng/libpng-src/ci/LICENSE_MIT.txt b/Build/source/libs/libpng/libpng-src/ci/LICENSE_MIT.txt
new file mode 100644
index 00000000000..9cf106272ac
--- /dev/null
+++ b/Build/source/libs/libpng/libpng-src/ci/LICENSE_MIT.txt
@@ -0,0 +1,19 @@
+MIT License
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
diff --git a/Build/source/libs/libpng/libpng-src/ci/ci_lint_ci.sh b/Build/source/libs/libpng/libpng-src/ci/ci_lint_ci.sh
new file mode 100644
index 00000000000..123ed482f10
--- /dev/null
+++ b/Build/source/libs/libpng/libpng-src/ci/ci_lint_ci.sh
@@ -0,0 +1,88 @@
+#!/usr/bin/env bash
+set -e
+
+# Copyright (c) 2019-2024 Cosmin Truta.
+#
+# Use, modification and distribution are subject to the MIT License.
+# Please see the accompanying file LICENSE_MIT.txt
+#
+# SPDX-License-Identifier: MIT
+
+# shellcheck source="ci/lib/ci.lib.sh"
+source "$(dirname "$0")/lib/ci.lib.sh"
+cd "$CI_TOPLEVEL_DIR"
+
+CI_SHELLCHECK="$(command -v shellcheck || true)"
+CI_YAMLLINT="$(command -v yamllint || true)"
+CI_LINT_COUNTER=0
+
+function ci_lint_ci_config_files {
+ ci_info "linting: CI config files"
+ local MY_FILE
+ if [[ -x $CI_YAMLLINT ]]
+ then
+ ci_spawn "$CI_YAMLLINT" --version
+ for MY_FILE in "$CI_TOPLEVEL_DIR"/.*.yml
+ do
+ ci_spawn "$CI_YAMLLINT" --strict "$MY_FILE" ||
+ CI_LINT_COUNTER=$((CI_LINT_COUNTER + 1))
+ done
+ else
+ ci_warn "program not found: 'yamllint'; skipping checks"
+ fi
+}
+
+function ci_lint_ci_scripts {
+ ci_info "linting: CI scripts"
+ local MY_FILE
+ if [[ -x $CI_SHELLCHECK ]]
+ then
+ ci_spawn "$CI_SHELLCHECK" --version
+ for MY_FILE in "$CI_SCRIPT_DIR"/*.sh
+ do
+ ci_spawn "$CI_SHELLCHECK" -x "$MY_FILE" ||
+ CI_LINT_COUNTER=$((CI_LINT_COUNTER + 1))
+ done
+ else
+ ci_warn "program not found: 'shellcheck'; skipping checks"
+ fi
+}
+
+function ci_lint_ci_scripts_license {
+ ci_info "linting: CI scripts license"
+ ci_spawn grep -F "MIT License" ci/LICENSE_MIT.txt || {
+ ci_warn "bad or missing CI license file: '$CI_SCRIPT_DIR/LICENSE_MIT.txt'"
+ CI_LINT_COUNTER=$((CI_LINT_COUNTER + 1))
+ }
+}
+
+function usage {
+ echo "usage: $CI_SCRIPT_NAME"
+ exit 0
+}
+
+function main {
+ local opt
+ while getopts ":" opt
+ do
+ # This ain't a while-loop. It only pretends to be.
+ [[ $1 == -[?h]* || $1 == --help ]] && usage
+ ci_err "unknown option: '$1'"
+ done
+ shift $((OPTIND - 1))
+ # And... go!
+ [[ $# -eq 0 ]] || ci_err "unexpected argument: '$1'"
+ ci_lint_ci_config_files
+ ci_lint_ci_scripts
+ ci_lint_ci_scripts_license
+ if [[ $CI_LINT_COUNTER -eq 0 ]]
+ then
+ ci_info "success!"
+ exit 0
+ else
+ ci_info "failed on $CI_LINT_COUNTER file(s)"
+ exit 1
+ fi
+}
+
+main "$@"
diff --git a/Build/source/libs/libpng/libpng-src/ci/ci_verify_cmake.sh b/Build/source/libs/libpng/libpng-src/ci/ci_verify_cmake.sh
index 4e11addfb9d..1d3e9734e69 100644
--- a/Build/source/libs/libpng/libpng-src/ci/ci_verify_cmake.sh
+++ b/Build/source/libs/libpng/libpng-src/ci/ci_verify_cmake.sh
@@ -1,46 +1,30 @@
#!/usr/bin/env bash
set -e
-# ci_verify_cmake.sh
-# Continuously integrate libpng using CMake.
+# Copyright (c) 2019-2024 Cosmin Truta.
#
-# Copyright (c) 2019-2023 Cosmin Truta.
+# Use, modification and distribution are subject to the MIT License.
+# Please see the accompanying file LICENSE_MIT.txt
#
-# This software is released under the libpng license.
-# For conditions of distribution and use, see the disclaimer
-# and license in png.h.
+# SPDX-License-Identifier: MIT
-CI_SCRIPTNAME="$(basename "$0")"
-CI_SCRIPTDIR="$(cd "$(dirname "$0")" && pwd)"
-CI_SRCDIR="$(dirname "$CI_SCRIPTDIR")"
-CI_BUILDDIR="$CI_SRCDIR/out/ci_verify_cmake.build"
-CI_INSTALLDIR="$CI_SRCDIR/out/ci_verify_cmake.install"
+# shellcheck source="ci/lib/ci.lib.sh"
+source "$(dirname "$0")/lib/ci.lib.sh"
+cd "$CI_TOPLEVEL_DIR"
+
+CI_SRC_DIR="$CI_TOPLEVEL_DIR"
+CI_OUT_DIR="$CI_TOPLEVEL_DIR/out"
+CI_BUILD_DIR="$CI_OUT_DIR/ci_verify_cmake.$CI_TARGET_SYSTEM.$CI_TARGET_ARCH.build"
+CI_INSTALL_DIR="$CI_OUT_DIR/ci_verify_cmake.$CI_TARGET_SYSTEM.$CI_TARGET_ARCH.install"
# Keep the following relative paths in sync with the absolute paths.
# We use them for the benefit of native Windows tools that might be
# otherwise confused by the path encoding used by Bash-on-Windows.
-CI_SRCDIR_FROM_BUILDDIR="../.."
-CI_INSTALLDIR_FROM_BUILDDIR="../ci_verify_cmake.install"
-
-function ci_info {
- printf >&2 "%s: %s\\n" "$CI_SCRIPTNAME" "$*"
-}
-
-function ci_err {
- printf >&2 "%s: error: %s\\n" "$CI_SCRIPTNAME" "$*"
- exit 2
-}
+CI_BUILD_TO_SRC_RELDIR="../.."
+CI_BUILD_TO_INSTALL_RELDIR="../ci_verify_cmake.$CI_TARGET_SYSTEM.$CI_TARGET_ARCH.install"
-function ci_spawn {
- printf >&2 "%s: executing:" "$CI_SCRIPTNAME"
- printf >&2 " %q" "$@"
- printf >&2 "\\n"
- "$@"
-}
-
-function ci_init_cmake_build {
- CI_SYSTEM_NAME="$(uname -s)"
- CI_MACHINE_NAME="$(uname -m)"
+function ci_init_build {
+ # Ensure that the mandatory variables are initialized.
CI_CMAKE="${CI_CMAKE:-cmake}"
CI_CTEST="${CI_CTEST:-ctest}"
CI_CMAKE_BUILD_TYPE="${CI_CMAKE_BUILD_TYPE:-Release}"
@@ -54,17 +38,21 @@ function ci_init_cmake_build {
[[ $TMP && ( $Tmp || $tmp ) ]] && unset TMP
# Ensure that CI_CMAKE_GENERATOR_PLATFORM is initialized for this generator.
[[ $CI_CMAKE_GENERATOR_PLATFORM ]] ||
- ci_err "missing: \$CI_CMAKE_GENERATOR_PLATFORM"
+ ci_err_internal "missing \$CI_CMAKE_GENERATOR_PLATFORM"
fi
}
-function ci_trace_cmake_build {
+function ci_trace_build {
ci_info "## START OF CONFIGURATION ##"
- ci_info "system name: $CI_SYSTEM_NAME"
- ci_info "machine hardware name: $CI_MACHINE_NAME"
- ci_info "source directory: $CI_SRCDIR"
- ci_info "build directory: $CI_BUILDDIR"
- ci_info "install directory: $CI_INSTALLDIR"
+ ci_info "build arch: $CI_BUILD_ARCH"
+ ci_info "build system: $CI_BUILD_SYSTEM"
+ [[ "$CI_TARGET_SYSTEM.$CI_TARGET_ARCH" != "$CI_BUILD_SYSTEM.$CI_BUILD_ARCH" ]] && {
+ ci_info "target arch: $CI_TARGET_ARCH"
+ ci_info "target system: $CI_TARGET_SYSTEM"
+ }
+ ci_info "source directory: $CI_SRC_DIR"
+ ci_info "build directory: $CI_BUILD_DIR"
+ ci_info "install directory: $CI_INSTALL_DIR"
ci_info "environment option: \$CI_CMAKE: '$CI_CMAKE'"
ci_info "environment option: \$CI_CMAKE_GENERATOR: '$CI_CMAKE_GENERATOR'"
ci_info "environment option: \$CI_CMAKE_GENERATOR_PLATFORM: '$CI_CMAKE_GENERATOR_PLATFORM'"
@@ -93,14 +81,17 @@ function ci_trace_cmake_build {
ci_info "## END OF CONFIGURATION ##"
}
-function ci_cleanup_old_cmake_build {
- [[ ! -e $CI_BUILDDIR ]] ||
- ci_spawn rm -fr "$CI_BUILDDIR"
- [[ ! -e $CI_INSTALLDIR ]] ||
- ci_spawn rm -fr "$CI_INSTALLDIR"
+function ci_cleanup_old_build {
+ if [[ -e $CI_BUILD_DIR || -e $CI_INSTALL_DIR ]]
+ then
+ ci_info "## START OF PRE-BUILD CLEANUP ##"
+ ci_spawn rm -fr "$CI_BUILD_DIR"
+ ci_spawn rm -fr "$CI_INSTALL_DIR"
+ ci_info "## END OF PRE-BUILD CLEANUP ##"
+ fi
}
-function ci_build_cmake {
+function ci_build {
ci_info "## START OF BUILD ##"
ci_spawn "$(command -v "$CI_CMAKE")" --version
ci_spawn "$(command -v "$CI_CTEST")" --version
@@ -118,14 +109,16 @@ function ci_build_cmake {
ALL_CMAKE_VARS+=(-DCMAKE_C_COMPILER="$CI_CC")
[[ $ALL_CC_FLAGS ]] &&
ALL_CMAKE_VARS+=(-DCMAKE_C_FLAGS="$ALL_CC_FLAGS")
- [[ $CI_AR ]] &&
- ALL_CMAKE_VARS+=(-DCMAKE_AR="$CI_AR")
- [[ $CI_RANLIB ]] &&
- ALL_CMAKE_VARS+=(-DCMAKE_RANLIB="$CI_RANLIB")
+ [[ $CI_AR ]] && {
+ # Use the full path of CI_AR to work around a CMake error.
+ ALL_CMAKE_VARS+=(-DCMAKE_AR="$(command -v "$CI_AR")")
+ }
+ [[ $CI_RANLIB ]] && {
+ # Use the full path of CI_RANLIB to work around a CMake error.
+ ALL_CMAKE_VARS+=(-DCMAKE_RANLIB="$(command -v "$CI_RANLIB")")
+ }
ALL_CMAKE_VARS+=(-DCMAKE_BUILD_TYPE="$CI_CMAKE_BUILD_TYPE")
ALL_CMAKE_VARS+=(-DCMAKE_VERBOSE_MAKEFILE=ON)
- [[ $CI_NO_TEST ]] &&
- ALL_CMAKE_VARS+=(-DPNG_TESTS=OFF)
ALL_CMAKE_VARS+=($CI_CMAKE_VARS)
local ALL_CMAKE_BUILD_FLAGS=($CI_CMAKE_BUILD_FLAGS)
local ALL_CTEST_FLAGS=($CI_CTEST_FLAGS)
@@ -134,47 +127,68 @@ function ci_build_cmake {
ci_spawn export CMAKE_GENERATOR="$CI_CMAKE_GENERATOR"
[[ $CI_CMAKE_GENERATOR_PLATFORM ]] &&
ci_spawn export CMAKE_GENERATOR_PLATFORM="$CI_CMAKE_GENERATOR_PLATFORM"
- # Build and install.
- # Use $CI_SRCDIR_FROM_BUILDDIR and $CI_INSTALLDIR_FROM_BUILDDIR
- # instead of $CI_SRCDIR and $CI_INSTALLDIR from this point onwards.
- ci_spawn mkdir -p "$CI_BUILDDIR"
- ci_spawn cd "$CI_BUILDDIR"
- [[ $CI_SRCDIR -ef $CI_SRCDIR_FROM_BUILDDIR ]] ||
- ci_err "assertion failed: testing: '$CI_SRCDIR' -ef '$CI_SRCDIR_FROM_BUILDDIR'"
- ci_spawn mkdir -p "$CI_INSTALLDIR"
- [[ $CI_INSTALLDIR -ef $CI_INSTALLDIR_FROM_BUILDDIR ]] ||
- ci_err "assertion failed: testing: '$CI_INSTALLDIR' -ef '$CI_INSTALLDIR_FROM_BUILDDIR'"
- ci_spawn "$CI_CMAKE" -DCMAKE_INSTALL_PREFIX="$CI_INSTALLDIR_FROM_BUILDDIR" \
+ # Build!
+ # Use $CI_BUILD_TO_SRC_RELDIR and $CI_BUILD_TO_INSTALL_RELDIR
+ # instead of $CI_SRC_DIR and $CI_INSTALL_DIR from this point onwards.
+ ci_spawn mkdir -p "$CI_BUILD_DIR"
+ ci_spawn cd "$CI_BUILD_DIR"
+ [[ $CI_BUILD_TO_SRC_RELDIR -ef $CI_SRC_DIR ]] ||
+ ci_err_internal "bad or missing \$CI_BUILD_TO_SRC_RELDIR"
+ ci_spawn mkdir -p "$CI_INSTALL_DIR"
+ [[ $CI_BUILD_TO_INSTALL_RELDIR -ef $CI_INSTALL_DIR ]] ||
+ ci_err_internal "bad or missing \$CI_BUILD_TO_INSTALL_RELDIR"
+ # Spawn "cmake ...".
+ ci_spawn "$CI_CMAKE" -DCMAKE_INSTALL_PREFIX="$CI_BUILD_TO_INSTALL_RELDIR" \
"${ALL_CMAKE_VARS[@]}" \
- "$CI_SRCDIR_FROM_BUILDDIR"
+ "$CI_BUILD_TO_SRC_RELDIR"
+ # Spawn "cmake --build ...".
ci_spawn "$CI_CMAKE" --build . \
--config "$CI_CMAKE_BUILD_TYPE" \
"${ALL_CMAKE_BUILD_FLAGS[@]}"
- [[ $CI_NO_TEST ]] ||
+ ci_expr $((CI_NO_TEST)) || {
+ # Spawn "ctest" if testing is not disabled.
ci_spawn "$CI_CTEST" --build-config "$CI_CMAKE_BUILD_TYPE" \
"${ALL_CTEST_FLAGS[@]}"
- [[ $CI_NO_INSTALL ]] ||
+ }
+ ci_expr $((CI_NO_INSTALL)) || {
+ # Spawn "cmake --build ... --target install" if installation is not disabled.
ci_spawn "$CI_CMAKE" --build . \
--config "$CI_CMAKE_BUILD_TYPE" \
--target install \
"${ALL_CMAKE_BUILD_FLAGS[@]}"
- [[ $CI_NO_CLEAN ]] ||
+ }
+ ci_expr $((CI_NO_CLEAN)) || {
+ # Spawn "make --build ... --target clean" if cleaning is not disabled.
ci_spawn "$CI_CMAKE" --build . \
--config "$CI_CMAKE_BUILD_TYPE" \
--target clean \
"${ALL_CMAKE_BUILD_FLAGS[@]}"
+ }
ci_info "## END OF BUILD ##"
}
+function usage {
+ echo "usage: $CI_SCRIPT_NAME"
+ exit 0
+}
+
function main {
+ local opt
+ while getopts ":" opt
+ do
+ # This ain't a while-loop. It only pretends to be.
+ [[ $1 == -[?h]* || $1 == --help ]] && usage
+ ci_err "unknown option: '$1'"
+ done
+ shift $((OPTIND - 1))
+ ci_init_build
+ ci_trace_build
[[ $# -eq 0 ]] || {
ci_info "note: this program accepts environment options only"
- ci_err "unexpected command arguments: '$*'"
+ ci_err "unexpected argument: '$1'"
}
- ci_init_cmake_build
- ci_trace_cmake_build
- ci_cleanup_old_cmake_build
- ci_build_cmake
+ ci_cleanup_old_build
+ ci_build
}
main "$@"
diff --git a/Build/source/libs/libpng/libpng-src/ci/ci_verify_configure.sh b/Build/source/libs/libpng/libpng-src/ci/ci_verify_configure.sh
index a8e88787aed..9be76d98620 100644
--- a/Build/source/libs/libpng/libpng-src/ci/ci_verify_configure.sh
+++ b/Build/source/libs/libpng/libpng-src/ci/ci_verify_configure.sh
@@ -1,56 +1,48 @@
#!/usr/bin/env bash
set -e
-# ci_verify_configure.sh
-# Continuously integrate libpng using the configure script.
+# Copyright (c) 2019-2024 Cosmin Truta.
#
-# Copyright (c) 2019-2023 Cosmin Truta.
+# Use, modification and distribution are subject to the MIT License.
+# Please see the accompanying file LICENSE_MIT.txt
#
-# This software is released under the libpng license.
-# For conditions of distribution and use, see the disclaimer
-# and license in png.h.
+# SPDX-License-Identifier: MIT
-CI_SCRIPTNAME="$(basename "$0")"
-CI_SCRIPTDIR="$(cd "$(dirname "$0")" && pwd)"
-CI_SRCDIR="$(dirname "$CI_SCRIPTDIR")"
-CI_BUILDDIR="$CI_SRCDIR/out/ci_verify_configure.build"
-CI_INSTALLDIR="$CI_SRCDIR/out/ci_verify_configure.install"
+# shellcheck source="ci/lib/ci.lib.sh"
+source "$(dirname "$0")/lib/ci.lib.sh"
+cd "$CI_TOPLEVEL_DIR"
-function ci_info {
- printf >&2 "%s: %s\\n" "$CI_SCRIPTNAME" "$*"
-}
-
-function ci_err {
- printf >&2 "%s: error: %s\\n" "$CI_SCRIPTNAME" "$*"
- exit 2
-}
+CI_SRC_DIR="$CI_TOPLEVEL_DIR"
+CI_OUT_DIR="$CI_TOPLEVEL_DIR/out"
+CI_BUILD_DIR="$CI_OUT_DIR/ci_verify_configure.$CI_TARGET_SYSTEM.$CI_TARGET_ARCH.build"
+CI_INSTALL_DIR="$CI_OUT_DIR/ci_verify_configure.$CI_TARGET_SYSTEM.$CI_TARGET_ARCH.install"
-function ci_spawn {
- printf >&2 "%s: executing:" "$CI_SCRIPTNAME"
- printf >&2 " %q" "$@"
- printf >&2 "\\n"
- "$@"
-}
-
-function ci_init_configure_build {
- CI_SYSTEM_NAME="$(uname -s)"
- CI_MACHINE_NAME="$(uname -m)"
+function ci_init_build {
+ # Ensure that the mandatory variables are initialized.
CI_MAKE="${CI_MAKE:-make}"
- # Set CI_CC to cc by default, if the cc command is available.
- # The configure script defaults CC to gcc, which is not always a good idea.
- [[ -x $(command -v cc) ]] && CI_CC="${CI_CC:-cc}"
+ [[ "$CI_TARGET_SYSTEM.$CI_TARGET_ARCH" != "$CI_BUILD_SYSTEM.$CI_BUILD_ARCH" ]] || {
+ # For native builds, set CI_CC to "cc" by default if the cc command is available.
+ # The configure script defaults CC to "gcc", which is not always a good idea.
+ [[ -x $(command -v cc) ]] && CI_CC="${CI_CC:-cc}"
+ }
# Ensure that the CI_ variables that cannot be customized reliably are not initialized.
- [[ ! $CI_CONFIGURE_VARS ]] || ci_err "unexpected: \$CI_CONFIGURE_VARS='$CI_CONFIGURE_VARS'"
- [[ ! $CI_MAKE_VARS ]] || ci_err "unexpected: \$CI_MAKE_VARS='$CI_MAKE_VARS'"
+ [[ ! $CI_CONFIGURE_VARS ]] ||
+ ci_err "unsupported: \$CI_CONFIGURE_VARS='$CI_CONFIGURE_VARS'"
+ [[ ! $CI_MAKE_VARS ]] ||
+ ci_err "unsupported: \$CI_MAKE_VARS='$CI_MAKE_VARS'"
}
-function ci_trace_configure_build {
+function ci_trace_build {
ci_info "## START OF CONFIGURATION ##"
- ci_info "system name: $CI_SYSTEM_NAME"
- ci_info "machine hardware name: $CI_MACHINE_NAME"
- ci_info "source directory: $CI_SRCDIR"
- ci_info "build directory: $CI_BUILDDIR"
- ci_info "install directory: $CI_INSTALLDIR"
+ ci_info "build arch: $CI_BUILD_ARCH"
+ ci_info "build system: $CI_BUILD_SYSTEM"
+ [[ "$CI_TARGET_SYSTEM.$CI_TARGET_ARCH" != "$CI_BUILD_SYSTEM.$CI_BUILD_ARCH" ]] && {
+ ci_info "target arch: $CI_TARGET_ARCH"
+ ci_info "target system: $CI_TARGET_SYSTEM"
+ }
+ ci_info "source directory: $CI_SRC_DIR"
+ ci_info "build directory: $CI_BUILD_DIR"
+ ci_info "install directory: $CI_INSTALL_DIR"
ci_info "environment option: \$CI_CONFIGURE_FLAGS: '$CI_CONFIGURE_FLAGS'"
ci_info "environment option: \$CI_MAKE: '$CI_MAKE'"
ci_info "environment option: \$CI_MAKE_FLAGS: '$CI_MAKE_FLAGS'"
@@ -80,14 +72,17 @@ function ci_trace_configure_build {
ci_info "## END OF CONFIGURATION ##"
}
-function ci_cleanup_old_configure_build {
- [[ ! -e $CI_BUILDDIR ]] ||
- ci_spawn rm -fr "$CI_BUILDDIR"
- [[ ! -e $CI_INSTALLDIR ]] ||
- ci_spawn rm -fr "$CI_INSTALLDIR"
+function ci_cleanup_old_build {
+ if [[ -e $CI_BUILD_DIR || -e $CI_INSTALL_DIR ]]
+ then
+ ci_info "## START OF PRE-BUILD CLEANUP ##"
+ ci_spawn rm -fr "$CI_BUILD_DIR"
+ ci_spawn rm -fr "$CI_INSTALL_DIR"
+ ci_info "## END OF PRE-BUILD CLEANUP ##"
+ fi
}
-function ci_build_configure {
+function ci_build {
ci_info "## START OF BUILD ##"
# Export the configure build environment.
[[ $CI_CC ]] && ci_spawn export CC="$CI_CC"
@@ -96,33 +91,58 @@ function ci_build_configure {
[[ $CI_CPP_FLAGS ]] && ci_spawn export CPPFLAGS="$CI_CPP_FLAGS"
[[ $CI_AR ]] && ci_spawn export AR="$CI_AR"
[[ $CI_RANLIB ]] && ci_spawn export RANLIB="$CI_RANLIB"
- [[ $CI_LD ]] && ci_spawn export CPP="$CI_LD"
+ [[ $CI_LD ]] && ci_spawn export LD="$CI_LD"
[[ $CI_LD_FLAGS ]] && ci_spawn export LDFLAGS="$CI_LD_FLAGS"
[[ $CI_SANITIZERS ]] && {
ci_spawn export CFLAGS="-fsanitize=$CI_SANITIZERS ${CFLAGS:-"-O2"}"
ci_spawn export LDFLAGS="-fsanitize=$CI_SANITIZERS $LDFLAGS"
}
- # Build and install.
- ci_spawn mkdir -p "$CI_BUILDDIR"
- ci_spawn cd "$CI_BUILDDIR"
- ci_spawn "$CI_SRCDIR/configure" --prefix="$CI_INSTALLDIR" $CI_CONFIGURE_FLAGS
+ # Build!
+ ci_spawn mkdir -p "$CI_BUILD_DIR"
+ ci_spawn cd "$CI_BUILD_DIR"
+ # Spawn "configure".
+ ci_spawn "$CI_SRC_DIR/configure" --prefix="$CI_INSTALL_DIR" $CI_CONFIGURE_FLAGS
+ # Spawn "make".
ci_spawn "$CI_MAKE" $CI_MAKE_FLAGS
- [[ $CI_NO_TEST ]] || ci_spawn "$CI_MAKE" $CI_MAKE_FLAGS test
- [[ $CI_NO_INSTALL ]] || ci_spawn "$CI_MAKE" $CI_MAKE_FLAGS install
- [[ $CI_NO_CLEAN ]] || ci_spawn "$CI_MAKE" $CI_MAKE_FLAGS clean
- [[ $CI_NO_CLEAN ]] || ci_spawn "$CI_MAKE" $CI_MAKE_FLAGS distclean
+ ci_expr $((CI_NO_TEST)) || {
+ # Spawn "make test" if testing is not disabled.
+ ci_spawn "$CI_MAKE" $CI_MAKE_FLAGS test
+ }
+ ci_expr $((CI_NO_INSTALL)) || {
+ # Spawn "make install" if installation is not disabled.
+ ci_spawn "$CI_MAKE" $CI_MAKE_FLAGS install
+ }
+ ci_expr $((CI_NO_CLEAN)) || {
+ # Spawn "make clean" and "make distclean" if cleaning is not disabled.
+ ci_spawn "$CI_MAKE" $CI_MAKE_FLAGS clean
+ ci_spawn "$CI_MAKE" $CI_MAKE_FLAGS distclean
+ }
ci_info "## END OF BUILD ##"
}
+function usage {
+ echo "usage: $CI_SCRIPT_NAME"
+ exit 0
+}
+
function main {
+ local opt
+ while getopts ":" opt
+ do
+ # This ain't a while-loop. It only pretends to be.
+ [[ $1 == -[?h]* || $1 == --help ]] && usage
+ ci_err "unknown option: '$1'"
+ done
+ shift $((OPTIND - 1))
+ # And... go!
+ ci_init_build
+ ci_trace_build
[[ $# -eq 0 ]] || {
ci_info "note: this program accepts environment options only"
- ci_err "unexpected command arguments: '$*'"
+ ci_err "unexpected argument: '$1'"
}
- ci_init_configure_build
- ci_trace_configure_build
- ci_cleanup_old_configure_build
- ci_build_configure
+ ci_cleanup_old_build
+ ci_build
}
main "$@"
diff --git a/Build/source/libs/libpng/libpng-src/ci/ci_verify_makefiles.sh b/Build/source/libs/libpng/libpng-src/ci/ci_verify_makefiles.sh
index 78e7469d752..beda3b470e6 100644
--- a/Build/source/libs/libpng/libpng-src/ci/ci_verify_makefiles.sh
+++ b/Build/source/libs/libpng/libpng-src/ci/ci_verify_makefiles.sh
@@ -1,38 +1,21 @@
#!/usr/bin/env bash
set -e
-# ci_verify_makefiles.sh
-# Continuously integrate libpng using the legacy makefiles.
+# Copyright (c) 2019-2024 Cosmin Truta.
#
-# Copyright (c) 2019-2023 Cosmin Truta.
+# Use, modification and distribution are subject to the MIT License.
+# Please see the accompanying file LICENSE_MIT.txt
#
-# This software is released under the libpng license.
-# For conditions of distribution and use, see the disclaimer
-# and license in png.h.
+# SPDX-License-Identifier: MIT
-CI_SCRIPTNAME="$(basename "$0")"
-CI_SCRIPTDIR="$(cd "$(dirname "$0")" && pwd)"
-CI_SRCDIR="$(dirname "$CI_SCRIPTDIR")"
+# shellcheck source="ci/lib/ci.lib.sh"
+source "$(dirname "$0")/lib/ci.lib.sh"
+cd "$CI_TOPLEVEL_DIR"
-function ci_info {
- printf >&2 "%s: %s\\n" "$CI_SCRIPTNAME" "$*"
-}
-
-function ci_err {
- printf >&2 "%s: error: %s\\n" "$CI_SCRIPTNAME" "$*"
- exit 2
-}
-
-function ci_spawn {
- printf >&2 "%s: executing:" "$CI_SCRIPTNAME"
- printf >&2 " %q" "$@"
- printf >&2 "\\n"
- "$@"
-}
+CI_SRC_DIR="$CI_TOPLEVEL_DIR"
-function ci_init_makefiles_build {
- CI_SYSTEM_NAME="$(uname -s)"
- CI_MACHINE_NAME="$(uname -m)"
+function ci_init_build {
+ # Ensure that the mandatory variables are initialized.
CI_MAKE="${CI_MAKE:-make}"
case "$CI_CC" in
( *clang* )
@@ -44,11 +27,15 @@ function ci_init_makefiles_build {
esac
}
-function ci_trace_makefiles_build {
+function ci_trace_build {
ci_info "## START OF CONFIGURATION ##"
- ci_info "system name: $CI_SYSTEM_NAME"
- ci_info "machine hardware name: $CI_MACHINE_NAME"
- ci_info "source directory: $CI_SRCDIR"
+ ci_info "build arch: $CI_BUILD_ARCH"
+ ci_info "build system: $CI_BUILD_SYSTEM"
+ [[ "$CI_TARGET_SYSTEM.$CI_TARGET_ARCH" != "$CI_BUILD_SYSTEM.$CI_BUILD_ARCH" ]] && {
+ ci_info "target arch: $CI_TARGET_ARCH"
+ ci_info "target system: $CI_TARGET_SYSTEM"
+ }
+ ci_info "source directory: $CI_SRC_DIR"
ci_info "environment option: \$CI_MAKEFILES: '$CI_MAKEFILES'"
ci_info "environment option: \$CI_MAKE: '$CI_MAKE'"
ci_info "environment option: \$CI_MAKE_FLAGS: '$CI_MAKE_FLAGS'"
@@ -79,20 +66,24 @@ function ci_trace_makefiles_build {
ci_info "## END OF CONFIGURATION ##"
}
-function ci_cleanup_old_makefiles_build {
+function ci_cleanup_old_build {
# Any old makefile-based build will most likely leave a mess
# of object files behind if interrupted, e.g., via Ctrl+C.
# There may be other files behind, depending on what makefile
# had been used. We cannot easily enumerate all of those.
# Fortunately, for a clean makefiles-based build, it should be
# sufficient to remove the old object files only.
- [[ -z $(find "$CI_SRCDIR" -maxdepth 1 -name "*.o") ]] ||
- ci_spawn rm -f "$CI_SRCDIR"/*.o
- [[ -z $(find "$CI_SRCDIR" -maxdepth 1 -name "*.obj") ]] ||
- ci_spawn rm -f "$CI_SRCDIR"/*.obj
+ ci_info "## START OF PRE-BUILD CLEANUP ##"
+ local MY_FILE
+ find "$CI_SRC_DIR" -maxdepth 1 \( -iname "*.o" -o -iname "*.obj" \) |
+ while IFS="" read -r MY_FILE
+ do
+ ci_spawn rm -fr "$MY_FILE"
+ done
+ ci_info "## END OF PRE-BUILD CLEANUP ##"
}
-function ci_build_makefiles {
+function ci_build {
ci_info "## START OF BUILD ##"
# Initialize ALL_CC_FLAGS and ALL_LD_FLAGS as strings.
local ALL_CC_FLAGS="$CI_CC_FLAGS"
@@ -118,37 +109,55 @@ function ci_build_makefiles {
[[ $CI_LIBS ]] && ALL_MAKE_VARS+=(LIBS="$CI_LIBS")
ALL_MAKE_VARS+=($CI_MAKE_VARS)
# Build!
- cd "$CI_SRCDIR"
local MY_MAKEFILE
for MY_MAKEFILE in $CI_MAKEFILES
do
ci_info "using makefile: $MY_MAKEFILE"
+ # Spawn "make".
ci_spawn "$CI_MAKE" -f "$MY_MAKEFILE" \
"${ALL_MAKE_FLAGS[@]}" \
"${ALL_MAKE_VARS[@]}"
- [[ $CI_NO_TEST ]] ||
+ ci_expr $((CI_NO_TEST)) || {
+ # Spawn "make test" if testing is not disabled.
ci_spawn "$CI_MAKE" -f "$MY_MAKEFILE" \
"${ALL_MAKE_FLAGS[@]}" \
"${ALL_MAKE_VARS[@]}" \
test
- [[ $CI_NO_CLEAN ]] ||
+ }
+ ci_expr $((CI_NO_CLEAN)) || {
+ # Spawn "make clean" if cleaning is not disabled.
ci_spawn "$CI_MAKE" -f "$MY_MAKEFILE" \
"${ALL_MAKE_FLAGS[@]}" \
"${ALL_MAKE_VARS[@]}" \
clean
+ }
done
ci_info "## END OF BUILD ##"
}
+function usage {
+ echo "usage: $CI_SCRIPT_NAME"
+ exit 0
+}
+
function main {
+ local opt
+ while getopts ":" opt
+ do
+ # This ain't a while-loop. It only pretends to be.
+ [[ $1 == -[?h]* || $1 == --help ]] && usage
+ ci_err "unknown option: '$1'"
+ done
+ shift $((OPTIND - 1))
+ # And... go!
+ ci_init_build
+ ci_trace_build
[[ $# -eq 0 ]] || {
ci_info "note: this program accepts environment options only"
- ci_err "unexpected command arguments: '$*'"
+ ci_err "unexpected argument: '$1'"
}
- ci_init_makefiles_build
- ci_trace_makefiles_build
- ci_cleanup_old_makefiles_build
- ci_build_makefiles
+ ci_cleanup_old_build
+ ci_build
}
main "$@"
diff --git a/Build/source/libs/libpng/libpng-src/ci/lib/ci.lib.sh b/Build/source/libs/libpng/libpng-src/ci/lib/ci.lib.sh
new file mode 100644
index 00000000000..1f3c698b5d7
--- /dev/null
+++ b/Build/source/libs/libpng/libpng-src/ci/lib/ci.lib.sh
@@ -0,0 +1,90 @@
+# Copyright (c) 2019-2024 Cosmin Truta.
+#
+# Use, modification and distribution are subject to the MIT License.
+# Please see the accompanying file LICENSE_MIT.txt
+#
+# SPDX-License-Identifier: MIT
+
+test -f "$BASH_SOURCE" ||
+ echo >&2 "warning: this module requires Bash version 3 or newer"
+test "${#BASH_SOURCE[@]}" -gt 1 ||
+ echo >&2 "warning: this module should be sourced from a Bash script"
+
+# Reset the locale to avoid surprises from locale-dependent commands.
+export LC_ALL=C
+export LANG=C
+export LANGUAGE=C
+
+# Reset CDPATH to avoid surprises from the "cd" command.
+export CDPATH=""
+
+# Initialize the global constants CI_SCRIPT_{NAME,DIR} and CI_TOPLEVEL_DIR.
+CI_SCRIPT_NAME="$(basename -- "$0")"
+CI_SCRIPT_DIR="$(cd "$(dirname -- "$0")" && pwd)"
+CI_TOPLEVEL_DIR="$(cd "$(dirname -- "${BASH_SOURCE[0]}")/../.." && pwd)"
+
+# Initialize the global constants CI_BUILD_{...} for the host build platform.
+CI_BUILD_ARCH="${CI_BUILD_ARCH:-"$(uname -m | tr 'A-Z/\.-' 'a-z____')"}"
+CI_BUILD_SYSTEM="${CI_BUILD_SYSTEM:-"$(uname -s | tr 'A-Z/\.-' 'a-z____')"}"
+
+# Initialize the global constants CI_TARGET_{...} for the target platform.
+CI_TARGET_ARCH="${CI_TARGET_ARCH:-"$CI_BUILD_ARCH"}"
+CI_TARGET_SYSTEM="${CI_TARGET_SYSTEM:-"$CI_BUILD_SYSTEM"}"
+
+function ci_info {
+ printf >&2 "%s: %s\\n" "$CI_SCRIPT_NAME" "$*"
+}
+
+function ci_warn {
+ printf >&2 "%s: warning: %s\\n" "$CI_SCRIPT_NAME" "$*"
+}
+
+function ci_err {
+ printf >&2 "%s: error: %s\\n" "$CI_SCRIPT_NAME" "$*"
+ exit 2
+}
+
+function ci_err_internal {
+ printf >&2 "%s: internal error: %s\\n" "$CI_SCRIPT_NAME" "$*"
+ printf >&2 "ABORTED\\n"
+ # Exit with the conventional SIGABRT code.
+ exit 134
+}
+
+function ci_expr {
+ if [[ ${*:-0} == [0-9] ]]
+ then
+ # This is the same as in the else-branch below, albeit much faster
+ # for our intended use cases.
+ return $((!$1))
+ else
+ # The funny-looking compound command "... && return $? || return $?"
+ # allows the execution to continue uninterrupted under "set -e".
+ expr >/dev/null "$@" && return $? || return $?
+ fi
+}
+
+function ci_spawn {
+ printf >&2 "%s: executing:" "$CI_SCRIPT_NAME"
+ printf >&2 " %q" "$@"
+ printf >&2 "\\n"
+ "$@"
+}
+
+# Ensure that the internal initialization is correct.
+[[ $CI_TOPLEVEL_DIR/ci/lib/ci.lib.sh -ef ${BASH_SOURCE[0]} ]] ||
+ ci_err_internal "bad or missing \$CI_TOPLEVEL_DIR"
+[[ $CI_SCRIPT_DIR/$CI_SCRIPT_NAME -ef $0 ]] ||
+ ci_err_internal "bad or missing \$CI_SCRIPT_DIR/\$CI_SCRIPT_NAME"
+[[ $CI_BUILD_ARCH && $CI_BUILD_SYSTEM ]] ||
+ ci_err_internal "missing \$CI_BUILD_ARCH or \$CI_BUILD_SYSTEM"
+[[ $CI_TARGET_ARCH && $CI_TARGET_SYSTEM ]] ||
+ ci_err_internal "missing \$CI_TARGET_ARCH or \$CI_TARGET_SYSTEM"
+
+# Ensure that the user initialization is correct.
+[[ ${CI_NO_TEST:-0} == [01] ]] ||
+ ci_err "bad boolean option: \$CI_NO_TEST: '$CI_NO_TEST'"
+[[ ${CI_NO_INSTALL:-0} == [01] ]] ||
+ ci_err "bad boolean option: \$CI_NO_INSTALL: '$CI_NO_INSTALL'"
+[[ ${CI_NO_CLEAN:-0} == [01] ]] ||
+ ci_err "bad boolean option: \$CI_NO_CLEAN: '$CI_NO_CLEAN'"
diff --git a/Build/source/libs/libpng/libpng-src/config.h.in b/Build/source/libs/libpng/libpng-src/config.h.in
index 3309c9fd513..3ec0c8ae874 100644
--- a/Build/source/libs/libpng/libpng-src/config.h.in
+++ b/Build/source/libs/libpng/libpng-src/config.h.in
@@ -3,19 +3,19 @@
/* Define to 1 if you have the <dlfcn.h> header file. */
#undef HAVE_DLFCN_H
-/* Define to 1 if you have the `feenableexcept' function. */
+/* Define to 1 if you have the 'feenableexcept' function. */
#undef HAVE_FEENABLEEXCEPT
/* Define to 1 if you have the <inttypes.h> header file. */
#undef HAVE_INTTYPES_H
-/* Define to 1 if you have the `m' library (-lm). */
+/* Define to 1 if you have the 'm' library (-lm). */
#undef HAVE_LIBM
-/* Define to 1 if you have the `z' library (-lz). */
+/* Define to 1 if you have the 'z' library (-lz). */
#undef HAVE_LIBZ
-/* Define to 1 if you have the `pow' function. */
+/* Define to 1 if you have the 'pow' function. */
#undef HAVE_POW
/* Define to 1 if you have the <stdint.h> header file. */
@@ -78,6 +78,18 @@
/* Enable Intel SSE optimizations */
#undef PNG_INTEL_SSE_OPT
+/* Enable LOONGARCH LSX optimizations */
+#undef PNG_LOONGARCH_LSX_OPT
+
+/* Turn on MIPS MMI optimizations at run-time */
+#undef PNG_MIPS_MMI_API_SUPPORTED
+
+/* Check for MIPS MMI support at run-time */
+#undef PNG_MIPS_MMI_CHECK_SUPPORTED
+
+/* Enable MIPS MMI optimizations */
+#undef PNG_MIPS_MMI_OPT
+
/* Turn on MIPS MSA optimizations at run-time */
#undef PNG_MIPS_MSA_API_SUPPORTED
@@ -96,12 +108,12 @@
/* Enable POWERPC VSX optimizations */
#undef PNG_POWERPC_VSX_OPT
-/* Define to 1 if all of the C90 standard headers exist (not just the ones
+/* Define to 1 if all of the C89 standard headers exist (not just the ones
required in a freestanding environment). This macro is provided for
backward compatibility; new code need not use it. */
#undef STDC_HEADERS
-/* Define to 1 if your <sys/time.h> declares `struct tm'. */
+/* Define to 1 if your <sys/time.h> declares 'struct tm'. */
#undef TM_IN_SYS_TIME
/* Version number of package */
diff --git a/Build/source/libs/libpng/libpng-src/configure.ac b/Build/source/libs/libpng/libpng-src/configure.ac
index 43c682e9f62..d81a580021c 100644
--- a/Build/source/libs/libpng/libpng-src/configure.ac
+++ b/Build/source/libs/libpng/libpng-src/configure.ac
@@ -1,6 +1,6 @@
# configure.ac
-# Copyright (c) 2018-2022 Cosmin Truta
+# Copyright (c) 2018-2024 Cosmin Truta
# Copyright (c) 2004-2016 Glenn Randers-Pehrson
# This code is released under the libpng license.
@@ -25,8 +25,8 @@ AC_PREREQ([2.68])
dnl Version number stuff here:
-AC_INIT([libpng],[1.6.40],[png-mng-implement@lists.sourceforge.net])
-AC_CONFIG_MACRO_DIR([scripts])
+AC_INIT([libpng],[1.6.41],[png-mng-implement@lists.sourceforge.net])
+AC_CONFIG_MACRO_DIR([scripts/autoconf])
# libpng does not follow GNU file name conventions (hence 'foreign')
# color-tests requires automake 1.11 or later
@@ -46,10 +46,10 @@ dnl automake, so the following is not necessary (and is not defined anyway):
dnl AM_PREREQ([1.11.2])
dnl stop configure from automagically running automake
-PNGLIB_VERSION=1.6.40
+PNGLIB_VERSION=1.6.41
PNGLIB_MAJOR=1
PNGLIB_MINOR=6
-PNGLIB_RELEASE=40
+PNGLIB_RELEASE=41
dnl End of version number stuff
@@ -89,6 +89,24 @@ fi
DFNCPP="$CPP"
AC_SUBST(DFNCPP)
+AC_ARG_ENABLE([tests],
+ AS_HELP_STRING([--disable-tests],
+ [do not build the test programs (default is to build)]),
+ [enable_tests="$enableval"],
+ [enable_tests=yes])
+
+AM_CONDITIONAL([ENABLE_TESTS],
+ [test "$enable_tests" != "no"])
+
+AC_ARG_ENABLE([tools],
+ AS_HELP_STRING([--disable-tools],
+ [do not build the auxiliary tools (default is to build)]),
+ [enable_tools="$enableval"],
+ [enable_tools=yes])
+
+AM_CONDITIONAL([ENABLE_TOOLS],
+ [test "$enable_tools" != "no"])
+
# -Werror cannot be passed to GCC in CFLAGS because configure will fail
# (it checks the compiler with a program that generates a warning).
# Add the following option to deal with this:
@@ -310,12 +328,18 @@ AC_ARG_ENABLE([hardware-optimizations],
enable_mips_msa=no
AC_DEFINE([PNG_MIPS_MSA_OPT], [0],
[Disable MIPS_MSA optimizations])
+ enable_mips_mmi=no
+ AC_DEFINE([PNG_MIPS_MMI_OPT], [0],
+ [Disable MIPS_MMI optimizations])
enable_powerpc_vsx=no
AC_DEFINE([PNG_POWERPC_VSX_OPT], [0],
[Disable POWERPC VSX optimizations])
enable_intel_sse=no
AC_DEFINE([PNG_INTEL_SSE_OPT], [0],
[Disable INTEL_SSE optimizations])
+ enable_loongarch_lsx=no
+ AC_DEFINE([PNG_LOONGARCH_LSX_OPT], [0],
+ [Disable LOONGARCH_LSX optimizations])
;;
*)
# allow enabling hardware optimization on any system:
@@ -326,7 +350,10 @@ AC_ARG_ENABLE([hardware-optimizations],
[Enable ARM_NEON optimizations])
;;
mipsel*|mips64el*)
+ enable_mips_mmi=yes
enable_mips_msa=yes
+ AC_DEFINE([PNG_MIPS_MMI_OPT], [1],
+ [Enable MIPS_MMI optimizations])
AC_DEFINE([PNG_MIPS_MSA_OPT], [2],
[Enable MIPS_MSA optimizations])
;;
@@ -340,6 +367,11 @@ AC_ARG_ENABLE([hardware-optimizations],
AC_DEFINE([PNG_POWERPC_VSX_OPT], [2],
[Enable POWERPC VSX optimizations])
;;
+ loongarch*)
+ enable_loongarch_lsx=yes
+ AC_DEFINE([PNG_LOONGARCH_LSX_OPT], [1],
+ [Enable LOONGARCH_LSX optimizations])
+ ;;
esac
;;
esac])
@@ -435,6 +467,51 @@ AM_CONDITIONAL([PNG_MIPS_MSA],
mipsel*|mips64el*) : ;;
esac])
+# MIPS
+# ===
+#
+# MIPS MMI (SIMD) support.
+
+AC_ARG_ENABLE([mips-mmi],
+ AS_HELP_STRING([[[--enable-mips-mmi]]],
+ [Enable MIPS MMI optimizations: =no/off, check, api, yes/on:]
+ [no/off: disable the optimizations; check: use internal checking code]
+ [(deprecated and poorly supported); api: disable by default, enable by]
+ [a call to png_set_option; yes/on: turn on unconditionally.]
+ [If not specified: determined by the compiler.]),
+ [case "$enableval" in
+ no|off)
+ # disable the default enabling on __mips_mmi systems:
+ AC_DEFINE([PNG_MIPS_MMI_OPT], [0],
+ [Disable MIPS MMI optimizations])
+ # Prevent inclusion of the assembler files below:
+ enable_mips_mmi=no;;
+ check)
+ AC_DEFINE([PNG_MIPS_MMI_CHECK_SUPPORTED], [],
+ [Check for MIPS MMI support at run-time]);;
+ api)
+ AC_DEFINE([PNG_MIPS_MMI_API_SUPPORTED], [],
+ [Turn on MIPS MMI optimizations at run-time]);;
+ yes|on)
+ AC_DEFINE([PNG_MIPS_MMI_OPT], [1],
+ [Enable MIPS MMI optimizations])
+ AC_MSG_WARN([--enable-mips-mmi: please specify 'check' or 'api', if]
+ [you want the optimizations unconditionally pass '-mloongson-mmi -march=loongson3a']
+ [to the compiler.]);;
+ *)
+ AC_MSG_ERROR([--enable-mips-mmi=${enable_mips_mmi}: invalid value])
+ esac])
+
+# Add MIPS specific files to all builds where the host_cpu is mips ('mips*') or
+# where MIPS optimizations were explicitly requested (this allows a fallback if a
+# future host CPU does not match 'mips*')
+
+AM_CONDITIONAL([PNG_MIPS_MMI],
+ [test "$enable_mips_mmi" != 'no' &&
+ case "$host_cpu" in
+ mipsel*|mips64el*) :;;
+ esac])
+
# INTEL
# =====
#
@@ -517,6 +594,69 @@ AM_CONDITIONAL([PNG_POWERPC_VSX],
powerpc*|ppc64*) : ;;
esac])
+# LOONGARCH
+# ===
+#
+# LOONGARCH LSX (SIMD) support
+
+if test "$LSX_CFLAGS" = ''; then
+ LSX_CFLAGS="-mlsx"
+fi
+
+compiler_support_loongarch_lsx=no
+AC_MSG_CHECKING(whether to use loongarch LSX intrinsics)
+save_CFLAGS=$CFLAGS
+CFLAGS="$CFLAGS $LSX_CFLAGS"
+AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
+#include<lsxintrin.h>
+int main(){
+ __m128i a, b, c;
+ a = __lsx_vadd_w(b, c);
+ return 0;
+}]])],compiler_support_loongarch_lsx=yes)
+CFLAGS=$save_CFLAGS
+AC_MSG_RESULT($compiler_support_loongarch_lsx)
+
+AC_ARG_ENABLE([loongarch-lsx],
+ AS_HELP_STRING([[[--enable-loongarch-lsx]]],
+ [Enable LOONGARCH LSX optimizations: =no/off, yes/on:]
+ [no/off: disable the optimizations;]
+ [yes/on: turn on unconditionally.]
+ [If not specified: determined by the compiler.]),
+ [case "$enableval" in
+ no|off)
+ # disable the default enabling on __loongarch_simd systems:
+ AC_DEFINE([PNG_LOONGARCH_LSX_OPT], [0],
+ [Disable LOONGARCH LSX optimizations])
+ # Prevent inclusion of the assembler files below:
+ enable_loongarch_lsx=no;;
+ yes|on)
+ AC_DEFINE([PNG_LOONGARCH_LSX_OPT], [1],
+ [Enable LOONGARCH LSX optimizations])
+ ;;
+ *)
+ AC_MSG_ERROR([--enable-loongarch-lsx=${enable_loongarch_lsx}: invalid value])
+ esac])
+
+if test "$enable_loongarch_lsx" != 'no'; then
+ if test $compiler_support_loongarch_lsx = yes; then
+ AC_DEFINE([PNG_LOONGARCH_LSX_OPT], [1], [Enable LOONGARCH LSX optimizations])
+ else
+ AC_MSG_WARN([Compiler does not support loongarch LSX.])
+ fi
+fi
+
+# Add LOONGARCH specific files to all builds where the host_cpu is loongarch ('loongarch*') or
+# where LOONGARCH optimizations were explicitly requested (this allows a fallback if a
+# future host CPU does not match 'loongarch*')
+
+AM_CONDITIONAL([PNG_LOONGARCH_LSX],
+ [test "$enable_loongarch_lsx" != 'no' && test $compiler_support_loongarch_lsx = yes &&
+ case "$host_cpu" in
+ loongarch*) :;;
+ *) test "$enable_loongarch_lsx" != '';;
+ esac])
+
AC_MSG_NOTICE([[Extra options for compiler: $PNG_COPTS]])
# Config files, substituting as above
diff --git a/Build/source/libs/libpng/libpng-src/contrib/mips-mmi/linux.c b/Build/source/libs/libpng/libpng-src/contrib/mips-mmi/linux.c
new file mode 100644
index 00000000000..31525fde9a1
--- /dev/null
+++ b/Build/source/libs/libpng/libpng-src/contrib/mips-mmi/linux.c
@@ -0,0 +1,142 @@
+
+/* contrib/mips-mmi/linux.c
+ *
+ * Copyright (c) 2024 Cosmin Truta
+ * Written by guxiwei, 2023
+ *
+ * This code is released under the libpng license.
+ * For conditions of distribution and use, see the disclaimer
+ * and license in png.h
+ */
+
+#include <stdint.h>
+#include <stdio.h>
+#include <string.h>
+#include <sys/auxv.h>
+
+/*
+ * parse_r var, r - Helper assembler macro for parsing register names.
+ *
+ * This converts the register name in $n form provided in \r to the
+ * corresponding register number, which is assigned to the variable \var. It is
+ * needed to allow explicit encoding of instructions in inline assembly where
+ * registers are chosen by the compiler in $n form, allowing us to avoid using
+ * fixed register numbers.
+ *
+ * It also allows newer instructions (not implemented by the assembler) to be
+ * transparently implemented using assembler macros, instead of needing separate
+ * cases depending on toolchain support.
+ *
+ * Simple usage example:
+ * __asm__ __volatile__("parse_r __rt, %0\n\t"
+ * ".insn\n\t"
+ * "# di %0\n\t"
+ * ".word (0x41606000 | (__rt << 16))"
+ * : "=r" (status);
+ */
+
+/* Match an individual register number and assign to \var */
+#define _IFC_REG(n) \
+ ".ifc \\r, $" #n "\n\t" \
+ "\\var = " #n "\n\t" \
+ ".endif\n\t"
+
+__asm__(".macro parse_r var r\n\t"
+ "\\var = -1\n\t"
+ _IFC_REG(0) _IFC_REG(1) _IFC_REG(2) _IFC_REG(3)
+ _IFC_REG(4) _IFC_REG(5) _IFC_REG(6) _IFC_REG(7)
+ _IFC_REG(8) _IFC_REG(9) _IFC_REG(10) _IFC_REG(11)
+ _IFC_REG(12) _IFC_REG(13) _IFC_REG(14) _IFC_REG(15)
+ _IFC_REG(16) _IFC_REG(17) _IFC_REG(18) _IFC_REG(19)
+ _IFC_REG(20) _IFC_REG(21) _IFC_REG(22) _IFC_REG(23)
+ _IFC_REG(24) _IFC_REG(25) _IFC_REG(26) _IFC_REG(27)
+ _IFC_REG(28) _IFC_REG(29) _IFC_REG(30) _IFC_REG(31)
+ ".iflt \\var\n\t"
+ ".error \"Unable to parse register name \\r\"\n\t"
+ ".endif\n\t"
+ ".endm");
+
+#define HWCAP_LOONGSON_CPUCFG (1 << 14)
+
+static int cpucfg_available(void)
+{
+ return getauxval(AT_HWCAP) & HWCAP_LOONGSON_CPUCFG;
+}
+
+static int strstart(const char *str, const char *pfx, const char **ptr)
+{
+ while (*pfx && *pfx == *str) {
+ pfx++;
+ str++;
+ }
+ if (!*pfx && ptr)
+ *ptr = str;
+ return !*pfx;
+}
+
+/* Most toolchains have no CPUCFG support yet */
+static uint32_t read_cpucfg(uint32_t reg)
+{
+ uint32_t __res;
+
+ __asm__ __volatile__(
+ "parse_r __res,%0\n\t"
+ "parse_r reg,%1\n\t"
+ ".insn \n\t"
+ ".word (0xc8080118 | (reg << 21) | (__res << 11))\n\t"
+ :"=r"(__res)
+ :"r"(reg)
+ :
+ );
+ return __res;
+}
+
+#define LOONGSON_CFG1 0x1
+
+#define LOONGSON_CFG1_MMI (1 << 4)
+
+static int cpu_flags_cpucfg(void)
+{
+ int flags = 0;
+ uint32_t cfg1 = read_cpucfg(LOONGSON_CFG1);
+
+ if (cfg1 & LOONGSON_CFG1_MMI)
+ flags = 1;
+
+ return flags;
+}
+
+static int cpu_flags_cpuinfo(void)
+{
+ FILE *f = fopen("/proc/cpuinfo", "r");
+ char buf[200];
+ int flags = 0;
+
+ if (!f)
+ return flags;
+
+ while (fgets(buf, sizeof(buf), f)) {
+ /* Legacy kernel may not export MMI in ASEs implemented */
+ if (strstart(buf, "cpu model", NULL)) {
+ if (strstr(buf, "Loongson-3 "))
+ flags = 1;
+ break;
+ }
+ if (strstart(buf, "ASEs implemented", NULL)) {
+ if (strstr(buf, " loongson-mmi"))
+ flags = 1;
+ break;
+ }
+ }
+ fclose(f);
+ return flags;
+}
+
+static int png_have_mmi()
+{
+ if (cpucfg_available())
+ return cpu_flags_cpucfg();
+ else
+ return cpu_flags_cpuinfo();
+ return 0;
+}
diff --git a/Build/source/libs/libpng/libpng-src/contrib/mips-msa/linux.c b/Build/source/libs/libpng/libpng-src/contrib/mips-msa/linux.c
index 3bac6111b79..cae8ca50ffc 100644
--- a/Build/source/libs/libpng/libpng-src/contrib/mips-msa/linux.c
+++ b/Build/source/libs/libpng/libpng-src/contrib/mips-msa/linux.c
@@ -1,67 +1,55 @@
/* contrib/mips-msa/linux.c
*
- * Copyright (c) 2020 Cosmin Truta
+ * Copyright (c) 2020-2023 Cosmin Truta
* Copyright (c) 2016 Glenn Randers-Pehrson
* Written by Mandar Sahastrabuddhe, 2016.
+ * Updated by Sui Jingfeng, 2021.
*
* This code is released under the libpng license.
* For conditions of distribution and use, see the disclaimer
* and license in png.h
*
- * SEE contrib/mips-msa/README before reporting bugs
+ * On Linux, png_have_msa is implemented by reading the pseudo-file
+ * "/proc/self/auxv".
+ *
+ * See contrib/mips-msa/README before reporting bugs.
*
* STATUS: SUPPORTED
* BUG REPORTS: png-mng-implement@sourceforge.net
- *
- * png_have_msa implemented for Linux by reading the widely available
- * pseudo-file /proc/cpuinfo.
- *
- * This code is strict ANSI-C and is probably moderately portable; it does
- * however use <stdio.h> and it assumes that /proc/cpuinfo is never localized.
*/
-#include <stdio.h>
-#include <string.h>
+#include <elf.h>
+#include <fcntl.h>
#include <stdlib.h>
+#include <unistd.h>
static int
png_have_msa(png_structp png_ptr)
{
- FILE *f = fopen("/proc/cpuinfo", "rb");
+ Elf64_auxv_t aux;
+ int fd;
+ int has_msa = 0;
- char *string = "msa";
- char word[10];
-
- if (f != NULL)
+ fd = open("/proc/self/auxv", O_RDONLY);
+ if (fd >= 0)
{
- while(!feof(f))
+ while (read(fd, &aux, sizeof(Elf64_auxv_t)) == sizeof(Elf64_auxv_t))
{
- int ch = fgetc(f);
- static int i = 0;
-
- while(!(ch <= 32))
+ if (aux.a_type == AT_HWCAP)
{
- word[i++] = ch;
- ch = fgetc(f);
- }
-
- int val = strcmp(string, word);
+ uint64_t hwcap = aux.a_un.a_val;
- if (val == 0) {
- fclose(f);
- return 1;
+ has_msa = (hwcap >> 1) & 1;
+ break;
}
-
- i = 0;
- memset(word, 0, 10);
}
-
- fclose(f);
+ close(fd);
}
#ifdef PNG_WARNINGS_SUPPORTED
else
- png_warning(png_ptr, "/proc/cpuinfo open failed");
+ png_warning(png_ptr, "/proc/self/auxv open failed");
#endif
- return 0;
+
+ return has_msa;
}
diff --git a/Build/source/libs/libpng/libpng-src/contrib/pngminus/.gitignore b/Build/source/libs/libpng/libpng-src/contrib/pngminus/.gitignore
new file mode 100644
index 00000000000..5114c75cdf2
--- /dev/null
+++ b/Build/source/libs/libpng/libpng-src/contrib/pngminus/.gitignore
@@ -0,0 +1,11 @@
+# Compiled executables
+png2pnm
+png2pnm.exe
+png2pnm-static*
+pnm2png
+pnm2png.exe
+pnm2png-static*
+
+# Test artifacts
+*.png
+*.p[abgnp]m
diff --git a/Build/source/libs/libpng/libpng-src/contrib/pngminus/CHANGES.txt b/Build/source/libs/libpng/libpng-src/contrib/pngminus/CHANGES.txt
index 4e64e5ee614..85e590a4a24 100644
--- a/Build/source/libs/libpng/libpng-src/contrib/pngminus/CHANGES.txt
+++ b/Build/source/libs/libpng/libpng-src/contrib/pngminus/CHANGES.txt
@@ -3,7 +3,7 @@ pnm2png / png2pnm --- conversion from PBM/PGM/PPM-file to PNG-file
copyright (C) 1999-2019 by Willem van Schaik <willem at schaik dot com>
version 1.0 - 1999.10.15 - First version.
- 1.1 - 2015.07.29 - Fixed leaks (Glenn Randers-Pehrson)
+ 1.1 - 2015.07.29 - Fix memory leaks (Glenn Randers-Pehrson)
1.2 - 2017.04.22 - Add buffer-size check
1.3 - 2017.08.24 - Fix potential overflow in buffer-size check
(Glenn Randers-Pehrson)
@@ -11,3 +11,4 @@ version 1.0 - 1999.10.15 - First version.
1.5 - 2018.08.05 - Fix buffer overflow in tokenizer (Cosmin Truta)
1.6 - 2018.08.05 - Improve portability and fix style (Cosmin Truta)
1.7 - 2019.01.22 - Change license to MIT (Willem van Schaik)
+ 1.8 - 2024.01.09 - Fix, improve, modernize (Cosmin Truta)
diff --git a/Build/source/libs/libpng/libpng-src/contrib/pngminus/CMakeLists.txt b/Build/source/libs/libpng/libpng-src/contrib/pngminus/CMakeLists.txt
index 1f815a58251..d7893648a72 100644
--- a/Build/source/libs/libpng/libpng-src/contrib/pngminus/CMakeLists.txt
+++ b/Build/source/libs/libpng/libpng-src/contrib/pngminus/CMakeLists.txt
@@ -1,24 +1,41 @@
-cmake_minimum_required(VERSION 3.1)
-cmake_policy(VERSION 3.1)
+# Copyright (c) 2018-2024 Cosmin Truta
+#
+# This software is released under the MIT license. For conditions of
+# distribution and use, see the LICENSE file part of this package.
-project(PNGMINUS C)
+cmake_minimum_required(VERSION 3.5)
-option(PNGMINUS_USE_STATIC_LIBRARIES "Use the static library builds" ON)
+project(PNGMINUS C)
-# libpng
-add_subdirectory(../.. libpng)
-include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../..)
-include_directories(${CMAKE_CURRENT_BINARY_DIR}/libpng)
-if(PNGMINUS_USE_STATIC_LIBRARIES)
- set(PNGMINUS_PNG_LIBRARY png_static)
-else()
- set(PNGMINUS_PNG_LIBRARY png)
-endif()
+option(PNGMINUS_USE_SYSTEM_PNG
+ "Use the libpng build found in the system" OFF)
-# png2pnm
add_executable(png2pnm png2pnm.c)
-target_link_libraries(png2pnm ${PNGMINUS_PNG_LIBRARY})
-
-# pnm2png
add_executable(pnm2png pnm2png.c)
-target_link_libraries(pnm2png ${PNGMINUS_PNG_LIBRARY})
+
+if(PNGMINUS_USE_SYSTEM_PNG)
+ # Use the system libpng.
+ find_package(PNG REQUIRED)
+ target_link_libraries(png2pnm PRIVATE PNG::PNG)
+ target_link_libraries(pnm2png PRIVATE PNG::PNG)
+else()
+ # Build and use the internal libpng.
+ # Configure libpng for static linking, to produce single-file executables.
+ set(PNG_STATIC ON
+ CACHE STRING "Build the internal libpng as a static library" FORCE)
+ set(PNG_SHARED OFF
+ CACHE STRING "Build the internal libpng as a shared library" FORCE)
+ set(PNG_FRAMEWORK OFF
+ CACHE STRING "Build the internal libpng as a framework bundle" FORCE)
+ add_subdirectory(../.. libpng)
+ target_include_directories(png2pnm PRIVATE
+ "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../..>"
+ "$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/libpng>"
+ )
+ target_include_directories(pnm2png PRIVATE
+ "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../..>"
+ "$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/libpng>"
+ )
+ target_link_libraries(png2pnm PRIVATE png_static)
+ target_link_libraries(pnm2png PRIVATE png_static)
+endif()
diff --git a/Build/source/libs/libpng/libpng-src/contrib/pngminus/png2pnm.c b/Build/source/libs/libpng/libpng-src/contrib/pngminus/png2pnm.c
index 5fef7ed1425..f9d5138b7eb 100644
--- a/Build/source/libs/libpng/libpng-src/contrib/pngminus/png2pnm.c
+++ b/Build/source/libs/libpng/libpng-src/contrib/pngminus/png2pnm.c
@@ -14,15 +14,10 @@
#define BOOL unsigned char
#endif
#ifndef TRUE
-#define TRUE (BOOL) 1
+#define TRUE ((BOOL) 1)
#endif
#ifndef FALSE
-#define FALSE (BOOL) 0
-#endif
-
-/* make png2pnm verbose so we can find problems (needs to be before png.h) */
-#ifndef PNG_DEBUG
-#define PNG_DEBUG 0
+#define FALSE ((BOOL) 0)
#endif
#include "png.h"
@@ -33,6 +28,9 @@ int main (int argc, char *argv[]);
void usage ();
BOOL png2pnm (FILE *png_file, FILE *pnm_file, FILE *alpha_file,
BOOL raw, BOOL alpha);
+BOOL do_png2pnm (png_struct *png_ptr, png_info *info_ptr,
+ FILE *pnm_file, FILE *alpha_file,
+ BOOL raw, BOOL alpha);
/*
* main
@@ -43,9 +41,12 @@ int main (int argc, char *argv[])
FILE *fp_rd = stdin;
FILE *fp_wr = stdout;
FILE *fp_al = NULL;
+ const char *fname_wr = NULL;
+ const char *fname_al = NULL;
BOOL raw = TRUE;
BOOL alpha = FALSE;
int argi;
+ int ret;
for (argi = 1; argi < argc; argi++)
{
@@ -64,6 +65,7 @@ int main (int argc, char *argv[])
argi++;
if ((fp_al = fopen (argv[argi], "wb")) == NULL)
{
+ fname_al = argv[argi];
fprintf (stderr, "PNM2PNG\n");
fprintf (stderr, "Error: cannot create alpha-channel file %s\n",
argv[argi]);
@@ -94,6 +96,7 @@ int main (int argc, char *argv[])
}
else if (fp_wr == stdout)
{
+ fname_wr = argv[argi];
if ((fp_wr = fopen (argv[argi], "wb")) == NULL)
{
fprintf (stderr, "PNG2PNM\n");
@@ -119,12 +122,7 @@ int main (int argc, char *argv[])
#endif
/* call the conversion program itself */
- if (png2pnm (fp_rd, fp_wr, fp_al, raw, alpha) == FALSE)
- {
- fprintf (stderr, "PNG2PNM\n");
- fprintf (stderr, "Error: unsuccessful conversion of PNG-image\n");
- exit (1);
- }
+ ret = png2pnm (fp_rd, fp_wr, fp_al, raw, alpha);
/* close input file */
fclose (fp_rd);
@@ -134,6 +132,17 @@ int main (int argc, char *argv[])
if (alpha)
fclose (fp_al);
+ if (!ret)
+ {
+ fprintf (stderr, "PNG2PNM\n");
+ fprintf (stderr, "Error: unsuccessful conversion of PNG-image\n");
+ if (fname_wr)
+ remove (fname_wr); /* no broken output file shall remain behind */
+ if (fname_al)
+ remove (fname_al); /* ditto */
+ exit (1);
+ }
+
return 0;
}
@@ -163,35 +172,11 @@ void usage ()
BOOL png2pnm (FILE *png_file, FILE *pnm_file, FILE *alpha_file,
BOOL raw, BOOL alpha)
{
- png_struct *png_ptr = NULL;
- png_info *info_ptr = NULL;
- png_byte buf[8];
- png_byte *png_pixels = NULL;
- png_byte **row_pointers = NULL;
- png_byte *pix_ptr = NULL;
- png_uint_32 row_bytes;
+ png_struct *png_ptr;
+ png_info *info_ptr;
+ BOOL ret;
- png_uint_32 width;
- png_uint_32 height;
- int bit_depth;
- int channels;
- int color_type;
- int alpha_present;
- int row, col;
- int ret;
- int i;
- long dep_16;
-
- /* read and check signature in PNG file */
- ret = fread (buf, 1, 8, png_file);
- if (ret != 8)
- return FALSE;
-
- ret = png_sig_cmp (buf, 0, 8);
- if (ret != 0)
- return FALSE;
-
- /* create png and info structures */
+ /* initialize the libpng context for reading from png_file */
png_ptr = png_create_read_struct (png_get_libpng_ver(NULL),
NULL, NULL, NULL);
@@ -208,31 +193,47 @@ BOOL png2pnm (FILE *png_file, FILE *pnm_file, FILE *alpha_file,
if (setjmp (png_jmpbuf (png_ptr)))
{
png_destroy_read_struct (&png_ptr, &info_ptr, NULL);
- return FALSE;
+ return FALSE; /* generic libpng error */
}
- /* set up the input control for C streams */
png_init_io (png_ptr, png_file);
- png_set_sig_bytes (png_ptr, 8); /* we already read the 8 signature bytes */
- /* read the file information */
- png_read_info (png_ptr, info_ptr);
+ /* do the actual conversion */
+ ret = do_png2pnm (png_ptr, info_ptr, pnm_file, alpha_file, raw, alpha);
- /* get size and bit-depth of the PNG-image */
- png_get_IHDR (png_ptr, info_ptr, &width, &height, &bit_depth, &color_type,
- NULL, NULL, NULL);
+ /* clean up the libpng structures and their internally-managed data */
+ png_destroy_read_struct (&png_ptr, &info_ptr, NULL);
- /* set-up the transformations */
+ return ret;
+}
- /* transform paletted images into full-color rgb */
- if (color_type == PNG_COLOR_TYPE_PALETTE)
- png_set_expand (png_ptr);
- /* expand images to bit-depth 8 (only applicable for grayscale images) */
- if (color_type == PNG_COLOR_TYPE_GRAY && bit_depth < 8)
- png_set_expand (png_ptr);
- /* transform transparency maps into full alpha-channel */
- if (png_get_valid (png_ptr, info_ptr, PNG_INFO_tRNS))
- png_set_expand (png_ptr);
+/*
+ * do_png2pnm - does the conversion in a fully-initialized libpng context
+ */
+
+BOOL do_png2pnm (png_struct *png_ptr, png_info *info_ptr,
+ FILE *pnm_file, FILE *alpha_file,
+ BOOL raw, BOOL alpha)
+{
+ png_byte **row_pointers;
+ png_byte *pix_ptr;
+ png_uint_32 width;
+ png_uint_32 height;
+ int bit_depth;
+ int channels;
+ int color_type;
+ int alpha_present;
+ png_uint_32 row, col, i;
+ long dep_16;
+
+ /* set up the image transformations that are necessary for the PNM format */
+
+ /* set up (if applicable) the expansion of paletted images to full-color rgb,
+ * and the expansion of transparency maps to full alpha-channel */
+ png_set_expand (png_ptr);
+
+ /* set up (if applicable) the expansion of grayscale images to bit-depth 8 */
+ png_set_expand_gray_1_2_4_to_8 (png_ptr);
#ifdef NJET
/* downgrade 16-bit images to 8-bit */
@@ -242,30 +243,22 @@ BOOL png2pnm (FILE *png_file, FILE *pnm_file, FILE *alpha_file,
if (color_type == PNG_COLOR_TYPE_GRAY ||
color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
png_set_gray_to_rgb (png_ptr);
- /* only if file has a file gamma, we do a correction */
- if (png_get_gAMA (png_ptr, info_ptr, &file_gamma))
- png_set_gamma (png_ptr, (double) 2.2, file_gamma);
+ /* if the PNG image has a gAMA chunk then gamma-correct the output image */
+ {
+ double file_gamma;
+ if (png_get_gAMA (png_ptr, info_ptr, &file_gamma))
+ png_set_gamma (png_ptr, (double) 2.2, file_gamma);
+ }
#endif
- /* all transformations have been registered; now update info_ptr data,
- * get rowbytes and channels, and allocate image memory */
-
- png_read_update_info (png_ptr, info_ptr);
+ /* read the image file, with all of the above image transforms applied */
+ png_read_png (png_ptr, info_ptr, 0, NULL);
- /* get the new color-type and bit-depth (after expansion/stripping) */
+ /* get the image size, bit-depth and color-type */
png_get_IHDR (png_ptr, info_ptr, &width, &height, &bit_depth, &color_type,
NULL, NULL, NULL);
- /* check for 16-bit files */
- if (bit_depth == 16)
- {
- raw = FALSE;
-#if defined(O_BINARY) && (O_BINARY != 0)
- setmode (fileno (pnm_file), O_BINARY);
-#endif
- }
-
- /* calculate new number of channels and store alpha-presence */
+ /* calculate the number of channels and store alpha-presence */
if (color_type == PNG_COLOR_TYPE_GRAY)
channels = 1;
else if (color_type == PNG_COLOR_TYPE_GRAY_ALPHA)
@@ -282,47 +275,12 @@ BOOL png2pnm (FILE *png_file, FILE *pnm_file, FILE *alpha_file,
if (alpha && !alpha_present)
{
fprintf (stderr, "PNG2PNM\n");
- fprintf (stderr, "Error: PNG-file doesn't contain alpha channel\n");
- exit (1);
- }
-
- /* row_bytes is the width x number of channels x (bit-depth / 8) */
- row_bytes = png_get_rowbytes (png_ptr, info_ptr);
-
- if ((row_bytes == 0) ||
- ((size_t) height > (size_t) (-1) / (size_t) row_bytes))
- {
- /* too big */
- png_destroy_read_struct (&png_ptr, &info_ptr, NULL);
- return FALSE;
- }
- if ((png_pixels = (png_byte *)
- malloc ((size_t) row_bytes * (size_t) height)) == NULL)
- {
- png_destroy_read_struct (&png_ptr, &info_ptr, NULL);
- return FALSE;
- }
-
- if ((row_pointers = (png_byte **)
- malloc ((size_t) height * sizeof (png_byte *))) == NULL)
- {
- png_destroy_read_struct (&png_ptr, &info_ptr, NULL);
- free (png_pixels);
+ fprintf (stderr, "Warning: no alpha channel in PNG file\n");
return FALSE;
}
- /* set the individual row_pointers to point at the correct offsets */
- for (i = 0; i < ((int) height); i++)
- row_pointers[i] = png_pixels + i * row_bytes;
-
- /* now we can go ahead and just read the whole image */
- png_read_image (png_ptr, row_pointers);
-
- /* read rest of file, and get additional chunks in info_ptr - REQUIRED */
- png_read_end (png_ptr, info_ptr);
-
- /* clean up after the read, and free any memory allocated - REQUIRED */
- png_destroy_read_struct (&png_ptr, &info_ptr, NULL);
+ /* get address of internally-allocated image data */
+ row_pointers = png_get_rows (png_ptr, info_ptr);
/* write header of PNM file */
@@ -353,24 +311,27 @@ BOOL png2pnm (FILE *png_file, FILE *pnm_file, FILE *alpha_file,
}
/* write data to PNM file */
- pix_ptr = png_pixels;
- for (row = 0; row < (int) height; row++)
+ for (row = 0; row < height; row++)
{
- for (col = 0; col < (int) width; col++)
+ pix_ptr = row_pointers[row];
+ for (col = 0; col < width; col++)
{
- for (i = 0; i < (channels - alpha_present); i++)
+ for (i = 0; i < (png_uint_32) (channels - alpha_present); i++)
{
if (raw)
{
fputc ((int) *pix_ptr++, pnm_file);
+ if (bit_depth == 16)
+ fputc ((int) *pix_ptr++, pnm_file);
}
else
{
if (bit_depth == 16)
{
- dep_16 = (long) *pix_ptr++;
- fprintf (pnm_file, "%ld ", (dep_16 << 8) + ((long) *pix_ptr++));
+ dep_16 = ((long) *pix_ptr++) << 8;
+ dep_16 += ((long) *pix_ptr++);
+ fprintf (pnm_file, "%ld ", dep_16);
}
else
{
@@ -382,22 +343,27 @@ BOOL png2pnm (FILE *png_file, FILE *pnm_file, FILE *alpha_file,
{
if (!alpha)
{
- pix_ptr++; /* alpha */
+ /* skip the alpha-channel */
+ pix_ptr++;
if (bit_depth == 16)
pix_ptr++;
}
- else /* output alpha-channel as pgm file */
+ else
{
+ /* output the alpha-channel as pgm file */
if (raw)
{
fputc ((int) *pix_ptr++, alpha_file);
+ if (bit_depth == 16)
+ fputc ((int) *pix_ptr++, alpha_file);
}
else
{
if (bit_depth == 16)
{
- dep_16 = (long) *pix_ptr++;
- fprintf (alpha_file, "%ld ", (dep_16 << 8) + (long) *pix_ptr++);
+ dep_16 = ((long) *pix_ptr++) << 8;
+ dep_16 += ((long) *pix_ptr++);
+ fprintf (alpha_file, "%ld ", dep_16);
}
else
{
@@ -417,11 +383,5 @@ BOOL png2pnm (FILE *png_file, FILE *pnm_file, FILE *alpha_file,
fprintf (pnm_file, "\n");
} /* end for row */
- if (row_pointers != NULL)
- free (row_pointers);
- if (png_pixels != NULL)
- free (png_pixels);
-
return TRUE;
-
} /* end of source */
diff --git a/Build/source/libs/libpng/libpng-src/contrib/pngminus/pnm2png.c b/Build/source/libs/libpng/libpng-src/contrib/pngminus/pnm2png.c
index a2c2551da92..052fd3272c8 100644
--- a/Build/source/libs/libpng/libpng-src/contrib/pngminus/pnm2png.c
+++ b/Build/source/libs/libpng/libpng-src/contrib/pngminus/pnm2png.c
@@ -6,6 +6,7 @@
* distribution and use, see the LICENSE file part of this package.
*/
+#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
@@ -14,15 +15,10 @@
#define BOOL unsigned char
#endif
#ifndef TRUE
-#define TRUE (BOOL) 1
+#define TRUE ((BOOL) 1)
#endif
#ifndef FALSE
-#define FALSE (BOOL) 0
-#endif
-
-/* make pnm2png verbose so we can find problems (needs to be before png.h) */
-#ifndef PNG_DEBUG
-#define PNG_DEBUG 0
+#define FALSE ((BOOL) 0)
#endif
#include "png.h"
@@ -33,9 +29,14 @@ int main (int argc, char *argv[]);
void usage ();
BOOL pnm2png (FILE *pnm_file, FILE *png_file, FILE *alpha_file,
BOOL interlace, BOOL alpha);
-void get_token (FILE *pnm_file, char *token_buf, size_t token_buf_size);
-png_uint_32 get_data (FILE *pnm_file, int depth);
-png_uint_32 get_value (FILE *pnm_file, int depth);
+BOOL do_pnm2png (png_struct *png_ptr, png_info *info_ptr,
+ FILE *pnm_file, FILE *alpha_file,
+ BOOL interlace, BOOL alpha);
+int fscan_pnm_magic (FILE *pnm_file, char *magic_buf, size_t magic_buf_size);
+int fscan_pnm_token (FILE *pnm_file, char *token_buf, size_t token_buf_size);
+int fscan_pnm_uint_32 (FILE *pnm_file, png_uint_32 *num_ptr);
+png_uint_32 get_pnm_data (FILE *pnm_file, int depth);
+png_uint_32 get_pnm_value (FILE *pnm_file, int depth);
/*
* main
@@ -46,9 +47,11 @@ int main (int argc, char *argv[])
FILE *fp_rd = stdin;
FILE *fp_al = NULL;
FILE *fp_wr = stdout;
+ const char *fname_wr = NULL;
BOOL interlace = FALSE;
BOOL alpha = FALSE;
int argi;
+ int ret;
for (argi = 1; argi < argc; argi++)
{
@@ -94,6 +97,7 @@ int main (int argc, char *argv[])
}
else if (fp_wr == stdout)
{
+ fname_wr = argv[argi];
if ((fp_wr = fopen (argv[argi], "wb")) == NULL)
{
fprintf (stderr, "PNM2PNG\n");
@@ -121,12 +125,7 @@ int main (int argc, char *argv[])
#endif
/* call the conversion program itself */
- if (pnm2png (fp_rd, fp_wr, fp_al, interlace, alpha) == FALSE)
- {
- fprintf (stderr, "PNM2PNG\n");
- fprintf (stderr, "Error: unsuccessful converting to PNG-image\n");
- exit (1);
- }
+ ret = pnm2png (fp_rd, fp_wr, fp_al, interlace, alpha);
/* close input file */
fclose (fp_rd);
@@ -136,6 +135,15 @@ int main (int argc, char *argv[])
if (alpha)
fclose (fp_al);
+ if (!ret)
+ {
+ fprintf (stderr, "PNM2PNG\n");
+ fprintf (stderr, "Error: unsuccessful converting to PNG-image\n");
+ if (fname_wr)
+ remove (fname_wr); /* no broken output file shall remain behind */
+ exit (1);
+ }
+
return 0;
}
@@ -163,77 +171,98 @@ void usage ()
BOOL pnm2png (FILE *pnm_file, FILE *png_file, FILE *alpha_file,
BOOL interlace, BOOL alpha)
{
- png_struct *png_ptr = NULL;
- png_info *info_ptr = NULL;
- png_byte *png_pixels = NULL;
- png_byte **row_pointers = NULL;
- png_byte *pix_ptr = NULL;
- volatile png_uint_32 row_bytes;
-
- char type_token[16];
- char width_token[16];
- char height_token[16];
- char maxval_token[16];
- volatile int color_type = 1;
- unsigned long ul_width = 0, ul_alpha_width = 0;
- unsigned long ul_height = 0, ul_alpha_height = 0;
- unsigned long ul_maxval = 0;
- volatile png_uint_32 width = 0, height = 0;
- volatile png_uint_32 alpha_width = 0, alpha_height = 0;
- png_uint_32 maxval;
- volatile int bit_depth = 0;
- int channels = 0;
- int alpha_depth = 0;
- int alpha_present = 0;
- int row, col;
- BOOL raw, alpha_raw = FALSE;
-#if defined(PNG_WRITE_INVERT_SUPPORTED) || defined(PNG_WRITE_PACK_SUPPORTED)
+ png_struct *png_ptr;
+ png_info *info_ptr;
+ BOOL ret;
+
+ /* initialize the libpng context for writing to png_file */
+
+ png_ptr = png_create_write_struct (png_get_libpng_ver(NULL),
+ NULL, NULL, NULL);
+ if (!png_ptr)
+ return FALSE; /* out of memory */
+
+ info_ptr = png_create_info_struct (png_ptr);
+ if (!info_ptr)
+ {
+ png_destroy_write_struct (&png_ptr, NULL);
+ return FALSE; /* out of memory */
+ }
+
+ if (setjmp (png_jmpbuf (png_ptr)))
+ {
+ png_destroy_write_struct (&png_ptr, &info_ptr);
+ return FALSE; /* generic libpng error */
+ }
+
+ png_init_io (png_ptr, png_file);
+
+ /* do the actual conversion */
+ ret = do_pnm2png (png_ptr, info_ptr, pnm_file, alpha_file, interlace, alpha);
+
+ /* clean up the libpng structures and their internally-managed data */
+ png_destroy_write_struct (&png_ptr, &info_ptr);
+
+ return ret;
+}
+
+/*
+ * do_pnm2png - does the conversion in a fully-initialized libpng context
+ */
+
+BOOL do_pnm2png (png_struct *png_ptr, png_info *info_ptr,
+ FILE *pnm_file, FILE *alpha_file,
+ BOOL interlace, BOOL alpha)
+{
+ png_byte **row_pointers;
+ png_byte *pix_ptr;
+ int bit_depth;
+ int color_type;
+ int channels;
+ char magic_token[4];
+ BOOL raw;
+ png_uint_32 width, height, maxval;
+ png_uint_32 row_bytes;
+ png_uint_32 row, col;
+ png_uint_32 val16, i;
+ png_uint_32 alpha_width = 0, alpha_height = 0;
+ int alpha_depth = 0, alpha_present = 0;
+ BOOL alpha_raw = FALSE;
BOOL packed_bitmap = FALSE;
-#endif
- png_uint_32 tmp16;
- int i;
/* read header of PNM file */
- get_token (pnm_file, type_token, sizeof (type_token));
- if (type_token[0] != 'P')
+ if (fscan_pnm_magic (pnm_file, magic_token, sizeof (magic_token)) != 1)
+ return FALSE; /* not a PNM file */
+
+ if ((magic_token[1] == '1') || (magic_token[1] == '4'))
{
- return FALSE;
+ if ((fscan_pnm_uint_32 (pnm_file, &width) != 1) ||
+ (fscan_pnm_uint_32 (pnm_file, &height) != 1))
+ return FALSE; /* bad PBM file header */
+ } else if ((magic_token[1] == '2') || (magic_token[1] == '5') ||
+ (magic_token[1] == '3') || (magic_token[1] == '6'))
+ {
+ if ((fscan_pnm_uint_32 (pnm_file, &width) != 1) ||
+ (fscan_pnm_uint_32 (pnm_file, &height) != 1) ||
+ (fscan_pnm_uint_32 (pnm_file, &maxval) != 1))
+ return FALSE; /* bad PGM/PPM file header */
}
- else if ((type_token[1] == '1') || (type_token[1] == '4'))
+
+ if ((magic_token[1] == '1') || (magic_token[1] == '4'))
{
-#if defined(PNG_WRITE_INVERT_SUPPORTED) || defined(PNG_WRITE_PACK_SUPPORTED)
- raw = (type_token[1] == '4');
- color_type = PNG_COLOR_TYPE_GRAY;
- get_token (pnm_file, width_token, sizeof (width_token));
- sscanf (width_token, "%lu", &ul_width);
- width = (png_uint_32) ul_width;
- get_token (pnm_file, height_token, sizeof (height_token));
- sscanf (height_token, "%lu", &ul_height);
- height = (png_uint_32) ul_height;
+ raw = (magic_token[1] == '4');
bit_depth = 1;
+ color_type = PNG_COLOR_TYPE_GRAY;
packed_bitmap = TRUE;
-#else
- fprintf (stderr, "PNM2PNG built without PNG_WRITE_INVERT_SUPPORTED and\n");
- fprintf (stderr, "PNG_WRITE_PACK_SUPPORTED can't read PBM (P1,P4) files\n");
- return FALSE;
-#endif
}
- else if ((type_token[1] == '2') || (type_token[1] == '5'))
+ else if ((magic_token[1] == '2') || (magic_token[1] == '5'))
{
- raw = (type_token[1] == '5');
+ raw = (magic_token[1] == '5');
color_type = PNG_COLOR_TYPE_GRAY;
- get_token (pnm_file, width_token, sizeof (width_token));
- sscanf (width_token, "%lu", &ul_width);
- width = (png_uint_32) ul_width;
- get_token (pnm_file, height_token, sizeof (height_token));
- sscanf (height_token, "%lu", &ul_height);
- height = (png_uint_32) ul_height;
- get_token (pnm_file, maxval_token, sizeof (maxval_token));
- sscanf (maxval_token, "%lu", &ul_maxval);
- maxval = (png_uint_32) ul_maxval;
-
- if (maxval <= 1)
+ if (maxval == 0)
+ return FALSE;
+ else if (maxval == 1)
bit_depth = 1;
else if (maxval <= 3)
bit_depth = 2;
@@ -246,20 +275,13 @@ BOOL pnm2png (FILE *pnm_file, FILE *png_file, FILE *alpha_file,
else /* maxval > 65535U */
return FALSE;
}
- else if ((type_token[1] == '3') || (type_token[1] == '6'))
+ else if ((magic_token[1] == '3') || (magic_token[1] == '6'))
{
- raw = (type_token[1] == '6');
+ raw = (magic_token[1] == '6');
color_type = PNG_COLOR_TYPE_RGB;
- get_token (pnm_file, width_token, sizeof (width_token));
- sscanf (width_token, "%lu", &ul_width);
- width = (png_uint_32) ul_width;
- get_token (pnm_file, height_token, sizeof (height_token));
- sscanf (height_token, "%lu", &ul_height);
- height = (png_uint_32) ul_height;
- get_token (pnm_file, maxval_token, sizeof (maxval_token));
- sscanf (maxval_token, "%lu", &ul_maxval);
- maxval = (png_uint_32) ul_maxval;
- if (maxval <= 1)
+ if (maxval == 0)
+ return FALSE;
+ else if (maxval == 1)
bit_depth = 1;
else if (maxval <= 3)
bit_depth = 2;
@@ -272,6 +294,11 @@ BOOL pnm2png (FILE *pnm_file, FILE *png_file, FILE *alpha_file,
else /* maxval > 65535U */
return FALSE;
}
+ else if (magic_token[1] == '7')
+ {
+ fprintf (stderr, "PNM2PNG can't read PAM (P7) files\n");
+ return FALSE;
+ }
else
{
return FALSE;
@@ -281,51 +308,36 @@ BOOL pnm2png (FILE *pnm_file, FILE *png_file, FILE *alpha_file,
if (alpha)
{
- if (color_type == PNG_COLOR_TYPE_GRAY)
- color_type = PNG_COLOR_TYPE_GRAY_ALPHA;
- if (color_type == PNG_COLOR_TYPE_RGB)
- color_type = PNG_COLOR_TYPE_RGB_ALPHA;
+ if ((fscan_pnm_magic (alpha_file, magic_token, sizeof (magic_token)) != 1)
+ || ((magic_token[1] != '2') && (magic_token[1] != '5')))
+ return FALSE; /* not a PGM file */
- get_token (alpha_file, type_token, sizeof (type_token));
- if (type_token[0] != 'P')
- {
+ if ((fscan_pnm_uint_32 (alpha_file, &alpha_width) != 1) ||
+ (fscan_pnm_uint_32 (alpha_file, &alpha_height) != 1) ||
+ (fscan_pnm_uint_32 (alpha_file, &maxval) != 1))
+ return FALSE; /* bad PGM file header */
+
+ if ((alpha_width != width) || (alpha_height != height))
+ return FALSE; /* mismatched PGM dimensions */
+
+ alpha_raw = (magic_token[1] == '5');
+ color_type |= PNG_COLOR_MASK_ALPHA;
+ if (maxval == 0)
return FALSE;
- }
- else if ((type_token[1] == '2') || (type_token[1] == '5'))
- {
- alpha_raw = (type_token[1] == '5');
- get_token (alpha_file, width_token, sizeof (width_token));
- sscanf (width_token, "%lu", &ul_alpha_width);
- alpha_width = (png_uint_32) ul_alpha_width;
- if (alpha_width != width)
- return FALSE;
- get_token (alpha_file, height_token, sizeof (height_token));
- sscanf (height_token, "%lu", &ul_alpha_height);
- alpha_height = (png_uint_32) ul_alpha_height;
- if (alpha_height != height)
- return FALSE;
- get_token (alpha_file, maxval_token, sizeof (maxval_token));
- sscanf (maxval_token, "%lu", &ul_maxval);
- maxval = (png_uint_32) ul_maxval;
- if (maxval <= 1)
- alpha_depth = 1;
- else if (maxval <= 3)
- alpha_depth = 2;
- else if (maxval <= 15)
- alpha_depth = 4;
- else if (maxval <= 255)
- alpha_depth = 8;
- else if (maxval <= 65535U)
- alpha_depth = 16;
- else /* maxval > 65535U */
- return FALSE;
- if (alpha_depth != bit_depth)
- return FALSE;
- }
- else
- {
+ else if (maxval == 1)
+ alpha_depth = 1;
+ else if (maxval <= 3)
+ alpha_depth = 2;
+ else if (maxval <= 15)
+ alpha_depth = 4;
+ else if (maxval <= 255)
+ alpha_depth = 8;
+ else if (maxval <= 65535U)
+ alpha_depth = 16;
+ else /* maxval > 65535U */
+ return FALSE;
+ if (alpha_depth != bit_depth)
return FALSE;
- }
} /* end if alpha */
/* calculate the number of channels and store alpha-presence */
@@ -337,21 +349,17 @@ BOOL pnm2png (FILE *pnm_file, FILE *png_file, FILE *alpha_file,
channels = 3;
else if (color_type == PNG_COLOR_TYPE_RGB_ALPHA)
channels = 4;
-#if 0
else
- channels = 0; /* cannot happen */
-#endif
+ return FALSE; /* NOTREACHED */
alpha_present = (channels - 1) % 2;
-#if defined(PNG_WRITE_INVERT_SUPPORTED) || defined(PNG_WRITE_PACK_SUPPORTED)
if (packed_bitmap)
{
/* row data is as many bytes as can fit width x channels x bit_depth */
row_bytes = (width * channels * bit_depth + 7) / 8;
}
else
-#endif
{
/* row_bytes is the width x number of channels x (bit-depth / 8) */
row_bytes = width * channels * ((bit_depth <= 8) ? 1 : 2);
@@ -363,50 +371,59 @@ BOOL pnm2png (FILE *pnm_file, FILE *png_file, FILE *alpha_file,
/* too big */
return FALSE;
}
- if ((png_pixels = (png_byte *)
- malloc ((size_t) row_bytes * (size_t) height)) == NULL)
+
+ /* allocate the rows using the same memory layout as libpng, and transfer
+ * their ownership to libpng, with the responsibility to clean everything up;
+ * please note the use of png_calloc instead of png_malloc */
+ row_pointers = (png_byte **)
+ png_calloc (png_ptr, height * sizeof (png_byte *));
+ png_set_rows (png_ptr, info_ptr, row_pointers);
+ png_data_freer (png_ptr, info_ptr, PNG_DESTROY_WILL_FREE_DATA, PNG_FREE_ALL);
+ for (row = 0; row < height; row++)
{
- /* out of memory */
- return FALSE;
+ /* the individual rows should only be allocated after all the previous
+ * steps completed successfully, because libpng must handle correctly
+ * any image allocation left incomplete after an out-of-memory error */
+ row_pointers[row] = (png_byte *) png_malloc (png_ptr, row_bytes);
}
- /* read data from PNM file */
- pix_ptr = png_pixels;
+ /* read the data from PNM file */
- for (row = 0; row < (int) height; row++)
+ for (row = 0; row < height; row++)
{
-#if defined(PNG_WRITE_INVERT_SUPPORTED) || defined(PNG_WRITE_PACK_SUPPORTED)
+ pix_ptr = row_pointers[row];
if (packed_bitmap)
{
- for (i = 0; i < (int) row_bytes; i++)
+ for (i = 0; i < row_bytes; i++)
{
/* png supports this format natively so no conversion is needed */
- *pix_ptr++ = get_data (pnm_file, 8);
+ *pix_ptr++ = get_pnm_data (pnm_file, 8);
}
}
else
-#endif
{
- for (col = 0; col < (int) width; col++)
+ for (col = 0; col < width; col++)
{
- for (i = 0; i < (channels - alpha_present); i++)
+ for (i = 0; i < (png_uint_32) (channels - alpha_present); i++)
{
if (raw)
{
- *pix_ptr++ = get_data (pnm_file, bit_depth);
+ *pix_ptr++ = get_pnm_data (pnm_file, bit_depth);
+ if (bit_depth == 16)
+ *pix_ptr++ = get_pnm_data (pnm_file, bit_depth);
}
else
{
if (bit_depth <= 8)
{
- *pix_ptr++ = get_value (pnm_file, bit_depth);
+ *pix_ptr++ = get_pnm_value (pnm_file, bit_depth);
}
else
{
- tmp16 = get_value (pnm_file, bit_depth);
- *pix_ptr = (png_byte) ((tmp16 >> 8) & 0xFF);
+ val16 = get_pnm_value (pnm_file, bit_depth);
+ *pix_ptr = (png_byte) ((val16 >> 8) & 0xFF);
pix_ptr++;
- *pix_ptr = (png_byte) (tmp16 & 0xFF);
+ *pix_ptr = (png_byte) (val16 & 0xFF);
pix_ptr++;
}
}
@@ -416,19 +433,21 @@ BOOL pnm2png (FILE *pnm_file, FILE *png_file, FILE *alpha_file,
{
if (alpha_raw)
{
- *pix_ptr++ = get_data (alpha_file, alpha_depth);
+ *pix_ptr++ = get_pnm_data (alpha_file, alpha_depth);
+ if (alpha_depth == 16)
+ *pix_ptr++ = get_pnm_data (alpha_file, alpha_depth);
}
else
{
if (alpha_depth <= 8)
{
- *pix_ptr++ = get_value (alpha_file, bit_depth);
+ *pix_ptr++ = get_pnm_value (alpha_file, bit_depth);
}
else
{
- tmp16 = get_value (alpha_file, bit_depth);
- *pix_ptr++ = (png_byte) ((tmp16 >> 8) & 0xFF);
- *pix_ptr++ = (png_byte) (tmp16 & 0xFF);
+ val16 = get_pnm_value (alpha_file, bit_depth);
+ *pix_ptr++ = (png_byte) ((val16 >> 8) & 0xFF);
+ *pix_ptr++ = (png_byte) (val16 & 0xFF);
}
}
} /* end if alpha */
@@ -436,86 +455,66 @@ BOOL pnm2png (FILE *pnm_file, FILE *png_file, FILE *alpha_file,
} /* end for col */
} /* end for row */
- /* prepare the standard PNG structures */
- png_ptr = png_create_write_struct (png_get_libpng_ver(NULL),
- NULL, NULL, NULL);
- if (!png_ptr)
- {
- free (png_pixels);
- return FALSE;
- }
- info_ptr = png_create_info_struct (png_ptr);
- if (!info_ptr)
- {
- png_destroy_write_struct (&png_ptr, NULL);
- free (png_pixels);
- return FALSE;
- }
+ /* we're going to write more or less the same PNG as the input file */
+ png_set_IHDR (png_ptr, info_ptr, width, height, bit_depth, color_type,
+ (!interlace) ? PNG_INTERLACE_NONE : PNG_INTERLACE_ADAM7,
+ PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE);
-#if defined(PNG_WRITE_INVERT_SUPPORTED) || defined(PNG_WRITE_PACK_SUPPORTED)
if (packed_bitmap == TRUE)
{
png_set_packing (png_ptr);
png_set_invert_mono (png_ptr);
}
-#endif
-
- if (setjmp (png_jmpbuf (png_ptr)))
- {
- png_destroy_write_struct (&png_ptr, &info_ptr);
- free (png_pixels);
- return FALSE;
- }
-
- /* initialize the png structure */
- png_init_io (png_ptr, png_file);
-
- /* we're going to write more or less the same PNG as the input file */
- png_set_IHDR (png_ptr, info_ptr, width, height, bit_depth, color_type,
- (!interlace) ? PNG_INTERLACE_NONE : PNG_INTERLACE_ADAM7,
- PNG_COMPRESSION_TYPE_BASE, PNG_FILTER_TYPE_BASE);
/* write the file header information */
png_write_info (png_ptr, info_ptr);
- /* if needed we will allocate memory for an new array of row-pointers */
- if (row_pointers == NULL)
- {
- if ((row_pointers = (png_byte **)
- malloc (height * sizeof (png_byte *))) == NULL)
- {
- png_destroy_write_struct (&png_ptr, &info_ptr);
- free (png_pixels);
- return FALSE;
- }
- }
-
- /* set the individual row_pointers to point at the correct offsets */
- for (i = 0; i < (int) height; i++)
- row_pointers[i] = png_pixels + i * row_bytes;
-
/* write out the entire image data in one call */
png_write_image (png_ptr, row_pointers);
/* write the additional chunks to the PNG file (not really needed) */
png_write_end (png_ptr, info_ptr);
- /* clean up after the write, and free any memory allocated */
- png_destroy_write_struct (&png_ptr, &info_ptr);
-
- if (row_pointers != NULL)
- free (row_pointers);
- if (png_pixels != NULL)
- free (png_pixels);
-
return TRUE;
} /* end of pnm2png */
/*
- * get_token - gets the first string after whitespace
+ * fscan_pnm_magic - like fscan_pnm_token below, but expects the magic string
+ * to start immediately, without any comment or whitespace,
+ * and to match the regex /^P[1-9]$/
*/
-void get_token (FILE *pnm_file, char *token_buf, size_t token_buf_size)
+int fscan_pnm_magic (FILE *pnm_file, char *magic_buf, size_t magic_buf_size)
+{
+ int ret;
+
+ ret = fgetc (pnm_file);
+ if (ret == EOF) return 0;
+ ungetc (ret, pnm_file);
+ if (ret != 'P') return 0;
+
+ /* the string buffer must be at least four bytes long, i.e., the capacity
+ * required for strings of at least three characters long, i.e., the minimum
+ * required for ensuring that our magic string is exactly two characters long
+ */
+ if (magic_buf_size < 4) return -1;
+
+ ret = fscan_pnm_token (pnm_file, magic_buf, magic_buf_size);
+ if (ret < 1) return ret;
+
+ if ((magic_buf[1] < '1') || (magic_buf[1] > '9')) return 0;
+ if (magic_buf[2] != '\0') return 0;
+
+ return 1;
+}
+
+/*
+ * fscan_pnm_token - extracts the first string token after whitespace,
+ * and (like fscanf) returns the number of successful
+ * extractions, which can be either 0 or 1
+ */
+
+int fscan_pnm_token (FILE *pnm_file, char *token_buf, size_t token_buf_size)
{
size_t i = 0;
int ret;
@@ -543,29 +542,66 @@ void get_token (FILE *pnm_file, char *token_buf, size_t token_buf_size)
{
ret = fgetc (pnm_file);
if (ret == EOF) break;
+ if (ret == '0')
+ {
+ /* avoid storing more than one leading '0' in the token buffer,
+ * to ensure that all valid (in-range) numeric inputs can fit in. */
+ if ((i == 0) && (token_buf[i] == '0')) continue;
+ }
if (++i == token_buf_size - 1) break;
token_buf[i] = (char) ret;
}
while ((ret != '\n') && (ret != '\r') && (ret != ' '));
token_buf[i] = '\0';
+ return (i > 0) ? 1 : 0;
+}
- return;
+/*
+ * fscan_pnm_uint_32 - like fscan_token above, but expects the extracted token
+ * to be numeric, and converts it to an unsigned 32-bit int
+ */
+
+int fscan_pnm_uint_32 (FILE *pnm_file, png_uint_32 *num_ptr)
+{
+ char token[16];
+ unsigned long token_value;
+ int ret;
+
+ ret = fscan_pnm_token (pnm_file, token, sizeof (token));
+ if (ret < 1) return ret;
+
+ if ((token[0] < '0') && (token[0] > '9'))
+ return 0; /* the token starts with junk, or a +/- sign, which is invalid */
+
+ ret = sscanf (token, "%lu%*c", &token_value);
+ if (ret != 1)
+ return 0; /* the token ends with junk */
+
+ *num_ptr = (png_uint_32) token_value;
+
+#if ULONG_MAX > 0xFFFFFFFFUL
+ /* saturate the converted number, following the fscanf convention */
+ if (token_value > 0xFFFFFFFFUL)
+ *num_ptr = 0xFFFFFFFFUL;
+#endif
+
+ return 1;
}
/*
- * get_data - takes first byte and converts into next pixel value,
- * taking as much bits as defined by bit-depth and
- * using the bit-depth to fill up a byte (0Ah -> AAh)
+ * get_pnm_data - takes first byte and converts into next pixel value,
+ * taking as many bits as defined by bit-depth and
+ * using the bit-depth to fill up a byte (0x0A -> 0xAA)
*/
-png_uint_32 get_data (FILE *pnm_file, int depth)
+png_uint_32 get_pnm_data (FILE *pnm_file, int depth)
{
static int bits_left = 0;
static int old_value = 0;
static int mask = 0;
- int i;
png_uint_32 ret_value;
+ int i;
if (mask == 0)
for (i = 0; i < depth; i++)
@@ -573,7 +609,11 @@ png_uint_32 get_data (FILE *pnm_file, int depth)
if (bits_left <= 0)
{
+ /* FIXME:
+ * signal the premature end of file, instead of pretending to read zeroes
+ */
old_value = fgetc (pnm_file);
+ if (old_value == EOF) return 0;
bits_left = 8;
}
@@ -588,25 +628,28 @@ png_uint_32 get_data (FILE *pnm_file, int depth)
}
/*
- * get_value - takes first (numeric) string and converts into number,
- * using the bit-depth to fill up a byte (0Ah -> AAh)
+ * get_pnm_value - takes first (numeric) string and converts into number,
+ * using the bit-depth to fill up a byte (0x0A -> 0xAA)
*/
-png_uint_32 get_value (FILE *pnm_file, int depth)
+png_uint_32 get_pnm_value (FILE *pnm_file, int depth)
{
static png_uint_32 mask = 0;
- char token[16];
- unsigned long ul_ret_value;
png_uint_32 ret_value;
- int i = 0;
+ int i;
if (mask == 0)
for (i = 0; i < depth; i++)
mask = (mask << 1) | 0x01;
- get_token (pnm_file, token, sizeof (token));
- sscanf (token, "%lu", &ul_ret_value);
- ret_value = (png_uint_32) ul_ret_value;
+ if (fscan_pnm_uint_32 (pnm_file, &ret_value) != 1)
+ {
+ /* FIXME:
+ * signal the invalid numeric tokens or the premature end of file,
+ * instead of pretending to read zeroes
+ */
+ return 0;
+ }
ret_value &= mask;
diff --git a/Build/source/libs/libpng/libpng-src/contrib/pngminus/png2pnm.bat b/Build/source/libs/libpng/libpng-src/contrib/pngminus/test_png2pnm.bat
index a2798c34032..a2798c34032 100644
--- a/Build/source/libs/libpng/libpng-src/contrib/pngminus/png2pnm.bat
+++ b/Build/source/libs/libpng/libpng-src/contrib/pngminus/test_png2pnm.bat
diff --git a/Build/source/libs/libpng/libpng-src/contrib/pngminus/png2pnm.sh b/Build/source/libs/libpng/libpng-src/contrib/pngminus/test_png2pnm.sh
index 756126a53c2..756126a53c2 100755..100644
--- a/Build/source/libs/libpng/libpng-src/contrib/pngminus/png2pnm.sh
+++ b/Build/source/libs/libpng/libpng-src/contrib/pngminus/test_png2pnm.sh
diff --git a/Build/source/libs/libpng/libpng-src/contrib/pngminus/pngminus.bat b/Build/source/libs/libpng/libpng-src/contrib/pngminus/test_pngminus.bat
index fa60e7de07f..fa60e7de07f 100644
--- a/Build/source/libs/libpng/libpng-src/contrib/pngminus/pngminus.bat
+++ b/Build/source/libs/libpng/libpng-src/contrib/pngminus/test_pngminus.bat
diff --git a/Build/source/libs/libpng/libpng-src/contrib/pngminus/pngminus.sh b/Build/source/libs/libpng/libpng-src/contrib/pngminus/test_pngminus.sh
index cc9b4a56e37..cc9b4a56e37 100755..100644
--- a/Build/source/libs/libpng/libpng-src/contrib/pngminus/pngminus.sh
+++ b/Build/source/libs/libpng/libpng-src/contrib/pngminus/test_pngminus.sh
diff --git a/Build/source/libs/libpng/libpng-src/contrib/pngminus/pnm2png.bat b/Build/source/libs/libpng/libpng-src/contrib/pngminus/test_pnm2png.bat
index c02b80beccd..c02b80beccd 100644
--- a/Build/source/libs/libpng/libpng-src/contrib/pngminus/pnm2png.bat
+++ b/Build/source/libs/libpng/libpng-src/contrib/pngminus/test_pnm2png.bat
diff --git a/Build/source/libs/libpng/libpng-src/contrib/pngminus/pnm2png.sh b/Build/source/libs/libpng/libpng-src/contrib/pngminus/test_pnm2png.sh
index 2ad17a608c9..2ad17a608c9 100755..100644
--- a/Build/source/libs/libpng/libpng-src/contrib/pngminus/pnm2png.sh
+++ b/Build/source/libs/libpng/libpng-src/contrib/pngminus/test_pnm2png.sh
diff --git a/Build/source/libs/libpng/libpng-src/contrib/testpngs/badpal/regression-palette-8.png b/Build/source/libs/libpng/libpng-src/contrib/testpngs/badpal/regression-palette-8.png
new file mode 100644
index 00000000000..dcb88b6ec41
--- /dev/null
+++ b/Build/source/libs/libpng/libpng-src/contrib/testpngs/badpal/regression-palette-8.png
Binary files differ
diff --git a/Build/source/libs/libpng/libpng-src/contrib/testpngs/badpal/small-palette-1.png b/Build/source/libs/libpng/libpng-src/contrib/testpngs/badpal/small-palette-1.png
new file mode 100644
index 00000000000..7e9dbfd095b
--- /dev/null
+++ b/Build/source/libs/libpng/libpng-src/contrib/testpngs/badpal/small-palette-1.png
Binary files differ
diff --git a/Build/source/libs/libpng/libpng-src/contrib/testpngs/badpal/small-palette-2.png b/Build/source/libs/libpng/libpng-src/contrib/testpngs/badpal/small-palette-2.png
new file mode 100644
index 00000000000..6629164d709
--- /dev/null
+++ b/Build/source/libs/libpng/libpng-src/contrib/testpngs/badpal/small-palette-2.png
Binary files differ
diff --git a/Build/source/libs/libpng/libpng-src/contrib/testpngs/badpal/small-palette-4.png b/Build/source/libs/libpng/libpng-src/contrib/testpngs/badpal/small-palette-4.png
new file mode 100644
index 00000000000..7401dc70b1f
--- /dev/null
+++ b/Build/source/libs/libpng/libpng-src/contrib/testpngs/badpal/small-palette-4.png
Binary files differ
diff --git a/Build/source/libs/libpng/libpng-src/contrib/testpngs/badpal/small-palette-8.png b/Build/source/libs/libpng/libpng-src/contrib/testpngs/badpal/small-palette-8.png
new file mode 100644
index 00000000000..a4533871314
--- /dev/null
+++ b/Build/source/libs/libpng/libpng-src/contrib/testpngs/badpal/small-palette-8.png
Binary files differ
diff --git a/Build/source/libs/libpng/libpng-src/contrib/testpngs/badpal/test-palette-1.png b/Build/source/libs/libpng/libpng-src/contrib/testpngs/badpal/test-palette-1.png
new file mode 100644
index 00000000000..614fd97bba7
--- /dev/null
+++ b/Build/source/libs/libpng/libpng-src/contrib/testpngs/badpal/test-palette-1.png
Binary files differ
diff --git a/Build/source/libs/libpng/libpng-src/contrib/testpngs/badpal/test-palette-2.png b/Build/source/libs/libpng/libpng-src/contrib/testpngs/badpal/test-palette-2.png
new file mode 100644
index 00000000000..a7e996464bf
--- /dev/null
+++ b/Build/source/libs/libpng/libpng-src/contrib/testpngs/badpal/test-palette-2.png
Binary files differ
diff --git a/Build/source/libs/libpng/libpng-src/contrib/testpngs/badpal/test-palette-4.png b/Build/source/libs/libpng/libpng-src/contrib/testpngs/badpal/test-palette-4.png
new file mode 100644
index 00000000000..39853bfce9a
--- /dev/null
+++ b/Build/source/libs/libpng/libpng-src/contrib/testpngs/badpal/test-palette-4.png
Binary files differ
diff --git a/Build/source/libs/libpng/libpng-src/contrib/testpngs/badpal/test-palette-8.png b/Build/source/libs/libpng/libpng-src/contrib/testpngs/badpal/test-palette-8.png
new file mode 100644
index 00000000000..46d0993544e
--- /dev/null
+++ b/Build/source/libs/libpng/libpng-src/contrib/testpngs/badpal/test-palette-8.png
Binary files differ
diff --git a/Build/source/libs/libpng/libpng-src/contrib/testpngs/makepngs.sh b/Build/source/libs/libpng/libpng-src/contrib/testpngs/makepngs.sh
index 270f0630aaf..f0238c3b53d 100755
--- a/Build/source/libs/libpng/libpng-src/contrib/testpngs/makepngs.sh
+++ b/Build/source/libs/libpng/libpng-src/contrib/testpngs/makepngs.sh
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/usr/bin/env bash
# Make a set of test PNG files, MAKEPNG is the name of the makepng executable
# built from contrib/libtests/makepng.c
diff --git a/Build/source/libs/libpng/libpng-src/contrib/tools/intgamma.sh b/Build/source/libs/libpng/libpng-src/contrib/tools/intgamma.sh
index 3198cb2415d..aaed68a09ee 100755
--- a/Build/source/libs/libpng/libpng-src/contrib/tools/intgamma.sh
+++ b/Build/source/libs/libpng/libpng-src/contrib/tools/intgamma.sh
@@ -19,7 +19,7 @@
# Function to print out a list of numbers as integers; the function truncates
# the integers which must be one-per-line.
-function print(){
+print(){
awk 'BEGIN{
str = ""
}
diff --git a/Build/source/libs/libpng/libpng-src/contrib/tools/pngcp.c b/Build/source/libs/libpng/libpng-src/contrib/tools/pngcp.c
index 579e28d2b8a..cf621fa5bf5 100644
--- a/Build/source/libs/libpng/libpng-src/contrib/tools/pngcp.c
+++ b/Build/source/libs/libpng/libpng-src/contrib/tools/pngcp.c
@@ -1,6 +1,6 @@
/* pngcp.c
*
- * Copyright (c) 2016,2022 John Cunningham Bowler
+ * Copyright (c) 2016,2022,2024 John Cunningham Bowler
*
* This code is released under the libpng license.
* For conditions of distribution and use, see the disclaimer
@@ -88,16 +88,6 @@
# define voidcast(type, value) (value)
#endif /* __cplusplus */
-#ifdef __GNUC__
- /* Many versions of GCC erroneously report that local variables unmodified
- * within the scope of a setjmp may be clobbered. This hacks round the
- * problem (sometimes) without harming other compilers.
- */
-# define gv volatile
-#else
-# define gv
-#endif
-
/* 'CLOCK_PROCESS_CPUTIME_ID' is one of the clock timers for clock_gettime. It
* need not be supported even when clock_gettime is available. It returns the
* 'CPU' time the process has consumed. 'CPU' time is assumed to include time
@@ -395,6 +385,7 @@ struct display
{
jmp_buf error_return; /* Where to go to on error */
unsigned int errset; /* error_return is set */
+ int errlevel; /* error level from longjmp */
const char *operation; /* What is happening */
const char *filename; /* The name of the original file */
@@ -634,7 +625,10 @@ display_log(struct display *dp, error_level level, const char *fmt, ...)
if (level > APP_FAIL || (level > ERRORS && !(dp->options & CONTINUE)))
{
if (dp->errset)
+ {
+ dp->errlevel = level;
longjmp(dp->error_return, level);
+ }
else
exit(99);
@@ -2318,14 +2312,9 @@ cp_one_file(struct display *dp, const char *filename, const char *destname)
}
static int
-cppng(struct display *dp, const char *file, const char *gv dest)
- /* Exists solely to isolate the setjmp clobbers which some versions of GCC
- * erroneously generate.
- */
+cppng(struct display *dp, const char *file, const char *dest)
{
- int ret = setjmp(dp->error_return);
-
- if (ret == 0)
+ if (setjmp(dp->error_return) == 0)
{
dp->errset = 1;
cp_one_file(dp, file, dest);
@@ -2337,10 +2326,11 @@ cppng(struct display *dp, const char *file, const char *gv dest)
{
dp->errset = 0;
- if (ret < ERRORS) /* shouldn't longjmp on warnings */
- display_log(dp, INTERNAL_ERROR, "unexpected return code %d", ret);
+ if (dp->errlevel < ERRORS) /* shouldn't longjmp on warnings */
+ display_log(dp, INTERNAL_ERROR, "unexpected return code %d",
+ dp->errlevel);
- return ret;
+ return dp->errlevel;
}
}
diff --git a/Build/source/libs/libpng/libpng-src/contrib/tools/pngfix.c b/Build/source/libs/libpng/libpng-src/contrib/tools/pngfix.c
index cdf3f1cb4a1..025e68790e2 100644
--- a/Build/source/libs/libpng/libpng-src/contrib/tools/pngfix.c
+++ b/Build/source/libs/libpng/libpng-src/contrib/tools/pngfix.c
@@ -1,6 +1,6 @@
/* pngfix.c
*
- * Copyright (c) 2014-2017 John Cunningham Bowler
+ * Copyright (c) 2014-2017,2024 John Cunningham Bowler
*
* This code is released under the libpng license.
* For conditions of distribution and use, see the disclaimer
@@ -20,19 +20,6 @@
#define implies(x,y) assert(!(x) || (y))
-#ifdef __GNUC__
- /* This is used to fix the error:
- *
- * pngfix.c:
- * In function 'zlib_advance':
- * pngfix.c:181:13: error: assuming signed overflow does not
- * occur when simplifying conditional to constant [-Werror=strict-overflow]
- */
-# define FIX_GCC volatile
-#else
-# define FIX_GCC
-#endif
-
#define PROGRAM_NAME "pngfix"
/* Define the following to use this program against your installed libpng,
@@ -218,7 +205,7 @@ uarb_inc(uarb num, int in_digits, png_int_32 add)
* in_digits+1 if add is known to be in the range -65535..65535.
*/
{
- FIX_GCC int out_digits = 0;
+ int out_digits = 0;
while (out_digits < in_digits)
{
@@ -263,7 +250,7 @@ uarb_add32(uarb num, int in_digits, png_uint_32 add)
}
static int
-uarb_mult_digit(uarb acc, int a_digits, uarb num, FIX_GCC int n_digits,
+uarb_mult_digit(uarb acc, int a_digits, uarb num, int n_digits,
png_uint_16 val)
/* Primitive one-digit multiply - 'val' must be 0..65535. Note that this
* primitive is a multiply and accumulate - the result of *num * val is added
@@ -336,7 +323,7 @@ uarb_shift(uarb inout, int ndigits, unsigned int right_shift)
* 1..15
*/
{
- FIX_GCC int i = ndigits;
+ int i = ndigits;
png_uint_16 carry = 0;
assert(right_shift >= 1 && right_shift <= 15);
@@ -351,7 +338,7 @@ uarb_shift(uarb inout, int ndigits, unsigned int right_shift)
inout[i] = temp;
/* The shift may reduce ndigits */
- if (i == ndigits-1 && temp == 0)
+ if (i+1 == ndigits && temp == 0)
ndigits = i;
}
@@ -1005,10 +992,18 @@ file_end(struct file *file)
if (file->out != NULL)
{
- /* NOTE: this is bitwise |, all the following functions must execute and
- * must succeed.
+ /* On some systems 'fclose' deletes the FILE struct (making it
+ * inaccessbile). There is no guarantee that fclose returns an error
+ * code from fflush or, indeed, from the FILE error indicator. There is
+ * also no explicit (or clear) guarantee in the standard that anything
+ * other than a read or write operation sets the error indicator; fflush
+ * is not a read or write operation, so both conditions must be checked
+ * to ensure the close succeeded and in ANSI-C conformant code they must
+ * be checked before the fclose call.
*/
- if (ferror(file->out) | fflush(file->out) | fclose(file->out))
+ const int err = fflush(file->out) || ferror(file->out);
+
+ if (fclose(file->out) || err)
{
perror(file->out_name);
emit_error(file, READ_ERROR_CODE, "output write error");
@@ -4054,3 +4049,4 @@ main(void)
return 77;
}
#endif /* PNG_SETJMP_SUPPORTED */
+/* vi: set textwidth=80 shiftwidth=3 softtabstop=-1 expandtab: */
diff --git a/Build/source/libs/libpng/libpng-src/example.c b/Build/source/libs/libpng/libpng-src/example.c
index b3038efb0d5..3465fbb372e 100644
--- a/Build/source/libs/libpng/libpng-src/example.c
+++ b/Build/source/libs/libpng/libpng-src/example.c
@@ -3,7 +3,7 @@
/* example.c - an example of using libpng
*
- * Maintained 2018 Cosmin Truta
+ * Maintained 2018-2024 Cosmin Truta
* Maintained 1998-2016 Glenn Randers-Pehrson
* Maintained 1996-1997 Andreas Dilger
* Written 1995-1996 Guy Eric Schalnat, Group 42, Inc.
@@ -259,9 +259,9 @@ int check_if_png(char *file_name, FILE **fp)
return 0;
/* Compare the first PNG_BYTES_TO_CHECK bytes of the signature.
- * Return nonzero (true) if they match.
+ * Return true if they match.
*/
- return(!png_sig_cmp(buf, 0, PNG_BYTES_TO_CHECK));
+ return png_sig_cmp(buf, 0, PNG_BYTES_TO_CHECK) == 0;
}
/* Read a PNG file. You may want to return an error code if the read
@@ -281,7 +281,7 @@ void read_png(char *file_name) /* We need to open the file */
FILE *fp;
if ((fp = fopen(file_name, "rb")) == NULL)
- return (ERROR);
+ return ERROR;
#else no_open_file /* prototype 2 */
void read_png(FILE *fp, int sig_read) /* File is already open */
@@ -304,7 +304,7 @@ void read_png(FILE *fp, int sig_read) /* File is already open */
if (png_ptr == NULL)
{
fclose(fp);
- return (ERROR);
+ return ERROR;
}
/* Allocate/initialize the memory for image information. REQUIRED. */
@@ -313,7 +313,7 @@ void read_png(FILE *fp, int sig_read) /* File is already open */
{
fclose(fp);
png_destroy_read_struct(&png_ptr, NULL, NULL);
- return (ERROR);
+ return ERROR;
}
/* Set error handling if you are using the setjmp/longjmp method (this is
@@ -326,7 +326,7 @@ void read_png(FILE *fp, int sig_read) /* File is already open */
png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
fclose(fp);
/* If we get here, we had a problem reading the file. */
- return (ERROR);
+ return ERROR;
}
/* One of the following I/O initialization methods is REQUIRED. */
@@ -585,7 +585,7 @@ void read_png(FILE *fp, int sig_read) /* File is already open */
fclose(fp);
/* That's it! */
- return (OK);
+ return OK;
}
/* Progressively read a file */
@@ -604,18 +604,18 @@ initialize_png_reader(png_structp *png_ptr, png_infop *info_ptr)
if (*png_ptr == NULL)
{
*info_ptr = NULL;
- return (ERROR);
+ return ERROR;
}
*info_ptr = png_create_info_struct(png_ptr);
if (*info_ptr == NULL)
{
png_destroy_read_struct(png_ptr, info_ptr, NULL);
- return (ERROR);
+ return ERROR;
}
if (setjmp(png_jmpbuf((*png_ptr))))
{
png_destroy_read_struct(png_ptr, info_ptr, NULL);
- return (ERROR);
+ return ERROR;
}
/* You will need to provide all three function callbacks,
@@ -632,7 +632,7 @@ initialize_png_reader(png_structp *png_ptr, png_infop *info_ptr)
*/
png_set_progressive_read_fn(*png_ptr, (void *)stream_data,
info_callback, row_callback, end_callback);
- return (OK);
+ return OK;
}
int
@@ -643,7 +643,7 @@ process_data(png_structp *png_ptr, png_infop *info_ptr,
{
/* Free the png_ptr and info_ptr memory on error. */
png_destroy_read_struct(png_ptr, info_ptr, NULL);
- return (ERROR);
+ return ERROR;
}
/* Give chunks of data as they arrive from the data stream
@@ -657,7 +657,7 @@ process_data(png_structp *png_ptr, png_infop *info_ptr,
* callback, if you aren't already displaying them there.
*/
png_process_data(*png_ptr, *info_ptr, buffer, length);
- return (OK);
+ return OK;
}
info_callback(png_structp png_ptr, png_infop info)
@@ -747,7 +747,7 @@ void write_png(char *file_name /* , ... other image information ... */)
/* Open the file */
fp = fopen(file_name, "wb");
if (fp == NULL)
- return (ERROR);
+ return ERROR;
/* Create and initialize the png_struct with the desired error handler
* functions. If you want to use the default stderr and longjump method,
@@ -760,7 +760,7 @@ void write_png(char *file_name /* , ... other image information ... */)
if (png_ptr == NULL)
{
fclose(fp);
- return (ERROR);
+ return ERROR;
}
/* Allocate/initialize the image information data. REQUIRED. */
@@ -769,7 +769,7 @@ void write_png(char *file_name /* , ... other image information ... */)
{
fclose(fp);
png_destroy_write_struct(&png_ptr, NULL);
- return (ERROR);
+ return ERROR;
}
/* Set up error handling. REQUIRED if you aren't supplying your own
@@ -780,7 +780,7 @@ void write_png(char *file_name /* , ... other image information ... */)
/* If we get here, we had a problem writing the file. */
fclose(fp);
png_destroy_write_struct(&png_ptr, &info_ptr);
- return (ERROR);
+ return ERROR;
}
/* One of the following I/O initialization functions is REQUIRED. */
@@ -1035,7 +1035,7 @@ void write_png(char *file_name /* , ... other image information ... */)
fclose(fp);
/* That's it! */
- return (OK);
+ return OK;
}
#endif /* if 0 */
diff --git a/Build/source/libs/libpng/libpng-src/libpng-manual.txt b/Build/source/libs/libpng/libpng-src/libpng-manual.txt
index 67b50788266..dbb60af61d1 100644
--- a/Build/source/libs/libpng/libpng-src/libpng-manual.txt
+++ b/Build/source/libs/libpng/libpng-src/libpng-manual.txt
@@ -1,6 +1,6 @@
libpng-manual.txt - A description on how to use and modify libpng
- Copyright (c) 2018-2023 Cosmin Truta
+ Copyright (c) 2018-2024 Cosmin Truta
Copyright (c) 1998-2018 Glenn Randers-Pehrson
This document is released under the libpng license.
@@ -9,9 +9,9 @@ libpng-manual.txt - A description on how to use and modify libpng
Based on:
- libpng version 1.6.36, December 2018, through 1.6.40 - June 2023
+ libpng version 1.6.36, December 2018, through 1.6.41 - January 2024
Updated and distributed by Cosmin Truta
- Copyright (c) 2018-2023 Cosmin Truta
+ Copyright (c) 2018-2024 Cosmin Truta
libpng versions 0.97, January 1998, through 1.6.35 - July 2018
Updated and distributed by Glenn Randers-Pehrson
diff --git a/Build/source/libs/libpng/libpng-src/libpng.3 b/Build/source/libs/libpng/libpng-src/libpng.3
index 003bfaf6c22..3c68fe51700 100644
--- a/Build/source/libs/libpng/libpng-src/libpng.3
+++ b/Build/source/libs/libpng/libpng-src/libpng.3
@@ -1,6 +1,6 @@
-.TH LIBPNG 3 "June 21, 2023"
+.TH LIBPNG 3 "January 24, 2024"
.SH NAME
-libpng \- Portable Network Graphics (PNG) Reference Library 1.6.40
+libpng \- Portable Network Graphics (PNG) Reference Library 1.6.41
.SH SYNOPSIS
\fB#include <png.h>\fP
@@ -519,7 +519,7 @@ Following is a copy of the libpng-manual.txt file that accompanies libpng.
.SH LIBPNG.TXT
libpng-manual.txt - A description on how to use and modify libpng
- Copyright (c) 2018-2023 Cosmin Truta
+ Copyright (c) 2018-2024 Cosmin Truta
Copyright (c) 1998-2018 Glenn Randers-Pehrson
This document is released under the libpng license.
@@ -528,9 +528,9 @@ libpng-manual.txt - A description on how to use and modify libpng
Based on:
- libpng version 1.6.36, December 2018, through 1.6.40 - June 2023
+ libpng version 1.6.36, December 2018, through 1.6.41 - January 2024
Updated and distributed by Cosmin Truta
- Copyright (c) 2018-2023 Cosmin Truta
+ Copyright (c) 2018-2024 Cosmin Truta
libpng versions 0.97, January 1998, through 1.6.35 - July 2018
Updated and distributed by Glenn Randers-Pehrson
diff --git a/Build/source/libs/libpng/libpng-src/libpngpf.3 b/Build/source/libs/libpng/libpng-src/libpngpf.3
index 43eeb9a319c..610432dcbdd 100644
--- a/Build/source/libs/libpng/libpng-src/libpngpf.3
+++ b/Build/source/libs/libpng/libpng-src/libpngpf.3
@@ -1,6 +1,6 @@
-.TH LIBPNGPF 3 "June 21, 2023"
+.TH LIBPNGPF 3 "January 24, 2024"
.SH NAME
-libpng \- Portable Network Graphics (PNG) Reference Library 1.6.40
+libpng \- Portable Network Graphics (PNG) Reference Library 1.6.41
(private functions)
.SH SYNOPSIS
diff --git a/Build/source/libs/libpng/libpng-src/loongarch/filter_lsx_intrinsics.c b/Build/source/libs/libpng/libpng-src/loongarch/filter_lsx_intrinsics.c
new file mode 100644
index 00000000000..af6cc763a07
--- /dev/null
+++ b/Build/source/libs/libpng/libpng-src/loongarch/filter_lsx_intrinsics.c
@@ -0,0 +1,412 @@
+/* filter_lsx_intrinsics.c - LSX optimized filter functions
+ *
+ * Copyright (c) 2021 Loongson Technology Corporation Limited
+ * All rights reserved.
+ * Copyright (c) 2018 Cosmin Truta
+ * Copyright (c) 2016 Glenn Randers-Pehrson
+ * Contributed by Jin Bo (jinbo@loongson.cn)
+ *
+ * This code is released under the libpng license.
+ * For conditions of distribution and use, see the disclaimer
+ * and license in png.h
+ */
+
+#include "../pngpriv.h"
+
+#ifdef PNG_READ_SUPPORTED
+
+#if PNG_LOONGARCH_LSX_IMPLEMENTATION == 1 /* intrinsics code from pngpriv.h */
+
+#include <lsxintrin.h>
+
+#define LSX_LD(psrc) __lsx_vld((psrc), 0)
+
+#define LSX_LD_2(psrc, stride, out0, out1) \
+{ \
+ out0 = LSX_LD(psrc); \
+ out1 = LSX_LD(psrc + stride); \
+}
+
+#define LSX_LD_4(psrc, stride, out0, out1, out2, out3) \
+{ \
+ LSX_LD_2(psrc, stride, out0, out1); \
+ LSX_LD_2(psrc + stride * 2, stride, out2, out3); \
+}
+
+#define LSX_ST(in, pdst) __lsx_vst(in, (pdst), 0)
+
+#define LSX_ST_2(in0, in1, pdst, stride) \
+{ \
+ LSX_ST(in0, pdst); \
+ LSX_ST(in1, pdst + stride); \
+}
+
+#define LSX_ST_4(in0, in1, in2, in3, pdst, stride) \
+{ \
+ LSX_ST_2(in0, in1, pdst, stride); \
+ LSX_ST_2(in2, in3, pdst + stride * 2, stride); \
+}
+
+#define LSX_ADD_B(in0, in1, out0) \
+{ \
+ out0 = __lsx_vadd_b(in0, in1); \
+}
+
+#define LSX_ADD_B_2(in0, in1, in2, in3, out0, out1) \
+{ \
+ LSX_ADD_B(in0, in1, out0); \
+ LSX_ADD_B(in2, in3, out1); \
+}
+
+#define LSX_ADD_B_4(in0, in1, in2, in3, in4, in5, \
+ in6, in7, out0, out1, out2, out3) \
+{ \
+ LSX_ADD_B_2(in0, in1, in2, in3, out0, out1); \
+ LSX_ADD_B_2(in4, in5, in6, in7, out2, out3); \
+}
+
+#define LSX_ABS_B_3(in0, in1, in2, out0, out1, out2) \
+{ \
+ out0 = __lsx_vadda_h(in0, zero); \
+ out1 = __lsx_vadda_h(in1, zero); \
+ out2 = __lsx_vadda_h(in2, zero); \
+}
+
+#define LSX_ILVL_B(in_h, in_l, out0) \
+{ \
+ out0 = __lsx_vilvl_b(in_h, in_l); \
+}
+
+#define LSX_ILVL_B_2(in0_h, in0_l, in1_h, in1_l, out0, out1) \
+{ \
+ LSX_ILVL_B(in0_h, in0_l, out0); \
+ LSX_ILVL_B(in1_h, in1_l, out1); \
+}
+
+#define LSX_HSUB_HU_BU_2(in0, in1, out0, out1) \
+{ \
+ out0 = __lsx_vhsubw_hu_bu(in0, in0); \
+ out1 = __lsx_vhsubw_hu_bu(in1, in1); \
+}
+
+#define LSX_CMP_PICK_SMALLER(in0, in1, in2, in3, in4, in5, out0) \
+{ \
+ __m128i _cmph, _cmpb, _in0, _in3; \
+ _cmph = __lsx_vslt_h(in1, in0); \
+ _cmpb = __lsx_vpickev_b(_cmph, _cmph); \
+ _in0 = __lsx_vmin_bu(in0,in1); \
+ _in3 = __lsx_vbitsel_v(in3, in4, _cmpb); \
+ _cmph = __lsx_vslt_h(in2, _in0); \
+ _cmpb = __lsx_vpickev_b(_cmph, _cmph); \
+ _in3 = __lsx_vbitsel_v(_in3, in5, _cmpb); \
+ out0 = __lsx_vadd_b(out0, _in3); \
+}
+
+void png_read_filter_row_up_lsx(png_row_infop row_info, png_bytep row,
+ png_const_bytep prev_row)
+{
+ size_t n = row_info->rowbytes;
+ png_bytep rp = row;
+ png_const_bytep pp = prev_row;
+ __m128i vec_0, vec_1, vec_2, vec_3;
+ __m128i vec_4, vec_5, vec_6, vec_7;
+
+ while (n >= 64)
+ {
+ LSX_LD_4(rp, 16, vec_0, vec_1, vec_2, vec_3);
+ LSX_LD_4(pp, 16, vec_4, vec_5, vec_6, vec_7);
+ pp += 64;
+ LSX_ADD_B_4(vec_0 ,vec_4, vec_1, vec_5, vec_2, vec_6,
+ vec_3, vec_7, vec_0, vec_1, vec_2, vec_3);
+ LSX_ST_4(vec_0, vec_1, vec_2, vec_3, rp, 16);
+ rp += 64;
+ n -= 64;
+ }
+ if (n & 63)
+ {
+ if (n >= 32)
+ {
+ LSX_LD_2(rp, 16, vec_0, vec_1);
+ LSX_LD_2(pp, 16, vec_2, vec_3);
+ pp += 32;
+ LSX_ADD_B_2(vec_0, vec_2, vec_1, vec_3, vec_0, vec_1);
+ LSX_ST_2(vec_0, vec_1, rp, 16);
+ rp += 32;
+ n -= 32;
+ }
+ if (n & 31)
+ {
+ if (n >= 16)
+ {
+ vec_0 = LSX_LD(rp);
+ vec_1 = LSX_LD(pp);
+ pp += 16;
+ LSX_ADD_B(vec_0, vec_1, vec_0);
+ LSX_ST(vec_0, rp);
+ rp += 16;
+ n -= 16;
+ }
+ if (n >= 8)
+ {
+ vec_0 = __lsx_vldrepl_d(rp, 0);
+ vec_1 = __lsx_vldrepl_d(pp, 0);
+ vec_0 = __lsx_vadd_b(vec_0, vec_1);
+ __lsx_vstelm_d(vec_0, rp, 0, 0);
+ rp += 8;
+ pp += 8;
+ n -= 8;
+ }
+ while (n--)
+ {
+ *rp = *rp + *pp++;
+ rp++;
+ }
+ }
+ }
+}
+
+void png_read_filter_row_sub3_lsx(png_row_infop row_info, png_bytep row,
+ png_const_bytep prev_row)
+{
+ size_t n = row_info->rowbytes;
+ png_uint_32 tmp;
+ png_bytep nxt = row;
+ __m128i vec_0, vec_1;
+
+ PNG_UNUSED(prev_row);
+
+ vec_0 = __lsx_vldrepl_w(nxt, 0);
+ nxt += 3;
+ n -= 3;
+
+ while (n >= 3)
+ {
+ vec_1 = __lsx_vldrepl_w(nxt, 0);
+ vec_1 = __lsx_vadd_b(vec_1, vec_0);
+ __lsx_vstelm_h(vec_1, nxt, 0, 0);
+ vec_0 = vec_1;
+ nxt += 2;
+ __lsx_vstelm_b(vec_1, nxt, 0, 2);
+ nxt += 1;
+ n -= 3;
+ }
+
+ row = nxt - 3;
+ while (n--)
+ {
+ *nxt = *nxt + *row++;
+ nxt++;
+ }
+}
+
+void png_read_filter_row_sub4_lsx(png_row_infop row_info, png_bytep row,
+ png_const_bytep prev_row)
+{
+ size_t n = row_info->rowbytes;
+ __m128i vec_0, vec_1;
+
+ PNG_UNUSED(prev_row);
+
+ vec_0 = __lsx_vldrepl_w(row, 0);
+ row += 4;
+ n -= 4;
+
+ while (n >= 4)
+ {
+ vec_1 = __lsx_vldrepl_w(row, 0);
+ vec_1 = __lsx_vadd_b(vec_1, vec_0);
+ __lsx_vstelm_w(vec_1, row, 0, 0);
+ vec_0 = vec_1;
+ row += 4;
+ n -= 4;
+ }
+}
+
+void png_read_filter_row_avg3_lsx(png_row_infop row_info, png_bytep row,
+ png_const_bytep prev_row)
+{
+ size_t n = row_info->rowbytes;
+ png_bytep nxt = row;
+ png_const_bytep prev_nxt = prev_row;
+ __m128i vec_0, vec_1, vec_2;
+
+ vec_0 = __lsx_vldrepl_w(nxt, 0);
+ vec_1 = __lsx_vldrepl_w(prev_nxt, 0);
+ prev_nxt += 3;
+ vec_1 = __lsx_vsrli_b(vec_1, 1);
+ vec_1 = __lsx_vadd_b(vec_1, vec_0);
+ __lsx_vstelm_h(vec_1, nxt, 0, 0);
+ nxt += 2;
+ __lsx_vstelm_b(vec_1, nxt, 0, 2);
+ nxt += 1;
+ n -= 3;
+
+ while (n >= 3)
+ {
+ vec_2 = vec_1;
+ vec_0 = __lsx_vldrepl_w(nxt, 0);
+ vec_1 = __lsx_vldrepl_w(prev_nxt, 0);
+ prev_nxt += 3;
+
+ vec_1 = __lsx_vavg_bu(vec_1, vec_2);
+ vec_1 = __lsx_vadd_b(vec_1, vec_0);
+
+ __lsx_vstelm_h(vec_1, nxt, 0, 0);
+ nxt += 2;
+ __lsx_vstelm_b(vec_1, nxt, 0, 2);
+ nxt += 1;
+ n -= 3;
+ }
+
+ row = nxt - 3;
+ while (n--)
+ {
+ vec_2 = __lsx_vldrepl_b(row, 0);
+ row++;
+ vec_0 = __lsx_vldrepl_b(nxt, 0);
+ vec_1 = __lsx_vldrepl_b(prev_nxt, 0);
+ prev_nxt++;
+
+ vec_1 = __lsx_vavg_bu(vec_1, vec_2);
+ vec_1 = __lsx_vadd_b(vec_1, vec_0);
+
+ __lsx_vstelm_b(vec_1, nxt, 0, 0);
+ nxt++;
+ }
+}
+
+void png_read_filter_row_avg4_lsx(png_row_infop row_info, png_bytep row,
+ png_const_bytep prev_row)
+{
+ size_t n = row_info->rowbytes;
+ __m128i vec_0, vec_1, vec_2;
+
+ vec_0 = __lsx_vldrepl_w(row, 0);
+ vec_1 = __lsx_vldrepl_w(prev_row, 0);
+ prev_row += 4;
+ vec_1 = __lsx_vsrli_b(vec_1, 1);
+ vec_1 = __lsx_vadd_b(vec_1, vec_0);
+ __lsx_vstelm_w(vec_1, row, 0, 0);
+ row += 4;
+ n -= 4;
+
+ while (n >= 4)
+ {
+ vec_2 = vec_1;
+ vec_0 = __lsx_vldrepl_w(row, 0);
+ vec_1 = __lsx_vldrepl_w(prev_row, 0);
+ prev_row += 4;
+
+ vec_1 = __lsx_vavg_bu(vec_1, vec_2);
+ vec_1 = __lsx_vadd_b(vec_1, vec_0);
+
+ __lsx_vstelm_w(vec_1, row, 0, 0);
+ row += 4;
+ n -= 4;
+ }
+}
+
+void png_read_filter_row_paeth3_lsx(png_row_infop row_info,
+ png_bytep row,
+ png_const_bytep prev_row)
+{
+ size_t n = row_info->rowbytes;
+ png_bytep nxt = row;
+ png_const_bytep prev_nxt = prev_row;
+ __m128i vec_a, vec_b, vec_c, vec_d;
+ __m128i vec_pa, vec_pb, vec_pc;
+ __m128i zero = {0};
+
+ vec_a = __lsx_vldrepl_w(nxt, 0);
+ vec_b = __lsx_vldrepl_w(prev_nxt, 0);
+ prev_nxt += 3;
+ vec_d = __lsx_vadd_b(vec_a, vec_b);
+ __lsx_vstelm_h(vec_d, nxt, 0, 0);
+ nxt += 2;
+ __lsx_vstelm_b(vec_d, nxt, 0, 2);
+ nxt += 1;
+ n -= 3;
+
+ while (n >= 3)
+ {
+ vec_a = vec_d;
+ vec_c = vec_b;
+ vec_b = __lsx_vldrepl_w(prev_nxt, 0);
+ prev_nxt += 3;
+ vec_d = __lsx_vldrepl_w(nxt, 0);
+
+ LSX_ILVL_B_2(vec_b, vec_c, vec_a, vec_c, vec_pa, vec_pb);
+ LSX_HSUB_HU_BU_2(vec_pa, vec_pb, vec_pa, vec_pb);
+ vec_pc = __lsx_vadd_h(vec_pa, vec_pb);
+ LSX_ABS_B_3(vec_pa, vec_pb, vec_pc, vec_pa, vec_pb, vec_pc);
+ LSX_CMP_PICK_SMALLER(vec_pa, vec_pb, vec_pc, vec_a, vec_b, vec_c, vec_d);
+
+ __lsx_vstelm_h(vec_d, nxt, 0, 0);
+ nxt += 2;
+ __lsx_vstelm_b(vec_d, nxt, 0, 2);
+ nxt += 1;
+ n -= 3;
+ }
+
+ prev_row = prev_nxt - 3;
+ row = nxt - 3;
+ while (n--)
+ {
+ vec_a = __lsx_vldrepl_b(row, 0);
+ row++;
+ vec_b = __lsx_vldrepl_b(prev_nxt, 0);
+ prev_nxt++;
+ vec_c = __lsx_vldrepl_b(prev_row, 0);
+ prev_row++;
+ vec_d = __lsx_vldrepl_b(nxt, 0);
+
+ LSX_ILVL_B_2(vec_b, vec_c, vec_a, vec_c, vec_pa, vec_pb);
+ LSX_HSUB_HU_BU_2(vec_pa, vec_pb, vec_pa, vec_pb);
+ vec_pc = __lsx_vadd_h(vec_pa, vec_pb);
+ LSX_ABS_B_3(vec_pa, vec_pb, vec_pc, vec_pa, vec_pb, vec_pc);
+ LSX_CMP_PICK_SMALLER(vec_pa, vec_pb, vec_pc, vec_a, vec_b, vec_c, vec_d);
+
+ __lsx_vstelm_b(vec_d, nxt, 0, 0);
+ nxt++;
+ }
+}
+
+void png_read_filter_row_paeth4_lsx(png_row_infop row_info,
+ png_bytep row,
+ png_const_bytep prev_row)
+{
+ size_t n = row_info->rowbytes;
+ __m128i vec_a, vec_b, vec_c, vec_d;
+ __m128i vec_pa, vec_pb, vec_pc;
+ __m128i zero = {0};
+
+ vec_a = __lsx_vldrepl_w(row, 0);
+ vec_b = __lsx_vldrepl_w(prev_row, 0);
+ prev_row += 4;
+ vec_d = __lsx_vadd_b(vec_a, vec_b);
+ __lsx_vstelm_w(vec_d, row, 0, 0);
+ row += 4;
+ n -= 4;
+
+ while (n >= 4)
+ {
+ vec_a = vec_d;
+ vec_c = vec_b;
+ vec_b = __lsx_vldrepl_w(prev_row, 0);
+ prev_row += 4;
+ vec_d = __lsx_vldrepl_w(row, 0);
+
+ LSX_ILVL_B_2(vec_b, vec_c, vec_a, vec_c, vec_pa, vec_pb);
+ LSX_HSUB_HU_BU_2(vec_pa, vec_pb, vec_pa, vec_pb);
+ vec_pc = __lsx_vadd_h(vec_pa, vec_pb);
+ LSX_ABS_B_3(vec_pa, vec_pb, vec_pc, vec_pa, vec_pb, vec_pc);
+ LSX_CMP_PICK_SMALLER(vec_pa, vec_pb, vec_pc, vec_a, vec_b, vec_c, vec_d);
+
+ __lsx_vstelm_w(vec_d, row, 0, 0);
+ row += 4;
+ n -= 4;
+ }
+}
+
+#endif /* PNG_LOONGARCH_LSX_IMPLEMENTATION == 1 (intrinsics) */
+#endif /* PNG_READ_SUPPORTED */
diff --git a/Build/source/libs/libpng/libpng-src/loongarch/loongarch_lsx_init.c b/Build/source/libs/libpng/libpng-src/loongarch/loongarch_lsx_init.c
new file mode 100644
index 00000000000..2c80fe81b68
--- /dev/null
+++ b/Build/source/libs/libpng/libpng-src/loongarch/loongarch_lsx_init.c
@@ -0,0 +1,65 @@
+/* loongarch_lsx_init.c - LSX optimized filter functions
+ *
+ * Copyright (c) 2021 Loongson Technology Corporation Limited
+ * All rights reserved.
+ * Contributed by Jin Bo <jinbo@loongson.cn>
+ *
+ * This code is released under the libpng license.
+ * For conditions of distribution and use, see the disclaimer
+ * and license in png.h
+ */
+
+#include "../pngpriv.h"
+
+#ifdef PNG_READ_SUPPORTED
+#if PNG_LOONGARCH_LSX_IMPLEMENTATION == 1
+
+#include <sys/auxv.h>
+
+#define LA_HWCAP_LSX (1<<4)
+static int png_has_lsx(void)
+{
+ int flags = 0;
+ int flag = (int)getauxval(AT_HWCAP);
+
+ if (flag & LA_HWCAP_LSX)
+ return 1;
+
+ return 0;
+}
+
+void
+png_init_filter_functions_lsx(png_structp pp, unsigned int bpp)
+{
+ /* IMPORTANT: any new external functions used here must be declared using
+ * PNG_INTERNAL_FUNCTION in ../pngpriv.h. This is required so that the
+ * 'prefix' option to configure works:
+ *
+ * ./configure --with-libpng-prefix=foobar_
+ *
+ * Verify you have got this right by running the above command, doing a build
+ * and examining pngprefix.h; it must contain a #define for every external
+ * function you add. (Notice that this happens automatically for the
+ * initialization function.)
+ */
+
+ if (png_has_lsx())
+ {
+ pp->read_filter[PNG_FILTER_VALUE_UP-1] = png_read_filter_row_up_lsx;
+ if (bpp == 3)
+ {
+ pp->read_filter[PNG_FILTER_VALUE_SUB-1] = png_read_filter_row_sub3_lsx;
+ pp->read_filter[PNG_FILTER_VALUE_AVG-1] = png_read_filter_row_avg3_lsx;
+ pp->read_filter[PNG_FILTER_VALUE_PAETH-1] = png_read_filter_row_paeth3_lsx;
+ }
+ else if (bpp == 4)
+ {
+ pp->read_filter[PNG_FILTER_VALUE_SUB-1] = png_read_filter_row_sub4_lsx;
+ pp->read_filter[PNG_FILTER_VALUE_AVG-1] = png_read_filter_row_avg4_lsx;
+ pp->read_filter[PNG_FILTER_VALUE_PAETH-1] = png_read_filter_row_paeth4_lsx;
+ }
+ }
+}
+
+#endif /* PNG_LOONGARCH_LSX_IMPLEMENTATION == 1 */
+#endif /* PNG_READ_SUPPORTED */
diff --git a/Build/source/libs/libpng/libpng-src/mips/filter_mmi_inline_assembly.c b/Build/source/libs/libpng/libpng-src/mips/filter_mmi_inline_assembly.c
new file mode 100644
index 00000000000..b330a465381
--- /dev/null
+++ b/Build/source/libs/libpng/libpng-src/mips/filter_mmi_inline_assembly.c
@@ -0,0 +1,525 @@
+/* filter_mmi_intrinsics.c - MMI optimized filter functions
+ *
+ * Copyright (c) 2024 Cosmin Truta
+ * Written by zhanglixia and guxiwei, 2023
+ *
+ * This code is released under the libpng license.
+ * For conditions of distribution and use, see the disclaimer
+ * and license in png.h
+ */
+
+#include "../pngpriv.h"
+
+#ifdef PNG_READ_SUPPORTED
+
+#if PNG_MIPS_MMI_IMPLEMENTATION == 2 /* Inline Assembly */
+
+/* Functions in this file look at most 3 pixels (a,b,c) to predict the 4th (d).
+ * They're positioned like this:
+ * prev: c b
+ * row: a d
+ * The Sub filter predicts d=a, Avg d=(a+b)/2, and Paeth predicts d to be
+ * whichever of a, b, or c is closest to p=a+b-c.
+ */
+
+void png_read_filter_row_up_mmi(png_row_infop row_info, png_bytep row,
+ png_const_bytep prev_row)
+{
+ int istop = row_info->rowbytes;
+ double rp,pp;
+ __asm__ volatile (
+ "1: \n\t"
+ "ldc1 %[rp], 0x00(%[row]) \n\t"
+ "ldc1 %[pp], 0x00(%[prev_row]) \n\t"
+ "paddb %[rp], %[rp], %[pp] \n\t"
+ "sdc1 %[rp], 0x00(%[row]) \n\t"
+
+ "daddiu %[row], %[row], 0x08 \n\t"
+ "daddiu %[prev_row], %[prev_row], 0x08 \n\t"
+ "daddiu %[istop], %[istop], -0x08 \n\t"
+ "bgtz %[istop], 1b \n\t"
+ : [rp]"=&f"(rp), [pp]"=&f"(pp)
+ : [row]"r"(row), [prev_row]"r"(prev_row),
+ [istop]"r"(istop)
+ : "memory"
+ );
+}
+
+void png_read_filter_row_sub3_mmi(png_row_infop row_info, png_bytep row,
+ png_const_bytep prev)
+{
+ int istop = row_info->rowbytes;
+ double rp, pp, dest;
+ double eight, sixteen, twenty_four, forty_eight;
+ double tmp0;
+ double ftmp[2];
+
+ __asm__ volatile (
+ "li %[tmp0], 0x08 \n\t"
+ "dmtc1 %[tmp0], %[eight] \n\t"
+ "li %[tmp0], 0x10 \n\t"
+ "dmtc1 %[tmp0], %[sixteen] \n\t"
+ "li %[tmp0], 0x18 \n\t"
+ "dmtc1 %[tmp0], %[twenty_four] \n\t"
+ "li %[tmp0], 0x30 \n\t"
+ "dmtc1 %[tmp0], %[forty_eight] \n\t"
+ "xor %[dest], %[dest], %[dest] \n\t"
+
+ "1: \n\t"
+ "gsldrc1 %[rp], 0x00(%[row]) \n\t"
+ "gsldlc1 %[rp], 0x07(%[row]) \n\t"
+ "gsldrc1 %[pp], 0x08(%[row]) \n\t"
+ "gsldlc1 %[pp], 0x0f(%[row]) \n\t"
+
+ "paddb %[ftmp0], %[dest], %[rp] \n\t"
+ "swc1 %[ftmp0], 0x00(%[row]) \n\t"
+
+ "dsrl %[ftmp1], %[rp], %[twenty_four] \n\t"
+ "paddb %[dest], %[ftmp1], %[ftmp0] \n\t"
+ "gsswrc1 %[dest], 0x03(%[row]) \n\t"
+ "gsswlc1 %[dest], 0x06(%[row]) \n\t"
+
+ "dsrl %[ftmp0], %[rp], %[forty_eight] \n\t"
+ "dsll %[ftmp1], %[pp], %[sixteen] \n\t"
+ "or %[ftmp0], %[ftmp0], %[ftmp1] \n\t"
+ "paddb %[dest], %[dest], %[ftmp0] \n\t"
+ "gsswrc1 %[dest], 0x06(%[row]) \n\t"
+ "gsswlc1 %[dest], 0x09(%[row]) \n\t"
+
+ "dsrl %[ftmp0], %[pp], %[eight] \n\t"
+ "paddb %[dest], %[dest], %[ftmp0] \n\t"
+ "gsswrc1 %[dest], 0x09(%[row]) \n\t"
+ "daddiu %[row], %[row], 0x0c \n\t"
+ "daddiu %[istop], %[istop], -0x0c \n\t"
+ "bgtz %[istop], 1b \n\t"
+ : [rp]"=&f"(rp), [pp]"=&f"(pp), [dest]"=&f"(dest),
+ [tmp0]"=&r"(tmp0), [ftmp0]"=&f"(ftmp[0]),
+ [ftmp1]"=&f"(ftmp[1]), [eight]"=&f"(eight),
+ [sixteen]"=&f"(sixteen), [twenty_four]"=&f"(twenty_four),
+ [forty_eight]"=&f"(forty_eight)
+ : [row]"r"(row), [istop]"r"(istop)
+ : "memory"
+ );
+
+ PNG_UNUSED(prev)
+}
+
+void png_read_filter_row_sub4_mmi(png_row_infop row_info, png_bytep row,
+ png_const_bytep prev)
+{
+ /* The Sub filter predicts each pixel as the previous pixel, a.
+ * There is no pixel to the left of the first pixel. It's encoded directly.
+ * That works with our main loop if we just say that left pixel was zero.
+ */
+ int istop = row_info->rowbytes;
+ double rp,pp;
+
+ __asm__ volatile (
+ "1: \n\t"
+ "lwc1 %[pp], 0x00(%[row]) \n\t"
+ "lwc1 %[rp], 0x04(%[row]) \n\t"
+ "paddb %[rp], %[rp], %[pp] \n\t"
+ "swc1 %[rp], 0x04(%[row]) \n\t"
+
+ "daddiu %[row], %[row], 0x04 \n\t"
+ "daddiu %[istop], %[istop], -0x04 \n\t"
+ "bgtz %[istop], 1b \n\t"
+ : [rp]"=&f"(rp), [pp]"=&f"(pp)
+ : [row]"r"(row), [istop]"r"(istop)
+ : "memory"
+ );
+
+ PNG_UNUSED(prev)
+}
+
+void png_read_filter_row_avg3_mmi(png_row_infop row_info, png_bytep row,
+ png_const_bytep prev)
+{
+ int istop = row_info->rowbytes;
+ double rp, pp, rp1, pp1;
+ double tmp0;
+ double ftmp[3];
+ double one, dest;
+ double eight, sixteen, twenty_four, forty_eight;
+
+ __asm__ volatile (
+ "li %[tmp0], 0x08 \n\t"
+ "dmtc1 %[tmp0], %[eight] \n\t"
+ "li %[tmp0], 0x10 \n\t"
+ "dmtc1 %[tmp0], %[sixteen] \n\t"
+ "li %[tmp0], 0x18 \n\t"
+ "dmtc1 %[tmp0], %[twenty_four] \n\t"
+ "li %[tmp0], 0x30 \n\t"
+ "dmtc1 %[tmp0], %[forty_eight] \n\t"
+ "xor %[dest], %[dest], %[dest] \n\t"
+
+ "li %[tmp0], 0x01 \n\t"
+ "ins %[tmp0], %[tmp0], 8, 8 \n\t"
+ "dmtc1 %[tmp0], %[one] \n\t"
+ "pshufh %[one], %[one], %[dest] \n\t"
+
+ "1: \n\t"
+ "gsldrc1 %[rp], 0x00(%[row]) \n\t"
+ "gsldlc1 %[rp], 0x07(%[row]) \n\t"
+ "gsldrc1 %[pp], 0x00(%[prev]) \n\t"
+ "gsldlc1 %[pp], 0x07(%[prev]) \n\t"
+ "gsldrc1 %[rp1], 0x08(%[row]) \n\t"
+ "gsldlc1 %[rp1], 0x0f(%[row]) \n\t"
+ "gsldrc1 %[pp1], 0x08(%[prev]) \n\t"
+ "gsldlc1 %[pp1], 0x0f(%[prev]) \n\t"
+
+ "xor %[ftmp0], %[pp], %[dest] \n\t"
+ "pavgb %[ftmp1], %[pp], %[dest] \n\t"
+ "and %[ftmp0], %[ftmp0], %[one] \n\t"
+ "psubb %[ftmp1], %[ftmp1], %[ftmp0] \n\t"
+ "paddb %[dest], %[rp], %[ftmp1] \n\t"
+ "swc1 %[dest], 0x00(%[row]) \n\t"
+
+ "dsrl %[ftmp0], %[rp], %[twenty_four] \n\t"
+ "dsrl %[ftmp1], %[pp], %[twenty_four] \n\t"
+
+ "xor %[ftmp2], %[ftmp1], %[dest] \n\t"
+ "pavgb %[ftmp1], %[ftmp1], %[dest] \n\t"
+ "and %[ftmp2], %[ftmp2], %[one] \n\t"
+ "psubb %[ftmp1], %[ftmp1], %[ftmp2] \n\t"
+ "paddb %[dest], %[ftmp0], %[ftmp1] \n\t"
+ "gsswrc1 %[dest], 0x03(%[row]) \n\t"
+ "gsswlc1 %[dest], 0x06(%[row]) \n\t"
+
+ "dsrl %[ftmp0], %[rp], %[forty_eight] \n\t"
+ "dsll %[ftmp1], %[rp1], %[sixteen] \n\t"
+ "or %[ftmp0], %[ftmp0], %[ftmp1] \n\t"
+ "dsrl %[ftmp2], %[pp], %[forty_eight] \n\t"
+ "dsll %[ftmp1], %[pp1], %[sixteen] \n\t"
+ "or %[ftmp1], %[ftmp2], %[ftmp1] \n\t"
+
+ "xor %[ftmp2], %[ftmp1], %[dest] \n\t"
+ "pavgb %[ftmp1], %[ftmp1], %[dest] \n\t"
+ "and %[ftmp2], %[ftmp2], %[one] \n\t"
+ "psubb %[ftmp1], %[ftmp1], %[ftmp2] \n\t"
+ "paddb %[dest], %[ftmp0], %[ftmp1] \n\t"
+ "gsswrc1 %[dest], 0x06(%[row]) \n\t"
+ "gsswlc1 %[dest], 0x09(%[row]) \n\t"
+
+ "dsrl %[ftmp0], %[rp1], %[eight] \n\t"
+ "dsrl %[ftmp1], %[pp1], %[eight] \n\t"
+
+ "xor %[ftmp2], %[ftmp1], %[dest] \n\t"
+ "pavgb %[ftmp1], %[ftmp1], %[dest] \n\t"
+ "and %[ftmp2], %[ftmp2], %[one] \n\t"
+ "psubb %[ftmp1], %[ftmp1], %[ftmp2] \n\t"
+ "paddb %[dest], %[ftmp0], %[ftmp1] \n\t"
+ "gsswrc1 %[dest], 0x09(%[row]) \n\t"
+ "daddiu %[row], %[row], 0x0c \n\t"
+ "daddiu %[prev], %[prev], 0x0c \n\t"
+ "daddiu %[istop], %[istop], -0x0c \n\t"
+ "bgtz %[istop], 1b \n\t"
+ : [rp]"=&f"(rp), [pp]"=&f"(pp), [rp1]"=&f"(rp1),
+ [pp1]"=&f"(pp1), [tmp0]"=&r"(tmp0), [ftmp0]"=&f"(ftmp[0]),
+ [ftmp1]"=&f"(ftmp[1]), [ftmp2]"=&f"(ftmp[2]), [one]"=&f"(one),
+ [dest]"=&f"(dest), [eight]"=&f"(eight), [sixteen]"=&f"(sixteen),
+ [twenty_four]"=&f"(twenty_four), [forty_eight]"=&f"(forty_eight)
+ : [row]"r"(row), [prev]"r"(prev), [istop]"r"(istop)
+ : "memory"
+ );
+}
+
+void png_read_filter_row_avg4_mmi(png_row_infop row_info, png_bytep row,
+ png_const_bytep prev)
+{
+ int istop = row_info->rowbytes;
+ double rp,pp;
+ double dest;
+ double ftmp[2];
+ double tmp;
+
+ __asm__ volatile (
+ "xor %[dest], %[dest], %[dest] \n\t"
+ "li %[tmp], 0x01 \n\t"
+ "ins %[tmp], %[tmp], 8, 8 \n\t"
+ "dmtc1 %[tmp], %[ftmp1] \n\t"
+ "pshufh %[ftmp1], %[ftmp1], %[dest] \n\t"
+
+ "1: \n\t"
+ "lwc1 %[rp], 0x00(%[row]) \n\t"
+ "lwc1 %[pp], 0x00(%[prev]) \n\t"
+ "xor %[ftmp0], %[pp], %[dest] \n\t"
+ "pavgb %[pp], %[pp], %[dest] \n\t"
+ "and %[ftmp0], %[ftmp0], %[ftmp1] \n\t"
+ "psubb %[pp], %[pp], %[ftmp0] \n\t"
+ "paddb %[dest], %[rp], %[pp] \n\t"
+ "swc1 %[dest], 0x00(%[row]) \n\t"
+ "daddiu %[row], %[row], 0x04 \n\t"
+ "daddiu %[prev], %[prev], 0x04 \n\t"
+ "daddiu %[istop], %[istop], -0x04 \n\t"
+ "bgtz %[istop], 1b \n\t"
+ : [rp]"=&f"(rp), [pp]"=&f"(pp), [ftmp0]"=&f"(ftmp[0]),
+ [ftmp1]"=&f"(ftmp[1]), [dest]"=&f"(dest), [tmp]"=&r"(tmp)
+ : [row]"r"(row), [prev]"r"(prev), [istop]"r"(istop)
+ : "memory"
+ );
+}
+
+void png_read_filter_row_paeth3_mmi(png_row_infop row_info, png_bytep row,
+ png_const_bytep prev)
+{
+ /* Paeth tries to predict pixel d using the pixel to the left of it, a,
+ * and two pixels from the previous row, b and c:
+ * prev: c b
+ * row: a d
+ * The Paeth function predicts d to be whichever of a, b, or c is nearest to
+ * p=a+b-c.
+ *
+ * The first pixel has no left context, and so uses an Up filter, p = b.
+ * This works naturally with our main loop's p = a+b-c if we force a and c
+ * to zero.
+ * Here we zero b and d, which become c and a respectively at the start of
+ * the loop.
+ */
+ int istop = row_info->rowbytes;
+ double rp, pp, rp1, pp1, zero;
+ double a, b, c, d, pa, pb, pc;
+ double tmp0;
+ double ftmp[3];
+ double eight, sixteen, twenty_four, forty_eight;
+
+ __asm__ volatile (
+ "xor %[a], %[a], %[a] \n\t"
+ "xor %[c], %[c], %[c] \n\t"
+ "xor %[zero], %[zero], %[zero] \n\t"
+ "li %[tmp0], 0x08 \n\t"
+ "dmtc1 %[tmp0], %[eight] \n\t"
+ "li %[tmp0], 0x10 \n\t"
+ "dmtc1 %[tmp0], %[sixteen] \n\t"
+ "li %[tmp0], 0x18 \n\t"
+ "dmtc1 %[tmp0], %[twenty_four] \n\t"
+ "li %[tmp0], 0x30 \n\t"
+ "dmtc1 %[tmp0], %[forty_eight] \n\t"
+
+ "1: \n\t"
+ "gsldrc1 %[rp], 0x00(%[row]) \n\t"
+ "gsldlc1 %[rp], 0x07(%[row]) \n\t"
+ "gsldrc1 %[pp], 0x00(%[prev]) \n\t"
+ "gsldlc1 %[pp], 0x07(%[prev]) \n\t"
+ "gsldrc1 %[rp1], 0x08(%[row]) \n\t"
+ "gsldlc1 %[rp1], 0x0f(%[row]) \n\t"
+ "gsldrc1 %[pp1], 0x08(%[prev]) \n\t"
+ "gsldlc1 %[pp1], 0x0f(%[prev]) \n\t"
+
+ "punpcklbh %[b], %[pp], %[zero] \n\t"
+ "punpcklbh %[d], %[rp], %[zero] \n\t"
+ "packushb %[ftmp0], %[c], %[c] \n\t"
+ "packushb %[ftmp1], %[a], %[a] \n\t"
+ "pasubub %[pa], %[pp], %[ftmp0] \n\t"
+ "pasubub %[pb], %[ftmp1], %[ftmp0] \n\t"
+ "psubh %[ftmp0], %[b], %[c] \n\t"
+ "psubh %[ftmp1], %[a], %[c] \n\t"
+ "paddh %[pc], %[ftmp0], %[ftmp1] \n\t"
+ "pcmpgth %[ftmp0], %[zero], %[pc] \n\t"
+ "xor %[pc], %[pc], %[ftmp0] \n\t"
+ "psubh %[pc], %[pc], %[ftmp0] \n\t"
+ "punpcklbh %[pa], %[pa], %[zero] \n\t"
+ "punpcklbh %[pb], %[pb], %[zero] \n\t"
+ "pcmpgth %[ftmp0], %[pa], %[pb] \n\t"
+ "and %[ftmp1], %[b], %[ftmp0] \n\t"
+ "pandn %[a], %[ftmp0], %[a] \n\t"
+ "or %[a], %[a], %[ftmp1] \n\t"
+ "pminsh %[pa], %[pa], %[pb] \n\t"
+ "pcmpgth %[ftmp0], %[pa], %[pc] \n\t"
+ "and %[ftmp1], %[c], %[ftmp0] \n\t"
+ "pandn %[a], %[ftmp0], %[a] \n\t"
+ "or %[a], %[a], %[ftmp1] \n\t"
+ "paddb %[a], %[a], %[d] \n\t"
+ "packushb %[d], %[a], %[a] \n\t"
+ "punpcklbh %[c], %[pp], %[zero] \n\t"
+ "swc1 %[d], 0x00(%[row]) \n\t"
+
+ "dsrl %[ftmp0], %[rp], %[twenty_four] \n\t"
+ "dsrl %[ftmp2], %[pp], %[twenty_four] \n\t"
+
+ "punpcklbh %[b], %[ftmp2], %[zero] \n\t"
+ "punpcklbh %[d], %[ftmp0], %[zero] \n\t"
+ "packushb %[ftmp0], %[c], %[c] \n\t"
+ "packushb %[ftmp1], %[a], %[a] \n\t"
+ "pasubub %[pa], %[ftmp2], %[ftmp0] \n\t"
+ "pasubub %[pb], %[ftmp1], %[ftmp0] \n\t"
+ "psubh %[ftmp0], %[b], %[c] \n\t"
+ "psubh %[ftmp1], %[a], %[c] \n\t"
+ "paddh %[pc], %[ftmp0], %[ftmp1] \n\t"
+ "pcmpgth %[ftmp0], %[zero], %[pc] \n\t"
+ "xor %[pc], %[pc], %[ftmp0] \n\t"
+ "psubh %[pc], %[pc], %[ftmp0] \n\t"
+ "punpcklbh %[pa], %[pa], %[zero] \n\t"
+ "punpcklbh %[pb], %[pb], %[zero] \n\t"
+ "pcmpgth %[ftmp0], %[pa], %[pb] \n\t"
+ "and %[ftmp1], %[b], %[ftmp0] \n\t"
+ "pandn %[a], %[ftmp0], %[a] \n\t"
+ "or %[a], %[a], %[ftmp1] \n\t"
+ "pminsh %[pa], %[pa], %[pb] \n\t"
+ "pcmpgth %[ftmp0], %[pa], %[pc] \n\t"
+ "and %[ftmp1], %[c], %[ftmp0] \n\t"
+ "pandn %[a], %[ftmp0], %[a] \n\t"
+ "or %[a], %[a], %[ftmp1] \n\t"
+ "paddb %[a], %[a], %[d] \n\t"
+ "packushb %[d], %[a], %[a] \n\t"
+ "punpcklbh %[c], %[ftmp2], %[zero] \n\t"
+ "gsswrc1 %[d], 0x03(%[row]) \n\t"
+ "gsswlc1 %[d], 0x06(%[row]) \n\t"
+
+ "dsrl %[ftmp0], %[rp], %[forty_eight] \n\t"
+ "dsll %[ftmp1], %[rp1], %[sixteen] \n\t"
+ "or %[ftmp0], %[ftmp0], %[ftmp1] \n\t"
+ "dsrl %[ftmp2], %[pp], %[forty_eight] \n\t"
+ "dsll %[ftmp1], %[pp1], %[sixteen] \n\t"
+ "or %[ftmp2], %[ftmp2], %[ftmp1] \n\t"
+
+ "punpcklbh %[b], %[ftmp2], %[zero] \n\t"
+ "punpcklbh %[d], %[ftmp0], %[zero] \n\t"
+ "packushb %[ftmp0], %[c], %[c] \n\t"
+ "packushb %[ftmp1], %[a], %[a] \n\t"
+ "pasubub %[pa], %[ftmp2], %[ftmp0] \n\t"
+ "pasubub %[pb], %[ftmp1], %[ftmp0] \n\t"
+ "psubh %[ftmp0], %[b], %[c] \n\t"
+ "psubh %[ftmp1], %[a], %[c] \n\t"
+ "paddh %[pc], %[ftmp0], %[ftmp1] \n\t"
+ "pcmpgth %[ftmp0], %[zero], %[pc] \n\t"
+ "xor %[pc], %[pc], %[ftmp0] \n\t"
+ "psubh %[pc], %[pc], %[ftmp0] \n\t"
+ "punpcklbh %[pa], %[pa], %[zero] \n\t"
+ "punpcklbh %[pb], %[pb], %[zero] \n\t"
+ "pcmpgth %[ftmp0], %[pa], %[pb] \n\t"
+ "and %[ftmp1], %[b], %[ftmp0] \n\t"
+ "pandn %[a], %[ftmp0], %[a] \n\t"
+ "or %[a], %[a], %[ftmp1] \n\t"
+ "pminsh %[pa], %[pa], %[pb] \n\t"
+ "pcmpgth %[ftmp0], %[pa], %[pc] \n\t"
+ "and %[ftmp1], %[c], %[ftmp0] \n\t"
+ "pandn %[a], %[ftmp0], %[a] \n\t"
+ "or %[a], %[a], %[ftmp1] \n\t"
+ "paddb %[a], %[a], %[d] \n\t"
+ "packushb %[d], %[a], %[a] \n\t"
+ "punpcklbh %[c], %[ftmp2], %[zero] \n\t"
+ "gsswrc1 %[d], 0x06(%[row]) \n\t"
+ "gsswlc1 %[d], 0x09(%[row]) \n\t"
+
+ "dsrl %[ftmp0], %[rp1], %[eight] \n\t"
+ "dsrl %[ftmp2], %[pp1], %[eight] \n\t"
+
+ "punpcklbh %[b], %[ftmp2], %[zero] \n\t"
+ "punpcklbh %[d], %[ftmp0], %[zero] \n\t"
+ "packushb %[ftmp0], %[c], %[c] \n\t"
+ "packushb %[ftmp1], %[a], %[a] \n\t"
+ "pasubub %[pa], %[ftmp2], %[ftmp0] \n\t"
+ "pasubub %[pb], %[ftmp1], %[ftmp0] \n\t"
+ "psubh %[ftmp0], %[b], %[c] \n\t"
+ "psubh %[ftmp1], %[a], %[c] \n\t"
+ "paddh %[pc], %[ftmp0], %[ftmp1] \n\t"
+ "pcmpgth %[ftmp0], %[zero], %[pc] \n\t"
+ "xor %[pc], %[pc], %[ftmp0] \n\t"
+ "psubh %[pc], %[pc], %[ftmp0] \n\t"
+ "punpcklbh %[pa], %[pa], %[zero] \n\t"
+ "punpcklbh %[pb], %[pb], %[zero] \n\t"
+ "pcmpgth %[ftmp0], %[pa], %[pb] \n\t"
+ "and %[ftmp1], %[b], %[ftmp0] \n\t"
+ "pandn %[a], %[ftmp0], %[a] \n\t"
+ "or %[a], %[a], %[ftmp1] \n\t"
+ "pminsh %[pa], %[pa], %[pb] \n\t"
+ "pcmpgth %[ftmp0], %[pa], %[pc] \n\t"
+ "and %[ftmp1], %[c], %[ftmp0] \n\t"
+ "pandn %[a], %[ftmp0], %[a] \n\t"
+ "or %[a], %[a], %[ftmp1] \n\t"
+ "paddb %[a], %[a], %[d] \n\t"
+ "packushb %[d], %[a], %[a] \n\t"
+ "punpcklbh %[c], %[ftmp2], %[zero] \n\t"
+ "gsswrc1 %[d], 0x09(%[row]) \n\t"
+
+ "daddiu %[row], %[row], 0x0c \n\t"
+ "daddiu %[prev], %[prev], 0x0c \n\t"
+ "daddiu %[istop], %[istop], -0x0c \n\t"
+ "bgtz %[istop], 1b \n\t"
+ : [rp]"=&f"(rp), [pp]"=&f"(pp), [rp1]"=&f"(rp1), [pp1]"=&f"(pp1),
+ [zero]"=&f"(zero), [a]"=&f"(a),[b]"=&f"(b), [c]"=&f"(c),
+ [d]"=&f"(d), [pa]"=&f"(pa), [pb]"=&f"(pb), [pc]"=&f"(pc),
+ [tmp0]"=&r"(tmp0), [ftmp0]"=&f"(ftmp[0]), [ftmp1]"=&f"(ftmp[1]),
+ [ftmp2]"=&f"(ftmp[2]), [eight]"=&f"(eight), [sixteen]"=&f"(sixteen),
+ [twenty_four]"=&f"(twenty_four), [forty_eight]"=&f"(forty_eight)
+ : [row]"r"(row), [prev]"r"(prev), [istop]"r"(istop)
+ : "memory"
+ );
+}
+
+void png_read_filter_row_paeth4_mmi(png_row_infop row_info, png_bytep row,
+ png_const_bytep prev)
+{
+ /* Paeth tries to predict pixel d using the pixel to the left of it, a,
+ * and two pixels from the previous row, b and c:
+ * prev: c b
+ * row: a d
+ * The Paeth function predicts d to be whichever of a, b, or c is nearest to
+ * p=a+b-c.
+ *
+ * The first pixel has no left context, and so uses an Up filter, p = b.
+ * This works naturally with our main loop's p = a+b-c if we force a and c
+ * to zero.
+ * Here we zero b and d, which become c and a respectively at the start of
+ * the loop.
+ */
+ int istop = row_info->rowbytes;
+ double rp, pp, zero;
+ double a, b, c, d, pa, pb, pc;
+ double ftmp[2];
+
+ __asm__ volatile (
+ "xor %[a], %[a], %[a] \n\t"
+ "xor %[c], %[c], %[c] \n\t"
+ "xor %[zero], %[zero], %[zero] \n\t"
+
+ "1: \n\t"
+ "lwc1 %[rp], 0x00(%[row]) \n\t"
+ "lwc1 %[pp], 0x00(%[prev]) \n\t"
+ "punpcklbh %[b], %[pp], %[zero] \n\t"
+ "punpcklbh %[d], %[rp], %[zero] \n\t"
+
+ "packushb %[ftmp0], %[c], %[c] \n\t"
+ "packushb %[ftmp1], %[a], %[a] \n\t"
+ "pasubub %[pa], %[pp], %[ftmp0] \n\t"
+ "pasubub %[pb], %[ftmp1], %[ftmp0] \n\t"
+ "psubh %[ftmp0], %[b], %[c] \n\t"
+ "psubh %[ftmp1], %[a], %[c] \n\t"
+ "paddh %[pc], %[ftmp0], %[ftmp1] \n\t"
+ "pcmpgth %[ftmp0], %[zero], %[pc] \n\t"
+ "xor %[pc], %[pc], %[ftmp0] \n\t"
+ "psubh %[pc], %[pc], %[ftmp0] \n\t"
+
+ "punpcklbh %[pa], %[pa], %[zero] \n\t"
+ "punpcklbh %[pb], %[pb], %[zero] \n\t"
+
+ "pcmpgth %[ftmp0], %[pa], %[pb] \n\t"
+ "and %[ftmp1], %[b], %[ftmp0] \n\t"
+ "pandn %[a], %[ftmp0], %[a] \n\t"
+ "or %[a], %[a], %[ftmp1] \n\t"
+ "pminsh %[pa], %[pa], %[pb] \n\t"
+
+ "pcmpgth %[ftmp0], %[pa], %[pc] \n\t"
+ "and %[ftmp1], %[c], %[ftmp0] \n\t"
+ "pandn %[a], %[ftmp0], %[a] \n\t"
+ "or %[a], %[a], %[ftmp1] \n\t"
+ "paddb %[a], %[a], %[d] \n\t"
+ "packushb %[d], %[a], %[a] \n\t"
+ "swc1 %[d], 0x00(%[row]) \n\t"
+ "punpcklbh %[c], %[pp], %[zero] \n\t"
+ "daddiu %[row], %[row], 0x04 \n\t"
+ "daddiu %[prev], %[prev], 0x04 \n\t"
+ "daddiu %[istop], %[istop], -0x04 \n\t"
+ "bgtz %[istop], 1b \n\t"
+ : [rp]"=&f"(rp), [pp]"=&f"(pp), [zero]"=&f"(zero),
+ [a]"=&f"(a), [b]"=&f"(b), [c]"=&f"(c), [d]"=&f"(d),
+ [pa]"=&f"(pa), [pb]"=&f"(pb), [pc]"=&f"(pc),
+ [ftmp0]"=&f"(ftmp[0]), [ftmp1]"=&f"(ftmp[1])
+ : [row]"r"(row), [prev]"r"(prev), [istop]"r"(istop)
+ : "memory"
+ );
+}
+
+#endif /* PNG_MIPS_MMI_IMPLEMENTATION > 0 */
+#endif /* READ */
diff --git a/Build/source/libs/libpng/libpng-src/mips/filter_msa_intrinsics.c b/Build/source/libs/libpng/libpng-src/mips/filter_msa_intrinsics.c
index a579179421c..1b734f4d9a7 100644
--- a/Build/source/libs/libpng/libpng-src/mips/filter_msa_intrinsics.c
+++ b/Build/source/libs/libpng/libpng-src/mips/filter_msa_intrinsics.c
@@ -1,9 +1,9 @@
/* filter_msa_intrinsics.c - MSA optimised filter functions
*
- * Copyright (c) 2018 Cosmin Truta
+ * Copyright (c) 2018-2024 Cosmin Truta
* Copyright (c) 2016 Glenn Randers-Pehrson
- * Written by Mandar Sahastrabuddhe, August 2016.
+ * Written by Mandar Sahastrabuddhe, August 2016
*
* This code is released under the libpng license.
* For conditions of distribution and use, see the disclaimer
@@ -11,7 +11,6 @@
*/
#include <stdio.h>
-#include <stdint.h>
#include "../pngpriv.h"
#ifdef PNG_READ_SUPPORTED
@@ -20,6 +19,7 @@
#if PNG_MIPS_MSA_IMPLEMENTATION == 1 /* intrinsics code from pngpriv.h */
#include <msa.h>
+#include <stdint.h>
/* libpng row pointers are not necessarily aligned to any particular boundary,
* however this code will only work with appropriate alignment. mips/mips_init.c
@@ -379,8 +379,8 @@ void png_read_filter_row_up_msa(png_row_infop row_info, png_bytep row,
LD_UB4(pp, 16, src4, src5, src6, src7);
pp += 64;
- ADD4(src0, src4, src1, src5, src2, src6, src3, src7,
- src0, src1, src2, src3);
+ ADD4(src0, src4, src1, src5, src2, src6, src3, src7,
+ src0, src1, src2, src3);
ST_UB4(src0, src1, src2, src3, rp, 16);
rp += 64;
@@ -400,7 +400,7 @@ void png_read_filter_row_up_msa(png_row_infop row_info, png_bytep row,
LD_UB4(pp, 16, src4, src5, src6, src7);
ADD4(src0, src4, src1, src5, src2, src6, src3, src7,
- src0, src1, src2, src3);
+ src0, src1, src2, src3);
ST_UB4(src0, src1, src2, src3, rp, 16);
rp += 64;
@@ -425,7 +425,7 @@ void png_read_filter_row_up_msa(png_row_infop row_info, png_bytep row,
LD_UB2(rp, 16, src0, src1);
LD_UB2(pp, 16, src4, src5);
- ADD2(src0, src4, src1, src5, src0, src1);
+ ADD2(src0, src4, src1, src5, src0, src1);
ST_UB2(src0, src1, rp, 16);
rp += 32;
diff --git a/Build/source/libs/libpng/libpng-src/mips/mips_init.c b/Build/source/libs/libpng/libpng-src/mips/mips_init.c
index 8dd283deefe..5c6fa1dbf11 100644
--- a/Build/source/libs/libpng/libpng-src/mips/mips_init.c
+++ b/Build/source/libs/libpng/libpng-src/mips/mips_init.c
@@ -1,9 +1,10 @@
/* mips_init.c - MSA optimised filter functions
*
- * Copyright (c) 2018 Cosmin Truta
+ * Copyright (c) 2018-2024 Cosmin Truta
* Copyright (c) 2016 Glenn Randers-Pehrson
- * Written by Mandar Sahastrabuddhe, 2016.
+ * Written by Mandar Sahastrabuddhe, 2016
+ * Updated by guxiwei, 2023
*
* This code is released under the libpng license.
* For conditions of distribution and use, see the disclaimer
@@ -20,8 +21,9 @@
#ifdef PNG_READ_SUPPORTED
-#if PNG_MIPS_MSA_OPT > 0
-#ifdef PNG_MIPS_MSA_CHECK_SUPPORTED /* Do run-time checks */
+#if PNG_MIPS_MSA_IMPLEMENTATION == 1 || PNG_MIPS_MMI_IMPLEMENTATION > 0
+
+#ifdef PNG_MIPS_MSA_CHECK_SUPPORTED /* Do MIPS MSA run-time checks */
/* WARNING: it is strongly recommended that you do not build libpng with
* run-time checks for CPU features if at all possible. In the case of the MIPS
* MSA instructions there is no processor-specific way of detecting the
@@ -51,13 +53,83 @@ static int png_have_msa(png_structp png_ptr);
#endif /* PNG_MIPS_MSA_FILE */
#endif /* PNG_MIPS_MSA_CHECK_SUPPORTED */
+#ifdef PNG_MIPS_MMI_CHECK_SUPPORTED /* Do MIPS MMI run-times checks */
+#ifndef PNG_MIPS_MMI_FILE
+# ifdef __linux__
+# define PNG_MIPS_MMI_FILE "contrib/mips-mmi/linux.c"
+# endif
+#endif
+
+#ifdef PNG_MIPS_MMI_FILE
+
+#include <signal.h> /* for sig_atomic_t */
+static int png_have_mmi();
+#include PNG_MIPS_MMI_FILE
+
+#else /* PNG_MIPS_MMI_FILE */
+# error "PNG_MIPS_MMI_FILE undefined: no support for run-time MIPS MMI checks"
+#endif /* PNG_MIPS_MMI_FILE */
+#endif /* PNG_MIPS_MMI_CHECK_SUPPORTED*/
+
#ifndef PNG_ALIGNED_MEMORY_SUPPORTED
# error "ALIGNED_MEMORY is required; set: -DPNG_ALIGNED_MEMORY_SUPPORTED"
#endif
+/* MIPS supports two optimizations: MMI and MSA. The appropriate
+ * optimization is chosen at runtime
+ */
void
-png_init_filter_functions_msa(png_structp pp, unsigned int bpp)
+png_init_filter_functions_mips(png_structp pp, unsigned int bpp)
{
+#if PNG_MIPS_MMI_IMPLEMENTATION > 0
+#ifdef PNG_MIPS_MMI_API_SUPPORTED
+ switch ((pp->options >> PNG_MIPS_MMI) & 3)
+ {
+ case PNG_OPTION_UNSET:
+#endif /* PNG_MIPS_MMI_API_SUPPORTED */
+#ifdef PNG_MIPS_MMI_CHECK_SUPPORTED
+ {
+ static volatile sig_atomic_t no_mmi = -1; /* not checked */
+
+ if (no_mmi < 0)
+ no_mmi = !png_have_mmi();
+
+ if (no_mmi)
+ goto MIPS_MSA_INIT;
+ }
+#ifdef PNG_MIPS_MMI_API_SUPPORTED
+ break;
+#endif
+#endif /* PNG_MIPS_MMI_CHECK_SUPPORTED */
+
+#ifdef PNG_MIPS_MMI_API_SUPPORTED
+ default: /* OFF or INVALID */
+ goto MIPS_MSA_INIT;
+
+ case PNG_OPTION_ON:
+ /* Option turned on */
+ break;
+ }
+#endif
+ pp->read_filter[PNG_FILTER_VALUE_UP-1] = png_read_filter_row_up_mmi;
+ if (bpp == 3)
+ {
+ pp->read_filter[PNG_FILTER_VALUE_SUB-1] = png_read_filter_row_sub3_mmi;
+ pp->read_filter[PNG_FILTER_VALUE_AVG-1] = png_read_filter_row_avg3_mmi;
+ pp->read_filter[PNG_FILTER_VALUE_PAETH-1] =
+ png_read_filter_row_paeth3_mmi;
+ }
+ else if (bpp == 4)
+ {
+ pp->read_filter[PNG_FILTER_VALUE_SUB-1] = png_read_filter_row_sub4_mmi;
+ pp->read_filter[PNG_FILTER_VALUE_AVG-1] = png_read_filter_row_avg4_mmi;
+ pp->read_filter[PNG_FILTER_VALUE_PAETH-1] =
+ png_read_filter_row_paeth4_mmi;
+ }
+#endif /* PNG_MIPS_MMI_IMPLEMENTATION > 0 */
+
+MIPS_MSA_INIT:
+#if PNG_MIPS_MSA_IMPLEMENTATION == 1
/* The switch statement is compiled in for MIPS_MSA_API, the call to
* png_have_msa is compiled in for MIPS_MSA_CHECK. If both are defined
* the check is only performed if the API has not set the MSA option on
@@ -125,6 +197,8 @@ png_init_filter_functions_msa(png_structp pp, unsigned int bpp)
pp->read_filter[PNG_FILTER_VALUE_AVG-1] = png_read_filter_row_avg4_msa;
pp->read_filter[PNG_FILTER_VALUE_PAETH-1] = png_read_filter_row_paeth4_msa;
}
+#endif /* PNG_MIPS_MSA_IMPLEMENTATION == 1 */
+ return;
}
-#endif /* PNG_MIPS_MSA_OPT > 0 */
+#endif /* PNG_MIPS_MSA_IMPLEMENTATION == 1 || PNG_MIPS_MMI_IMPLEMENTATION > 0 */
#endif /* READ */
diff --git a/Build/source/libs/libpng/libpng-src/png.5 b/Build/source/libs/libpng/libpng-src/png.5
index 5442ea17f8c..e2c177a7e9c 100644
--- a/Build/source/libs/libpng/libpng-src/png.5
+++ b/Build/source/libs/libpng/libpng-src/png.5
@@ -1,4 +1,4 @@
-.TH PNG 5 "June 21, 2023"
+.TH PNG 5 "January 24, 2024"
.SH NAME
png \- Portable Network Graphics (PNG) format
diff --git a/Build/source/libs/libpng/libpng-src/png.c b/Build/source/libs/libpng/libpng-src/png.c
index d6471b06ccd..e411381f8f9 100644
--- a/Build/source/libs/libpng/libpng-src/png.c
+++ b/Build/source/libs/libpng/libpng-src/png.c
@@ -1,7 +1,7 @@
/* png.c - location for general purpose libpng functions
*
- * Copyright (c) 2018-2023 Cosmin Truta
+ * Copyright (c) 2018-2024 Cosmin Truta
* Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson
* Copyright (c) 1996-1997 Andreas Dilger
* Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
@@ -14,27 +14,7 @@
#include "pngpriv.h"
/* Generate a compiler error if there is an old png.h in the search path. */
-typedef png_libpng_version_1_6_40 Your_png_h_is_not_version_1_6_40;
-
-#ifdef __GNUC__
-/* The version tests may need to be added to, but the problem warning has
- * consistently been fixed in GCC versions which obtain wide-spread release.
- * The problem is that many versions of GCC rearrange comparison expressions in
- * the optimizer in such a way that the results of the comparison will change
- * if signed integer overflow occurs. Such comparisons are not permitted in
- * ANSI C90, however GCC isn't clever enough to work out that that do not occur
- * below in png_ascii_from_fp and png_muldiv, so it produces a warning with
- * -Wextra. Unfortunately this is highly dependent on the optimizer and the
- * machine architecture so the warning comes and goes unpredictably and is
- * impossible to "fix", even were that a good idea.
- */
-#if __GNUC__ == 7 && __GNUC_MINOR__ == 1
-#define GCC_STRICT_OVERFLOW 1
-#endif /* GNU 7.1.x */
-#endif /* GNU */
-#ifndef GCC_STRICT_OVERFLOW
-#define GCC_STRICT_OVERFLOW 0
-#endif
+typedef png_libpng_version_1_6_41 Your_png_h_is_not_version_1_6_41;
/* Tells libpng that we have already handled the first "num_bytes" bytes
* of the PNG file signature. If the PNG data is embedded into another
@@ -73,21 +53,21 @@ png_set_sig_bytes(png_structrp png_ptr, int num_bytes)
int PNGAPI
png_sig_cmp(png_const_bytep sig, size_t start, size_t num_to_check)
{
- png_byte png_signature[8] = {137, 80, 78, 71, 13, 10, 26, 10};
+ static const png_byte png_signature[8] = {137, 80, 78, 71, 13, 10, 26, 10};
if (num_to_check > 8)
num_to_check = 8;
else if (num_to_check < 1)
- return (-1);
+ return -1;
if (start > 7)
- return (-1);
+ return -1;
if (start + num_to_check > 8)
num_to_check = 8 - start;
- return ((int)(memcmp(&sig[start], &png_signature[start], num_to_check)));
+ return memcmp(&sig[start], &png_signature[start], num_to_check);
}
#endif /* READ */
@@ -447,7 +427,6 @@ png_info_init_3,(png_infopp ptr_ptr, size_t png_info_struct_size),
memset(info_ptr, 0, (sizeof *info_ptr));
}
-/* The following API is not called internally */
void PNGAPI
png_data_freer(png_const_structrp png_ptr, png_inforp info_ptr,
int freer, png_uint_32 mask)
@@ -686,9 +665,9 @@ png_voidp PNGAPI
png_get_io_ptr(png_const_structrp png_ptr)
{
if (png_ptr == NULL)
- return (NULL);
+ return NULL;
- return (png_ptr->io_ptr);
+ return png_ptr->io_ptr;
}
#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED)
@@ -752,7 +731,7 @@ png_convert_to_rfc1123_buffer(char out[29], png_const_timep ptime)
{
size_t pos = 0;
- char number_buf[5]; /* enough for a four-digit year */
+ char number_buf[5] = {0, 0, 0, 0, 0}; /* enough for a four-digit year */
# define APPEND_STRING(string) pos = png_safecat(out, 29, pos, (string))
# define APPEND_NUMBER(format, value)\
@@ -815,8 +794,8 @@ png_get_copyright(png_const_structrp png_ptr)
return PNG_STRING_COPYRIGHT
#else
return PNG_STRING_NEWLINE \
- "libpng version 1.6.40" PNG_STRING_NEWLINE \
- "Copyright (c) 2018-2023 Cosmin Truta" PNG_STRING_NEWLINE \
+ "libpng version 1.6.41" PNG_STRING_NEWLINE \
+ "Copyright (c) 2018-2024 Cosmin Truta" PNG_STRING_NEWLINE \
"Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson" \
PNG_STRING_NEWLINE \
"Copyright (c) 1996-1997 Andreas Dilger" PNG_STRING_NEWLINE \
@@ -977,7 +956,7 @@ png_reset_zstream(png_structrp png_ptr)
return Z_STREAM_ERROR;
/* WARNING: this resets the window bits to the maximum! */
- return (inflateReset(&png_ptr->zstream));
+ return inflateReset(&png_ptr->zstream);
}
#endif /* READ */
@@ -986,7 +965,7 @@ png_uint_32 PNGAPI
png_access_version_number(void)
{
/* Version of *.c files used when building libpng */
- return((png_uint_32)PNG_LIBPNG_VER);
+ return (png_uint_32)PNG_LIBPNG_VER;
}
#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED)
@@ -2891,14 +2870,6 @@ png_pow10(int power)
/* Function to format a floating point value in ASCII with a given
* precision.
*/
-#if GCC_STRICT_OVERFLOW
-#pragma GCC diagnostic push
-/* The problem arises below with exp_b10, which can never overflow because it
- * comes, originally, from frexp and is therefore limited to a range which is
- * typically +/-710 (log2(DBL_MAX)/log2(DBL_MIN)).
- */
-#pragma GCC diagnostic warning "-Wstrict-overflow=2"
-#endif /* GCC_STRICT_OVERFLOW */
void /* PRIVATE */
png_ascii_from_fp(png_const_structrp png_ptr, png_charp ascii, size_t size,
double fp, unsigned int precision)
@@ -3220,10 +3191,6 @@ png_ascii_from_fp(png_const_structrp png_ptr, png_charp ascii, size_t size,
/* Here on buffer too small. */
png_error(png_ptr, "ASCII conversion buffer too small");
}
-#if GCC_STRICT_OVERFLOW
-#pragma GCC diagnostic pop
-#endif /* GCC_STRICT_OVERFLOW */
-
# endif /* FLOATING_POINT */
# ifdef PNG_FIXED_POINT_SUPPORTED
@@ -3251,7 +3218,7 @@ png_ascii_from_fixed(png_const_structrp png_ptr, png_charp ascii,
if (num <= 0x80000000) /* else overflowed */
{
unsigned int ndigits = 0, first = 16 /* flag value */;
- char digits[10];
+ char digits[10] = {0};
while (num)
{
@@ -3336,15 +3303,6 @@ png_fixed(png_const_structrp png_ptr, double fp, png_const_charp text)
* the nearest .00001). Overflow and divide by zero are signalled in
* the result, a boolean - true on success, false on overflow.
*/
-#if GCC_STRICT_OVERFLOW /* from above */
-/* It is not obvious which comparison below gets optimized in such a way that
- * signed overflow would change the result; looking through the code does not
- * reveal any tests which have the form GCC complains about, so presumably the
- * optimizer is moving an add or subtract into the 'if' somewhere.
- */
-#pragma GCC diagnostic push
-#pragma GCC diagnostic warning "-Wstrict-overflow=2"
-#endif /* GCC_STRICT_OVERFLOW */
int
png_muldiv(png_fixed_point_p res, png_fixed_point a, png_int_32 times,
png_int_32 divisor)
@@ -3459,9 +3417,6 @@ png_muldiv(png_fixed_point_p res, png_fixed_point a, png_int_32 times,
return 0;
}
-#if GCC_STRICT_OVERFLOW
-#pragma GCC diagnostic pop
-#endif /* GCC_STRICT_OVERFLOW */
#endif /* READ_GAMMA || INCH_CONVERSIONS */
#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_INCH_CONVERSIONS_SUPPORTED)
diff --git a/Build/source/libs/libpng/libpng-src/png.h b/Build/source/libs/libpng/libpng-src/png.h
index cfc4841099d..d78c7799341 100644
--- a/Build/source/libs/libpng/libpng-src/png.h
+++ b/Build/source/libs/libpng/libpng-src/png.h
@@ -1,9 +1,9 @@
/* png.h - header file for PNG reference library
*
- * libpng version 1.6.40
+ * libpng version 1.6.41
*
- * Copyright (c) 2018-2023 Cosmin Truta
+ * Copyright (c) 2018-2024 Cosmin Truta
* Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson
* Copyright (c) 1996-1997 Andreas Dilger
* Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
@@ -15,7 +15,7 @@
* libpng versions 0.89, June 1996, through 0.96, May 1997: Andreas Dilger
* libpng versions 0.97, January 1998, through 1.6.35, July 2018:
* Glenn Randers-Pehrson
- * libpng versions 1.6.36, December 2018, through 1.6.40, June 2023:
+ * libpng versions 1.6.36, December 2018, through 1.6.41, January 2024:
* Cosmin Truta
* See also "Contributing Authors", below.
*/
@@ -27,8 +27,8 @@
* PNG Reference Library License version 2
* ---------------------------------------
*
- * * Copyright (c) 1995-2023 The PNG Reference Library Authors.
- * * Copyright (c) 2018-2023 Cosmin Truta.
+ * * Copyright (c) 1995-2024 The PNG Reference Library Authors.
+ * * Copyright (c) 2018-2024 Cosmin Truta.
* * Copyright (c) 2000-2002, 2004, 2006-2018 Glenn Randers-Pehrson.
* * Copyright (c) 1996-1997 Andreas Dilger.
* * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
@@ -239,7 +239,7 @@
* ...
* 1.5.30 15 10530 15.so.15.30[.0]
* ...
- * 1.6.40 16 10640 16.so.16.40[.0]
+ * 1.6.41 16 10641 16.so.16.41[.0]
*
* Henceforth the source version will match the shared-library major and
* minor numbers; the shared-library major version number will be used for
@@ -278,8 +278,8 @@
*/
/* Version information for png.h - this should match the version in png.c */
-#define PNG_LIBPNG_VER_STRING "1.6.40"
-#define PNG_HEADER_VERSION_STRING " libpng version 1.6.40 - June 21, 2023\n"
+#define PNG_LIBPNG_VER_STRING "1.6.41"
+#define PNG_HEADER_VERSION_STRING " libpng version " PNG_LIBPNG_VER_STRING "\n"
#define PNG_LIBPNG_VER_SONUM 16
#define PNG_LIBPNG_VER_DLLNUM 16
@@ -287,7 +287,7 @@
/* These should match the first 3 components of PNG_LIBPNG_VER_STRING: */
#define PNG_LIBPNG_VER_MAJOR 1
#define PNG_LIBPNG_VER_MINOR 6
-#define PNG_LIBPNG_VER_RELEASE 40
+#define PNG_LIBPNG_VER_RELEASE 41
/* This should be zero for a public release, or non-zero for a
* development version. [Deprecated]
@@ -318,7 +318,7 @@
* From version 1.0.1 it is:
* XXYYZZ, where XX=major, YY=minor, ZZ=release
*/
-#define PNG_LIBPNG_VER 10640 /* 1.6.40 */
+#define PNG_LIBPNG_VER 10641 /* 1.6.41 */
/* Library configuration: these options cannot be changed after
* the library has been built.
@@ -428,7 +428,7 @@ extern "C" {
/* This triggers a compiler error in png.c, if png.c and png.h
* do not agree upon the version number.
*/
-typedef char* png_libpng_version_1_6_40;
+typedef char* png_libpng_version_1_6_41;
/* Basic control structions. Read libpng-manual.txt or libpng.3 for more info.
*
@@ -849,7 +849,7 @@ PNG_FUNCTION(void, (PNGCAPI *png_longjmp_ptr), PNGARG((jmp_buf, int)), typedef);
#define PNG_TRANSFORM_GRAY_TO_RGB 0x2000 /* read only */
/* Added to libpng-1.5.4 */
#define PNG_TRANSFORM_EXPAND_16 0x4000 /* read only */
-#if INT_MAX >= 0x8000 /* else this might break */
+#if ~0U > 0xffffU /* or else this might break on a 16-bit machine */
#define PNG_TRANSFORM_SCALE_16 0x8000 /* read only */
#endif
@@ -908,15 +908,15 @@ PNG_EXPORT(2, void, png_set_sig_bytes, (png_structrp png_ptr, int num_bytes));
/* Check sig[start] through sig[start + num_to_check - 1] to see if it's a
* PNG file. Returns zero if the supplied bytes match the 8-byte PNG
* signature, and non-zero otherwise. Having num_to_check == 0 or
- * start > 7 will always fail (ie return non-zero).
+ * start > 7 will always fail (i.e. return non-zero).
*/
PNG_EXPORT(3, int, png_sig_cmp, (png_const_bytep sig, size_t start,
size_t num_to_check));
/* Simple signature checking function. This is the same as calling
- * png_check_sig(sig, n) := !png_sig_cmp(sig, 0, n).
+ * png_check_sig(sig, n) := (png_sig_cmp(sig, 0, n) != 0).
*/
-#define png_check_sig(sig, n) !png_sig_cmp((sig), 0, (n))
+#define png_check_sig(sig, n) (png_sig_cmp((sig), 0, (n)) != 0)
/* Allocate and initialize png_ptr struct for reading, and any other memory. */
PNG_EXPORTA(4, png_structp, png_create_read_struct,
@@ -1730,12 +1730,9 @@ PNG_EXPORT(97, void, png_free, (png_const_structrp png_ptr, png_voidp ptr));
PNG_EXPORT(98, void, png_free_data, (png_const_structrp png_ptr,
png_inforp info_ptr, png_uint_32 free_me, int num));
-/* Reassign responsibility for freeing existing data, whether allocated
+/* Reassign the responsibility for freeing existing data, whether allocated
* by libpng or by the application; this works on the png_info structure passed
- * in, it does not change the state for other png_info structures.
- *
- * It is unlikely that this function works correctly as of 1.6.0 and using it
- * may result either in memory leaks or double free of allocated data.
+ * in, without changing the state for other png_info structures.
*/
PNG_EXPORT(99, void, png_data_freer, (png_const_structrp png_ptr,
png_inforp info_ptr, int freer, png_uint_32 mask));
@@ -3207,11 +3204,18 @@ PNG_EXPORT(245, int, png_image_write_to_memory, (png_imagep image, void *memory,
#ifdef PNG_MIPS_MSA_API_SUPPORTED
# define PNG_MIPS_MSA 6 /* HARDWARE: MIPS Msa SIMD instructions supported */
#endif
-#define PNG_IGNORE_ADLER32 8
+#ifdef PNG_DISABLE_ADLER32_CHECK_SUPPORTED
+# define PNG_IGNORE_ADLER32 8 /* SOFTWARE: disable Adler32 check on IDAT */
+#endif
#ifdef PNG_POWERPC_VSX_API_SUPPORTED
-# define PNG_POWERPC_VSX 10 /* HARDWARE: PowerPC VSX SIMD instructions supported */
+# define PNG_POWERPC_VSX 10 /* HARDWARE: PowerPC VSX SIMD instructions
+ * supported */
#endif
-#define PNG_OPTION_NEXT 12 /* Next option - numbers must be even */
+#ifdef PNG_MIPS_MMI_API_SUPPORTED
+# define PNG_MIPS_MMI 12 /* HARDWARE: MIPS MMI SIMD instructions supported */
+#endif
+
+#define PNG_OPTION_NEXT 14 /* Next option - numbers must be even */
/* Return values: NOTE: there are four values and 'off' is *not* zero */
#define PNG_OPTION_UNSET 0 /* Unset - defaults to off */
diff --git a/Build/source/libs/libpng/libpng-src/pngconf.h b/Build/source/libs/libpng/libpng-src/pngconf.h
index 6671e3c3356..30c1aad52d7 100644
--- a/Build/source/libs/libpng/libpng-src/pngconf.h
+++ b/Build/source/libs/libpng/libpng-src/pngconf.h
@@ -1,9 +1,9 @@
/* pngconf.h - machine-configurable file for libpng
*
- * libpng version 1.6.40
+ * libpng version 1.6.41
*
- * Copyright (c) 2018-2022 Cosmin Truta
+ * Copyright (c) 2018-2024 Cosmin Truta
* Copyright (c) 1998-2002,2004,2006-2016,2018 Glenn Randers-Pehrson
* Copyright (c) 1996-1997 Andreas Dilger
* Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
diff --git a/Build/source/libs/libpng/libpng-src/pngerror.c b/Build/source/libs/libpng/libpng-src/pngerror.c
index ec3a709b9d2..29ebda79437 100644
--- a/Build/source/libs/libpng/libpng-src/pngerror.c
+++ b/Build/source/libs/libpng/libpng-src/pngerror.c
@@ -1,7 +1,7 @@
/* pngerror.c - stub functions for i/o and memory allocation
*
- * Copyright (c) 2018 Cosmin Truta
+ * Copyright (c) 2018-2024 Cosmin Truta
* Copyright (c) 1998-2002,2004,2006-2017 Glenn Randers-Pehrson
* Copyright (c) 1996-1997 Andreas Dilger
* Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
@@ -255,7 +255,7 @@ void
png_warning_parameter_unsigned(png_warning_parameters p, int number, int format,
png_alloc_size_t value)
{
- char buffer[PNG_NUMBER_BUFFER_SIZE];
+ char buffer[PNG_NUMBER_BUFFER_SIZE] = {0};
png_warning_parameter(p, number, PNG_FORMAT_NUMBER(buffer, format, value));
}
@@ -265,7 +265,7 @@ png_warning_parameter_signed(png_warning_parameters p, int number, int format,
{
png_alloc_size_t u;
png_charp str;
- char buffer[PNG_NUMBER_BUFFER_SIZE];
+ char buffer[PNG_NUMBER_BUFFER_SIZE] = {0};
/* Avoid overflow by doing the negate in a png_alloc_size_t: */
u = (png_alloc_size_t)value;
@@ -858,7 +858,7 @@ png_get_error_ptr(png_const_structrp png_ptr)
if (png_ptr == NULL)
return NULL;
- return ((png_voidp)png_ptr->error_ptr);
+ return (png_voidp)png_ptr->error_ptr;
}
@@ -933,31 +933,25 @@ png_safe_warning(png_structp png_nonconst_ptr, png_const_charp warning_message)
#endif
int /* PRIVATE */
-png_safe_execute(png_imagep image_in, int (*function)(png_voidp), png_voidp arg)
+png_safe_execute(png_imagep image, int (*function)(png_voidp), png_voidp arg)
{
- volatile png_imagep image = image_in;
- volatile int result;
- volatile png_voidp saved_error_buf;
+ png_voidp saved_error_buf = image->opaque->error_buf;
jmp_buf safe_jmpbuf;
+ int result;
- /* Safely execute function(arg) with png_error returning to this function. */
- saved_error_buf = image->opaque->error_buf;
- result = setjmp(safe_jmpbuf) == 0;
-
- if (result != 0)
+ /* Safely execute function(arg), with png_error returning back here. */
+ if (setjmp(safe_jmpbuf) == 0)
{
-
image->opaque->error_buf = safe_jmpbuf;
result = function(arg);
+ image->opaque->error_buf = saved_error_buf;
+ return result;
}
+ /* On png_error, return via longjmp, pop the jmpbuf, and free the image. */
image->opaque->error_buf = saved_error_buf;
-
- /* And do the cleanup prior to any failure return. */
- if (result == 0)
- png_image_free(image);
-
- return result;
+ png_image_free(image);
+ return 0;
}
#endif /* SIMPLIFIED READ || SIMPLIFIED_WRITE */
#endif /* READ || WRITE */
diff --git a/Build/source/libs/libpng/libpng-src/pngget.c b/Build/source/libs/libpng/libpng-src/pngget.c
index 1490a032e1a..1084b268ff9 100644
--- a/Build/source/libs/libpng/libpng-src/pngget.c
+++ b/Build/source/libs/libpng/libpng-src/pngget.c
@@ -1,7 +1,7 @@
/* pngget.c - retrieval of values from info struct
*
- * Copyright (c) 2018-2023 Cosmin Truta
+ * Copyright (c) 2018-2024 Cosmin Truta
* Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson
* Copyright (c) 1996-1997 Andreas Dilger
* Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
@@ -28,22 +28,22 @@ png_get_valid(png_const_structrp png_ptr, png_const_inforp info_ptr,
* valid tRNS chunk in this case.
*/
if (flag == PNG_INFO_tRNS && png_ptr->num_trans == 0)
- return(0);
+ return 0;
#endif
- return(info_ptr->valid & flag);
+ return info_ptr->valid & flag;
}
- return(0);
+ return 0;
}
size_t PNGAPI
png_get_rowbytes(png_const_structrp png_ptr, png_const_inforp info_ptr)
{
if (png_ptr != NULL && info_ptr != NULL)
- return(info_ptr->rowbytes);
+ return info_ptr->rowbytes;
- return(0);
+ return 0;
}
#ifdef PNG_INFO_IMAGE_SUPPORTED
@@ -51,9 +51,9 @@ png_bytepp PNGAPI
png_get_rows(png_const_structrp png_ptr, png_const_inforp info_ptr)
{
if (png_ptr != NULL && info_ptr != NULL)
- return(info_ptr->row_pointers);
+ return info_ptr->row_pointers;
- return(0);
+ return 0;
}
#endif
@@ -65,7 +65,7 @@ png_get_image_width(png_const_structrp png_ptr, png_const_inforp info_ptr)
if (png_ptr != NULL && info_ptr != NULL)
return info_ptr->width;
- return (0);
+ return 0;
}
png_uint_32 PNGAPI
@@ -74,7 +74,7 @@ png_get_image_height(png_const_structrp png_ptr, png_const_inforp info_ptr)
if (png_ptr != NULL && info_ptr != NULL)
return info_ptr->height;
- return (0);
+ return 0;
}
png_byte PNGAPI
@@ -83,7 +83,7 @@ png_get_bit_depth(png_const_structrp png_ptr, png_const_inforp info_ptr)
if (png_ptr != NULL && info_ptr != NULL)
return info_ptr->bit_depth;
- return (0);
+ return 0;
}
png_byte PNGAPI
@@ -92,7 +92,7 @@ png_get_color_type(png_const_structrp png_ptr, png_const_inforp info_ptr)
if (png_ptr != NULL && info_ptr != NULL)
return info_ptr->color_type;
- return (0);
+ return 0;
}
png_byte PNGAPI
@@ -101,7 +101,7 @@ png_get_filter_type(png_const_structrp png_ptr, png_const_inforp info_ptr)
if (png_ptr != NULL && info_ptr != NULL)
return info_ptr->filter_type;
- return (0);
+ return 0;
}
png_byte PNGAPI
@@ -110,7 +110,7 @@ png_get_interlace_type(png_const_structrp png_ptr, png_const_inforp info_ptr)
if (png_ptr != NULL && info_ptr != NULL)
return info_ptr->interlace_type;
- return (0);
+ return 0;
}
png_byte PNGAPI
@@ -119,7 +119,7 @@ png_get_compression_type(png_const_structrp png_ptr, png_const_inforp info_ptr)
if (png_ptr != NULL && info_ptr != NULL)
return info_ptr->compression_type;
- return (0);
+ return 0;
}
png_uint_32 PNGAPI
@@ -127,21 +127,20 @@ png_get_x_pixels_per_meter(png_const_structrp png_ptr, png_const_inforp
info_ptr)
{
#ifdef PNG_pHYs_SUPPORTED
+ png_debug(1, "in png_get_x_pixels_per_meter");
+
if (png_ptr != NULL && info_ptr != NULL &&
(info_ptr->valid & PNG_INFO_pHYs) != 0)
- {
- png_debug1(1, "in %s retrieval function",
- "png_get_x_pixels_per_meter");
-
- if (info_ptr->phys_unit_type == PNG_RESOLUTION_METER)
- return (info_ptr->x_pixels_per_unit);
- }
+ {
+ if (info_ptr->phys_unit_type == PNG_RESOLUTION_METER)
+ return info_ptr->x_pixels_per_unit;
+ }
#else
PNG_UNUSED(png_ptr)
PNG_UNUSED(info_ptr)
#endif
- return (0);
+ return 0;
}
png_uint_32 PNGAPI
@@ -149,42 +148,41 @@ png_get_y_pixels_per_meter(png_const_structrp png_ptr, png_const_inforp
info_ptr)
{
#ifdef PNG_pHYs_SUPPORTED
+ png_debug(1, "in png_get_y_pixels_per_meter");
+
if (png_ptr != NULL && info_ptr != NULL &&
(info_ptr->valid & PNG_INFO_pHYs) != 0)
{
- png_debug1(1, "in %s retrieval function",
- "png_get_y_pixels_per_meter");
-
if (info_ptr->phys_unit_type == PNG_RESOLUTION_METER)
- return (info_ptr->y_pixels_per_unit);
+ return info_ptr->y_pixels_per_unit;
}
#else
PNG_UNUSED(png_ptr)
PNG_UNUSED(info_ptr)
#endif
- return (0);
+ return 0;
}
png_uint_32 PNGAPI
png_get_pixels_per_meter(png_const_structrp png_ptr, png_const_inforp info_ptr)
{
#ifdef PNG_pHYs_SUPPORTED
+ png_debug(1, "in png_get_pixels_per_meter");
+
if (png_ptr != NULL && info_ptr != NULL &&
(info_ptr->valid & PNG_INFO_pHYs) != 0)
{
- png_debug1(1, "in %s retrieval function", "png_get_pixels_per_meter");
-
if (info_ptr->phys_unit_type == PNG_RESOLUTION_METER &&
info_ptr->x_pixels_per_unit == info_ptr->y_pixels_per_unit)
- return (info_ptr->x_pixels_per_unit);
+ return info_ptr->x_pixels_per_unit;
}
#else
PNG_UNUSED(png_ptr)
PNG_UNUSED(info_ptr)
#endif
- return (0);
+ return 0;
}
#ifdef PNG_FLOATING_POINT_SUPPORTED
@@ -193,21 +191,21 @@ png_get_pixel_aspect_ratio(png_const_structrp png_ptr, png_const_inforp
info_ptr)
{
#ifdef PNG_READ_pHYs_SUPPORTED
+ png_debug(1, "in png_get_pixel_aspect_ratio");
+
if (png_ptr != NULL && info_ptr != NULL &&
(info_ptr->valid & PNG_INFO_pHYs) != 0)
{
- png_debug1(1, "in %s retrieval function", "png_get_aspect_ratio");
-
if (info_ptr->x_pixels_per_unit != 0)
- return ((float)((float)info_ptr->y_pixels_per_unit
- /(float)info_ptr->x_pixels_per_unit));
+ return (float)info_ptr->y_pixels_per_unit
+ / (float)info_ptr->x_pixels_per_unit;
}
#else
PNG_UNUSED(png_ptr)
PNG_UNUSED(info_ptr)
#endif
- return ((float)0.0);
+ return (float)0.0;
}
#endif
@@ -217,6 +215,8 @@ png_get_pixel_aspect_ratio_fixed(png_const_structrp png_ptr,
png_const_inforp info_ptr)
{
#ifdef PNG_READ_pHYs_SUPPORTED
+ png_debug(1, "in png_get_pixel_aspect_ratio_fixed");
+
if (png_ptr != NULL && info_ptr != NULL &&
(info_ptr->valid & PNG_INFO_pHYs) != 0 &&
info_ptr->x_pixels_per_unit > 0 && info_ptr->y_pixels_per_unit > 0 &&
@@ -225,8 +225,6 @@ png_get_pixel_aspect_ratio_fixed(png_const_structrp png_ptr,
{
png_fixed_point res;
- png_debug1(1, "in %s retrieval function", "png_get_aspect_ratio_fixed");
-
/* The following casts work because a PNG 4 byte integer only has a valid
* range of 0..2^31-1; otherwise the cast might overflow.
*/
@@ -247,80 +245,80 @@ png_int_32 PNGAPI
png_get_x_offset_microns(png_const_structrp png_ptr, png_const_inforp info_ptr)
{
#ifdef PNG_oFFs_SUPPORTED
+ png_debug(1, "in png_get_x_offset_microns");
+
if (png_ptr != NULL && info_ptr != NULL &&
(info_ptr->valid & PNG_INFO_oFFs) != 0)
{
- png_debug1(1, "in %s retrieval function", "png_get_x_offset_microns");
-
if (info_ptr->offset_unit_type == PNG_OFFSET_MICROMETER)
- return (info_ptr->x_offset);
+ return info_ptr->x_offset;
}
#else
PNG_UNUSED(png_ptr)
PNG_UNUSED(info_ptr)
#endif
- return (0);
+ return 0;
}
png_int_32 PNGAPI
png_get_y_offset_microns(png_const_structrp png_ptr, png_const_inforp info_ptr)
{
#ifdef PNG_oFFs_SUPPORTED
+ png_debug(1, "in png_get_y_offset_microns");
+
if (png_ptr != NULL && info_ptr != NULL &&
(info_ptr->valid & PNG_INFO_oFFs) != 0)
{
- png_debug1(1, "in %s retrieval function", "png_get_y_offset_microns");
-
if (info_ptr->offset_unit_type == PNG_OFFSET_MICROMETER)
- return (info_ptr->y_offset);
+ return info_ptr->y_offset;
}
#else
PNG_UNUSED(png_ptr)
PNG_UNUSED(info_ptr)
#endif
- return (0);
+ return 0;
}
png_int_32 PNGAPI
png_get_x_offset_pixels(png_const_structrp png_ptr, png_const_inforp info_ptr)
{
#ifdef PNG_oFFs_SUPPORTED
+ png_debug(1, "in png_get_x_offset_pixels");
+
if (png_ptr != NULL && info_ptr != NULL &&
(info_ptr->valid & PNG_INFO_oFFs) != 0)
{
- png_debug1(1, "in %s retrieval function", "png_get_x_offset_pixels");
-
if (info_ptr->offset_unit_type == PNG_OFFSET_PIXEL)
- return (info_ptr->x_offset);
+ return info_ptr->x_offset;
}
#else
PNG_UNUSED(png_ptr)
PNG_UNUSED(info_ptr)
#endif
- return (0);
+ return 0;
}
png_int_32 PNGAPI
png_get_y_offset_pixels(png_const_structrp png_ptr, png_const_inforp info_ptr)
{
#ifdef PNG_oFFs_SUPPORTED
+ png_debug(1, "in png_get_y_offset_pixels");
+
if (png_ptr != NULL && info_ptr != NULL &&
(info_ptr->valid & PNG_INFO_oFFs) != 0)
{
- png_debug1(1, "in %s retrieval function", "png_get_y_offset_pixels");
-
if (info_ptr->offset_unit_type == PNG_OFFSET_PIXEL)
- return (info_ptr->y_offset);
+ return info_ptr->y_offset;
}
#else
PNG_UNUSED(png_ptr)
PNG_UNUSED(info_ptr)
#endif
- return (0);
+ return 0;
}
#ifdef PNG_INCH_CONVERSIONS_SUPPORTED
@@ -434,11 +432,11 @@ png_get_pHYs_dpi(png_const_structrp png_ptr, png_const_inforp info_ptr,
{
png_uint_32 retval = 0;
+ png_debug1(1, "in %s retrieval function", "pHYs");
+
if (png_ptr != NULL && info_ptr != NULL &&
(info_ptr->valid & PNG_INFO_pHYs) != 0)
{
- png_debug1(1, "in %s retrieval function", "pHYs");
-
if (res_x != NULL)
{
*res_x = info_ptr->x_pixels_per_unit;
@@ -464,7 +462,7 @@ png_get_pHYs_dpi(png_const_structrp png_ptr, png_const_inforp info_ptr,
}
}
- return (retval);
+ return retval;
}
#endif /* pHYs */
#endif /* INCH_CONVERSIONS */
@@ -478,9 +476,9 @@ png_byte PNGAPI
png_get_channels(png_const_structrp png_ptr, png_const_inforp info_ptr)
{
if (png_ptr != NULL && info_ptr != NULL)
- return(info_ptr->channels);
+ return info_ptr->channels;
- return (0);
+ return 0;
}
#ifdef PNG_READ_SUPPORTED
@@ -488,9 +486,9 @@ png_const_bytep PNGAPI
png_get_signature(png_const_structrp png_ptr, png_const_inforp info_ptr)
{
if (png_ptr != NULL && info_ptr != NULL)
- return(info_ptr->signature);
+ return info_ptr->signature;
- return (NULL);
+ return NULL;
}
#endif
@@ -499,17 +497,17 @@ png_uint_32 PNGAPI
png_get_bKGD(png_const_structrp png_ptr, png_inforp info_ptr,
png_color_16p *background)
{
+ png_debug1(1, "in %s retrieval function", "bKGD");
+
if (png_ptr != NULL && info_ptr != NULL &&
(info_ptr->valid & PNG_INFO_bKGD) != 0 &&
background != NULL)
{
- png_debug1(1, "in %s retrieval function", "bKGD");
-
*background = &(info_ptr->background);
- return (PNG_INFO_bKGD);
+ return PNG_INFO_bKGD;
}
- return (0);
+ return 0;
}
#endif
@@ -524,6 +522,8 @@ png_get_cHRM(png_const_structrp png_ptr, png_const_inforp info_ptr,
double *white_x, double *white_y, double *red_x, double *red_y,
double *green_x, double *green_y, double *blue_x, double *blue_y)
{
+ png_debug1(1, "in %s retrieval function", "cHRM");
+
/* Quiet API change: this code used to only return the end points if a cHRM
* chunk was present, but the end points can also come from iCCP or sRGB
* chunks, so in 1.6.0 the png_get_ APIs return the end points regardless and
@@ -533,8 +533,6 @@ png_get_cHRM(png_const_structrp png_ptr, png_const_inforp info_ptr,
if (png_ptr != NULL && info_ptr != NULL &&
(info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_ENDPOINTS) != 0)
{
- png_debug1(1, "in %s retrieval function", "cHRM");
-
if (white_x != NULL)
*white_x = png_float(png_ptr,
info_ptr->colorspace.end_points_xy.whitex, "cHRM white X");
@@ -559,10 +557,10 @@ png_get_cHRM(png_const_structrp png_ptr, png_const_inforp info_ptr,
if (blue_y != NULL)
*blue_y = png_float(png_ptr, info_ptr->colorspace.end_points_xy.bluey,
"cHRM blue Y");
- return (PNG_INFO_cHRM);
+ return PNG_INFO_cHRM;
}
- return (0);
+ return 0;
}
png_uint_32 PNGAPI
@@ -571,11 +569,11 @@ png_get_cHRM_XYZ(png_const_structrp png_ptr, png_const_inforp info_ptr,
double *green_Y, double *green_Z, double *blue_X, double *blue_Y,
double *blue_Z)
{
+ png_debug1(1, "in %s retrieval function", "cHRM_XYZ(float)");
+
if (png_ptr != NULL && info_ptr != NULL &&
(info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_ENDPOINTS) != 0)
{
- png_debug1(1, "in %s retrieval function", "cHRM_XYZ(float)");
-
if (red_X != NULL)
*red_X = png_float(png_ptr, info_ptr->colorspace.end_points_XYZ.red_X,
"cHRM red X");
@@ -603,10 +601,10 @@ png_get_cHRM_XYZ(png_const_structrp png_ptr, png_const_inforp info_ptr,
if (blue_Z != NULL)
*blue_Z = png_float(png_ptr,
info_ptr->colorspace.end_points_XYZ.blue_Z, "cHRM blue Z");
- return (PNG_INFO_cHRM);
+ return PNG_INFO_cHRM;
}
- return (0);
+ return 0;
}
# endif
@@ -619,11 +617,11 @@ png_get_cHRM_XYZ_fixed(png_const_structrp png_ptr, png_const_inforp info_ptr,
png_fixed_point *int_blue_X, png_fixed_point *int_blue_Y,
png_fixed_point *int_blue_Z)
{
+ png_debug1(1, "in %s retrieval function", "cHRM_XYZ");
+
if (png_ptr != NULL && info_ptr != NULL &&
(info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_ENDPOINTS) != 0)
{
- png_debug1(1, "in %s retrieval function", "cHRM_XYZ");
-
if (int_red_X != NULL)
*int_red_X = info_ptr->colorspace.end_points_XYZ.red_X;
if (int_red_Y != NULL)
@@ -642,10 +640,10 @@ png_get_cHRM_XYZ_fixed(png_const_structrp png_ptr, png_const_inforp info_ptr,
*int_blue_Y = info_ptr->colorspace.end_points_XYZ.blue_Y;
if (int_blue_Z != NULL)
*int_blue_Z = info_ptr->colorspace.end_points_XYZ.blue_Z;
- return (PNG_INFO_cHRM);
+ return PNG_INFO_cHRM;
}
- return (0);
+ return 0;
}
png_uint_32 PNGAPI
@@ -675,10 +673,10 @@ png_get_cHRM_fixed(png_const_structrp png_ptr, png_const_inforp info_ptr,
*blue_x = info_ptr->colorspace.end_points_xy.bluex;
if (blue_y != NULL)
*blue_y = info_ptr->colorspace.end_points_xy.bluey;
- return (PNG_INFO_cHRM);
+ return PNG_INFO_cHRM;
}
- return (0);
+ return 0;
}
# endif
#endif
@@ -696,10 +694,10 @@ png_get_gAMA_fixed(png_const_structrp png_ptr, png_const_inforp info_ptr,
file_gamma != NULL)
{
*file_gamma = info_ptr->colorspace.gamma;
- return (PNG_INFO_gAMA);
+ return PNG_INFO_gAMA;
}
- return (0);
+ return 0;
}
# endif
@@ -716,10 +714,10 @@ png_get_gAMA(png_const_structrp png_ptr, png_const_inforp info_ptr,
{
*file_gamma = png_float(png_ptr, info_ptr->colorspace.gamma,
"png_get_gAMA");
- return (PNG_INFO_gAMA);
+ return PNG_INFO_gAMA;
}
- return (0);
+ return 0;
}
# endif
#endif
@@ -735,10 +733,10 @@ png_get_sRGB(png_const_structrp png_ptr, png_const_inforp info_ptr,
(info_ptr->valid & PNG_INFO_sRGB) != 0 && file_srgb_intent != NULL)
{
*file_srgb_intent = info_ptr->colorspace.rendering_intent;
- return (PNG_INFO_sRGB);
+ return PNG_INFO_sRGB;
}
- return (0);
+ return 0;
}
#endif
@@ -762,10 +760,10 @@ png_get_iCCP(png_const_structrp png_ptr, png_inforp info_ptr,
*/
if (compression_type != NULL)
*compression_type = PNG_COMPRESSION_TYPE_BASE;
- return (PNG_INFO_iCCP);
+ return PNG_INFO_iCCP;
}
- return (0);
+ return 0;
}
#endif
@@ -775,13 +773,15 @@ int PNGAPI
png_get_sPLT(png_const_structrp png_ptr, png_inforp info_ptr,
png_sPLT_tpp spalettes)
{
+ png_debug1(1, "in %s retrieval function", "sPLT");
+
if (png_ptr != NULL && info_ptr != NULL && spalettes != NULL)
{
*spalettes = info_ptr->splt_palettes;
return info_ptr->splt_palettes_num;
}
- return (0);
+ return 0;
}
#endif
@@ -807,10 +807,10 @@ png_get_eXIf_1(png_const_structrp png_ptr, png_const_inforp info_ptr,
{
*num_exif = info_ptr->num_exif;
*exif = info_ptr->exif;
- return (PNG_INFO_eXIf);
+ return PNG_INFO_eXIf;
}
- return (0);
+ return 0;
}
#endif
@@ -825,10 +825,10 @@ png_get_hIST(png_const_structrp png_ptr, png_inforp info_ptr,
(info_ptr->valid & PNG_INFO_hIST) != 0 && hist != NULL)
{
*hist = info_ptr->hist;
- return (PNG_INFO_hIST);
+ return PNG_INFO_hIST;
}
- return (0);
+ return 0;
}
#endif
@@ -841,7 +841,7 @@ png_get_IHDR(png_const_structrp png_ptr, png_const_inforp info_ptr,
png_debug1(1, "in %s retrieval function", "IHDR");
if (png_ptr == NULL || info_ptr == NULL)
- return (0);
+ return 0;
if (width != NULL)
*width = info_ptr->width;
@@ -873,7 +873,7 @@ png_get_IHDR(png_const_structrp png_ptr, png_const_inforp info_ptr,
info_ptr->bit_depth, info_ptr->color_type, info_ptr->interlace_type,
info_ptr->compression_type, info_ptr->filter_type);
- return (1);
+ return 1;
}
#ifdef PNG_oFFs_SUPPORTED
@@ -890,10 +890,10 @@ png_get_oFFs(png_const_structrp png_ptr, png_const_inforp info_ptr,
*offset_x = info_ptr->x_offset;
*offset_y = info_ptr->y_offset;
*unit_type = (int)info_ptr->offset_unit_type;
- return (PNG_INFO_oFFs);
+ return PNG_INFO_oFFs;
}
- return (0);
+ return 0;
}
#endif
@@ -917,10 +917,10 @@ png_get_pCAL(png_const_structrp png_ptr, png_inforp info_ptr,
*nparams = (int)info_ptr->pcal_nparams;
*units = info_ptr->pcal_units;
*params = info_ptr->pcal_params;
- return (PNG_INFO_pCAL);
+ return PNG_INFO_pCAL;
}
- return (0);
+ return 0;
}
#endif
@@ -932,6 +932,8 @@ png_uint_32 PNGAPI
png_get_sCAL_fixed(png_const_structrp png_ptr, png_const_inforp info_ptr,
int *unit, png_fixed_point *width, png_fixed_point *height)
{
+ png_debug1(1, "in %s retrieval function", "sCAL");
+
if (png_ptr != NULL && info_ptr != NULL &&
(info_ptr->valid & PNG_INFO_sCAL) != 0)
{
@@ -943,10 +945,10 @@ png_get_sCAL_fixed(png_const_structrp png_ptr, png_const_inforp info_ptr,
*width = png_fixed(png_ptr, atof(info_ptr->scal_s_width), "sCAL width");
*height = png_fixed(png_ptr, atof(info_ptr->scal_s_height),
"sCAL height");
- return (PNG_INFO_sCAL);
+ return PNG_INFO_sCAL;
}
- return(0);
+ return 0;
}
# endif /* FLOATING_ARITHMETIC */
# endif /* FIXED_POINT */
@@ -955,32 +957,36 @@ png_uint_32 PNGAPI
png_get_sCAL(png_const_structrp png_ptr, png_const_inforp info_ptr,
int *unit, double *width, double *height)
{
+ png_debug1(1, "in %s retrieval function", "sCAL(float)");
+
if (png_ptr != NULL && info_ptr != NULL &&
(info_ptr->valid & PNG_INFO_sCAL) != 0)
{
*unit = info_ptr->scal_unit;
*width = atof(info_ptr->scal_s_width);
*height = atof(info_ptr->scal_s_height);
- return (PNG_INFO_sCAL);
+ return PNG_INFO_sCAL;
}
- return(0);
+ return 0;
}
# endif /* FLOATING POINT */
png_uint_32 PNGAPI
png_get_sCAL_s(png_const_structrp png_ptr, png_const_inforp info_ptr,
int *unit, png_charpp width, png_charpp height)
{
+ png_debug1(1, "in %s retrieval function", "sCAL(str)");
+
if (png_ptr != NULL && info_ptr != NULL &&
(info_ptr->valid & PNG_INFO_sCAL) != 0)
{
*unit = info_ptr->scal_unit;
*width = info_ptr->scal_s_width;
*height = info_ptr->scal_s_height;
- return (PNG_INFO_sCAL);
+ return PNG_INFO_sCAL;
}
- return(0);
+ return 0;
}
#endif /* sCAL */
@@ -1015,7 +1021,7 @@ png_get_pHYs(png_const_structrp png_ptr, png_const_inforp info_ptr,
}
}
- return (retval);
+ return retval;
}
#endif /* pHYs */
@@ -1031,10 +1037,10 @@ png_get_PLTE(png_const_structrp png_ptr, png_inforp info_ptr,
*palette = info_ptr->palette;
*num_palette = info_ptr->num_palette;
png_debug1(3, "num_palette = %d", *num_palette);
- return (PNG_INFO_PLTE);
+ return PNG_INFO_PLTE;
}
- return (0);
+ return 0;
}
#ifdef PNG_sBIT_SUPPORTED
@@ -1048,10 +1054,10 @@ png_get_sBIT(png_const_structrp png_ptr, png_inforp info_ptr,
(info_ptr->valid & PNG_INFO_sBIT) != 0 && sig_bit != NULL)
{
*sig_bit = &(info_ptr->sig_bit);
- return (PNG_INFO_sBIT);
+ return PNG_INFO_sBIT;
}
- return (0);
+ return 0;
}
#endif
@@ -1062,7 +1068,7 @@ png_get_text(png_const_structrp png_ptr, png_inforp info_ptr,
{
if (png_ptr != NULL && info_ptr != NULL && info_ptr->num_text > 0)
{
- png_debug1(1, "in 0x%lx retrieval function",
+ png_debug1(1, "in text retrieval function, chunk typeid = 0x%lx",
(unsigned long)png_ptr->chunk_name);
if (text_ptr != NULL)
@@ -1077,7 +1083,7 @@ png_get_text(png_const_structrp png_ptr, png_inforp info_ptr,
if (num_text != NULL)
*num_text = 0;
- return(0);
+ return 0;
}
#endif
@@ -1092,10 +1098,10 @@ png_get_tIME(png_const_structrp png_ptr, png_inforp info_ptr,
(info_ptr->valid & PNG_INFO_tIME) != 0 && mod_time != NULL)
{
*mod_time = &(info_ptr->mod_time);
- return (PNG_INFO_tIME);
+ return PNG_INFO_tIME;
}
- return (0);
+ return 0;
}
#endif
@@ -1105,11 +1111,12 @@ png_get_tRNS(png_const_structrp png_ptr, png_inforp info_ptr,
png_bytep *trans_alpha, int *num_trans, png_color_16p *trans_color)
{
png_uint_32 retval = 0;
+
+ png_debug1(1, "in %s retrieval function", "tRNS");
+
if (png_ptr != NULL && info_ptr != NULL &&
(info_ptr->valid & PNG_INFO_tRNS) != 0)
{
- png_debug1(1, "in %s retrieval function", "tRNS");
-
if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
{
if (trans_alpha != NULL)
@@ -1141,7 +1148,7 @@ png_get_tRNS(png_const_structrp png_ptr, png_inforp info_ptr,
}
}
- return (retval);
+ return retval;
}
#endif
@@ -1156,7 +1163,7 @@ png_get_unknown_chunks(png_const_structrp png_ptr, png_inforp info_ptr,
return info_ptr->unknown_chunks_num;
}
- return (0);
+ return 0;
}
#endif
@@ -1252,7 +1259,7 @@ png_get_palette_max(png_const_structp png_ptr, png_const_infop info_ptr)
if (png_ptr != NULL && info_ptr != NULL)
return png_ptr->num_palette_max;
- return (-1);
+ return -1;
}
# endif
#endif
diff --git a/Build/source/libs/libpng/libpng-src/pnglibconf.h b/Build/source/libs/libpng/libpng-src/pnglibconf.h
index c7033ae176f..d768a8ef087 100644
--- a/Build/source/libs/libpng/libpng-src/pnglibconf.h
+++ b/Build/source/libs/libpng/libpng-src/pnglibconf.h
@@ -1,8 +1,8 @@
/* pnglibconf.h - library build configuration */
-/* libpng version 1.6.40 */
+/* libpng version 1.6.41 */
-/* Copyright (c) 2018-2023 Cosmin Truta */
+/* Copyright (c) 2018-2024 Cosmin Truta */
/* Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson */
/* This code is released under the libpng license. */
@@ -27,6 +27,7 @@
#define PNG_COLORSPACE_SUPPORTED
#define PNG_CONSOLE_IO_SUPPORTED
#define PNG_CONVERT_tIME_SUPPORTED
+/*#undef PNG_DISABLE_ADLER32_CHECK_SUPPORTED*/
#define PNG_EASY_ACCESS_SUPPORTED
/*#undef PNG_ERROR_NUMBERS_SUPPORTED*/
#define PNG_ERROR_TEXT_SUPPORTED
@@ -41,6 +42,10 @@
#define PNG_INCH_CONVERSIONS_SUPPORTED
#define PNG_INFO_IMAGE_SUPPORTED
#define PNG_IO_STATE_SUPPORTED
+/*#undef PNG_MIPS_MMI_API_SUPPORTED*/
+/*#undef PNG_MIPS_MMI_CHECK_SUPPORTED*/
+/*#undef PNG_MIPS_MSA_API_SUPPORTED*/
+/*#undef PNG_MIPS_MSA_CHECK_SUPPORTED*/
#define PNG_MNG_FEATURES_SUPPORTED
#define PNG_POINTER_INDEXING_SUPPORTED
/*#undef PNG_POWERPC_VSX_API_SUPPORTED*/
diff --git a/Build/source/libs/libpng/libpng-src/pngpread.c b/Build/source/libs/libpng/libpng-src/pngpread.c
index e283627b77c..be640f77a9b 100644
--- a/Build/source/libs/libpng/libpng-src/pngpread.c
+++ b/Build/source/libs/libpng/libpng-src/pngpread.c
@@ -1,7 +1,7 @@
/* pngpread.c - read a png file in push mode
*
- * Copyright (c) 2018 Cosmin Truta
+ * Copyright (c) 2018-2024 Cosmin Truta
* Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson
* Copyright (c) 1996-1997 Andreas Dilger
* Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
@@ -145,10 +145,10 @@ png_push_read_sig(png_structrp png_ptr, png_inforp info_ptr)
num_to_check);
png_ptr->sig_bytes = (png_byte)(png_ptr->sig_bytes + num_to_check);
- if (png_sig_cmp(info_ptr->signature, num_checked, num_to_check))
+ if (png_sig_cmp(info_ptr->signature, num_checked, num_to_check) != 0)
{
if (num_checked < 4 &&
- png_sig_cmp(info_ptr->signature, num_checked, num_to_check - 4))
+ png_sig_cmp(info_ptr->signature, num_checked, num_to_check - 4) != 0)
png_error(png_ptr, "Not a PNG file");
else
@@ -1089,7 +1089,7 @@ png_voidp PNGAPI
png_get_progressive_ptr(png_const_structrp png_ptr)
{
if (png_ptr == NULL)
- return (NULL);
+ return NULL;
return png_ptr->io_ptr;
}
diff --git a/Build/source/libs/libpng/libpng-src/pngpriv.h b/Build/source/libs/libpng/libpng-src/pngpriv.h
index 7c19373f0b8..3a3e9d3564d 100644
--- a/Build/source/libs/libpng/libpng-src/pngpriv.h
+++ b/Build/source/libs/libpng/libpng-src/pngpriv.h
@@ -1,7 +1,7 @@
/* pngpriv.h - private declarations for use inside libpng
*
- * Copyright (c) 2018-2023 Cosmin Truta
+ * Copyright (c) 2018-2024 Cosmin Truta
* Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson
* Copyright (c) 1996-1997 Andreas Dilger
* Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
@@ -197,6 +197,18 @@
# endif
#endif
+#ifndef PNG_MIPS_MMI_OPT
+# ifdef PNG_MIPS_MMI
+# if defined(__mips_loongson_mmi) && (_MIPS_SIM == _ABI64) && defined(PNG_ALIGNED_MEMORY_SUPPORTED)
+# define PNG_MIPS_MMI_OPT 1
+# else
+# define PNG_MIPS_MMI_OPT 0
+# endif
+# else
+# define PNG_MIPS_MMI_OPT 0
+# endif
+#endif
+
#ifndef PNG_POWERPC_VSX_OPT
# if defined(__PPC64__) && defined(__ALTIVEC__) && defined(__VSX__)
# define PNG_POWERPC_VSX_OPT 2
@@ -205,6 +217,14 @@
# endif
#endif
+#ifndef PNG_LOONGARCH_LSX_OPT
+# if defined(__loongarch_sx)
+# define PNG_LOONGARCH_LSX_OPT 1
+# else
+# define PNG_LOONGARCH_LSX_OPT 0
+# endif
+#endif
+
#ifndef PNG_INTEL_SSE_OPT
# ifdef PNG_INTEL_SSE
/* Only check for SSE if the build configuration has been modified to
@@ -248,7 +268,6 @@
#endif
#if PNG_MIPS_MSA_OPT > 0
-# define PNG_FILTER_OPTIMIZATIONS png_init_filter_functions_msa
# ifndef PNG_MIPS_MSA_IMPLEMENTATION
# if defined(__mips_msa)
# if defined(__clang__)
@@ -264,11 +283,28 @@
# ifndef PNG_MIPS_MSA_IMPLEMENTATION
# define PNG_MIPS_MSA_IMPLEMENTATION 1
+# define PNG_FILTER_OPTIMIZATIONS png_init_filter_functions_mips
# endif
#else
# define PNG_MIPS_MSA_IMPLEMENTATION 0
#endif /* PNG_MIPS_MSA_OPT > 0 */
+#if PNG_MIPS_MMI_OPT > 0
+# ifndef PNG_MIPS_MMI_IMPLEMENTATION
+# if defined(__mips_loongson_mmi) && (_MIPS_SIM == _ABI64)
+# define PNG_MIPS_MMI_IMPLEMENTATION 2
+# else /* !defined __mips_loongson_mmi || _MIPS_SIM != _ABI64 */
+# define PNG_MIPS_MMI_IMPLEMENTATION 0
+# endif /* __mips_loongson_mmi && _MIPS_SIM == _ABI64 */
+# endif /* !PNG_MIPS_MMI_IMPLEMENTATION */
+
+# if PNG_MIPS_MMI_IMPLEMENTATION > 0
+# define PNG_FILTER_OPTIMIZATIONS png_init_filter_functions_mips
+# endif
+#else
+# define PNG_MIPS_MMI_IMPLEMENTATION 0
+#endif /* PNG_MIPS_MMI_OPT > 0 */
+
#if PNG_POWERPC_VSX_OPT > 0
# define PNG_FILTER_OPTIMIZATIONS png_init_filter_functions_vsx
# define PNG_POWERPC_VSX_IMPLEMENTATION 1
@@ -276,6 +312,12 @@
# define PNG_POWERPC_VSX_IMPLEMENTATION 0
#endif
+#if PNG_LOONGARCH_LSX_OPT > 0
+# define PNG_FILTER_OPTIMIZATIONS png_init_filter_functions_lsx
+# define PNG_LOONGARCH_LSX_IMPLEMENTATION 1
+#else
+# define PNG_LOONGARCH_LSX_IMPLEMENTATION 0
+#endif
/* Is this a build of a DLL where compilation of the object modules requires
* different preprocessor settings to those required for a simple library? If
@@ -514,18 +556,8 @@
*/
# include <float.h>
-# if (defined(__MWERKS__) && defined(macintosh)) || defined(applec) || \
- defined(THINK_C) || defined(__SC__) || defined(TARGET_OS_MAC)
- /* We need to check that <math.h> hasn't already been included earlier
- * as it seems it doesn't agree with <fp.h>, yet we should really use
- * <fp.h> if possible.
- */
-# if !defined(__MATH_H__) && !defined(__MATH_H) && !defined(__cmath__)
-# include <fp.h>
-# endif
-# else
-# include <math.h>
-# endif
+# include <math.h>
+
# if defined(_AMIGA) && defined(__SASC) && defined(_M68881)
/* Amiga SAS/C: We must include builtin FPU functions when compiling using
* MATH=68881
@@ -1306,7 +1338,7 @@ PNG_INTERNAL_FUNCTION(void,png_read_filter_row_paeth4_neon,(png_row_infop
row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);
#endif
-#if PNG_MIPS_MSA_OPT > 0
+#if PNG_MIPS_MSA_IMPLEMENTATION == 1
PNG_INTERNAL_FUNCTION(void,png_read_filter_row_up_msa,(png_row_infop row_info,
png_bytep row, png_const_bytep prev_row),PNG_EMPTY);
PNG_INTERNAL_FUNCTION(void,png_read_filter_row_sub3_msa,(png_row_infop
@@ -1323,6 +1355,23 @@ PNG_INTERNAL_FUNCTION(void,png_read_filter_row_paeth4_msa,(png_row_infop
row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);
#endif
+#if PNG_MIPS_MMI_IMPLEMENTATION > 0
+PNG_INTERNAL_FUNCTION(void,png_read_filter_row_up_mmi,(png_row_infop row_info,
+ png_bytep row, png_const_bytep prev_row),PNG_EMPTY);
+PNG_INTERNAL_FUNCTION(void,png_read_filter_row_sub3_mmi,(png_row_infop
+ row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);
+PNG_INTERNAL_FUNCTION(void,png_read_filter_row_sub4_mmi,(png_row_infop
+ row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);
+PNG_INTERNAL_FUNCTION(void,png_read_filter_row_avg3_mmi,(png_row_infop
+ row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);
+PNG_INTERNAL_FUNCTION(void,png_read_filter_row_avg4_mmi,(png_row_infop
+ row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);
+PNG_INTERNAL_FUNCTION(void,png_read_filter_row_paeth3_mmi,(png_row_infop
+ row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);
+PNG_INTERNAL_FUNCTION(void,png_read_filter_row_paeth4_mmi,(png_row_infop
+ row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);
+#endif
+
#if PNG_POWERPC_VSX_OPT > 0
PNG_INTERNAL_FUNCTION(void,png_read_filter_row_up_vsx,(png_row_infop row_info,
png_bytep row, png_const_bytep prev_row),PNG_EMPTY);
@@ -1355,6 +1404,23 @@ PNG_INTERNAL_FUNCTION(void,png_read_filter_row_paeth4_sse2,(png_row_infop
row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);
#endif
+#if PNG_LOONGARCH_LSX_IMPLEMENTATION == 1
+PNG_INTERNAL_FUNCTION(void,png_read_filter_row_up_lsx,(png_row_infop
+ row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);
+PNG_INTERNAL_FUNCTION(void,png_read_filter_row_sub3_lsx,(png_row_infop
+ row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);
+PNG_INTERNAL_FUNCTION(void,png_read_filter_row_sub4_lsx,(png_row_infop
+ row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);
+PNG_INTERNAL_FUNCTION(void,png_read_filter_row_avg3_lsx,(png_row_infop
+ row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);
+PNG_INTERNAL_FUNCTION(void,png_read_filter_row_avg4_lsx,(png_row_infop
+ row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);
+PNG_INTERNAL_FUNCTION(void,png_read_filter_row_paeth3_lsx,(png_row_infop
+ row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);
+PNG_INTERNAL_FUNCTION(void,png_read_filter_row_paeth4_lsx,(png_row_infop
+ row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);
+#endif
+
/* Choose the best filter to use and filter the row data */
PNG_INTERNAL_FUNCTION(void,png_write_find_filter,(png_structrp png_ptr,
png_row_infop row_info),PNG_EMPTY);
@@ -2094,17 +2160,27 @@ PNG_INTERNAL_FUNCTION(void, png_init_filter_functions_neon,
(png_structp png_ptr, unsigned int bpp), PNG_EMPTY);
#endif
-#if PNG_MIPS_MSA_OPT > 0
-PNG_INTERNAL_FUNCTION(void, png_init_filter_functions_msa,
+#if PNG_MIPS_MSA_IMPLEMENTATION == 1
+PNG_INTERNAL_FUNCTION(void, png_init_filter_functions_mips,
(png_structp png_ptr, unsigned int bpp), PNG_EMPTY);
#endif
+# if PNG_MIPS_MMI_IMPLEMENTATION > 0
+PNG_INTERNAL_FUNCTION(void, png_init_filter_functions_mips,
+ (png_structp png_ptr, unsigned int bpp), PNG_EMPTY);
+# endif
+
# if PNG_INTEL_SSE_IMPLEMENTATION > 0
PNG_INTERNAL_FUNCTION(void, png_init_filter_functions_sse2,
(png_structp png_ptr, unsigned int bpp), PNG_EMPTY);
# endif
#endif
+#if PNG_LOONGARCH_LSX_OPT > 0
+PNG_INTERNAL_FUNCTION(void, png_init_filter_functions_lsx,
+ (png_structp png_ptr, unsigned int bpp), PNG_EMPTY);
+#endif
+
PNG_INTERNAL_FUNCTION(png_uint_32, png_check_keyword, (png_structrp png_ptr,
png_const_charp key, png_bytep new_key), PNG_EMPTY);
diff --git a/Build/source/libs/libpng/libpng-src/pngread.c b/Build/source/libs/libpng/libpng-src/pngread.c
index 96996ced5ba..008a41856b6 100644
--- a/Build/source/libs/libpng/libpng-src/pngread.c
+++ b/Build/source/libs/libpng/libpng-src/pngread.c
@@ -1,7 +1,7 @@
/* pngread.c - read a PNG file
*
- * Copyright (c) 2018-2019 Cosmin Truta
+ * Copyright (c) 2018-2024 Cosmin Truta
* Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson
* Copyright (c) 1996-1997 Andreas Dilger
* Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
@@ -568,7 +568,7 @@ png_read_row(png_structrp png_ptr, png_bytep row, png_bytep dsp_row)
#endif
#ifdef PNG_READ_TRANSFORMS_SUPPORTED
- if (png_ptr->transformations)
+ if (png_ptr->transformations || png_ptr->num_palette_max >= 0)
png_do_read_transformations(png_ptr, &row_info);
#endif
@@ -785,7 +785,7 @@ png_read_end(png_structrp png_ptr, png_inforp info_ptr)
#ifdef PNG_READ_CHECK_FOR_INVALID_INDEX_SUPPORTED
/* Report invalid palette index; added at libng-1.5.10 */
if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE &&
- png_ptr->num_palette_max > png_ptr->num_palette)
+ png_ptr->num_palette_max >= png_ptr->num_palette)
png_benign_error(png_ptr, "Read palette index exceeding num_palette");
#endif
@@ -1049,6 +1049,8 @@ void PNGAPI
png_read_png(png_structrp png_ptr, png_inforp info_ptr,
int transforms, voidp params)
{
+ png_debug(1, "in png_read_png");
+
if (png_ptr == NULL || info_ptr == NULL)
return;
diff --git a/Build/source/libs/libpng/libpng-src/pngrtran.c b/Build/source/libs/libpng/libpng-src/pngrtran.c
index 238f5afe7e8..16474741aac 100644
--- a/Build/source/libs/libpng/libpng-src/pngrtran.c
+++ b/Build/source/libs/libpng/libpng-src/pngrtran.c
@@ -1,7 +1,7 @@
/* pngrtran.c - transforms the data in a row for PNG readers
*
- * Copyright (c) 2018-2019 Cosmin Truta
+ * Copyright (c) 2018-2024 Cosmin Truta
* Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson
* Copyright (c) 1996-1997 Andreas Dilger
* Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
@@ -290,7 +290,7 @@ png_set_alpha_mode_fixed(png_structrp png_ptr, int mode,
int compose = 0;
png_fixed_point file_gamma;
- png_debug(1, "in png_set_alpha_mode");
+ png_debug(1, "in png_set_alpha_mode_fixed");
if (png_rtran_ok(png_ptr, 0) == 0)
return;
@@ -970,7 +970,7 @@ void PNGFAPI
png_set_rgb_to_gray_fixed(png_structrp png_ptr, int error_action,
png_fixed_point red, png_fixed_point green)
{
- png_debug(1, "in png_set_rgb_to_gray");
+ png_debug(1, "in png_set_rgb_to_gray_fixed");
/* Need the IHDR here because of the check on color_type below. */
/* TODO: fix this */
diff --git a/Build/source/libs/libpng/libpng-src/pngrutil.c b/Build/source/libs/libpng/libpng-src/pngrutil.c
index 068ab193a33..d31dc21dae8 100644
--- a/Build/source/libs/libpng/libpng-src/pngrutil.c
+++ b/Build/source/libs/libpng/libpng-src/pngrutil.c
@@ -1,7 +1,7 @@
/* pngrutil.c - utilities to read a PNG file
*
- * Copyright (c) 2018-2022 Cosmin Truta
+ * Copyright (c) 2018-2024 Cosmin Truta
* Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson
* Copyright (c) 1996-1997 Andreas Dilger
* Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
@@ -26,7 +26,7 @@ png_get_uint_31(png_const_structrp png_ptr, png_const_bytep buf)
if (uval > PNG_UINT_31_MAX)
png_error(png_ptr, "PNG unsigned integer out of range");
- return (uval);
+ return uval;
}
#if defined(PNG_READ_gAMA_SUPPORTED) || defined(PNG_READ_cHRM_SUPPORTED)
@@ -140,7 +140,7 @@ png_read_sig(png_structrp png_ptr, png_inforp info_ptr)
if (png_sig_cmp(info_ptr->signature, num_checked, num_to_check) != 0)
{
if (num_checked < 4 &&
- png_sig_cmp(info_ptr->signature, num_checked, num_to_check - 4))
+ png_sig_cmp(info_ptr->signature, num_checked, num_to_check - 4) != 0)
png_error(png_ptr, "Not a PNG file");
else
png_error(png_ptr, "PNG file corrupted by ASCII conversion");
@@ -171,7 +171,7 @@ png_read_chunk_header(png_structrp png_ptr)
/* Put the chunk name into png_ptr->chunk_name. */
png_ptr->chunk_name = PNG_CHUNK_FROM_STRING(buf+4);
- png_debug2(0, "Reading %lx chunk, length = %lu",
+ png_debug2(0, "Reading chunk typeid = 0x%lx, length = %lu",
(unsigned long)png_ptr->chunk_name, (unsigned long)length);
/* Reset the crc and run it over the chunk name. */
@@ -238,10 +238,10 @@ png_crc_finish(png_structrp png_ptr, png_uint_32 skip)
else
png_chunk_error(png_ptr, "CRC error");
- return (1);
+ return 1;
}
- return (0);
+ return 0;
}
/* Compare the CRC stored in the PNG file with that calculated by libpng from
@@ -277,11 +277,11 @@ png_crc_error(png_structrp png_ptr)
if (need_crc != 0)
{
crc = png_get_uint_32(crc_bytes);
- return ((int)(crc != png_ptr->crc));
+ return crc != png_ptr->crc;
}
else
- return (0);
+ return 0;
}
#if defined(PNG_READ_iCCP_SUPPORTED) || defined(PNG_READ_iTXt_SUPPORTED) ||\
@@ -421,8 +421,7 @@ png_inflate_claim(png_structrp png_ptr, png_uint_32 owner)
png_ptr->flags |= PNG_FLAG_ZSTREAM_INITIALIZED;
}
-#if ZLIB_VERNUM >= 0x1290 && \
- defined(PNG_SET_OPTION_SUPPORTED) && defined(PNG_IGNORE_ADLER32)
+#ifdef PNG_DISABLE_ADLER32_CHECK_SUPPORTED
if (((png_ptr->options >> PNG_IGNORE_ADLER32) & 3) == PNG_OPTION_ON)
/* Turn off validation of the ADLER32 checksum in IDAT chunks */
ret = inflateValidate(&png_ptr->zstream, 0);
diff --git a/Build/source/libs/libpng/libpng-src/pngset.c b/Build/source/libs/libpng/libpng-src/pngset.c
index 3fc31feb0cb..eb1c8c7a35a 100644
--- a/Build/source/libs/libpng/libpng-src/pngset.c
+++ b/Build/source/libs/libpng/libpng-src/pngset.c
@@ -1,7 +1,7 @@
/* pngset.c - storage of image information into info struct
*
- * Copyright (c) 2018-2023 Cosmin Truta
+ * Copyright (c) 2018-2024 Cosmin Truta
* Copyright (c) 1998-2018 Glenn Randers-Pehrson
* Copyright (c) 1996-1997 Andreas Dilger
* Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
@@ -763,11 +763,11 @@ png_set_text_2(png_const_structrp png_ptr, png_inforp info_ptr,
{
int i;
- png_debug1(1, "in %lx storage function", png_ptr == NULL ? 0xabadca11U :
- (unsigned long)png_ptr->chunk_name);
+ png_debug1(1, "in text storage function, chunk typeid = 0x%lx",
+ png_ptr == NULL ? 0xabadca11UL : (unsigned long)png_ptr->chunk_name);
if (png_ptr == NULL || info_ptr == NULL || num_text <= 0 || text_ptr == NULL)
- return(0);
+ return 0;
/* Make sure we have enough space in the "text" array in info_struct
* to hold all of the incoming text_ptr objects. This compare can't overflow
@@ -947,7 +947,7 @@ png_set_text_2(png_const_structrp png_ptr, png_inforp info_ptr,
png_debug1(3, "transferred text chunk %d", info_ptr->num_text);
}
- return(0);
+ return 0;
}
#endif
@@ -1063,6 +1063,8 @@ png_set_sPLT(png_const_structrp png_ptr,
{
png_sPLT_tp np;
+ png_debug1(1, "in %s storage function", "sPLT");
+
if (png_ptr == NULL || info_ptr == NULL || nentries <= 0 || entries == NULL)
return;
@@ -1537,7 +1539,7 @@ void PNGAPI
png_set_rows(png_const_structrp png_ptr, png_inforp info_ptr,
png_bytepp row_pointers)
{
- png_debug1(1, "in %s storage function", "rows");
+ png_debug(1, "in png_set_rows");
if (png_ptr == NULL || info_ptr == NULL)
return;
@@ -1556,6 +1558,8 @@ png_set_rows(png_const_structrp png_ptr, png_inforp info_ptr,
void PNGAPI
png_set_compression_buffer_size(png_structrp png_ptr, size_t size)
{
+ png_debug(1, "in png_set_compression_buffer_size");
+
if (png_ptr == NULL)
return;
@@ -1627,6 +1631,8 @@ void PNGAPI
png_set_user_limits(png_structrp png_ptr, png_uint_32 user_width_max,
png_uint_32 user_height_max)
{
+ png_debug(1, "in png_set_user_limits");
+
/* Images with dimensions larger than these limits will be
* rejected by png_set_IHDR(). To accept any PNG datastream
* regardless of dimensions, set both limits to 0x7fffffff.
@@ -1642,6 +1648,8 @@ png_set_user_limits(png_structrp png_ptr, png_uint_32 user_width_max,
void PNGAPI
png_set_chunk_cache_max(png_structrp png_ptr, png_uint_32 user_chunk_cache_max)
{
+ png_debug(1, "in png_set_chunk_cache_max");
+
if (png_ptr != NULL)
png_ptr->user_chunk_cache_max = user_chunk_cache_max;
}
@@ -1651,6 +1659,8 @@ void PNGAPI
png_set_chunk_malloc_max(png_structrp png_ptr,
png_alloc_size_t user_chunk_malloc_max)
{
+ png_debug(1, "in png_set_chunk_malloc_max");
+
if (png_ptr != NULL)
png_ptr->user_chunk_malloc_max = user_chunk_malloc_max;
}
diff --git a/Build/source/libs/libpng/libpng-src/pngtest.c b/Build/source/libs/libpng/libpng-src/pngtest.c
index 37b42bb3461..f83e8bbf2cd 100644
--- a/Build/source/libs/libpng/libpng-src/pngtest.c
+++ b/Build/source/libs/libpng/libpng-src/pngtest.c
@@ -1,7 +1,7 @@
/* pngtest.c - a simple test program to test libpng
*
- * Copyright (c) 2018-2019 Cosmin Truta
+ * Copyright (c) 2018-2024 Cosmin Truta
* Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson
* Copyright (c) 1996-1997 Andreas Dilger
* Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
@@ -524,7 +524,7 @@ PNGCBAPI png_debug_malloc(png_structp png_ptr, png_alloc_size_t size)
*/
if (size == 0)
- return (NULL);
+ return NULL;
/* This calls the library allocator twice, once to get the requested
buffer and once to get a new free list entry. */
@@ -565,7 +565,7 @@ PNGCBAPI png_debug_malloc(png_structp png_ptr, png_alloc_size_t size)
printf("png_malloc %lu bytes at %p\n", (unsigned long)size,
pinfo->pointer);
- return (png_voidp)(pinfo->pointer);
+ return (png_voidp)pinfo->pointer;
}
}
@@ -698,9 +698,9 @@ read_user_chunk_callback(png_struct *png_ptr, png_unknown_chunkp chunk)
png_error(png_ptr, "lost user chunk pointer");
/* Return one of the following:
- * return (-n); chunk had an error
- * return (0); did not recognize
- * return (n); success
+ * return -n; chunk had an error
+ * return 0; did not recognize
+ * return n; success
*
* The unknown chunk structure contains the chunk data:
* png_byte name[5];
@@ -715,38 +715,38 @@ read_user_chunk_callback(png_struct *png_ptr, png_unknown_chunkp chunk)
{
/* Found sTER chunk */
if (chunk->size != 1)
- return (-1); /* Error return */
+ return -1; /* Error return */
if (chunk->data[0] != 0 && chunk->data[0] != 1)
- return (-1); /* Invalid mode */
+ return -1; /* Invalid mode */
if (set_location(png_ptr, my_user_chunk_data, have_sTER) != 0)
{
my_user_chunk_data->sTER_mode=chunk->data[0];
- return (1);
+ return 1;
}
else
- return (0); /* duplicate sTER - give it to libpng */
+ return 0; /* duplicate sTER - give it to libpng */
}
if (chunk->name[0] != 118 || chunk->name[1] != 112 || /* v p */
chunk->name[2] != 65 || chunk->name[3] != 103) /* A g */
- return (0); /* Did not recognize */
+ return 0; /* Did not recognize */
/* Found ImageMagick vpAg chunk */
if (chunk->size != 9)
- return (-1); /* Error return */
+ return -1; /* Error return */
if (set_location(png_ptr, my_user_chunk_data, have_vpAg) == 0)
- return (0); /* duplicate vpAg */
+ return 0; /* duplicate vpAg */
my_user_chunk_data->vpAg_width = png_get_uint_31(png_ptr, chunk->data);
my_user_chunk_data->vpAg_height = png_get_uint_31(png_ptr, chunk->data + 4);
my_user_chunk_data->vpAg_units = chunk->data[8];
- return (1);
+ return 1;
}
#ifdef PNG_WRITE_SUPPORTED
@@ -882,14 +882,14 @@ test_one_file(const char *inname, const char *outname)
if ((fpin = fopen(inname, "rb")) == NULL)
{
fprintf(STDERR, "Could not find input file %s\n", inname);
- return (1);
+ return 1;
}
if ((fpout = fopen(outname, "wb")) == NULL)
{
fprintf(STDERR, "Could not open output file %s\n", outname);
FCLOSE(fpin);
- return (1);
+ return 1;
}
pngtest_debug("Allocating read and write structures");
@@ -948,7 +948,7 @@ test_one_file(const char *inname, const char *outname)
#endif
FCLOSE(fpin);
FCLOSE(fpout);
- return (1);
+ return 1;
}
#ifdef PNG_WRITE_SUPPORTED
@@ -968,7 +968,7 @@ test_one_file(const char *inname, const char *outname)
png_destroy_write_struct(&write_ptr, &write_info_ptr);
FCLOSE(fpin);
FCLOSE(fpout);
- return (1);
+ return 1;
}
#endif
#endif
@@ -1656,16 +1656,16 @@ test_one_file(const char *inname, const char *outname)
pngtest_debug("Destroying data structs");
#ifdef SINGLE_ROWBUF_ALLOC
- pngtest_debug("destroying row_buf for read_ptr");
+ pngtest_debug("Destroying row_buf for read_ptr");
png_free(read_ptr, row_buf);
row_buf = NULL;
#endif /* SINGLE_ROWBUF_ALLOC */
- pngtest_debug("destroying read_ptr, read_info_ptr, end_info_ptr");
+ pngtest_debug("Destroying read_ptr, read_info_ptr, end_info_ptr");
png_destroy_read_struct(&read_ptr, &read_info_ptr, &end_info_ptr);
#ifdef PNG_WRITE_SUPPORTED
- pngtest_debug("destroying write_end_info_ptr");
+ pngtest_debug("Destroying write_end_info_ptr");
png_destroy_info_struct(write_ptr, &write_end_info_ptr);
- pngtest_debug("destroying write_ptr, write_info_ptr");
+ pngtest_debug("Destroying write_ptr, write_info_ptr");
png_destroy_write_struct(&write_ptr, &write_info_ptr);
#endif
pngtest_debug("Destruction complete.");
@@ -1686,7 +1686,7 @@ test_one_file(const char *inname, const char *outname)
inname, error_count, warning_count);
if (strict != 0)
- return (1);
+ return 1;
}
# ifdef PNG_WRITE_SUPPORTED
@@ -1704,21 +1704,21 @@ test_one_file(const char *inname, const char *outname)
inname, warning_count);
if (strict != 0)
- return (1);
+ return 1;
}
pngtest_debug("Opening files for comparison");
if ((fpin = fopen(inname, "rb")) == NULL)
{
fprintf(STDERR, "Could not find file %s\n", inname);
- return (1);
+ return 1;
}
if ((fpout = fopen(outname, "rb")) == NULL)
{
fprintf(STDERR, "Could not find file %s\n", outname);
FCLOSE(fpin);
- return (1);
+ return 1;
}
#if defined (PNG_WRITE_SUPPORTED) /* else nothing was written */ &&\
@@ -1757,10 +1757,10 @@ test_one_file(const char *inname, const char *outname)
FCLOSE(fpout);
if (strict != 0 && unsupported_chunks == 0)
- return (1);
+ return 1;
else
- return (0);
+ return 0;
}
if (num_in == 0)
@@ -1794,10 +1794,10 @@ test_one_file(const char *inname, const char *outname)
* can be exactly the same size!
*/
if (strict != 0 && unsupported_chunks == 0)
- return (1);
+ return 1;
else
- return (0);
+ return 0;
}
}
}
@@ -1806,7 +1806,7 @@ test_one_file(const char *inname, const char *outname)
FCLOSE(fpin);
FCLOSE(fpout);
- return (0);
+ return 0;
}
/* Input and output filenames */
@@ -2155,4 +2155,4 @@ main(void)
#endif
/* Generate a compiler error if there is an old png.h in the search path. */
-typedef png_libpng_version_1_6_40 Your_png_h_is_not_version_1_6_40;
+typedef png_libpng_version_1_6_41 Your_png_h_is_not_version_1_6_41;
diff --git a/Build/source/libs/libpng/libpng-src/pngtrans.c b/Build/source/libs/libpng/libpng-src/pngtrans.c
index 1100f46ebec..62cb21edf1f 100644
--- a/Build/source/libs/libpng/libpng-src/pngtrans.c
+++ b/Build/source/libs/libpng/libpng-src/pngtrans.c
@@ -1,7 +1,7 @@
/* pngtrans.c - transforms the data in a row (used by both readers and writers)
*
- * Copyright (c) 2018 Cosmin Truta
+ * Copyright (c) 2018-2024 Cosmin Truta
* Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson
* Copyright (c) 1996-1997 Andreas Dilger
* Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
@@ -103,10 +103,10 @@ png_set_interlace_handling(png_structrp png_ptr)
if (png_ptr != 0 && png_ptr->interlaced != 0)
{
png_ptr->transformations |= PNG_INTERLACE;
- return (7);
+ return 7;
}
- return (1);
+ return 1;
}
#endif
@@ -498,6 +498,8 @@ png_do_strip_channel(png_row_infop row_info, png_bytep row, int at_start)
png_bytep dp = row; /* destination pointer */
png_bytep ep = row + row_info->rowbytes; /* One beyond end of row */
+ png_debug(1, "in png_do_strip_channel");
+
/* At the start sp will point to the first byte to copy and dp to where
* it is copied to. ep always points just beyond the end of the row, so
* the loop simply copies (channels-1) channels until sp reaches ep.
@@ -698,6 +700,8 @@ png_do_bgr(png_row_infop row_info, png_bytep row)
void /* PRIVATE */
png_do_check_palette_indexes(png_structrp png_ptr, png_row_infop row_info)
{
+ png_debug(1, "in png_do_check_palette_indexes");
+
if (png_ptr->num_palette < (1 << row_info->bit_depth) &&
png_ptr->num_palette > 0) /* num_palette can be 0 in MNG files */
{
@@ -708,7 +712,7 @@ png_do_check_palette_indexes(png_structrp png_ptr, png_row_infop row_info)
* forms produced on either GCC or MSVC.
*/
int padding = PNG_PADBITS(row_info->pixel_depth, row_info->width);
- png_bytep rp = png_ptr->row_buf + row_info->rowbytes - 1;
+ png_bytep rp = png_ptr->row_buf + row_info->rowbytes;
switch (row_info->bit_depth)
{
@@ -833,7 +837,7 @@ png_voidp PNGAPI
png_get_user_transform_ptr(png_const_structrp png_ptr)
{
if (png_ptr == NULL)
- return (NULL);
+ return NULL;
return png_ptr->user_transform_ptr;
}
diff --git a/Build/source/libs/libpng/libpng-src/pngwrite.c b/Build/source/libs/libpng/libpng-src/pngwrite.c
index 32f4bfbe7df..77e412f43d5 100644
--- a/Build/source/libs/libpng/libpng-src/pngwrite.c
+++ b/Build/source/libs/libpng/libpng-src/pngwrite.c
@@ -1,7 +1,7 @@
/* pngwrite.c - general routines to write a PNG file
*
- * Copyright (c) 2018-2023 Cosmin Truta
+ * Copyright (c) 2018-2024 Cosmin Truta
* Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson
* Copyright (c) 1996-1997 Andreas Dilger
* Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
@@ -369,7 +369,8 @@ png_write_end(png_structrp png_ptr, png_inforp info_ptr)
png_error(png_ptr, "No IDATs written into file");
#ifdef PNG_WRITE_CHECK_FOR_INVALID_INDEX_SUPPORTED
- if (png_ptr->num_palette_max > png_ptr->num_palette)
+ if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE &&
+ png_ptr->num_palette_max >= png_ptr->num_palette)
png_benign_error(png_ptr, "Wrote palette index exceeding num_palette");
#endif
@@ -714,12 +715,12 @@ png_write_row(png_structrp png_ptr, png_const_bytep row)
/* 1.5.6: moved from png_struct to be a local structure: */
png_row_info row_info;
- if (png_ptr == NULL)
- return;
-
png_debug2(1, "in png_write_row (row %u, pass %d)",
png_ptr->row_number, png_ptr->pass);
+ if (png_ptr == NULL)
+ return;
+
/* Initialize transformations and other stuff if first time */
if (png_ptr->row_number == 0 && png_ptr->pass == 0)
{
@@ -1210,6 +1211,8 @@ png_set_compression_strategy(png_structrp png_ptr, int strategy)
void PNGAPI
png_set_compression_window_bits(png_structrp png_ptr, int window_bits)
{
+ png_debug(1, "in png_set_compression_window_bits");
+
if (png_ptr == NULL)
return;
@@ -1293,6 +1296,8 @@ png_set_text_compression_strategy(png_structrp png_ptr, int strategy)
void PNGAPI
png_set_text_compression_window_bits(png_structrp png_ptr, int window_bits)
{
+ png_debug(1, "in png_set_text_compression_window_bits");
+
if (png_ptr == NULL)
return;
@@ -1330,6 +1335,8 @@ png_set_text_compression_method(png_structrp png_ptr, int method)
void PNGAPI
png_set_write_status_fn(png_structrp png_ptr, png_write_status_ptr write_row_fn)
{
+ png_debug(1, "in png_set_write_status_fn");
+
if (png_ptr == NULL)
return;
@@ -1357,6 +1364,8 @@ void PNGAPI
png_write_png(png_structrp png_ptr, png_inforp info_ptr,
int transforms, voidp params)
{
+ png_debug(1, "in png_write_png");
+
if (png_ptr == NULL || info_ptr == NULL)
return;
diff --git a/Build/source/libs/libpng/libpng-src/pngwutil.c b/Build/source/libs/libpng/libpng-src/pngwutil.c
index 01f0607c709..14cc4ce367f 100644
--- a/Build/source/libs/libpng/libpng-src/pngwutil.c
+++ b/Build/source/libs/libpng/libpng-src/pngwutil.c
@@ -1,7 +1,7 @@
/* pngwutil.c - utilities to write a PNG file
*
- * Copyright (c) 2018-2022 Cosmin Truta
+ * Copyright (c) 2018-2024 Cosmin Truta
* Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson
* Copyright (c) 1996-1997 Andreas Dilger
* Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
@@ -2311,7 +2311,7 @@ png_setup_sub_row(png_structrp png_ptr, png_uint_32 bpp,
break;
}
- return (sum);
+ return sum;
}
static void /* PRIVATE */
@@ -2361,7 +2361,7 @@ png_setup_up_row(png_structrp png_ptr, size_t row_bytes, size_t lmins)
break;
}
- return (sum);
+ return sum;
}
static void /* PRIVATE */
png_setup_up_row_only(png_structrp png_ptr, size_t row_bytes)
@@ -2417,7 +2417,7 @@ png_setup_avg_row(png_structrp png_ptr, png_uint_32 bpp,
break;
}
- return (sum);
+ return sum;
}
static void /* PRIVATE */
png_setup_avg_row_only(png_structrp png_ptr, png_uint_32 bpp,
@@ -2500,7 +2500,7 @@ png_setup_paeth_row(png_structrp png_ptr, png_uint_32 bpp,
break;
}
- return (sum);
+ return sum;
}
static void /* PRIVATE */
png_setup_paeth_row_only(png_structrp png_ptr, png_uint_32 bpp,
diff --git a/Build/source/libs/libpng/libpng-src/scripts/autoconf/README.md b/Build/source/libs/libpng/libpng-src/scripts/autoconf/README.md
new file mode 100644
index 00000000000..64963b73645
--- /dev/null
+++ b/Build/source/libs/libpng/libpng-src/scripts/autoconf/README.md
@@ -0,0 +1,7 @@
+Autoconf Macro Files for the PNG Reference Library
+==================================================
+
+The Autoconf files associated with libpng are free software.
+Use, modification and distribution of each individual file
+are subject to the specific licensing terms and conditions
+stated at the top of the file.
diff --git a/Build/source/libs/libpng/libpng-src/scripts/libtool.m4 b/Build/source/libs/libpng/libpng-src/scripts/autoconf/libtool.m4
index 79a2451ef52..79a2451ef52 100644
--- a/Build/source/libs/libpng/libpng-src/scripts/libtool.m4
+++ b/Build/source/libs/libpng/libpng-src/scripts/autoconf/libtool.m4
diff --git a/Build/source/libs/libpng/libpng-src/scripts/ltoptions.m4 b/Build/source/libs/libpng/libpng-src/scripts/autoconf/ltoptions.m4
index b0b5e9c2126..b0b5e9c2126 100644
--- a/Build/source/libs/libpng/libpng-src/scripts/ltoptions.m4
+++ b/Build/source/libs/libpng/libpng-src/scripts/autoconf/ltoptions.m4
diff --git a/Build/source/libs/libpng/libpng-src/scripts/ltsugar.m4 b/Build/source/libs/libpng/libpng-src/scripts/autoconf/ltsugar.m4
index 902508bd93a..902508bd93a 100644
--- a/Build/source/libs/libpng/libpng-src/scripts/ltsugar.m4
+++ b/Build/source/libs/libpng/libpng-src/scripts/autoconf/ltsugar.m4
diff --git a/Build/source/libs/libpng/libpng-src/scripts/ltversion.m4 b/Build/source/libs/libpng/libpng-src/scripts/autoconf/ltversion.m4
index b155d0aceca..b155d0aceca 100644
--- a/Build/source/libs/libpng/libpng-src/scripts/ltversion.m4
+++ b/Build/source/libs/libpng/libpng-src/scripts/autoconf/ltversion.m4
diff --git a/Build/source/libs/libpng/libpng-src/scripts/lt~obsolete.m4 b/Build/source/libs/libpng/libpng-src/scripts/autoconf/lt~obsolete.m4
index 0f7a8759da8..0f7a8759da8 100644
--- a/Build/source/libs/libpng/libpng-src/scripts/lt~obsolete.m4
+++ b/Build/source/libs/libpng/libpng-src/scripts/autoconf/lt~obsolete.m4
diff --git a/Build/source/libs/libpng/libpng-src/scripts/cmake/AUTHORS.md b/Build/source/libs/libpng/libpng-src/scripts/cmake/AUTHORS.md
new file mode 100644
index 00000000000..1c1173ab3fa
--- /dev/null
+++ b/Build/source/libs/libpng/libpng-src/scripts/cmake/AUTHORS.md
@@ -0,0 +1,35 @@
+CMake Files, Lists and Scripts for the PNG Reference Library
+============================================================
+
+Author List
+-----------
+
+ * Alex Gaynor
+ * Andreas Franek
+ * B. Scott Michel
+ * Cameron Cawley
+ * Christian Ehrlicher
+ * Christopher Sean Morrison
+ * Claudio Bley
+ * Clifford Yapp
+ * Clinton Ingram
+ * Cosmin Truta
+ * David Callu
+ * Gleb Mazovetskiy
+ * Glenn Randers-Pehrson
+ * Gunther Nikl
+ * Jeremy Maitin-Shepard
+ * John Bowler
+ * Jon Creighton
+ * Kyle Bentley
+ * Martin Storsjö
+ * Owen Rudge
+ * Roger Leigh
+ * Roger Lowman
+ * Sam Serrels
+ * Simon Hausmann
+ * Steve Robinson
+ * Timothy Lyanguzov
+ * Tyler Kropp
+ * Vadim Barkov
+ * Vicky Pfau
diff --git a/Build/source/libs/libpng/libpng-src/scripts/cmake/README.md b/Build/source/libs/libpng/libpng-src/scripts/cmake/README.md
new file mode 100644
index 00000000000..ca418893a95
--- /dev/null
+++ b/Build/source/libs/libpng/libpng-src/scripts/cmake/README.md
@@ -0,0 +1,35 @@
+CMake Files, Lists and Scripts for the PNG Reference Library
+============================================================
+
+Copyright Notice
+----------------
+
+ * Copyright (c) 2018-2024 Cosmin Truta.
+ * Copyright (c) 2007-2018 Glenn Randers-Pehrson.
+ * Originally written by Christian Ehrlicher, 2007.
+
+Use, modification and distribution of the CMake
+files in the libpng distribution are subject to
+the same licensing terms and conditions as libpng.
+Please see the copyright notice in `png.h` or visit
+http://libpng.org/pub/png/src/libpng-LICENSE.txt
+
+File List
+---------
+
+ CMakeLists.txt ==> The main CMake lists file
+ scripts/cmake/AUTHORS.md ==> The Authors file
+ scripts/cmake/README.md ==> This file
+ scripts/cmake/genchk.cmake.in ==> Template for genchk.cmake
+ scripts/cmake/genout.cmake.in ==> Template for genout.cmake
+ scripts/cmake/gensrc.cmake.in ==> Template for gensrc.cmake
+ scripts/cmake/test.cmake.in ==> Template for test.cmake
+
+Acknowledgements
+----------------
+
+See the accompanying file `scripts/cmake/AUTHORS.md`
+for the list of Contributing Authors.
+
+If you are a Contributing Author, please make sure
+that you are being acknowledged.
diff --git a/Build/source/libs/libpng/libpng-src/scripts/genchk.cmake.in b/Build/source/libs/libpng/libpng-src/scripts/cmake/genchk.cmake.in
index 1b6aa84ae24..5ea92dd7315 100644
--- a/Build/source/libs/libpng/libpng-src/scripts/genchk.cmake.in
+++ b/Build/source/libs/libpng/libpng-src/scripts/cmake/genchk.cmake.in
@@ -1,12 +1,16 @@
# genchk.cmake.in
# Generate .chk from .out with awk (generic), based upon the automake logic.
-# Copyright (C) 2016 Glenn Randers-Pehrson
+# Copyright (c) 2022-2024 Cosmin Truta
+# Copyright (c) 2016 Glenn Randers-Pehrson
# Written by Roger Leigh, 2016
-
-# This code is released under the libpng license.
-# For conditions of distribution and use, see the disclaimer
-# and license in png.h
+#
+# Use, modification and distribution are subject to
+# the same licensing terms and conditions as libpng.
+# Please see the copyright notice in png.h or visit
+# http://libpng.org/pub/png/src/libpng-LICENSE.txt
+#
+# SPDX-License-Identifier: libpng-2.0
# Variables substituted from CMakeLists.txt
set(SRCDIR "@CMAKE_CURRENT_SOURCE_DIR@")
@@ -21,7 +25,7 @@ get_filename_component(OUTPUTBASE "${OUTPUT}" NAME_WE)
get_filename_component(INPUTDIR "${INPUT}" PATH)
get_filename_component(OUTPUTDIR "${OUTPUT}" PATH)
-if("${INPUTEXT}" STREQUAL ".out" AND "${OUTPUTEXT}" STREQUAL ".chk")
+if(INPUTEXT STREQUAL ".out" AND OUTPUTEXT STREQUAL ".chk")
# Generate .chk from .out with awk (generic)
file(REMOVE "${OUTPUT}" "${OUTPUTDIR}/${OUTPUTBASE}.new")
execute_process(COMMAND "${AWK}" -f "${BINDIR}/scripts/checksym.awk"
diff --git a/Build/source/libs/libpng/libpng-src/scripts/genout.cmake.in b/Build/source/libs/libpng/libpng-src/scripts/cmake/genout.cmake.in
index ec685d900d7..ab828596899 100644
--- a/Build/source/libs/libpng/libpng-src/scripts/genout.cmake.in
+++ b/Build/source/libs/libpng/libpng-src/scripts/cmake/genout.cmake.in
@@ -1,12 +1,16 @@
# genout.cmake.in
# Generate .out from .c with awk (generic), based upon the automake logic.
-# Copyright (C) 2016 Glenn Randers-Pehrson
+# Copyright (c) 2022-2024 Cosmin Truta
+# Copyright (c) 2016 Glenn Randers-Pehrson
# Written by Roger Leigh, 2016
-
-# This code is released under the libpng license.
-# For conditions of distribution and use, see the disclaimer
-# and license in png.h
+#
+# Use, modification and distribution are subject to
+# the same licensing terms and conditions as libpng.
+# Please see the copyright notice in png.h or visit
+# http://libpng.org/pub/png/src/libpng-LICENSE.txt
+#
+# SPDX-License-Identifier: libpng-2.0
# Variables substituted from CMakeLists.txt
set(SRCDIR "@CMAKE_CURRENT_SOURCE_DIR@")
@@ -41,7 +45,7 @@ get_filename_component(OUTPUTBASE "${OUTPUT}" NAME_WE)
get_filename_component(INPUTDIR "${INPUT}" PATH)
get_filename_component(OUTPUTDIR "${OUTPUT}" PATH)
-if ("${INPUTEXT}" STREQUAL ".c" AND "${OUTPUTEXT}" STREQUAL ".out")
+if(INPUTEXT STREQUAL ".c" AND OUTPUTEXT STREQUAL ".out")
get_filename_component(GENDIR "${OUTPUT}" PATH)
file(MAKE_DIRECTORY "${GENDIR}")
diff --git a/Build/source/libs/libpng/libpng-src/scripts/gensrc.cmake.in b/Build/source/libs/libpng/libpng-src/scripts/cmake/gensrc.cmake.in
index e97fada20f9..52dab8d2bcd 100644
--- a/Build/source/libs/libpng/libpng-src/scripts/gensrc.cmake.in
+++ b/Build/source/libs/libpng/libpng-src/scripts/cmake/gensrc.cmake.in
@@ -1,12 +1,16 @@
# gensrc.cmake.in
# Generate source files with awk, based upon the automake logic.
-# Copyright (C) 2016 Glenn Randers-Pehrson
+# Copyright (c) 2022-2024 Cosmin Truta
+# Copyright (c) 2016 Glenn Randers-Pehrson
# Written by Roger Leigh, 2016
-
-# This code is released under the libpng license.
-# For conditions of distribution and use, see the disclaimer
-# and license in png.h
+#
+# Use, modification and distribution are subject to
+# the same licensing terms and conditions as libpng.
+# Please see the copyright notice in png.h or visit
+# http://libpng.org/pub/png/src/libpng-LICENSE.txt
+#
+# SPDX-License-Identifier: libpng-2.0
# Variables substituted from CMakeLists.txt
set(SRCDIR "@CMAKE_CURRENT_SOURCE_DIR@")
@@ -17,7 +21,7 @@ set(DFA_XTRA "@DFA_XTRA@")
set(PNG_PREFIX "@PNG_PREFIX@")
set(PNGLIB_VERSION "@PNGLIB_VERSION@")
-if("${OUTPUT}" STREQUAL "scripts/pnglibconf.c")
+if(OUTPUT STREQUAL "scripts/pnglibconf.c")
# Generate scripts/pnglibconf.c
file(REMOVE "${BINDIR}/pnglibconf.tf6" "${BINDIR}/pnglibconf.tf7")
@@ -45,7 +49,7 @@ if("${OUTPUT}" STREQUAL "scripts/pnglibconf.c")
file(MAKE_DIRECTORY "${BINDIR}/scripts")
file(RENAME "pnglibconf.tf7" "${BINDIR}/scripts/pnglibconf.c")
-elseif ("${OUTPUT}" STREQUAL "pnglibconf.c")
+elseif(OUTPUT STREQUAL "pnglibconf.c")
# Generate pnglibconf.c
file(REMOVE "${BINDIR}/pnglibconf.tf4" "${BINDIR}/pnglibconf.tf5")
@@ -72,7 +76,7 @@ elseif ("${OUTPUT}" STREQUAL "pnglibconf.c")
file(MAKE_DIRECTORY "${BINDIR}/scripts")
file(RENAME "pnglibconf.tf5" "${BINDIR}/pnglibconf.c")
-elseif ("${OUTPUT}" STREQUAL "pnglibconf.h")
+elseif(OUTPUT STREQUAL "pnglibconf.h")
# Generate pnglibconf.h
file(REMOVE "${BINDIR}/${OUTPUT}")
@@ -101,7 +105,7 @@ elseif ("${OUTPUT}" STREQUAL "pnglibconf.h")
endif()
endif()
-elseif ("${OUTPUT}" STREQUAL "pngprefix.h")
+elseif(OUTPUT STREQUAL "pngprefix.h")
# Generate pngprefix.h
file(REMOVE "${BINDIR}/${OUTPUT}")
@@ -123,7 +127,7 @@ elseif ("${OUTPUT}" STREQUAL "pngprefix.h")
file(WRITE "${BINDIR}/${OUTPUT}" "/* No libpng symbol prefix configured. */")
endif()
-elseif("${OUTPUT}" STREQUAL "scripts/pnglibconf.h.prebuilt")
+elseif(OUTPUT STREQUAL "scripts/pnglibconf.h.prebuilt")
# Generate scripts/pnglibconf.h.prebuilt (fails build)
message(STATUS "Attempting to build scripts/pnglibconf.h.prebuilt")
@@ -134,5 +138,7 @@ elseif("${OUTPUT}" STREQUAL "scripts/pnglibconf.h.prebuilt")
message(FATAL_ERROR "Stopping build")
else()
+
message(FATAL_ERROR "Unsupported output: ${OUTPUT}")
+
endif()
diff --git a/Build/source/libs/libpng/libpng-src/scripts/test.cmake.in b/Build/source/libs/libpng/libpng-src/scripts/cmake/test.cmake.in
index fa6a889bbaf..a1cd30f556c 100644
--- a/Build/source/libs/libpng/libpng-src/scripts/test.cmake.in
+++ b/Build/source/libs/libpng/libpng-src/scripts/cmake/test.cmake.in
@@ -1,11 +1,15 @@
# test.cmake.in
-# Copyright (C) 2016 Glenn Randers-Pehrson
+# Copyright (c) 2024 Cosmin Truta
+# Copyright (c) 2016 Glenn Randers-Pehrson
# Written by Roger Leigh, 2016
-
-# This code is released under the libpng license.
-# For conditions of distribution and use, see the disclaimer
-# and license in png.h
+#
+# Use, modification and distribution are subject to
+# the same licensing terms and conditions as libpng.
+# Please see the copyright notice in png.h or visit
+# http://libpng.org/pub/png/src/libpng-LICENSE.txt
+#
+# SPDX-License-Identifier: libpng-2.0
set(TEST_OPTIONS "@TEST_OPTIONS@")
set(TEST_FILES "@TEST_FILES@")
@@ -22,8 +26,7 @@ if(WIN32)
set(ENV{PATH} "${LIBPNG_DIR};$ENV{PATH}")
endif()
-execute_process(COMMAND "${CMAKE_COMMAND}" -E echo "Running ${TEST_COMMAND}" ${TEST_OPTIONS} ${NATIVE_TEST_FILES})
-
+message("Running ${TEST_COMMAND}" ${TEST_OPTIONS} ${NATIVE_TEST_FILES})
execute_process(COMMAND "${TEST_COMMAND}" ${TEST_OPTIONS} ${NATIVE_TEST_FILES}
RESULT_VARIABLE TEST_STATUS)
if(TEST_STATUS)
diff --git a/Build/source/libs/libpng/libpng-src/scripts/libpng-config-head.in b/Build/source/libs/libpng/libpng-src/scripts/libpng-config-head.in
index b3e45a4b59b..3cc2ecb7127 100644
--- a/Build/source/libs/libpng/libpng-src/scripts/libpng-config-head.in
+++ b/Build/source/libs/libpng/libpng-src/scripts/libpng-config-head.in
@@ -11,7 +11,7 @@
# Modeled after libxml-config.
-version=1.6.40
+version=1.6.41
prefix=""
libdir=""
libs=""
diff --git a/Build/source/libs/libpng/libpng-src/scripts/libpng.pc.in b/Build/source/libs/libpng/libpng-src/scripts/libpng.pc.in
index 142b1b51f33..d206d86a4e8 100644
--- a/Build/source/libs/libpng/libpng-src/scripts/libpng.pc.in
+++ b/Build/source/libs/libpng/libpng-src/scripts/libpng.pc.in
@@ -5,6 +5,6 @@ includedir=@includedir@/libpng16
Name: libpng
Description: Loads and saves PNG files
-Version: 1.6.40
+Version: 1.6.41
Libs: -L${libdir} -lpng16
Cflags: -I${includedir}
diff --git a/Build/source/libs/libpng/libpng-src/scripts/pnglibconf.dfa b/Build/source/libs/libpng/libpng-src/scripts/pnglibconf.dfa
index 003e0f2f04c..739805d2d99 100644
--- a/Build/source/libs/libpng/libpng-src/scripts/pnglibconf.dfa
+++ b/Build/source/libs/libpng/libpng-src/scripts/pnglibconf.dfa
@@ -8,7 +8,7 @@ com pnglibconf.h - library build configuration
com
version
com
-com Copyright (c) 2018-2023 Cosmin Truta
+com Copyright (c) 2018-2024 Cosmin Truta
com Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson
com
com This code is released under the libpng license.
@@ -256,6 +256,55 @@ option POWERPC_VSX_API disabled enables SET_OPTION,
option POWERPC_VSX_CHECK disabled,
sets POWERPC_VSX_OPT 1
+# These options are specific to the MIPS MSA hardware optimizations.
+#
+# MIPS_MSA_OPT: unset: check at compile time (__mips_msa must be defined by
+# the compiler, typically as a result of specifying
+# "-mmsa -mfp64" compiler flags)
+# 0: disable (even if the CPU supports MSA.)
+# 1: check at run time (via MIPS_MSA_{API,CHECK})
+# 2: switch on unconditionally (inadvisable - instead pass
+# -mmsa -mfp64 to compiler options)
+# When building libpng avoid using any setting other than '0'; '1' is
+# set automatically when either 'API' or 'CHECK' are configured in,
+# '2' should not be necessary as "-mmsa -mfp64" will achieve the same
+# effect as well as applying MSA optimizations to the rest of the
+# libpng code.
+# NOTE: any setting other than '0' requires ALIGNED_MEMORY
+# MIPS_MSA_API: (PNG_MIPS_MSA == 1) allow the optimization to be switched on
+# with png_set_option.
+# MIPS_MSA_CHECK: (PNG_MIPS_MSA == 1) compile a run-time check to see if MSA
+# extensions are supported.
+setting MIPS_MSA_OPT
+option MIPS_MSA_API disabled requires ALIGNED_MEMORY enables SET_OPTION,
+ sets MIPS_MSA_OPT 1
+option MIPS_MSA_CHECK disabled requires ALIGNED_MEMORY,
+ sets MIPS_MSA_OPT 1
+
+# These options are specific to the MIPS MMI hardware optimizations.
+#
+# MIPS_MMI_OPT: unset: check at compile time (__mips_loongson_mmi must be defined by
+# the compiler, typically as a result of specifying
+# "-mloongson-mmi -march=loongson3a" compiler flags)
+# 0: disable (even if the CPU supports MMI.)
+# 1: check at run time (via MIPS_MMI_{API,CHECK})
+# 2: switch on unconditionally (inadvisable - instead pass
+# -mloongson-mmi -march=loongson3a to compiler options)
+# When building libpng avoid using any setting other than '0'; '1' is
+# set automatically when either 'API' or 'CHECK' are configured in,
+# '2' should not be necessary as "-mloongson-mmi -march=loongson3a" will achieve the same
+# effect as well as applying MMI optimizations to the rest of the
+# libpng code.
+# MIPS_MMI_API: (PNG_MIPS_MMI == 1) allow the optimization to be switched on
+# with png_set_option
+# MIPS_MMI_CHECK: (PNG_MIPS_MMI == 1) compile a run-time check to see if MMI
+# extensions are supported.
+setting MIPS_MMI_OPT
+option MIPS_MMI_API disabled requires ALIGNED_MEMORY enables SET_OPTION,
+ sets MIPS_MMI_OPT 1
+option MIPS_MMI_CHECK disabled requires ALIGNED_MEMORY,
+ sets MIPS_MMI_OPT 1
+
# These settings configure the default compression level (0-9) and 'strategy';
# strategy is as defined by the implementors of zlib. It describes the input
@@ -336,6 +385,34 @@ option BENIGN_ERRORS
option BENIGN_WRITE_ERRORS requires BENIGN_ERRORS disabled
option BENIGN_READ_ERRORS requires BENIGN_ERRORS
+# Adler32 checksum
+#
+# This option allows the check of the Adler32 checksum performed by zlib to
+# be turned off for IDAT chunks (only). Unless this option is enabled and
+# turned on (not the default even if enabled) a failed Adler32 at the end of the
+# stream will result in a decompression (inflate) failure on read even though
+# the entire image might have been read successfully.
+#
+# This option relies on an undocumented function 'inflateValidate' which is
+# present in only some versions of zlib. If the function is not present in the
+# zlib used with libpng code which uses -lpng is likely to fail to link or to
+# launch in the case of a DLL.
+#
+# Therefore this option is currently disabled by default; it has to be turned on
+# in pngusr.dfa and then the application program has to explicitly turn the
+# functionality on by calling png_set_option.
+#
+# Furthermore the option is explicitly turned off here if the zlib version
+# number is below that required - libpng wouldn't compile in that case if the
+# option were turned on.
+option DISABLE_ADLER32_CHECK requires READ enables SET_OPTION disabled
+
+# ZLIB_VERNUM must be used here, not PNG_ZLIB_VERNUM, because
+# scripts/options.awk ends up putting this test adhead of the setting of
+# PNG_ZLIB_VERNUM (apparently above, but not because of the two-pass processing)
+@#if ZLIB_VERNUM < 0x1290
+@# define PNG_NO_DISABLE_ADLER32_CHECK
+@#endif
# Generic options - affect both read and write.
diff --git a/Build/source/libs/libpng/libpng-src/scripts/pnglibconf.h.prebuilt b/Build/source/libs/libpng/libpng-src/scripts/pnglibconf.h.prebuilt
index c7033ae176f..d768a8ef087 100644
--- a/Build/source/libs/libpng/libpng-src/scripts/pnglibconf.h.prebuilt
+++ b/Build/source/libs/libpng/libpng-src/scripts/pnglibconf.h.prebuilt
@@ -1,8 +1,8 @@
/* pnglibconf.h - library build configuration */
-/* libpng version 1.6.40 */
+/* libpng version 1.6.41 */
-/* Copyright (c) 2018-2023 Cosmin Truta */
+/* Copyright (c) 2018-2024 Cosmin Truta */
/* Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson */
/* This code is released under the libpng license. */
@@ -27,6 +27,7 @@
#define PNG_COLORSPACE_SUPPORTED
#define PNG_CONSOLE_IO_SUPPORTED
#define PNG_CONVERT_tIME_SUPPORTED
+/*#undef PNG_DISABLE_ADLER32_CHECK_SUPPORTED*/
#define PNG_EASY_ACCESS_SUPPORTED
/*#undef PNG_ERROR_NUMBERS_SUPPORTED*/
#define PNG_ERROR_TEXT_SUPPORTED
@@ -41,6 +42,10 @@
#define PNG_INCH_CONVERSIONS_SUPPORTED
#define PNG_INFO_IMAGE_SUPPORTED
#define PNG_IO_STATE_SUPPORTED
+/*#undef PNG_MIPS_MMI_API_SUPPORTED*/
+/*#undef PNG_MIPS_MMI_CHECK_SUPPORTED*/
+/*#undef PNG_MIPS_MSA_API_SUPPORTED*/
+/*#undef PNG_MIPS_MSA_CHECK_SUPPORTED*/
#define PNG_MNG_FEATURES_SUPPORTED
#define PNG_POINTER_INDEXING_SUPPORTED
/*#undef PNG_POWERPC_VSX_API_SUPPORTED*/
diff --git a/Build/source/libs/libpng/libpng-src/tests/pngtest-all b/Build/source/libs/libpng/libpng-src/tests/pngtest-all
index 5e96451d373..7a9b64ae672 100644
--- a/Build/source/libs/libpng/libpng-src/tests/pngtest-all
+++ b/Build/source/libs/libpng/libpng-src/tests/pngtest-all
@@ -1,16 +1,93 @@
#!/bin/sh
-# normal execution
+st=0 # exit status (set to 1 if a test fails)
+fail="**FAIL**"
+success=" SUCCESS"
+TEST(){
+ # Try to make the log file easier to read:
+ test_status="$success"
+ echo "=============== PNGTEST $* ===================="
+ ./pngtest "$@" || {
+ st=$?
+ test_status="$fail"
+ }
+ echo "===============$test_status $* ===================="
+}
-./pngtest --strict ${srcdir}/pngtest.png
+# The "standard" test
+TEST --strict "${srcdir}"/pngtest.png
-# various crashers
-# using --relaxed because some come from fuzzers that don't maintain CRC's
+# Various crashers
+# Use --relaxed because some come from fuzzers that don't maintain CRCs
+TEST --relaxed "${srcdir}"/contrib/testpngs/crashers/badcrc.png
+# Use --xfail because there is no reliable way of disabling these errors
+# (Adler32 checking cannot be switched off on all builds and there is no
+# provision for turning the other checks into warnings.)
+TEST --xfail "${srcdir}"/contrib/testpngs/crashers/badadler.png
+TEST --xfail "${srcdir}"/contrib/testpngs/crashers/bad_iCCP.png
+TEST --xfail "${srcdir}"/contrib/testpngs/crashers/empty_ancillary_chunks.png
+for file in "${srcdir}"/contrib/testpngs/crashers/huge_*_chunk.png
+do
+ TEST --xfail "$file"
+done
+for file in "${srcdir}"/contrib/testpngs/crashers/huge_*safe_to_copy.png
+do
+ TEST --xfail "$file"
+done
+TEST --xfail "${srcdir}"/contrib/testpngs/crashers/huge_IDAT.png
-./pngtest --relaxed ${srcdir}/contrib/testpngs/crashers/badcrc.png
-./pngtest --relaxed ${srcdir}/contrib/testpngs/crashers/badadler.png
-./pngtest --xfail ${srcdir}/contrib/testpngs/crashers/bad_iCCP.png
-./pngtest --xfail ${srcdir}/contrib/testpngs/crashers/empty_ancillary_chunks.png
-./pngtest --xfail ${srcdir}/contrib/testpngs/crashers/huge_*_chunk.png \
- ${srcdir}/contrib/testpngs/crashers/huge_*safe_to_copy.png
-./pngtest --xfail ${srcdir}/contrib/testpngs/crashers/huge_IDAT.png
+# Regression tests for required warnings (or errors):
+check_stdout(){
+ # $1: the test file (a bad PNG which must produce a warning, etc)
+ # $2: a string which must occur at the end of line on stdout for success
+ # result: an error message on descriptor 3 if the string is NOT found
+ #
+ # WARNING: when this script is executed on MSYS2 (Windows Cygwin variant)
+ # pngtest outputs lines terminated with <cr><lf> however the MSYS2 shell
+ # expects <lf> (\n) terminated lines so the <cr> ends up in the shell
+ # variable 'line' below. The pattern matching ignores this because of the
+ # '*' at the end of the pattern match.
+ found=
+ while read line
+ do
+ case "$line" in
+ *"$2"*) found=1;;
+ esac
+ echo "$line" # preserve the original output verbatim
+ done
+ # output the missing warning on descriptor 3:
+ test -z "$found" && echo "$1: $2" >&3
+}
+# NOTE: traditionally the Bourne shell executed the last element in a pipe
+# sequence in the original shell so it could set variables in the original
+# shell however this is not reliable and doesn't work in bash.
+#
+# It *is* reliable to use the actual exit status of the last command in
+# the pipeline.
+exec 4>&1 # original stdout - the log file
+{
+ exec 3>&1 # stdout is the pipe at this point
+ fail=" FAIL(EXPECTED)" # runtime scope
+ success=" SUCCESS(UNEXPECTED)" # there should be a write error
+ for file in "${srcdir}"/contrib/testpngs/badpal/*.png
+ do
+ # The exit code is ignored here, the test is that the particular errors
+ # (warnings) are produced. The original output still ends up in the log
+ # file.
+ TEST "$file" |
+ check_stdout "$file" 'IDAT: Read palette index exceeding num_palette' |
+ check_stdout "$file" 'Wrote palette index exceeding num_palette' >&4
+ done
+ exec 3>&-
+} | {
+ # This may not be a sub-shell, if it is 'st' is undefined and the exit
+ # just ends up as 'exit'.
+ while read error
+ do
+ echo "MISSING REPORT: $error"
+ st=1
+ done
+ exit $st
+} || st=$?
+
+exit $st
diff --git a/Build/source/libs/libpng/version.ac b/Build/source/libs/libpng/version.ac
index 4886dd8b922..12fa4795212 100644
--- a/Build/source/libs/libpng/version.ac
+++ b/Build/source/libs/libpng/version.ac
@@ -8,4 +8,4 @@ dnl
dnl --------------------------------------------------------
dnl
dnl m4-include this file to define the current libpng version
-m4_define([libpng_version], [1.6.40])
+m4_define([libpng_version], [1.6.41])