diff --git a/bin/Irrlicht.dll b/bin/Irrlicht.dll
index af319668..e29ad78d 100644
Binary files a/bin/Irrlicht.dll and b/bin/Irrlicht.dll differ
diff --git a/bin/Irrlicht_VS.dll b/bin/Irrlicht_VS.dll
index 61bdcde5..c16512e8 100644
Binary files a/bin/Irrlicht_VS.dll and b/bin/Irrlicht_VS.dll differ
diff --git a/bin/Irrlicht_VS64.dll b/bin/Irrlicht_VS64.dll
index af319668..e29ad78d 100644
Binary files a/bin/Irrlicht_VS64.dll and b/bin/Irrlicht_VS64.dll differ
diff --git a/bin/Irrlicht_mingw.dll b/bin/Irrlicht_mingw.dll
index 33ab2638..48b7eb13 100644
Binary files a/bin/Irrlicht_mingw.dll and b/bin/Irrlicht_mingw.dll differ
diff --git a/bin/Irrlicht_mingw64.dll b/bin/Irrlicht_mingw64.dll
index 340b7125..00e0b7a8 100644
Binary files a/bin/Irrlicht_mingw64.dll and b/bin/Irrlicht_mingw64.dll differ
diff --git a/src/libs/Irrlicht/changesForBC.txt b/src/libs/Irrlicht/changesForBC.txt
index 8c1ea416..50501ba4 100644
--- a/src/libs/Irrlicht/changesForBC.txt
+++ b/src/libs/Irrlicht/changesForBC.txt
@@ -1,7 +1,7 @@
Notes on Irrlicht as used in Bridge Command
===========================================
-Irrlicht updated to r6731 from SVN trunk
+Irrlicht updated to r6738 from SVN trunk
The following changes are applied for Bridge Command from
Irrlicht trunk, and all changes marked in source with //JAMES:
diff --git a/src/libs/Irrlicht/irrlicht-svn/changes.txt b/src/libs/Irrlicht/irrlicht-svn/changes.txt
index 578c1543..ddfc8fa6 100644
--- a/src/libs/Irrlicht/irrlicht-svn/changes.txt
+++ b/src/libs/Irrlicht/irrlicht-svn/changes.txt
@@ -456,6 +456,8 @@ Changes in 1.9 (not yet released)
--------------------------
Changes in 1.8.6
+- Update libpng to 1.6.54 (from 1.6.37)
+- Avoid compile warnings with newer compilers like gcc 14
- Fix CGUIPanel (in Gui Editor) so horizontal scrollbar can get focus (Feature request #163). Thanks @yybbwc for reporting.
- CXMeshFileLoader: fix buffer overreads with text format. Thanks @sfan5 for report and patch.
Patch (commit 6f4f7c4 to Minetest): https://github.com/minetest/irrlicht/commit/6f4f7c4d75c9d563e98d3936ed8bc6e248dc14a8
diff --git a/src/libs/Irrlicht/irrlicht-svn/lib/Win32-gcc/Irrlicht.dll b/src/libs/Irrlicht/irrlicht-svn/lib/Win32-gcc/Irrlicht.dll
index 33ab2638..48b7eb13 100644
Binary files a/src/libs/Irrlicht/irrlicht-svn/lib/Win32-gcc/Irrlicht.dll and b/src/libs/Irrlicht/irrlicht-svn/lib/Win32-gcc/Irrlicht.dll differ
diff --git a/src/libs/Irrlicht/irrlicht-svn/lib/Win32-gcc/libIrrlicht.a b/src/libs/Irrlicht/irrlicht-svn/lib/Win32-gcc/libIrrlicht.a
index 283d1421..a1cc3fce 100644
Binary files a/src/libs/Irrlicht/irrlicht-svn/lib/Win32-gcc/libIrrlicht.a and b/src/libs/Irrlicht/irrlicht-svn/lib/Win32-gcc/libIrrlicht.a differ
diff --git a/src/libs/Irrlicht/irrlicht-svn/lib/Win32-visualstudio/Irrlicht.lib b/src/libs/Irrlicht/irrlicht-svn/lib/Win32-visualstudio/Irrlicht.lib
index f52ad0b1..95e02b35 100644
Binary files a/src/libs/Irrlicht/irrlicht-svn/lib/Win32-visualstudio/Irrlicht.lib and b/src/libs/Irrlicht/irrlicht-svn/lib/Win32-visualstudio/Irrlicht.lib differ
diff --git a/src/libs/Irrlicht/irrlicht-svn/lib/Win64-gcc/Irrlicht.dll b/src/libs/Irrlicht/irrlicht-svn/lib/Win64-gcc/Irrlicht.dll
index 340b7125..00e0b7a8 100644
Binary files a/src/libs/Irrlicht/irrlicht-svn/lib/Win64-gcc/Irrlicht.dll and b/src/libs/Irrlicht/irrlicht-svn/lib/Win64-gcc/Irrlicht.dll differ
diff --git a/src/libs/Irrlicht/irrlicht-svn/lib/Win64-gcc/libIrrlicht.a b/src/libs/Irrlicht/irrlicht-svn/lib/Win64-gcc/libIrrlicht.a
index 03134086..414841b8 100644
Binary files a/src/libs/Irrlicht/irrlicht-svn/lib/Win64-gcc/libIrrlicht.a and b/src/libs/Irrlicht/irrlicht-svn/lib/Win64-gcc/libIrrlicht.a differ
diff --git a/src/libs/Irrlicht/irrlicht-svn/lib/Win64-visualstudio/Irrlicht.lib b/src/libs/Irrlicht/irrlicht-svn/lib/Win64-visualstudio/Irrlicht.lib
index ea6fa1a3..4ebf080f 100644
Binary files a/src/libs/Irrlicht/irrlicht-svn/lib/Win64-visualstudio/Irrlicht.lib and b/src/libs/Irrlicht/irrlicht-svn/lib/Win64-visualstudio/Irrlicht.lib differ
diff --git a/src/libs/Irrlicht/irrlicht-svn/source/Irrlicht/CImageLoaderJPG.cpp b/src/libs/Irrlicht/irrlicht-svn/source/Irrlicht/CImageLoaderJPG.cpp
index 48c8997d..77f0cbf7 100644
--- a/src/libs/Irrlicht/irrlicht-svn/source/Irrlicht/CImageLoaderJPG.cpp
+++ b/src/libs/Irrlicht/irrlicht-svn/source/Irrlicht/CImageLoaderJPG.cpp
@@ -210,7 +210,7 @@ IImage* CImageLoaderJPG::loadImage(io::IReadFile* file) const
jpeg_read_header(&cinfo, TRUE);
bool useCMYK=false;
- if (cinfo.jpeg_color_space==JCS_CMYK)
+ if (cinfo.jpeg_color_space==JCS_CMYK || cinfo.jpeg_color_space==JCS_YCCK)
{
cinfo.out_color_space=JCS_CMYK;
cinfo.out_color_components=4;
diff --git a/src/libs/Irrlicht/irrlicht-svn/source/Irrlicht/COpenGLCoreCacheHandler.h b/src/libs/Irrlicht/irrlicht-svn/source/Irrlicht/COpenGLCoreCacheHandler.h
index 6a3eb822..9e3c4ba4 100644
--- a/src/libs/Irrlicht/irrlicht-svn/source/Irrlicht/COpenGLCoreCacheHandler.h
+++ b/src/libs/Irrlicht/irrlicht-svn/source/Irrlicht/COpenGLCoreCacheHandler.h
@@ -148,9 +148,7 @@ class COpenGLCoreCacheHandler
{
if (Texture[i] == texture)
{
- Texture[i] = 0;
-
- texture->drop();
+ set(i, nullptr);
}
}
}
@@ -161,11 +159,7 @@ class COpenGLCoreCacheHandler
{
if (Texture[i])
{
- const TOpenGLTexture* prevTexture = Texture[i];
-
- Texture[i] = 0;
-
- prevTexture->drop();
+ set(i, nullptr);
}
}
}
@@ -415,7 +409,7 @@ class COpenGLCoreCacheHandler
// Color Mask.
- void getColorMask(u8& mask)
+ void getColorMask(u8& mask) const
{
mask = ColorMask[0];
}
@@ -470,6 +464,11 @@ class COpenGLCoreCacheHandler
// Depth calls.
+ void getDepthFunc(GLenum& mode) const
+ {
+ mode = DepthFunc;
+ }
+
void setDepthFunc(GLenum mode)
{
if (DepthFunc != mode)
@@ -479,7 +478,7 @@ class COpenGLCoreCacheHandler
}
}
- void getDepthMask(bool& depth)
+ void getDepthMask(bool& depth) const
{
depth = DepthMask;
}
@@ -497,7 +496,7 @@ class COpenGLCoreCacheHandler
}
}
- void getDepthTest(bool& enable)
+ void getDepthTest(bool& enable) const
{
enable = DepthTest;
}
diff --git a/src/libs/Irrlicht/irrlicht-svn/source/Irrlicht/COpenGLCoreTexture.h b/src/libs/Irrlicht/irrlicht-svn/source/Irrlicht/COpenGLCoreTexture.h
index ccd37704..9093b367 100644
--- a/src/libs/Irrlicht/irrlicht-svn/source/Irrlicht/COpenGLCoreTexture.h
+++ b/src/libs/Irrlicht/irrlicht-svn/source/Irrlicht/COpenGLCoreTexture.h
@@ -262,6 +262,7 @@ class COpenGLCoreTexture : public ITexture
#if 1
IImage* tmpImage = LockImage; // not sure yet if the size required by glGetTexImage is always correct, if not we might have to allocate a different tmpImage and convert colors later on.
+ const COpenGLCoreTexture* prevTexture = Driver->getCacheHandler()->getTextureCache().get(0);
Driver->getCacheHandler()->getTextureCache().set(0, this);
Driver->testGLError(__LINE__);
@@ -297,6 +298,9 @@ class COpenGLCoreTexture : public ITexture
delete[] tmpBuffer;
}
+
+ Driver->getCacheHandler()->getTextureCache().set(0, prevTexture);
+
#else // Alternative method working with copies to memory, still here for quick testing when things break, hope we can remove that before 1.9 release.
COpenGLCoreTexture* tmpTexture = new COpenGLCoreTexture("OGL_CORE_LOCK_TEXTURE", Size, ETT_2D, ColorFormat, Driver);
diff --git a/src/libs/Irrlicht/irrlicht-svn/source/Irrlicht/Irrlicht-gcc.cbp b/src/libs/Irrlicht/irrlicht-svn/source/Irrlicht/Irrlicht-gcc.cbp
index 789a1169..08498e95 100644
--- a/src/libs/Irrlicht/irrlicht-svn/source/Irrlicht/Irrlicht-gcc.cbp
+++ b/src/libs/Irrlicht/irrlicht-svn/source/Irrlicht/Irrlicht-gcc.cbp
@@ -129,6 +129,9 @@
+
+
+
@@ -1340,6 +1343,7 @@
+
diff --git a/src/libs/Irrlicht/irrlicht-svn/source/Irrlicht/Irrlicht17.0.vcxproj b/src/libs/Irrlicht/irrlicht-svn/source/Irrlicht/Irrlicht17.0.vcxproj
index fc3e1714..15fcacb3 100644
--- a/src/libs/Irrlicht/irrlicht-svn/source/Irrlicht/Irrlicht17.0.vcxproj
+++ b/src/libs/Irrlicht/irrlicht-svn/source/Irrlicht/Irrlicht17.0.vcxproj
@@ -362,7 +362,7 @@
WIN32;WIN64;NDEBUG;_WINDOWS;_USRDLL;IRRLICHT_EXPORTS;_CRT_SECURE_NO_DEPRECATE;%(PreprocessorDefinitions)truefalse
- MultiThreadedDLL
+ MultiThreadedfalsetrueLevel3
diff --git a/src/libs/Irrlicht/irrlicht-svn/source/Irrlicht/SConstruct b/src/libs/Irrlicht/irrlicht-svn/source/Irrlicht/SConstruct
index bbc03897..1b5ae23f 100644
--- a/src/libs/Irrlicht/irrlicht-svn/source/Irrlicht/SConstruct
+++ b/src/libs/Irrlicht/irrlicht-svn/source/Irrlicht/SConstruct
@@ -43,7 +43,7 @@ def createEnvironment() :
vars.Add(PathVariable("installdir", "install directory for the library", os.path.join("bin"), PathVariable.PathIsDirCreate))
vars.Add(EnumVariable("buildtarget", "type of the library", "shared", allowed_values=("shared", "static")))
vars.Add(EnumVariable("buildtype", "name of target build type", "release", allowed_values=("debug", "release")))
- vars.Add(EnumVariable("platform", "build platform", "", allowed_values=("", "linux", "osx-library", "osx-framework", "win32-mingw", "win32-msvc", "win64-msvc")))
+ vars.Add(EnumVariable("platform", "build platform", "", allowed_values=("", "linux", "osx-library", "osx-framework", "win32-mingw", "win32-msvc", "win64-msvc", "win64-mingw")))
vars.Add(BoolVariable("package", "creates of the compiled library a package (header & binary) as a zip file", False))
vars.Add(BoolVariable("opengl", "build with Open GL support", True))
@@ -60,8 +60,11 @@ def createEnvironment() :
if env["platform"] in ["linux", "osx-library", "osx-framework"] :
env.Tool("default")
+ # add CMake compile_commands
+ env.Tool('compilation_db')
+ env.CompilationDatabase()
- elif env["platform"] in ["win32-msvc", "win64-mvc"] :
+ elif env["platform"] in ["win32-msvc", "win64-msvc"] :
env.Tool("msvc")
env.Tool("mslink")
env.Tool("msvs")
@@ -69,6 +72,9 @@ def createEnvironment() :
elif env["platform"] in ["win32-mingw", "win64-mingw"] :
env.Tool("mingw")
+ # add CMake compile_commands
+ env.Tool('compilation_db')
+ env.CompilationDatabase()
else :
raise SCons.Errors.StopError("platform is not set")
@@ -83,11 +89,12 @@ def createEnvironment() :
# read first Irrlicht SDK version from the file include/IrrCompileConfig.h
irrlichtversion = None
try :
- configfile = open( os.path.join("include", "IrrCompileConfig.h"), "r" )
+ configpath = os.path.join("include", "IrrCompileConfig.h")
+ configfile = open( configpath, "r" )
irrlichtversion = re.search("#define(.*)IRRLICHT_SDK_VERSION(.*)", configfile.read())
configfile.close()
except :
- pass
+ pass
if irrlichtversion == None :
raise SCons.Errors.StopError("can not find Irrlicht SDK version in the configuration header")
@@ -99,10 +106,11 @@ def createEnvironment() :
if env["buildtype"] == "debug" :
env["irr_libinstallname"] = env["irr_libinstallname"] + "Debug"
- if "CXX" in os.environ :
- env.Replace(CXX = os.environ["CXX"])
- if "CC" in os.environ :
- env.Replace(CC = os.environ["CC"])
+ if env["platform"] not in ["win32-msvc", "win64-msvc"]:
+ if "CXX" in os.environ :
+ env.Replace(CXX = os.environ["CXX"])
+ if "CC" in os.environ :
+ env.Replace(CC = os.environ["CC"])
if "CPPPATH" in os.environ :
env.AppendUnique(CPPPATH = os.environ["CPPPATH"].split(os.pathsep))
if "CXXFLAGS" in os.environ :
@@ -175,8 +183,11 @@ def getLibraryBuildEnvironment(env) :
elif envlib["platform"] in ["win32-msvc", "win64-msvc"] :
+ exeversion = "0.0"
+ if envlib["irr_libversion"] != None:
+ exeversion = ".".join(envlib["irr_libversion"].split('.')[:2]) # /VERSION is major.minor only...
envlib.AppendUnique(CXXFLAGS = ["/analyze", "/Gd", "/GF", "/GR-", "/GS", "/Gy", "/Zl"])
- envlib.AppendUnique(LINKFLAGS = ["/VERSION:\""+envlib["irr_libversion"]+"\"", "/nologo"])
+ envlib.AppendUnique(LINKFLAGS = ["/VERSION:\""+exeversion+"\"", "/nologo"])
envlib.AppendUnique(LIBS = ["gdi32.lib", "user32.lib", "advapi32.lib"])
if envlib["buildtype"] == "debug" :
@@ -220,7 +231,7 @@ def configDirectX(envlib) :
if "win32" in envlib["platform"] :
envlib.AppendUnique(LIBPATH = [os.path.join(envlib["directxsdk"], "Lib", "x86")])
elif "win64" in envlib["platform"] :
- envlib.AppendUnique(LIBPATH = [os.path.join(envlib["directxsdk"], "Lib", "x84")])
+ envlib.AppendUnique(LIBPATH = [os.path.join(envlib["directxsdk"], "Lib", "x64")])
else :
envlib.AppendUnique(CPPDEFINES = ["NO_IRR_COMPILE_WITH_DIRECT3D_9_"])
@@ -360,7 +371,6 @@ env = createEnvironment()
envlib = getLibraryBuildEnvironment(env)
envexamples = getExampleBuildEnvironment(env)
-
# === set the sources (we use similar structure of the Makefile) ====================================================
# get all header files (for later installation)
headers = Glob(os.path.join("include", "*.h"))
diff --git a/src/libs/Irrlicht/irrlicht-svn/source/Irrlicht/libpng/ANNOUNCE b/src/libs/Irrlicht/irrlicht-svn/source/Irrlicht/libpng/ANNOUNCE
index 33f9b05d..e35e626d 100644
--- a/src/libs/Irrlicht/irrlicht-svn/source/Irrlicht/libpng/ANNOUNCE
+++ b/src/libs/Irrlicht/irrlicht-svn/source/Irrlicht/libpng/ANNOUNCE
@@ -1,5 +1,5 @@
-libpng 1.6.37 - April 14, 2019
-==============================
+libpng 1.6.54 - January 12, 2026
+================================
This is a public release of libpng, intended for use in production code.
@@ -7,15 +7,12 @@ This is a public release of libpng, intended for use in production code.
Files available for download
----------------------------
-Source files with LF line endings (for Unix/Linux):
+Source files:
- * libpng-1.6.37.tar.xz (LZMA-compressed, recommended)
- * libpng-1.6.37.tar.gz
-
-Source files with CRLF line endings (for Windows):
-
- * lp1637.7z (LZMA-compressed, recommended)
- * lp1637.zip
+ * libpng-1.6.54.tar.xz (LZMA-compressed, recommended)
+ * libpng-1.6.54.tar.gz (deflate-compressed)
+ * lpng1654.7z (LZMA-compressed)
+ * lpng1654.zip (deflate-compressed)
Other information:
@@ -25,21 +22,16 @@ Other information:
* TRADEMARK.md
-Changes since the previous public release (version 1.6.36)
-----------------------------------------------------------
-
- * Fixed a use-after-free vulnerability (CVE-2019-7317) in png_image_free.
- * Fixed a memory leak in the ARM NEON implementation of png_do_expand_palette.
- * Fixed a memory leak in pngtest.c.
- * Fixed two vulnerabilities (CVE-2018-14048, CVE-2018-14550) in
- contrib/pngminus; refactor.
- * Changed the license of contrib/pngminus to MIT; refresh makefile and docs.
- (Contributed by Willem van Schaik)
- * Fixed a typo in the libpng license v2.
- (Contributed by Miguel Ojeda)
- * Added makefiles for AddressSanitizer-enabled builds.
- * Cleaned up various makefiles.
+Changes from version 1.6.53 to version 1.6.54
+---------------------------------------------
+ * Fixed CVE-2026-22695 (medium severity):
+ Heap buffer over-read in `png_image_read_direct_scaled.
+ (Reported and fixed by Petr Simecek.)
+ * Fixed CVE-2026-22801 (medium severity):
+ Integer truncation causing heap buffer over-read in `png_image_write_*`.
+ * Implemented various improvements in oss-fuzz.
+ (Contributed by Philippe Antoine.)
Send comments/corrections/commendations to png-mng-implement at lists.sf.net.
Subscription is required; visit
diff --git a/src/libs/Irrlicht/irrlicht-svn/source/Irrlicht/libpng/AUTHORS b/src/libs/Irrlicht/irrlicht-svn/source/Irrlicht/libpng/AUTHORS
index 79a3d103..b9c0fffc 100644
--- a/src/libs/Irrlicht/irrlicht-svn/source/Irrlicht/libpng/AUTHORS
+++ b/src/libs/Irrlicht/irrlicht-svn/source/Irrlicht/libpng/AUTHORS
@@ -4,7 +4,10 @@ PNG REFERENCE LIBRARY AUTHORS
This is the list of PNG Reference Library ("libpng") Contributing
Authors, for copyright and licensing purposes.
+ * Adam Richter
+ * Alexander Smorkalov
* Andreas Dilger
+ * Chris Blume
* Cosmin Truta
* Dave Martindale
* Eric S. Raymond
@@ -15,31 +18,54 @@ Authors, for copyright and licensing purposes.
* James Yu
* John Bowler
* Kevin Bracey
+ * Lucas Chollet
* Magnus Holmgren
* Mandar Sahastrabuddhe
+ * Manfred Schlaegl
* Mans Rullgard
* Matt Sarett
* Mike Klein
+ * Pascal Massimino
* Paul Schmidt
+ * Petr Simecek
+ * Philippe Antoine
+ * Qiang Zhou
* Sam Bushell
* Samuel Williams
* Simon-Pierre Cadieux
* Tim Wegner
+ * Tobias Stoeckmann
* Tom Lane
* Tom Tanner
* Vadim Barkov
* Willem van Schaik
* Zhijie Liang
+ * Apple Inc.
+ - Zixu Wang (王子旭)
* Arm Holdings
- - Richard Townsend
- * Google Inc.
- - Matt Sarett
- - Mike Klein
+ - Richard Townsend
+ * Google LLC
+ - Dan Field
+ - Dragoș Tiselice
+ - Leon Scroggins III
+ - Matt Sarett
+ - Mike Klein
+ - Sami Boukortt
+ - Wan-Teh Chang
+ * Loongson Technology Corporation Ltd.
+ - GuXiWei (顾希伟)
+ - JinBo (金波)
+ - ZhangLixia (张利霞)
+ * Samsung Group
+ - Filip Wasil
+ * SpacemiT Hangzhou Technology, Co.
+ - Liang Junzhao (梁俊钊)
The build projects, the build scripts, the test scripts, and other
-files in the "projects", "scripts" and "tests" directories, have other
-copyright owners, but are released under the libpng license.
+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/src/libs/Irrlicht/irrlicht-svn/source/Irrlicht/libpng/CHANGES b/src/libs/Irrlicht/irrlicht-svn/source/Irrlicht/libpng/CHANGES
index abd63da4..7d18763a 100644
--- a/src/libs/Irrlicht/irrlicht-svn/source/Irrlicht/libpng/CHANGES
+++ b/src/libs/Irrlicht/irrlicht-svn/source/Irrlicht/libpng/CHANGES
@@ -204,7 +204,7 @@ Version 0.97 [January, 1998]
Added simple sRGB support (Glenn R-P)
Easier conditional compiling, e.g.,
define PNG_READ/WRITE_NOT_FULLY_SUPPORTED;
- all configurable options can be selected from command-line instead
+ all configurable options can be selected from command line instead
of having to edit pngconf.h (Glenn R-P)
Fixed memory leak in pngwrite.c (free info_ptr->text) (Glenn R-P)
Added more conditions for png_do_background, to avoid changing
@@ -942,7 +942,7 @@ Version 1.0.8 [July 24, 2000]
Version 1.0.9beta1 [November 10, 2000]
Fixed typo in scripts/makefile.hpux
Updated makevms.com in scripts and contrib/* and contrib/* (Martin Zinser)
- Fixed seqence-point bug in contrib/pngminus/png2pnm (Martin Zinser)
+ Fixed sequence-point bug in contrib/pngminus/png2pnm (Martin Zinser)
Changed "cdrom.com" in documentation to "libpng.org"
Revised pnggccrd.c to get it all working, and updated makefile.gcmmx (Greg).
Changed type of "params" from voidp to png_voidp in png_read|write_png().
@@ -2295,7 +2295,7 @@ Version 1.4.0beta58 [May 14, 2009]
Clarified usage of sig_bit versus sig_bit_p in example.c (Vincent Torri)
Version 1.4.0beta59 [May 15, 2009]
- Reformated sources in libpng style (3-space intentation, comment format)
+ Reformatted sources in libpng style (3-space indentation, comment format)
Fixed typo in libpng docs (PNG_FILTER_AVE should be PNG_FILTER_AVG)
Added sections about the git repository and our coding style to the
documentation
@@ -2661,7 +2661,7 @@ Version 1.4.1beta06 [January 28, 2010]
Version 1.4.1beta07 [February 6, 2010]
Folded some long lines in the source files.
- Added defineable PNG_USER_CHUNK_CACHE_MAX, PNG_USER_CHUNK_MALLOC_MAX,
+ Added definable PNG_USER_CHUNK_CACHE_MAX, PNG_USER_CHUNK_MALLOC_MAX,
and a PNG_USER_LIMITS_SUPPORTED flag.
Eliminated use of png_ptr->irowbytes and reused the slot in png_ptr as
png_ptr->png_user_chunk_malloc_max.
@@ -3886,7 +3886,7 @@ Version 1.6.0beta06 [January 24, 2012]
Version 1.6.0beta07 [January 28, 2012]
Eliminated Intel icc/icl compiler warnings. The Intel (GCC derived)
compiler issues slightly different warnings from those issued by the
- current vesions of GCC. This eliminates those warnings by
+ current versions of GCC. This eliminates those warnings by
adding/removing casts and small code rewrites.
Updated configure.ac from autoupdate: added --enable-werror option.
Also some layout regularization and removal of introduced tab characters
@@ -3919,7 +3919,7 @@ Version 1.6.0beta08 [February 1, 2012]
version checking to configure.ac
Improved pngstest speed by not doing redundant tests and add const to
the background parameter of png_image_finish_read. The --background
- option is now done automagically only when required, so that commandline
+ option is now done automagically only when required, so that command-line
option no longer exists.
Cleaned up pngpriv.h to consistently declare all functions and data.
Also eliminated PNG_CONST_DATA, which is apparently not needed but we
@@ -4052,7 +4052,7 @@ Version 1.6.0beta16 [March 6, 2012]
(in fact this is harmless, but the PNG data produced may be sub-optimal).
Version 1.6.0beta17 [March 10, 2012]
- Fixed PNG_LIBPNG_BUILD_BASE_TYPE definition.
+ Fixed PNG_LIBPNG_BUILD_BASE_TYPE definition.
Reject all iCCP chunks after the first, even if the first one is invalid.
Deflate/inflate was reworked to move common zlib calls into single
functions [rw]util.c. A new shared keyword check routine was also added
@@ -4962,7 +4962,7 @@ Version 1.6.13beta01 [July 4, 2014]
Changed "if defined(__ARM_NEON__)" to
"if (defined(__ARM_NEON__) || defined(__ARM_NEON))" (James Wu).
Fixed clang no-warning builds: png_digit was defined but never used.
-
+
Version 1.6.13beta02 [July 21, 2014]
Fixed an incorrect separator ("/" should be "\") in scripts/makefile.vcwin32
(bug report from Wolfgang S. Kechel). Bug was introduced in libpng-1.6.11.
@@ -5453,7 +5453,7 @@ Version 1.6.21beta01 [December 11, 2015]
Version 1.6.21beta02 [December 14, 2015]
Moved png_check_keyword() from pngwutil.c to pngset.c
Removed LE/BE dependencies in pngvalid, to 'fix' the current problem
- in the BigEndian tests by not testing it, making the BE code the same
+ in the BigEndian tests by not testing it, making the BE code the same
as the LE version.
Fixes to pngvalid for various reduced build configurations (eliminate unused
statics) and a fix for the case in rgb_to_gray when the digitize option
@@ -5517,7 +5517,7 @@ Version 1.6.22beta03 [March 9, 2016]
Added a common-law trademark notice and export control information
to the LICENSE file, png.h, and the man page.
Restored "& 0xff" in png_save_uint_16() and png_save_uint_32() that
- were accidentally removed from libpng-1.6.17.
+ were accidentally removed from libpng-1.6.17.
Changed PNG_INFO_cHNK and PNG_FREE_cHNK from 0xnnnn to 0xnnnnU in png.h
(Robert C. Seacord).
Removed dubious "#if INT_MAX" test from png.h that was added to
@@ -5927,7 +5927,7 @@ Version 1.6.32beta03 [August 2, 2017]
(Bug report from the OSS-fuzz project).
Version 1.6.32beta04 [August 2, 2017]
- Replaced local eXIf_buf with info_ptr-eXIf_buf in png_handle_eXIf().
+ Replaced local eXIf_buf with info_ptr->eXIf_buf in png_handle_eXIf().
Update libpng.3 and libpng-manual.txt about eXIf functions.
Version 1.6.32beta05 [August 2, 2017]
@@ -5950,7 +5950,7 @@ Version 1.6.32beta09 [August 3, 2017]
Require cmake-2.8.8 in CMakeLists.txt. Revised symlink creation,
no longer using deprecated cmake LOCATION feature (Clifford Yapp).
Fixed five-byte error in the calculation of IDAT maximum possible size.
-
+
Version 1.6.32beta10 [August 5, 2017]
Moved chunk-length check into a png_check_chunk_length() private
function (Suggested by Max Stepin).
@@ -6103,6 +6103,234 @@ Version 1.6.37 [April 14, 2019]
Added makefiles for AddressSanitizer-enabled builds.
Cleaned up various makefiles.
+Version 1.6.38 [September 14, 2022]
+ Added configurations and scripts for continuous integration.
+ Fixed various errors in the handling of tRNS, hIST and eXIf.
+ Implemented many stability improvements across all platforms.
+ Updated the internal documentation.
+
+Version 1.6.39 [November 20, 2022]
+ Changed the error handler of oversized chunks (i.e. larger than
+ PNG_USER_CHUNK_MALLOC_MAX) from png_chunk_error to png_benign_error.
+ Fixed a buffer overflow error in contrib/tools/pngfix.
+ Fixed a memory leak (CVE-2019-6129) in contrib/tools/pngcp.
+ Disabled the ARM Neon optimizations by default in the CMake file,
+ following the default behavior of the configure script.
+ Allowed configure.ac to work with the trunk version of autoconf.
+ Removed the support for "install" targets from the legacy makefiles;
+ removed the obsolete makefile.cegcc.
+ Cleaned up the code and updated the internal documentation.
+
+Version 1.6.40 [June 21, 2023]
+ 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.
+
+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)
+
+Version 1.6.42 [January 29, 2024]
+ Fixed the implementation of the macro function png_check_sig().
+ This was an API regression, introduced in libpng-1.6.41.
+ (Reported by Matthieu Darbois)
+ Fixed and updated the libpng manual.
+
+Version 1.6.43 [February 23, 2024]
+ Fixed the row width check in png_check_IHDR().
+ This corrected a bug that was specific to the 16-bit platforms,
+ and removed a spurious compiler warning from the 64-bit builds.
+ (Reported by Jacek Caban; fixed by John Bowler)
+ Added eXIf chunk support to the push-mode reader in pngpread.c.
+ (Contributed by Chris Blume)
+ Added contrib/pngexif for the benefit of the users who would like
+ to inspect the content of eXIf chunks.
+ Added contrib/conftest/basic.dfa, a basic build-time configuration.
+ (Contributed by John Bowler)
+ Fixed a preprocessor condition in pngread.c that broke build-time
+ configurations like contrib/conftest/pngcp.dfa.
+ (Contributed by John Bowler)
+ Added CMake build support for LoongArch LSX.
+ (Contributed by GuXiWei)
+ Fixed a CMake build error that occurred under a peculiar state of the
+ dependency tree. This was a regression introduced in libpng-1.6.41.
+ (Contributed by Dan Rosser)
+ Marked the installed libpng headers as system headers in CMake.
+ (Contributed by Benjamin Buch)
+ Updated the build support for RISCOS.
+ (Contributed by Cameron Cawley)
+ Updated the makefiles to allow cross-platform builds to initialize
+ conventional make variables like AR and ARFLAGS.
+ Added various improvements to the CI scripts in areas like version
+ consistency verification and text linting.
+ Added version consistency verification to pngtest.c also.
+
+Version 1.6.44 [September 12, 2024]
+ Hardened calculations in chroma handling to prevent overflows, and
+ relaxed a constraint in cHRM validation to accomodate the standard
+ ACES AP1 set of color primaries.
+ (Contributed by John Bowler)
+ Removed the ASM implementation of ARM Neon optimizations and updated
+ the build accordingly. Only the remaining C implementation shall be
+ used from now on, thus ensuring the support of the PAC/BTI security
+ features on ARM64.
+ (Contributed by Ross Burton and John Bowler)
+ Fixed the pickup of the PNG_HARDWARE_OPTIMIZATIONS option in the
+ CMake build on FreeBSD/amd64. This is an important performance fix
+ on this platform.
+ Applied various fixes and improvements to the CMake build.
+ (Contributed by Eric Riff, Benjamin Buch and Erik Scholz)
+ Added fuzzing targets for the simplified read API.
+ (Contributed by Mikhail Khachayants)
+ Fixed a build error involving pngtest.c under a custom config.
+ This was a regression introduced in a code cleanup in libpng-1.6.43.
+ (Contributed by Ben Wagner)
+ Fixed and improved the config files for AppVeyor CI and Travis CI.
+
+Version 1.6.45 [January 7, 2025]
+ Added support for the cICP chunk.
+ (Contributed by Lucas Chollet and John Bowler)
+ Adjusted and improved various checks in colorspace calculations.
+ (Contributed by John Bowler)
+ Rearranged the write order of colorspace chunks for better conformance
+ with the PNG v3 draft specification.
+ (Contributed by John Bowler)
+ Raised the minimum required CMake version from 3.6 to 3.14.
+ Forked off a development branch for libpng version 1.8.
+
+Version 1.6.46 [January 23, 2025]
+ Added support for the mDCV and cLLI chunks.
+ (Contributed by John Bowler)
+ Fixed a build issue affecting C89 compilers.
+ This was a regression introduced in libpng-1.6.45.
+ (Contributed by John Bowler)
+ Added makefile.c89, specifically for testing C89 compilers.
+ Cleaned up contrib/pngminus: corrected an old typo, removed an old
+ workaround, and updated the CMake file.
+
+Version 1.6.47 [February 18, 2025]
+ Modified the behaviour of colorspace chunks in order to adhere
+ to the new precedence rules formulated in the latest draft of
+ the PNG Specification.
+ (Contributed by John Bowler)
+ Fixed a latent bug in `png_write_iCCP`.
+ This would have been a read-beyond-end-of-malloc vulnerability,
+ introduced early in the libpng-1.6.0 development, yet (fortunately!)
+ it was inaccessible before the above-mentioned modification of the
+ colorspace precedence rules, due to pre-existing colorspace checks.
+ (Reported by Bob Friesenhahn; fixed by John Bowler)
+
+Version 1.6.48 [April 30, 2025]
+ Fixed the floating-point version of the mDCv setter `png_set_mDCv`.
+ (Reported by Mohit Bakshi; fixed by John Bowler)
+ Added #error directives to discourage the inclusion of private
+ libpng implementation header files in PNG-supporting applications.
+ Added the CMake build option `PNG_LIBCONF_HEADER`, to be used as an
+ alternative to `DFA_XTRA`.
+ Removed the Travis CI configuration files, with heartfelt thanks for
+ their generous support of our project over the past five years!
+
+Version 1.6.49 [June 12, 2025]
+ Added SIMD-optimized code for the RISC-V Vector Extension (RVV).
+ (Contributed by Manfred Schlaegl, Dragos Tiselice and Filip Wasil)
+ Added various fixes and improvements to the build scripts and to
+ the sample code.
+
+Version 1.6.50 [July 1, 2025]
+ Improved the detection of the RVV Extension on the RISC-V platform.
+ (Contributed by Filip Wasil)
+ Replaced inline ASM with C intrinsics in the RVV code.
+ (Contributed by Filip Wasil)
+ Fixed a decoder defect in which unknown chunks trailing IDAT, set
+ to go through the unknown chunk handler, incorrectly triggered
+ out-of-place IEND errors.
+ (Contributed by John Bowler)
+ Fixed the CMake file for cross-platform builds that require `libm`.
+
+Version 1.6.51 [November 21, 2025]
+ Fixed CVE-2025-64505 (moderate severity):
+ Heap buffer overflow in `png_do_quantize` via malformed palette index.
+ (Reported by Samsung; analyzed by Fabio Gritti.)
+ Fixed CVE-2025-64506 (moderate severity):
+ Heap buffer over-read in `png_write_image_8bit` with 8-bit input and
+ `convert_to_8bit` enabled.
+ (Reported by Samsung and ;
+ analyzed by Fabio Gritti.)
+ Fixed CVE-2025-64720 (high severity):
+ Buffer overflow in `png_image_read_composite` via incorrect palette
+ premultiplication.
+ (Reported by Samsung; analyzed by John Bowler.)
+ Fixed CVE-2025-65018 (high severity):
+ Heap buffer overflow in `png_combine_row` triggered via
+ `png_image_finish_read`.
+ (Reported by .)
+ Fixed a memory leak in `png_set_quantize`.
+ (Reported by Samsung; analyzed by Fabio Gritti.)
+ Removed the experimental and incomplete ERROR_NUMBERS code.
+ (Contributed by Tobias Stoeckmann.)
+ Improved the RISC-V vector extension support; required RVV 1.0 or newer.
+ (Contributed by Filip Wasil.)
+ Added GitHub Actions workflows for automated testing.
+ Performed various refactorings and cleanups.
+
+Version 1.6.52 [December 3, 2025]
+ Fixed CVE-2025-66293 (high severity):
+ Out-of-bounds read in `png_image_read_composite`.
+ (Reported by flyfish101 .)
+ Fixed the Paeth filter handling in the RISC-V RVV implementation.
+ (Reported by Filip Wasil; fixed by Liang Junzhao.)
+ Improved the performance of the RISC-V RVV implementation.
+ (Contributed by Liang Junzhao.)
+ Added allocation failure fuzzing to oss-fuzz.
+ (Contributed by Philippe Antoine.)
+
+Version 1.6.53 [December 5, 2025]
+ Fixed a build failure on RISC-V RVV caused by a misspelled intrinsic.
+ (Contributed by Alexander Smorkalov.)
+ Fixed a build failure with CMake 4.1 or newer, on Windows, when using
+ Visual C++ without MASM installed.
+
+Version 1.6.54 [January 12, 2026]
+ Fixed CVE-2026-22695 (medium severity):
+ Heap buffer over-read in `png_image_read_direct_scaled.
+ (Reported and fixed by Petr Simecek.)
+ Fixed CVE-2026-22801 (medium severity):
+ Integer truncation causing heap buffer over-read in `png_image_write_*`.
+ Implemented various improvements in oss-fuzz.
+ (Contributed by Philippe Antoine.)
+
+
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/src/libs/Irrlicht/irrlicht-svn/source/Irrlicht/libpng/CMakeLists.txt b/src/libs/Irrlicht/irrlicht-svn/source/Irrlicht/libpng/CMakeLists.txt
index 73668ccd..0a95f20f 100644
--- a/src/libs/Irrlicht/irrlicht-svn/source/Irrlicht/libpng/CMakeLists.txt
+++ b/src/libs/Irrlicht/irrlicht-svn/source/Irrlicht/libpng/CMakeLists.txt
@@ -1,368 +1,497 @@
-# CMakeLists.txt
-
-# Copyright (C) 2018 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 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
-# Revised by Cosmin Truta, 2018
-# Revised by Kyle Bentley, 2018
-
-# 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()
+# CMakeLists.txt - CMake lists for libpng
+#
+# Copyright (c) 2018-2026 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.14...4.2)
set(PNGLIB_MAJOR 1)
set(PNGLIB_MINOR 6)
-set(PNGLIB_RELEASE 37)
-set(PNGLIB_NAME libpng${PNGLIB_MAJOR}${PNGLIB_MINOR})
-set(PNGLIB_VERSION ${PNGLIB_MAJOR}.${PNGLIB_MINOR}.${PNGLIB_RELEASE})
+set(PNGLIB_REVISION 54)
+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})
-include(GNUInstallDirs)
+project(libpng
+ VERSION ${PNGLIB_VERSION}
+ LANGUAGES C)
-# needed packages
+include(CheckCSourceCompiles)
+include(CheckLibraryExists)
+include(GNUInstallDirs)
-# Allow users to specify location of Zlib.
-# Useful if zlib is being built alongside this as a sub-project.
-option(PNG_BUILD_ZLIB "Custom zlib Location, else find_package is used" OFF)
+# 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
+ ""
+ CACHE STRING "Prefix to prepend to the API function names")
+
+# Allow the users to override the postfix appended to debug library file names.
+# Previously, we used to set CMAKE_DEBUG_POSTFIX globally. That variable should
+# not be cached, however, because doing so would affect all projects processed
+# after libpng, in unexpected and undesirable ways.
+set(PNG_DEBUG_POSTFIX
+ "d"
+ CACHE STRING "Postfix to append to library file names under the Debug configuration")
+
+# Allow the users to import their own extra configuration settings.
+# Those settings can be either passed via DFA_XTRA if they are in DFA form
+# (such as "pngusr.dfa"), or via PNG_LIBCONF_HEADER if they are in prebuilt
+# header file form (such as "scripts/pnglibconf.h.prebuilt"), but not both.
+# For platforms such as Android or iOS, or in certain cross-platform build
+# scenarios, having a valid PNG_LIBCONF_HEADER is mandatory.
+set(DFA_XTRA
+ ""
+ CACHE FILEPATH "DFA file containing customized build configuration settings for libpng")
+set(PNG_LIBCONF_HEADER
+ ""
+ CACHE FILEPATH "C header file containing customized build configuration settings for libpng")
+set(PNG_LIBCONF_HEADER_PREBUILT "${CMAKE_CURRENT_SOURCE_DIR}/scripts/pnglibconf.h.prebuilt")
+if(ANDROID OR IOS)
+ set(PNG_LIBCONF_HEADER "${PNG_LIBCONF_HEADER_PREBUILT}")
+endif()
+if((NOT DFA_XTRA STREQUAL "") AND (NOT PNG_LIBCONF_HEADER STREQUAL ""))
+ message(SEND_ERROR "The options DFA_XTRA=\"${DFA_XTRA}\" "
+ "and PNG_LIBCONF_HEADER=\"${PNG_LIBCONF_HEADER}\" "
+ "are mutually exclusive")
+endif()
-if(NOT PNG_BUILD_ZLIB)
- find_package(ZLIB REQUIRED)
- include_directories(${ZLIB_INCLUDE_DIR})
+# 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)
+else()
+ option(PNG_FRAMEWORK "Build libpng as a framework bundle (not available on this platform)" OFF)
+endif()
+if(NOT APPLE AND PNG_FRAMEWORK)
+ message(SEND_ERROR "The option PNG_FRAMEWORK should not be set on this platform")
endif()
-if(UNIX AND NOT APPLE AND NOT BEOS AND NOT HAIKU)
- find_library(M_LIBRARY m)
+# Allow the users to switch on/off the auxiliary build and test artifacts.
+# These artifacts are NOT part of libpng proper, and are subject to change
+# at any time.
+option(PNG_TESTS "Build the libpng tests" ON)
+
+# Same as above, but for the third-party tools.
+# Although these tools are targetted at development environments only,
+# the users are allowed to override the option to build by default.
+if(ANDROID OR IOS)
+ option(PNG_TOOLS "Build the libpng tools" OFF)
else()
- # libm is not needed and/or not available
- set(M_LIBRARY "")
+ option(PNG_TOOLS "Build the libpng tools" ON)
endif()
-# COMMAND LINE OPTIONS
-option(PNG_SHARED "Build shared lib" ON)
-option(PNG_STATIC "Build static lib" ON)
-option(PNG_TESTS "Build libpng tests" 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()
-# Many more configuration options could be added here
-option(PNG_FRAMEWORK "Build OS X framework" OFF)
-option(PNG_DEBUG "Build with debug output" OFF)
+# Allow the users to switch on/off the use of hardware (SIMD) optimized code.
option(PNG_HARDWARE_OPTIMIZATIONS "Enable hardware optimizations" ON)
-set(PNG_PREFIX "" CACHE STRING "Prefix to add to the API function names")
-set(DFA_XTRA "" CACHE FILEPATH "File containing extra configuration settings")
+# Initialize and show the target architecture variable PNG_TARGET_ARCHITECTURE.
+#
+# NOTE:
+# On macOS, CMake sets CMAKE_SYSTEM_PROCESSOR to either "x86_64" or "arm64",
+# based upon the OS architecture, not the target architecture. As such, we need
+# to check CMAKE_OSX_ARCHITECTURES to identify which hardware-specific flags to
+# enable. Note that this will fail if you attempt to build a universal binary
+# in a single CMake invocation.
+if(APPLE AND CMAKE_OSX_ARCHITECTURES)
+ string(TOLOWER "${CMAKE_OSX_ARCHITECTURES}" PNG_TARGET_ARCHITECTURE)
+else()
+ string(TOLOWER "${CMAKE_SYSTEM_PROCESSOR}" PNG_TARGET_ARCHITECTURE)
+endif()
+message(STATUS "Building for target architecture: ${PNG_TARGET_ARCHITECTURE}")
+
+# Allow the users to specify a custom location of zlib.
+# With CMake 3.12 and newer, this option is no longer necessary.
+option(PNG_BUILD_ZLIB "[Deprecated; please use ZLIB_ROOT]" OFF)
+if(PNG_BUILD_ZLIB)
+ if("x${ZLIB_ROOT}" STREQUAL "x")
+ message(SEND_ERROR "The option PNG_BUILD_ZLIB=${PNG_BUILD_ZLIB} is no longer supported; "
+ "please use ZLIB_ROOT instead")
+ else()
+ message(SEND_ERROR "The option PNG_BUILD_ZLIB=${PNG_BUILD_ZLIB} is no longer supported; "
+ "using ZLIB_ROOT=\"${ZLIB_ROOT}\"")
+ endif()
+endif()
+
+# Find the zlib library.
+find_package(ZLIB REQUIRED)
+set(PNG_LINK_LIBRARIES ZLIB::ZLIB)
+
+# Find the math library (unless we already know it's not available or
+# not needed).
+if(UNIX AND NOT (APPLE OR BEOS OR HAIKU OR EMSCRIPTEN))
+ check_library_exists(m pow "" PNG_HAVE_LIBM_POW)
+endif()
+if(PNG_HAVE_LIBM_POW)
+ list(APPEND PNG_LINK_LIBRARIES m)
+endif()
+
+# Silence function deprecation warnings on the Windows compilers that might
+# use the MSVC Runtime library headers.
+if(WIN32 AND (CMAKE_C_COMPILER_ID MATCHES "MSVC|Intel|Clang"))
+ add_definitions(-D_CRT_NONSTDC_NO_DEPRECATE)
+ add_definitions(-D_CRT_SECURE_NO_DEPRECATE)
+endif()
if(PNG_HARDWARE_OPTIMIZATIONS)
-# set definitions and sources for arm
-if(CMAKE_SYSTEM_PROCESSOR MATCHES "^arm" OR
- CMAKE_SYSTEM_PROCESSOR MATCHES "^aarch64")
- set(PNG_ARM_NEON_POSSIBLE_VALUES check on off)
- set(PNG_ARM_NEON "check" CACHE STRING "Enable ARM NEON optimizations:
- check: (default) use internal checking code;
- off: disable the optimizations;
- on: turn on unconditionally.")
- set_property(CACHE PNG_ARM_NEON PROPERTY STRINGS
- ${PNG_ARM_NEON_POSSIBLE_VALUES})
- 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")
- 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")
- add_definitions(-DPNG_ARM_NEON_OPT=2)
- elseif(${PNG_ARM_NEON} STREQUAL "check")
- add_definitions(-DPNG_ARM_NEON_CHECK_SUPPORTED)
+ # Set definitions and sources for ARM.
+ if(PNG_TARGET_ARCHITECTURE MATCHES "^(arm|aarch)")
+ if(PNG_TARGET_ARCHITECTURE MATCHES "^(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")
+ else()
+ set(PNG_ARM_NEON_POSSIBLE_VALUES check on off)
+ set(PNG_ARM_NEON
+ "off"
+ CACHE STRING "Enable ARM NEON optimizations: check|on|off; off is default")
+ endif()
+ set_property(CACHE PNG_ARM_NEON
+ PROPERTY STRINGS ${PNG_ARM_NEON_POSSIBLE_VALUES})
+ 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")
+ set(libpng_arm_sources
+ arm/arm_init.c
+ arm/filter_neon_intrinsics.c
+ arm/palette_neon_intrinsics.c)
+ if(PNG_ARM_NEON STREQUAL "on")
+ add_definitions(-DPNG_ARM_NEON_OPT=2)
+ elseif(PNG_ARM_NEON STREQUAL "check")
+ add_definitions(-DPNG_ARM_NEON_CHECK_SUPPORTED)
+ endif()
+ else()
+ add_definitions(-DPNG_ARM_NEON_OPT=0)
endif()
- else()
- add_definitions(-DPNG_ARM_NEON_OPT=0)
endif()
-endif()
-# set definitions and sources for powerpc
-if(CMAKE_SYSTEM_PROCESSOR MATCHES "^powerpc*" OR
- CMAKE_SYSTEM_PROCESSOR MATCHES "^ppc64*")
- set(PNG_POWERPC_VSX_POSSIBLE_VALUES on off)
- set(PNG_POWERPC_VSX "on" CACHE STRING "Enable POWERPC VSX optimizations:
- off: disable the optimizations.")
- set_property(CACHE PNG_POWERPC_VSX PROPERTY STRINGS
- ${PNG_POWERPC_VSX_POSSIBLE_VALUES})
- 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")
- set(libpng_powerpc_sources
- powerpc/powerpc_init.c
- powerpc/filter_vsx_intrinsics.c)
- if(${PNG_POWERPC_VSX} STREQUAL "on")
- add_definitions(-DPNG_POWERPC_VSX_OPT=2)
+ # Set definitions and sources for PowerPC.
+ if(PNG_TARGET_ARCHITECTURE 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")
+ set_property(CACHE PNG_POWERPC_VSX
+ PROPERTY STRINGS ${PNG_POWERPC_VSX_POSSIBLE_VALUES})
+ 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")
+ set(libpng_powerpc_sources
+ powerpc/powerpc_init.c
+ powerpc/filter_vsx_intrinsics.c)
+ if(PNG_POWERPC_VSX STREQUAL "on")
+ add_definitions(-DPNG_POWERPC_VSX_OPT=2)
+ endif()
+ else()
+ add_definitions(-DPNG_POWERPC_VSX_OPT=0)
endif()
- else()
- add_definitions(-DPNG_POWERPC_VSX_OPT=0)
endif()
-endif()
-# set definitions and sources for intel
-if(CMAKE_SYSTEM_PROCESSOR MATCHES "^i?86" OR
- CMAKE_SYSTEM_PROCESSOR MATCHES "^x86_64*")
- set(PNG_INTEL_SSE_POSSIBLE_VALUES on off)
- set(PNG_INTEL_SSE "on" CACHE STRING "Enable INTEL_SSE optimizations:
- off: disable the optimizations")
- set_property(CACHE PNG_INTEL_SSE PROPERTY STRINGS
- ${PNG_INTEL_SSE_POSSIBLE_VALUES})
- 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")
- set(libpng_intel_sources
- intel/intel_init.c
- intel/filter_sse2_intrinsics.c)
- if(${PNG_INTEL_SSE} STREQUAL "on")
- add_definitions(-DPNG_INTEL_SSE_OPT=1)
+ # Set definitions and sources for Intel.
+ if(PNG_TARGET_ARCHITECTURE 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")
+ set_property(CACHE PNG_INTEL_SSE
+ PROPERTY STRINGS ${PNG_INTEL_SSE_POSSIBLE_VALUES})
+ 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")
+ set(libpng_intel_sources
+ intel/intel_init.c
+ intel/filter_sse2_intrinsics.c)
+ if(PNG_INTEL_SSE STREQUAL "on")
+ add_definitions(-DPNG_INTEL_SSE_OPT=1)
+ endif()
+ else()
+ add_definitions(-DPNG_INTEL_SSE_OPT=0)
endif()
- else()
- add_definitions(-DPNG_INTEL_SSE_OPT=0)
endif()
-endif()
-# set definitions and sources for MIPS
-if(CMAKE_SYSTEM_PROCESSOR MATCHES "mipsel*" OR
- CMAKE_SYSTEM_PROCESSOR MATCHES "mips64el*")
- set(PNG_MIPS_MSA_POSSIBLE_VALUES on off)
- set(PNG_MIPS_MSA "on" CACHE STRING "Enable MIPS_MSA optimizations:
- off: disable the optimizations")
- 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)
- message(FATAL_ERROR
- "PNG_MIPS_MSA must be one of [${PNG_MIPS_MSA_POSSIBLE_VALUES}]")
- elseif(NOT ${PNG_MIPS_MSA} STREQUAL "off")
- set(libpng_mips_sources
- mips/mips_init.c
- mips/filter_msa_intrinsics.c)
- if(${PNG_MIPS_MSA} STREQUAL "on")
+ # Set definitions and sources for MIPS.
+ if(PNG_TARGET_ARCHITECTURE 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_msa)
+ if(index_msa EQUAL -1)
+ message(FATAL_ERROR "PNG_MIPS_MSA must be one of [${PNG_MIPS_MSA_POSSIBLE_VALUES}]")
+ 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)
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)
+ add_definitions(-DPNG_MIPS_MMI_OPT=1)
+ else()
+ add_definitions(-DPNG_MIPS_MSA_OPT=0)
+ add_definitions(-DPNG_MIPS_MMI_OPT=0)
+ endif()
+ endif()
+
+ # Set definitions and sources for LoongArch.
+ if(PNG_TARGET_ARCHITECTURE MATCHES "^(loongarch)")
+ include(CheckCCompilerFlag)
+ set(PNG_LOONGARCH_LSX_POSSIBLE_VALUES on off)
+ set(PNG_LOONGARCH_LSX
+ "on"
+ CACHE STRING "Enable LOONGARCH_LSX optimizations: on|off; on is default")
+ set_property(CACHE PNG_LOONGARCH_LSX
+ PROPERTY STRINGS ${PNG_LOONGARCH_LSX_POSSIBLE_VALUES})
+ list(FIND PNG_LOONGARCH_LSX_POSSIBLE_VALUES ${PNG_LOONGARCH_LSX} index)
+ if(index EQUAL -1)
+ message(FATAL_ERROR "PNG_LOONGARCH_LSX must be one of [${PNG_LOONGARCH_LSX_POSSIBLE_VALUES}]")
+ elseif(NOT PNG_LOONGARCH_LSX STREQUAL "off")
+ check_c_compiler_flag("-mlsx" COMPILER_SUPPORTS_LSX)
+ if(COMPILER_SUPPORTS_LSX)
+ set(libpng_loongarch_sources
+ loongarch/loongarch_lsx_init.c
+ loongarch/filter_lsx_intrinsics.c)
+ set_source_files_properties(${libpng_loongarch_sources}
+ PROPERTIES COMPILE_FLAGS "-mlsx")
+ add_definitions(-DPNG_LOONGARCH_LSX_OPT=1)
+ else()
+ message(FATAL_ERROR "This compiler does not support the -mlsx option")
+ endif()
+ else()
+ add_definitions(-DPNG_LOONGARCH_LSX_OPT=0)
+ endif()
+ endif()
+
+ # Set definitions and sources for RISC-V.
+ if(PNG_TARGET_ARCHITECTURE MATCHES "^(riscv)")
+ include(CheckCCompilerFlag)
+ set(PNG_RISCV_RVV_POSSIBLE_VALUES on off)
+ set(PNG_RISCV_RVV "off"
+ CACHE STRING "Enable RISC-V Vector optimizations: on|off; off is default")
+ set_property(CACHE PNG_RISCV_RVV
+ PROPERTY STRINGS ${PNG_RISCV_RVV_POSSIBLE_VALUES})
+ list(FIND PNG_RISCV_RVV_POSSIBLE_VALUES ${PNG_RISCV_RVV} index)
+ if(index EQUAL -1)
+ message(FATAL_ERROR "PNG_RISCV_RVV must be one of [${PNG_RISCV_RVV_POSSIBLE_VALUES}]")
+ elseif(NOT PNG_RISCV_RVV STREQUAL "off")
+
+ check_c_source_compiles("
+ #include
+ int main() {
+ const float src[] = { 0.0f, 0.0f, 0.0f, 0.0f };
+ uint64_t ptr[2] = {0x0908060504020100, 0xFFFFFFFF0E0D0C0A};
+ vuint8m1_t a = __riscv_vreinterpret_v_u64m1_u8m1(__riscv_vle64_v_u64m1(ptr, 2));
+ vfloat32m1_t val = __riscv_vle32_v_f32m1((const float*)(src), 4);
+ return (int)__riscv_vfmv_f_s_f32m1_f32(val);
+ }" COMPILER_SUPPORTS_RVV)
+
+ if(NOT COMPILER_SUPPORTS_RVV)
+ message(FATAL_ERROR "Compiler does not support RISC-V Vector extension or its unable to detect it")
+ endif()
+ set(libpng_riscv_sources
+ riscv/filter_rvv_intrinsics.c
+ riscv/riscv_init.c)
+ if(PNG_RISCV_RVV STREQUAL "on")
+ add_definitions(-DPNG_RISCV_RVV_OPT=2)
+ else()
+ add_definitions(-DPNG_RISCV_RVV_OPT=0)
+ endif()
+ else()
+ add_definitions(-DPNG_RISCV_RVV_OPT=0)
endif()
- else()
- add_definitions(-DPNG_MIPS_MSA_OPT=0)
endif()
-endif()
else(PNG_HARDWARE_OPTIMIZATIONS)
-# set definitions and sources for arm
-if(CMAKE_SYSTEM_PROCESSOR MATCHES "^arm" OR
- CMAKE_SYSTEM_PROCESSOR MATCHES "^aarch64")
- add_definitions(-DPNG_ARM_NEON_OPT=0)
-endif()
+ # Set definitions and sources for ARM.
+ if(PNG_TARGET_ARCHITECTURE MATCHES "^(arm|aarch)")
+ add_definitions(-DPNG_ARM_NEON_OPT=0)
+ endif()
-# set definitions and sources for powerpc
-if(CMAKE_SYSTEM_PROCESSOR MATCHES "^powerpc*" OR
- CMAKE_SYSTEM_PROCESSOR MATCHES "^ppc64*")
- add_definitions(-DPNG_POWERPC_VSX_OPT=0)
-endif()
+ # Set definitions and sources for PowerPC.
+ if(PNG_TARGET_ARCHITECTURE MATCHES "^(powerpc|ppc64)")
+ add_definitions(-DPNG_POWERPC_VSX_OPT=0)
+ endif()
-# set definitions and sources for intel
-if(CMAKE_SYSTEM_PROCESSOR MATCHES "^i?86" OR
- CMAKE_SYSTEM_PROCESSOR MATCHES "^x86_64*")
- add_definitions(-DPNG_INTEL_SSE_OPT=0)
-endif()
+ # Set definitions and sources for Intel.
+ if(PNG_TARGET_ARCHITECTURE MATCHES "^(i[3-6]86|x86|amd64)")
+ add_definitions(-DPNG_INTEL_SSE_OPT=0)
+ endif()
-# set definitions and sources for MIPS
-if(CMAKE_SYSTEM_PROCESSOR MATCHES "mipsel*" OR
- CMAKE_SYSTEM_PROCESSOR MATCHES "mips64el*")
- add_definitions(-DPNG_MIPS_MSA_OPT=0)
-endif()
+ # Set definitions and sources for MIPS.
+ if(PNG_TARGET_ARCHITECTURE MATCHES "^(mipsel|mips64el)")
+ add_definitions(-DPNG_MIPS_MSA_OPT=0)
+ endif()
-endif(PNG_HARDWARE_OPTIMIZATIONS)
+ # Set definitions and sources for LoongArch.
+ if(PNG_TARGET_ARCHITECTURE MATCHES "^(loongarch)")
+ add_definitions(-DPNG_LOONGARCH_LSX_OPT=0)
+ endif()
-# SET LIBNAME
-set(PNG_LIB_NAME png${PNGLIB_MAJOR}${PNGLIB_MINOR})
+ # Set definitions and sources for RISC-V.
+ if(PNG_TARGET_ARCHITECTURE MATCHES "^(riscv)")
+ add_definitions(-DPNG_RISCV_RVV_OPT=0)
+ endif()
-# to distinguish between debug and release lib
-set(CMAKE_DEBUG_POSTFIX "d")
+endif(PNG_HARDWARE_OPTIMIZATIONS)
-include(CheckCSourceCompiles)
option(ld-version-script "Enable linker version script" ON)
-if(ld-version-script AND NOT APPLE)
+if(ld-version-script AND NOT (ANDROID OR APPLE))
# Check if LD supports linker scripts.
- file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/conftest.map" "VERS_1 {
- global: sym;
- local: *;
-};
-
-VERS_2 {
- global: sym2;
- main;
-} VERS_1;
+ file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/conftest.map" "
+VERS_1 { global: sym1; local: *; };
+VERS_2 { global: sym2; main; } VERS_1;
")
- set(CMAKE_REQUIRED_FLAGS_SAVE ${CMAKE_REQUIRED_FLAGS})
- set(CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS} "-Wl,--version-script='${CMAKE_CURRENT_BINARY_DIR}/conftest.map'")
- check_c_source_compiles("void sym(void) {}
+ set(_SAVED_CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS})
+ 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})
+ endif()
+ list(APPEND CMAKE_REQUIRED_FLAGS
+ "-Wl,--version-script='${CMAKE_CURRENT_BINARY_DIR}/conftest.map'")
+ check_c_source_compiles("
+void sym1(void) {}
void sym2(void) {}
-int main(void) {return 0;}
+int main(void) { return 0; }
" HAVE_LD_VERSION_SCRIPT)
if(NOT HAVE_LD_VERSION_SCRIPT)
- set(CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS_SAVE} "-Wl,-M -Wl,${CMAKE_CURRENT_BINARY_DIR}/conftest.map")
- check_c_source_compiles("void sym(void) {}
+ set(CMAKE_REQUIRED_FLAGS ${_SAVED_CMAKE_REQUIRED_FLAGS})
+ 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})
+ endif()
+ list(APPEND CMAKE_REQUIRED_FLAGS "-Wl,-M -Wl,${CMAKE_CURRENT_BINARY_DIR}/conftest.map")
+ check_c_source_compiles("
+void sym1(void) {}
void sym2(void) {}
-int main(void) {return 0;}
+int main(void) { return 0; }
" HAVE_SOLARIS_LD_VERSION_SCRIPT)
endif()
- set(CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS_SAVE})
+ set(CMAKE_REQUIRED_FLAGS ${_SAVED_CMAKE_REQUIRED_FLAGS})
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(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")
+if(PNG_LIBCONF_HEADER STREQUAL "")
+ # No custom configuration header file has been specified, so we build it
+ # from our DFA files and (optionally) out of the user-supplied DFA file.
+ # Find an AWK language processor.
+ # Start with specific AWK implementations like gawk and nawk, which are
+ # known to work with our scripts, then fall back to the system awk.
+ find_program(AWK NAMES gawk nawk awk)
+ if(AWK)
+ message(STATUS "Found AWK program: ${AWK}")
+ else()
+ message(STATUS "Could not find an AWK-compatible program")
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)
- symbol_prefix()
endif()
-find_program(AWK NAMES gawk awk)
-
-include_directories(${CMAKE_CURRENT_BINARY_DIR})
-
-if(NOT AWK OR ANDROID)
- # No awk available to generate sources; use pre-built pnglibconf.h
- configure_file(${CMAKE_CURRENT_SOURCE_DIR}/scripts/pnglibconf.h.prebuilt
- ${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.h)
- add_custom_target(genfiles) # Dummy
+# Include the internal module PNGCheckLibconf.cmake
+include("${CMAKE_CURRENT_SOURCE_DIR}/scripts/cmake/PNGCheckLibconf.cmake")
+
+if(NOT PNG_LIBCONF_HEADER STREQUAL "")
+ # Configure libpng with the user-defined pnglibconf.h file.
+ png_check_libconf(HEADER "${PNG_LIBCONF_HEADER}")
+ configure_file("${PNG_LIBCONF_HEADER}"
+ "${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.h"
+ @ONLY)
+ add_custom_target(png_genfiles)
+elseif(NOT AWK)
+ # No AWK program available to generate pnglibconf.h.
+ # Configure libpng with pnglibconf.h.prebuilt.
+ png_check_libconf(HEADER "${PNG_LIBCONF_HEADER_PREBUILT}")
+ configure_file("${PNG_LIBCONF_HEADER_PREBUILT}"
+ "${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.h"
+ @ONLY)
+ add_custom_target(png_genfiles)
else()
- include(CMakeParseArguments)
- # Generate .chk from .out with awk
- # generate_chk(INPUT inputfile OUTPUT outputfile [DEPENDS dep1 [dep2...]])
- function(generate_chk)
- set(options)
- set(oneValueArgs INPUT OUTPUT)
- set(multiValueArgs DEPENDS)
- cmake_parse_arguments(_GC "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
- if(NOT _GC_INPUT)
- message(FATAL_ERROR "generate_chk: Missing INPUT argument")
- endif()
- if(NOT _GC_OUTPUT)
- message(FATAL_ERROR "generate_chk: Missing OUTPUT argument")
- endif()
-
- add_custom_command(OUTPUT "${_GC_OUTPUT}"
- COMMAND "${CMAKE_COMMAND}"
- "-DINPUT=${_GC_INPUT}"
- "-DOUTPUT=${_GC_OUTPUT}"
- -P "${CMAKE_CURRENT_BINARY_DIR}/scripts/genchk.cmake"
- DEPENDS "${_GC_INPUT}" ${_GC_DEPENDS}
- WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}")
- endfunction()
-
- # Generate .out from .c with awk
- # generate_out(INPUT inputfile OUTPUT outputfile [DEPENDS dep1 [dep2...]])
- function(generate_out)
- set(options)
- set(oneValueArgs INPUT OUTPUT)
- set(multiValueArgs DEPENDS)
- cmake_parse_arguments(_GO "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
- if(NOT _GO_INPUT)
- message(FATAL_ERROR "generate_out: Missing INPUT argument")
- endif()
- if(NOT _GO_OUTPUT)
- message(FATAL_ERROR "generate_out: Missing OUTPUT argument")
- endif()
-
- add_custom_command(OUTPUT "${_GO_OUTPUT}"
- COMMAND "${CMAKE_COMMAND}"
- "-DINPUT=${_GO_INPUT}"
- "-DOUTPUT=${_GO_OUTPUT}"
- -P "${CMAKE_CURRENT_BINARY_DIR}/scripts/genout.cmake"
- DEPENDS "${_GO_INPUT}" ${_GO_DEPENDS}
- WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}")
- endfunction()
-
- # Generate specific source file with awk
- # generate_source(OUTPUT outputfile [DEPENDS dep1 [dep2...]])
- function(generate_source)
- set(options)
- set(oneValueArgs OUTPUT)
- set(multiValueArgs DEPENDS)
- cmake_parse_arguments(_GSO "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
- if(NOT _GSO_OUTPUT)
- message(FATAL_ERROR "generate_source: Missing OUTPUT argument")
- endif()
-
- add_custom_command(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${_GSO_OUTPUT}"
- COMMAND "${CMAKE_COMMAND}"
- "-DOUTPUT=${_GSO_OUTPUT}"
- -P "${CMAKE_CURRENT_BINARY_DIR}/scripts/gensrc.cmake"
- DEPENDS ${_GSO_DEPENDS}
- WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}")
- endfunction()
-
- # Copy file
- function(generate_copy source destination)
- add_custom_command(OUTPUT "${destination}"
- COMMAND "${CMAKE_COMMAND}" -E remove "${destination}"
- COMMAND "${CMAKE_COMMAND}" -E copy "${source}"
- "${destination}"
- DEPENDS "${source}")
- endfunction()
+ png_check_libconf(DFA_XTRA "${DFA_XTRA}")
+
+ # Include the internal module PNGGenConfig.cmake
+ include("${CMAKE_CURRENT_SOURCE_DIR}/scripts/cmake/PNGGenConfig.cmake")
+
+ # Work around a limitation of various Windows AWK programs that are
+ # unable to process CRLF-terminated AWK scripts.
+ # Copy these AWK scripts to a temporary location, converting their
+ # line endings from Windows (CRLF) to Unix (LF) at the destination.
+ configure_file("${CMAKE_CURRENT_SOURCE_DIR}/scripts/checksym.awk"
+ "${CMAKE_CURRENT_BINARY_DIR}/scripts/checksym.awk"
+ @ONLY
+ NEWLINE_STYLE LF)
+ configure_file("${CMAKE_CURRENT_SOURCE_DIR}/scripts/options.awk"
+ "${CMAKE_CURRENT_BINARY_DIR}/scripts/options.awk"
+ @ONLY
+ NEWLINE_STYLE LF)
+ configure_file("${CMAKE_CURRENT_SOURCE_DIR}/scripts/dfn.awk"
+ "${CMAKE_CURRENT_BINARY_DIR}/scripts/dfn.awk"
+ @ONLY
+ NEWLINE_STYLE LF)
# Generate scripts/pnglibconf.h
- generate_source(OUTPUT "scripts/pnglibconf.c"
+ generate_source(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/scripts/pnglibconf.c"
DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/scripts/pnglibconf.dfa"
- "${CMAKE_CURRENT_SOURCE_DIR}/scripts/options.awk"
+ "${CMAKE_CURRENT_BINARY_DIR}/scripts/options.awk"
"${CMAKE_CURRENT_SOURCE_DIR}/pngconf.h")
# Generate pnglibconf.c
- generate_source(OUTPUT "pnglibconf.c"
+ generate_source(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.c"
DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/scripts/pnglibconf.dfa"
- "${CMAKE_CURRENT_SOURCE_DIR}/scripts/options.awk"
+ "${CMAKE_CURRENT_BINARY_DIR}/scripts/options.awk"
"${CMAKE_CURRENT_SOURCE_DIR}/pngconf.h")
if(PNG_PREFIX)
@@ -377,7 +506,7 @@ else()
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.out")
# Generate pnglibconf.h
- generate_source(OUTPUT "pnglibconf.h"
+ generate_source(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.h"
DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.out"
${PNGLIBCONF_H_EXTRA_DEPENDS})
@@ -392,7 +521,7 @@ else()
"${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.out")
# Generate pngprefix.h
- generate_source(OUTPUT "pngprefix.h"
+ generate_source(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/pngprefix.h"
DEPENDS ${PNGPREFIX_H_EXTRA_DEPENDS})
generate_out(INPUT "${CMAKE_CURRENT_SOURCE_DIR}/scripts/sym.c"
@@ -413,305 +542,334 @@ else()
generate_chk(INPUT "${CMAKE_CURRENT_BINARY_DIR}/scripts/symbols.out"
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/scripts/symbols.chk"
- DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/scripts/checksym.awk"
+ DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/scripts/checksym.awk"
"${CMAKE_CURRENT_SOURCE_DIR}/scripts/symbols.def")
- add_custom_target(symbol-check DEPENDS
- "${CMAKE_CURRENT_BINARY_DIR}/scripts/symbols.chk")
+ generate_copy(INPUT "${CMAKE_CURRENT_BINARY_DIR}/scripts/sym.out"
+ OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/libpng.sym")
- generate_copy("${CMAKE_CURRENT_BINARY_DIR}/scripts/sym.out"
- "${CMAKE_CURRENT_BINARY_DIR}/libpng.sym")
- generate_copy("${CMAKE_CURRENT_BINARY_DIR}/scripts/vers.out"
- "${CMAKE_CURRENT_BINARY_DIR}/libpng.vers")
+ generate_copy(INPUT "${CMAKE_CURRENT_BINARY_DIR}/scripts/vers.out"
+ OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/libpng.vers")
- add_custom_target(genvers DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/libpng.vers")
- add_custom_target(gensym DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/libpng.sym")
-
- add_custom_target("genprebuilt"
+ 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}/scripts/cmake/gensrc.cmake"
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}")
- # A single target handles generation of all generated files. If
- # they are depended upon separately by multiple targets, this
- # confuses parallel make (it would require a separate top-level
- # target for each file to track the dependencies properly).
- add_custom_target(genfiles DEPENDS
- "${CMAKE_CURRENT_BINARY_DIR}/libpng.sym"
- "${CMAKE_CURRENT_BINARY_DIR}/libpng.vers"
- "${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.c"
- "${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.h"
- "${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.out"
- "${CMAKE_CURRENT_BINARY_DIR}/pngprefix.h"
- "${CMAKE_CURRENT_BINARY_DIR}/scripts/intprefix.out"
- "${CMAKE_CURRENT_BINARY_DIR}/scripts/pnglibconf.c"
- "${CMAKE_CURRENT_BINARY_DIR}/scripts/prefix.out"
- "${CMAKE_CURRENT_BINARY_DIR}/scripts/sym.out"
- "${CMAKE_CURRENT_BINARY_DIR}/scripts/symbols.chk"
- "${CMAKE_CURRENT_BINARY_DIR}/scripts/symbols.out"
- "${CMAKE_CURRENT_BINARY_DIR}/scripts/vers.out")
-endif(NOT AWK OR ANDROID)
-
-# OUR SOURCES
+ # A single target handles generation of all generated files.
+ add_custom_target(png_genfiles
+ DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/libpng.sym"
+ "${CMAKE_CURRENT_BINARY_DIR}/libpng.vers"
+ "${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.c"
+ "${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.h"
+ "${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.out"
+ "${CMAKE_CURRENT_BINARY_DIR}/pngprefix.h"
+ "${CMAKE_CURRENT_BINARY_DIR}/scripts/intprefix.out"
+ "${CMAKE_CURRENT_BINARY_DIR}/scripts/pnglibconf.c"
+ "${CMAKE_CURRENT_BINARY_DIR}/scripts/prefix.out"
+ "${CMAKE_CURRENT_BINARY_DIR}/scripts/sym.out"
+ "${CMAKE_CURRENT_BINARY_DIR}/scripts/symbols.chk"
+ "${CMAKE_CURRENT_BINARY_DIR}/scripts/symbols.out"
+ "${CMAKE_CURRENT_BINARY_DIR}/scripts/vers.out")
+endif()
+
+# List the source code files.
set(libpng_public_hdrs
- png.h
- pngconf.h
- "${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.h"
+ png.h
+ pngconf.h
+ "${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.h"
)
set(libpng_private_hdrs
- pngpriv.h
- pngdebug.h
- pnginfo.h
- pngstruct.h
+ pngpriv.h
+ pngdebug.h
+ pnginfo.h
+ pngstruct.h
)
-if(AWK AND NOT ANDROID)
+if(AWK)
list(APPEND libpng_private_hdrs "${CMAKE_CURRENT_BINARY_DIR}/pngprefix.h")
endif()
set(libpng_sources
- ${libpng_public_hdrs}
- ${libpng_private_hdrs}
- png.c
- pngerror.c
- pngget.c
- pngmem.c
- pngpread.c
- pngread.c
- pngrio.c
- pngrtran.c
- pngrutil.c
- pngset.c
- pngtrans.c
- pngwio.c
- pngwrite.c
- pngwtran.c
- pngwutil.c
- ${libpng_arm_sources}
- ${libpng_intel_sources}
- ${libpng_mips_sources}
- ${libpng_powerpc_sources}
+ ${libpng_public_hdrs}
+ ${libpng_private_hdrs}
+ png.c
+ pngerror.c
+ pngget.c
+ pngmem.c
+ pngpread.c
+ pngread.c
+ pngrio.c
+ pngrtran.c
+ pngrutil.c
+ pngset.c
+ pngtrans.c
+ pngwio.c
+ pngwrite.c
+ pngwtran.c
+ pngwutil.c
+ ${libpng_arm_sources}
+ ${libpng_intel_sources}
+ ${libpng_mips_sources}
+ ${libpng_powerpc_sources}
+ ${libpng_loongarch_sources}
+ ${libpng_riscv_sources}
)
+
set(pngtest_sources
- pngtest.c
+ pngtest.c
)
set(pngvalid_sources
- contrib/libtests/pngvalid.c
+ contrib/libtests/pngvalid.c
)
set(pngstest_sources
- contrib/libtests/pngstest.c
+ contrib/libtests/pngstest.c
)
set(pngunknown_sources
- contrib/libtests/pngunknown.c
+ contrib/libtests/pngunknown.c
)
set(pngimage_sources
- contrib/libtests/pngimage.c
+ contrib/libtests/pngimage.c
)
set(pngfix_sources
- contrib/tools/pngfix.c
+ contrib/tools/pngfix.c
)
set(png_fix_itxt_sources
- contrib/tools/png-fix-itxt.c
+ contrib/tools/png-fix-itxt.c
)
-if(MSVC)
- add_definitions(-D_CRT_SECURE_NO_DEPRECATE)
-endif()
+# Now build our targets.
-if(PNG_DEBUG)
- add_definitions(-DPNG_DEBUG)
-endif()
+# Initialize the list of libpng library targets.
+set(PNG_LIBRARY_TARGETS "")
-# NOW BUILD OUR TARGET
-include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${ZLIB_INCLUDE_DIR})
-
-unset(PNG_LIB_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 ""))
+ # 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.
+ set(PNG_SHARED_OUTPUT_NAME "png${PNGLIB_ABI_VERSION}")
+ set(PNG_STATIC_OUTPUT_NAME "png${PNGLIB_ABI_VERSION}")
+else()
+ # We are, most likely, on a Windows toolchain like MSVC, Clang on Windows,
+ # Borland/Embarcadero, etc. We need to specify the "libpng" name explicitly.
+ # We also need to use a custom suffix, in order to distinguish between the
+ # shared import library name and the static library name.
+ set(PNG_SHARED_OUTPUT_NAME "libpng${PNGLIB_ABI_VERSION}")
+ set(PNG_STATIC_OUTPUT_NAME "libpng${PNGLIB_ABI_VERSION}_static")
+endif()
if(PNG_SHARED)
- add_library(png SHARED ${libpng_sources})
- set(PNG_LIB_TARGETS png)
- set_target_properties(png PROPERTIES OUTPUT_NAME ${PNG_LIB_NAME})
- add_dependencies(png genfiles)
- if(MSVC)
- # msvc does not append 'lib' - do it here to have consistent name
- set_target_properties(png PROPERTIES PREFIX "lib")
- set_target_properties(png PROPERTIES IMPORT_PREFIX "lib")
- endif()
- target_link_libraries(png ${ZLIB_LIBRARY} ${M_LIBRARY})
-
+ add_library(png_shared SHARED ${libpng_sources})
+ add_dependencies(png_shared png_genfiles)
+ list(APPEND PNG_LIBRARY_TARGETS png_shared)
+ set_target_properties(png_shared
+ PROPERTIES OUTPUT_NAME "${PNG_SHARED_OUTPUT_NAME}"
+ DEBUG_POSTFIX "${PNG_DEBUG_POSTFIX}"
+ VERSION "${PNGLIB_SHARED_VERSION}"
+ SOVERSION "${PNGLIB_ABI_VERSION}")
if(UNIX AND AWK)
if(HAVE_LD_VERSION_SCRIPT)
- set_target_properties(png PROPERTIES LINK_FLAGS
- "-Wl,--version-script='${CMAKE_CURRENT_BINARY_DIR}/libpng.vers'")
+ set_target_properties(png_shared
+ PROPERTIES LINK_FLAGS "-Wl,--version-script='${CMAKE_CURRENT_BINARY_DIR}/libpng.vers'")
elseif(HAVE_SOLARIS_LD_VERSION_SCRIPT)
- set_target_properties(png PROPERTIES LINK_FLAGS
- "-Wl,-M -Wl,'${CMAKE_CURRENT_BINARY_DIR}/libpng.vers'")
+ set_target_properties(png_shared
+ PROPERTIES LINK_FLAGS "-Wl,-M -Wl,'${CMAKE_CURRENT_BINARY_DIR}/libpng.vers'")
endif()
endif()
+ 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_include_directories(png_shared
+ PUBLIC "$")
+ target_include_directories(png_shared
+ PUBLIC "$")
+ target_include_directories(png_shared
+ SYSTEM
+ INTERFACE "$")
+ target_link_libraries(png_shared
+ PUBLIC ${PNG_LINK_LIBRARIES})
endif()
if(PNG_STATIC)
- # does not work without changing name
- set(PNG_LIB_NAME_STATIC png_static)
add_library(png_static STATIC ${libpng_sources})
- add_dependencies(png_static genfiles)
- # MSVC doesn't use a different file extension for shared vs. static
- # libs. We are able to change OUTPUT_NAME to remove the _static
- # for all other platforms.
- if(NOT MSVC)
- set_target_properties(png_static PROPERTIES
- OUTPUT_NAME "${PNG_LIB_NAME}"
- CLEAN_DIRECT_OUTPUT 1)
- else()
- set_target_properties(png_static PROPERTIES
- OUTPUT_NAME "${PNG_LIB_NAME}_static"
- CLEAN_DIRECT_OUTPUT 1)
- endif()
- list(APPEND PNG_LIB_TARGETS png_static)
- if(MSVC)
- # msvc does not append 'lib' - do it here to have consistent name
- set_target_properties(png_static PROPERTIES PREFIX "lib")
- endif()
- target_link_libraries(png_static ${ZLIB_LIBRARY} ${M_LIBRARY})
+ add_dependencies(png_static png_genfiles)
+ list(APPEND PNG_LIBRARY_TARGETS png_static)
+ set_target_properties(png_static
+ PROPERTIES OUTPUT_NAME "${PNG_STATIC_OUTPUT_NAME}"
+ DEBUG_POSTFIX "${PNG_DEBUG_POSTFIX}")
+ target_include_directories(png_static
+ PUBLIC "$")
+ target_include_directories(png_static
+ PUBLIC "$")
+ target_include_directories(png_static
+ SYSTEM
+ INTERFACE "$")
+ target_link_libraries(png_static
+ PUBLIC ${PNG_LINK_LIBRARIES})
+endif()
+
+if(PNG_FRAMEWORK AND NOT APPLE)
+ message(AUTHOR_WARNING "Setting PNG_FRAMEWORK to OFF, as it only applies to Apple systems")
+ set(PNG_FRAMEWORK OFF)
endif()
if(PNG_FRAMEWORK)
- set(PNG_LIB_NAME_FRAMEWORK png_framework)
add_library(png_framework SHARED ${libpng_sources})
- add_dependencies(png_framework genfiles)
- list(APPEND PNG_LIB_TARGETS png_framework)
- set_target_properties(png_framework PROPERTIES
- FRAMEWORK TRUE
- FRAMEWORK_VERSION ${PNGLIB_VERSION}
- MACOSX_FRAMEWORK_SHORT_VERSION_STRING ${PNGLIB_MAJOR}.${PNGLIB_MINOR}
- MACOSX_FRAMEWORK_BUNDLE_VERSION ${PNGLIB_VERSION}
- 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_LIBRARY} ${M_LIBRARY})
-endif()
-
-if(NOT PNG_LIB_TARGETS)
- message(SEND_ERROR
- "No library variant selected to build. "
- "Please enable at least one of the following options: "
- "PNG_STATIC, PNG_SHARED, PNG_FRAMEWORK")
-endif()
-
-if(PNG_SHARED AND WIN32)
- set_target_properties(png PROPERTIES DEFINE_SYMBOL PNG_BUILD_DLL)
-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()
-
- set(TEST_OPTIONS "${_PAT_OPTIONS}")
- set(TEST_FILES "${_PAT_FILES}")
+ add_dependencies(png_framework png_genfiles)
+ list(APPEND PNG_LIBRARY_TARGETS png_framework)
+ set_target_properties(png_framework
+ PROPERTIES FRAMEWORK TRUE
+ FRAMEWORK_VERSION "${PNGLIB_VERSION}"
+ MACOSX_FRAMEWORK_SHORT_VERSION_STRING "${PNGLIB_MAJOR}.${PNGLIB_MINOR}"
+ MACOSX_FRAMEWORK_BUNDLE_VERSION "${PNGLIB_VERSION}"
+ MACOSX_FRAMEWORK_IDENTIFIER "org.libpng.libpng"
+ XCODE_ATTRIBUTE_INSTALL_PATH "@rpath"
+ PUBLIC_HEADER "${libpng_public_hdrs}"
+ 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 "$")
+ target_include_directories(png_framework
+ PUBLIC "$")
+ target_include_directories(png_framework
+ SYSTEM
+ INTERFACE "$")
+ target_link_libraries(png_framework
+ PUBLIC ${PNG_LINK_LIBRARIES})
+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=$"
- "-DTEST_COMMAND=$"
- -P "${CMAKE_CURRENT_BINARY_DIR}/tests/${_PAT_NAME}.cmake")
-endfunction()
+if(NOT PNG_LIBRARY_TARGETS)
+ message(SEND_ERROR "No library variant selected to build. "
+ "Please enable at least one of the following options: "
+ "PNG_SHARED, PNG_STATIC, PNG_FRAMEWORK")
+endif()
if(PNG_TESTS AND PNG_SHARED)
+ enable_testing()
+
+ # Include the internal module PNGTest.cmake
+ include("${CMAKE_CURRENT_SOURCE_DIR}/scripts/cmake/PNGTest.cmake")
+
# 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")
list(SORT PNGSUITE_PNGS)
file(GLOB TEST_PNGS "${CMAKE_CURRENT_SOURCE_DIR}/contrib/testpngs/*.png")
list(SORT TEST_PNGS)
+ file(GLOB TEST_PNG3_PNGS "${CMAKE_CURRENT_SOURCE_DIR}/contrib/testpngs/png-3/*.png")
+ list(SORT TEST_PNG3_PNGS)
set(PNGTEST_PNG "${CMAKE_CURRENT_SOURCE_DIR}/pngtest.png")
add_executable(pngtest ${pngtest_sources})
- target_link_libraries(pngtest png)
+ target_link_libraries(pngtest
+ PRIVATE png_shared)
+
+ png_add_test(NAME pngtest
+ COMMAND pngtest
+ FILES "${PNGTEST_PNG}")
- png_add_test(NAME pngtest COMMAND pngtest FILES "${PNGTEST_PNG}")
+ png_add_test(NAME pngtest-png-3
+ COMMAND pngtest
+ FILES "${TEST_PNG3_PNGS}")
add_executable(pngvalid ${pngvalid_sources})
- target_link_libraries(pngvalid png)
+ target_link_libraries(pngvalid
+ PRIVATE png_shared)
png_add_test(NAME pngvalid-gamma-16-to-8
- COMMAND pngvalid OPTIONS --gamma-16-to-8)
+ COMMAND pngvalid
+ OPTIONS --gamma-16-to-8)
png_add_test(NAME pngvalid-gamma-alpha-mode
- COMMAND pngvalid OPTIONS --gamma-alpha-mode)
+ COMMAND pngvalid
+ OPTIONS --gamma-alpha-mode)
png_add_test(NAME pngvalid-gamma-background
- COMMAND pngvalid OPTIONS --gamma-background)
+ COMMAND pngvalid
+ OPTIONS --gamma-background)
png_add_test(NAME pngvalid-gamma-expand16-alpha-mode
- COMMAND pngvalid OPTIONS --gamma-alpha-mode --expand16)
+ COMMAND pngvalid
+ OPTIONS --gamma-alpha-mode --expand16)
png_add_test(NAME pngvalid-gamma-expand16-background
- COMMAND pngvalid OPTIONS --gamma-background --expand16)
+ COMMAND pngvalid
+ OPTIONS --gamma-background --expand16)
png_add_test(NAME pngvalid-gamma-expand16-transform
- COMMAND pngvalid OPTIONS --gamma-transform --expand16)
+ COMMAND pngvalid
+ OPTIONS --gamma-transform --expand16)
png_add_test(NAME pngvalid-gamma-sbit
- COMMAND pngvalid OPTIONS --gamma-sbit)
+ COMMAND pngvalid
+ OPTIONS --gamma-sbit)
png_add_test(NAME pngvalid-gamma-threshold
- COMMAND pngvalid OPTIONS --gamma-threshold)
+ COMMAND pngvalid
+ OPTIONS --gamma-threshold)
png_add_test(NAME pngvalid-gamma-transform
- COMMAND pngvalid OPTIONS --gamma-transform)
+ COMMAND pngvalid
+ OPTIONS --gamma-transform)
png_add_test(NAME pngvalid-progressive-interlace-standard
- COMMAND pngvalid OPTIONS --standard --progressive-read --interlace)
+ COMMAND pngvalid
+ OPTIONS --standard --progressive-read --interlace)
png_add_test(NAME pngvalid-progressive-size
- COMMAND pngvalid OPTIONS --size --progressive-read)
+ COMMAND pngvalid
+ OPTIONS --size --progressive-read)
png_add_test(NAME pngvalid-progressive-standard
- COMMAND pngvalid OPTIONS --standard --progressive-read)
+ COMMAND pngvalid
+ OPTIONS --standard --progressive-read)
png_add_test(NAME pngvalid-standard
- COMMAND pngvalid OPTIONS --standard)
+ COMMAND pngvalid
+ OPTIONS --standard)
png_add_test(NAME pngvalid-transform
- COMMAND pngvalid OPTIONS --transform)
+ COMMAND pngvalid
+ OPTIONS --transform)
add_executable(pngstest ${pngstest_sources})
- target_link_libraries(pngstest png)
+ 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()
@@ -729,203 +887,263 @@ if(PNG_TESTS AND PNG_SHARED)
endforeach()
endforeach()
- add_executable(pngunknown ${pngunknown_sources})
- target_link_libraries(pngunknown png)
+ # Regression test:
+ # Use stride_extra > 32767 to trigger row_bytes > 65535 for linear images.
+ png_add_test(NAME pngstest-large-stride
+ COMMAND pngstest
+ OPTIONS --stride-extra 33000 --tmpfile "large-stride-" --log
+ FILES "${CMAKE_CURRENT_SOURCE_DIR}/contrib/testpngs/rgb-alpha-16-linear.png")
- png_add_test(NAME pngunknown-discard COMMAND pngunknown OPTIONS --strict default=discard FILES "${PNGTEST_PNG}")
- png_add_test(NAME pngunknown-IDAT COMMAND pngunknown OPTIONS --strict default=discard IDAT=save FILES "${PNGTEST_PNG}")
- png_add_test(NAME pngunknown-if-safe COMMAND pngunknown OPTIONS --strict default=if-safe FILES "${PNGTEST_PNG}")
- png_add_test(NAME pngunknown-sAPI COMMAND pngunknown OPTIONS --strict bKGD=save cHRM=save gAMA=save all=discard iCCP=save sBIT=save sRGB=save FILES "${PNGTEST_PNG}")
- png_add_test(NAME pngunknown-save COMMAND pngunknown OPTIONS --strict default=save FILES "${PNGTEST_PNG}")
- png_add_test(NAME pngunknown-sTER COMMAND pngunknown OPTIONS --strict sTER=if-safe FILES "${PNGTEST_PNG}")
- png_add_test(NAME pngunknown-vpAg COMMAND pngunknown OPTIONS --strict vpAg=if-safe FILES "${PNGTEST_PNG}")
+ add_executable(pngunknown ${pngunknown_sources})
+ target_link_libraries(pngunknown
+ PRIVATE png_shared)
+
+ png_add_test(NAME pngunknown-discard
+ COMMAND pngunknown
+ OPTIONS --strict default=discard
+ FILES "${PNGTEST_PNG}")
+ png_add_test(NAME pngunknown-IDAT
+ COMMAND pngunknown
+ OPTIONS --strict default=discard IDAT=save
+ FILES "${PNGTEST_PNG}")
+ png_add_test(NAME pngunknown-if-safe
+ COMMAND pngunknown
+ OPTIONS --strict default=if-safe
+ FILES "${PNGTEST_PNG}")
+ png_add_test(NAME pngunknown-sAPI
+ COMMAND pngunknown
+ OPTIONS --strict
+ bKGD=save cHRM=save gAMA=save all=discard iCCP=save sBIT=save sRGB=save
+ FILES "${PNGTEST_PNG}")
+ png_add_test(NAME pngunknown-save
+ COMMAND pngunknown
+ OPTIONS --strict default=save
+ FILES "${PNGTEST_PNG}")
+ png_add_test(NAME pngunknown-sTER
+ COMMAND pngunknown
+ OPTIONS --strict sTER=if-safe
+ FILES "${PNGTEST_PNG}")
+ png_add_test(NAME pngunknown-vpAg
+ COMMAND pngunknown
+ OPTIONS --strict vpAg=if-safe
+ FILES "${PNGTEST_PNG}")
add_executable(pngimage ${pngimage_sources})
- target_link_libraries(pngimage png)
-
- png_add_test(NAME pngimage-quick COMMAND pngimage OPTIONS --list-combos --log FILES ${PNGSUITE_PNGS})
- png_add_test(NAME pngimage-full COMMAND pngimage OPTIONS --exhaustive --list-combos --log FILES ${PNGSUITE_PNGS})
+ target_link_libraries(pngimage
+ PRIVATE png_shared)
+
+ png_add_test(NAME pngimage-quick
+ COMMAND pngimage
+ OPTIONS --list-combos --log
+ FILES ${PNGSUITE_PNGS})
+ png_add_test(NAME pngimage-full
+ COMMAND pngimage
+ OPTIONS --exhaustive --list-combos --log
+ FILES ${PNGSUITE_PNGS})
endif()
-if(PNG_SHARED)
+if(PNG_SHARED AND PNG_TOOLS)
add_executable(pngfix ${pngfix_sources})
- target_link_libraries(pngfix png)
+ 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_LIBRARY} ${M_LIBRARY})
+ target_link_libraries(png-fix-itxt
+ PRIVATE ${PNG_LINK_LIBRARIES})
list(APPEND PNG_BIN_TARGETS png-fix-itxt)
endif()
-# Set a variable with CMake code which:
-# Creates a symlink from src to dest (if possible) or alternatively
-# copies if different.
-include(CMakeParseArguments)
-
+# Create a symlink that points to a target file (if symlinking is possible),
+# or make a copy of the target file (if symlinking is not possible):
+# create_symlink( [FILE | TARGET ])
function(create_symlink DEST_FILE)
-
- cmake_parse_arguments(S "" "FILE;TARGET" "" ${ARGN})
-
- if(NOT S_TARGET AND NOT S_FILE)
- message(FATAL_ERROR "create_symlink: Missing TARGET or FILE argument")
+ # TODO:
+ # Replace this implementation with CMake's built-in create_symlink function,
+ # which has been fully functional on all platforms, including Windows, since
+ # CMake version 3.13.
+ cmake_parse_arguments(_SYM "" "FILE;TARGET" "" ${ARGN})
+ if(NOT _SYM_FILE AND NOT _SYM_TARGET)
+ message(FATAL_ERROR "create_symlink: Missing arguments: FILE or TARGET")
endif()
-
- if(S_TARGET AND S_FILE)
- message(FATAL_ERROR "create_symlink: Both source file ${S_FILE} and build target ${S_TARGET} arguments are present; can only have one.")
+ if(_SYM_FILE AND _SYM_TARGET)
+ message(FATAL_ERROR "create_symlink: Mutually-exlusive arguments:"
+ "FILE (${_SYM_FILE}) and TARGET (${_SYM_TARGET})")
endif()
- if(S_FILE)
+ if(_SYM_FILE)
# If we don't need to symlink something that's coming from a build target,
# we can go ahead and symlink/copy at configure time.
if(CMAKE_HOST_WIN32 AND NOT CYGWIN)
- execute_process(
- COMMAND "${CMAKE_COMMAND}" -E copy_if_different ${S_FILE} ${DEST_FILE}
- WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}")
+ execute_process(COMMAND "${CMAKE_COMMAND}"
+ -E copy_if_different
+ "${_SYM_FILE}"
+ "${DEST_FILE}"
+ WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}")
else()
- execute_process(
- COMMAND ${CMAKE_COMMAND} -E create_symlink ${S_FILE} ${DEST_FILE}
- WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}")
+ execute_process(COMMAND "${CMAKE_COMMAND}"
+ -E create_symlink
+ "${_SYM_FILE}"
+ "${DEST_FILE}"
+ WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}")
endif()
endif()
- if(S_TARGET)
- # We need to use generator expressions, which can be a bit tricky, so for
- # simplicity make the symlink a POST_BUILD step and use the TARGET
+ if(_SYM_TARGET)
+ # We need to use generator expressions, which can be a bit tricky.
+ # For simplicity, make the symlink a POST_BUILD step, and use the TARGET
# signature of add_custom_command.
if(CMAKE_HOST_WIN32 AND NOT CYGWIN)
- add_custom_command(TARGET ${S_TARGET} POST_BUILD
- COMMAND "${CMAKE_COMMAND}" -E copy_if_different $ $/${DEST_FILE})
+ add_custom_command(TARGET ${_SYM_TARGET}
+ POST_BUILD
+ COMMAND "${CMAKE_COMMAND}"
+ -E copy_if_different
+ "$/$"
+ "$/${DEST_FILE}")
else()
- add_custom_command(TARGET ${S_TARGET} POST_BUILD
- COMMAND "${CMAKE_COMMAND}" -E create_symlink $ $/${DEST_FILE})
+ add_custom_command(TARGET ${_SYM_TARGET}
+ POST_BUILD
+ COMMAND "${CMAKE_COMMAND}"
+ -E create_symlink
+ "$"
+ "$/${DEST_FILE}")
endif()
endif()
-
endfunction()
# Create source generation scripts.
-configure_file(${CMAKE_CURRENT_SOURCE_DIR}/scripts/genchk.cmake.in
- ${CMAKE_CURRENT_BINARY_DIR}/scripts/genchk.cmake @ONLY)
-configure_file(${CMAKE_CURRENT_SOURCE_DIR}/scripts/genout.cmake.in
- ${CMAKE_CURRENT_BINARY_DIR}/scripts/genout.cmake @ONLY)
-configure_file(${CMAKE_CURRENT_SOURCE_DIR}/scripts/gensrc.cmake.in
- ${CMAKE_CURRENT_BINARY_DIR}/scripts/gensrc.cmake @ONLY)
+configure_file("${CMAKE_CURRENT_SOURCE_DIR}/scripts/cmake/genchk.cmake.in"
+ "${CMAKE_CURRENT_BINARY_DIR}/scripts/cmake/genchk.cmake"
+ @ONLY)
+configure_file("${CMAKE_CURRENT_SOURCE_DIR}/scripts/cmake/genout.cmake.in"
+ "${CMAKE_CURRENT_BINARY_DIR}/scripts/cmake/genout.cmake"
+ @ONLY)
+configure_file("${CMAKE_CURRENT_SOURCE_DIR}/scripts/cmake/gensrc.cmake.in"
+ "${CMAKE_CURRENT_BINARY_DIR}/scripts/cmake/gensrc.cmake"
+ @ONLY)
# libpng is a library so default to 'lib'
if(NOT DEFINED CMAKE_INSTALL_LIBDIR)
set(CMAKE_INSTALL_LIBDIR lib)
endif()
-# CREATE PKGCONFIG FILES
+# Create pkgconfig files.
# We use the same files like ./configure, so we have to set its vars.
-# Only do this on Windows for Cygwin - the files don't make much sense outside
-# of a UNIX look-alike.
+# Only do this on Windows for Cygwin - the files don't make much sense
+# outside of a UNIX look-alike.
if(NOT WIN32 OR CYGWIN OR MINGW)
- set(prefix ${CMAKE_INSTALL_PREFIX})
- set(exec_prefix ${CMAKE_INSTALL_PREFIX})
- set(libdir ${CMAKE_INSTALL_FULL_LIBDIR})
- set(includedir ${CMAKE_INSTALL_FULL_INCLUDEDIR})
- set(LIBS "-lz -lm")
- configure_file(${CMAKE_CURRENT_SOURCE_DIR}/libpng.pc.in
- ${CMAKE_CURRENT_BINARY_DIR}/${PNGLIB_NAME}.pc @ONLY)
- create_symlink(libpng.pc FILE ${PNGLIB_NAME}.pc)
-
- configure_file(${CMAKE_CURRENT_SOURCE_DIR}/libpng-config.in
- ${CMAKE_CURRENT_BINARY_DIR}/${PNGLIB_NAME}-config @ONLY)
- create_symlink(libpng-config FILE ${PNGLIB_NAME}-config)
-endif()
-
-# SET UP LINKS
-if(PNG_SHARED)
- set_target_properties(png PROPERTIES
-# VERSION 16.${PNGLIB_RELEASE}.1.6.37
- VERSION 16.${PNGLIB_RELEASE}.0
- SOVERSION 16
- CLEAN_DIRECT_OUTPUT 1)
+ set(prefix "${CMAKE_INSTALL_PREFIX}")
+ set(exec_prefix "${CMAKE_INSTALL_PREFIX}")
+ set(libdir "${CMAKE_INSTALL_FULL_LIBDIR}")
+ set(includedir "${CMAKE_INSTALL_FULL_INCLUDEDIR}")
+ set(LIBS "-lz -lm")
+ configure_file("${CMAKE_CURRENT_SOURCE_DIR}/libpng.pc.in"
+ "${CMAKE_CURRENT_BINARY_DIR}/libpng${PNGLIB_ABI_VERSION}.pc"
+ @ONLY)
+ create_symlink(libpng.pc FILE libpng${PNGLIB_ABI_VERSION}.pc)
+ configure_file("${CMAKE_CURRENT_SOURCE_DIR}/libpng-config.in"
+ "${CMAKE_CURRENT_BINARY_DIR}/libpng${PNGLIB_ABI_VERSION}-config"
+ @ONLY)
+ create_symlink(libpng-config FILE libpng${PNGLIB_ABI_VERSION}-config)
endif()
-# INSTALL
+# Install.
if(NOT SKIP_INSTALL_LIBRARIES AND NOT SKIP_INSTALL_ALL)
- install(TARGETS ${PNG_LIB_TARGETS}
+ install(TARGETS ${PNG_LIBRARY_TARGETS}
EXPORT libpng
- RUNTIME DESTINATION bin
- LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
- ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
- FRAMEWORK DESTINATION ${CMAKE_INSTALL_LIBDIR})
+ 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)
- install(FILES $/libpng${CMAKE_IMPORT_LIBRARY_SUFFIX}
- DESTINATION ${CMAKE_INSTALL_LIBDIR})
- endif()
-
- if(NOT WIN32)
- create_symlink(libpng${CMAKE_SHARED_LIBRARY_SUFFIX} TARGET png)
- install(FILES $/libpng${CMAKE_SHARED_LIBRARY_SUFFIX}
- DESTINATION ${CMAKE_INSTALL_LIBDIR})
+ if(NOT WIN32 OR CYGWIN OR MINGW)
+ create_symlink(libpng${CMAKE_SHARED_LIBRARY_SUFFIX} TARGET png_shared)
+ install(FILES "$/libpng${CMAKE_SHARED_LIBRARY_SUFFIX}"
+ DESTINATION "${CMAKE_INSTALL_LIBDIR}")
endif()
endif()
if(PNG_STATIC)
if(NOT WIN32 OR CYGWIN OR MINGW)
create_symlink(libpng${CMAKE_STATIC_LIBRARY_SUFFIX} TARGET png_static)
- install(FILES $/libpng${CMAKE_STATIC_LIBRARY_SUFFIX}
- DESTINATION ${CMAKE_INSTALL_LIBDIR})
+ install(FILES "$/libpng${CMAKE_STATIC_LIBRARY_SUFFIX}"
+ DESTINATION "${CMAKE_INSTALL_LIBDIR}")
endif()
endif()
endif()
if(NOT SKIP_INSTALL_HEADERS AND NOT SKIP_INSTALL_ALL)
- install(FILES ${libpng_public_hdrs} DESTINATION include)
- install(FILES ${libpng_public_hdrs} DESTINATION include/${PNGLIB_NAME})
+ install(FILES ${libpng_public_hdrs}
+ DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}")
+ install(FILES ${libpng_public_hdrs}
+ 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)
- install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/${PNGLIB_NAME}-config DESTINATION bin)
+ install(PROGRAMS "${CMAKE_CURRENT_BINARY_DIR}/libpng-config"
+ DESTINATION "${CMAKE_INSTALL_BINDIR}")
+ install(PROGRAMS "${CMAKE_CURRENT_BINARY_DIR}/libpng${PNGLIB_ABI_VERSION}-config"
+ 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)
- # Install man pages
- if(NOT PNG_MAN_DIR)
- set(PNG_MAN_DIR "share/man")
- endif()
- install(FILES libpng.3 libpngpf.3 DESTINATION ${PNG_MAN_DIR}/man3)
- install(FILES png.5 DESTINATION ${PNG_MAN_DIR}/man5)
- # Install pkg-config files
+ # Install the man pages.
+ install(FILES libpng.3 libpngpf.3
+ DESTINATION "${CMAKE_INSTALL_MANDIR}/man3")
+ install(FILES png.5
+ DESTINATION "${CMAKE_INSTALL_MANDIR}/man5")
+ # Install the pkg-config files.
if(NOT CMAKE_HOST_WIN32 OR CYGWIN OR MINGW)
- install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libpng.pc
- DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
- install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/libpng-config
- DESTINATION bin)
- install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PNGLIB_NAME}.pc
- DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
- install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/${PNGLIB_NAME}-config
- DESTINATION bin)
+ install(FILES "${CMAKE_CURRENT_BINARY_DIR}/libpng.pc"
+ DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
+ install(PROGRAMS "${CMAKE_CURRENT_BINARY_DIR}/libpng-config"
+ DESTINATION "${CMAKE_INSTALL_BINDIR}")
+ install(FILES "${CMAKE_CURRENT_BINARY_DIR}/libpng${PNGLIB_ABI_VERSION}.pc"
+ DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
+ install(PROGRAMS "${CMAKE_CURRENT_BINARY_DIR}/libpng${PNGLIB_ABI_VERSION}-config"
+ DESTINATION "${CMAKE_INSTALL_BINDIR}")
endif()
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 FILE lib${PNG_LIB_NAME}.cmake)
+ install(EXPORT libpng
+ DESTINATION "${CMAKE_INSTALL_LIBDIR}/libpng"
+ FILE libpng${PNGLIB_ABI_VERSION}.cmake)
endif()
-# what's with libpng-manual.txt and all the extra files?
-
-# UNINSTALL
-# do we need this?
-
-# DIST
-# do we need this?
+# Create a CMake Config File that can be used via find_package(PNG CONFIG)
+if(NOT SKIP_INSTALL_CONFIG_FILE AND NOT SKIP_INSTALL_ALL)
+ install(TARGETS ${PNG_LIBRARY_TARGETS}
+ EXPORT PNGTargets
+ RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
+ LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
+ ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
+ FRAMEWORK DESTINATION "${CMAKE_INSTALL_LIBDIR}")
+
+ include(CMakePackageConfigHelpers)
+ write_basic_package_version_file(PNGConfigVersion.cmake
+ VERSION ${PNGLIB_VERSION}
+ COMPATIBILITY SameMinorVersion)
+
+ install(EXPORT PNGTargets
+ FILE PNGTargets.cmake
+ NAMESPACE PNG::
+ DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/PNG")
+
+ install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/scripts/cmake/PNGConfig.cmake"
+ "${CMAKE_CURRENT_BINARY_DIR}/PNGConfigVersion.cmake"
+ DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/PNG")
+endif()
-# to create msvc import lib for mingw compiled shared lib
+# TODO: Create MSVC import lib for MinGW-compiled shared lib.
# pexports libpng.dll > libpng.def
# lib /def:libpng.def /machine:x86
diff --git a/src/libs/Irrlicht/irrlicht-svn/source/Irrlicht/libpng/LICENSE b/src/libs/Irrlicht/irrlicht-svn/source/Irrlicht/libpng/LICENSE
index 10075901..795711a9 100644
--- a/src/libs/Irrlicht/irrlicht-svn/source/Irrlicht/libpng/LICENSE
+++ b/src/libs/Irrlicht/irrlicht-svn/source/Irrlicht/libpng/LICENSE
@@ -4,8 +4,8 @@ COPYRIGHT NOTICE, DISCLAIMER, and LICENSE
PNG Reference Library License version 2
---------------------------------------
- * Copyright (c) 1995-2019 The PNG Reference Library Authors.
- * Copyright (c) 2018-2019 Cosmin Truta.
+ * Copyright (c) 1995-2026 The PNG Reference Library Authors.
+ * Copyright (c) 2018-2026 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/src/libs/Irrlicht/irrlicht-svn/source/Irrlicht/libpng/README b/src/libs/Irrlicht/irrlicht-svn/source/Irrlicht/libpng/README
index 98f1bb19..a0cc161c 100644
--- a/src/libs/Irrlicht/irrlicht-svn/source/Irrlicht/libpng/README
+++ b/src/libs/Irrlicht/irrlicht-svn/source/Irrlicht/libpng/README
@@ -1,178 +1,179 @@
-README for libpng version 1.6.37 - April 14, 2019
-=================================================
-
-See the note about version numbers near the top of png.h.
-See INSTALL for instructions on how to install libpng.
-
-Libpng comes in several distribution formats. Get libpng-*.tar.gz or
-libpng-*.tar.xz or if you want UNIX-style line endings in the text
-files, or lpng*.7z or lpng*.zip if you want DOS-style line endings.
-
-Version 0.89 was the first official release of libpng. Don't let the
-fact that it's the first release fool you. The libpng library has been
-in extensive use and testing since mid-1995. By late 1997 it had
-finally gotten to the stage where there hadn't been significant
-changes to the API in some time, and people have a bad feeling about
-libraries with versions < 1.0. Version 1.0.0 was released in
-March 1998.
-
-****
-Note that some of the changes to the png_info structure render this
-version of the library binary incompatible with libpng-0.89 or
-earlier versions if you are using a shared library. The type of the
-"filler" parameter for png_set_filler() has changed from png_byte to
-png_uint_32, which will affect shared-library applications that use
-this function.
+README for libpng version 1.6.54
+================================
-To avoid problems with changes to the internals of the png info_struct,
-new APIs have been made available in 0.95 to avoid direct application
-access to info_ptr. These functions are the png_set_ and
-png_get_ functions. These functions should be used when
-accessing/storing the info_struct data, rather than manipulating it
-directly, to avoid such problems in the future.
+See the note about version numbers near the top of `png.h`.
+See `INSTALL` for instructions on how to install libpng.
-It is important to note that the APIs did not make current programs
-that access the info struct directly incompatible with the new
-library, through libpng-1.2.x. In libpng-1.4.x, which was meant to
-be a transitional release, members of the png_struct and the
-info_struct can still be accessed, but the compiler will issue a
-warning about deprecated usage. Since libpng-1.5.0, direct access
-to these structs is not allowed, and the definitions of the structs
-reside in private pngstruct.h and pnginfo.h header files that are not
-accessible to applications. It is strongly suggested that new
-programs use the new APIs (as shown in example.c and pngtest.c), and
-older programs be converted to the new format, to facilitate upgrades
-in the future.
-****
-
-Additions since 0.90 include the ability to compile libpng as a
-Windows DLL, and new APIs for accessing data in the info struct.
-Experimental functions include the ability to set weighting and cost
-factors for row filter selection, direct reads of integers from buffers
-on big-endian processors that support misaligned data access, faster
-methods of doing alpha composition, and more accurate 16->8 bit color
-conversion.
+Libpng comes in several distribution formats. Get `libpng-*.tar.gz`
+or `libpng-*.tar.xz` if you want UNIX-style line endings in the text
+files, or `lpng*.7z` or `lpng*.zip` if you want DOS-style line endings.
-The additions since 0.89 include the ability to read from a PNG stream
-which has had some (or all) of the signature bytes read by the calling
-application. This also allows the reading of embedded PNG streams that
-do not have the PNG file signature. As well, it is now possible to set
-the library action on the detection of chunk CRC errors. It is possible
-to set different actions based on whether the CRC error occurred in a
-critical or an ancillary chunk.
+For a detailed description on using libpng, read `libpng-manual.txt`.
+For examples of libpng in a program, see `example.c` and `pngtest.c`.
+For usage information and restrictions (what little they are) on libpng,
+see `png.h`. For a description on using zlib (the compression library
+used by libpng) and zlib's restrictions, see `zlib.h`.
-For a detailed description on using libpng, read libpng-manual.txt.
-For examples of libpng in a program, see example.c and pngtest.c. For
-usage information and restrictions (what little they are) on libpng,
-see png.h. For a description on using zlib (the compression library
-used by libpng) and zlib's restrictions, see zlib.h
-
-I have included a general makefile, as well as several machine and
-compiler specific ones, but you may have to modify one for your own
-needs.
-
-You should use zlib 1.0.4 or later to run this, but it MAY work with
+You should use zlib 1.0.4 or later to run this, but it _may_ work with
versions as old as zlib 0.95. Even so, there are bugs in older zlib
versions which can cause the output of invalid compression streams for
some images.
You should also note that zlib is a compression library that is useful
for more things than just PNG files. You can use zlib as a drop-in
-replacement for fread() and fwrite(), if you are so inclined.
+replacement for `fread()` and `fwrite()`, if you are so inclined.
zlib should be available at the same place that libpng is, or at
-https://zlib.net.
+https://zlib.net .
You may also want a copy of the PNG specification. It is available
as an RFC, a W3C Recommendation, and an ISO/IEC Standard. You can find
these at http://www.libpng.org/pub/png/pngdocs.html .
-This code is currently being archived at libpng.sourceforge.io in the
-[DOWNLOAD] area, and at http://libpng.download/src .
+This code is currently being archived at https://libpng.sourceforge.io
+in the download area, and at http://libpng.download/src .
This release, based in a large way on Glenn's, Guy's and Andreas'
earlier work, was created and will be supported by myself and the PNG
development group.
-Send comments/corrections/commendations to png-mng-implement at
-lists.sourceforge.net (subscription required; visit
+Send comments, corrections and commendations to `png-mng-implement`
+at `lists.sourceforge.net`. (Subscription is required; visit
https://lists.sourceforge.net/lists/listinfo/png-mng-implement
-to subscribe).
-
-Send general questions about the PNG specification to png-mng-misc
-at lists.sourceforge.net (subscription required; visit
-https://lists.sourceforge.net/lists/listinfo/png-mng-misc to
-subscribe).
-
-Files in this distribution:
-
- ANNOUNCE => Announcement of this version, with recent changes
- AUTHORS => List of contributing authors
- CHANGES => Description of changes between libpng versions
- KNOWNBUG => List of known bugs and deficiencies
- LICENSE => License to use and redistribute libpng
- README => This file
- TODO => Things not implemented in the current library
- TRADEMARK => Trademark information
- example.c => Example code for using libpng functions
- libpng.3 => manual page for libpng (includes libpng-manual.txt)
- libpng-manual.txt => Description of libpng and its functions
- libpngpf.3 => manual page for libpng's private functions
- png.5 => manual page for the PNG format
- png.c => Basic interface functions common to library
- png.h => Library function and interface declarations (public)
- pngpriv.h => Library function and interface declarations (private)
- pngconf.h => System specific library configuration (public)
- pngstruct.h => png_struct declaration (private)
- pnginfo.h => png_info struct declaration (private)
- pngdebug.h => debugging macros (private)
- pngerror.c => Error/warning message I/O functions
- pngget.c => Functions for retrieving info from struct
- pngmem.c => Memory handling functions
- pngbar.png => PNG logo, 88x31
- pngnow.png => PNG logo, 98x31
- pngpread.c => Progressive reading functions
- pngread.c => Read data/helper high-level functions
- pngrio.c => Lowest-level data read I/O functions
- pngrtran.c => Read data transformation functions
- pngrutil.c => Read data utility functions
- pngset.c => Functions for storing data into the info_struct
- pngtest.c => Library test program
- pngtest.png => Library test sample image
- pngtrans.c => Common data transformation functions
- pngwio.c => Lowest-level write I/O functions
- pngwrite.c => High-level write functions
- pngwtran.c => Write data transformations
- pngwutil.c => Write utility functions
- arm => Contains optimized code for the ARM platform
- powerpc => Contains optimized code for the PowerPC platform
- contrib => Contributions
- arm-neon => Optimized code for ARM-NEON platform
- powerpc-vsx => Optimized code for POWERPC-VSX platform
- examples => Example programs
- gregbook => source code for PNG reading and writing, from
- Greg Roelofs' "PNG: The Definitive Guide",
- O'Reilly, 1999
- libtests => Test programs
- mips-msa => Optimized code for MIPS-MSA platform
- pngminim => Minimal decoder, encoder, and progressive decoder
- programs demonstrating use of pngusr.dfa
- pngminus => Simple pnm2png and png2pnm programs
- pngsuite => Test images
- testpngs
- tools => Various tools
- visupng => Contains a MSVC workspace for VisualPng
- intel => Optimized code for INTEL-SSE2 platform
- mips => Optimized code for MIPS platform
- projects => Contains project files and workspaces for
- building a DLL
- owatcom => Contains a WATCOM project for building libpng
- visualc71 => Contains a Microsoft Visual C++ (MSVC)
- workspace for building libpng and zlib
- vstudio => Contains a Microsoft Visual C++ (MSVC)
- workspace for building libpng and zlib
- scripts => Directory containing scripts for building libpng:
- (see scripts/README.txt for the list of scripts)
+to subscribe.)
+
+Send general questions about the PNG specification to `png-mng-misc`
+at `lists.sourceforge.net`. (Subscription is required; visit
+https://lists.sourceforge.net/lists/listinfo/png-mng-misc
+to subscribe.)
+
+Historical notes
+----------------
+
+The libpng library has been in extensive use and testing since mid-1995.
+Version 0.89, published a year later, was the first official release.
+By late 1997, it had finally gotten to the stage where there hadn't
+been significant changes to the API in some time, and people have a bad
+feeling about libraries with versions below 1.0. Version 1.0.0 was
+released in March 1998.
+
+Note that some of the changes to the `png_info` structure render this
+version of the library binary incompatible with libpng-0.89 or
+earlier versions if you are using a shared library. The type of the
+`filler` parameter for `png_set_filler()` has changed from `png_byte`
+to `png_uint_32`, which will affect shared-library applications that
+use this function.
+
+To avoid problems with changes to the internals of the `info_struct`,
+new APIs have been made available in 0.95 to avoid direct application
+access to `info_ptr`. These functions are the `png_set_` and
+`png_get_` functions. These functions should be used when
+accessing/storing the `info_struct` data, rather than manipulating it
+directly, to avoid such problems in the future.
+
+It is important to note that the APIs did not make current programs
+that access the info struct directly incompatible with the new
+library, through libpng-1.2.x. In libpng-1.4.x, which was meant to
+be a transitional release, members of the `png_struct` and the
+`info_struct` can still be accessed, but the compiler will issue a
+warning about deprecated usage. Since libpng-1.5.0, direct access
+to these structs is not allowed, and the definitions of the structs
+reside in private `pngstruct.h` and `pnginfo.h` header files that are
+not accessible to applications. It is strongly suggested that new
+programs use the new APIs (as shown in `example.c` and `pngtest.c`),
+and older programs be converted to the new format, to facilitate
+upgrades in the future.
+
+The additions since 0.89 include the ability to read from a PNG stream
+which has had some (or all) of the signature bytes read by the calling
+application. This also allows the reading of embedded PNG streams that
+do not have the PNG file signature. As well, it is now possible to set
+the library action on the detection of chunk CRC errors. It is possible
+to set different actions based on whether the CRC error occurred in a
+critical or an ancillary chunk.
+
+The additions since 0.90 include the ability to compile libpng as a
+Windows DLL, and new APIs for accessing data in the `info_struct`.
+Experimental functions included the ability to set weighting and cost
+factors for row filter selection, direct reads of integers from buffers
+on big-endian processors that support misaligned data access, faster
+methods of doing alpha composition, and more accurate 16-to-8 bit color
+conversion. Some of these experimental functions, such as the weighted
+filter heuristics, have since been removed.
+
+Files included in this distribution
+-----------------------------------
+
+ ANNOUNCE => Announcement of this version, with recent changes
+ AUTHORS => List of contributing authors
+ CHANGES => Description of changes between libpng versions
+ INSTALL => Instructions to install libpng
+ LICENSE => License to use and redistribute libpng
+ README => This file
+ TODO => Things not implemented in the current library
+ TRADEMARK => Trademark information
+ example.c => Example code for using libpng functions
+ libpng.3 => Manual page for libpng (includes libpng-manual.txt)
+ libpng-manual.txt => Description of libpng and its functions
+ libpngpf.3 => Manual page for libpng's private functions (deprecated)
+ png.5 => Manual page for the PNG format
+ png.c => Basic interface functions common to library
+ png.h => Library function and interface declarations (public)
+ pngpriv.h => Library function and interface declarations (private)
+ pngconf.h => System specific library configuration (public)
+ pngstruct.h => png_struct declaration (private)
+ pnginfo.h => png_info struct declaration (private)
+ pngdebug.h => debugging macros (private)
+ pngerror.c => Error/warning message I/O functions
+ pngget.c => Functions for retrieving info from struct
+ pngmem.c => Memory handling functions
+ pngbar.png => PNG logo, 88x31
+ pngnow.png => PNG logo, 98x31
+ pngpread.c => Progressive reading functions
+ pngread.c => Read data/helper high-level functions
+ pngrio.c => Lowest-level data read I/O functions
+ pngrtran.c => Read data transformation functions
+ pngrutil.c => Read data utility functions
+ pngset.c => Functions for storing data into the info_struct
+ pngtest.c => Library test program
+ pngtest.png => Library test sample image
+ pngtrans.c => Common data transformation functions
+ pngwio.c => Lowest-level write I/O functions
+ pngwrite.c => High-level write functions
+ pngwtran.c => Write data transformations
+ pngwutil.c => Write utility functions
+ arm/ => Optimized code for ARM Neon
+ intel/ => Optimized code for INTEL SSE2
+ loongarch/ => Optimized code for LoongArch LSX
+ mips/ => Optimized code for MIPS MSA and MIPS MMI
+ powerpc/ => Optimized code for PowerPC VSX
+ riscv/ => Optimized code for the RISC-V platform
+ ci/ => Scripts for continuous integration
+ contrib/ => External contributions
+ arm-neon/ => Optimized code for the ARM-NEON platform
+ mips-msa/ => Optimized code for the MIPS-MSA platform
+ powerpc-vsx/ => Optimized code for the POWERPC-VSX platform
+ examples/ => Examples of libpng usage
+ gregbook/ => Source code for PNG reading and writing, from
+ "PNG: The Definitive Guide" by Greg Roelofs,
+ O'Reilly, 1999
+ libtests/ => Test programs
+ pngexif/ => Program to inspect the EXIF information in PNG files
+ pngminim/ => Minimal decoder, encoder, and progressive decoder
+ programs demonstrating the use of pngusr.dfa
+ pngminus/ => Simple pnm2png and png2pnm programs
+ pngsuite/ => Test images
+ riscv-rvv/ => Optimized code for the RISC-V Vector platform
+ testpngs/ => Test images
+ tools/ => Various tools
+ visupng/ => VisualPng, a Windows viewer for PNG images
+ projects/ => Project files and workspaces for various IDEs
+ owatcom/ => OpenWatcom project
+ visualc71/ => Microsoft Visual C++ 7.1 workspace
+ vstudio/ => Microsoft Visual Studio workspace
+ scripts/ => Scripts and makefiles for building libpng
+ (see scripts/README.txt for the complete list)
+ tests/ => Test scripts
Good luck, and happy coding!
diff --git a/src/libs/Irrlicht/irrlicht-svn/source/Irrlicht/libpng/TODO b/src/libs/Irrlicht/irrlicht-svn/source/Irrlicht/libpng/TODO
index 9b2388b5..cee4a545 100644
--- a/src/libs/Irrlicht/irrlicht-svn/source/Irrlicht/libpng/TODO
+++ b/src/libs/Irrlicht/irrlicht-svn/source/Irrlicht/libpng/TODO
@@ -1,23 +1,22 @@
-TODO - list of things to do for libpng:
+TODO list for libpng
+--------------------
-* Fix all defects (duh!)
-* Better C++ wrapper / full C++ implementation (?)
-* Fix the problems with C++ and 'extern "C"'.
-* cHRM transformation.
-* Palette creation.
-* "grayscale->palette" transformation and "palette->grayscale" detection.
-* Improved dithering.
-* Multi-lingual error and warning message support.
-* Complete sRGB transformation. (Currently it simply uses gamma=0.45455.)
-* Man pages for function calls.
-* Better documentation.
-* Better filter selection
- (e.g., counting huffman bits/precompression; filter inertia; filter costs).
-* Histogram creation.
-* Text conversion between different code pages (e.g., Latin-1 -> Mac).
-* Avoid building gamma tables whenever possible.
-* Greater precision in changing to linear gamma for compositing against
- background, and in doing rgb-to-gray transformations.
-* Investigate pre-incremented loop counters and other loop constructions.
-* Interpolated method of handling interlacing.
-* More validations for libpng transformations.
+ * Fix all defects (duh!)
+ * cHRM transformation.
+ * Palette creation.
+ * "grayscale->palette" transformation and "palette->grayscale" detection.
+ * Improved dithering.
+ * Multi-lingual error and warning message support.
+ * Complete sRGB transformation. (Currently it simply uses gamma=0.45455.)
+ * Man pages for function calls.
+ * Better documentation.
+ * Better filter selection
+ (e.g., counting huffman bits/precompression; filter inertia; filter costs).
+ * Histogram creation.
+ * Text conversion between different code pages (e.g., Latin-1 to Mac).
+ * Avoid building gamma tables whenever possible.
+ * Greater precision in changing to linear gamma for compositing against
+ background, and in doing rgb-to-gray transformations.
+ * Investigate pre-incremented loop counters and other loop constructions.
+ * Interpolated method of handling interlacing.
+ * More validations for libpng transformations.
diff --git a/src/libs/Irrlicht/irrlicht-svn/source/Irrlicht/libpng/example.c b/src/libs/Irrlicht/irrlicht-svn/source/Irrlicht/libpng/example.c
index 122b19d3..69a3db9d 100644
--- a/src/libs/Irrlicht/irrlicht-svn/source/Irrlicht/libpng/example.c
+++ b/src/libs/Irrlicht/irrlicht-svn/source/Irrlicht/libpng/example.c
@@ -1,9 +1,8 @@
-
#if 0 /* in case someone actually tries to compile this */
/* example.c - an example of using libpng
*
- * Maintained 2018 Cosmin Truta
+ * Maintained 2018-2025 Cosmin Truta
* Maintained 1998-2016 Glenn Randers-Pehrson
* Maintained 1996-1997 Andreas Dilger
* Written 1995-1996 Guy Eric Schalnat, Group 42, Inc.
@@ -125,6 +124,7 @@ int main(int argc, const char **argv)
png_image_free(&image);
else
free(buffer);
+ }
}
/* Something went wrong reading or writing the image. libpng stores a
@@ -179,11 +179,11 @@ int main(int argc, const char **argv)
* components.
*
* You do not have to read directly from a file. You can read from memory or,
- * on systems that support it, from a FILE*. This is controlled by
- * the particular png_image_read_from_ function you call at the start.
- * Likewise, on write, you can write to a FILE* if your system supports it.
- * Check the macro PNG_STDIO_SUPPORTED to see if stdio support has been
- * included in your libpng build.
+ * on systems that support , from a FILE object. This is controlled
+ * by the particular png_image_begin_read_from_ function you call at the start.
+ * Likewise, on write, you can write to a FILE object if your system supports
+ * . The macro PNG_STDIO_SUPPORTED indicates if stdio is available
+ * and accessible from your libpng build.
*
* If you read 16-bit (PNG_FORMAT_FLAG_LINEAR) data, you may need to write it
* in the 8-bit format for display. You do this by setting the convert_to_8bit
@@ -258,9 +258,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
@@ -280,7 +280,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 */
@@ -303,7 +303,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. */
@@ -312,7 +312,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
@@ -325,7 +325,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. */
@@ -584,7 +584,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 */
@@ -603,18 +603,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,
@@ -631,7 +631,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
@@ -642,7 +642,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
@@ -656,7 +656,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)
@@ -746,7 +746,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,
@@ -759,7 +759,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. */
@@ -768,7 +768,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
@@ -779,7 +779,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. */
@@ -1034,7 +1034,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/src/libs/Irrlicht/irrlicht-svn/source/Irrlicht/libpng/libpng-manual.txt b/src/libs/Irrlicht/irrlicht-svn/source/Irrlicht/libpng/libpng-manual.txt
index 7d40fb5d..c83886fa 100644
--- a/src/libs/Irrlicht/irrlicht-svn/source/Irrlicht/libpng/libpng-manual.txt
+++ b/src/libs/Irrlicht/irrlicht-svn/source/Irrlicht/libpng/libpng-manual.txt
@@ -1,6 +1,6 @@
libpng-manual.txt - A description on how to use and modify libpng
- Copyright (c) 2018-2019 Cosmin Truta
+ Copyright (c) 2018-2025 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.37 - April 2019
+ libpng version 1.6.36, December 2018, through 1.6.54 - January 2026
Updated and distributed by Cosmin Truta
- Copyright (c) 2018-2019 Cosmin Truta
+ Copyright (c) 2018-2026 Cosmin Truta
libpng versions 0.97, January 1998, through 1.6.35 - July 2018
Updated and distributed by Glenn Randers-Pehrson
@@ -65,18 +65,22 @@ Libpng was written as a companion to the PNG specification, as a way
of reducing the amount of time and effort it takes to support the PNG
file format in application programs.
-The PNG specification (second edition), November 2003, is available as
+The PNG specification (Third Edition), June 2025, is available as
+a W3C Recommendation at
+.
+
+The PNG specification (Second Edition), November 2003, is available as
a W3C Recommendation and as an ISO Standard (ISO/IEC 15948:2004 (E)) at
.
The W3C and ISO documents have identical technical content.
The PNG-1.2 specification is available at
-.
-It is technically equivalent
-to the PNG specification (second edition) but has some additional material.
+.
+It is technically equivalent to the PNG specification (Second Edition)
+but has some additional material.
The PNG-1.0 specification is available as RFC 2083 at
- and as a
+ and as a
W3C Recommendation at .
Some additional chunks are described in the special-purpose public chunks
@@ -357,7 +361,7 @@ Customizing libpng.
return ERROR;
}
- is_png = !png_sig_cmp(header, 0, number);
+ is_png = (png_sig_cmp(header, 0, number) == 0);
if (!is_png)
{
return NOT_PNG;
@@ -385,8 +389,7 @@ create the structure, so your application should check for that.
if (!info_ptr)
{
- png_destroy_read_struct(&png_ptr,
- (png_infopp)NULL, (png_infopp)NULL);
+ png_destroy_read_struct(&png_ptr, NULL, NULL);
return ERROR;
}
@@ -419,14 +422,13 @@ free any memory.
if (setjmp(png_jmpbuf(png_ptr)))
{
- png_destroy_read_struct(&png_ptr, &info_ptr,
- &end_info);
+ png_destroy_read_struct(&png_ptr, &info_ptr, &end_info);
fclose(fp);
return ERROR;
}
-Pass (png_infopp)NULL instead of &end_info if you didn't create
-an end_info structure.
+Pass NULL instead of &end_info if you didn't create an end_info
+structure.
If you would rather avoid the complexity of setjmp/longjmp issues,
you can compile libpng with PNG_NO_SETJMP, in which case
@@ -496,7 +498,7 @@ You can set up a callback function to handle any unknown chunks in the
input stream. You must supply the function
read_chunk_callback(png_structp png_ptr,
- png_unknown_chunkp chunk);
+ png_unknown_chunkp chunk)
{
/* The unknown chunk structure contains your
chunk data, along with similar data for any other
@@ -547,9 +549,9 @@ a progress meter or the like. It's demonstrated in pngtest.c.
You must supply a function
void read_row_callback(png_structp png_ptr,
- png_uint_32 row, int pass);
+ png_uint_32 row, int pass)
{
- /* put your code here */
+ /* put your code here */
}
(You can give it another name that you like instead of "read_row_callback")
@@ -877,7 +879,7 @@ described below (the latter being the two common names for associated alpha
color channels). Note that PNG files always contain non-associated color
channels; png_set_alpha_mode() with one of the modes causes the decoder to
convert the pixels to an associated form before returning them to your
-application.
+application.
Since it is not necessary to perform arithmetic on opaque color values so
long as they are not to be resampled and are in the final color space it is
@@ -1180,22 +1182,22 @@ where row_pointers is an array of pointers to the pixel data for each row:
If you know your image size and pixel size ahead of time, you can allocate
row_pointers prior to calling png_read_png() with
- if (height > PNG_UINT_32_MAX/(sizeof (png_byte)))
- png_error (png_ptr,
+ if (height > PNG_UINT_32_MAX / (sizeof (png_bytep)))
+ png_error(png_ptr,
"Image is too tall to process in memory");
- if (width > PNG_UINT_32_MAX/pixel_size)
- png_error (png_ptr,
+ if (width > PNG_UINT_32_MAX / pixel_size)
+ png_error(png_ptr,
"Image is too wide to process in memory");
row_pointers = png_malloc(png_ptr,
height*(sizeof (png_bytep)));
- for (int i=0; i PNG_SIZE_MAX/(width*pixel_size)) {
- png_error(png_ptr,"image_data buffer would be too large");
- }
+ if (height > PNG_SIZE_MAX/(width*pixel_size))
+ png_error(png_ptr, "image_data buffer would be too large");
- png_bytep buffer=png_malloc(png_ptr,height*width*pixel_size);
+ png_bytep buffer = png_malloc(png_ptr,
+ height*width*pixel_size);
- for (int i=0; i= 10504
png_set_scale_16(png_ptr);
#else
png_set_strip_16(png_ptr);
#endif
+ }
(The more accurate "png_set_scale_16()" API became available in libpng version
1.5.4).
@@ -1792,7 +1795,7 @@ the information. If, instead, you want to convert the image to an opaque
version with no alpha channel use png_set_background; see below.
As of libpng version 1.5.2, almost all useful expansions are supported, the
-major ommissions are conversion of grayscale to indexed images (which can be
+major omissions are conversion of grayscale to indexed images (which can be
done trivially in the application) and conversion of indexed to grayscale (which
can be done by a trivial manipulation of the palette.)
@@ -1901,7 +1904,7 @@ Note that png_set_filler() does not change the color type. If you want
to do that, you can add a true alpha channel with
if (color_type == PNG_COLOR_TYPE_RGB ||
- color_type == PNG_COLOR_TYPE_GRAY)
+ color_type == PNG_COLOR_TYPE_GRAY)
png_set_add_alpha(png_ptr, filler, PNG_FILLER_AFTER);
where "filler" contains the alpha value to assign to each pixel.
@@ -1926,7 +1929,7 @@ with alpha.
if (color_type == PNG_COLOR_TYPE_RGB ||
color_type == PNG_COLOR_TYPE_RGB_ALPHA)
png_set_rgb_to_gray(png_ptr, error_action,
- double red_weight, double green_weight);
+ (double)red_weight, (double)green_weight);
error_action = 1: silently do the conversion
@@ -1949,8 +1952,8 @@ In the corresponding fixed point API the red_weight and green_weight values are
simply scaled by 100,000:
png_set_rgb_to_gray(png_ptr, error_action,
- png_fixed_point red_weight,
- png_fixed_point green_weight);
+ (png_fixed_point)red_weight,
+ (png_fixed_point)green_weight);
If you have set error_action = 1 or 2, you can
later check whether the image really was gray, after processing
@@ -2186,9 +2189,8 @@ do your own check for number_of_rows*width*pixel_size if you are using
a multiple-row buffer:
/* Guard against integer overflow */
- if (number_of_rows > PNG_SIZE_MAX/(width*pixel_size)) {
- png_error(png_ptr,"image_data buffer would be too large");
- }
+ if (number_of_rows > PNG_SIZE_MAX/(width*pixel_size))
+ png_error(png_ptr, "image_data buffer would be too large");
Remember: Before you call png_read_update_info(), the png_get_*()
functions return the values corresponding to the original PNG image.
@@ -2408,12 +2410,11 @@ separate.
if (!end_info)
{
- png_destroy_read_struct(&png_ptr, &info_ptr,
- (png_infopp)NULL);
+ png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
return ERROR;
}
- png_read_end(png_ptr, end_info);
+ png_read_end(png_ptr, end_info);
If you are not interested, you should still call png_read_end()
but you can pass NULL, avoiding the need to create an end_info structure.
@@ -2421,7 +2422,7 @@ If you do this, libpng will not process any chunks after IDAT other than
skipping over them and perhaps (depending on whether you have called
png_set_crc_action) checking their CRCs while looking for the IEND chunk.
- png_read_end(png_ptr, (png_infop)NULL);
+ png_read_end(png_ptr, NULL);
If you don't call png_read_end(), then your file pointer will be
left pointing to the first chunk after the last IDAT, which is probably
@@ -2430,13 +2431,11 @@ the PNG datastream.
When you are done, you can free all memory allocated by libpng like this:
- png_destroy_read_struct(&png_ptr, &info_ptr,
- &end_info);
+ png_destroy_read_struct(&png_ptr, &info_ptr, &end_info);
or, if you didn't create an end_info structure,
- png_destroy_read_struct(&png_ptr, &info_ptr,
- (png_infopp)NULL);
+ png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
It is also possible to individually free the info_ptr members that
point to libpng-allocated storage with the following function:
@@ -2556,15 +2555,13 @@ png_infop info_ptr;
if (!info_ptr)
{
- png_destroy_read_struct(&png_ptr,
- (png_infopp)NULL, (png_infopp)NULL);
+ png_destroy_read_struct(&png_ptr, NULL, NULL);
return ERROR;
}
if (setjmp(png_jmpbuf(png_ptr)))
{
- png_destroy_read_struct(&png_ptr, &info_ptr,
- (png_infopp)NULL);
+ png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
return ERROR;
}
@@ -2597,8 +2594,7 @@ png_infop info_ptr;
{
if (setjmp(png_jmpbuf(png_ptr)))
{
- png_destroy_read_struct(&png_ptr, &info_ptr,
- (png_infopp)NULL);
+ png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
return ERROR;
}
@@ -2763,8 +2759,7 @@ both "png_ptr"; you can call them anything you like, such as
png_infop info_ptr = png_create_info_struct(png_ptr);
if (!info_ptr)
{
- png_destroy_write_struct(&png_ptr,
- (png_infopp)NULL);
+ png_destroy_write_struct(&png_ptr, NULL);
return ERROR;
}
@@ -2790,7 +2785,7 @@ section below for more information on the libpng error handling.
if (setjmp(png_jmpbuf(png_ptr)))
{
- png_destroy_write_struct(&png_ptr, &info_ptr);
+ png_destroy_write_struct(&png_ptr, &info_ptr);
fclose(fp);
return ERROR;
}
@@ -2844,9 +2839,9 @@ a progress meter or the like. It's demonstrated in pngtest.c.
You must supply a function
void write_row_callback(png_structp png_ptr, png_uint_32 row,
- int pass);
+ int pass)
{
- /* put your code here */
+ /* put your code here */
}
(You can give it another name that you like instead of "write_row_callback")
@@ -3116,8 +3111,8 @@ width, height, bit_depth, and color_type must be the same in each call.
png_set_eXIf_1(png_ptr, info_ptr, num_exif, exif);
- exif - Exif profile (array of
- png_byte) (PNG_INFO_eXIf)
+ exif - Exif profile (array of png_byte)
+ (PNG_INFO_eXIf)
png_set_hIST(png_ptr, info_ptr, hist);
@@ -3127,12 +3122,12 @@ width, height, bit_depth, and color_type must be the same in each call.
png_set_tIME(png_ptr, info_ptr, mod_time);
mod_time - time image was last modified
- (PNG_VALID_tIME)
+ (PNG_INFO_tIME)
png_set_bKGD(png_ptr, info_ptr, background);
background - background color (of type
- png_color_16p) (PNG_VALID_bKGD)
+ png_color_16p) (PNG_INFO_bKGD)
png_set_text(png_ptr, info_ptr, text_ptr, num_text);
@@ -3360,19 +3355,6 @@ Here is an example of writing two private chunks, prVt and miNE:
/* Needed because miNE is not safe-to-copy */
png_set_keep_unknown_chunks(png, PNG_HANDLE_CHUNK_ALWAYS,
(png_bytep) "miNE", 1);
- # if PNG_LIBPNG_VER < 10600
- /* Deal with unknown chunk location bug in 1.5.x and earlier */
- png_set_unknown_chunk_location(png, info, 0, PNG_HAVE_IHDR);
- png_set_unknown_chunk_location(png, info, 1, PNG_AFTER_IDAT);
- # endif
- # if PNG_LIBPNG_VER < 10500
- /* PNG_AFTER_IDAT writes two copies of the chunk prior to libpng-1.5.0,
- * one before IDAT and another after IDAT, so don't use it; only use
- * PNG_HAVE_IHDR location. This call resets the location previously
- * set by assignment and png_set_unknown_chunk_location() for chunk 1.
- */
- png_set_unknown_chunk_location(png, info, 1, PNG_HAVE_IHDR);
- # endif
#endif
The high-level write interface
@@ -4098,7 +4080,7 @@ READ APIs
is filled in from the PNG header in the file.
int png_image_begin_read_from_stdio (png_imagep image,
- FILE* file)
+ FILE *file)
The PNG header is read from the stdio FILE object.
@@ -4173,7 +4155,7 @@ be written:
int convert_to_8_bit, const void *buffer,
png_int_32 row_stride, const void *colormap)
- Write the image to the given (FILE*).
+ Write the image to the given FILE object.
With all write APIs if image is in one of the linear formats with
(png_uint_16) data then setting convert_to_8_bit will cause the output to be
@@ -4218,7 +4200,7 @@ png_create_read_struct_2() or png_create_write_struct_2() to register your
own functions as described above. These functions also provide a void
pointer that can be retrieved via
- mem_ptr=png_get_mem_ptr(png_ptr);
+ mem_ptr = png_get_mem_ptr(png_ptr);
Your replacement memory functions must have prototypes as follows:
@@ -4515,7 +4497,7 @@ When PNG_DEBUG is defined but is zero, the macros aren't defined, but you
can still use PNG_DEBUG to control your own debugging:
#ifdef PNG_DEBUG
- fprintf(stderr, ...
+ fprintf(stderr, ...);
#endif
When PNG_DEBUG = 1, the macros are defined, but only png_debug statements
@@ -4692,7 +4674,7 @@ deprecated since libpng-1.0.16 and libpng-1.2.6.
The function
png_check_sig(sig, num)
was replaced with
- !png_sig_cmp(sig, 0, num)
+ png_sig_cmp(sig, 0, num) == 0
It has been deprecated since libpng-0.90.
The function
@@ -4756,8 +4738,8 @@ png_get_mmx_bitdepth_threshold(), png_get_mmx_rowbytes_threshold(),
png_set_asm_flags(), and png_mmx_supported()
We removed the obsolete png_check_sig(), png_memcpy_check(), and
-png_memset_check() functions. Instead use !png_sig_cmp(), memcpy(),
-and memset(), respectively.
+png_memset_check() functions. Instead use png_sig_cmp() == 0,
+memcpy(), and memset(), respectively.
The function png_set_gray_1_2_4_to_8() was removed. It has been
deprecated since libpng-1.0.18 and 1.2.9, when it was replaced with
@@ -5182,7 +5164,7 @@ a pre-existing bug where the per-chunk 'keep' setting is ignored, and makes
it possible to skip IDAT chunks in the sequential reader.
The machine-generated configure files are no longer included in branches
-libpng16 and later of the GIT repository. They continue to be included
+libpng17 and later of the GIT repository. They continue to be included
in the tarball releases, however.
Libpng-1.6.0 through 1.6.2 used the CMF bytes at the beginning of the IDAT
@@ -5239,7 +5221,7 @@ changed, and is unaffected by conditional compilation macros. It is the
best choice for use in configure scripts for detecting the presence of any
libpng version since 0.88. In an autoconf "configure.in" you could use
- AC_CHECK_LIB(png, png_get_io_ptr, ...
+ AC_CHECK_LIB(png, png_get_io_ptr, ...)
XV. Source code repository
@@ -5248,12 +5230,12 @@ control. The git repository was built from old libpng-x.y.z.tar.gz files
going back to version 0.70. You can access the git repository (read only)
at
- https://github.com/glennrp/libpng or
+ https://github.com/pnggroup/libpng or
https://git.code.sf.net/p/libpng/code.git
or you can browse it with a web browser at
- https://github.com/glennrp/libpng or
+ https://github.com/pnggroup/libpng or
https://sourceforge.net/p/libpng/code/ci/libpng16/tree/
Patches can be sent to png-mng-implement at lists.sourceforge.net or
@@ -5263,7 +5245,7 @@ uploaded to the libpng bug tracker at
or as a "pull request" to
- https://github.com/glennrp/libpng/pulls
+ https://github.com/pnggroup/libpng/pulls
We also accept patches built from the tar or zip distributions, and
simple verbal descriptions of bug fixes, reported either to the
diff --git a/src/libs/Irrlicht/irrlicht-svn/source/Irrlicht/libpng/libpng.3 b/src/libs/Irrlicht/irrlicht-svn/source/Irrlicht/libpng/libpng.3
index aabb160b..5d5bfc92 100644
--- a/src/libs/Irrlicht/irrlicht-svn/source/Irrlicht/libpng/libpng.3
+++ b/src/libs/Irrlicht/irrlicht-svn/source/Irrlicht/libpng/libpng.3
@@ -1,6 +1,6 @@
-.TH LIBPNG 3 "April 14, 2019"
+.TH LIBPNG 3 "January 12, 2026"
.SH NAME
-libpng \- Portable Network Graphics (PNG) Reference Library 1.6.37
+libpng \- Portable Network Graphics (PNG) Reference Library 1.6.54
.SH SYNOPSIS
\fB#include \fP
@@ -223,7 +223,7 @@ libpng \- Portable Network Graphics (PNG) Reference Library 1.6.37
\fBint png_image_begin_read_from_file (png_imagep \fP\fIimage\fP\fB, const char \fI*file_name\fP\fB);\fP
-\fBint png_image_begin_read_from_stdio (png_imagep \fP\fIimage\fP\fB, FILE* \fIfile\fP\fB);\fP
+\fBint png_image_begin_read_from_stdio (png_imagep \fP\fIimage\fP\fB, FILE *\fIfile\fP\fB);\fP
\fBint, png_image_begin_read_from_memory (png_imagep \fP\fIimage\fP\fB, png_const_voidp \fP\fImemory\fP\fB, size_t \fIsize\fP\fB);\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-2019 Cosmin Truta
+ Copyright (c) 2018-2025 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.37 - April 2019
+ libpng version 1.6.36, December 2018, through 1.6.54 - January 2026
Updated and distributed by Cosmin Truta
- Copyright (c) 2018-2019 Cosmin Truta
+ Copyright (c) 2018-2026 Cosmin Truta
libpng versions 0.97, January 1998, through 1.6.35 - July 2018
Updated and distributed by Glenn Randers-Pehrson
@@ -584,18 +584,22 @@ Libpng was written as a companion to the PNG specification, as a way
of reducing the amount of time and effort it takes to support the PNG
file format in application programs.
-The PNG specification (second edition), November 2003, is available as
+The PNG specification (Third Edition), June 2025, is available as
+a W3C Recommendation at
+.
+
+The PNG specification (Second Edition), November 2003, is available as
a W3C Recommendation and as an ISO Standard (ISO/IEC 15948:2004 (E)) at
.
The W3C and ISO documents have identical technical content.
The PNG-1.2 specification is available at
-.
-It is technically equivalent
-to the PNG specification (second edition) but has some additional material.
+.
+It is technically equivalent to the PNG specification (Second Edition)
+but has some additional material.
The PNG-1.0 specification is available as RFC 2083 at
- and as a
+ and as a
W3C Recommendation at .
Some additional chunks are described in the special-purpose public chunks
@@ -876,7 +880,7 @@ Customizing libpng.
return ERROR;
}
- is_png = !png_sig_cmp(header, 0, number);
+ is_png = (png_sig_cmp(header, 0, number) == 0);
if (!is_png)
{
return NOT_PNG;
@@ -904,8 +908,7 @@ create the structure, so your application should check for that.
if (!info_ptr)
{
- png_destroy_read_struct(&png_ptr,
- (png_infopp)NULL, (png_infopp)NULL);
+ png_destroy_read_struct(&png_ptr, NULL, NULL);
return ERROR;
}
@@ -938,14 +941,13 @@ free any memory.
if (setjmp(png_jmpbuf(png_ptr)))
{
- png_destroy_read_struct(&png_ptr, &info_ptr,
- &end_info);
+ png_destroy_read_struct(&png_ptr, &info_ptr, &end_info);
fclose(fp);
return ERROR;
}
-Pass (png_infopp)NULL instead of &end_info if you didn't create
-an end_info structure.
+Pass NULL instead of &end_info if you didn't create an end_info
+structure.
If you would rather avoid the complexity of setjmp/longjmp issues,
you can compile libpng with PNG_NO_SETJMP, in which case
@@ -1015,7 +1017,7 @@ You can set up a callback function to handle any unknown chunks in the
input stream. You must supply the function
read_chunk_callback(png_structp png_ptr,
- png_unknown_chunkp chunk);
+ png_unknown_chunkp chunk)
{
/* The unknown chunk structure contains your
chunk data, along with similar data for any other
@@ -1066,9 +1068,9 @@ a progress meter or the like. It's demonstrated in pngtest.c.
You must supply a function
void read_row_callback(png_structp png_ptr,
- png_uint_32 row, int pass);
+ png_uint_32 row, int pass)
{
- /* put your code here */
+ /* put your code here */
}
(You can give it another name that you like instead of "read_row_callback")
@@ -1396,7 +1398,7 @@ described below (the latter being the two common names for associated alpha
color channels). Note that PNG files always contain non-associated color
channels; png_set_alpha_mode() with one of the modes causes the decoder to
convert the pixels to an associated form before returning them to your
-application.
+application.
Since it is not necessary to perform arithmetic on opaque color values so
long as they are not to be resampled and are in the final color space it is
@@ -1699,22 +1701,22 @@ where row_pointers is an array of pointers to the pixel data for each row:
If you know your image size and pixel size ahead of time, you can allocate
row_pointers prior to calling png_read_png() with
- if (height > PNG_UINT_32_MAX/(sizeof (png_byte)))
- png_error (png_ptr,
+ if (height > PNG_UINT_32_MAX / (sizeof (png_bytep)))
+ png_error(png_ptr,
"Image is too tall to process in memory");
- if (width > PNG_UINT_32_MAX/pixel_size)
- png_error (png_ptr,
+ if (width > PNG_UINT_32_MAX / pixel_size)
+ png_error(png_ptr,
"Image is too wide to process in memory");
row_pointers = png_malloc(png_ptr,
height*(sizeof (png_bytep)));
- for (int i=0; i PNG_SIZE_MAX/(width*pixel_size)) {
- png_error(png_ptr,"image_data buffer would be too large");
- }
+ if (height > PNG_SIZE_MAX/(width*pixel_size))
+ png_error(png_ptr, "image_data buffer would be too large");
- png_bytep buffer=png_malloc(png_ptr,height*width*pixel_size);
+ png_bytep buffer = png_malloc(png_ptr,
+ height*width*pixel_size);
- for (int i=0; i= 10504
png_set_scale_16(png_ptr);
#else
png_set_strip_16(png_ptr);
#endif
+ }
(The more accurate "png_set_scale_16()" API became available in libpng version
1.5.4).
@@ -2311,7 +2314,7 @@ the information. If, instead, you want to convert the image to an opaque
version with no alpha channel use png_set_background; see below.
As of libpng version 1.5.2, almost all useful expansions are supported, the
-major ommissions are conversion of grayscale to indexed images (which can be
+major omissions are conversion of grayscale to indexed images (which can be
done trivially in the application) and conversion of indexed to grayscale (which
can be done by a trivial manipulation of the palette.)
@@ -2420,7 +2423,7 @@ Note that png_set_filler() does not change the color type. If you want
to do that, you can add a true alpha channel with
if (color_type == PNG_COLOR_TYPE_RGB ||
- color_type == PNG_COLOR_TYPE_GRAY)
+ color_type == PNG_COLOR_TYPE_GRAY)
png_set_add_alpha(png_ptr, filler, PNG_FILLER_AFTER);
where "filler" contains the alpha value to assign to each pixel.
@@ -2445,7 +2448,7 @@ with alpha.
if (color_type == PNG_COLOR_TYPE_RGB ||
color_type == PNG_COLOR_TYPE_RGB_ALPHA)
png_set_rgb_to_gray(png_ptr, error_action,
- double red_weight, double green_weight);
+ (double)red_weight, (double)green_weight);
error_action = 1: silently do the conversion
@@ -2468,8 +2471,8 @@ In the corresponding fixed point API the red_weight and green_weight values are
simply scaled by 100,000:
png_set_rgb_to_gray(png_ptr, error_action,
- png_fixed_point red_weight,
- png_fixed_point green_weight);
+ (png_fixed_point)red_weight,
+ (png_fixed_point)green_weight);
If you have set error_action = 1 or 2, you can
later check whether the image really was gray, after processing
@@ -2705,9 +2708,8 @@ do your own check for number_of_rows*width*pixel_size if you are using
a multiple-row buffer:
/* Guard against integer overflow */
- if (number_of_rows > PNG_SIZE_MAX/(width*pixel_size)) {
- png_error(png_ptr,"image_data buffer would be too large");
- }
+ if (number_of_rows > PNG_SIZE_MAX/(width*pixel_size))
+ png_error(png_ptr, "image_data buffer would be too large");
Remember: Before you call png_read_update_info(), the png_get_*()
functions return the values corresponding to the original PNG image.
@@ -2927,12 +2929,11 @@ separate.
if (!end_info)
{
- png_destroy_read_struct(&png_ptr, &info_ptr,
- (png_infopp)NULL);
+ png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
return ERROR;
}
- png_read_end(png_ptr, end_info);
+ png_read_end(png_ptr, end_info);
If you are not interested, you should still call png_read_end()
but you can pass NULL, avoiding the need to create an end_info structure.
@@ -2940,7 +2941,7 @@ If you do this, libpng will not process any chunks after IDAT other than
skipping over them and perhaps (depending on whether you have called
png_set_crc_action) checking their CRCs while looking for the IEND chunk.
- png_read_end(png_ptr, (png_infop)NULL);
+ png_read_end(png_ptr, NULL);
If you don't call png_read_end(), then your file pointer will be
left pointing to the first chunk after the last IDAT, which is probably
@@ -2949,13 +2950,11 @@ the PNG datastream.
When you are done, you can free all memory allocated by libpng like this:
- png_destroy_read_struct(&png_ptr, &info_ptr,
- &end_info);
+ png_destroy_read_struct(&png_ptr, &info_ptr, &end_info);
or, if you didn't create an end_info structure,
- png_destroy_read_struct(&png_ptr, &info_ptr,
- (png_infopp)NULL);
+ png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
It is also possible to individually free the info_ptr members that
point to libpng-allocated storage with the following function:
@@ -3075,15 +3074,13 @@ png_infop info_ptr;
if (!info_ptr)
{
- png_destroy_read_struct(&png_ptr,
- (png_infopp)NULL, (png_infopp)NULL);
+ png_destroy_read_struct(&png_ptr, NULL, NULL);
return ERROR;
}
if (setjmp(png_jmpbuf(png_ptr)))
{
- png_destroy_read_struct(&png_ptr, &info_ptr,
- (png_infopp)NULL);
+ png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
return ERROR;
}
@@ -3116,8 +3113,7 @@ png_infop info_ptr;
{
if (setjmp(png_jmpbuf(png_ptr)))
{
- png_destroy_read_struct(&png_ptr, &info_ptr,
- (png_infopp)NULL);
+ png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
return ERROR;
}
@@ -3282,8 +3278,7 @@ both "png_ptr"; you can call them anything you like, such as
png_infop info_ptr = png_create_info_struct(png_ptr);
if (!info_ptr)
{
- png_destroy_write_struct(&png_ptr,
- (png_infopp)NULL);
+ png_destroy_write_struct(&png_ptr, NULL);
return ERROR;
}
@@ -3309,7 +3304,7 @@ section below for more information on the libpng error handling.
if (setjmp(png_jmpbuf(png_ptr)))
{
- png_destroy_write_struct(&png_ptr, &info_ptr);
+ png_destroy_write_struct(&png_ptr, &info_ptr);
fclose(fp);
return ERROR;
}
@@ -3363,9 +3358,9 @@ a progress meter or the like. It's demonstrated in pngtest.c.
You must supply a function
void write_row_callback(png_structp png_ptr, png_uint_32 row,
- int pass);
+ int pass)
{
- /* put your code here */
+ /* put your code here */
}
(You can give it another name that you like instead of "write_row_callback")
@@ -3635,8 +3630,8 @@ width, height, bit_depth, and color_type must be the same in each call.
png_set_eXIf_1(png_ptr, info_ptr, num_exif, exif);
- exif - Exif profile (array of
- png_byte) (PNG_INFO_eXIf)
+ exif - Exif profile (array of png_byte)
+ (PNG_INFO_eXIf)
png_set_hIST(png_ptr, info_ptr, hist);
@@ -3646,12 +3641,12 @@ width, height, bit_depth, and color_type must be the same in each call.
png_set_tIME(png_ptr, info_ptr, mod_time);
mod_time - time image was last modified
- (PNG_VALID_tIME)
+ (PNG_INFO_tIME)
png_set_bKGD(png_ptr, info_ptr, background);
background - background color (of type
- png_color_16p) (PNG_VALID_bKGD)
+ png_color_16p) (PNG_INFO_bKGD)
png_set_text(png_ptr, info_ptr, text_ptr, num_text);
@@ -3879,19 +3874,6 @@ Here is an example of writing two private chunks, prVt and miNE:
/* Needed because miNE is not safe-to-copy */
png_set_keep_unknown_chunks(png, PNG_HANDLE_CHUNK_ALWAYS,
(png_bytep) "miNE", 1);
- # if PNG_LIBPNG_VER < 10600
- /* Deal with unknown chunk location bug in 1.5.x and earlier */
- png_set_unknown_chunk_location(png, info, 0, PNG_HAVE_IHDR);
- png_set_unknown_chunk_location(png, info, 1, PNG_AFTER_IDAT);
- # endif
- # if PNG_LIBPNG_VER < 10500
- /* PNG_AFTER_IDAT writes two copies of the chunk prior to libpng-1.5.0,
- * one before IDAT and another after IDAT, so don't use it; only use
- * PNG_HAVE_IHDR location. This call resets the location previously
- * set by assignment and png_set_unknown_chunk_location() for chunk 1.
- */
- png_set_unknown_chunk_location(png, info, 1, PNG_HAVE_IHDR);
- # endif
#endif
.SS The high-level write interface
@@ -4617,7 +4599,7 @@ READ APIs
is filled in from the PNG header in the file.
int png_image_begin_read_from_stdio (png_imagep image,
- FILE* file)
+ FILE *file)
The PNG header is read from the stdio FILE object.
@@ -4692,7 +4674,7 @@ be written:
int convert_to_8_bit, const void *buffer,
png_int_32 row_stride, const void *colormap)
- Write the image to the given (FILE*).
+ Write the image to the given FILE object.
With all write APIs if image is in one of the linear formats with
(png_uint_16) data then setting convert_to_8_bit will cause the output to be
@@ -4737,7 +4719,7 @@ png_create_read_struct_2() or png_create_write_struct_2() to register your
own functions as described above. These functions also provide a void
pointer that can be retrieved via
- mem_ptr=png_get_mem_ptr(png_ptr);
+ mem_ptr = png_get_mem_ptr(png_ptr);
Your replacement memory functions must have prototypes as follows:
@@ -5034,7 +5016,7 @@ When PNG_DEBUG is defined but is zero, the macros aren't defined, but you
can still use PNG_DEBUG to control your own debugging:
#ifdef PNG_DEBUG
- fprintf(stderr, ...
+ fprintf(stderr, ...);
#endif
When PNG_DEBUG = 1, the macros are defined, but only png_debug statements
@@ -5211,7 +5193,7 @@ deprecated since libpng-1.0.16 and libpng-1.2.6.
The function
png_check_sig(sig, num)
was replaced with
- !png_sig_cmp(sig, 0, num)
+ png_sig_cmp(sig, 0, num) == 0
It has been deprecated since libpng-0.90.
The function
@@ -5275,8 +5257,8 @@ png_get_mmx_bitdepth_threshold(), png_get_mmx_rowbytes_threshold(),
png_set_asm_flags(), and png_mmx_supported()
We removed the obsolete png_check_sig(), png_memcpy_check(), and
-png_memset_check() functions. Instead use !png_sig_cmp(), memcpy(),
-and memset(), respectively.
+png_memset_check() functions. Instead use png_sig_cmp() == 0,
+memcpy(), and memset(), respectively.
The function png_set_gray_1_2_4_to_8() was removed. It has been
deprecated since libpng-1.0.18 and 1.2.9, when it was replaced with
@@ -5701,7 +5683,7 @@ a pre-existing bug where the per-chunk 'keep' setting is ignored, and makes
it possible to skip IDAT chunks in the sequential reader.
The machine-generated configure files are no longer included in branches
-libpng16 and later of the GIT repository. They continue to be included
+libpng17 and later of the GIT repository. They continue to be included
in the tarball releases, however.
Libpng-1.6.0 through 1.6.2 used the CMF bytes at the beginning of the IDAT
@@ -5758,7 +5740,7 @@ changed, and is unaffected by conditional compilation macros. It is the
best choice for use in configure scripts for detecting the presence of any
libpng version since 0.88. In an autoconf "configure.in" you could use
- AC_CHECK_LIB(png, png_get_io_ptr, ...
+ AC_CHECK_LIB(png, png_get_io_ptr, ...)
.SH XV. Source code repository
@@ -5767,12 +5749,12 @@ control. The git repository was built from old libpng-x.y.z.tar.gz files
going back to version 0.70. You can access the git repository (read only)
at
- https://github.com/glennrp/libpng or
+ https://github.com/pnggroup/libpng or
https://git.code.sf.net/p/libpng/code.git
or you can browse it with a web browser at
- https://github.com/glennrp/libpng or
+ https://github.com/pnggroup/libpng or
https://sourceforge.net/p/libpng/code/ci/libpng16/tree/
Patches can be sent to png-mng-implement at lists.sourceforge.net or
@@ -5782,7 +5764,7 @@ uploaded to the libpng bug tracker at
or as a "pull request" to
- https://github.com/glennrp/libpng/pulls
+ https://github.com/pnggroup/libpng/pulls
We also accept patches built from the tar or zip distributions, and
simple verbal descriptions of bug fixes, reported either to the
@@ -5995,35 +5977,25 @@ letter, until version 1.0.6j; from then on they were given the upcoming
public release number plus "betaNN" or "rcNN".
.SH "SEE ALSO"
-.IR libpngpf(3) ", " png(5)
-.LP
-.IR libpng :
+.BR "png"(5)
.IP
-https://libpng.sourceforge.io/ (follow the [DOWNLOAD] link)
-http://www.libpng.org/pub/png
-
+The PNG (Portable Network Graphics) format specification.
.LP
-.IR zlib :
+.B libpng
.IP
-(generally) at the same location as
-.I libpng
-or at
+http://www.libpng.org/pub/png/libpng.html (canonical home page)
.br
-https://zlib.net/
-
+https://github.com/pnggroup/libpng (canonical Git repository)
+.br
+https://libpng.sourceforge.io (downloadable archives)
.LP
-.IR PNG specification: RFC 2083
+.B zlib
.IP
-(generally) at the same location as
-.I libpng
-or at
+https://zlib.net (canonical home page)
.br
-https://www.ietf.org/rfc/rfc2083.txt
+https://github.com/madler/zlib (canonical Git repository)
.br
-or (as a W3C Recommendation) at
-.br
-https://www.w3.org/TR/REC-png.html
-
+A copy of zlib may also be found at the same location as libpng.
.LP
In the case of any inconsistency between the PNG specification
and this library, the specification takes precedence.
@@ -6043,10 +6015,10 @@ Libpng:
Initially created in 1995 by Guy Eric Schalnat, then of Group 42, Inc.
Maintained by Cosmin Truta.
-Supported by the PNG development group
+Supported by the PNG development group.
.br
-png-mng-implement at lists.sourceforge.net (subscription required; visit
-https://lists.sourceforge.net/lists/listinfo/png-mng-implement
-to subscribe).
+png-mng-implement at lists.sourceforge.net. (Subscription is required;
+visit https://lists.sourceforge.net/lists/listinfo/png-mng-implement
+to subscribe.)
.\" end of man page
diff --git a/src/libs/Irrlicht/irrlicht-svn/source/Irrlicht/libpng/libpngpf.3 b/src/libs/Irrlicht/irrlicht-svn/source/Irrlicht/libpng/libpngpf.3
index 13b5cf07..bc48c1b7 100644
--- a/src/libs/Irrlicht/irrlicht-svn/source/Irrlicht/libpng/libpngpf.3
+++ b/src/libs/Irrlicht/irrlicht-svn/source/Irrlicht/libpng/libpngpf.3
@@ -1,24 +1,17 @@
-.TH LIBPNGPF 3 "April 14, 2019"
+.TH LIBPNGPF 3 "January 12, 2026"
.SH NAME
-libpng \- Portable Network Graphics (PNG) Reference Library 1.6.37
-(private functions)
+libpng \- Portable Network Graphics (PNG) Reference Library 1.6.54
.SH SYNOPSIS
-\fB#include \fI"pngpriv.h"
-
-\fBAs of libpng version \fP\fI1.5.1\fP\fB, this section is no longer
-\fP\fImaintained\fP\fB, now that the private function prototypes are hidden in
-\fP\fIpngpriv.h\fP\fB and not accessible to applications. Look in
-\fP\fIpngpriv.h\fP\fB for the prototypes and a short description of each
-function.
+\fB#include "pngpriv.h"\fP
.SH DESCRIPTION
-The functions previously listed here are used privately by libpng and are not
-available for use by applications. They are not "exported" to applications
-using shared libraries.
+As of libpng version 1.5.1, this manual is no longer maintained. The private
+function prototypes, declared in private header files, should not be accessed
+by applications.
.SH "SEE ALSO"
-.BR "png"(5), " libpng"(3), " zlib"(3), " deflate"(5), " " and " zlib"(5)
+.BR "libpng"(3)
.SH AUTHORS
Cosmin Truta, Glenn Randers-Pehrson
diff --git a/src/libs/Irrlicht/irrlicht-svn/source/Irrlicht/libpng/png.5 b/src/libs/Irrlicht/irrlicht-svn/source/Irrlicht/libpng/png.5
index fa025f89..c691c116 100644
--- a/src/libs/Irrlicht/irrlicht-svn/source/Irrlicht/libpng/png.5
+++ b/src/libs/Irrlicht/irrlicht-svn/source/Irrlicht/libpng/png.5
@@ -1,4 +1,4 @@
-.TH PNG 5 "April 14, 2019"
+.TH PNG 5 "January 12, 2026"
.SH NAME
png \- Portable Network Graphics (PNG) format
@@ -6,79 +6,76 @@ png \- Portable Network Graphics (PNG) format
PNG (Portable Network Graphics) is an extensible file format for the
lossless, portable, well-compressed storage of raster images. PNG
provides a patent-free replacement for GIF, and can also replace many
-common uses of TIFF. Indexed-color, grayscale, and truecolor images are
-supported, plus an optional alpha channel. Sample depths range from
-1 to 16 bits.
-.br
+common uses of TIFF. Indexed-color, grayscale, and truecolor images
+are supported, plus an optional alpha channel. Sample depths range
+from 1 to 16 bits.
+.P
PNG is designed to work well in online viewing applications, such
as the World Wide Web, so it is fully streamable with a progressive
display option. PNG is robust, providing both full file integrity
checking and fast, simple detection of common transmission errors.
-Also, PNG can store gamma and chromaticity data for improved color
-matching on heterogeneous platforms.
+Also, PNG can store color space data for improved color matching on
+heterogeneous platforms.
.SH "SEE ALSO"
-.BR "libpng"(3), " libpngpf"(3), " zlib"(3), " deflate"(5), " " and " zlib"(5)
+.BR "libpng"(3), " zlib"(3), " deflate"(5), " " and " zlib"(5)
.LP
-PNG Specification (Second Edition), November 2003:
+Portable Network Graphics (PNG) Specification (Third Edition):
.IP
.br
+W3C Recommendation 24 June 2025
+.br
+https://www.w3.org/TR/2025/REC-png-3-20250624/
+.LP
+Portable Network Graphics (PNG) Specification (Second Edition):
+.IP
+.br
+ISO/IEC 15948:2004(E)
+.br
+https://www.iso.org/standard/29581.html
+.IP
+.br
+W3C Recommendation 10 November 2003
+.br
https://www.w3.org/TR/2003/REC-PNG-20031110/
.LP
-PNG 1.2 Specification, July 1999:
+Portable Network Graphics (PNG) Specification Version 1.2:
+.IP
+.br
+Published by the PNG Development Group on 14 July 1999
+.br
+https://www.libpng.org/pub/png/spec/1.2/
+.LP
+Portable Network Graphics (PNG) Specification Version 1.1:
.IP
.br
-https://png-mng.sourceforge.io/pub/png/spec/1.2/
+Published by the PNG Development Group on 15 February 1999
+.br
+https://www.libpng.org/pub/png/spec/1.1/
.LP
-PNG 1.0 Specification, October 1996:
+Portable Network Graphics (PNG) Specification Version 1.0:
.IP
.br
-RFC 2083
+IETF RFC 2083, March 1997
.br
https://www.ietf.org/rfc/rfc2083.txt
.IP
.br
-or W3C Recommendation
+W3C Recommendation 1 October 1996
.br
https://www.w3.org/TR/REC-png-961001
.SH AUTHORS
-This man page: Cosmin Truta, Glenn Randers-Pehrson
+This man page: Glenn Randers-Pehrson, Cosmin Truta, Chris Lilley.
.LP
-Portable Network Graphics (PNG) Specification (Second Edition)
-Information technology - Computer graphics and image processing -
-Portable Network Graphics (PNG): Functional specification.
-ISO/IEC 15948:2003 (E) (November 10, 2003): David Duce and others.
+PNG Specification (Third Edition): Chris Blume et al.
.LP
-Portable Network Graphics (PNG) Specification Version 1.2 (July 8, 1999):
-Glenn Randers-Pehrson and others (png-list).
+PNG Specification (Second Edition): David Duce et al.
.LP
-Portable Network Graphics (PNG) Specification Version 1.0 (October 1, 1996):
-Thomas Boutell and others (png-list).
-
-.SH COPYRIGHT
+PNG Specification Version 1.2: Glenn Randers-Pehrson et al.
.LP
-This man page is
-.br
-Copyright (c) 2018-2019 Cosmin Truta.
-.br
-Copyright (c) 1998-2006 Glenn Randers-Pehrson.
-.br
-See png.h for conditions of use and distribution.
-.LP
-The PNG Specification (Second Edition) is
-.br
-Copyright (c) 2003 W3C. (MIT, ERCIM, Keio), All Rights Reserved.
+PNG Specification Version 1.1: Glenn Randers-Pehrson et al.
.LP
-The PNG-1.2 Specification is
-.br
-Copyright (c) 1999 Glenn Randers-Pehrson.
-.br
-See the specification for conditions of use and distribution.
-.LP
-The PNG-1.0 Specification is
-.br
-Copyright (c) 1996 Massachusetts Institute of Technology.
-.br
-See the specification for conditions of use and distribution.
+PNG Specification Version 1.0: Thomas Boutell et al.
+
.\" end of man page
diff --git a/src/libs/Irrlicht/irrlicht-svn/source/Irrlicht/libpng/png.c b/src/libs/Irrlicht/irrlicht-svn/source/Irrlicht/libpng/png.c
index d5e9e18b..e66d8b77 100644
--- a/src/libs/Irrlicht/irrlicht-svn/source/Irrlicht/libpng/png.c
+++ b/src/libs/Irrlicht/irrlicht-svn/source/Irrlicht/libpng/png.c
@@ -1,7 +1,6 @@
-
/* png.c - location for general purpose libpng functions
*
- * Copyright (c) 2018-2019 Cosmin Truta
+ * Copyright (c) 2018-2026 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,28 +13,35 @@
#include "pngpriv.h"
/* Generate a compiler error if there is an old png.h in the search path. */
-typedef png_libpng_version_1_6_37 Your_png_h_is_not_version_1_6_37;
-
-#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.
+typedef png_libpng_version_1_6_54 Your_png_h_is_not_version_1_6_54;
+
+/* Sanity check the chunks definitions - PNG_KNOWN_CHUNKS from pngpriv.h and the
+ * corresponding macro definitions. This causes a compile time failure if
+ * something is wrong but generates no code.
+ *
+ * (1) The first check is that the PNG_CHUNK(cHNK, index) 'index' values must
+ * increment from 0 to the last value.
+ */
+#define PNG_CHUNK(cHNK, index) != (index) || ((index)+1)
+
+#if 0 PNG_KNOWN_CHUNKS < 0
+# error PNG_KNOWN_CHUNKS chunk definitions are not in order
+#endif
+
+#undef PNG_CHUNK
+
+/* (2) The chunk name macros, png_cHNK, must all be valid and defined. Since
+ * this is a preprocessor test undefined pp-tokens come out as zero and will
+ * fail this test.
*/
-#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
+#define PNG_CHUNK(cHNK, index) !PNG_CHUNK_NAME_VALID(png_ ## cHNK) ||
+
+#if PNG_KNOWN_CHUNKS 0
+# error png_cHNK not defined for some known cHNK
#endif
+#undef PNG_CHUNK
+
/* 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
* stream we can set num_bytes = 8 so that libpng will not attempt to read
@@ -73,21 +79,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 */
@@ -95,17 +101,24 @@ png_sig_cmp(png_const_bytep sig, size_t start, size_t num_to_check)
#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED)
/* Function to allocate memory for zlib */
PNG_FUNCTION(voidpf /* PRIVATE */,
-png_zalloc,(voidpf png_ptr, uInt items, uInt size),PNG_ALLOCATED)
+png_zalloc,(voidpf png_ptr, uInt items, uInt size),
+ PNG_ALLOCATED)
{
png_alloc_size_t num_bytes = size;
if (png_ptr == NULL)
return NULL;
- if (items >= (~(png_alloc_size_t)0)/size)
+ /* This check against overflow is vestigial, dating back from
+ * the old times when png_zalloc used to be an exported function.
+ * We're still keeping it here for now, as an extra-cautious
+ * prevention against programming errors inside zlib, although it
+ * should rather be a debug-time assertion instead.
+ */
+ if (size != 0 && items >= (~(png_alloc_size_t)0) / size)
{
- png_warning (png_voidcast(png_structrp, png_ptr),
- "Potential overflow in png_zalloc()");
+ png_warning(png_voidcast(png_structrp, png_ptr),
+ "Potential overflow in png_zalloc()");
return NULL;
}
@@ -232,10 +245,6 @@ png_user_version_check(png_structrp png_ptr, png_const_charp user_png_ver)
png_warning(png_ptr, m);
#endif
-#ifdef PNG_ERROR_NUMBERS_SUPPORTED
- png_ptr->flags = 0;
-#endif
-
return 0;
}
@@ -249,7 +258,8 @@ png_user_version_check(png_structrp png_ptr, png_const_charp user_png_ver)
PNG_FUNCTION(png_structp /* PRIVATE */,
png_create_png_struct,(png_const_charp user_png_ver, png_voidp error_ptr,
png_error_ptr error_fn, png_error_ptr warn_fn, png_voidp mem_ptr,
- png_malloc_ptr malloc_fn, png_free_ptr free_fn),PNG_ALLOCATED)
+ png_malloc_ptr malloc_fn, png_free_ptr free_fn),
+ PNG_ALLOCATED)
{
png_struct create_struct;
# ifdef PNG_SETJMP_SUPPORTED
@@ -262,21 +272,23 @@ png_create_png_struct,(png_const_charp user_png_ver, png_voidp error_ptr,
*/
memset(&create_struct, 0, (sizeof create_struct));
- /* Added at libpng-1.2.6 */
# ifdef PNG_USER_LIMITS_SUPPORTED
create_struct.user_width_max = PNG_USER_WIDTH_MAX;
create_struct.user_height_max = PNG_USER_HEIGHT_MAX;
# ifdef PNG_USER_CHUNK_CACHE_MAX
- /* Added at libpng-1.2.43 and 1.4.0 */
create_struct.user_chunk_cache_max = PNG_USER_CHUNK_CACHE_MAX;
# endif
-# ifdef PNG_USER_CHUNK_MALLOC_MAX
- /* Added at libpng-1.2.43 and 1.4.1, required only for read but exists
- * in png_struct regardless.
- */
+# if PNG_USER_CHUNK_MALLOC_MAX > 0 /* default to compile-time limit */
create_struct.user_chunk_malloc_max = PNG_USER_CHUNK_MALLOC_MAX;
+
+ /* No compile-time limit, so initialize to the system limit: */
+# elif defined PNG_MAX_MALLOC_64K /* legacy system limit */
+ create_struct.user_chunk_malloc_max = 65536U;
+
+# else /* modern system limit SIZE_MAX (C99) */
+ create_struct.user_chunk_malloc_max = PNG_SIZE_MAX;
# endif
# endif
@@ -351,7 +363,8 @@ png_create_png_struct,(png_const_charp user_png_ver, png_voidp error_ptr,
/* Allocate the memory for an info_struct for the application. */
PNG_FUNCTION(png_infop,PNGAPI
-png_create_info_struct,(png_const_structrp png_ptr),PNG_ALLOCATED)
+png_create_info_struct,(png_const_structrp png_ptr),
+ PNG_ALLOCATED)
{
png_inforp info_ptr;
@@ -447,7 +460,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)
@@ -619,13 +631,6 @@ png_free_data(png_const_structrp png_ptr, png_inforp info_ptr, png_uint_32 mask,
/* Free any eXIf entry */
if (((mask & PNG_FREE_EXIF) & info_ptr->free_me) != 0)
{
-# ifdef PNG_READ_eXIf_SUPPORTED
- if (info_ptr->eXIf_buf)
- {
- png_free(png_ptr, info_ptr->eXIf_buf);
- info_ptr->eXIf_buf = NULL;
- }
-# endif
if (info_ptr->exif)
{
png_free(png_ptr, info_ptr->exif);
@@ -686,9 +691,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)
@@ -700,7 +705,7 @@ png_get_io_ptr(png_const_structrp png_ptr)
* function of your own because "FILE *" isn't necessarily available.
*/
void PNGAPI
-png_init_io(png_structrp png_ptr, png_FILE_p fp)
+png_init_io(png_structrp png_ptr, FILE *fp)
{
png_debug(1, "in png_init_io");
@@ -720,7 +725,7 @@ png_init_io(png_structrp png_ptr, png_FILE_p fp)
*
* Where UNSIGNED_MAX is the appropriate maximum unsigned value, so when the
* negative integral value is added the result will be an unsigned value
- * correspnding to the 2's complement representation.
+ * corresponding to the 2's complement representation.
*/
void PNGAPI
png_save_int_32(png_bytep buf, png_int_32 i)
@@ -752,7 +757,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 +820,8 @@ png_get_copyright(png_const_structrp png_ptr)
return PNG_STRING_COPYRIGHT
#else
return PNG_STRING_NEWLINE \
- "libpng version 1.6.37" PNG_STRING_NEWLINE \
- "Copyright (c) 2018-2019 Cosmin Truta" PNG_STRING_NEWLINE \
+ "libpng version 1.6.54" PNG_STRING_NEWLINE \
+ "Copyright (c) 2018-2026 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 +982,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 +991,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)
@@ -1060,210 +1065,132 @@ png_zstream_error(png_structrp png_ptr, int ret)
}
}
-/* png_convert_size: a PNGAPI but no longer in png.h, so deleted
- * at libpng 1.5.5!
- */
-
-/* Added at libpng version 1.2.34 and 1.4.0 (moved from pngset.c) */
-#ifdef PNG_GAMMA_SUPPORTED /* always set if COLORSPACE */
-static int
-png_colorspace_check_gamma(png_const_structrp png_ptr,
- png_colorspacerp colorspace, png_fixed_point gAMA, int from)
- /* This is called to check a new gamma value against an existing one. The
- * routine returns false if the new gamma value should not be written.
- *
- * 'from' says where the new gamma value comes from:
- *
- * 0: the new gamma value is the libpng estimate for an ICC profile
- * 1: the new gamma value comes from a gAMA chunk
- * 2: the new gamma value comes from an sRGB chunk
- */
+#ifdef PNG_COLORSPACE_SUPPORTED
+static png_int_32
+png_fp_add(png_int_32 addend0, png_int_32 addend1, int *error)
{
- png_fixed_point gtest;
-
- if ((colorspace->flags & PNG_COLORSPACE_HAVE_GAMMA) != 0 &&
- (png_muldiv(>est, colorspace->gamma, PNG_FP_1, gAMA) == 0 ||
- png_gamma_significant(gtest) != 0))
+ /* Safely add two fixed point values setting an error flag and returning 0.5
+ * on overflow.
+ * IMPLEMENTATION NOTE: ANSI requires signed overflow not to occur, therefore
+ * relying on addition of two positive values producing a negative one is not
+ * safe.
+ */
+ if (addend0 > 0)
{
- /* Either this is an sRGB image, in which case the calculated gamma
- * approximation should match, or this is an image with a profile and the
- * value libpng calculates for the gamma of the profile does not match the
- * value recorded in the file. The former, sRGB, case is an error, the
- * latter is just a warning.
- */
- if ((colorspace->flags & PNG_COLORSPACE_FROM_sRGB) != 0 || from == 2)
- {
- png_chunk_report(png_ptr, "gamma value does not match sRGB",
- PNG_CHUNK_ERROR);
- /* Do not overwrite an sRGB value */
- return from == 2;
- }
-
- else /* sRGB tag not involved */
- {
- png_chunk_report(png_ptr, "gamma value does not match libpng estimate",
- PNG_CHUNK_WARNING);
- return from == 1;
- }
+ if (0x7fffffff - addend0 >= addend1)
+ return addend0+addend1;
}
-
- return 1;
-}
-
-void /* PRIVATE */
-png_colorspace_set_gamma(png_const_structrp png_ptr,
- png_colorspacerp colorspace, png_fixed_point gAMA)
-{
- /* Changed in libpng-1.5.4 to limit the values to ensure overflow can't
- * occur. Since the fixed point representation is asymmetrical it is
- * possible for 1/gamma to overflow the limit of 21474 and this means the
- * gamma value must be at least 5/100000 and hence at most 20000.0. For
- * safety the limits here are a little narrower. The values are 0.00016 to
- * 6250.0, which are truly ridiculous gamma values (and will produce
- * displays that are all black or all white.)
- *
- * In 1.6.0 this test replaces the ones in pngrutil.c, in the gAMA chunk
- * handling code, which only required the value to be >0.
- */
- png_const_charp errmsg;
-
- if (gAMA < 16 || gAMA > 625000000)
- errmsg = "gamma value out of range";
-
-# ifdef PNG_READ_gAMA_SUPPORTED
- /* Allow the application to set the gamma value more than once */
- else if ((png_ptr->mode & PNG_IS_READ_STRUCT) != 0 &&
- (colorspace->flags & PNG_COLORSPACE_FROM_gAMA) != 0)
- errmsg = "duplicate";
-# endif
-
- /* Do nothing if the colorspace is already invalid */
- else if ((colorspace->flags & PNG_COLORSPACE_INVALID) != 0)
- return;
-
- else
+ else if (addend0 < 0)
{
- if (png_colorspace_check_gamma(png_ptr, colorspace, gAMA,
- 1/*from gAMA*/) != 0)
- {
- /* Store this gamma value. */
- colorspace->gamma = gAMA;
- colorspace->flags |=
- (PNG_COLORSPACE_HAVE_GAMMA | PNG_COLORSPACE_FROM_gAMA);
- }
-
- /* At present if the check_gamma test fails the gamma of the colorspace is
- * not updated however the colorspace is not invalidated. This
- * corresponds to the case where the existing gamma comes from an sRGB
- * chunk or profile. An error message has already been output.
- */
- return;
+ if (-0x7fffffff - addend0 <= addend1)
+ return addend0+addend1;
}
+ else
+ return addend1;
- /* Error exit - errmsg has been set. */
- colorspace->flags |= PNG_COLORSPACE_INVALID;
- png_chunk_report(png_ptr, errmsg, PNG_CHUNK_WRITE_ERROR);
+ *error = 1;
+ return PNG_FP_1/2;
}
-void /* PRIVATE */
-png_colorspace_sync_info(png_const_structrp png_ptr, png_inforp info_ptr)
+static png_int_32
+png_fp_sub(png_int_32 addend0, png_int_32 addend1, int *error)
{
- if ((info_ptr->colorspace.flags & PNG_COLORSPACE_INVALID) != 0)
+ /* As above but calculate addend0-addend1. */
+ if (addend1 > 0)
{
- /* Everything is invalid */
- info_ptr->valid &= ~(PNG_INFO_gAMA|PNG_INFO_cHRM|PNG_INFO_sRGB|
- PNG_INFO_iCCP);
-
-# ifdef PNG_COLORSPACE_SUPPORTED
- /* Clean up the iCCP profile now if it won't be used. */
- png_free_data(png_ptr, info_ptr, PNG_FREE_ICCP, -1/*not used*/);
-# else
- PNG_UNUSED(png_ptr)
-# endif
+ if (-0x7fffffff + addend1 <= addend0)
+ return addend0-addend1;
}
-
- else
+ else if (addend1 < 0)
{
-# ifdef PNG_COLORSPACE_SUPPORTED
- /* Leave the INFO_iCCP flag set if the pngset.c code has already set
- * it; this allows a PNG to contain a profile which matches sRGB and
- * yet still have that profile retrievable by the application.
- */
- if ((info_ptr->colorspace.flags & PNG_COLORSPACE_MATCHES_sRGB) != 0)
- info_ptr->valid |= PNG_INFO_sRGB;
-
- else
- info_ptr->valid &= ~PNG_INFO_sRGB;
-
- if ((info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_ENDPOINTS) != 0)
- info_ptr->valid |= PNG_INFO_cHRM;
-
- else
- info_ptr->valid &= ~PNG_INFO_cHRM;
-# endif
-
- if ((info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_GAMMA) != 0)
- info_ptr->valid |= PNG_INFO_gAMA;
-
- else
- info_ptr->valid &= ~PNG_INFO_gAMA;
+ if (0x7fffffff + addend1 >= addend0)
+ return addend0-addend1;
}
+ else
+ return addend0;
+
+ *error = 1;
+ return PNG_FP_1/2;
}
-#ifdef PNG_READ_SUPPORTED
-void /* PRIVATE */
-png_colorspace_sync(png_const_structrp png_ptr, png_inforp info_ptr)
+static int
+png_safe_add(png_int_32 *addend0_and_result, png_int_32 addend1,
+ png_int_32 addend2)
{
- if (info_ptr == NULL) /* reduce code size; check here not in the caller */
- return;
-
- info_ptr->colorspace = png_ptr->colorspace;
- png_colorspace_sync_info(png_ptr, info_ptr);
+ /* Safely add three integers. Returns 0 on success, 1 on overflow. Does not
+ * set the result on overflow.
+ */
+ int error = 0;
+ int result = png_fp_add(*addend0_and_result,
+ png_fp_add(addend1, addend2, &error),
+ &error);
+ if (!error) *addend0_and_result = result;
+ return error;
}
-#endif
-#endif /* GAMMA */
-#ifdef PNG_COLORSPACE_SUPPORTED
/* Added at libpng-1.5.5 to support read and write of true CIEXYZ values for
* cHRM, as opposed to using chromaticities. These internal APIs return
* non-zero on a parameter error. The X, Y and Z values are required to be
* positive and less than 1.0.
*/
-static int
+int /* PRIVATE */
png_xy_from_XYZ(png_xy *xy, const png_XYZ *XYZ)
{
- png_int_32 d, dwhite, whiteX, whiteY;
+ /* NOTE: returns 0 on success, 1 means error. */
+ png_int_32 d, dred, dgreen, dblue, dwhite, whiteX, whiteY;
- d = XYZ->red_X + XYZ->red_Y + XYZ->red_Z;
- if (png_muldiv(&xy->redx, XYZ->red_X, PNG_FP_1, d) == 0)
+ /* 'd' in each of the blocks below is just X+Y+Z for each component,
+ * x, y and z are X,Y,Z/(X+Y+Z).
+ */
+ d = XYZ->red_X;
+ if (png_safe_add(&d, XYZ->red_Y, XYZ->red_Z))
return 1;
- if (png_muldiv(&xy->redy, XYZ->red_Y, PNG_FP_1, d) == 0)
+ dred = d;
+ if (png_muldiv(&xy->redx, XYZ->red_X, PNG_FP_1, dred) == 0)
+ return 1;
+ if (png_muldiv(&xy->redy, XYZ->red_Y, PNG_FP_1, dred) == 0)
return 1;
- dwhite = d;
- whiteX = XYZ->red_X;
- whiteY = XYZ->red_Y;
- d = XYZ->green_X + XYZ->green_Y + XYZ->green_Z;
- if (png_muldiv(&xy->greenx, XYZ->green_X, PNG_FP_1, d) == 0)
+ d = XYZ->green_X;
+ if (png_safe_add(&d, XYZ->green_Y, XYZ->green_Z))
return 1;
- if (png_muldiv(&xy->greeny, XYZ->green_Y, PNG_FP_1, d) == 0)
+ dgreen = d;
+ if (png_muldiv(&xy->greenx, XYZ->green_X, PNG_FP_1, dgreen) == 0)
+ return 1;
+ if (png_muldiv(&xy->greeny, XYZ->green_Y, PNG_FP_1, dgreen) == 0)
return 1;
- dwhite += d;
- whiteX += XYZ->green_X;
- whiteY += XYZ->green_Y;
- d = XYZ->blue_X + XYZ->blue_Y + XYZ->blue_Z;
- if (png_muldiv(&xy->bluex, XYZ->blue_X, PNG_FP_1, d) == 0)
+ d = XYZ->blue_X;
+ if (png_safe_add(&d, XYZ->blue_Y, XYZ->blue_Z))
+ return 1;
+ dblue = d;
+ if (png_muldiv(&xy->bluex, XYZ->blue_X, PNG_FP_1, dblue) == 0)
+ return 1;
+ if (png_muldiv(&xy->bluey, XYZ->blue_Y, PNG_FP_1, dblue) == 0)
return 1;
- if (png_muldiv(&xy->bluey, XYZ->blue_Y, PNG_FP_1, d) == 0)
+
+ /* The reference white is simply the sum of the end-point (X,Y,Z) vectors so
+ * the fillowing calculates (X+Y+Z) of the reference white (media white,
+ * encoding white) itself:
+ */
+ d = dblue;
+ if (png_safe_add(&d, dred, dgreen))
return 1;
- dwhite += d;
- whiteX += XYZ->blue_X;
- whiteY += XYZ->blue_Y;
+ dwhite = d;
- /* The reference white is simply the sum of the end-point (X,Y,Z) vectors,
- * thus:
+ /* Find the white X,Y values from the sum of the red, green and blue X,Y
+ * values.
*/
+ d = XYZ->red_X;
+ if (png_safe_add(&d, XYZ->green_X, XYZ->blue_X))
+ return 1;
+ whiteX = d;
+
+ d = XYZ->red_Y;
+ if (png_safe_add(&d, XYZ->green_Y, XYZ->blue_Y))
+ return 1;
+ whiteY = d;
+
if (png_muldiv(&xy->whitex, whiteX, PNG_FP_1, dwhite) == 0)
return 1;
if (png_muldiv(&xy->whitey, whiteY, PNG_FP_1, dwhite) == 0)
@@ -1272,9 +1199,10 @@ png_xy_from_XYZ(png_xy *xy, const png_XYZ *XYZ)
return 0;
}
-static int
+int /* PRIVATE */
png_XYZ_from_xy(png_XYZ *XYZ, const png_xy *xy)
{
+ /* NOTE: returns 0 on success, 1 means error. */
png_fixed_point red_inverse, green_inverse, blue_scale;
png_fixed_point left, right, denominator;
@@ -1282,15 +1210,24 @@ png_XYZ_from_xy(png_XYZ *XYZ, const png_xy *xy)
* have end points with 0 tristimulus values (these are impossible end
* points, but they are used to cover the possible colors). We check
* xy->whitey against 5, not 0, to avoid a possible integer overflow.
+ *
+ * The limits here will *not* accept ACES AP0, where bluey is -7700
+ * (-0.0770) because the PNG spec itself requires the xy values to be
+ * unsigned. whitey is also required to be 5 or more to avoid overflow.
+ *
+ * Instead the upper limits have been relaxed to accomodate ACES AP1 where
+ * redz ends up as -600 (-0.006). ProPhotoRGB was already "in range."
+ * The new limit accomodates the AP0 and AP1 ranges for z but not AP0 redy.
*/
- if (xy->redx < 0 || xy->redx > PNG_FP_1) return 1;
- if (xy->redy < 0 || xy->redy > PNG_FP_1-xy->redx) return 1;
- if (xy->greenx < 0 || xy->greenx > PNG_FP_1) return 1;
- if (xy->greeny < 0 || xy->greeny > PNG_FP_1-xy->greenx) return 1;
- if (xy->bluex < 0 || xy->bluex > PNG_FP_1) return 1;
- if (xy->bluey < 0 || xy->bluey > PNG_FP_1-xy->bluex) return 1;
- if (xy->whitex < 0 || xy->whitex > PNG_FP_1) return 1;
- if (xy->whitey < 5 || xy->whitey > PNG_FP_1-xy->whitex) return 1;
+ const png_fixed_point fpLimit = PNG_FP_1+(PNG_FP_1/10);
+ if (xy->redx < 0 || xy->redx > fpLimit) return 1;
+ if (xy->redy < 0 || xy->redy > fpLimit-xy->redx) return 1;
+ if (xy->greenx < 0 || xy->greenx > fpLimit) return 1;
+ if (xy->greeny < 0 || xy->greeny > fpLimit-xy->greenx) return 1;
+ if (xy->bluex < 0 || xy->bluex > fpLimit) return 1;
+ if (xy->bluey < 0 || xy->bluey > fpLimit-xy->bluex) return 1;
+ if (xy->whitex < 0 || xy->whitex > fpLimit) return 1;
+ if (xy->whitey < 5 || xy->whitey > fpLimit-xy->whitex) return 1;
/* The reverse calculation is more difficult because the original tristimulus
* value had 9 independent values (red,green,blue)x(X,Y,Z) however only 8
@@ -1435,18 +1372,23 @@ png_XYZ_from_xy(png_XYZ *XYZ, const png_xy *xy)
* (green-x - blue-x)*(red-y - blue-y)-(green-y - blue-y)*(red-x - blue-x)
*
* Accuracy:
- * The input values have 5 decimal digits of accuracy. The values are all in
- * the range 0 < value < 1, so simple products are in the same range but may
- * need up to 10 decimal digits to preserve the original precision and avoid
- * underflow. Because we are using a 32-bit signed representation we cannot
- * match this; the best is a little over 9 decimal digits, less than 10.
+ * The input values have 5 decimal digits of accuracy.
+ *
+ * In the previous implementation the values were all in the range 0 < value
+ * < 1, so simple products are in the same range but may need up to 10
+ * decimal digits to preserve the original precision and avoid underflow.
+ * Because we are using a 32-bit signed representation we cannot match this;
+ * the best is a little over 9 decimal digits, less than 10.
+ *
+ * This range has now been extended to allow values up to 1.1, or 110,000 in
+ * fixed point.
*
* The approach used here is to preserve the maximum precision within the
* signed representation. Because the red-scale calculation above uses the
- * difference between two products of values that must be in the range -1..+1
- * it is sufficient to divide the product by 7; ceil(100,000/32767*2). The
- * factor is irrelevant in the calculation because it is applied to both
- * numerator and denominator.
+ * difference between two products of values that must be in the range
+ * -1.1..+1.1 it is sufficient to divide the product by 8;
+ * ceil(121,000/32767*2). The factor is irrelevant in the calculation
+ * because it is applied to both numerator and denominator.
*
* Note that the values of the differences of the products of the
* chromaticities in the above equations tend to be small, for example for
@@ -1468,49 +1410,64 @@ png_XYZ_from_xy(png_XYZ *XYZ, const png_xy *xy)
* Adobe Wide Gamut RGB
* 0.258728243040113 0.724682314948566 0.016589442011321
*/
- /* By the argument, above overflow should be impossible here. The return
- * value of 2 indicates an internal error to the caller.
- */
- if (png_muldiv(&left, xy->greenx-xy->bluex, xy->redy - xy->bluey, 7) == 0)
- return 2;
- if (png_muldiv(&right, xy->greeny-xy->bluey, xy->redx - xy->bluex, 7) == 0)
- return 2;
- denominator = left - right;
-
- /* Now find the red numerator. */
- if (png_muldiv(&left, xy->greenx-xy->bluex, xy->whitey-xy->bluey, 7) == 0)
- return 2;
- if (png_muldiv(&right, xy->greeny-xy->bluey, xy->whitex-xy->bluex, 7) == 0)
- return 2;
-
- /* Overflow is possible here and it indicates an extreme set of PNG cHRM
- * chunk values. This calculation actually returns the reciprocal of the
- * scale value because this allows us to delay the multiplication of white-y
- * into the denominator, which tends to produce a small number.
- */
- if (png_muldiv(&red_inverse, xy->whitey, denominator, left-right) == 0 ||
- red_inverse <= xy->whitey /* r+g+b scales = white scale */)
- return 1;
+ {
+ int error = 0;
- /* Similarly for green_inverse: */
- if (png_muldiv(&left, xy->redy-xy->bluey, xy->whitex-xy->bluex, 7) == 0)
- return 2;
- if (png_muldiv(&right, xy->redx-xy->bluex, xy->whitey-xy->bluey, 7) == 0)
- return 2;
- if (png_muldiv(&green_inverse, xy->whitey, denominator, left-right) == 0 ||
- green_inverse <= xy->whitey)
- return 1;
+ /* By the argument above overflow should be impossible here, however the
+ * code now simply returns a failure code. The xy subtracts in the
+ * arguments to png_muldiv are *not* checked for overflow because the
+ * checks at the start guarantee they are in the range 0..110000 and
+ * png_fixed_point is a 32-bit signed number.
+ */
+ if (png_muldiv(&left, xy->greenx-xy->bluex, xy->redy - xy->bluey, 8) == 0)
+ return 1;
+ if (png_muldiv(&right, xy->greeny-xy->bluey, xy->redx - xy->bluex, 8) ==
+ 0)
+ return 1;
+ denominator = png_fp_sub(left, right, &error);
+ if (error) return 1;
- /* And the blue scale, the checks above guarantee this can't overflow but it
- * can still produce 0 for extreme cHRM values.
- */
- blue_scale = png_reciprocal(xy->whitey) - png_reciprocal(red_inverse) -
- png_reciprocal(green_inverse);
- if (blue_scale <= 0)
- return 1;
+ /* Now find the red numerator. */
+ if (png_muldiv(&left, xy->greenx-xy->bluex, xy->whitey-xy->bluey, 8) == 0)
+ return 1;
+ if (png_muldiv(&right, xy->greeny-xy->bluey, xy->whitex-xy->bluex, 8) ==
+ 0)
+ return 1;
+
+ /* Overflow is possible here and it indicates an extreme set of PNG cHRM
+ * chunk values. This calculation actually returns the reciprocal of the
+ * scale value because this allows us to delay the multiplication of
+ * white-y into the denominator, which tends to produce a small number.
+ */
+ if (png_muldiv(&red_inverse, xy->whitey, denominator,
+ png_fp_sub(left, right, &error)) == 0 || error ||
+ red_inverse <= xy->whitey /* r+g+b scales = white scale */)
+ return 1;
+ /* Similarly for green_inverse: */
+ if (png_muldiv(&left, xy->redy-xy->bluey, xy->whitex-xy->bluex, 8) == 0)
+ return 1;
+ if (png_muldiv(&right, xy->redx-xy->bluex, xy->whitey-xy->bluey, 8) == 0)
+ return 1;
+ if (png_muldiv(&green_inverse, xy->whitey, denominator,
+ png_fp_sub(left, right, &error)) == 0 || error ||
+ green_inverse <= xy->whitey)
+ return 1;
+
+ /* And the blue scale, the checks above guarantee this can't overflow but
+ * it can still produce 0 for extreme cHRM values.
+ */
+ blue_scale = png_fp_sub(png_fp_sub(png_reciprocal(xy->whitey),
+ png_reciprocal(red_inverse), &error),
+ png_reciprocal(green_inverse), &error);
+ if (error || blue_scale <= 0)
+ return 1;
+ }
- /* And fill in the png_XYZ: */
+ /* And fill in the png_XYZ. Again the subtracts are safe because of the
+ * checks on the xy values at the start (the subtracts just calculate the
+ * corresponding z values.)
+ */
if (png_muldiv(&XYZ->red_X, xy->redx, PNG_FP_1, red_inverse) == 0)
return 1;
if (png_muldiv(&XYZ->red_Y, xy->redy, PNG_FP_1, red_inverse) == 0)
@@ -1537,250 +1494,9 @@ png_XYZ_from_xy(png_XYZ *XYZ, const png_xy *xy)
return 0; /*success*/
}
+#endif /* COLORSPACE */
-static int
-png_XYZ_normalize(png_XYZ *XYZ)
-{
- png_int_32 Y;
-
- if (XYZ->red_Y < 0 || XYZ->green_Y < 0 || XYZ->blue_Y < 0 ||
- XYZ->red_X < 0 || XYZ->green_X < 0 || XYZ->blue_X < 0 ||
- XYZ->red_Z < 0 || XYZ->green_Z < 0 || XYZ->blue_Z < 0)
- return 1;
-
- /* Normalize by scaling so the sum of the end-point Y values is PNG_FP_1.
- * IMPLEMENTATION NOTE: ANSI requires signed overflow not to occur, therefore
- * relying on addition of two positive values producing a negative one is not
- * safe.
- */
- Y = XYZ->red_Y;
- if (0x7fffffff - Y < XYZ->green_X)
- return 1;
- Y += XYZ->green_Y;
- if (0x7fffffff - Y < XYZ->blue_X)
- return 1;
- Y += XYZ->blue_Y;
-
- if (Y != PNG_FP_1)
- {
- if (png_muldiv(&XYZ->red_X, XYZ->red_X, PNG_FP_1, Y) == 0)
- return 1;
- if (png_muldiv(&XYZ->red_Y, XYZ->red_Y, PNG_FP_1, Y) == 0)
- return 1;
- if (png_muldiv(&XYZ->red_Z, XYZ->red_Z, PNG_FP_1, Y) == 0)
- return 1;
-
- if (png_muldiv(&XYZ->green_X, XYZ->green_X, PNG_FP_1, Y) == 0)
- return 1;
- if (png_muldiv(&XYZ->green_Y, XYZ->green_Y, PNG_FP_1, Y) == 0)
- return 1;
- if (png_muldiv(&XYZ->green_Z, XYZ->green_Z, PNG_FP_1, Y) == 0)
- return 1;
-
- if (png_muldiv(&XYZ->blue_X, XYZ->blue_X, PNG_FP_1, Y) == 0)
- return 1;
- if (png_muldiv(&XYZ->blue_Y, XYZ->blue_Y, PNG_FP_1, Y) == 0)
- return 1;
- if (png_muldiv(&XYZ->blue_Z, XYZ->blue_Z, PNG_FP_1, Y) == 0)
- return 1;
- }
-
- return 0;
-}
-
-static int
-png_colorspace_endpoints_match(const png_xy *xy1, const png_xy *xy2, int delta)
-{
- /* Allow an error of +/-0.01 (absolute value) on each chromaticity */
- if (PNG_OUT_OF_RANGE(xy1->whitex, xy2->whitex,delta) ||
- PNG_OUT_OF_RANGE(xy1->whitey, xy2->whitey,delta) ||
- PNG_OUT_OF_RANGE(xy1->redx, xy2->redx, delta) ||
- PNG_OUT_OF_RANGE(xy1->redy, xy2->redy, delta) ||
- PNG_OUT_OF_RANGE(xy1->greenx, xy2->greenx,delta) ||
- PNG_OUT_OF_RANGE(xy1->greeny, xy2->greeny,delta) ||
- PNG_OUT_OF_RANGE(xy1->bluex, xy2->bluex, delta) ||
- PNG_OUT_OF_RANGE(xy1->bluey, xy2->bluey, delta))
- return 0;
- return 1;
-}
-
-/* Added in libpng-1.6.0, a different check for the validity of a set of cHRM
- * chunk chromaticities. Earlier checks used to simply look for the overflow
- * condition (where the determinant of the matrix to solve for XYZ ends up zero
- * because the chromaticity values are not all distinct.) Despite this it is
- * theoretically possible to produce chromaticities that are apparently valid
- * but that rapidly degrade to invalid, potentially crashing, sets because of
- * arithmetic inaccuracies when calculations are performed on them. The new
- * check is to round-trip xy -> XYZ -> xy and then check that the result is
- * within a small percentage of the original.
- */
-static int
-png_colorspace_check_xy(png_XYZ *XYZ, const png_xy *xy)
-{
- int result;
- png_xy xy_test;
-
- /* As a side-effect this routine also returns the XYZ endpoints. */
- result = png_XYZ_from_xy(XYZ, xy);
- if (result != 0)
- return result;
-
- result = png_xy_from_XYZ(&xy_test, XYZ);
- if (result != 0)
- return result;
-
- if (png_colorspace_endpoints_match(xy, &xy_test,
- 5/*actually, the math is pretty accurate*/) != 0)
- return 0;
-
- /* Too much slip */
- return 1;
-}
-
-/* This is the check going the other way. The XYZ is modified to normalize it
- * (another side-effect) and the xy chromaticities are returned.
- */
-static int
-png_colorspace_check_XYZ(png_xy *xy, png_XYZ *XYZ)
-{
- int result;
- png_XYZ XYZtemp;
-
- result = png_XYZ_normalize(XYZ);
- if (result != 0)
- return result;
-
- result = png_xy_from_XYZ(xy, XYZ);
- if (result != 0)
- return result;
-
- XYZtemp = *XYZ;
- return png_colorspace_check_xy(&XYZtemp, xy);
-}
-
-/* Used to check for an endpoint match against sRGB */
-static const png_xy sRGB_xy = /* From ITU-R BT.709-3 */
-{
- /* color x y */
- /* red */ 64000, 33000,
- /* green */ 30000, 60000,
- /* blue */ 15000, 6000,
- /* white */ 31270, 32900
-};
-
-static int
-png_colorspace_set_xy_and_XYZ(png_const_structrp png_ptr,
- png_colorspacerp colorspace, const png_xy *xy, const png_XYZ *XYZ,
- int preferred)
-{
- if ((colorspace->flags & PNG_COLORSPACE_INVALID) != 0)
- return 0;
-
- /* The consistency check is performed on the chromaticities; this factors out
- * variations because of the normalization (or not) of the end point Y
- * values.
- */
- if (preferred < 2 &&
- (colorspace->flags & PNG_COLORSPACE_HAVE_ENDPOINTS) != 0)
- {
- /* The end points must be reasonably close to any we already have. The
- * following allows an error of up to +/-.001
- */
- if (png_colorspace_endpoints_match(xy, &colorspace->end_points_xy,
- 100) == 0)
- {
- colorspace->flags |= PNG_COLORSPACE_INVALID;
- png_benign_error(png_ptr, "inconsistent chromaticities");
- return 0; /* failed */
- }
-
- /* Only overwrite with preferred values */
- if (preferred == 0)
- return 1; /* ok, but no change */
- }
-
- colorspace->end_points_xy = *xy;
- colorspace->end_points_XYZ = *XYZ;
- colorspace->flags |= PNG_COLORSPACE_HAVE_ENDPOINTS;
-
- /* The end points are normally quoted to two decimal digits, so allow +/-0.01
- * on this test.
- */
- if (png_colorspace_endpoints_match(xy, &sRGB_xy, 1000) != 0)
- colorspace->flags |= PNG_COLORSPACE_ENDPOINTS_MATCH_sRGB;
-
- else
- colorspace->flags &= PNG_COLORSPACE_CANCEL(
- PNG_COLORSPACE_ENDPOINTS_MATCH_sRGB);
-
- return 2; /* ok and changed */
-}
-
-int /* PRIVATE */
-png_colorspace_set_chromaticities(png_const_structrp png_ptr,
- png_colorspacerp colorspace, const png_xy *xy, int preferred)
-{
- /* We must check the end points to ensure they are reasonable - in the past
- * color management systems have crashed as a result of getting bogus
- * colorant values, while this isn't the fault of libpng it is the
- * responsibility of libpng because PNG carries the bomb and libpng is in a
- * position to protect against it.
- */
- png_XYZ XYZ;
-
- switch (png_colorspace_check_xy(&XYZ, xy))
- {
- case 0: /* success */
- return png_colorspace_set_xy_and_XYZ(png_ptr, colorspace, xy, &XYZ,
- preferred);
-
- case 1:
- /* We can't invert the chromaticities so we can't produce value XYZ
- * values. Likely as not a color management system will fail too.
- */
- colorspace->flags |= PNG_COLORSPACE_INVALID;
- png_benign_error(png_ptr, "invalid chromaticities");
- break;
-
- default:
- /* libpng is broken; this should be a warning but if it happens we
- * want error reports so for the moment it is an error.
- */
- colorspace->flags |= PNG_COLORSPACE_INVALID;
- png_error(png_ptr, "internal error checking chromaticities");
- }
-
- return 0; /* failed */
-}
-
-int /* PRIVATE */
-png_colorspace_set_endpoints(png_const_structrp png_ptr,
- png_colorspacerp colorspace, const png_XYZ *XYZ_in, int preferred)
-{
- png_XYZ XYZ = *XYZ_in;
- png_xy xy;
-
- switch (png_colorspace_check_XYZ(&xy, &XYZ))
- {
- case 0:
- return png_colorspace_set_xy_and_XYZ(png_ptr, colorspace, &xy, &XYZ,
- preferred);
-
- case 1:
- /* End points are invalid. */
- colorspace->flags |= PNG_COLORSPACE_INVALID;
- png_benign_error(png_ptr, "invalid end points");
- break;
-
- default:
- colorspace->flags |= PNG_COLORSPACE_INVALID;
- png_error(png_ptr, "internal error checking chromaticities");
- }
-
- return 0; /* failed */
-}
-
-#if defined(PNG_sRGB_SUPPORTED) || defined(PNG_iCCP_SUPPORTED)
+#ifdef PNG_READ_iCCP_SUPPORTED
/* Error message generation */
static char
png_icc_tag_char(png_uint_32 byte)
@@ -1820,15 +1536,12 @@ is_ICC_signature(png_alloc_size_t it)
}
static int
-png_icc_profile_error(png_const_structrp png_ptr, png_colorspacerp colorspace,
- png_const_charp name, png_alloc_size_t value, png_const_charp reason)
+png_icc_profile_error(png_const_structrp png_ptr, png_const_charp name,
+ png_alloc_size_t value, png_const_charp reason)
{
size_t pos;
char message[196]; /* see below for calculation */
- if (colorspace != NULL)
- colorspace->flags |= PNG_COLORSPACE_INVALID;
-
pos = png_safecat(message, (sizeof message), 0, "profile '"); /* 9 chars */
pos = png_safecat(message, pos+79, pos, name); /* Truncate to 79 chars */
pos = png_safecat(message, (sizeof message), pos, "': "); /* +2 = 90 */
@@ -1842,122 +1555,24 @@ png_icc_profile_error(png_const_structrp png_ptr, png_colorspacerp colorspace,
}
# ifdef PNG_WARNINGS_SUPPORTED
else
- {
- char number[PNG_NUMBER_BUFFER_SIZE]; /* +24 = 114*/
+ {
+ char number[PNG_NUMBER_BUFFER_SIZE]; /* +24 = 114 */
- pos = png_safecat(message, (sizeof message), pos,
- png_format_number(number, number+(sizeof number),
- PNG_NUMBER_FORMAT_x, value));
- pos = png_safecat(message, (sizeof message), pos, "h: "); /*+2 = 116*/
- }
+ pos = png_safecat(message, (sizeof message), pos,
+ png_format_number(number, number+(sizeof number),
+ PNG_NUMBER_FORMAT_x, value));
+ pos = png_safecat(message, (sizeof message), pos, "h: "); /* +2 = 116 */
+ }
# endif
/* The 'reason' is an arbitrary message, allow +79 maximum 195 */
pos = png_safecat(message, (sizeof message), pos, reason);
PNG_UNUSED(pos)
- /* This is recoverable, but make it unconditionally an app_error on write to
- * avoid writing invalid ICC profiles into PNG files (i.e., we handle them
- * on read, with a warning, but on write unless the app turns off
- * application errors the PNG won't be written.)
- */
- png_chunk_report(png_ptr, message,
- (colorspace != NULL) ? PNG_CHUNK_ERROR : PNG_CHUNK_WRITE_ERROR);
+ png_chunk_benign_error(png_ptr, message);
return 0;
}
-#endif /* sRGB || iCCP */
-
-#ifdef PNG_sRGB_SUPPORTED
-int /* PRIVATE */
-png_colorspace_set_sRGB(png_const_structrp png_ptr, png_colorspacerp colorspace,
- int intent)
-{
- /* sRGB sets known gamma, end points and (from the chunk) intent. */
- /* IMPORTANT: these are not necessarily the values found in an ICC profile
- * because ICC profiles store values adapted to a D50 environment; it is
- * expected that the ICC profile mediaWhitePointTag will be D50; see the
- * checks and code elsewhere to understand this better.
- *
- * These XYZ values, which are accurate to 5dp, produce rgb to gray
- * coefficients of (6968,23435,2366), which are reduced (because they add up
- * to 32769 not 32768) to (6968,23434,2366). These are the values that
- * libpng has traditionally used (and are the best values given the 15bit
- * algorithm used by the rgb to gray code.)
- */
- static const png_XYZ sRGB_XYZ = /* D65 XYZ (*not* the D50 adapted values!) */
- {
- /* color X Y Z */
- /* red */ 41239, 21264, 1933,
- /* green */ 35758, 71517, 11919,
- /* blue */ 18048, 7219, 95053
- };
-
- /* Do nothing if the colorspace is already invalidated. */
- if ((colorspace->flags & PNG_COLORSPACE_INVALID) != 0)
- return 0;
-
- /* Check the intent, then check for existing settings. It is valid for the
- * PNG file to have cHRM or gAMA chunks along with sRGB, but the values must
- * be consistent with the correct values. If, however, this function is
- * called below because an iCCP chunk matches sRGB then it is quite
- * conceivable that an older app recorded incorrect gAMA and cHRM because of
- * an incorrect calculation based on the values in the profile - this does
- * *not* invalidate the profile (though it still produces an error, which can
- * be ignored.)
- */
- if (intent < 0 || intent >= PNG_sRGB_INTENT_LAST)
- return png_icc_profile_error(png_ptr, colorspace, "sRGB",
- (png_alloc_size_t)intent, "invalid sRGB rendering intent");
-
- if ((colorspace->flags & PNG_COLORSPACE_HAVE_INTENT) != 0 &&
- colorspace->rendering_intent != intent)
- return png_icc_profile_error(png_ptr, colorspace, "sRGB",
- (png_alloc_size_t)intent, "inconsistent rendering intents");
-
- if ((colorspace->flags & PNG_COLORSPACE_FROM_sRGB) != 0)
- {
- png_benign_error(png_ptr, "duplicate sRGB information ignored");
- return 0;
- }
-
- /* If the standard sRGB cHRM chunk does not match the one from the PNG file
- * warn but overwrite the value with the correct one.
- */
- if ((colorspace->flags & PNG_COLORSPACE_HAVE_ENDPOINTS) != 0 &&
- !png_colorspace_endpoints_match(&sRGB_xy, &colorspace->end_points_xy,
- 100))
- png_chunk_report(png_ptr, "cHRM chunk does not match sRGB",
- PNG_CHUNK_ERROR);
-
- /* This check is just done for the error reporting - the routine always
- * returns true when the 'from' argument corresponds to sRGB (2).
- */
- (void)png_colorspace_check_gamma(png_ptr, colorspace, PNG_GAMMA_sRGB_INVERSE,
- 2/*from sRGB*/);
-
- /* intent: bugs in GCC force 'int' to be used as the parameter type. */
- colorspace->rendering_intent = (png_uint_16)intent;
- colorspace->flags |= PNG_COLORSPACE_HAVE_INTENT;
-
- /* endpoints */
- colorspace->end_points_xy = sRGB_xy;
- colorspace->end_points_XYZ = sRGB_XYZ;
- colorspace->flags |=
- (PNG_COLORSPACE_HAVE_ENDPOINTS|PNG_COLORSPACE_ENDPOINTS_MATCH_sRGB);
-
- /* gamma */
- colorspace->gamma = PNG_GAMMA_sRGB_INVERSE;
- colorspace->flags |= PNG_COLORSPACE_HAVE_GAMMA;
-
- /* Finally record that we have an sRGB profile */
- colorspace->flags |=
- (PNG_COLORSPACE_MATCHES_sRGB|PNG_COLORSPACE_FROM_sRGB);
-
- return 1; /* set */
-}
-#endif /* sRGB */
-#ifdef PNG_iCCP_SUPPORTED
/* Encoded value of D50 as an ICC XYZNumber. From the ICC 2010 spec the value
* is XYZ(0.9642,1.0,0.8249), which scales to:
*
@@ -1967,21 +1582,19 @@ static const png_byte D50_nCIEXYZ[12] =
{ 0x00, 0x00, 0xf6, 0xd6, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0xd3, 0x2d };
static int /* bool */
-icc_check_length(png_const_structrp png_ptr, png_colorspacerp colorspace,
- png_const_charp name, png_uint_32 profile_length)
+icc_check_length(png_const_structrp png_ptr, png_const_charp name,
+ png_uint_32 profile_length)
{
if (profile_length < 132)
- return png_icc_profile_error(png_ptr, colorspace, name, profile_length,
- "too short");
+ return png_icc_profile_error(png_ptr, name, profile_length, "too short");
return 1;
}
-#ifdef PNG_READ_iCCP_SUPPORTED
int /* PRIVATE */
-png_icc_check_length(png_const_structrp png_ptr, png_colorspacerp colorspace,
- png_const_charp name, png_uint_32 profile_length)
+png_icc_check_length(png_const_structrp png_ptr, png_const_charp name,
+ png_uint_32 profile_length)
{
- if (!icc_check_length(png_ptr, colorspace, name, profile_length))
+ if (!icc_check_length(png_ptr, name, profile_length))
return 0;
/* This needs to be here because the 'normal' check is in
@@ -1990,30 +1603,17 @@ png_icc_check_length(png_const_structrp png_ptr, png_colorspacerp colorspace,
* the caller supplies the profile buffer so libpng doesn't allocate it. See
* the call to icc_check_length below (the write case).
*/
-# ifdef PNG_SET_USER_LIMITS_SUPPORTED
- else if (png_ptr->user_chunk_malloc_max > 0 &&
- png_ptr->user_chunk_malloc_max < profile_length)
- return png_icc_profile_error(png_ptr, colorspace, name, profile_length,
- "exceeds application limits");
-# elif PNG_USER_CHUNK_MALLOC_MAX > 0
- else if (PNG_USER_CHUNK_MALLOC_MAX < profile_length)
- return png_icc_profile_error(png_ptr, colorspace, name, profile_length,
- "exceeds libpng limits");
-# else /* !SET_USER_LIMITS */
- /* This will get compiled out on all 32-bit and better systems. */
- else if (PNG_SIZE_MAX < profile_length)
- return png_icc_profile_error(png_ptr, colorspace, name, profile_length,
- "exceeds system limits");
-# endif /* !SET_USER_LIMITS */
+ if (profile_length > png_chunk_max(png_ptr))
+ return png_icc_profile_error(png_ptr, name, profile_length,
+ "profile too long");
return 1;
}
-#endif /* READ_iCCP */
int /* PRIVATE */
-png_icc_check_header(png_const_structrp png_ptr, png_colorspacerp colorspace,
- png_const_charp name, png_uint_32 profile_length,
- png_const_bytep profile/* first 132 bytes only */, int color_type)
+png_icc_check_header(png_const_structrp png_ptr, png_const_charp name,
+ png_uint_32 profile_length,
+ png_const_bytep profile/* first 132 bytes only */, int color_type)
{
png_uint_32 temp;
@@ -2024,18 +1624,18 @@ png_icc_check_header(png_const_structrp png_ptr, png_colorspacerp colorspace,
*/
temp = png_get_uint_32(profile);
if (temp != profile_length)
- return png_icc_profile_error(png_ptr, colorspace, name, temp,
+ return png_icc_profile_error(png_ptr, name, temp,
"length does not match profile");
temp = (png_uint_32) (*(profile+8));
if (temp > 3 && (profile_length & 3))
- return png_icc_profile_error(png_ptr, colorspace, name, profile_length,
+ return png_icc_profile_error(png_ptr, name, profile_length,
"invalid length");
temp = png_get_uint_32(profile+128); /* tag count: 12 bytes/tag */
if (temp > 357913930 || /* (2^32-4-132)/12: maximum possible tag count */
profile_length < 132+12*temp) /* truncated tag table */
- return png_icc_profile_error(png_ptr, colorspace, name, temp,
+ return png_icc_profile_error(png_ptr, name, temp,
"tag count too large");
/* The 'intent' must be valid or we can't store it, ICC limits the intent to
@@ -2043,14 +1643,14 @@ png_icc_check_header(png_const_structrp png_ptr, png_colorspacerp colorspace,
*/
temp = png_get_uint_32(profile+64);
if (temp >= 0xffff) /* The ICC limit */
- return png_icc_profile_error(png_ptr, colorspace, name, temp,
+ return png_icc_profile_error(png_ptr, name, temp,
"invalid rendering intent");
/* This is just a warning because the profile may be valid in future
* versions.
*/
if (temp >= PNG_sRGB_INTENT_LAST)
- (void)png_icc_profile_error(png_ptr, NULL, name, temp,
+ (void)png_icc_profile_error(png_ptr, name, temp,
"intent outside defined range");
/* At this point the tag table can't be checked because it hasn't necessarily
@@ -2067,7 +1667,7 @@ png_icc_check_header(png_const_structrp png_ptr, png_colorspacerp colorspace,
*/
temp = png_get_uint_32(profile+36); /* signature 'ascp' */
if (temp != 0x61637370)
- return png_icc_profile_error(png_ptr, colorspace, name, temp,
+ return png_icc_profile_error(png_ptr, name, temp,
"invalid signature");
/* Currently the PCS illuminant/adopted white point (the computational
@@ -2078,7 +1678,7 @@ png_icc_check_header(png_const_structrp png_ptr, png_colorspacerp colorspace,
* following is just a warning.
*/
if (memcmp(profile+68, D50_nCIEXYZ, 12) != 0)
- (void)png_icc_profile_error(png_ptr, NULL, name, 0/*no tag value*/,
+ (void)png_icc_profile_error(png_ptr, name, 0/*no tag value*/,
"PCS illuminant is not D50");
/* The PNG spec requires this:
@@ -2106,18 +1706,18 @@ png_icc_check_header(png_const_structrp png_ptr, png_colorspacerp colorspace,
{
case 0x52474220: /* 'RGB ' */
if ((color_type & PNG_COLOR_MASK_COLOR) == 0)
- return png_icc_profile_error(png_ptr, colorspace, name, temp,
+ return png_icc_profile_error(png_ptr, name, temp,
"RGB color space not permitted on grayscale PNG");
break;
case 0x47524159: /* 'GRAY' */
if ((color_type & PNG_COLOR_MASK_COLOR) != 0)
- return png_icc_profile_error(png_ptr, colorspace, name, temp,
+ return png_icc_profile_error(png_ptr, name, temp,
"Gray color space not permitted on RGB PNG");
break;
default:
- return png_icc_profile_error(png_ptr, colorspace, name, temp,
+ return png_icc_profile_error(png_ptr, name, temp,
"invalid ICC profile color space");
}
@@ -2142,7 +1742,7 @@ png_icc_check_header(png_const_structrp png_ptr, png_colorspacerp colorspace,
case 0x61627374: /* 'abst' */
/* May not be embedded in an image */
- return png_icc_profile_error(png_ptr, colorspace, name, temp,
+ return png_icc_profile_error(png_ptr, name, temp,
"invalid embedded Abstract ICC profile");
case 0x6c696e6b: /* 'link' */
@@ -2152,7 +1752,7 @@ png_icc_check_header(png_const_structrp png_ptr, png_colorspacerp colorspace,
* therefore a DeviceLink profile should not be found embedded in a
* PNG.
*/
- return png_icc_profile_error(png_ptr, colorspace, name, temp,
+ return png_icc_profile_error(png_ptr, name, temp,
"unexpected DeviceLink ICC profile class");
case 0x6e6d636c: /* 'nmcl' */
@@ -2160,7 +1760,7 @@ png_icc_check_header(png_const_structrp png_ptr, png_colorspacerp colorspace,
* contain an AToB0 tag that is open to misinterpretation. Almost
* certainly it will fail the tests below.
*/
- (void)png_icc_profile_error(png_ptr, NULL, name, temp,
+ (void)png_icc_profile_error(png_ptr, name, temp,
"unexpected NamedColor ICC profile class");
break;
@@ -2170,7 +1770,7 @@ png_icc_check_header(png_const_structrp png_ptr, png_colorspacerp colorspace,
* tag content to ensure they are backward compatible with one of the
* understood profiles.
*/
- (void)png_icc_profile_error(png_ptr, NULL, name, temp,
+ (void)png_icc_profile_error(png_ptr, name, temp,
"unrecognized ICC profile class");
break;
}
@@ -2186,7 +1786,7 @@ png_icc_check_header(png_const_structrp png_ptr, png_colorspacerp colorspace,
break;
default:
- return png_icc_profile_error(png_ptr, colorspace, name, temp,
+ return png_icc_profile_error(png_ptr, name, temp,
"unexpected ICC PCS encoding");
}
@@ -2194,9 +1794,9 @@ png_icc_check_header(png_const_structrp png_ptr, png_colorspacerp colorspace,
}
int /* PRIVATE */
-png_icc_check_tag_table(png_const_structrp png_ptr, png_colorspacerp colorspace,
- png_const_charp name, png_uint_32 profile_length,
- png_const_bytep profile /* header plus whole tag table */)
+png_icc_check_tag_table(png_const_structrp png_ptr, png_const_charp name,
+ png_uint_32 profile_length,
+ png_const_bytep profile /* header plus whole tag table */)
{
png_uint_32 tag_count = png_get_uint_32(profile+128);
png_uint_32 itag;
@@ -2222,7 +1822,7 @@ png_icc_check_tag_table(png_const_structrp png_ptr, png_colorspacerp colorspace,
* profile.
*/
if (tag_start > profile_length || tag_length > profile_length - tag_start)
- return png_icc_profile_error(png_ptr, colorspace, name, tag_id,
+ return png_icc_profile_error(png_ptr, name, tag_id,
"ICC profile tag outside profile");
if ((tag_start & 3) != 0)
@@ -2231,318 +1831,132 @@ png_icc_check_tag_table(png_const_structrp png_ptr, png_colorspacerp colorspace,
* only a warning here because libpng does not care about the
* alignment.
*/
- (void)png_icc_profile_error(png_ptr, NULL, name, tag_id,
+ (void)png_icc_profile_error(png_ptr, name, tag_id,
"ICC profile tag start not a multiple of 4");
}
}
return 1; /* success, maybe with warnings */
}
+#endif /* READ_iCCP */
-#ifdef PNG_sRGB_SUPPORTED
-#if PNG_sRGB_PROFILE_CHECKS >= 0
-/* Information about the known ICC sRGB profiles */
-static const struct
-{
- png_uint_32 adler, crc, length;
- png_uint_32 md5[4];
- png_byte have_md5;
- png_byte is_broken;
- png_uint_16 intent;
-
-# define PNG_MD5(a,b,c,d) { a, b, c, d }, (a!=0)||(b!=0)||(c!=0)||(d!=0)
-# define PNG_ICC_CHECKSUM(adler, crc, md5, intent, broke, date, length, fname)\
- { adler, crc, length, md5, broke, intent },
-
-} png_sRGB_checks[] =
-{
- /* This data comes from contrib/tools/checksum-icc run on downloads of
- * all four ICC sRGB profiles from www.color.org.
- */
- /* adler32, crc32, MD5[4], intent, date, length, file-name */
- PNG_ICC_CHECKSUM(0x0a3fd9f6, 0x3b8772b9,
- PNG_MD5(0x29f83dde, 0xaff255ae, 0x7842fae4, 0xca83390d), 0, 0,
- "2009/03/27 21:36:31", 3048, "sRGB_IEC61966-2-1_black_scaled.icc")
-
- /* ICC sRGB v2 perceptual no black-compensation: */
- PNG_ICC_CHECKSUM(0x4909e5e1, 0x427ebb21,
- PNG_MD5(0xc95bd637, 0xe95d8a3b, 0x0df38f99, 0xc1320389), 1, 0,
- "2009/03/27 21:37:45", 3052, "sRGB_IEC61966-2-1_no_black_scaling.icc")
-
- PNG_ICC_CHECKSUM(0xfd2144a1, 0x306fd8ae,
- PNG_MD5(0xfc663378, 0x37e2886b, 0xfd72e983, 0x8228f1b8), 0, 0,
- "2009/08/10 17:28:01", 60988, "sRGB_v4_ICC_preference_displayclass.icc")
-
- /* ICC sRGB v4 perceptual */
- PNG_ICC_CHECKSUM(0x209c35d2, 0xbbef7812,
- PNG_MD5(0x34562abf, 0x994ccd06, 0x6d2c5721, 0xd0d68c5d), 0, 0,
- "2007/07/25 00:05:37", 60960, "sRGB_v4_ICC_preference.icc")
-
- /* The following profiles have no known MD5 checksum. If there is a match
- * on the (empty) MD5 the other fields are used to attempt a match and
- * a warning is produced. The first two of these profiles have a 'cprt' tag
- * which suggests that they were also made by Hewlett Packard.
- */
- PNG_ICC_CHECKSUM(0xa054d762, 0x5d5129ce,
- PNG_MD5(0x00000000, 0x00000000, 0x00000000, 0x00000000), 1, 0,
- "2004/07/21 18:57:42", 3024, "sRGB_IEC61966-2-1_noBPC.icc")
-
- /* This is a 'mntr' (display) profile with a mediaWhitePointTag that does not
- * match the D50 PCS illuminant in the header (it is in fact the D65 values,
- * so the white point is recorded as the un-adapted value.) The profiles
- * below only differ in one byte - the intent - and are basically the same as
- * the previous profile except for the mediaWhitePointTag error and a missing
- * chromaticAdaptationTag.
- */
- PNG_ICC_CHECKSUM(0xf784f3fb, 0x182ea552,
- PNG_MD5(0x00000000, 0x00000000, 0x00000000, 0x00000000), 0, 1/*broken*/,
- "1998/02/09 06:49:00", 3144, "HP-Microsoft sRGB v2 perceptual")
-
- PNG_ICC_CHECKSUM(0x0398f3fc, 0xf29e526d,
- PNG_MD5(0x00000000, 0x00000000, 0x00000000, 0x00000000), 1, 1/*broken*/,
- "1998/02/09 06:49:00", 3144, "HP-Microsoft sRGB v2 media-relative")
-};
-
+#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED
+#if (defined PNG_READ_mDCV_SUPPORTED) || (defined PNG_READ_cHRM_SUPPORTED)
static int
-png_compare_ICC_profile_with_sRGB(png_const_structrp png_ptr,
- png_const_bytep profile, uLong adler)
+have_chromaticities(png_const_structrp png_ptr)
{
- /* The quick check is to verify just the MD5 signature and trust the
- * rest of the data. Because the profile has already been verified for
- * correctness this is safe. png_colorspace_set_sRGB will check the 'intent'
- * field too, so if the profile has been edited with an intent not defined
- * by sRGB (but maybe defined by a later ICC specification) the read of
- * the profile will fail at that point.
+ /* Handle new PNGv3 chunks and the precedence rules to determine whether
+ * png_struct::chromaticities must be processed. Only required for RGB to
+ * gray.
+ *
+ * mDCV: this is the mastering colour space and it is independent of the
+ * encoding so it needs to be used regardless of the encoded space.
+ *
+ * cICP: first in priority but not yet implemented - the chromaticities come
+ * from the 'primaries'.
+ *
+ * iCCP: not supported by libpng (so ignored)
+ *
+ * sRGB: the defaults match sRGB
+ *
+ * cHRM: calculate the coefficients
*/
+# ifdef PNG_READ_mDCV_SUPPORTED
+ if (png_has_chunk(png_ptr, mDCV))
+ return 1;
+# define check_chromaticities 1
+# endif /*mDCV*/
- png_uint_32 length = 0;
- png_uint_32 intent = 0x10000; /* invalid */
-#if PNG_sRGB_PROFILE_CHECKS > 1
- uLong crc = 0; /* the value for 0 length data */
-#endif
- unsigned int i;
-
-#ifdef PNG_SET_OPTION_SUPPORTED
- /* First see if PNG_SKIP_sRGB_CHECK_PROFILE has been set to "on" */
- if (((png_ptr->options >> PNG_SKIP_sRGB_CHECK_PROFILE) & 3) ==
- PNG_OPTION_ON)
- return 0;
-#endif
-
- for (i=0; i < (sizeof png_sRGB_checks) / (sizeof png_sRGB_checks[0]); ++i)
- {
- if (png_get_uint_32(profile+84) == png_sRGB_checks[i].md5[0] &&
- png_get_uint_32(profile+88) == png_sRGB_checks[i].md5[1] &&
- png_get_uint_32(profile+92) == png_sRGB_checks[i].md5[2] &&
- png_get_uint_32(profile+96) == png_sRGB_checks[i].md5[3])
- {
- /* This may be one of the old HP profiles without an MD5, in that
- * case we can only use the length and Adler32 (note that these
- * are not used by default if there is an MD5!)
- */
-# if PNG_sRGB_PROFILE_CHECKS == 0
- if (png_sRGB_checks[i].have_md5 != 0)
- return 1+png_sRGB_checks[i].is_broken;
-# endif
-
- /* Profile is unsigned or more checks have been configured in. */
- if (length == 0)
- {
- length = png_get_uint_32(profile);
- intent = png_get_uint_32(profile+64);
- }
-
- /* Length *and* intent must match */
- if (length == (png_uint_32) png_sRGB_checks[i].length &&
- intent == (png_uint_32) png_sRGB_checks[i].intent)
- {
- /* Now calculate the adler32 if not done already. */
- if (adler == 0)
- {
- adler = adler32(0, NULL, 0);
- adler = adler32(adler, profile, length);
- }
-
- if (adler == png_sRGB_checks[i].adler)
- {
- /* These basic checks suggest that the data has not been
- * modified, but if the check level is more than 1 perform
- * our own crc32 checksum on the data.
- */
-# if PNG_sRGB_PROFILE_CHECKS > 1
- if (crc == 0)
- {
- crc = crc32(0, NULL, 0);
- crc = crc32(crc, profile, length);
- }
-
- /* So this check must pass for the 'return' below to happen.
- */
- if (crc == png_sRGB_checks[i].crc)
-# endif
- {
- if (png_sRGB_checks[i].is_broken != 0)
- {
- /* These profiles are known to have bad data that may cause
- * problems if they are used, therefore attempt to
- * discourage their use, skip the 'have_md5' warning below,
- * which is made irrelevant by this error.
- */
- png_chunk_report(png_ptr, "known incorrect sRGB profile",
- PNG_CHUNK_ERROR);
- }
-
- /* Warn that this being done; this isn't even an error since
- * the profile is perfectly valid, but it would be nice if
- * people used the up-to-date ones.
- */
- else if (png_sRGB_checks[i].have_md5 == 0)
- {
- png_chunk_report(png_ptr,
- "out-of-date sRGB profile with no signature",
- PNG_CHUNK_WARNING);
- }
+# ifdef PNG_READ_sRGB_SUPPORTED
+ if (png_has_chunk(png_ptr, sRGB))
+ return 0;
+# endif /*sRGB*/
- return 1+png_sRGB_checks[i].is_broken;
- }
- }
-
-# if PNG_sRGB_PROFILE_CHECKS > 0
- /* The signature matched, but the profile had been changed in some
- * way. This probably indicates a data error or uninformed hacking.
- * Fall through to "no match".
- */
- png_chunk_report(png_ptr,
- "Not recognizing known sRGB profile that has been edited",
- PNG_CHUNK_WARNING);
- break;
-# endif
- }
- }
- }
+# ifdef PNG_READ_cHRM_SUPPORTED
+ if (png_has_chunk(png_ptr, cHRM))
+ return 1;
+# define check_chromaticities 1
+# endif /*cHRM*/
- return 0; /* no match */
+ return 0; /* sRGB defaults */
}
+#endif /* READ_mDCV || READ_cHRM */
void /* PRIVATE */
-png_icc_set_sRGB(png_const_structrp png_ptr,
- png_colorspacerp colorspace, png_const_bytep profile, uLong adler)
+png_set_rgb_coefficients(png_structrp png_ptr)
{
- /* Is this profile one of the known ICC sRGB profiles? If it is, just set
- * the sRGB information.
+ /* Set the rgb_to_gray coefficients from the colorspace if available. Note
+ * that '_set' means that png_rgb_to_gray was called **and** it successfully
+ * set up the coefficients.
*/
- if (png_compare_ICC_profile_with_sRGB(png_ptr, profile, adler) != 0)
- (void)png_colorspace_set_sRGB(png_ptr, colorspace,
- (int)/*already checked*/png_get_uint_32(profile+64));
-}
-#endif /* PNG_sRGB_PROFILE_CHECKS >= 0 */
-#endif /* sRGB */
-
-int /* PRIVATE */
-png_colorspace_set_ICC(png_const_structrp png_ptr, png_colorspacerp colorspace,
- png_const_charp name, png_uint_32 profile_length, png_const_bytep profile,
- int color_type)
-{
- if ((colorspace->flags & PNG_COLORSPACE_INVALID) != 0)
- return 0;
-
- if (icc_check_length(png_ptr, colorspace, name, profile_length) != 0 &&
- png_icc_check_header(png_ptr, colorspace, name, profile_length, profile,
- color_type) != 0 &&
- png_icc_check_tag_table(png_ptr, colorspace, name, profile_length,
- profile) != 0)
+ if (png_ptr->rgb_to_gray_coefficients_set == 0)
{
-# if defined(PNG_sRGB_SUPPORTED) && PNG_sRGB_PROFILE_CHECKS >= 0
- /* If no sRGB support, don't try storing sRGB information */
- png_icc_set_sRGB(png_ptr, colorspace, profile, 0);
-# endif
- return 1;
- }
+# if check_chromaticities
+ png_XYZ xyz;
- /* Failure case */
- return 0;
-}
-#endif /* iCCP */
-
-#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED
-void /* PRIVATE */
-png_colorspace_set_rgb_coefficients(png_structrp png_ptr)
-{
- /* Set the rgb_to_gray coefficients from the colorspace. */
- if (png_ptr->rgb_to_gray_coefficients_set == 0 &&
- (png_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_ENDPOINTS) != 0)
- {
- /* png_set_background has not been called, get the coefficients from the Y
- * values of the colorspace colorants.
- */
- png_fixed_point r = png_ptr->colorspace.end_points_XYZ.red_Y;
- png_fixed_point g = png_ptr->colorspace.end_points_XYZ.green_Y;
- png_fixed_point b = png_ptr->colorspace.end_points_XYZ.blue_Y;
- png_fixed_point total = r+g+b;
-
- if (total > 0 &&
- r >= 0 && png_muldiv(&r, r, 32768, total) && r >= 0 && r <= 32768 &&
- g >= 0 && png_muldiv(&g, g, 32768, total) && g >= 0 && g <= 32768 &&
- b >= 0 && png_muldiv(&b, b, 32768, total) && b >= 0 && b <= 32768 &&
- r+g+b <= 32769)
+ if (have_chromaticities(png_ptr) &&
+ png_XYZ_from_xy(&xyz, &png_ptr->chromaticities) == 0)
{
- /* We allow 0 coefficients here. r+g+b may be 32769 if two or
- * all of the coefficients were rounded up. Handle this by
- * reducing the *largest* coefficient by 1; this matches the
- * approach used for the default coefficients in pngrtran.c
+ /* png_set_rgb_to_gray has not set the coefficients, get them from the
+ * Y * values of the colorspace colorants.
*/
- int add = 0;
+ png_fixed_point r = xyz.red_Y;
+ png_fixed_point g = xyz.green_Y;
+ png_fixed_point b = xyz.blue_Y;
+ png_fixed_point total = r+g+b;
+
+ if (total > 0 &&
+ r >= 0 && png_muldiv(&r, r, 32768, total) && r >= 0 && r <= 32768 &&
+ g >= 0 && png_muldiv(&g, g, 32768, total) && g >= 0 && g <= 32768 &&
+ b >= 0 && png_muldiv(&b, b, 32768, total) && b >= 0 && b <= 32768 &&
+ r+g+b <= 32769)
+ {
+ /* We allow 0 coefficients here. r+g+b may be 32769 if two or
+ * all of the coefficients were rounded up. Handle this by
+ * reducing the *largest* coefficient by 1; this matches the
+ * approach used for the default coefficients in pngrtran.c
+ */
+ int add = 0;
- if (r+g+b > 32768)
- add = -1;
- else if (r+g+b < 32768)
- add = 1;
+ if (r+g+b > 32768)
+ add = -1;
+ else if (r+g+b < 32768)
+ add = 1;
- if (add != 0)
- {
- if (g >= r && g >= b)
- g += add;
- else if (r >= g && r >= b)
- r += add;
- else
- b += add;
- }
+ if (add != 0)
+ {
+ if (g >= r && g >= b)
+ g += add;
+ else if (r >= g && r >= b)
+ r += add;
+ else
+ b += add;
+ }
- /* Check for an internal error. */
- if (r+g+b != 32768)
- png_error(png_ptr,
- "internal error handling cHRM coefficients");
+ /* Check for an internal error. */
+ if (r+g+b != 32768)
+ png_error(png_ptr,
+ "internal error handling cHRM coefficients");
- else
- {
- png_ptr->rgb_to_gray_red_coeff = (png_uint_16)r;
- png_ptr->rgb_to_gray_green_coeff = (png_uint_16)g;
+ else
+ {
+ png_ptr->rgb_to_gray_red_coeff = (png_uint_16)r;
+ png_ptr->rgb_to_gray_green_coeff = (png_uint_16)g;
+ }
}
}
-
- /* This is a png_error at present even though it could be ignored -
- * it should never happen, but it is important that if it does, the
- * bug is fixed.
- */
else
- png_error(png_ptr, "internal error handling cHRM->XYZ");
+# endif /* check_chromaticities */
+ {
+ /* Use the historical REC 709 (etc) values: */
+ png_ptr->rgb_to_gray_red_coeff = 6968;
+ png_ptr->rgb_to_gray_green_coeff = 23434;
+ /* png_ptr->rgb_to_gray_blue_coeff = 2366; */
+ }
}
}
#endif /* READ_RGB_TO_GRAY */
-#endif /* COLORSPACE */
-
-#ifdef __GNUC__
-/* This exists solely to work round a warning from GNU C. */
-static int /* PRIVATE */
-png_gt(size_t a, size_t b)
-{
- return a > b;
-}
-#else
-# define png_gt(a,b) ((a) > (b))
-#endif
-
void /* PRIVATE */
png_check_IHDR(png_const_structrp png_ptr,
png_uint_32 width, png_uint_32 height, int bit_depth,
@@ -2564,8 +1978,16 @@ png_check_IHDR(png_const_structrp png_ptr,
error = 1;
}
- if (png_gt(((width + 7) & (~7U)),
- ((PNG_SIZE_MAX
+ /* The bit mask on the first line below must be at least as big as a
+ * png_uint_32. "~7U" is not adequate on 16-bit systems because it will
+ * be an unsigned 16-bit value. Casting to (png_alloc_size_t) makes the
+ * type of the result at least as bit (in bits) as the RHS of the > operator
+ * which also avoids a common warning on 64-bit systems that the comparison
+ * of (png_uint_32) against the constant value on the RHS will always be
+ * false.
+ */
+ if (((width + 7) & ~(png_alloc_size_t)7) >
+ (((PNG_SIZE_MAX
- 48 /* big_row_buf hack */
- 1) /* filter byte */
/ 8) /* 8-byte RGBA pixels */
@@ -2710,7 +2132,7 @@ png_check_IHDR(png_const_structrp png_ptr,
int /* PRIVATE */
png_check_fp_number(png_const_charp string, size_t size, int *statep,
- png_size_tp whereami)
+ size_t *whereami)
{
int state = *statep;
size_t i = *whereami;
@@ -2838,8 +2260,8 @@ png_check_fp_number(png_const_charp string, size_t size, int *statep,
int
png_check_fp_string(png_const_charp string, size_t size)
{
- int state=0;
- size_t char_index=0;
+ int state = 0;
+ size_t char_index = 0;
if (png_check_fp_number(string, size, &state, &char_index) != 0 &&
(char_index == size || string[char_index] == 0))
@@ -2891,14 +2313,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 +2634,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 +2661,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)
{
@@ -3328,7 +2738,27 @@ png_fixed(png_const_structrp png_ptr, double fp, png_const_charp text)
}
#endif
-#if defined(PNG_GAMMA_SUPPORTED) || defined(PNG_COLORSPACE_SUPPORTED) ||\
+#if defined(PNG_FLOATING_POINT_SUPPORTED) && \
+ !defined(PNG_FIXED_POINT_MACRO_SUPPORTED) && \
+ (defined(PNG_cLLI_SUPPORTED) || defined(PNG_mDCV_SUPPORTED))
+png_uint_32
+png_fixed_ITU(png_const_structrp png_ptr, double fp, png_const_charp text)
+{
+ double r = floor(10000 * fp + .5);
+
+ if (r > 2147483647. || r < 0)
+ png_fixed_error(png_ptr, text);
+
+# ifndef PNG_ERROR_TEXT_SUPPORTED
+ PNG_UNUSED(text)
+# endif
+
+ return (png_uint_32)r;
+}
+#endif
+
+
+#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_COLORSPACE_SUPPORTED) ||\
defined(PNG_INCH_CONVERSIONS_SUPPORTED) || defined(PNG_READ_pHYs_SUPPORTED)
/* muldiv functions */
/* This API takes signed arguments and rounds the result to the nearest
@@ -3336,16 +2766,7 @@ 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
+int /* PRIVATE */
png_muldiv(png_fixed_point_p res, png_fixed_point a, png_int_32 times,
png_int_32 divisor)
{
@@ -3459,30 +2880,7 @@ 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)
-/* The following is for when the caller doesn't much care about the
- * result.
- */
-png_fixed_point
-png_muldiv_warn(png_const_structrp png_ptr, png_fixed_point a, png_int_32 times,
- png_int_32 divisor)
-{
- png_fixed_point result;
-
- if (png_muldiv(&result, a, times, divisor) != 0)
- return result;
-
- png_warning(png_ptr, "fixed point overflow ignored");
- return 0;
-}
-#endif
-#ifdef PNG_GAMMA_SUPPORTED /* more fixed point functions for gamma */
/* Calculate a reciprocal, return 0 on div-by-zero or overflow. */
png_fixed_point
png_reciprocal(png_fixed_point a)
@@ -3501,26 +2899,38 @@ png_reciprocal(png_fixed_point a)
return 0; /* error/overflow */
}
+#endif /* READ_GAMMA || COLORSPACE || INCH_CONVERSIONS || READ_pHYS */
+#ifdef PNG_READ_GAMMA_SUPPORTED
/* This is the shared test on whether a gamma value is 'significant' - whether
* it is worth doing gamma correction.
*/
int /* PRIVATE */
png_gamma_significant(png_fixed_point gamma_val)
{
+ /* sRGB: 1/2.2 == 0.4545(45)
+ * AdobeRGB: 1/(2+51/256) ~= 0.45471 5dp
+ *
+ * So the correction from AdobeRGB to sRGB (output) is:
+ *
+ * 2.2/(2+51/256) == 1.00035524
+ *
+ * I.e. vanishly small (<4E-4) but still detectable in 16-bit linear (+/-
+ * 23). Note that the Adobe choice seems to be something intended to give an
+ * exact number with 8 binary fractional digits - it is the closest to 2.2
+ * that is possible a base 2 .8p representation.
+ */
return gamma_val < PNG_FP_1 - PNG_GAMMA_THRESHOLD_FIXED ||
gamma_val > PNG_FP_1 + PNG_GAMMA_THRESHOLD_FIXED;
}
-#endif
-#ifdef PNG_READ_GAMMA_SUPPORTED
-#ifdef PNG_16BIT_SUPPORTED
+#ifndef PNG_FLOATING_ARITHMETIC_SUPPORTED
/* A local convenience routine. */
static png_fixed_point
png_product2(png_fixed_point a, png_fixed_point b)
{
- /* The required result is 1/a * 1/b; the following preserves accuracy. */
-#ifdef PNG_FLOATING_ARITHMETIC_SUPPORTED
+ /* The required result is a * b; the following preserves accuracy. */
+#ifdef PNG_FLOATING_ARITHMETIC_SUPPORTED /* Should now be unused */
double r = a * 1E-5;
r *= b;
r = floor(r+.5);
@@ -3536,9 +2946,8 @@ png_product2(png_fixed_point a, png_fixed_point b)
return 0; /* overflow */
}
-#endif /* 16BIT */
+#endif /* FLOATING_ARITHMETIC */
-/* The inverse of the above. */
png_fixed_point
png_reciprocal2(png_fixed_point a, png_fixed_point b)
{
@@ -4191,10 +3600,27 @@ png_destroy_gamma_table(png_structrp png_ptr)
* tables, we don't make a full table if we are reducing to 8-bit in
* the future. Note also how the gamma_16 tables are segmented so that
* we don't need to allocate > 64K chunks for a full 16-bit table.
+ *
+ * TODO: move this to pngrtran.c and make it static. Better yet create
+ * pngcolor.c and put all the PNG_COLORSPACE stuff in there.
*/
+#if defined(PNG_READ_BACKGROUND_SUPPORTED) || \
+ defined(PNG_READ_ALPHA_MODE_SUPPORTED) || \
+ defined(PNG_READ_RGB_TO_GRAY_SUPPORTED)
+# define GAMMA_TRANSFORMS 1 /* #ifdef CSE */
+#else
+# define GAMMA_TRANSFORMS 0
+#endif
+
void /* PRIVATE */
png_build_gamma_table(png_structrp png_ptr, int bit_depth)
{
+ png_fixed_point file_gamma, screen_gamma;
+ png_fixed_point correction;
+# if GAMMA_TRANSFORMS
+ png_fixed_point file_to_linear, linear_to_screen;
+# endif
+
png_debug(1, "in png_build_gamma_table");
/* Remove any existing table; this copes with multiple calls to
@@ -4209,27 +3635,44 @@ png_build_gamma_table(png_structrp png_ptr, int bit_depth)
png_destroy_gamma_table(png_ptr);
}
+ /* The following fields are set, finally, in png_init_read_transformations.
+ * If file_gamma is 0 (unset) nothing can be done otherwise if screen_gamma
+ * is 0 (unset) there is no gamma correction but to/from linear is possible.
+ */
+ file_gamma = png_ptr->file_gamma;
+ screen_gamma = png_ptr->screen_gamma;
+# if GAMMA_TRANSFORMS
+ file_to_linear = png_reciprocal(file_gamma);
+# endif
+
+ if (screen_gamma > 0)
+ {
+# if GAMMA_TRANSFORMS
+ linear_to_screen = png_reciprocal(screen_gamma);
+# endif
+ correction = png_reciprocal2(screen_gamma, file_gamma);
+ }
+ else /* screen gamma unknown */
+ {
+# if GAMMA_TRANSFORMS
+ linear_to_screen = file_gamma;
+# endif
+ correction = PNG_FP_1;
+ }
+
if (bit_depth <= 8)
{
- png_build_8bit_table(png_ptr, &png_ptr->gamma_table,
- png_ptr->screen_gamma > 0 ?
- png_reciprocal2(png_ptr->colorspace.gamma,
- png_ptr->screen_gamma) : PNG_FP_1);
+ png_build_8bit_table(png_ptr, &png_ptr->gamma_table, correction);
-#if defined(PNG_READ_BACKGROUND_SUPPORTED) || \
- defined(PNG_READ_ALPHA_MODE_SUPPORTED) || \
- defined(PNG_READ_RGB_TO_GRAY_SUPPORTED)
+#if GAMMA_TRANSFORMS
if ((png_ptr->transformations & (PNG_COMPOSE | PNG_RGB_TO_GRAY)) != 0)
{
- png_build_8bit_table(png_ptr, &png_ptr->gamma_to_1,
- png_reciprocal(png_ptr->colorspace.gamma));
+ png_build_8bit_table(png_ptr, &png_ptr->gamma_to_1, file_to_linear);
png_build_8bit_table(png_ptr, &png_ptr->gamma_from_1,
- png_ptr->screen_gamma > 0 ?
- png_reciprocal(png_ptr->screen_gamma) :
- png_ptr->colorspace.gamma/* Probably doing rgb_to_gray */);
+ linear_to_screen);
}
-#endif /* READ_BACKGROUND || READ_ALPHA_MODE || RGB_TO_GRAY */
+#endif /* GAMMA_TRANSFORMS */
}
#ifdef PNG_16BIT_SUPPORTED
else
@@ -4295,32 +3738,26 @@ png_build_gamma_table(png_structrp png_ptr, int bit_depth)
* reduced to 8 bits.
*/
if ((png_ptr->transformations & (PNG_16_TO_8 | PNG_SCALE_16_TO_8)) != 0)
- png_build_16to8_table(png_ptr, &png_ptr->gamma_16_table, shift,
- png_ptr->screen_gamma > 0 ? png_product2(png_ptr->colorspace.gamma,
- png_ptr->screen_gamma) : PNG_FP_1);
-
+ png_build_16to8_table(png_ptr, &png_ptr->gamma_16_table, shift,
+ png_reciprocal(correction));
else
- png_build_16bit_table(png_ptr, &png_ptr->gamma_16_table, shift,
- png_ptr->screen_gamma > 0 ? png_reciprocal2(png_ptr->colorspace.gamma,
- png_ptr->screen_gamma) : PNG_FP_1);
+ png_build_16bit_table(png_ptr, &png_ptr->gamma_16_table, shift,
+ correction);
-#if defined(PNG_READ_BACKGROUND_SUPPORTED) || \
- defined(PNG_READ_ALPHA_MODE_SUPPORTED) || \
- defined(PNG_READ_RGB_TO_GRAY_SUPPORTED)
+# if GAMMA_TRANSFORMS
if ((png_ptr->transformations & (PNG_COMPOSE | PNG_RGB_TO_GRAY)) != 0)
{
png_build_16bit_table(png_ptr, &png_ptr->gamma_16_to_1, shift,
- png_reciprocal(png_ptr->colorspace.gamma));
+ file_to_linear);
/* Notice that the '16 from 1' table should be full precision, however
* the lookup on this table still uses gamma_shift, so it can't be.
* TODO: fix this.
*/
png_build_16bit_table(png_ptr, &png_ptr->gamma_16_from_1, shift,
- png_ptr->screen_gamma > 0 ? png_reciprocal(png_ptr->screen_gamma) :
- png_ptr->colorspace.gamma/* Probably doing rgb_to_gray */);
+ linear_to_screen);
}
-#endif /* READ_BACKGROUND || READ_ALPHA_MODE || RGB_TO_GRAY */
+#endif /* GAMMA_TRANSFORMS */
}
#endif /* 16BIT */
}
@@ -4535,7 +3972,7 @@ png_image_free_function(png_voidp argument)
# ifdef PNG_STDIO_SUPPORTED
if (cp->owned_file != 0)
{
- FILE *fp = png_voidcast(FILE*, cp->png_ptr->io_ptr);
+ FILE *fp = png_voidcast(FILE *, cp->png_ptr->io_ptr);
cp->owned_file = 0;
/* Ignore errors here. */
diff --git a/src/libs/Irrlicht/irrlicht-svn/source/Irrlicht/libpng/png.h b/src/libs/Irrlicht/irrlicht-svn/source/Irrlicht/libpng/png.h
index 1cc28bfe..6d6a5a75 100644
--- a/src/libs/Irrlicht/irrlicht-svn/source/Irrlicht/libpng/png.h
+++ b/src/libs/Irrlicht/irrlicht-svn/source/Irrlicht/libpng/png.h
@@ -1,9 +1,8 @@
-
/* png.h - header file for PNG reference library
*
- * libpng version 1.6.37 - April 14, 2019
+ * libpng version 1.6.54
*
- * Copyright (c) 2018-2019 Cosmin Truta
+ * Copyright (c) 2018-2026 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 +14,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.37, April 2019:
+ * libpng versions 1.6.36, December 2018, through 1.6.54, January 2026:
* Cosmin Truta
* See also "Contributing Authors", below.
*/
@@ -27,8 +26,8 @@
* PNG Reference Library License version 2
* ---------------------------------------
*
- * * Copyright (c) 1995-2019 The PNG Reference Library Authors.
- * * Copyright (c) 2018-2019 Cosmin Truta.
+ * * Copyright (c) 1995-2026 The PNG Reference Library Authors.
+ * * Copyright (c) 2018-2026 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 +238,7 @@
* ...
* 1.5.30 15 10530 15.so.15.30[.0]
* ...
- * 1.6.37 16 10637 16.so.16.37[.0]
+ * 1.6.54 16 10654 16.so.16.54[.0]
*
* Henceforth the source version will match the shared-library major and
* minor numbers; the shared-library major version number will be used for
@@ -255,9 +254,6 @@
* to the info_ptr or png_ptr members through png.h, and the compiled
* application is loaded with a different version of the library.
*
- * DLLNUM will change each time there are forward or backward changes
- * in binary compatibility (e.g., when a new feature is added).
- *
* See libpng.txt or libpng.3 for more information. The PNG specification
* is available as a W3C Recommendation and as an ISO/IEC Standard; see
*
@@ -278,27 +274,29 @@
*/
/* Version information for png.h - this should match the version in png.c */
-#define PNG_LIBPNG_VER_STRING "1.6.37"
-#define PNG_HEADER_VERSION_STRING " libpng version 1.6.37 - April 14, 2019\n"
+#define PNG_LIBPNG_VER_STRING "1.6.54"
+#define PNG_HEADER_VERSION_STRING " libpng version " PNG_LIBPNG_VER_STRING "\n"
-#define PNG_LIBPNG_VER_SONUM 16
-#define PNG_LIBPNG_VER_DLLNUM 16
+/* The versions of shared library builds should stay in sync, going forward */
+#define PNG_LIBPNG_VER_SHAREDLIB 16
+#define PNG_LIBPNG_VER_SONUM PNG_LIBPNG_VER_SHAREDLIB /* [Deprecated] */
+#define PNG_LIBPNG_VER_DLLNUM PNG_LIBPNG_VER_SHAREDLIB /* [Deprecated] */
/* 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 37
+#define PNG_LIBPNG_VER_RELEASE 54
/* This should be zero for a public release, or non-zero for a
- * development version. [Deprecated]
+ * development version.
*/
-#define PNG_LIBPNG_VER_BUILD 0
+#define PNG_LIBPNG_VER_BUILD 0
/* Release Status */
-#define PNG_LIBPNG_BUILD_ALPHA 1
-#define PNG_LIBPNG_BUILD_BETA 2
-#define PNG_LIBPNG_BUILD_RC 3
-#define PNG_LIBPNG_BUILD_STABLE 4
+#define PNG_LIBPNG_BUILD_ALPHA 1
+#define PNG_LIBPNG_BUILD_BETA 2
+#define PNG_LIBPNG_BUILD_RC 3
+#define PNG_LIBPNG_BUILD_STABLE 4
#define PNG_LIBPNG_BUILD_RELEASE_STATUS_MASK 7
/* Release-Specific Flags */
@@ -318,7 +316,7 @@
* From version 1.0.1 it is:
* XXYYZZ, where XX=major, YY=minor, ZZ=release
*/
-#define PNG_LIBPNG_VER 10637 /* 1.6.37 */
+#define PNG_LIBPNG_VER 10654 /* 1.6.54 */
/* Library configuration: these options cannot be changed after
* the library has been built.
@@ -428,7 +426,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_37;
+typedef char *png_libpng_version_1_6_54;
/* Basic control structions. Read libpng-manual.txt or libpng.3 for more info.
*
@@ -746,6 +744,21 @@ typedef png_unknown_chunk * * png_unknown_chunkpp;
#define PNG_INFO_sCAL 0x4000U /* ESR, 1.0.6 */
#define PNG_INFO_IDAT 0x8000U /* ESR, 1.0.6 */
#define PNG_INFO_eXIf 0x10000U /* GR-P, 1.6.31 */
+#define PNG_INFO_cICP 0x20000U /* PNGv3: 1.6.45 */
+#define PNG_INFO_cLLI 0x40000U /* PNGv3: 1.6.45 */
+#define PNG_INFO_mDCV 0x80000U /* PNGv3: 1.6.45 */
+/* APNG: these chunks are stored as unknown, these flags are never set
+ * however they are provided as a convenience for implementors of APNG and
+ * avoids any merge conflicts.
+ *
+ * Private chunks: these chunk names violate the chunk name recommendations
+ * because the chunk definitions have no signature and because the private
+ * chunks with these names have been reserved. Private definitions should
+ * avoid them.
+ */
+#define PNG_INFO_acTL 0x100000U /* PNGv3: 1.6.45: unknown */
+#define PNG_INFO_fcTL 0x200000U /* PNGv3: 1.6.45: unknown */
+#define PNG_INFO_fdAT 0x400000U /* PNGv3: 1.6.45: unknown */
/* This is used for the transformation routines, as some of them
* change these values for the row. It also should enable using
@@ -772,17 +785,22 @@ typedef png_row_info * * png_row_infopp;
* modify the buffer it is passed. The 'read' function, on the other hand, is
* expected to return the read data in the buffer.
*/
-typedef PNG_CALLBACK(void, *png_error_ptr, (png_structp, png_const_charp));
-typedef PNG_CALLBACK(void, *png_rw_ptr, (png_structp, png_bytep, size_t));
-typedef PNG_CALLBACK(void, *png_flush_ptr, (png_structp));
-typedef PNG_CALLBACK(void, *png_read_status_ptr, (png_structp, png_uint_32,
- int));
-typedef PNG_CALLBACK(void, *png_write_status_ptr, (png_structp, png_uint_32,
- int));
+typedef PNG_CALLBACK(void, *png_error_ptr,
+ (png_structp, png_const_charp));
+typedef PNG_CALLBACK(void, *png_rw_ptr,
+ (png_structp, png_bytep, size_t));
+typedef PNG_CALLBACK(void, *png_flush_ptr,
+ (png_structp));
+typedef PNG_CALLBACK(void, *png_read_status_ptr,
+ (png_structp, png_uint_32, int));
+typedef PNG_CALLBACK(void, *png_write_status_ptr,
+ (png_structp, png_uint_32, int));
#ifdef PNG_PROGRESSIVE_READ_SUPPORTED
-typedef PNG_CALLBACK(void, *png_progressive_info_ptr, (png_structp, png_infop));
-typedef PNG_CALLBACK(void, *png_progressive_end_ptr, (png_structp, png_infop));
+typedef PNG_CALLBACK(void, *png_progressive_info_ptr,
+ (png_structp, png_infop));
+typedef PNG_CALLBACK(void, *png_progressive_end_ptr,
+ (png_structp, png_infop));
/* The following callback receives png_uint_32 row_number, int pass for the
* png_bytep data of the row. When transforming an interlaced image the
@@ -794,19 +812,19 @@ typedef PNG_CALLBACK(void, *png_progressive_end_ptr, (png_structp, png_infop));
* find the output pixel (x,y) given an interlaced sub-image pixel
* (row,col,pass). (See below for these macros.)
*/
-typedef PNG_CALLBACK(void, *png_progressive_row_ptr, (png_structp, png_bytep,
- png_uint_32, int));
+typedef PNG_CALLBACK(void, *png_progressive_row_ptr,
+ (png_structp, png_bytep, png_uint_32, int));
#endif
#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \
defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED)
-typedef PNG_CALLBACK(void, *png_user_transform_ptr, (png_structp, png_row_infop,
- png_bytep));
+typedef PNG_CALLBACK(void, *png_user_transform_ptr,
+ (png_structp, png_row_infop, png_bytep));
#endif
#ifdef PNG_USER_CHUNKS_SUPPORTED
-typedef PNG_CALLBACK(int, *png_user_chunk_ptr, (png_structp,
- png_unknown_chunkp));
+typedef PNG_CALLBACK(int, *png_user_chunk_ptr,
+ (png_structp, png_unknown_chunkp));
#endif
#ifdef PNG_UNKNOWN_CHUNKS_SUPPORTED
/* not used anywhere */
@@ -825,7 +843,7 @@ typedef PNG_CALLBACK(int, *png_user_chunk_ptr, (png_structp,
* your compiler. This may be very difficult - try using a different compiler
* to build the library!
*/
-PNG_FUNCTION(void, (PNGCAPI *png_longjmp_ptr), PNGARG((jmp_buf, int)), typedef);
+PNG_FUNCTION(void, (PNGCAPI *png_longjmp_ptr), (jmp_buf, int), typedef);
#endif
/* Transform masks for the high-level interface */
@@ -849,7 +867,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
@@ -864,9 +882,10 @@ PNG_FUNCTION(void, (PNGCAPI *png_longjmp_ptr), PNGARG((jmp_buf, int)), typedef);
* ignores the first argument) should be completely compatible with the
* following.
*/
-typedef PNG_CALLBACK(png_voidp, *png_malloc_ptr, (png_structp,
- png_alloc_size_t));
-typedef PNG_CALLBACK(void, *png_free_ptr, (png_structp, png_voidp));
+typedef PNG_CALLBACK(png_voidp, *png_malloc_ptr,
+ (png_structp, png_alloc_size_t));
+typedef PNG_CALLBACK(void, *png_free_ptr,
+ (png_structp, png_voidp));
/* Section 4: exported functions
* Here are the function definitions most commonly used. This is not
@@ -898,43 +917,45 @@ typedef PNG_CALLBACK(void, *png_free_ptr, (png_structp, png_voidp));
*/
/* Returns the version number of the library */
-PNG_EXPORT(1, png_uint_32, png_access_version_number, (void));
+PNG_EXPORT(1, png_uint_32, png_access_version_number,
+ (void));
/* Tell lib we have already handled the first magic bytes.
* Handling more than 8 bytes from the beginning of the file is an error.
*/
-PNG_EXPORT(2, void, png_set_sig_bytes, (png_structrp png_ptr, int num_bytes));
+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));
+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) /* DEPRECATED */
/* Allocate and initialize png_ptr struct for reading, and any other memory. */
PNG_EXPORTA(4, png_structp, png_create_read_struct,
- (png_const_charp user_png_ver, png_voidp error_ptr,
- png_error_ptr error_fn, png_error_ptr warn_fn),
- PNG_ALLOCATED);
+ (png_const_charp user_png_ver,
+ png_voidp error_ptr, png_error_ptr error_fn, png_error_ptr warn_fn),
+ PNG_ALLOCATED);
/* Allocate and initialize png_ptr struct for writing, and any other memory */
PNG_EXPORTA(5, png_structp, png_create_write_struct,
- (png_const_charp user_png_ver, png_voidp error_ptr, png_error_ptr error_fn,
- png_error_ptr warn_fn),
- PNG_ALLOCATED);
+ (png_const_charp user_png_ver,
+ png_voidp error_ptr, png_error_ptr error_fn, png_error_ptr warn_fn),
+ PNG_ALLOCATED);
PNG_EXPORT(6, size_t, png_get_compression_buffer_size,
- (png_const_structrp png_ptr));
+ (png_const_structrp png_ptr));
-PNG_EXPORT(7, void, png_set_compression_buffer_size, (png_structrp png_ptr,
- size_t size));
+PNG_EXPORT(7, void, png_set_compression_buffer_size,
+ (png_structrp png_ptr, size_t size));
/* Moved from pngconf.h in 1.4.0 and modified to ensure setjmp/longjmp
* match up.
@@ -947,8 +968,8 @@ PNG_EXPORT(7, void, png_set_compression_buffer_size, (png_structrp png_ptr,
* allocated by the library - the call will return NULL on a mismatch
* indicating an ABI mismatch.
*/
-PNG_EXPORT(8, jmp_buf*, png_set_longjmp_fn, (png_structrp png_ptr,
- png_longjmp_ptr longjmp_fn, size_t jmp_buf_size));
+PNG_EXPORT(8, jmp_buf*, png_set_longjmp_fn,
+ (png_structrp png_ptr, png_longjmp_ptr longjmp_fn, size_t jmp_buf_size));
# define png_jmpbuf(png_ptr) \
(*png_set_longjmp_fn((png_ptr), longjmp, (sizeof (jmp_buf))))
#else
@@ -960,67 +981,77 @@ PNG_EXPORT(8, jmp_buf*, png_set_longjmp_fn, (png_structrp png_ptr,
* will use it; otherwise it will call PNG_ABORT(). This function was
* added in libpng-1.5.0.
*/
-PNG_EXPORTA(9, void, png_longjmp, (png_const_structrp png_ptr, int val),
- PNG_NORETURN);
+PNG_EXPORTA(9, void, png_longjmp,
+ (png_const_structrp png_ptr, int val),
+ PNG_NORETURN);
#ifdef PNG_READ_SUPPORTED
/* Reset the compression stream */
-PNG_EXPORTA(10, int, png_reset_zstream, (png_structrp png_ptr), PNG_DEPRECATED);
+PNG_EXPORTA(10, int, png_reset_zstream,
+ (png_structrp png_ptr),
+ PNG_DEPRECATED);
#endif
/* New functions added in libpng-1.0.2 (not enabled by default until 1.2.0) */
#ifdef PNG_USER_MEM_SUPPORTED
PNG_EXPORTA(11, png_structp, png_create_read_struct_2,
- (png_const_charp user_png_ver, png_voidp error_ptr, png_error_ptr error_fn,
- png_error_ptr warn_fn,
+ (png_const_charp user_png_ver,
+ png_voidp error_ptr, png_error_ptr error_fn, png_error_ptr warn_fn,
png_voidp mem_ptr, png_malloc_ptr malloc_fn, png_free_ptr free_fn),
- PNG_ALLOCATED);
+ PNG_ALLOCATED);
PNG_EXPORTA(12, png_structp, png_create_write_struct_2,
- (png_const_charp user_png_ver, png_voidp error_ptr, png_error_ptr error_fn,
- png_error_ptr warn_fn,
+ (png_const_charp user_png_ver,
+ png_voidp error_ptr, png_error_ptr error_fn, png_error_ptr warn_fn,
png_voidp mem_ptr, png_malloc_ptr malloc_fn, png_free_ptr free_fn),
- PNG_ALLOCATED);
+ PNG_ALLOCATED);
#endif
/* Write the PNG file signature. */
-PNG_EXPORT(13, void, png_write_sig, (png_structrp png_ptr));
+PNG_EXPORT(13, void, png_write_sig,
+ (png_structrp png_ptr));
/* Write a PNG chunk - size, type, (optional) data, CRC. */
-PNG_EXPORT(14, void, png_write_chunk, (png_structrp png_ptr, png_const_bytep
- chunk_name, png_const_bytep data, size_t length));
+PNG_EXPORT(14, void, png_write_chunk,
+ (png_structrp png_ptr,
+ png_const_bytep chunk_name, png_const_bytep data, size_t length));
/* Write the start of a PNG chunk - length and chunk name. */
-PNG_EXPORT(15, void, png_write_chunk_start, (png_structrp png_ptr,
+PNG_EXPORT(15, void, png_write_chunk_start,
+ (png_structrp png_ptr,
png_const_bytep chunk_name, png_uint_32 length));
/* Write the data of a PNG chunk started with png_write_chunk_start(). */
-PNG_EXPORT(16, void, png_write_chunk_data, (png_structrp png_ptr,
+PNG_EXPORT(16, void, png_write_chunk_data,
+ (png_structrp png_ptr,
png_const_bytep data, size_t length));
/* Finish a chunk started with png_write_chunk_start() (includes CRC). */
-PNG_EXPORT(17, void, png_write_chunk_end, (png_structrp png_ptr));
+PNG_EXPORT(17, void, png_write_chunk_end,
+ (png_structrp png_ptr));
/* Allocate and initialize the info structure */
-PNG_EXPORTA(18, png_infop, png_create_info_struct, (png_const_structrp png_ptr),
- PNG_ALLOCATED);
+PNG_EXPORTA(18, png_infop, png_create_info_struct,
+ (png_const_structrp png_ptr),
+ PNG_ALLOCATED);
/* DEPRECATED: this function allowed init structures to be created using the
* default allocation method (typically malloc). Use is deprecated in 1.6.0 and
* the API will be removed in the future.
*/
-PNG_EXPORTA(19, void, png_info_init_3, (png_infopp info_ptr,
- size_t png_info_struct_size), PNG_DEPRECATED);
+PNG_EXPORTA(19, void, png_info_init_3,
+ (png_infopp info_ptr, size_t png_info_struct_size),
+ PNG_DEPRECATED);
/* Writes all the PNG information before the image. */
PNG_EXPORT(20, void, png_write_info_before_PLTE,
- (png_structrp png_ptr, png_const_inforp info_ptr));
+ (png_structrp png_ptr, png_const_inforp info_ptr));
PNG_EXPORT(21, void, png_write_info,
- (png_structrp png_ptr, png_const_inforp info_ptr));
+ (png_structrp png_ptr, png_const_inforp info_ptr));
#ifdef PNG_SEQUENTIAL_READ_SUPPORTED
/* Read the information before the actual image data. */
PNG_EXPORT(22, void, png_read_info,
- (png_structrp png_ptr, png_inforp info_ptr));
+ (png_structrp png_ptr, png_inforp info_ptr));
#endif
#ifdef PNG_TIME_RFC1123_SUPPORTED
@@ -1030,45 +1061,54 @@ PNG_EXPORT(22, void, png_read_info,
*/
#if PNG_LIBPNG_VER < 10700
/* To do: remove this from libpng17 (and from libpng17/png.c and pngstruct.h) */
-PNG_EXPORTA(23, png_const_charp, png_convert_to_rfc1123, (png_structrp png_ptr,
- png_const_timep ptime),PNG_DEPRECATED);
+PNG_EXPORTA(23, png_const_charp, png_convert_to_rfc1123,
+ (png_structrp png_ptr, png_const_timep ptime),
+ PNG_DEPRECATED);
#endif
-PNG_EXPORT(241, int, png_convert_to_rfc1123_buffer, (char out[29],
- png_const_timep ptime));
+PNG_EXPORT(241, int, png_convert_to_rfc1123_buffer,
+ (char out[29], png_const_timep ptime));
#endif
#ifdef PNG_CONVERT_tIME_SUPPORTED
/* Convert from a struct tm to png_time */
-PNG_EXPORT(24, void, png_convert_from_struct_tm, (png_timep ptime,
- const struct tm * ttime));
+PNG_EXPORT(24, void, png_convert_from_struct_tm,
+ (png_timep ptime, const struct tm * ttime));
/* Convert from time_t to png_time. Uses gmtime() */
-PNG_EXPORT(25, void, png_convert_from_time_t, (png_timep ptime, time_t ttime));
+PNG_EXPORT(25, void, png_convert_from_time_t,
+ (png_timep ptime, time_t ttime));
#endif /* CONVERT_tIME */
#ifdef PNG_READ_EXPAND_SUPPORTED
/* Expand data to 24-bit RGB, or 8-bit grayscale, with alpha if available. */
-PNG_EXPORT(26, void, png_set_expand, (png_structrp png_ptr));
-PNG_EXPORT(27, void, png_set_expand_gray_1_2_4_to_8, (png_structrp png_ptr));
-PNG_EXPORT(28, void, png_set_palette_to_rgb, (png_structrp png_ptr));
-PNG_EXPORT(29, void, png_set_tRNS_to_alpha, (png_structrp png_ptr));
+PNG_EXPORT(26, void, png_set_expand,
+ (png_structrp png_ptr));
+PNG_EXPORT(27, void, png_set_expand_gray_1_2_4_to_8,
+ (png_structrp png_ptr));
+PNG_EXPORT(28, void, png_set_palette_to_rgb,
+ (png_structrp png_ptr));
+PNG_EXPORT(29, void, png_set_tRNS_to_alpha,
+ (png_structrp png_ptr));
#endif
#ifdef PNG_READ_EXPAND_16_SUPPORTED
/* Expand to 16-bit channels, forces conversion of palette to RGB and expansion
* of a tRNS chunk if present.
*/
-PNG_EXPORT(221, void, png_set_expand_16, (png_structrp png_ptr));
+PNG_EXPORT(221, void, png_set_expand_16,
+ (png_structrp png_ptr));
#endif
#if defined(PNG_READ_BGR_SUPPORTED) || defined(PNG_WRITE_BGR_SUPPORTED)
/* Use blue, green, red order for pixels. */
-PNG_EXPORT(30, void, png_set_bgr, (png_structrp png_ptr));
+PNG_EXPORT(30, void, png_set_bgr,
+ (png_structrp png_ptr));
#endif
#ifdef PNG_READ_GRAY_TO_RGB_SUPPORTED
/* Expand the grayscale to 24-bit RGB if necessary. */
-PNG_EXPORT(31, void, png_set_gray_to_rgb, (png_structrp png_ptr));
+PNG_EXPORT(31, void, png_set_gray_to_rgb,
+ (png_structrp png_ptr));
#endif
#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED
@@ -1078,18 +1118,20 @@ PNG_EXPORT(31, void, png_set_gray_to_rgb, (png_structrp png_ptr));
#define PNG_ERROR_ACTION_ERROR 3
#define PNG_RGB_TO_GRAY_DEFAULT (-1)/*for red/green coefficients*/
-PNG_FP_EXPORT(32, void, png_set_rgb_to_gray, (png_structrp png_ptr,
+PNG_FP_EXPORT(32, void, png_set_rgb_to_gray,
+ (png_structrp png_ptr,
int error_action, double red, double green))
-PNG_FIXED_EXPORT(33, void, png_set_rgb_to_gray_fixed, (png_structrp png_ptr,
+PNG_FIXED_EXPORT(33, void, png_set_rgb_to_gray_fixed,
+ (png_structrp png_ptr,
int error_action, png_fixed_point red, png_fixed_point green))
-PNG_EXPORT(34, png_byte, png_get_rgb_to_gray_status, (png_const_structrp
- png_ptr));
+PNG_EXPORT(34, png_byte, png_get_rgb_to_gray_status,
+ (png_const_structrp png_ptr));
#endif
#ifdef PNG_BUILD_GRAYSCALE_PALETTE_SUPPORTED
-PNG_EXPORT(35, void, png_build_grayscale_palette, (int bit_depth,
- png_colorp palette));
+PNG_EXPORT(35, void, png_build_grayscale_palette,
+ (int bit_depth, png_colorp palette));
#endif
#ifdef PNG_READ_ALPHA_MODE_SUPPORTED
@@ -1134,10 +1176,10 @@ PNG_EXPORT(35, void, png_build_grayscale_palette, (int bit_depth,
#define PNG_ALPHA_OPTIMIZED 2 /* 'PNG' for opaque pixels, else 'STANDARD' */
#define PNG_ALPHA_BROKEN 3 /* the alpha channel is gamma encoded */
-PNG_FP_EXPORT(227, void, png_set_alpha_mode, (png_structrp png_ptr, int mode,
- double output_gamma))
-PNG_FIXED_EXPORT(228, void, png_set_alpha_mode_fixed, (png_structrp png_ptr,
- int mode, png_fixed_point output_gamma))
+PNG_FP_EXPORT(227, void, png_set_alpha_mode,
+ (png_structrp png_ptr, int mode, double output_gamma))
+PNG_FIXED_EXPORT(228, void, png_set_alpha_mode_fixed,
+ (png_structrp png_ptr, int mode, png_fixed_point output_gamma))
#endif
#if defined(PNG_GAMMA_SUPPORTED) || defined(PNG_READ_ALPHA_MODE_SUPPORTED)
@@ -1227,51 +1269,57 @@ PNG_FIXED_EXPORT(228, void, png_set_alpha_mode_fixed, (png_structrp png_ptr,
*/
#ifdef PNG_READ_STRIP_ALPHA_SUPPORTED
-PNG_EXPORT(36, void, png_set_strip_alpha, (png_structrp png_ptr));
+PNG_EXPORT(36, void, png_set_strip_alpha,
+ (png_structrp png_ptr));
#endif
#if defined(PNG_READ_SWAP_ALPHA_SUPPORTED) || \
defined(PNG_WRITE_SWAP_ALPHA_SUPPORTED)
-PNG_EXPORT(37, void, png_set_swap_alpha, (png_structrp png_ptr));
+PNG_EXPORT(37, void, png_set_swap_alpha,
+ (png_structrp png_ptr));
#endif
#if defined(PNG_READ_INVERT_ALPHA_SUPPORTED) || \
defined(PNG_WRITE_INVERT_ALPHA_SUPPORTED)
-PNG_EXPORT(38, void, png_set_invert_alpha, (png_structrp png_ptr));
+PNG_EXPORT(38, void, png_set_invert_alpha,
+ (png_structrp png_ptr));
#endif
#if defined(PNG_READ_FILLER_SUPPORTED) || defined(PNG_WRITE_FILLER_SUPPORTED)
/* Add a filler byte to 8-bit or 16-bit Gray or 24-bit or 48-bit RGB images. */
-PNG_EXPORT(39, void, png_set_filler, (png_structrp png_ptr, png_uint_32 filler,
- int flags));
+PNG_EXPORT(39, void, png_set_filler,
+ (png_structrp png_ptr, png_uint_32 filler, int flags));
/* The values of the PNG_FILLER_ defines should NOT be changed */
# define PNG_FILLER_BEFORE 0
# define PNG_FILLER_AFTER 1
/* Add an alpha byte to 8-bit or 16-bit Gray or 24-bit or 48-bit RGB images. */
-PNG_EXPORT(40, void, png_set_add_alpha, (png_structrp png_ptr,
- png_uint_32 filler, int flags));
+PNG_EXPORT(40, void, png_set_add_alpha,
+ (png_structrp png_ptr, png_uint_32 filler, int flags));
#endif /* READ_FILLER || WRITE_FILLER */
#if defined(PNG_READ_SWAP_SUPPORTED) || defined(PNG_WRITE_SWAP_SUPPORTED)
/* Swap bytes in 16-bit depth files. */
-PNG_EXPORT(41, void, png_set_swap, (png_structrp png_ptr));
+PNG_EXPORT(41, void, png_set_swap,
+ (png_structrp png_ptr));
#endif
#if defined(PNG_READ_PACK_SUPPORTED) || defined(PNG_WRITE_PACK_SUPPORTED)
/* Use 1 byte per pixel in 1, 2, or 4-bit depth files. */
-PNG_EXPORT(42, void, png_set_packing, (png_structrp png_ptr));
+PNG_EXPORT(42, void, png_set_packing,
+ (png_structrp png_ptr));
#endif
#if defined(PNG_READ_PACKSWAP_SUPPORTED) || \
defined(PNG_WRITE_PACKSWAP_SUPPORTED)
/* Swap packing order of pixels in bytes. */
-PNG_EXPORT(43, void, png_set_packswap, (png_structrp png_ptr));
+PNG_EXPORT(43, void, png_set_packswap,
+ (png_structrp png_ptr));
#endif
#if defined(PNG_READ_SHIFT_SUPPORTED) || defined(PNG_WRITE_SHIFT_SUPPORTED)
/* Converts files to legal bit depths. */
-PNG_EXPORT(44, void, png_set_shift, (png_structrp png_ptr, png_const_color_8p
- true_bits));
+PNG_EXPORT(44, void, png_set_shift,
+ (png_structrp png_ptr, png_const_color_8p true_bits));
#endif
#if defined(PNG_READ_INTERLACING_SUPPORTED) || \
@@ -1282,12 +1330,14 @@ PNG_EXPORT(44, void, png_set_shift, (png_structrp png_ptr, png_const_color_8p
* necessary to call png_read_row or png_read_rows png_get_image_height
* times for each pass.
*/
-PNG_EXPORT(45, int, png_set_interlace_handling, (png_structrp png_ptr));
+PNG_EXPORT(45, int, png_set_interlace_handling,
+ (png_structrp png_ptr));
#endif
#if defined(PNG_READ_INVERT_SUPPORTED) || defined(PNG_WRITE_INVERT_SUPPORTED)
/* Invert monochrome files */
-PNG_EXPORT(46, void, png_set_invert_mono, (png_structrp png_ptr));
+PNG_EXPORT(46, void, png_set_invert_mono,
+ (png_structrp png_ptr));
#endif
#ifdef PNG_READ_BACKGROUND_SUPPORTED
@@ -1296,10 +1346,12 @@ PNG_EXPORT(46, void, png_set_invert_mono, (png_structrp png_ptr));
* read. Doing so will result in unexpected behavior and possible warnings or
* errors if the PNG file contains a bKGD chunk.
*/
-PNG_FP_EXPORT(47, void, png_set_background, (png_structrp png_ptr,
+PNG_FP_EXPORT(47, void, png_set_background,
+ (png_structrp png_ptr,
png_const_color_16p background_color, int background_gamma_code,
int need_expand, double background_gamma))
-PNG_FIXED_EXPORT(215, void, png_set_background_fixed, (png_structrp png_ptr,
+PNG_FIXED_EXPORT(215, void, png_set_background_fixed,
+ (png_structrp png_ptr,
png_const_color_16p background_color, int background_gamma_code,
int need_expand, png_fixed_point background_gamma))
#endif
@@ -1312,20 +1364,23 @@ PNG_FIXED_EXPORT(215, void, png_set_background_fixed, (png_structrp png_ptr,
#ifdef PNG_READ_SCALE_16_TO_8_SUPPORTED
/* Scale a 16-bit depth file down to 8-bit, accurately. */
-PNG_EXPORT(229, void, png_set_scale_16, (png_structrp png_ptr));
+PNG_EXPORT(229, void, png_set_scale_16,
+ (png_structrp png_ptr));
#endif
#ifdef PNG_READ_STRIP_16_TO_8_SUPPORTED
#define PNG_READ_16_TO_8_SUPPORTED /* Name prior to 1.5.4 */
/* Strip the second byte of information from a 16-bit depth file. */
-PNG_EXPORT(48, void, png_set_strip_16, (png_structrp png_ptr));
+PNG_EXPORT(48, void, png_set_strip_16,
+ (png_structrp png_ptr));
#endif
#ifdef PNG_READ_QUANTIZE_SUPPORTED
/* Turn on quantizing, and reduce the palette to the number of colors
* available.
*/
-PNG_EXPORT(49, void, png_set_quantize, (png_structrp png_ptr,
+PNG_EXPORT(49, void, png_set_quantize,
+ (png_structrp png_ptr,
png_colorp palette, int num_palette, int maximum_colors,
png_const_uint_16p histogram, int full_quantize));
#endif
@@ -1347,82 +1402,92 @@ PNG_EXPORT(49, void, png_set_quantize, (png_structrp png_ptr,
* API (floating point or fixed.) Notice, however, that the 'file_gamma' value
* is the inverse of a 'screen gamma' value.
*/
-PNG_FP_EXPORT(50, void, png_set_gamma, (png_structrp png_ptr,
+PNG_FP_EXPORT(50, void, png_set_gamma,
+ (png_structrp png_ptr,
double screen_gamma, double override_file_gamma))
-PNG_FIXED_EXPORT(208, void, png_set_gamma_fixed, (png_structrp png_ptr,
+PNG_FIXED_EXPORT(208, void, png_set_gamma_fixed,
+ (png_structrp png_ptr,
png_fixed_point screen_gamma, png_fixed_point override_file_gamma))
#endif
#ifdef PNG_WRITE_FLUSH_SUPPORTED
/* Set how many lines between output flushes - 0 for no flushing */
-PNG_EXPORT(51, void, png_set_flush, (png_structrp png_ptr, int nrows));
+PNG_EXPORT(51, void, png_set_flush,
+ (png_structrp png_ptr, int nrows));
/* Flush the current PNG output buffer */
-PNG_EXPORT(52, void, png_write_flush, (png_structrp png_ptr));
+PNG_EXPORT(52, void, png_write_flush,
+ (png_structrp png_ptr));
#endif
/* Optional update palette with requested transformations */
-PNG_EXPORT(53, void, png_start_read_image, (png_structrp png_ptr));
+PNG_EXPORT(53, void, png_start_read_image,
+ (png_structrp png_ptr));
/* Optional call to update the users info structure */
-PNG_EXPORT(54, void, png_read_update_info, (png_structrp png_ptr,
- png_inforp info_ptr));
+PNG_EXPORT(54, void, png_read_update_info,
+ (png_structrp png_ptr, png_inforp info_ptr));
#ifdef PNG_SEQUENTIAL_READ_SUPPORTED
/* Read one or more rows of image data. */
-PNG_EXPORT(55, void, png_read_rows, (png_structrp png_ptr, png_bytepp row,
+PNG_EXPORT(55, void, png_read_rows,
+ (png_structrp png_ptr, png_bytepp row,
png_bytepp display_row, png_uint_32 num_rows));
#endif
#ifdef PNG_SEQUENTIAL_READ_SUPPORTED
/* Read a row of data. */
-PNG_EXPORT(56, void, png_read_row, (png_structrp png_ptr, png_bytep row,
- png_bytep display_row));
+PNG_EXPORT(56, void, png_read_row,
+ (png_structrp png_ptr, png_bytep row, png_bytep display_row));
#endif
#ifdef PNG_SEQUENTIAL_READ_SUPPORTED
/* Read the whole image into memory at once. */
-PNG_EXPORT(57, void, png_read_image, (png_structrp png_ptr, png_bytepp image));
+PNG_EXPORT(57, void, png_read_image,
+ (png_structrp png_ptr, png_bytepp image));
#endif
/* Write a row of image data */
-PNG_EXPORT(58, void, png_write_row, (png_structrp png_ptr,
- png_const_bytep row));
+PNG_EXPORT(58, void, png_write_row,
+ (png_structrp png_ptr, png_const_bytep row));
/* Write a few rows of image data: (*row) is not written; however, the type
* is declared as writeable to maintain compatibility with previous versions
* of libpng and to allow the 'display_row' array from read_rows to be passed
* unchanged to write_rows.
*/
-PNG_EXPORT(59, void, png_write_rows, (png_structrp png_ptr, png_bytepp row,
- png_uint_32 num_rows));
+PNG_EXPORT(59, void, png_write_rows,
+ (png_structrp png_ptr, png_bytepp row, png_uint_32 num_rows));
/* Write the image data */
-PNG_EXPORT(60, void, png_write_image, (png_structrp png_ptr, png_bytepp image));
+PNG_EXPORT(60, void, png_write_image,
+ (png_structrp png_ptr, png_bytepp image));
/* Write the end of the PNG file. */
-PNG_EXPORT(61, void, png_write_end, (png_structrp png_ptr,
- png_inforp info_ptr));
+PNG_EXPORT(61, void, png_write_end,
+ (png_structrp png_ptr, png_inforp info_ptr));
#ifdef PNG_SEQUENTIAL_READ_SUPPORTED
/* Read the end of the PNG file. */
-PNG_EXPORT(62, void, png_read_end, (png_structrp png_ptr, png_inforp info_ptr));
+PNG_EXPORT(62, void, png_read_end,
+ (png_structrp png_ptr, png_inforp info_ptr));
#endif
/* Free any memory associated with the png_info_struct */
-PNG_EXPORT(63, void, png_destroy_info_struct, (png_const_structrp png_ptr,
- png_infopp info_ptr_ptr));
+PNG_EXPORT(63, void, png_destroy_info_struct,
+ (png_const_structrp png_ptr, png_infopp info_ptr_ptr));
/* Free any memory associated with the png_struct and the png_info_structs */
-PNG_EXPORT(64, void, png_destroy_read_struct, (png_structpp png_ptr_ptr,
+PNG_EXPORT(64, void, png_destroy_read_struct,
+ (png_structpp png_ptr_ptr,
png_infopp info_ptr_ptr, png_infopp end_info_ptr_ptr));
/* Free any memory associated with the png_struct and the png_info_structs */
-PNG_EXPORT(65, void, png_destroy_write_struct, (png_structpp png_ptr_ptr,
- png_infopp info_ptr_ptr));
+PNG_EXPORT(65, void, png_destroy_write_struct,
+ (png_structpp png_ptr_ptr, png_infopp info_ptr_ptr));
/* Set the libpng method of handling chunk CRC errors */
-PNG_EXPORT(66, void, png_set_crc_action, (png_structrp png_ptr, int crit_action,
- int ancil_action));
+PNG_EXPORT(66, void, png_set_crc_action,
+ (png_structrp png_ptr, int crit_action, int ancil_action));
/* Values for png_set_crc_action() say how to handle CRC errors in
* ancillary and critical chunks, and whether to use the data contained
@@ -1446,14 +1511,14 @@ PNG_EXPORT(66, void, png_set_crc_action, (png_structrp png_ptr, int crit_action,
* mainly useful for testing, as the defaults should work with most users.
* Those users who are tight on memory or want faster performance at the
* expense of compression can modify them. See the compression library
- * header file (zlib.h) for an explination of the compression functions.
+ * header file (zlib.h) for an explanation of the compression functions.
*/
/* Set the filtering method(s) used by libpng. Currently, the only valid
* value for "method" is 0.
*/
-PNG_EXPORT(67, void, png_set_filter, (png_structrp png_ptr, int method,
- int filters));
+PNG_EXPORT(67, void, png_set_filter,
+ (png_structrp png_ptr, int method, int filters));
#endif /* WRITE */
/* Flags for png_set_filter() to say which filters to use. The flags
@@ -1482,11 +1547,14 @@ PNG_EXPORT(67, void, png_set_filter, (png_structrp png_ptr, int method,
#ifdef PNG_WRITE_SUPPORTED
#ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED /* DEPRECATED */
-PNG_FP_EXPORT(68, void, png_set_filter_heuristics, (png_structrp png_ptr,
- int heuristic_method, int num_weights, png_const_doublep filter_weights,
+PNG_FP_EXPORT(68, void, png_set_filter_heuristics,
+ (png_structrp png_ptr,
+ int heuristic_method, int num_weights,
+ png_const_doublep filter_weights,
png_const_doublep filter_costs))
PNG_FIXED_EXPORT(209, void, png_set_filter_heuristics_fixed,
- (png_structrp png_ptr, int heuristic_method, int num_weights,
+ (png_structrp png_ptr,
+ int heuristic_method, int num_weights,
png_const_fixed_point_p filter_weights,
png_const_fixed_point_p filter_costs))
#endif /* WRITE_WEIGHTED_FILTER */
@@ -1501,48 +1569,48 @@ PNG_FIXED_EXPORT(209, void, png_set_filter_heuristics_fixed,
* 0 - 9, corresponding directly to the zlib compression levels 0 - 9
* (0 - no compression, 9 - "maximal" compression). Note that tests have
* shown that zlib compression levels 3-6 usually perform as well as level 9
- * for PNG images, and do considerably fewer caclulations. In the future,
+ * for PNG images, and do considerably fewer calculations. In the future,
* these values may not correspond directly to the zlib compression levels.
*/
#ifdef PNG_WRITE_CUSTOMIZE_COMPRESSION_SUPPORTED
-PNG_EXPORT(69, void, png_set_compression_level, (png_structrp png_ptr,
- int level));
+PNG_EXPORT(69, void, png_set_compression_level,
+ (png_structrp png_ptr, int level));
-PNG_EXPORT(70, void, png_set_compression_mem_level, (png_structrp png_ptr,
- int mem_level));
+PNG_EXPORT(70, void, png_set_compression_mem_level,
+ (png_structrp png_ptr, int mem_level));
-PNG_EXPORT(71, void, png_set_compression_strategy, (png_structrp png_ptr,
- int strategy));
+PNG_EXPORT(71, void, png_set_compression_strategy,
+ (png_structrp png_ptr, int strategy));
/* If PNG_WRITE_OPTIMIZE_CMF_SUPPORTED is defined, libpng will use a
* smaller value of window_bits if it can do so safely.
*/
-PNG_EXPORT(72, void, png_set_compression_window_bits, (png_structrp png_ptr,
- int window_bits));
+PNG_EXPORT(72, void, png_set_compression_window_bits,
+ (png_structrp png_ptr, int window_bits));
-PNG_EXPORT(73, void, png_set_compression_method, (png_structrp png_ptr,
- int method));
+PNG_EXPORT(73, void, png_set_compression_method,
+ (png_structrp png_ptr, int method));
#endif /* WRITE_CUSTOMIZE_COMPRESSION */
#ifdef PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION_SUPPORTED
/* Also set zlib parameters for compressing non-IDAT chunks */
-PNG_EXPORT(222, void, png_set_text_compression_level, (png_structrp png_ptr,
- int level));
+PNG_EXPORT(222, void, png_set_text_compression_level,
+ (png_structrp png_ptr, int level));
-PNG_EXPORT(223, void, png_set_text_compression_mem_level, (png_structrp png_ptr,
- int mem_level));
+PNG_EXPORT(223, void, png_set_text_compression_mem_level,
+ (png_structrp png_ptr, int mem_level));
-PNG_EXPORT(224, void, png_set_text_compression_strategy, (png_structrp png_ptr,
- int strategy));
+PNG_EXPORT(224, void, png_set_text_compression_strategy,
+ (png_structrp png_ptr, int strategy));
/* If PNG_WRITE_OPTIMIZE_CMF_SUPPORTED is defined, libpng will use a
* smaller value of window_bits if it can do so safely.
*/
PNG_EXPORT(225, void, png_set_text_compression_window_bits,
- (png_structrp png_ptr, int window_bits));
+ (png_structrp png_ptr, int window_bits));
-PNG_EXPORT(226, void, png_set_text_compression_method, (png_structrp png_ptr,
- int method));
+PNG_EXPORT(226, void, png_set_text_compression_method,
+ (png_structrp png_ptr, int method));
#endif /* WRITE_CUSTOMIZE_ZTXT_COMPRESSION */
#endif /* WRITE */
@@ -1557,7 +1625,8 @@ PNG_EXPORT(226, void, png_set_text_compression_method, (png_structrp png_ptr,
#ifdef PNG_STDIO_SUPPORTED
/* Initialize the input/output for the PNG file to the default functions. */
-PNG_EXPORT(74, void, png_init_io, (png_structrp png_ptr, png_FILE_p fp));
+PNG_EXPORT(74, void, png_init_io,
+ (png_structrp png_ptr, FILE *fp));
#endif
/* Replace the (error and abort), and warning functions with user
@@ -1568,11 +1637,13 @@ PNG_EXPORT(74, void, png_init_io, (png_structrp png_ptr, png_FILE_p fp));
* default function will be used.
*/
-PNG_EXPORT(75, void, png_set_error_fn, (png_structrp png_ptr,
+PNG_EXPORT(75, void, png_set_error_fn,
+ (png_structrp png_ptr,
png_voidp error_ptr, png_error_ptr error_fn, png_error_ptr warning_fn));
/* Return the user pointer associated with the error functions */
-PNG_EXPORT(76, png_voidp, png_get_error_ptr, (png_const_structrp png_ptr));
+PNG_EXPORT(76, png_voidp, png_get_error_ptr,
+ (png_const_structrp png_ptr));
/* Replace the default data output functions with a user supplied one(s).
* If buffered output is not used, then output_flush_fn can be set to NULL.
@@ -1584,47 +1655,54 @@ PNG_EXPORT(76, png_voidp, png_get_error_ptr, (png_const_structrp png_ptr));
* default flush function, which uses the standard *FILE structure, will
* be used.
*/
-PNG_EXPORT(77, void, png_set_write_fn, (png_structrp png_ptr, png_voidp io_ptr,
+PNG_EXPORT(77, void, png_set_write_fn,
+ (png_structrp png_ptr,
+ png_voidp io_ptr,
png_rw_ptr write_data_fn, png_flush_ptr output_flush_fn));
/* Replace the default data input function with a user supplied one. */
-PNG_EXPORT(78, void, png_set_read_fn, (png_structrp png_ptr, png_voidp io_ptr,
- png_rw_ptr read_data_fn));
+PNG_EXPORT(78, void, png_set_read_fn,
+ (png_structrp png_ptr,
+ png_voidp io_ptr, png_rw_ptr read_data_fn));
/* Return the user pointer associated with the I/O functions */
-PNG_EXPORT(79, png_voidp, png_get_io_ptr, (png_const_structrp png_ptr));
+PNG_EXPORT(79, png_voidp, png_get_io_ptr,
+ (png_const_structrp png_ptr));
-PNG_EXPORT(80, void, png_set_read_status_fn, (png_structrp png_ptr,
- png_read_status_ptr read_row_fn));
+PNG_EXPORT(80, void, png_set_read_status_fn,
+ (png_structrp png_ptr, png_read_status_ptr read_row_fn));
-PNG_EXPORT(81, void, png_set_write_status_fn, (png_structrp png_ptr,
- png_write_status_ptr write_row_fn));
+PNG_EXPORT(81, void, png_set_write_status_fn,
+ (png_structrp png_ptr, png_write_status_ptr write_row_fn));
#ifdef PNG_USER_MEM_SUPPORTED
/* Replace the default memory allocation functions with user supplied one(s). */
-PNG_EXPORT(82, void, png_set_mem_fn, (png_structrp png_ptr, png_voidp mem_ptr,
- png_malloc_ptr malloc_fn, png_free_ptr free_fn));
+PNG_EXPORT(82, void, png_set_mem_fn,
+ (png_structrp png_ptr,
+ png_voidp mem_ptr, png_malloc_ptr malloc_fn, png_free_ptr free_fn));
/* Return the user pointer associated with the memory functions */
-PNG_EXPORT(83, png_voidp, png_get_mem_ptr, (png_const_structrp png_ptr));
+PNG_EXPORT(83, png_voidp, png_get_mem_ptr,
+ (png_const_structrp png_ptr));
#endif
#ifdef PNG_READ_USER_TRANSFORM_SUPPORTED
-PNG_EXPORT(84, void, png_set_read_user_transform_fn, (png_structrp png_ptr,
- png_user_transform_ptr read_user_transform_fn));
+PNG_EXPORT(84, void, png_set_read_user_transform_fn,
+ (png_structrp png_ptr, png_user_transform_ptr read_user_transform_fn));
#endif
#ifdef PNG_WRITE_USER_TRANSFORM_SUPPORTED
-PNG_EXPORT(85, void, png_set_write_user_transform_fn, (png_structrp png_ptr,
- png_user_transform_ptr write_user_transform_fn));
+PNG_EXPORT(85, void, png_set_write_user_transform_fn,
+ (png_structrp png_ptr, png_user_transform_ptr write_user_transform_fn));
#endif
#ifdef PNG_USER_TRANSFORM_PTR_SUPPORTED
-PNG_EXPORT(86, void, png_set_user_transform_info, (png_structrp png_ptr,
- png_voidp user_transform_ptr, int user_transform_depth,
- int user_transform_channels));
+PNG_EXPORT(86, void, png_set_user_transform_info,
+ (png_structrp png_ptr,
+ png_voidp user_transform_ptr,
+ int user_transform_depth, int user_transform_channels));
/* Return the user pointer associated with the user transform functions */
PNG_EXPORT(87, png_voidp, png_get_user_transform_ptr,
- (png_const_structrp png_ptr));
+ (png_const_structrp png_ptr));
#endif
#ifdef PNG_USER_TRANSFORM_INFO_SUPPORTED
@@ -1639,8 +1717,10 @@ PNG_EXPORT(87, png_voidp, png_get_user_transform_ptr,
* find the output pixel (x,y) given an interlaced sub-image pixel
* (row,col,pass). (See below for these macros.)
*/
-PNG_EXPORT(217, png_uint_32, png_get_current_row_number, (png_const_structrp));
-PNG_EXPORT(218, png_byte, png_get_current_pass_number, (png_const_structrp));
+PNG_EXPORT(217, png_uint_32, png_get_current_row_number,
+ (png_const_structrp));
+PNG_EXPORT(218, png_byte, png_get_current_pass_number,
+ (png_const_structrp));
#endif
#ifdef PNG_READ_USER_CHUNKS_SUPPORTED
@@ -1663,28 +1743,32 @@ PNG_EXPORT(218, png_byte, png_get_current_pass_number, (png_const_structrp));
* See "INTERACTION WITH USER CHUNK CALLBACKS" below for important notes about
* how this behavior will change in libpng 1.7
*/
-PNG_EXPORT(88, void, png_set_read_user_chunk_fn, (png_structrp png_ptr,
+PNG_EXPORT(88, void, png_set_read_user_chunk_fn,
+ (png_structrp png_ptr,
png_voidp user_chunk_ptr, png_user_chunk_ptr read_user_chunk_fn));
#endif
#ifdef PNG_USER_CHUNKS_SUPPORTED
-PNG_EXPORT(89, png_voidp, png_get_user_chunk_ptr, (png_const_structrp png_ptr));
+PNG_EXPORT(89, png_voidp, png_get_user_chunk_ptr,
+ (png_const_structrp png_ptr));
#endif
#ifdef PNG_PROGRESSIVE_READ_SUPPORTED
/* Sets the function callbacks for the push reader, and a pointer to a
* user-defined structure available to the callback functions.
*/
-PNG_EXPORT(90, void, png_set_progressive_read_fn, (png_structrp png_ptr,
+PNG_EXPORT(90, void, png_set_progressive_read_fn,
+ (png_structrp png_ptr,
png_voidp progressive_ptr, png_progressive_info_ptr info_fn,
png_progressive_row_ptr row_fn, png_progressive_end_ptr end_fn));
/* Returns the user pointer associated with the push read functions */
PNG_EXPORT(91, png_voidp, png_get_progressive_ptr,
- (png_const_structrp png_ptr));
+ (png_const_structrp png_ptr));
/* Function to be called when data becomes available */
-PNG_EXPORT(92, void, png_process_data, (png_structrp png_ptr,
+PNG_EXPORT(92, void, png_process_data,
+ (png_structrp png_ptr,
png_inforp info_ptr, png_bytep buffer, size_t buffer_size));
/* A function which may be called *only* within png_process_data to stop the
@@ -1694,7 +1778,8 @@ PNG_EXPORT(92, void, png_process_data, (png_structrp png_ptr,
* 'save' is set to true the routine will first save all the pending data and
* will always return 0.
*/
-PNG_EXPORT(219, size_t, png_process_data_pause, (png_structrp, int save));
+PNG_EXPORT(219, size_t, png_process_data_pause,
+ (png_structrp, int save));
/* A function which may be called *only* outside (after) a call to
* png_process_data. It returns the number of bytes of data to skip in the
@@ -1702,48 +1787,53 @@ PNG_EXPORT(219, size_t, png_process_data_pause, (png_structrp, int save));
* application must skip than number of bytes of input data and pass the
* following data to the next call to png_process_data.
*/
-PNG_EXPORT(220, png_uint_32, png_process_data_skip, (png_structrp));
+PNG_EXPORT(220, png_uint_32, png_process_data_skip,
+ (png_structrp));
/* Function that combines rows. 'new_row' is a flag that should come from
* the callback and be non-NULL if anything needs to be done; the library
* stores its own version of the new data internally and ignores the passed
* in value.
*/
-PNG_EXPORT(93, void, png_progressive_combine_row, (png_const_structrp png_ptr,
+PNG_EXPORT(93, void, png_progressive_combine_row,
+ (png_const_structrp png_ptr,
png_bytep old_row, png_const_bytep new_row));
#endif /* PROGRESSIVE_READ */
-PNG_EXPORTA(94, png_voidp, png_malloc, (png_const_structrp png_ptr,
- png_alloc_size_t size), PNG_ALLOCATED);
+PNG_EXPORTA(94, png_voidp, png_malloc,
+ (png_const_structrp png_ptr, png_alloc_size_t size),
+ PNG_ALLOCATED);
/* Added at libpng version 1.4.0 */
-PNG_EXPORTA(95, png_voidp, png_calloc, (png_const_structrp png_ptr,
- png_alloc_size_t size), PNG_ALLOCATED);
+PNG_EXPORTA(95, png_voidp, png_calloc,
+ (png_const_structrp png_ptr, png_alloc_size_t size),
+ PNG_ALLOCATED);
/* Added at libpng version 1.2.4 */
-PNG_EXPORTA(96, png_voidp, png_malloc_warn, (png_const_structrp png_ptr,
- png_alloc_size_t size), PNG_ALLOCATED);
+PNG_EXPORTA(96, png_voidp, png_malloc_warn,
+ (png_const_structrp png_ptr, png_alloc_size_t size),
+ PNG_ALLOCATED);
/* Frees a pointer allocated by png_malloc() */
-PNG_EXPORT(97, void, png_free, (png_const_structrp png_ptr, png_voidp ptr));
+PNG_EXPORT(97, void, png_free,
+ (png_const_structrp png_ptr, png_voidp ptr));
/* Free data that was allocated internally */
-PNG_EXPORT(98, void, png_free_data, (png_const_structrp png_ptr,
- png_inforp info_ptr, png_uint_32 free_me, int num));
+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));
+PNG_EXPORT(99, void, png_data_freer,
+ (png_const_structrp png_ptr, png_inforp info_ptr,
+ int freer, png_uint_32 mask));
/* Assignments for png_data_freer */
#define PNG_DESTROY_WILL_FREE_DATA 1
-#define PNG_SET_WILL_FREE_DATA 1
-#define PNG_USER_WILL_FREE_DATA 2
+#define PNG_SET_WILL_FREE_DATA 1
+#define PNG_USER_WILL_FREE_DATA 2
/* Flags for png_ptr->free_me and info_ptr->free_me */
#define PNG_FREE_HIST 0x0008U
#define PNG_FREE_ICCP 0x0010U
@@ -1763,36 +1853,42 @@ PNG_EXPORT(99, void, png_data_freer, (png_const_structrp png_ptr,
#define PNG_FREE_MUL 0x4220U /* PNG_FREE_SPLT|PNG_FREE_TEXT|PNG_FREE_UNKN */
#ifdef PNG_USER_MEM_SUPPORTED
-PNG_EXPORTA(100, png_voidp, png_malloc_default, (png_const_structrp png_ptr,
- png_alloc_size_t size), PNG_ALLOCATED PNG_DEPRECATED);
-PNG_EXPORTA(101, void, png_free_default, (png_const_structrp png_ptr,
- png_voidp ptr), PNG_DEPRECATED);
+PNG_EXPORTA(100, png_voidp, png_malloc_default,
+ (png_const_structrp png_ptr, png_alloc_size_t size),
+ PNG_ALLOCATED PNG_DEPRECATED);
+PNG_EXPORTA(101, void, png_free_default,
+ (png_const_structrp png_ptr, png_voidp ptr),
+ PNG_DEPRECATED);
#endif
#ifdef PNG_ERROR_TEXT_SUPPORTED
/* Fatal error in PNG image of libpng - can't continue */
-PNG_EXPORTA(102, void, png_error, (png_const_structrp png_ptr,
- png_const_charp error_message), PNG_NORETURN);
+PNG_EXPORTA(102, void, png_error,
+ (png_const_structrp png_ptr, png_const_charp error_message),
+ PNG_NORETURN);
/* The same, but the chunk name is prepended to the error string. */
-PNG_EXPORTA(103, void, png_chunk_error, (png_const_structrp png_ptr,
- png_const_charp error_message), PNG_NORETURN);
+PNG_EXPORTA(103, void, png_chunk_error,
+ (png_const_structrp png_ptr, png_const_charp error_message),
+ PNG_NORETURN);
#else
/* Fatal error in PNG image of libpng - can't continue */
-PNG_EXPORTA(104, void, png_err, (png_const_structrp png_ptr), PNG_NORETURN);
+PNG_EXPORTA(104, void, png_err,
+ (png_const_structrp png_ptr),
+ PNG_NORETURN);
# define png_error(s1,s2) png_err(s1)
# define png_chunk_error(s1,s2) png_err(s1)
#endif
#ifdef PNG_WARNINGS_SUPPORTED
/* Non-fatal error in libpng. Can continue, but may have a problem. */
-PNG_EXPORT(105, void, png_warning, (png_const_structrp png_ptr,
- png_const_charp warning_message));
+PNG_EXPORT(105, void, png_warning,
+ (png_const_structrp png_ptr, png_const_charp warning_message));
/* Non-fatal error in libpng, chunk name is prepended to message. */
-PNG_EXPORT(106, void, png_chunk_warning, (png_const_structrp png_ptr,
- png_const_charp warning_message));
+PNG_EXPORT(106, void, png_chunk_warning,
+ (png_const_structrp png_ptr, png_const_charp warning_message));
#else
# define png_warning(s1,s2) ((void)(s1))
# define png_chunk_warning(s1,s2) ((void)(s1))
@@ -1801,17 +1897,17 @@ PNG_EXPORT(106, void, png_chunk_warning, (png_const_structrp png_ptr,
#ifdef PNG_BENIGN_ERRORS_SUPPORTED
/* Benign error in libpng. Can continue, but may have a problem.
* User can choose whether to handle as a fatal error or as a warning. */
-PNG_EXPORT(107, void, png_benign_error, (png_const_structrp png_ptr,
- png_const_charp warning_message));
+PNG_EXPORT(107, void, png_benign_error,
+ (png_const_structrp png_ptr, png_const_charp warning_message));
#ifdef PNG_READ_SUPPORTED
/* Same, chunk name is prepended to message (only during read) */
-PNG_EXPORT(108, void, png_chunk_benign_error, (png_const_structrp png_ptr,
- png_const_charp warning_message));
+PNG_EXPORT(108, void, png_chunk_benign_error,
+ (png_const_structrp png_ptr, png_const_charp warning_message));
#endif
PNG_EXPORT(109, void, png_set_benign_errors,
- (png_structrp png_ptr, int allowed));
+ (png_structrp png_ptr, int allowed));
#else
# ifdef PNG_ALLOW_BENIGN_ERRORS
# define png_benign_error png_warning
@@ -1835,283 +1931,413 @@ PNG_EXPORT(109, void, png_set_benign_errors,
* png_info_struct.
*/
/* Returns "flag" if chunk data is valid in info_ptr. */
-PNG_EXPORT(110, png_uint_32, png_get_valid, (png_const_structrp png_ptr,
- png_const_inforp info_ptr, png_uint_32 flag));
+PNG_EXPORT(110, png_uint_32, png_get_valid,
+ (png_const_structrp png_ptr, png_const_inforp info_ptr, png_uint_32 flag));
/* Returns number of bytes needed to hold a transformed row. */
-PNG_EXPORT(111, size_t, png_get_rowbytes, (png_const_structrp png_ptr,
- png_const_inforp info_ptr));
+PNG_EXPORT(111, size_t, png_get_rowbytes,
+ (png_const_structrp png_ptr, png_const_inforp info_ptr));
#ifdef PNG_INFO_IMAGE_SUPPORTED
/* Returns row_pointers, which is an array of pointers to scanlines that was
* returned from png_read_png().
*/
-PNG_EXPORT(112, png_bytepp, png_get_rows, (png_const_structrp png_ptr,
- png_const_inforp info_ptr));
+PNG_EXPORT(112, png_bytepp, png_get_rows,
+ (png_const_structrp png_ptr, png_const_inforp info_ptr));
/* Set row_pointers, which is an array of pointers to scanlines for use
* by png_write_png().
*/
-PNG_EXPORT(113, void, png_set_rows, (png_const_structrp png_ptr,
- png_inforp info_ptr, png_bytepp row_pointers));
+PNG_EXPORT(113, void, png_set_rows,
+ (png_const_structrp png_ptr, png_inforp info_ptr, png_bytepp row_pointers));
#endif
/* Returns number of color channels in image. */
-PNG_EXPORT(114, png_byte, png_get_channels, (png_const_structrp png_ptr,
- png_const_inforp info_ptr));
+PNG_EXPORT(114, png_byte, png_get_channels,
+ (png_const_structrp png_ptr, png_const_inforp info_ptr));
#ifdef PNG_EASY_ACCESS_SUPPORTED
/* Returns image width in pixels. */
-PNG_EXPORT(115, png_uint_32, png_get_image_width, (png_const_structrp png_ptr,
- png_const_inforp info_ptr));
+PNG_EXPORT(115, png_uint_32, png_get_image_width,
+ (png_const_structrp png_ptr, png_const_inforp info_ptr));
/* Returns image height in pixels. */
-PNG_EXPORT(116, png_uint_32, png_get_image_height, (png_const_structrp png_ptr,
- png_const_inforp info_ptr));
+PNG_EXPORT(116, png_uint_32, png_get_image_height,
+ (png_const_structrp png_ptr, png_const_inforp info_ptr));
/* Returns image bit_depth. */
-PNG_EXPORT(117, png_byte, png_get_bit_depth, (png_const_structrp png_ptr,
- png_const_inforp info_ptr));
+PNG_EXPORT(117, png_byte, png_get_bit_depth,
+ (png_const_structrp png_ptr, png_const_inforp info_ptr));
/* Returns image color_type. */
-PNG_EXPORT(118, png_byte, png_get_color_type, (png_const_structrp png_ptr,
- png_const_inforp info_ptr));
+PNG_EXPORT(118, png_byte, png_get_color_type,
+ (png_const_structrp png_ptr, png_const_inforp info_ptr));
/* Returns image filter_type. */
-PNG_EXPORT(119, png_byte, png_get_filter_type, (png_const_structrp png_ptr,
- png_const_inforp info_ptr));
+PNG_EXPORT(119, png_byte, png_get_filter_type,
+ (png_const_structrp png_ptr, png_const_inforp info_ptr));
/* Returns image interlace_type. */
-PNG_EXPORT(120, png_byte, png_get_interlace_type, (png_const_structrp png_ptr,
- png_const_inforp info_ptr));
+PNG_EXPORT(120, png_byte, png_get_interlace_type,
+ (png_const_structrp png_ptr, png_const_inforp info_ptr));
/* Returns image compression_type. */
-PNG_EXPORT(121, png_byte, png_get_compression_type, (png_const_structrp png_ptr,
- png_const_inforp info_ptr));
+PNG_EXPORT(121, png_byte, png_get_compression_type,
+ (png_const_structrp png_ptr, png_const_inforp info_ptr));
/* Returns image resolution in pixels per meter, from pHYs chunk data. */
PNG_EXPORT(122, png_uint_32, png_get_pixels_per_meter,
- (png_const_structrp png_ptr, png_const_inforp info_ptr));
+ (png_const_structrp png_ptr, png_const_inforp info_ptr));
PNG_EXPORT(123, png_uint_32, png_get_x_pixels_per_meter,
- (png_const_structrp png_ptr, png_const_inforp info_ptr));
+ (png_const_structrp png_ptr, png_const_inforp info_ptr));
PNG_EXPORT(124, png_uint_32, png_get_y_pixels_per_meter,
- (png_const_structrp png_ptr, png_const_inforp info_ptr));
+ (png_const_structrp png_ptr, png_const_inforp info_ptr));
/* Returns pixel aspect ratio, computed from pHYs chunk data. */
PNG_FP_EXPORT(125, float, png_get_pixel_aspect_ratio,
- (png_const_structrp png_ptr, png_const_inforp info_ptr))
+ (png_const_structrp png_ptr, png_const_inforp info_ptr))
PNG_FIXED_EXPORT(210, png_fixed_point, png_get_pixel_aspect_ratio_fixed,
- (png_const_structrp png_ptr, png_const_inforp info_ptr))
+ (png_const_structrp png_ptr, png_const_inforp info_ptr))
/* Returns image x, y offset in pixels or microns, from oFFs chunk data. */
PNG_EXPORT(126, png_int_32, png_get_x_offset_pixels,
- (png_const_structrp png_ptr, png_const_inforp info_ptr));
+ (png_const_structrp png_ptr, png_const_inforp info_ptr));
PNG_EXPORT(127, png_int_32, png_get_y_offset_pixels,
- (png_const_structrp png_ptr, png_const_inforp info_ptr));
+ (png_const_structrp png_ptr, png_const_inforp info_ptr));
PNG_EXPORT(128, png_int_32, png_get_x_offset_microns,
- (png_const_structrp png_ptr, png_const_inforp info_ptr));
+ (png_const_structrp png_ptr, png_const_inforp info_ptr));
PNG_EXPORT(129, png_int_32, png_get_y_offset_microns,
- (png_const_structrp png_ptr, png_const_inforp info_ptr));
+ (png_const_structrp png_ptr, png_const_inforp info_ptr));
#endif /* EASY_ACCESS */
#ifdef PNG_READ_SUPPORTED
/* Returns pointer to signature string read from PNG header */
-PNG_EXPORT(130, png_const_bytep, png_get_signature, (png_const_structrp png_ptr,
- png_const_inforp info_ptr));
+PNG_EXPORT(130, png_const_bytep, png_get_signature,
+ (png_const_structrp png_ptr, png_const_inforp info_ptr));
#endif
#ifdef PNG_bKGD_SUPPORTED
-PNG_EXPORT(131, png_uint_32, png_get_bKGD, (png_const_structrp png_ptr,
- png_inforp info_ptr, png_color_16p *background));
+PNG_EXPORT(131, png_uint_32, png_get_bKGD,
+ (png_const_structrp png_ptr, png_inforp info_ptr,
+ png_color_16p *background));
#endif
#ifdef PNG_bKGD_SUPPORTED
-PNG_EXPORT(132, void, png_set_bKGD, (png_const_structrp png_ptr,
- png_inforp info_ptr, png_const_color_16p background));
+PNG_EXPORT(132, void, png_set_bKGD,
+ (png_const_structrp png_ptr, png_inforp info_ptr,
+ png_const_color_16p background));
#endif
#ifdef PNG_cHRM_SUPPORTED
-PNG_FP_EXPORT(133, png_uint_32, 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_FP_EXPORT(230, png_uint_32, png_get_cHRM_XYZ, (png_const_structrp png_ptr,
- png_const_inforp info_ptr, double *red_X, double *red_Y, double *red_Z,
- double *green_X, double *green_Y, double *green_Z, double *blue_X,
- double *blue_Y, double *blue_Z))
+PNG_FP_EXPORT(133, png_uint_32, 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_FP_EXPORT(230, png_uint_32, png_get_cHRM_XYZ,
+ (png_const_structrp png_ptr, png_const_inforp info_ptr,
+ double *red_X, double *red_Y, double *red_Z,
+ double *green_X, double *green_Y, double *green_Z,
+ double *blue_X, double *blue_Y, double *blue_Z))
PNG_FIXED_EXPORT(134, png_uint_32, png_get_cHRM_fixed,
- (png_const_structrp png_ptr, png_const_inforp info_ptr,
+ (png_const_structrp png_ptr, png_const_inforp info_ptr,
png_fixed_point *int_white_x, png_fixed_point *int_white_y,
png_fixed_point *int_red_x, png_fixed_point *int_red_y,
png_fixed_point *int_green_x, png_fixed_point *int_green_y,
png_fixed_point *int_blue_x, png_fixed_point *int_blue_y))
PNG_FIXED_EXPORT(231, png_uint_32, png_get_cHRM_XYZ_fixed,
- (png_const_structrp png_ptr, png_const_inforp info_ptr,
+ (png_const_structrp png_ptr, png_const_inforp info_ptr,
png_fixed_point *int_red_X, png_fixed_point *int_red_Y,
- png_fixed_point *int_red_Z, png_fixed_point *int_green_X,
- png_fixed_point *int_green_Y, png_fixed_point *int_green_Z,
+ png_fixed_point *int_red_Z,
+ png_fixed_point *int_green_X, png_fixed_point *int_green_Y,
+ png_fixed_point *int_green_Z,
png_fixed_point *int_blue_X, png_fixed_point *int_blue_Y,
png_fixed_point *int_blue_Z))
#endif
#ifdef PNG_cHRM_SUPPORTED
-PNG_FP_EXPORT(135, void, png_set_cHRM, (png_const_structrp png_ptr,
- png_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_FP_EXPORT(232, void, png_set_cHRM_XYZ, (png_const_structrp png_ptr,
- png_inforp info_ptr, double red_X, double red_Y, double red_Z,
- double green_X, double green_Y, double green_Z, double blue_X,
- double blue_Y, double blue_Z))
-PNG_FIXED_EXPORT(136, void, png_set_cHRM_fixed, (png_const_structrp png_ptr,
- png_inforp info_ptr, png_fixed_point int_white_x,
- png_fixed_point int_white_y, png_fixed_point int_red_x,
- png_fixed_point int_red_y, png_fixed_point int_green_x,
- png_fixed_point int_green_y, png_fixed_point int_blue_x,
- png_fixed_point int_blue_y))
-PNG_FIXED_EXPORT(233, void, png_set_cHRM_XYZ_fixed, (png_const_structrp png_ptr,
- png_inforp info_ptr, png_fixed_point int_red_X, png_fixed_point int_red_Y,
- png_fixed_point int_red_Z, png_fixed_point int_green_X,
- png_fixed_point int_green_Y, png_fixed_point int_green_Z,
+PNG_FP_EXPORT(135, void, png_set_cHRM,
+ (png_const_structrp png_ptr, png_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_FP_EXPORT(232, void, png_set_cHRM_XYZ,
+ (png_const_structrp png_ptr, png_inforp info_ptr,
+ double red_X, double red_Y, double red_Z,
+ double green_X, double green_Y, double green_Z,
+ double blue_X, double blue_Y, double blue_Z))
+PNG_FIXED_EXPORT(136, void, png_set_cHRM_fixed,
+ (png_const_structrp png_ptr, png_inforp info_ptr,
+ png_fixed_point int_white_x, png_fixed_point int_white_y,
+ png_fixed_point int_red_x, png_fixed_point int_red_y,
+ png_fixed_point int_green_x, png_fixed_point int_green_y,
+ png_fixed_point int_blue_x, png_fixed_point int_blue_y))
+PNG_FIXED_EXPORT(233, void, png_set_cHRM_XYZ_fixed,
+ (png_const_structrp png_ptr, png_inforp info_ptr,
+ png_fixed_point int_red_X, png_fixed_point int_red_Y,
+ png_fixed_point int_red_Z,
+ png_fixed_point int_green_X, png_fixed_point int_green_Y,
+ png_fixed_point int_green_Z,
png_fixed_point int_blue_X, png_fixed_point int_blue_Y,
png_fixed_point int_blue_Z))
#endif
+#ifdef PNG_cICP_SUPPORTED
+PNG_EXPORT(250, png_uint_32, png_get_cICP,
+ (png_const_structrp png_ptr, png_const_inforp info_ptr,
+ png_bytep colour_primaries, png_bytep transfer_function,
+ png_bytep matrix_coefficients, png_bytep video_full_range_flag));
+#endif
+
+#ifdef PNG_cICP_SUPPORTED
+PNG_EXPORT(251, void, png_set_cICP,
+ (png_const_structrp png_ptr, png_inforp info_ptr,
+ png_byte colour_primaries, png_byte transfer_function,
+ png_byte matrix_coefficients, png_byte video_full_range_flag));
+#endif
+
+#ifdef PNG_cLLI_SUPPORTED
+PNG_FP_EXPORT(252, png_uint_32, png_get_cLLI,
+ (png_const_structrp png_ptr, png_const_inforp info_ptr,
+ double *maximum_content_light_level,
+ double *maximum_frame_average_light_level))
+PNG_FIXED_EXPORT(253, png_uint_32, png_get_cLLI_fixed,
+ (png_const_structrp png_ptr, png_const_inforp info_ptr,
+ /* The values below are in cd/m2 (nits) and are scaled by 10,000; not
+ * 100,000 as in the case of png_fixed_point.
+ */
+ png_uint_32p maximum_content_light_level_scaled_by_10000,
+ png_uint_32p maximum_frame_average_light_level_scaled_by_10000))
+#endif
+
+#ifdef PNG_cLLI_SUPPORTED
+PNG_FP_EXPORT(254, void, png_set_cLLI,
+ (png_const_structrp png_ptr, png_inforp info_ptr,
+ double maximum_content_light_level,
+ double maximum_frame_average_light_level))
+PNG_FIXED_EXPORT(255, void, png_set_cLLI_fixed,
+ (png_const_structrp png_ptr, png_inforp info_ptr,
+ /* The values below are in cd/m2 (nits) and are scaled by 10,000; not
+ * 100,000 as in the case of png_fixed_point.
+ */
+ png_uint_32 maximum_content_light_level_scaled_by_10000,
+ png_uint_32 maximum_frame_average_light_level_scaled_by_10000))
+#endif
+
#ifdef PNG_eXIf_SUPPORTED
-PNG_EXPORT(246, png_uint_32, png_get_eXIf, (png_const_structrp png_ptr,
- png_inforp info_ptr, png_bytep *exif));
-PNG_EXPORT(247, void, png_set_eXIf, (png_const_structrp png_ptr,
- png_inforp info_ptr, png_bytep exif));
+PNG_EXPORT(246, png_uint_32, png_get_eXIf,
+ (png_const_structrp png_ptr, png_inforp info_ptr, png_bytep *exif));
+PNG_EXPORT(247, void, png_set_eXIf,
+ (png_const_structrp png_ptr, png_inforp info_ptr, png_bytep exif));
-PNG_EXPORT(248, png_uint_32, png_get_eXIf_1, (png_const_structrp png_ptr,
- png_const_inforp info_ptr, png_uint_32 *num_exif, png_bytep *exif));
-PNG_EXPORT(249, void, png_set_eXIf_1, (png_const_structrp png_ptr,
- png_inforp info_ptr, png_uint_32 num_exif, png_bytep exif));
+PNG_EXPORT(248, png_uint_32, png_get_eXIf_1,
+ (png_const_structrp png_ptr, png_const_inforp info_ptr,
+ png_uint_32 *num_exif, png_bytep *exif));
+PNG_EXPORT(249, void, png_set_eXIf_1,
+ (png_const_structrp png_ptr, png_inforp info_ptr,
+ png_uint_32 num_exif, png_bytep exif));
#endif
#ifdef PNG_gAMA_SUPPORTED
-PNG_FP_EXPORT(137, png_uint_32, png_get_gAMA, (png_const_structrp png_ptr,
- png_const_inforp info_ptr, double *file_gamma))
+PNG_FP_EXPORT(137, png_uint_32, png_get_gAMA,
+ (png_const_structrp png_ptr, png_const_inforp info_ptr,
+ double *file_gamma))
PNG_FIXED_EXPORT(138, png_uint_32, png_get_gAMA_fixed,
- (png_const_structrp png_ptr, png_const_inforp info_ptr,
+ (png_const_structrp png_ptr, png_const_inforp info_ptr,
png_fixed_point *int_file_gamma))
#endif
#ifdef PNG_gAMA_SUPPORTED
-PNG_FP_EXPORT(139, void, png_set_gAMA, (png_const_structrp png_ptr,
- png_inforp info_ptr, double file_gamma))
-PNG_FIXED_EXPORT(140, void, png_set_gAMA_fixed, (png_const_structrp png_ptr,
- png_inforp info_ptr, png_fixed_point int_file_gamma))
+PNG_FP_EXPORT(139, void, png_set_gAMA,
+ (png_const_structrp png_ptr, png_inforp info_ptr,
+ double file_gamma))
+PNG_FIXED_EXPORT(140, void, png_set_gAMA_fixed,
+ (png_const_structrp png_ptr, png_inforp info_ptr,
+ png_fixed_point int_file_gamma))
#endif
#ifdef PNG_hIST_SUPPORTED
-PNG_EXPORT(141, png_uint_32, png_get_hIST, (png_const_structrp png_ptr,
- png_inforp info_ptr, png_uint_16p *hist));
-PNG_EXPORT(142, void, png_set_hIST, (png_const_structrp png_ptr,
- png_inforp info_ptr, png_const_uint_16p hist));
+PNG_EXPORT(141, png_uint_32, png_get_hIST,
+ (png_const_structrp png_ptr, png_inforp info_ptr, png_uint_16p *hist));
+PNG_EXPORT(142, void, png_set_hIST,
+ (png_const_structrp png_ptr, png_inforp info_ptr, png_const_uint_16p hist));
+#endif
+
+PNG_EXPORT(143, png_uint_32, png_get_IHDR,
+ (png_const_structrp png_ptr, png_const_inforp info_ptr,
+ png_uint_32 *width, png_uint_32 *height,
+ int *bit_depth, int *color_type,
+ int *interlace_method, int *compression_method, int *filter_method));
+
+PNG_EXPORT(144, void, png_set_IHDR,
+ (png_const_structrp png_ptr, png_inforp info_ptr,
+ png_uint_32 width, png_uint_32 height,
+ int bit_depth, int color_type,
+ int interlace_method, int compression_method, int filter_method));
+
+#ifdef PNG_mDCV_SUPPORTED
+PNG_FP_EXPORT(256, png_uint_32, png_get_mDCV,
+ (png_const_structrp png_ptr, png_const_inforp info_ptr,
+ /* The chromaticities of the mastering display. As cHRM, but independent of
+ * the encoding endpoints in cHRM, or cICP, or iCCP. These values will
+ * always be in the range 0 to 1.3107.
+ */
+ double *white_x, double *white_y,
+ double *red_x, double *red_y,
+ double *green_x, double *green_y,
+ double *blue_x, double *blue_y,
+ /* Mastering display luminance in cd/m2 (nits). */
+ double *mastering_display_maximum_luminance,
+ double *mastering_display_minimum_luminance))
+
+PNG_FIXED_EXPORT(257, png_uint_32, png_get_mDCV_fixed,
+ (png_const_structrp png_ptr, png_const_inforp info_ptr,
+ png_fixed_point *int_white_x, png_fixed_point *int_white_y,
+ png_fixed_point *int_red_x, png_fixed_point *int_red_y,
+ png_fixed_point *int_green_x, png_fixed_point *int_green_y,
+ png_fixed_point *int_blue_x, png_fixed_point *int_blue_y,
+ /* Mastering display luminance in cd/m2 (nits) multiplied (scaled) by
+ * 10,000.
+ */
+ png_uint_32p mastering_display_maximum_luminance_scaled_by_10000,
+ png_uint_32p mastering_display_minimum_luminance_scaled_by_10000))
+#endif
+
+#ifdef PNG_mDCV_SUPPORTED
+PNG_FP_EXPORT(258, void, png_set_mDCV,
+ (png_const_structrp png_ptr, png_inforp info_ptr,
+ /* The chromaticities of the mastering display. As cHRM, but independent of
+ * the encoding endpoints in cHRM, or cICP, or iCCP.
+ */
+ double white_x, double white_y,
+ double red_x, double red_y,
+ double green_x, double green_y,
+ double blue_x, double blue_y,
+ /* Mastering display luminance in cd/m2 (nits). */
+ double mastering_display_maximum_luminance,
+ double mastering_display_minimum_luminance))
+
+PNG_FIXED_EXPORT(259, void, png_set_mDCV_fixed,
+ (png_const_structrp png_ptr, png_inforp info_ptr,
+ /* The admissible range of these values is not the full range of a PNG
+ * fixed point value. Negative values cannot be encoded and the maximum
+ * value is about 1.3 */
+ png_fixed_point int_white_x, png_fixed_point int_white_y,
+ png_fixed_point int_red_x, png_fixed_point int_red_y,
+ png_fixed_point int_green_x, png_fixed_point int_green_y,
+ png_fixed_point int_blue_x, png_fixed_point int_blue_y,
+ /* These are PNG unsigned 4 byte values: 31-bit unsigned values. The MSB
+ * must be zero.
+ */
+ png_uint_32 mastering_display_maximum_luminance_scaled_by_10000,
+ png_uint_32 mastering_display_minimum_luminance_scaled_by_10000))
#endif
-PNG_EXPORT(143, png_uint_32, png_get_IHDR, (png_const_structrp png_ptr,
- png_const_inforp info_ptr, png_uint_32 *width, png_uint_32 *height,
- int *bit_depth, int *color_type, int *interlace_method,
- int *compression_method, int *filter_method));
-
-PNG_EXPORT(144, void, png_set_IHDR, (png_const_structrp png_ptr,
- png_inforp info_ptr, png_uint_32 width, png_uint_32 height, int bit_depth,
- int color_type, int interlace_method, int compression_method,
- int filter_method));
-
#ifdef PNG_oFFs_SUPPORTED
-PNG_EXPORT(145, png_uint_32, png_get_oFFs, (png_const_structrp png_ptr,
- png_const_inforp info_ptr, png_int_32 *offset_x, png_int_32 *offset_y,
- int *unit_type));
+PNG_EXPORT(145, png_uint_32, png_get_oFFs,
+ (png_const_structrp png_ptr, png_const_inforp info_ptr,
+ png_int_32 *offset_x, png_int_32 *offset_y, int *unit_type));
#endif
#ifdef PNG_oFFs_SUPPORTED
-PNG_EXPORT(146, void, png_set_oFFs, (png_const_structrp png_ptr,
- png_inforp info_ptr, png_int_32 offset_x, png_int_32 offset_y,
- int unit_type));
+PNG_EXPORT(146, void, png_set_oFFs,
+ (png_const_structrp png_ptr, png_inforp info_ptr,
+ png_int_32 offset_x, png_int_32 offset_y, int unit_type));
#endif
#ifdef PNG_pCAL_SUPPORTED
-PNG_EXPORT(147, png_uint_32, png_get_pCAL, (png_const_structrp png_ptr,
- png_inforp info_ptr, png_charp *purpose, png_int_32 *X0,
- png_int_32 *X1, int *type, int *nparams, png_charp *units,
- png_charpp *params));
+PNG_EXPORT(147, png_uint_32, png_get_pCAL,
+ (png_const_structrp png_ptr, png_inforp info_ptr,
+ png_charp *purpose, png_int_32 *X0, png_int_32 *X1,
+ int *type, int *nparams, png_charp *units, png_charpp *params));
#endif
#ifdef PNG_pCAL_SUPPORTED
-PNG_EXPORT(148, void, png_set_pCAL, (png_const_structrp png_ptr,
- png_inforp info_ptr, png_const_charp purpose, png_int_32 X0, png_int_32 X1,
+PNG_EXPORT(148, void, png_set_pCAL,
+ (png_const_structrp png_ptr, png_inforp info_ptr,
+ png_const_charp purpose, png_int_32 X0, png_int_32 X1,
int type, int nparams, png_const_charp units, png_charpp params));
#endif
#ifdef PNG_pHYs_SUPPORTED
-PNG_EXPORT(149, png_uint_32, png_get_pHYs, (png_const_structrp png_ptr,
- png_const_inforp info_ptr, png_uint_32 *res_x, png_uint_32 *res_y,
- int *unit_type));
+PNG_EXPORT(149, png_uint_32, png_get_pHYs,
+ (png_const_structrp png_ptr, png_const_inforp info_ptr,
+ png_uint_32 *res_x, png_uint_32 *res_y, int *unit_type));
#endif
#ifdef PNG_pHYs_SUPPORTED
-PNG_EXPORT(150, void, png_set_pHYs, (png_const_structrp png_ptr,
- png_inforp info_ptr, png_uint_32 res_x, png_uint_32 res_y, int unit_type));
+PNG_EXPORT(150, void, png_set_pHYs,
+ (png_const_structrp png_ptr, png_inforp info_ptr,
+ png_uint_32 res_x, png_uint_32 res_y, int unit_type));
#endif
-PNG_EXPORT(151, png_uint_32, png_get_PLTE, (png_const_structrp png_ptr,
- png_inforp info_ptr, png_colorp *palette, int *num_palette));
+PNG_EXPORT(151, png_uint_32, png_get_PLTE,
+ (png_const_structrp png_ptr, png_inforp info_ptr,
+ png_colorp *palette, int *num_palette));
-PNG_EXPORT(152, void, png_set_PLTE, (png_structrp png_ptr,
- png_inforp info_ptr, png_const_colorp palette, int num_palette));
+PNG_EXPORT(152, void, png_set_PLTE,
+ (png_structrp png_ptr, png_inforp info_ptr,
+ png_const_colorp palette, int num_palette));
#ifdef PNG_sBIT_SUPPORTED
-PNG_EXPORT(153, png_uint_32, png_get_sBIT, (png_const_structrp png_ptr,
- png_inforp info_ptr, png_color_8p *sig_bit));
+PNG_EXPORT(153, png_uint_32, png_get_sBIT,
+ (png_const_structrp png_ptr, png_inforp info_ptr,
+ png_color_8p *sig_bit));
#endif
#ifdef PNG_sBIT_SUPPORTED
-PNG_EXPORT(154, void, png_set_sBIT, (png_const_structrp png_ptr,
- png_inforp info_ptr, png_const_color_8p sig_bit));
+PNG_EXPORT(154, void, png_set_sBIT,
+ (png_const_structrp png_ptr, png_inforp info_ptr,
+ png_const_color_8p sig_bit));
#endif
#ifdef PNG_sRGB_SUPPORTED
-PNG_EXPORT(155, png_uint_32, png_get_sRGB, (png_const_structrp png_ptr,
- png_const_inforp info_ptr, int *file_srgb_intent));
+PNG_EXPORT(155, png_uint_32, png_get_sRGB,
+ (png_const_structrp png_ptr, png_const_inforp info_ptr,
+ int *file_srgb_intent));
#endif
#ifdef PNG_sRGB_SUPPORTED
-PNG_EXPORT(156, void, png_set_sRGB, (png_const_structrp png_ptr,
- png_inforp info_ptr, int srgb_intent));
-PNG_EXPORT(157, void, png_set_sRGB_gAMA_and_cHRM, (png_const_structrp png_ptr,
- png_inforp info_ptr, int srgb_intent));
+PNG_EXPORT(156, void, png_set_sRGB,
+ (png_const_structrp png_ptr, png_inforp info_ptr, int srgb_intent));
+PNG_EXPORT(157, void, png_set_sRGB_gAMA_and_cHRM,
+ (png_const_structrp png_ptr, png_inforp info_ptr, int srgb_intent));
#endif
#ifdef PNG_iCCP_SUPPORTED
-PNG_EXPORT(158, png_uint_32, png_get_iCCP, (png_const_structrp png_ptr,
- png_inforp info_ptr, png_charpp name, int *compression_type,
+PNG_EXPORT(158, png_uint_32, png_get_iCCP,
+ (png_const_structrp png_ptr, png_inforp info_ptr,
+ png_charpp name, int *compression_type,
png_bytepp profile, png_uint_32 *proflen));
#endif
#ifdef PNG_iCCP_SUPPORTED
-PNG_EXPORT(159, void, png_set_iCCP, (png_const_structrp png_ptr,
- png_inforp info_ptr, png_const_charp name, int compression_type,
+PNG_EXPORT(159, void, png_set_iCCP,
+ (png_const_structrp png_ptr, png_inforp info_ptr,
+ png_const_charp name, int compression_type,
png_const_bytep profile, png_uint_32 proflen));
#endif
#ifdef PNG_sPLT_SUPPORTED
-PNG_EXPORT(160, int, png_get_sPLT, (png_const_structrp png_ptr,
- png_inforp info_ptr, png_sPLT_tpp entries));
+PNG_EXPORT(160, int, png_get_sPLT,
+ (png_const_structrp png_ptr, png_inforp info_ptr,
+ png_sPLT_tpp entries));
#endif
#ifdef PNG_sPLT_SUPPORTED
-PNG_EXPORT(161, void, png_set_sPLT, (png_const_structrp png_ptr,
- png_inforp info_ptr, png_const_sPLT_tp entries, int nentries));
+PNG_EXPORT(161, void, png_set_sPLT,
+ (png_const_structrp png_ptr, png_inforp info_ptr,
+ png_const_sPLT_tp entries, int nentries));
#endif
#ifdef PNG_TEXT_SUPPORTED
/* png_get_text also returns the number of text chunks in *num_text */
-PNG_EXPORT(162, int, png_get_text, (png_const_structrp png_ptr,
- png_inforp info_ptr, png_textp *text_ptr, int *num_text));
+PNG_EXPORT(162, int, png_get_text,
+ (png_const_structrp png_ptr, png_inforp info_ptr,
+ png_textp *text_ptr, int *num_text));
#endif
/* Note while png_set_text() will accept a structure whose text,
@@ -2122,35 +2348,41 @@ PNG_EXPORT(162, int, png_get_text, (png_const_structrp png_ptr,
*/
#ifdef PNG_TEXT_SUPPORTED
-PNG_EXPORT(163, void, png_set_text, (png_const_structrp png_ptr,
- png_inforp info_ptr, png_const_textp text_ptr, int num_text));
+PNG_EXPORT(163, void, png_set_text,
+ (png_const_structrp png_ptr, png_inforp info_ptr,
+ png_const_textp text_ptr, int num_text));
#endif
#ifdef PNG_tIME_SUPPORTED
-PNG_EXPORT(164, png_uint_32, png_get_tIME, (png_const_structrp png_ptr,
- png_inforp info_ptr, png_timep *mod_time));
+PNG_EXPORT(164, png_uint_32, png_get_tIME,
+ (png_const_structrp png_ptr, png_inforp info_ptr,
+ png_timep *mod_time));
#endif
#ifdef PNG_tIME_SUPPORTED
-PNG_EXPORT(165, void, png_set_tIME, (png_const_structrp png_ptr,
- png_inforp info_ptr, png_const_timep mod_time));
+PNG_EXPORT(165, void, png_set_tIME,
+ (png_const_structrp png_ptr, png_inforp info_ptr,
+ png_const_timep mod_time));
#endif
#ifdef PNG_tRNS_SUPPORTED
-PNG_EXPORT(166, png_uint_32, png_get_tRNS, (png_const_structrp png_ptr,
- png_inforp info_ptr, png_bytep *trans_alpha, int *num_trans,
+PNG_EXPORT(166, png_uint_32, png_get_tRNS,
+ (png_const_structrp png_ptr, png_inforp info_ptr,
+ png_bytep *trans_alpha, int *num_trans,
png_color_16p *trans_color));
#endif
#ifdef PNG_tRNS_SUPPORTED
-PNG_EXPORT(167, void, png_set_tRNS, (png_structrp png_ptr,
- png_inforp info_ptr, png_const_bytep trans_alpha, int num_trans,
+PNG_EXPORT(167, void, png_set_tRNS,
+ (png_structrp png_ptr, png_inforp info_ptr,
+ png_const_bytep trans_alpha, int num_trans,
png_const_color_16p trans_color));
#endif
#ifdef PNG_sCAL_SUPPORTED
-PNG_FP_EXPORT(168, png_uint_32, png_get_sCAL, (png_const_structrp png_ptr,
- png_const_inforp info_ptr, int *unit, double *width, double *height))
+PNG_FP_EXPORT(168, png_uint_32, png_get_sCAL,
+ (png_const_structrp png_ptr, png_const_inforp info_ptr,
+ int *unit, double *width, double *height))
#if defined(PNG_FLOATING_ARITHMETIC_SUPPORTED) || \
defined(PNG_FLOATING_POINT_SUPPORTED)
/* NOTE: this API is currently implemented using floating point arithmetic,
@@ -2159,21 +2391,22 @@ PNG_FP_EXPORT(168, png_uint_32, png_get_sCAL, (png_const_structrp png_ptr,
* is highly recommended that png_get_sCAL_s be used instead.
*/
PNG_FIXED_EXPORT(214, png_uint_32, 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_const_structrp png_ptr, png_const_inforp info_ptr,
+ int *unit, png_fixed_point *width, png_fixed_point *height))
#endif
PNG_EXPORT(169, png_uint_32, png_get_sCAL_s,
- (png_const_structrp png_ptr, png_const_inforp info_ptr, int *unit,
- png_charpp swidth, png_charpp sheight));
-
-PNG_FP_EXPORT(170, void, png_set_sCAL, (png_const_structrp png_ptr,
- png_inforp info_ptr, int unit, double width, double height))
-PNG_FIXED_EXPORT(213, void, png_set_sCAL_fixed, (png_const_structrp png_ptr,
- png_inforp info_ptr, int unit, png_fixed_point width,
- png_fixed_point height))
-PNG_EXPORT(171, void, png_set_sCAL_s, (png_const_structrp png_ptr,
- png_inforp info_ptr, int unit,
- png_const_charp swidth, png_const_charp sheight));
+ (png_const_structrp png_ptr, png_const_inforp info_ptr,
+ int *unit, png_charpp swidth, png_charpp sheight));
+
+PNG_FP_EXPORT(170, void, png_set_sCAL,
+ (png_const_structrp png_ptr, png_inforp info_ptr,
+ int unit, double width, double height))
+PNG_FIXED_EXPORT(213, void, png_set_sCAL_fixed,
+ (png_const_structrp png_ptr, png_inforp info_ptr,
+ int unit, png_fixed_point width, png_fixed_point height))
+PNG_EXPORT(171, void, png_set_sCAL_s,
+ (png_const_structrp png_ptr, png_inforp info_ptr,
+ int unit, png_const_charp swidth, png_const_charp sheight));
#endif /* sCAL */
#ifdef PNG_SET_UNKNOWN_CHUNKS_SUPPORTED
@@ -2276,7 +2509,8 @@ PNG_EXPORT(171, void, png_set_sCAL_s, (png_const_structrp png_ptr,
* be processed by libpng.
*/
#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED
-PNG_EXPORT(172, void, png_set_keep_unknown_chunks, (png_structrp png_ptr,
+PNG_EXPORT(172, void, png_set_keep_unknown_chunks,
+ (png_structrp png_ptr,
int keep, png_const_bytep chunk_list, int num_chunks));
#endif /* HANDLE_AS_UNKNOWN */
@@ -2284,14 +2518,14 @@ PNG_EXPORT(172, void, png_set_keep_unknown_chunks, (png_structrp png_ptr,
* the result is therefore true (non-zero) if special handling is required,
* false for the default handling.
*/
-PNG_EXPORT(173, int, png_handle_as_unknown, (png_const_structrp png_ptr,
- png_const_bytep chunk_name));
+PNG_EXPORT(173, int, png_handle_as_unknown,
+ (png_const_structrp png_ptr, png_const_bytep chunk_name));
#endif /* SET_UNKNOWN_CHUNKS */
#ifdef PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED
-PNG_EXPORT(174, void, png_set_unknown_chunks, (png_const_structrp png_ptr,
- png_inforp info_ptr, png_const_unknown_chunkp unknowns,
- int num_unknowns));
+PNG_EXPORT(174, void, png_set_unknown_chunks,
+ (png_const_structrp png_ptr, png_inforp info_ptr,
+ png_const_unknown_chunkp unknowns, int num_unknowns));
/* NOTE: prior to 1.6.0 this routine set the 'location' field of the added
* unknowns to the location currently stored in the png_struct. This is
* invariably the wrong value on write. To fix this call the following API
@@ -2302,43 +2536,47 @@ PNG_EXPORT(174, void, png_set_unknown_chunks, (png_const_structrp png_ptr,
*/
PNG_EXPORT(175, void, png_set_unknown_chunk_location,
- (png_const_structrp png_ptr, png_inforp info_ptr, int chunk, int location));
+ (png_const_structrp png_ptr, png_inforp info_ptr,
+ int chunk, int location));
-PNG_EXPORT(176, int, png_get_unknown_chunks, (png_const_structrp png_ptr,
- png_inforp info_ptr, png_unknown_chunkpp entries));
+PNG_EXPORT(176, int, png_get_unknown_chunks,
+ (png_const_structrp png_ptr, png_inforp info_ptr,
+ png_unknown_chunkpp entries));
#endif
/* Png_free_data() will turn off the "valid" flag for anything it frees.
* If you need to turn it off for a chunk that your application has freed,
* you can use png_set_invalid(png_ptr, info_ptr, PNG_INFO_CHNK);
*/
-PNG_EXPORT(177, void, png_set_invalid, (png_const_structrp png_ptr,
- png_inforp info_ptr, int mask));
+PNG_EXPORT(177, void, png_set_invalid,
+ (png_const_structrp png_ptr, png_inforp info_ptr, int mask));
#ifdef PNG_INFO_IMAGE_SUPPORTED
/* The "params" pointer is currently not used and is for future expansion. */
#ifdef PNG_SEQUENTIAL_READ_SUPPORTED
-PNG_EXPORT(178, void, png_read_png, (png_structrp png_ptr, png_inforp info_ptr,
+PNG_EXPORT(178, void, png_read_png,
+ (png_structrp png_ptr, png_inforp info_ptr,
int transforms, png_voidp params));
#endif
#ifdef PNG_WRITE_SUPPORTED
-PNG_EXPORT(179, void, png_write_png, (png_structrp png_ptr, png_inforp info_ptr,
+PNG_EXPORT(179, void, png_write_png,
+ (png_structrp png_ptr, png_inforp info_ptr,
int transforms, png_voidp params));
#endif
#endif
PNG_EXPORT(180, png_const_charp, png_get_copyright,
- (png_const_structrp png_ptr));
+ (png_const_structrp png_ptr));
PNG_EXPORT(181, png_const_charp, png_get_header_ver,
- (png_const_structrp png_ptr));
+ (png_const_structrp png_ptr));
PNG_EXPORT(182, png_const_charp, png_get_header_version,
- (png_const_structrp png_ptr));
+ (png_const_structrp png_ptr));
PNG_EXPORT(183, png_const_charp, png_get_libpng_ver,
- (png_const_structrp png_ptr));
+ (png_const_structrp png_ptr));
#ifdef PNG_MNG_FEATURES_SUPPORTED
-PNG_EXPORT(184, png_uint_32, png_permit_mng_features, (png_structrp png_ptr,
- png_uint_32 mng_features_permitted));
+PNG_EXPORT(184, png_uint_32, png_permit_mng_features,
+ (png_structrp png_ptr, png_uint_32 mng_features_permitted));
#endif
/* For use in png_set_keep_unknown, added to version 1.2.6 */
@@ -2352,71 +2590,74 @@ PNG_EXPORT(184, png_uint_32, png_permit_mng_features, (png_structrp png_ptr,
* messages before passing them to the error or warning handler.
*/
#ifdef PNG_ERROR_NUMBERS_SUPPORTED
-PNG_EXPORT(185, void, png_set_strip_error_numbers, (png_structrp png_ptr,
- png_uint_32 strip_mode));
+PNG_EXPORT(185, void, png_set_strip_error_numbers,
+ (png_structrp png_ptr, png_uint_32 strip_mode));
#endif
/* Added in libpng-1.2.6 */
#ifdef PNG_SET_USER_LIMITS_SUPPORTED
-PNG_EXPORT(186, void, png_set_user_limits, (png_structrp png_ptr,
+PNG_EXPORT(186, void, png_set_user_limits,
+ (png_structrp png_ptr,
png_uint_32 user_width_max, png_uint_32 user_height_max));
PNG_EXPORT(187, png_uint_32, png_get_user_width_max,
- (png_const_structrp png_ptr));
+ (png_const_structrp png_ptr));
PNG_EXPORT(188, png_uint_32, png_get_user_height_max,
- (png_const_structrp png_ptr));
+ (png_const_structrp png_ptr));
/* Added in libpng-1.4.0 */
-PNG_EXPORT(189, void, png_set_chunk_cache_max, (png_structrp png_ptr,
- png_uint_32 user_chunk_cache_max));
+PNG_EXPORT(189, void, png_set_chunk_cache_max,
+ (png_structrp png_ptr, png_uint_32 user_chunk_cache_max));
PNG_EXPORT(190, png_uint_32, png_get_chunk_cache_max,
- (png_const_structrp png_ptr));
+ (png_const_structrp png_ptr));
/* Added in libpng-1.4.1 */
-PNG_EXPORT(191, void, png_set_chunk_malloc_max, (png_structrp png_ptr,
- png_alloc_size_t user_chunk_cache_max));
+PNG_EXPORT(191, void, png_set_chunk_malloc_max,
+ (png_structrp png_ptr, png_alloc_size_t user_chunk_cache_max));
PNG_EXPORT(192, png_alloc_size_t, png_get_chunk_malloc_max,
- (png_const_structrp png_ptr));
+ (png_const_structrp png_ptr));
#endif
#if defined(PNG_INCH_CONVERSIONS_SUPPORTED)
PNG_EXPORT(193, png_uint_32, png_get_pixels_per_inch,
- (png_const_structrp png_ptr, png_const_inforp info_ptr));
+ (png_const_structrp png_ptr, png_const_inforp info_ptr));
PNG_EXPORT(194, png_uint_32, png_get_x_pixels_per_inch,
- (png_const_structrp png_ptr, png_const_inforp info_ptr));
+ (png_const_structrp png_ptr, png_const_inforp info_ptr));
PNG_EXPORT(195, png_uint_32, png_get_y_pixels_per_inch,
- (png_const_structrp png_ptr, png_const_inforp info_ptr));
+ (png_const_structrp png_ptr, png_const_inforp info_ptr));
PNG_FP_EXPORT(196, float, png_get_x_offset_inches,
- (png_const_structrp png_ptr, png_const_inforp info_ptr))
+ (png_const_structrp png_ptr, png_const_inforp info_ptr))
#ifdef PNG_FIXED_POINT_SUPPORTED /* otherwise not implemented. */
PNG_FIXED_EXPORT(211, png_fixed_point, png_get_x_offset_inches_fixed,
- (png_const_structrp png_ptr, png_const_inforp info_ptr))
+ (png_const_structrp png_ptr, png_const_inforp info_ptr))
#endif
-PNG_FP_EXPORT(197, float, png_get_y_offset_inches, (png_const_structrp png_ptr,
- png_const_inforp info_ptr))
+PNG_FP_EXPORT(197, float, png_get_y_offset_inches,
+ (png_const_structrp png_ptr, png_const_inforp info_ptr))
#ifdef PNG_FIXED_POINT_SUPPORTED /* otherwise not implemented. */
PNG_FIXED_EXPORT(212, png_fixed_point, png_get_y_offset_inches_fixed,
- (png_const_structrp png_ptr, png_const_inforp info_ptr))
+ (png_const_structrp png_ptr, png_const_inforp info_ptr))
#endif
# ifdef PNG_pHYs_SUPPORTED
-PNG_EXPORT(198, png_uint_32, png_get_pHYs_dpi, (png_const_structrp png_ptr,
- png_const_inforp info_ptr, png_uint_32 *res_x, png_uint_32 *res_y,
- int *unit_type));
+PNG_EXPORT(198, png_uint_32, png_get_pHYs_dpi,
+ (png_const_structrp png_ptr, png_const_inforp info_ptr,
+ png_uint_32 *res_x, png_uint_32 *res_y, int *unit_type));
# endif /* pHYs */
#endif /* INCH_CONVERSIONS */
/* Added in libpng-1.4.0 */
#ifdef PNG_IO_STATE_SUPPORTED
-PNG_EXPORT(199, png_uint_32, png_get_io_state, (png_const_structrp png_ptr));
+PNG_EXPORT(199, png_uint_32, png_get_io_state,
+ (png_const_structrp png_ptr));
/* Removed from libpng 1.6; use png_get_io_chunk_type. */
-PNG_REMOVED(200, png_const_bytep, png_get_io_chunk_name, (png_structrp png_ptr),
- PNG_DEPRECATED)
+PNG_REMOVED(200, png_const_bytep, png_get_io_chunk_name,
+ (png_structrp png_ptr),
+ PNG_DEPRECATED)
PNG_EXPORT(216, png_uint_32, png_get_io_chunk_type,
- (png_const_structrp png_ptr));
+ (png_const_structrp png_ptr));
/* The flags returned by png_get_io_state() are the following: */
# define PNG_IO_NONE 0x0000 /* no I/O at this moment */
@@ -2541,21 +2782,26 @@ PNG_EXPORT(216, png_uint_32, png_get_io_chunk_type,
#endif /* READ_COMPOSITE_NODIV */
#ifdef PNG_READ_INT_FUNCTIONS_SUPPORTED
-PNG_EXPORT(201, png_uint_32, png_get_uint_32, (png_const_bytep buf));
-PNG_EXPORT(202, png_uint_16, png_get_uint_16, (png_const_bytep buf));
-PNG_EXPORT(203, png_int_32, png_get_int_32, (png_const_bytep buf));
+PNG_EXPORT(201, png_uint_32, png_get_uint_32,
+ (png_const_bytep buf));
+PNG_EXPORT(202, png_uint_16, png_get_uint_16,
+ (png_const_bytep buf));
+PNG_EXPORT(203, png_int_32, png_get_int_32,
+ (png_const_bytep buf));
#endif
-PNG_EXPORT(204, png_uint_32, png_get_uint_31, (png_const_structrp png_ptr,
- png_const_bytep buf));
+PNG_EXPORT(204, png_uint_32, png_get_uint_31,
+ (png_const_structrp png_ptr, png_const_bytep buf));
/* No png_get_int_16 -- may be added if there's a real need for it. */
/* Place a 32-bit number into a buffer in PNG byte order (big-endian). */
#ifdef PNG_WRITE_INT_FUNCTIONS_SUPPORTED
-PNG_EXPORT(205, void, png_save_uint_32, (png_bytep buf, png_uint_32 i));
+PNG_EXPORT(205, void, png_save_uint_32,
+ (png_bytep buf, png_uint_32 i));
#endif
#ifdef PNG_SAVE_INT_32_SUPPORTED
-PNG_EXPORT(206, void, png_save_int_32, (png_bytep buf, png_int_32 i));
+PNG_EXPORT(206, void, png_save_int_32,
+ (png_bytep buf, png_int_32 i));
#endif
/* Place a 16-bit number into a buffer in PNG byte order.
@@ -2563,7 +2809,8 @@ PNG_EXPORT(206, void, png_save_int_32, (png_bytep buf, png_int_32 i));
* just to avoid potential problems on pre-ANSI C compilers.
*/
#ifdef PNG_WRITE_INT_FUNCTIONS_SUPPORTED
-PNG_EXPORT(207, void, png_save_uint_16, (png_bytep buf, unsigned int i));
+PNG_EXPORT(207, void, png_save_uint_16,
+ (png_bytep buf, unsigned int i));
/* No png_save_int_16 -- may be added if there's a real need for it. */
#endif
@@ -2610,10 +2857,10 @@ PNG_EXPORT(207, void, png_save_uint_16, (png_bytep buf, unsigned int i));
#ifdef PNG_CHECK_FOR_INVALID_INDEX_SUPPORTED
PNG_EXPORT(242, void, png_set_check_for_invalid_index,
- (png_structrp png_ptr, int allowed));
+ (png_structrp png_ptr, int allowed));
# ifdef PNG_GET_PALETTE_MAX_SUPPORTED
-PNG_EXPORT(243, int, png_get_palette_max, (png_const_structp png_ptr,
- png_const_infop info_ptr));
+PNG_EXPORT(243, int, png_get_palette_max,
+ (png_const_structp png_ptr, png_const_infop info_ptr));
# endif
#endif /* CHECK_FOR_INVALID_INDEX */
@@ -2977,24 +3224,25 @@ typedef struct
* the png_controlp field 'opaque' to NULL (or, safer, memset the whole thing.)
*/
#ifdef PNG_STDIO_SUPPORTED
-PNG_EXPORT(234, int, png_image_begin_read_from_file, (png_imagep image,
- const char *file_name));
+PNG_EXPORT(234, int, png_image_begin_read_from_file,
+ (png_imagep image, const char *file_name));
/* The named file is opened for read and the image header is filled in
* from the PNG header in the file.
*/
-PNG_EXPORT(235, int, png_image_begin_read_from_stdio, (png_imagep image,
- FILE* file));
+PNG_EXPORT(235, int, png_image_begin_read_from_stdio,
+ (png_imagep image, FILE *file));
/* The PNG header is read from the stdio FILE object. */
#endif /* STDIO */
-PNG_EXPORT(236, int, png_image_begin_read_from_memory, (png_imagep image,
- png_const_voidp memory, size_t size));
+PNG_EXPORT(236, int, png_image_begin_read_from_memory,
+ (png_imagep image, png_const_voidp memory, size_t size));
/* The PNG header is read from the given memory buffer. */
-PNG_EXPORT(237, int, png_image_finish_read, (png_imagep image,
- png_const_colorp background, void *buffer, png_int_32 row_stride,
- void *colormap));
+PNG_EXPORT(237, int, png_image_finish_read,
+ (png_imagep image,
+ png_const_colorp background, void *buffer, png_int_32 row_stride,
+ void *colormap));
/* Finish reading the image into the supplied buffer and clean up the
* png_image structure.
*
@@ -3027,7 +3275,8 @@ PNG_EXPORT(237, int, png_image_finish_read, (png_imagep image,
* written to the colormap; this may be less than the original value.
*/
-PNG_EXPORT(238, void, png_image_free, (png_imagep image));
+PNG_EXPORT(238, void, png_image_free,
+ (png_imagep image));
/* Free any data allocated by libpng in image->opaque, setting the pointer to
* NULL. May be called at any time after the structure is initialized.
*/
@@ -3051,15 +3300,17 @@ PNG_EXPORT(238, void, png_image_free, (png_imagep image));
* colormap_entries: set to the number of entries in the color-map (0 to 256)
*/
#ifdef PNG_SIMPLIFIED_WRITE_STDIO_SUPPORTED
-PNG_EXPORT(239, int, png_image_write_to_file, (png_imagep image,
- const char *file, int convert_to_8bit, const void *buffer,
- png_int_32 row_stride, const void *colormap));
+PNG_EXPORT(239, int, png_image_write_to_file,
+ (png_imagep image,
+ const char *file, int convert_to_8bit, const void *buffer,
+ png_int_32 row_stride, const void *colormap));
/* Write the image to the named file. */
-PNG_EXPORT(240, int, png_image_write_to_stdio, (png_imagep image, FILE *file,
- int convert_to_8_bit, const void *buffer, png_int_32 row_stride,
- const void *colormap));
- /* Write the image to the given (FILE*). */
+PNG_EXPORT(240, int, png_image_write_to_stdio,
+ (png_imagep image,
+ FILE *file, int convert_to_8_bit, const void *buffer,
+ png_int_32 row_stride, const void *colormap));
+ /* Write the image to the given FILE object. */
#endif /* SIMPLIFIED_WRITE_STDIO */
/* With all write APIs if image is in one of the linear formats with 16-bit
@@ -3083,9 +3334,11 @@ PNG_EXPORT(240, int, png_image_write_to_stdio, (png_imagep image, FILE *file,
* notices) you need to use one of the other APIs.
*/
-PNG_EXPORT(245, int, png_image_write_to_memory, (png_imagep image, void *memory,
- png_alloc_size_t * PNG_RESTRICT memory_bytes, int convert_to_8_bit,
- const void *buffer, png_int_32 row_stride, const void *colormap));
+PNG_EXPORT(245, int, png_image_write_to_memory,
+ (png_imagep image,
+ void *memory, png_alloc_size_t * PNG_RESTRICT memory_bytes,
+ int convert_to_8_bit,
+ const void *buffer, png_int_32 row_stride, const void *colormap));
/* Write the image to the given memory buffer. The function both writes the
* whole PNG data stream to *memory and updates *memory_bytes with the count
* of bytes written.
@@ -3199,19 +3452,45 @@ PNG_EXPORT(245, int, png_image_write_to_memory, (png_imagep image, void *memory,
* selected at run time.
*/
#ifdef PNG_SET_OPTION_SUPPORTED
+
+/* HARDWARE: ARM Neon SIMD instructions supported */
#ifdef PNG_ARM_NEON_API_SUPPORTED
-# define PNG_ARM_NEON 0 /* HARDWARE: ARM Neon SIMD instructions supported */
+# define PNG_ARM_NEON 0
#endif
-#define PNG_MAXIMUM_INFLATE_WINDOW 2 /* SOFTWARE: force maximum window */
-#define PNG_SKIP_sRGB_CHECK_PROFILE 4 /* SOFTWARE: Check ICC profile for sRGB */
+
+/* SOFTWARE: Force maximum window */
+#define PNG_MAXIMUM_INFLATE_WINDOW 2
+
+/* SOFTWARE: Check ICC profile for sRGB */
+#define PNG_SKIP_sRGB_CHECK_PROFILE 4
+
+/* HARDWARE: MIPS MSA SIMD instructions supported */
#ifdef PNG_MIPS_MSA_API_SUPPORTED
-# define PNG_MIPS_MSA 6 /* HARDWARE: MIPS Msa SIMD instructions supported */
+# define PNG_MIPS_MSA 6
#endif
-#define PNG_IGNORE_ADLER32 8
+
+/* SOFTWARE: Disable Adler32 check on IDAT */
+#ifdef PNG_DISABLE_ADLER32_CHECK_SUPPORTED
+# define PNG_IGNORE_ADLER32 8
+#endif
+
+/* HARDWARE: PowerPC VSX SIMD instructions supported */
#ifdef PNG_POWERPC_VSX_API_SUPPORTED
-# define PNG_POWERPC_VSX 10 /* HARDWARE: PowerPC VSX SIMD instructions supported */
+# define PNG_POWERPC_VSX 10
#endif
-#define PNG_OPTION_NEXT 12 /* Next option - numbers must be even */
+
+/* HARDWARE: MIPS MMI SIMD instructions supported */
+#ifdef PNG_MIPS_MMI_API_SUPPORTED
+# define PNG_MIPS_MMI 12
+#endif
+
+/* HARDWARE: RISC-V RVV SIMD instructions supported */
+#ifdef PNG_RISCV_RVV_API_SUPPORTED
+# define PNG_RISCV_RVV 14
+#endif
+
+/* Next option - numbers must be even */
+#define PNG_OPTION_NEXT 16
/* Return values: NOTE: there are four values and 'off' is *not* zero */
#define PNG_OPTION_UNSET 0 /* Unset - defaults to off */
@@ -3235,7 +3514,7 @@ PNG_EXPORT(244, int, png_set_option, (png_structrp png_ptr, int option,
* one to use is one more than this.)
*/
#ifdef PNG_EXPORT_LAST_ORDINAL
- PNG_EXPORT_LAST_ORDINAL(249);
+ PNG_EXPORT_LAST_ORDINAL(259);
#endif
#ifdef __cplusplus
diff --git a/src/libs/Irrlicht/irrlicht-svn/source/Irrlicht/libpng/pngconf.h b/src/libs/Irrlicht/irrlicht-svn/source/Irrlicht/libpng/pngconf.h
index dcba9f9d..375eb5b9 100644
--- a/src/libs/Irrlicht/irrlicht-svn/source/Irrlicht/libpng/pngconf.h
+++ b/src/libs/Irrlicht/irrlicht-svn/source/Irrlicht/libpng/pngconf.h
@@ -1,9 +1,8 @@
-
/* pngconf.h - machine-configurable file for libpng
*
- * libpng version 1.6.37
+ * libpng version 1.6.54
*
- * Copyright (c) 2018-2019 Cosmin Truta
+ * Copyright (c) 2018-2026 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.
@@ -88,7 +87,7 @@
/* The PNGARG macro was used in versions of libpng prior to 1.6.0 to protect
* against legacy (pre ISOC90) compilers that did not understand function
- * prototypes. It is not required for modern C compilers.
+ * prototypes. [Deprecated.]
*/
#ifndef PNGARG
# define PNGARG(arglist) arglist
@@ -180,8 +179,8 @@
* compiler-specific macros to the values required to change the calling
* conventions of the various functions.
*/
-#if defined(_Windows) || defined(_WINDOWS) || defined(WIN32) ||\
- defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)
+#if defined(_WIN32) || defined(__WIN32__) || defined(__NT__) || \
+ defined(__CYGWIN__)
/* Windows system (DOS doesn't support DLLs). Includes builds under Cygwin or
* MinGW on any architecture currently supported by Windows. Also includes
* Watcom builds but these need special treatment because they are not
@@ -220,25 +219,13 @@
/* NOTE: PNGCBAPI always defaults to PNGCAPI. */
# if defined(PNGAPI) && !defined(PNG_USER_PRIVATEBUILD)
-# error "PNG_USER_PRIVATEBUILD must be defined if PNGAPI is changed"
+# error PNG_USER_PRIVATEBUILD must be defined if PNGAPI is changed
# endif
-# if (defined(_MSC_VER) && _MSC_VER < 800) ||\
- (defined(__BORLANDC__) && __BORLANDC__ < 0x500)
- /* older Borland and MSC
- * compilers used '__export' and required this to be after
- * the type.
- */
-# ifndef PNG_EXPORT_TYPE
-# define PNG_EXPORT_TYPE(type) type PNG_IMPEXP
-# endif
-# define PNG_DLL_EXPORT __export
-# else /* newer compiler */
-# define PNG_DLL_EXPORT __declspec(dllexport)
-# ifndef PNG_DLL_IMPORT
-# define PNG_DLL_IMPORT __declspec(dllimport)
-# endif
-# endif /* compiler */
+# define PNG_DLL_EXPORT __declspec(dllexport)
+# ifndef PNG_DLL_IMPORT
+# define PNG_DLL_IMPORT __declspec(dllimport)
+# endif
#else /* !Windows */
# if (defined(__IBMC__) || defined(__IBMCPP__)) && defined(__OS2__)
@@ -298,7 +285,7 @@
#ifndef PNG_EXPORTA
# define PNG_EXPORTA(ordinal, type, name, args, attributes) \
- PNG_FUNCTION(PNG_EXPORT_TYPE(type), (PNGAPI name), PNGARG(args), \
+ PNG_FUNCTION(PNG_EXPORT_TYPE(type), (PNGAPI name), args, \
PNG_LINKAGE_API attributes)
#endif
@@ -316,7 +303,7 @@
#endif
#ifndef PNG_CALLBACK
-# define PNG_CALLBACK(type, name, args) type (PNGCBAPI name) PNGARG(args)
+# define PNG_CALLBACK(type, name, args) type (PNGCBAPI name) args
#endif
/* Support for compiler specific function attributes. These are used
@@ -480,7 +467,7 @@
#if CHAR_BIT == 8 && UCHAR_MAX == 255
typedef unsigned char png_byte;
#else
-# error "libpng requires 8-bit bytes"
+# error libpng requires 8-bit bytes
#endif
#if INT_MIN == -32768 && INT_MAX == 32767
@@ -488,7 +475,7 @@
#elif SHRT_MIN == -32768 && SHRT_MAX == 32767
typedef short png_int_16;
#else
-# error "libpng requires a signed 16-bit type"
+# error libpng requires a signed 16-bit integer type
#endif
#if UINT_MAX == 65535
@@ -496,7 +483,7 @@
#elif USHRT_MAX == 65535
typedef unsigned short png_uint_16;
#else
-# error "libpng requires an unsigned 16-bit type"
+# error libpng requires an unsigned 16-bit integer type
#endif
#if INT_MIN < -2147483646 && INT_MAX > 2147483646
@@ -504,7 +491,7 @@
#elif LONG_MIN < -2147483646 && LONG_MAX > 2147483646
typedef long int png_int_32;
#else
-# error "libpng requires a signed 32-bit (or more) type"
+# error libpng requires a signed 32-bit (or longer) integer type
#endif
#if UINT_MAX > 4294967294U
@@ -512,7 +499,7 @@
#elif ULONG_MAX > 4294967294U
typedef unsigned long int png_uint_32;
#else
-# error "libpng requires an unsigned 32-bit (or more) type"
+# error libpng requires an unsigned 32-bit (or longer) integer type
#endif
/* Prior to 1.6.0, it was possible to disable the use of size_t and ptrdiff_t.
@@ -593,10 +580,6 @@ typedef const png_fixed_point * png_const_fixed_point_p;
typedef size_t * png_size_tp;
typedef const size_t * png_const_size_tp;
-#ifdef PNG_STDIO_SUPPORTED
-typedef FILE * png_FILE_p;
-#endif
-
#ifdef PNG_FLOATING_POINT_SUPPORTED
typedef double * png_doublep;
typedef const double * png_const_doublep;
@@ -618,6 +601,15 @@ typedef double * * png_doublepp;
/* Pointers to pointers to pointers; i.e., pointer to array */
typedef char * * * png_charppp;
+#ifdef PNG_STDIO_SUPPORTED
+/* With PNG_STDIO_SUPPORTED it was possible to use I/O streams that were
+ * not necessarily stdio FILE streams, to allow building Windows applications
+ * before Win32 and Windows CE applications before WinCE 3.0, but that kind
+ * of support has long been discontinued.
+ */
+typedef FILE * png_FILE_p; /* [Deprecated] */
+#endif
+
#endif /* PNG_BUILDING_SYMBOL_TABLE */
#endif /* PNGCONF_H */
diff --git a/src/libs/Irrlicht/irrlicht-svn/source/Irrlicht/libpng/pngdebug.h b/src/libs/Irrlicht/irrlicht-svn/source/Irrlicht/libpng/pngdebug.h
index 5530c0c9..31498f51 100644
--- a/src/libs/Irrlicht/irrlicht-svn/source/Irrlicht/libpng/pngdebug.h
+++ b/src/libs/Irrlicht/irrlicht-svn/source/Irrlicht/libpng/pngdebug.h
@@ -1,7 +1,6 @@
-
-/* pngdebug.h - Debugging macros for libpng, also used in pngtest.c
+/* pngdebug.h - internal debugging macros for libpng
*
- * Copyright (c) 2018 Cosmin Truta
+ * Copyright (c) 2018-2025 Cosmin Truta
* Copyright (c) 1998-2002,2004,2006-2013 Glenn Randers-Pehrson
* Copyright (c) 1996-1997 Andreas Dilger
* Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
@@ -11,6 +10,10 @@
* and license in png.h
*/
+#ifndef PNGPRIV_H
+# error This file must not be included by applications; please include
+#endif
+
/* Define PNG_DEBUG at compile time for debugging information. Higher
* numbers for PNG_DEBUG mean more debugging information. This has
* only been added since version 0.95 so it is not implemented throughout
@@ -35,9 +38,6 @@
#define PNGDEBUG_H
/* These settings control the formatting of messages in png.c and pngerror.c */
/* Moved to pngdebug.h at 1.5.0 */
-# ifndef PNG_LITERAL_SHARP
-# define PNG_LITERAL_SHARP 0x23
-# endif
# ifndef PNG_LITERAL_LEFT_SQUARE_BRACKET
# define PNG_LITERAL_LEFT_SQUARE_BRACKET 0x5b
# endif
diff --git a/src/libs/Irrlicht/irrlicht-svn/source/Irrlicht/libpng/pngerror.c b/src/libs/Irrlicht/irrlicht-svn/source/Irrlicht/libpng/pngerror.c
index c612e7a9..64a2284c 100644
--- a/src/libs/Irrlicht/irrlicht-svn/source/Irrlicht/libpng/pngerror.c
+++ b/src/libs/Irrlicht/irrlicht-svn/source/Irrlicht/libpng/pngerror.c
@@ -1,7 +1,6 @@
-
/* pngerror.c - stub functions for i/o and memory allocation
*
- * Copyright (c) 2018 Cosmin Truta
+ * Copyright (c) 2018-2025 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.
@@ -20,13 +19,14 @@
#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED)
-static PNG_FUNCTION(void, png_default_error,PNGARG((png_const_structrp png_ptr,
- png_const_charp error_message)),PNG_NORETURN);
+static PNG_FUNCTION(void /* PRIVATE */,
+png_default_error,(png_const_structrp png_ptr, png_const_charp error_message),
+ PNG_NORETURN);
#ifdef PNG_WARNINGS_SUPPORTED
static void /* PRIVATE */
-png_default_warning PNGARG((png_const_structrp png_ptr,
- png_const_charp warning_message));
+png_default_warning(png_const_structrp png_ptr,
+ png_const_charp warning_message);
#endif /* WARNINGS */
/* This function is called whenever there is a fatal error. This function
@@ -39,46 +39,6 @@ PNG_FUNCTION(void,PNGAPI
png_error,(png_const_structrp png_ptr, png_const_charp error_message),
PNG_NORETURN)
{
-#ifdef PNG_ERROR_NUMBERS_SUPPORTED
- char msg[16];
- if (png_ptr != NULL)
- {
- if ((png_ptr->flags &
- (PNG_FLAG_STRIP_ERROR_NUMBERS|PNG_FLAG_STRIP_ERROR_TEXT)) != 0)
- {
- if (*error_message == PNG_LITERAL_SHARP)
- {
- /* Strip "#nnnn " from beginning of error message. */
- int offset;
- for (offset = 1; offset<15; offset++)
- if (error_message[offset] == ' ')
- break;
-
- if ((png_ptr->flags & PNG_FLAG_STRIP_ERROR_TEXT) != 0)
- {
- int i;
- for (i = 0; i < offset - 1; i++)
- msg[i] = error_message[i + 1];
- msg[i - 1] = '\0';
- error_message = msg;
- }
-
- else
- error_message += offset;
- }
-
- else
- {
- if ((png_ptr->flags & PNG_FLAG_STRIP_ERROR_TEXT) != 0)
- {
- msg[0] = '0';
- msg[1] = '\0';
- error_message = msg;
- }
- }
- }
- }
-#endif
if (png_ptr != NULL && png_ptr->error_fn != NULL)
(*(png_ptr->error_fn))(png_constcast(png_structrp,png_ptr),
error_message);
@@ -89,7 +49,8 @@ png_error,(png_const_structrp png_ptr, png_const_charp error_message),
}
#else
PNG_FUNCTION(void,PNGAPI
-png_err,(png_const_structrp png_ptr),PNG_NORETURN)
+png_err,(png_const_structrp png_ptr),
+ PNG_NORETURN)
{
/* Prior to 1.5.2 the error_fn received a NULL pointer, expressed
* erroneously as '\0', instead of the empty string "". This was
@@ -216,21 +177,6 @@ void PNGAPI
png_warning(png_const_structrp png_ptr, png_const_charp warning_message)
{
int offset = 0;
- if (png_ptr != NULL)
- {
-#ifdef PNG_ERROR_NUMBERS_SUPPORTED
- if ((png_ptr->flags &
- (PNG_FLAG_STRIP_ERROR_NUMBERS|PNG_FLAG_STRIP_ERROR_TEXT)) != 0)
-#endif
- {
- if (*warning_message == PNG_LITERAL_SHARP)
- {
- for (offset = 1; offset < 15; offset++)
- if (warning_message[offset] == ' ')
- break;
- }
- }
- }
if (png_ptr != NULL && png_ptr->warning_fn != NULL)
(*(png_ptr->warning_fn))(png_constcast(png_structrp,png_ptr),
warning_message + offset);
@@ -255,7 +201,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 +211,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;
@@ -431,8 +377,8 @@ static const char png_digit[16] = {
};
static void /* PRIVATE */
-png_format_buffer(png_const_structrp png_ptr, png_charp buffer, png_const_charp
- error_message)
+png_format_buffer(png_const_structrp png_ptr, png_charp buffer,
+ png_const_charp error_message)
{
png_uint_32 chunk_name = png_ptr->chunk_name;
int iout = 0, ishift = 24;
@@ -511,8 +457,8 @@ png_chunk_warning(png_const_structrp png_ptr, png_const_charp warning_message)
#ifdef PNG_READ_SUPPORTED
#ifdef PNG_BENIGN_ERRORS_SUPPORTED
void PNGAPI
-png_chunk_benign_error(png_const_structrp png_ptr, png_const_charp
- error_message)
+png_chunk_benign_error(png_const_structrp png_ptr,
+ png_const_charp error_message)
{
if ((png_ptr->flags & PNG_FLAG_BENIGN_ERRORS_WARN) != 0)
png_chunk_warning(png_ptr, error_message);
@@ -569,7 +515,8 @@ png_chunk_report(png_const_structrp png_ptr, png_const_charp message, int error)
#ifdef PNG_ERROR_TEXT_SUPPORTED
#ifdef PNG_FLOATING_POINT_SUPPORTED
PNG_FUNCTION(void,
-png_fixed_error,(png_const_structrp png_ptr, png_const_charp name),PNG_NORETURN)
+png_fixed_error,(png_const_structrp png_ptr, png_const_charp name),
+ PNG_NORETURN)
{
# define fixed_message "fixed point overflow in "
# define fixed_message_ln ((sizeof fixed_message)-1)
@@ -712,42 +659,9 @@ png_default_error,(png_const_structrp png_ptr, png_const_charp error_message),
PNG_NORETURN)
{
#ifdef PNG_CONSOLE_IO_SUPPORTED
-#ifdef PNG_ERROR_NUMBERS_SUPPORTED
- /* Check on NULL only added in 1.5.4 */
- if (error_message != NULL && *error_message == PNG_LITERAL_SHARP)
- {
- /* Strip "#nnnn " from beginning of error message. */
- int offset;
- char error_number[16];
- for (offset = 0; offset<15; offset++)
- {
- error_number[offset] = error_message[offset + 1];
- if (error_message[offset] == ' ')
- break;
- }
-
- if ((offset > 1) && (offset < 15))
- {
- error_number[offset - 1] = '\0';
- fprintf(stderr, "libpng error no. %s: %s",
- error_number, error_message + offset + 1);
- fprintf(stderr, PNG_STRING_NEWLINE);
- }
-
- else
- {
- fprintf(stderr, "libpng error: %s, offset=%d",
- error_message, offset);
- fprintf(stderr, PNG_STRING_NEWLINE);
- }
- }
- else
-#endif
- {
- fprintf(stderr, "libpng error: %s", error_message ? error_message :
- "undefined");
- fprintf(stderr, PNG_STRING_NEWLINE);
- }
+ fprintf(stderr, "libpng error: %s", error_message ? error_message :
+ "undefined");
+ fprintf(stderr, PNG_STRING_NEWLINE);
#else
PNG_UNUSED(error_message) /* Make compiler happy */
#endif
@@ -755,7 +669,8 @@ png_default_error,(png_const_structrp png_ptr, png_const_charp error_message),
}
PNG_FUNCTION(void,PNGAPI
-png_longjmp,(png_const_structrp png_ptr, int val),PNG_NORETURN)
+png_longjmp,(png_const_structrp png_ptr, int val),
+ PNG_NORETURN)
{
#ifdef PNG_SETJMP_SUPPORTED
if (png_ptr != NULL && png_ptr->longjmp_fn != NULL &&
@@ -785,40 +700,8 @@ static void /* PRIVATE */
png_default_warning(png_const_structrp png_ptr, png_const_charp warning_message)
{
#ifdef PNG_CONSOLE_IO_SUPPORTED
-# ifdef PNG_ERROR_NUMBERS_SUPPORTED
- if (*warning_message == PNG_LITERAL_SHARP)
- {
- int offset;
- char warning_number[16];
- for (offset = 0; offset < 15; offset++)
- {
- warning_number[offset] = warning_message[offset + 1];
- if (warning_message[offset] == ' ')
- break;
- }
-
- if ((offset > 1) && (offset < 15))
- {
- warning_number[offset + 1] = '\0';
- fprintf(stderr, "libpng warning no. %s: %s",
- warning_number, warning_message + offset);
- fprintf(stderr, PNG_STRING_NEWLINE);
- }
-
- else
- {
- fprintf(stderr, "libpng warning: %s",
- warning_message);
- fprintf(stderr, PNG_STRING_NEWLINE);
- }
- }
- else
-# endif
-
- {
- fprintf(stderr, "libpng warning: %s", warning_message);
- fprintf(stderr, PNG_STRING_NEWLINE);
- }
+ fprintf(stderr, "libpng warning: %s", warning_message);
+ fprintf(stderr, PNG_STRING_NEWLINE);
#else
PNG_UNUSED(warning_message) /* Make compiler happy */
#endif
@@ -858,7 +741,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;
}
@@ -866,12 +749,8 @@ png_get_error_ptr(png_const_structrp png_ptr)
void PNGAPI
png_set_strip_error_numbers(png_structrp png_ptr, png_uint_32 strip_mode)
{
- if (png_ptr != NULL)
- {
- png_ptr->flags &=
- ((~(PNG_FLAG_STRIP_ERROR_NUMBERS |
- PNG_FLAG_STRIP_ERROR_TEXT))&strip_mode);
- }
+ PNG_UNUSED(png_ptr)
+ PNG_UNUSED(strip_mode)
}
#endif
@@ -933,31 +812,39 @@ 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;
+ const png_voidp saved_error_buf = image->opaque->error_buf;
jmp_buf safe_jmpbuf;
- /* 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)
{
+ int result;
image->opaque->error_buf = safe_jmpbuf;
result = function(arg);
+ image->opaque->error_buf = saved_error_buf;
+
+ if (result)
+ return 1; /* success */
}
+ /* The function failed either because of a caught png_error and a regular
+ * return of false above or because of an uncaught png_error from the
+ * function itself. Ensure that the error_buf is always set back to the
+ * value saved above:
+ */
image->opaque->error_buf = saved_error_buf;
- /* And do the cleanup prior to any failure return. */
- if (result == 0)
+ /* On the final false return, when about to return control to the caller, the
+ * image is freed (png_image_free does this check but it is duplicated here
+ * for clarity:
+ */
+ if (saved_error_buf == NULL)
png_image_free(image);
- return result;
+ return 0; /* failure */
}
#endif /* SIMPLIFIED READ || SIMPLIFIED_WRITE */
#endif /* READ || WRITE */
diff --git a/src/libs/Irrlicht/irrlicht-svn/source/Irrlicht/libpng/pngget.c b/src/libs/Irrlicht/irrlicht-svn/source/Irrlicht/libpng/pngget.c
index e7348645..6734c82a 100644
--- a/src/libs/Irrlicht/irrlicht-svn/source/Irrlicht/libpng/pngget.c
+++ b/src/libs/Irrlicht/irrlicht-svn/source/Irrlicht/libpng/pngget.c
@@ -1,7 +1,6 @@
-
/* pngget.c - retrieval of values from info struct
*
- * Copyright (c) 2018 Cosmin Truta
+ * Copyright (c) 2018-2025 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.
@@ -21,18 +20,29 @@ png_get_valid(png_const_structrp png_ptr, png_const_inforp info_ptr,
png_uint_32 flag)
{
if (png_ptr != NULL && info_ptr != NULL)
- return(info_ptr->valid & flag);
+ {
+#ifdef PNG_READ_tRNS_SUPPORTED
+ /* png_handle_PLTE() may have canceled a valid tRNS chunk but left the
+ * 'valid' flag for the detection of duplicate chunks. Do not report a
+ * valid tRNS chunk in this case.
+ */
+ if (flag == PNG_INFO_tRNS && png_ptr->num_trans == 0)
+ return 0;
+#endif
+
+ 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
@@ -40,9 +50,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
@@ -54,7 +64,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
@@ -63,7 +73,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
@@ -72,7 +82,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
@@ -81,7 +91,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
@@ -90,7 +100,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
@@ -99,7 +109,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
@@ -108,95 +118,93 @@ 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
-png_get_x_pixels_per_meter(png_const_structrp png_ptr, png_const_inforp
- info_ptr)
+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
-png_get_y_pixels_per_meter(png_const_structrp png_ptr, png_const_inforp
- info_ptr)
+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
float PNGAPI
-png_get_pixel_aspect_ratio(png_const_structrp png_ptr, png_const_inforp
- info_ptr)
+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
@@ -206,6 +214,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 &&
@@ -214,8 +224,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.
*/
@@ -236,80 +244,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
@@ -372,7 +380,13 @@ png_fixed_inches_from_microns(png_const_structrp png_ptr, png_int_32 microns)
* Notice that this can overflow - a warning is output and 0 is
* returned.
*/
- return png_muldiv_warn(png_ptr, microns, 500, 127);
+ png_fixed_point result;
+
+ if (png_muldiv(&result, microns, 500, 127) != 0)
+ return result;
+
+ png_warning(png_ptr, "fixed point overflow ignored");
+ return 0;
}
png_fixed_point PNGAPI
@@ -382,7 +396,7 @@ png_get_x_offset_inches_fixed(png_const_structrp png_ptr,
return png_fixed_inches_from_microns(png_ptr,
png_get_x_offset_microns(png_ptr, info_ptr));
}
-#endif
+#endif /* FIXED_POINT */
#ifdef PNG_FIXED_POINT_SUPPORTED
png_fixed_point PNGAPI
@@ -423,11 +437,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;
@@ -453,7 +467,7 @@ png_get_pHYs_dpi(png_const_structrp png_ptr, png_const_inforp info_ptr,
}
}
- return (retval);
+ return retval;
}
#endif /* pHYs */
#endif /* INCH_CONVERSIONS */
@@ -467,9 +481,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
@@ -477,9 +491,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
@@ -488,17 +502,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
@@ -510,48 +524,35 @@ png_get_bKGD(png_const_structrp png_ptr, png_inforp info_ptr,
# ifdef PNG_FLOATING_POINT_SUPPORTED
png_uint_32 PNGAPI
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)
+ double *whitex, double *whitey, double *redx, double *redy,
+ double *greenx, double *greeny, double *bluex, double *bluey)
{
- /* 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
- * the png_set_ APIs merely check that set end points are mutually
- * consistent.
- */
+ png_debug1(1, "in %s retrieval function", "cHRM");
+
+ /* PNGv3: this just returns the values store from the cHRM, if any. */
if (png_ptr != NULL && info_ptr != NULL &&
- (info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_ENDPOINTS) != 0)
+ (info_ptr->valid & PNG_INFO_cHRM) != 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");
- if (white_y != NULL)
- *white_y = png_float(png_ptr,
- info_ptr->colorspace.end_points_xy.whitey, "cHRM white Y");
- if (red_x != NULL)
- *red_x = png_float(png_ptr, info_ptr->colorspace.end_points_xy.redx,
- "cHRM red X");
- if (red_y != NULL)
- *red_y = png_float(png_ptr, info_ptr->colorspace.end_points_xy.redy,
- "cHRM red Y");
- if (green_x != NULL)
- *green_x = png_float(png_ptr,
- info_ptr->colorspace.end_points_xy.greenx, "cHRM green X");
- if (green_y != NULL)
- *green_y = png_float(png_ptr,
- info_ptr->colorspace.end_points_xy.greeny, "cHRM green Y");
- if (blue_x != NULL)
- *blue_x = png_float(png_ptr, info_ptr->colorspace.end_points_xy.bluex,
- "cHRM blue X");
- if (blue_y != NULL)
- *blue_y = png_float(png_ptr, info_ptr->colorspace.end_points_xy.bluey,
- "cHRM blue Y");
- return (PNG_INFO_cHRM);
+ if (whitex != NULL)
+ *whitex = png_float(png_ptr, info_ptr->cHRM.whitex, "cHRM wx");
+ if (whitey != NULL)
+ *whitey = png_float(png_ptr, info_ptr->cHRM.whitey, "cHRM wy");
+ if (redx != NULL)
+ *redx = png_float(png_ptr, info_ptr->cHRM.redx, "cHRM rx");
+ if (redy != NULL)
+ *redy = png_float(png_ptr, info_ptr->cHRM.redy, "cHRM ry");
+ if (greenx != NULL)
+ *greenx = png_float(png_ptr, info_ptr->cHRM.greenx, "cHRM gx");
+ if (greeny != NULL)
+ *greeny = png_float(png_ptr, info_ptr->cHRM.greeny, "cHRM gy");
+ if (bluex != NULL)
+ *bluex = png_float(png_ptr, info_ptr->cHRM.bluex, "cHRM bx");
+ if (bluey != NULL)
+ *bluey = png_float(png_ptr, info_ptr->cHRM.bluey, "cHRM by");
+ return PNG_INFO_cHRM;
}
- return (0);
+ return 0;
}
png_uint_32 PNGAPI
@@ -560,42 +561,35 @@ 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_XYZ XYZ;
+ 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)
+ (info_ptr->valid & PNG_INFO_cHRM) != 0 &&
+ png_XYZ_from_xy(&XYZ, &info_ptr->cHRM) == 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");
+ *red_X = png_float(png_ptr, XYZ.red_X, "cHRM red X");
if (red_Y != NULL)
- *red_Y = png_float(png_ptr, info_ptr->colorspace.end_points_XYZ.red_Y,
- "cHRM red Y");
+ *red_Y = png_float(png_ptr, XYZ.red_Y, "cHRM red Y");
if (red_Z != NULL)
- *red_Z = png_float(png_ptr, info_ptr->colorspace.end_points_XYZ.red_Z,
- "cHRM red Z");
+ *red_Z = png_float(png_ptr, XYZ.red_Z, "cHRM red Z");
if (green_X != NULL)
- *green_X = png_float(png_ptr,
- info_ptr->colorspace.end_points_XYZ.green_X, "cHRM green X");
+ *green_X = png_float(png_ptr, XYZ.green_X, "cHRM green X");
if (green_Y != NULL)
- *green_Y = png_float(png_ptr,
- info_ptr->colorspace.end_points_XYZ.green_Y, "cHRM green Y");
+ *green_Y = png_float(png_ptr, XYZ.green_Y, "cHRM green Y");
if (green_Z != NULL)
- *green_Z = png_float(png_ptr,
- info_ptr->colorspace.end_points_XYZ.green_Z, "cHRM green Z");
+ *green_Z = png_float(png_ptr, XYZ.green_Z, "cHRM green Z");
if (blue_X != NULL)
- *blue_X = png_float(png_ptr,
- info_ptr->colorspace.end_points_XYZ.blue_X, "cHRM blue X");
+ *blue_X = png_float(png_ptr, XYZ.blue_X, "cHRM blue X");
if (blue_Y != NULL)
- *blue_Y = png_float(png_ptr,
- info_ptr->colorspace.end_points_XYZ.blue_Y, "cHRM blue Y");
+ *blue_Y = png_float(png_ptr, XYZ.blue_Y, "cHRM blue Y");
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);
+ *blue_Z = png_float(png_ptr, XYZ.blue_Z, "cHRM blue Z");
+ return PNG_INFO_cHRM;
}
- return (0);
+ return 0;
}
# endif
@@ -608,66 +602,52 @@ 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_XYZ XYZ;
+ 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)
+ (info_ptr->valid & PNG_INFO_cHRM) != 0U &&
+ png_XYZ_from_xy(&XYZ, &info_ptr->cHRM) == 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)
- *int_red_Y = info_ptr->colorspace.end_points_XYZ.red_Y;
- if (int_red_Z != NULL)
- *int_red_Z = info_ptr->colorspace.end_points_XYZ.red_Z;
- if (int_green_X != NULL)
- *int_green_X = info_ptr->colorspace.end_points_XYZ.green_X;
- if (int_green_Y != NULL)
- *int_green_Y = info_ptr->colorspace.end_points_XYZ.green_Y;
- if (int_green_Z != NULL)
- *int_green_Z = info_ptr->colorspace.end_points_XYZ.green_Z;
- if (int_blue_X != NULL)
- *int_blue_X = info_ptr->colorspace.end_points_XYZ.blue_X;
- if (int_blue_Y != NULL)
- *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);
+ if (int_red_X != NULL) *int_red_X = XYZ.red_X;
+ if (int_red_Y != NULL) *int_red_Y = XYZ.red_Y;
+ if (int_red_Z != NULL) *int_red_Z = XYZ.red_Z;
+ if (int_green_X != NULL) *int_green_X = XYZ.green_X;
+ if (int_green_Y != NULL) *int_green_Y = XYZ.green_Y;
+ if (int_green_Z != NULL) *int_green_Z = XYZ.green_Z;
+ if (int_blue_X != NULL) *int_blue_X = XYZ.blue_X;
+ if (int_blue_Y != NULL) *int_blue_Y = XYZ.blue_Y;
+ if (int_blue_Z != NULL) *int_blue_Z = XYZ.blue_Z;
+ return PNG_INFO_cHRM;
}
- return (0);
+ return 0;
}
png_uint_32 PNGAPI
png_get_cHRM_fixed(png_const_structrp png_ptr, png_const_inforp info_ptr,
- png_fixed_point *white_x, png_fixed_point *white_y, png_fixed_point *red_x,
- png_fixed_point *red_y, png_fixed_point *green_x, png_fixed_point *green_y,
- png_fixed_point *blue_x, png_fixed_point *blue_y)
+ png_fixed_point *whitex, png_fixed_point *whitey, png_fixed_point *redx,
+ png_fixed_point *redy, png_fixed_point *greenx, png_fixed_point *greeny,
+ png_fixed_point *bluex, png_fixed_point *bluey)
{
png_debug1(1, "in %s retrieval function", "cHRM");
+ /* PNGv3: this just returns the values store from the cHRM, if any. */
if (png_ptr != NULL && info_ptr != NULL &&
- (info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_ENDPOINTS) != 0)
+ (info_ptr->valid & PNG_INFO_cHRM) != 0)
{
- if (white_x != NULL)
- *white_x = info_ptr->colorspace.end_points_xy.whitex;
- if (white_y != NULL)
- *white_y = info_ptr->colorspace.end_points_xy.whitey;
- if (red_x != NULL)
- *red_x = info_ptr->colorspace.end_points_xy.redx;
- if (red_y != NULL)
- *red_y = info_ptr->colorspace.end_points_xy.redy;
- if (green_x != NULL)
- *green_x = info_ptr->colorspace.end_points_xy.greenx;
- if (green_y != NULL)
- *green_y = info_ptr->colorspace.end_points_xy.greeny;
- if (blue_x != NULL)
- *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);
+ if (whitex != NULL) *whitex = info_ptr->cHRM.whitex;
+ if (whitey != NULL) *whitey = info_ptr->cHRM.whitey;
+ if (redx != NULL) *redx = info_ptr->cHRM.redx;
+ if (redy != NULL) *redy = info_ptr->cHRM.redy;
+ if (greenx != NULL) *greenx = info_ptr->cHRM.greenx;
+ if (greeny != NULL) *greeny = info_ptr->cHRM.greeny;
+ if (bluex != NULL) *bluex = info_ptr->cHRM.bluex;
+ if (bluey != NULL) *bluey = info_ptr->cHRM.bluey;
+ return PNG_INFO_cHRM;
}
- return (0);
+ return 0;
}
# endif
#endif
@@ -680,15 +660,15 @@ png_get_gAMA_fixed(png_const_structrp png_ptr, png_const_inforp info_ptr,
{
png_debug1(1, "in %s retrieval function", "gAMA");
+ /* PNGv3 compatibility: only report gAMA if it is really present. */
if (png_ptr != NULL && info_ptr != NULL &&
- (info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_GAMMA) != 0 &&
- file_gamma != NULL)
+ (info_ptr->valid & PNG_INFO_gAMA) != 0)
{
- *file_gamma = info_ptr->colorspace.gamma;
- return (PNG_INFO_gAMA);
+ if (file_gamma != NULL) *file_gamma = info_ptr->gamma;
+ return PNG_INFO_gAMA;
}
- return (0);
+ return 0;
}
# endif
@@ -699,16 +679,17 @@ png_get_gAMA(png_const_structrp png_ptr, png_const_inforp info_ptr,
{
png_debug1(1, "in %s retrieval function", "gAMA(float)");
+ /* PNGv3 compatibility: only report gAMA if it is really present. */
if (png_ptr != NULL && info_ptr != NULL &&
- (info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_GAMMA) != 0 &&
- file_gamma != NULL)
+ (info_ptr->valid & PNG_INFO_gAMA) != 0)
{
- *file_gamma = png_float(png_ptr, info_ptr->colorspace.gamma,
- "png_get_gAMA");
- return (PNG_INFO_gAMA);
+ if (file_gamma != NULL)
+ *file_gamma = png_float(png_ptr, info_ptr->gamma, "gAMA");
+
+ return PNG_INFO_gAMA;
}
- return (0);
+ return 0;
}
# endif
#endif
@@ -721,13 +702,14 @@ png_get_sRGB(png_const_structrp png_ptr, png_const_inforp info_ptr,
png_debug1(1, "in %s retrieval function", "sRGB");
if (png_ptr != NULL && info_ptr != NULL &&
- (info_ptr->valid & PNG_INFO_sRGB) != 0 && file_srgb_intent != NULL)
+ (info_ptr->valid & PNG_INFO_sRGB) != 0)
{
- *file_srgb_intent = info_ptr->colorspace.rendering_intent;
- return (PNG_INFO_sRGB);
+ if (file_srgb_intent != NULL)
+ *file_srgb_intent = info_ptr->rendering_intent;
+ return PNG_INFO_sRGB;
}
- return (0);
+ return 0;
}
#endif
@@ -751,11 +733,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
@@ -764,16 +745,148 @@ 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
+
+#ifdef PNG_cICP_SUPPORTED
+png_uint_32 PNGAPI
+png_get_cICP(png_const_structrp png_ptr,
+ png_const_inforp info_ptr, png_bytep colour_primaries,
+ png_bytep transfer_function, png_bytep matrix_coefficients,
+ png_bytep video_full_range_flag)
+{
+ png_debug1(1, "in %s retrieval function", "cICP");
+
+ if (png_ptr != NULL && info_ptr != NULL &&
+ (info_ptr->valid & PNG_INFO_cICP) != 0 &&
+ colour_primaries != NULL && transfer_function != NULL &&
+ matrix_coefficients != NULL && video_full_range_flag != NULL)
+ {
+ *colour_primaries = info_ptr->cicp_colour_primaries;
+ *transfer_function = info_ptr->cicp_transfer_function;
+ *matrix_coefficients = info_ptr->cicp_matrix_coefficients;
+ *video_full_range_flag = info_ptr->cicp_video_full_range_flag;
+ return (PNG_INFO_cICP);
+ }
+
+ return 0;
}
#endif
+#ifdef PNG_cLLI_SUPPORTED
+# ifdef PNG_FIXED_POINT_SUPPORTED
+png_uint_32 PNGAPI
+png_get_cLLI_fixed(png_const_structrp png_ptr, png_const_inforp info_ptr,
+ png_uint_32p maxCLL,
+ png_uint_32p maxFALL)
+{
+ png_debug1(1, "in %s retrieval function", "cLLI");
+
+ if (png_ptr != NULL && info_ptr != NULL &&
+ (info_ptr->valid & PNG_INFO_cLLI) != 0)
+ {
+ if (maxCLL != NULL) *maxCLL = info_ptr->maxCLL;
+ if (maxFALL != NULL) *maxFALL = info_ptr->maxFALL;
+ return PNG_INFO_cLLI;
+ }
+
+ return 0;
+}
+# endif
+
+# ifdef PNG_FLOATING_POINT_SUPPORTED
+png_uint_32 PNGAPI
+png_get_cLLI(png_const_structrp png_ptr, png_const_inforp info_ptr,
+ double *maxCLL, double *maxFALL)
+{
+ png_debug1(1, "in %s retrieval function", "cLLI(float)");
+
+ if (png_ptr != NULL && info_ptr != NULL &&
+ (info_ptr->valid & PNG_INFO_cLLI) != 0)
+ {
+ if (maxCLL != NULL) *maxCLL = info_ptr->maxCLL * .0001;
+ if (maxFALL != NULL) *maxFALL = info_ptr->maxFALL * .0001;
+ return PNG_INFO_cLLI;
+ }
+
+ return 0;
+}
+# endif
+#endif /* cLLI */
+
+#ifdef PNG_mDCV_SUPPORTED
+# ifdef PNG_FIXED_POINT_SUPPORTED
+png_uint_32 PNGAPI
+png_get_mDCV_fixed(png_const_structrp png_ptr, png_const_inforp info_ptr,
+ png_fixed_point *white_x, png_fixed_point *white_y,
+ png_fixed_point *red_x, png_fixed_point *red_y,
+ png_fixed_point *green_x, png_fixed_point *green_y,
+ png_fixed_point *blue_x, png_fixed_point *blue_y,
+ png_uint_32p mastering_maxDL, png_uint_32p mastering_minDL)
+{
+ png_debug1(1, "in %s retrieval function", "mDCV");
+
+ if (png_ptr != NULL && info_ptr != NULL &&
+ (info_ptr->valid & PNG_INFO_mDCV) != 0)
+ {
+ if (white_x != NULL) *white_x = info_ptr->mastering_white_x * 2;
+ if (white_y != NULL) *white_y = info_ptr->mastering_white_y * 2;
+ if (red_x != NULL) *red_x = info_ptr->mastering_red_x * 2;
+ if (red_y != NULL) *red_y = info_ptr->mastering_red_y * 2;
+ if (green_x != NULL) *green_x = info_ptr->mastering_green_x * 2;
+ if (green_y != NULL) *green_y = info_ptr->mastering_green_y * 2;
+ if (blue_x != NULL) *blue_x = info_ptr->mastering_blue_x * 2;
+ if (blue_y != NULL) *blue_y = info_ptr->mastering_blue_y * 2;
+ if (mastering_maxDL != NULL) *mastering_maxDL = info_ptr->mastering_maxDL;
+ if (mastering_minDL != NULL) *mastering_minDL = info_ptr->mastering_minDL;
+ return PNG_INFO_mDCV;
+ }
+
+ return 0;
+}
+# endif
+
+# ifdef PNG_FLOATING_POINT_SUPPORTED
+png_uint_32 PNGAPI
+png_get_mDCV(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,
+ double *mastering_maxDL, double *mastering_minDL)
+{
+ png_debug1(1, "in %s retrieval function", "mDCV(float)");
+
+ if (png_ptr != NULL && info_ptr != NULL &&
+ (info_ptr->valid & PNG_INFO_mDCV) != 0)
+ {
+ if (white_x != NULL) *white_x = info_ptr->mastering_white_x * .00002;
+ if (white_y != NULL) *white_y = info_ptr->mastering_white_y * .00002;
+ if (red_x != NULL) *red_x = info_ptr->mastering_red_x * .00002;
+ if (red_y != NULL) *red_y = info_ptr->mastering_red_y * .00002;
+ if (green_x != NULL) *green_x = info_ptr->mastering_green_x * .00002;
+ if (green_y != NULL) *green_y = info_ptr->mastering_green_y * .00002;
+ if (blue_x != NULL) *blue_x = info_ptr->mastering_blue_x * .00002;
+ if (blue_y != NULL) *blue_y = info_ptr->mastering_blue_y * .00002;
+ if (mastering_maxDL != NULL)
+ *mastering_maxDL = info_ptr->mastering_maxDL * .0001;
+ if (mastering_minDL != NULL)
+ *mastering_minDL = info_ptr->mastering_minDL * .0001;
+ return PNG_INFO_mDCV;
+ }
+
+ return 0;
+}
+# endif /* FLOATING_POINT */
+#endif /* mDCV */
+
#ifdef PNG_eXIf_SUPPORTED
png_uint_32 PNGAPI
png_get_eXIf(png_const_structrp png_ptr, png_inforp info_ptr,
@@ -796,10 +909,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
@@ -814,10 +927,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
@@ -830,7 +943,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;
@@ -862,7 +975,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
@@ -879,10 +992,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
@@ -906,10 +1019,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
@@ -921,6 +1034,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)
{
@@ -932,10 +1047,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 */
@@ -944,32 +1059,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 */
@@ -1004,7 +1123,7 @@ png_get_pHYs(png_const_structrp png_ptr, png_const_inforp info_ptr,
}
}
- return (retval);
+ return retval;
}
#endif /* pHYs */
@@ -1020,10 +1139,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
@@ -1037,10 +1156,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
@@ -1051,7 +1170,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)
@@ -1066,7 +1185,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
@@ -1081,10 +1200,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
@@ -1094,11 +1213,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)
@@ -1130,7 +1250,7 @@ png_get_tRNS(png_const_structrp png_ptr, png_inforp info_ptr,
}
}
- return (retval);
+ return retval;
}
#endif
@@ -1145,13 +1265,13 @@ png_get_unknown_chunks(png_const_structrp png_ptr, png_inforp info_ptr,
return info_ptr->unknown_chunks_num;
}
- return (0);
+ return 0;
}
#endif
#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED
png_byte PNGAPI
-png_get_rgb_to_gray_status (png_const_structrp png_ptr)
+png_get_rgb_to_gray_status(png_const_structrp png_ptr)
{
return (png_byte)(png_ptr ? png_ptr->rgb_to_gray_status : 0);
}
@@ -1192,27 +1312,27 @@ png_get_compression_buffer_size(png_const_structrp png_ptr)
/* These functions were added to libpng 1.2.6 and were enabled
* by default in libpng-1.4.0 */
png_uint_32 PNGAPI
-png_get_user_width_max (png_const_structrp png_ptr)
+png_get_user_width_max(png_const_structrp png_ptr)
{
return (png_ptr ? png_ptr->user_width_max : 0);
}
png_uint_32 PNGAPI
-png_get_user_height_max (png_const_structrp png_ptr)
+png_get_user_height_max(png_const_structrp png_ptr)
{
return (png_ptr ? png_ptr->user_height_max : 0);
}
/* This function was added to libpng 1.4.0 */
png_uint_32 PNGAPI
-png_get_chunk_cache_max (png_const_structrp png_ptr)
+png_get_chunk_cache_max(png_const_structrp png_ptr)
{
return (png_ptr ? png_ptr->user_chunk_cache_max : 0);
}
/* This function was added to libpng 1.4.1 */
png_alloc_size_t PNGAPI
-png_get_chunk_malloc_max (png_const_structrp png_ptr)
+png_get_chunk_malloc_max(png_const_structrp png_ptr)
{
return (png_ptr ? png_ptr->user_chunk_malloc_max : 0);
}
@@ -1221,13 +1341,13 @@ png_get_chunk_malloc_max (png_const_structrp png_ptr)
/* These functions were added to libpng 1.4.0 */
#ifdef PNG_IO_STATE_SUPPORTED
png_uint_32 PNGAPI
-png_get_io_state (png_const_structrp png_ptr)
+png_get_io_state(png_const_structrp png_ptr)
{
return png_ptr->io_state;
}
png_uint_32 PNGAPI
-png_get_io_chunk_type (png_const_structrp png_ptr)
+png_get_io_chunk_type(png_const_structrp png_ptr)
{
return png_ptr->chunk_name;
}
@@ -1241,7 +1361,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/src/libs/Irrlicht/irrlicht-svn/source/Irrlicht/libpng/pnginfo.h b/src/libs/Irrlicht/irrlicht-svn/source/Irrlicht/libpng/pnginfo.h
index dbbc35bc..d45d9427 100644
--- a/src/libs/Irrlicht/irrlicht-svn/source/Irrlicht/libpng/pnginfo.h
+++ b/src/libs/Irrlicht/irrlicht-svn/source/Irrlicht/libpng/pnginfo.h
@@ -1,7 +1,6 @@
-
-/* pnginfo.h - header file for PNG reference library
+/* pnginfo.h - internal structures for libpng
*
- * Copyright (c) 2018 Cosmin Truta
+ * Copyright (c) 2018-2025 Cosmin Truta
* Copyright (c) 1998-2002,2004,2006-2013,2018 Glenn Randers-Pehrson
* Copyright (c) 1996-1997 Andreas Dilger
* Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
@@ -11,43 +10,20 @@
* and license in png.h
*/
- /* png_info is a structure that holds the information in a PNG file so
- * that the application can find out the characteristics of the image.
- * If you are reading the file, this structure will tell you what is
- * in the PNG file. If you are writing the file, fill in the information
- * you want to put into the PNG file, using png_set_*() functions, then
- * call png_write_info().
- *
- * The names chosen should be very close to the PNG specification, so
- * consult that document for information about the meaning of each field.
- *
- * With libpng < 0.95, it was only possible to directly set and read the
- * the values in the png_info_struct, which meant that the contents and
- * order of the values had to remain fixed. With libpng 0.95 and later,
- * however, there are now functions that abstract the contents of
- * png_info_struct from the application, so this makes it easier to use
- * libpng with dynamic libraries, and even makes it possible to use
- * libraries that don't have all of the libpng ancillary chunk-handing
- * functionality. In libpng-1.5.0 this was moved into a separate private
- * file that is not visible to applications.
+#ifndef PNGPRIV_H
+# error This file must not be included by applications; please include
+#endif
+
+/* INTERNAL, PRIVATE definition of a PNG.
*
- * The following members may have allocated storage attached that should be
- * cleaned up before the structure is discarded: palette, trans, text,
- * pcal_purpose, pcal_units, pcal_params, hist, iccp_name, iccp_profile,
- * splt_palettes, scal_unit, row_pointers, and unknowns. By default, these
- * are automatically freed when the info structure is deallocated, if they were
- * allocated internally by libpng. This behavior can be changed by means
- * of the png_data_freer() function.
+ * png_info is a modifiable description of a PNG datastream. The fields inside
+ * this structure are accessed through png_get_() functions and modified
+ * using png_set_() functions.
*
- * More allocation details: all the chunk-reading functions that
- * change these members go through the corresponding png_set_*
- * functions. A function to clear these members is available: see
- * png_free_data(). The png_set_* functions do not depend on being
- * able to point info structure members to any of the storage they are
- * passed (they make their own copies), EXCEPT that the png_set_text
- * functions use the same storage passed to them in the text_ptr or
- * itxt_ptr structure argument, and the png_set_rows and png_set_unknowns
- * functions do not make their own copies.
+ * Some functions in libpng do directly access members of png_info. However,
+ * this should be avoided. png_struct objects contain members which hold
+ * caches, sometimes optimised, of the values from png_info objects, and
+ * png_info is not passed to the functions which read and write image data.
*/
#ifndef PNGINFO_H
#define PNGINFO_H
@@ -87,18 +63,12 @@ struct png_info_def
* and initialize the appropriate fields below.
*/
-#if defined(PNG_COLORSPACE_SUPPORTED) || defined(PNG_GAMMA_SUPPORTED)
- /* png_colorspace only contains 'flags' if neither GAMMA or COLORSPACE are
- * defined. When COLORSPACE is switched on all the colorspace-defining
- * chunks should be enabled, when GAMMA is switched on all the gamma-defining
- * chunks should be enabled. If this is not done it becomes possible to read
- * inconsistent PNG files and assign a probably incorrect interpretation to
- * the information. (In other words, by carefully choosing which chunks to
- * recognize the system configuration can select an interpretation for PNG
- * files containing ambiguous data and this will result in inconsistent
- * behavior between different libpng builds!)
- */
- png_colorspace colorspace;
+#ifdef PNG_cICP_SUPPORTED
+ /* cICP chunk data */
+ png_byte cicp_colour_primaries;
+ png_byte cicp_transfer_function;
+ png_byte cicp_matrix_coefficients;
+ png_byte cicp_video_full_range_flag;
#endif
#ifdef PNG_iCCP_SUPPORTED
@@ -108,6 +78,24 @@ struct png_info_def
png_uint_32 iccp_proflen; /* ICC profile data length */
#endif
+#ifdef PNG_cLLI_SUPPORTED
+ png_uint_32 maxCLL; /* cd/m2 (nits) * 10,000 */
+ png_uint_32 maxFALL;
+#endif
+
+#ifdef PNG_mDCV_SUPPORTED
+ png_uint_16 mastering_red_x; /* CIE (xy) x * 50,000 */
+ png_uint_16 mastering_red_y;
+ png_uint_16 mastering_green_x;
+ png_uint_16 mastering_green_y;
+ png_uint_16 mastering_blue_x;
+ png_uint_16 mastering_blue_y;
+ png_uint_16 mastering_white_x;
+ png_uint_16 mastering_white_y;
+ png_uint_32 mastering_maxDL; /* cd/m2 (nits) * 10,000 */
+ png_uint_32 mastering_minDL;
+#endif
+
#ifdef PNG_TEXT_SUPPORTED
/* The tEXt, and zTXt chunks contain human-readable textual data in
* uncompressed, compressed, and optionally compressed forms, respectively.
@@ -186,11 +174,8 @@ defined(PNG_READ_BACKGROUND_SUPPORTED)
#endif
#ifdef PNG_eXIf_SUPPORTED
- int num_exif; /* Added at libpng-1.6.31 */
+ png_uint_32 num_exif; /* Added at libpng-1.6.31 */
png_bytep exif;
-# ifdef PNG_READ_eXIf_SUPPORTED
- png_bytep eXIf_buf; /* Added at libpng-1.6.32 */
-# endif
#endif
#ifdef PNG_hIST_SUPPORTED
@@ -263,5 +248,16 @@ defined(PNG_READ_BACKGROUND_SUPPORTED)
png_bytepp row_pointers; /* the image bits */
#endif
+#ifdef PNG_cHRM_SUPPORTED
+ png_xy cHRM;
+#endif
+
+#ifdef PNG_gAMA_SUPPORTED
+ png_fixed_point gamma;
+#endif
+
+#ifdef PNG_sRGB_SUPPORTED
+ int rendering_intent;
+#endif
};
#endif /* PNGINFO_H */
diff --git a/src/libs/Irrlicht/irrlicht-svn/source/Irrlicht/libpng/pnglibconf.h b/src/libs/Irrlicht/irrlicht-svn/source/Irrlicht/libpng/pnglibconf.h
index e1e27e95..d627e1ea 100644
--- a/src/libs/Irrlicht/irrlicht-svn/source/Irrlicht/libpng/pnglibconf.h
+++ b/src/libs/Irrlicht/irrlicht-svn/source/Irrlicht/libpng/pnglibconf.h
@@ -1,8 +1,8 @@
/* pnglibconf.h - library build configuration */
-/* libpng version 1.6.37 */
+/* libpng version 1.6.54 */
-/* Copyright (c) 2018-2019 Cosmin Truta */
+/* Copyright (c) 2018-2026 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*/
@@ -83,11 +88,14 @@
#define PNG_READ_USER_TRANSFORM_SUPPORTED
#define PNG_READ_bKGD_SUPPORTED
#define PNG_READ_cHRM_SUPPORTED
+#define PNG_READ_cICP_SUPPORTED
+#define PNG_READ_cLLI_SUPPORTED
#define PNG_READ_eXIf_SUPPORTED
#define PNG_READ_gAMA_SUPPORTED
#define PNG_READ_hIST_SUPPORTED
#define PNG_READ_iCCP_SUPPORTED
#define PNG_READ_iTXt_SUPPORTED
+#define PNG_READ_mDCV_SUPPORTED
#define PNG_READ_oFFs_SUPPORTED
#define PNG_READ_pCAL_SUPPORTED
#define PNG_READ_pHYs_SUPPORTED
@@ -153,11 +161,14 @@
#define PNG_WRITE_WEIGHTED_FILTER_SUPPORTED
#define PNG_WRITE_bKGD_SUPPORTED
#define PNG_WRITE_cHRM_SUPPORTED
+#define PNG_WRITE_cICP_SUPPORTED
+#define PNG_WRITE_cLLI_SUPPORTED
#define PNG_WRITE_eXIf_SUPPORTED
#define PNG_WRITE_gAMA_SUPPORTED
#define PNG_WRITE_hIST_SUPPORTED
#define PNG_WRITE_iCCP_SUPPORTED
#define PNG_WRITE_iTXt_SUPPORTED
+#define PNG_WRITE_mDCV_SUPPORTED
#define PNG_WRITE_oFFs_SUPPORTED
#define PNG_WRITE_pCAL_SUPPORTED
#define PNG_WRITE_pHYs_SUPPORTED
@@ -171,11 +182,14 @@
#define PNG_WRITE_zTXt_SUPPORTED
#define PNG_bKGD_SUPPORTED
#define PNG_cHRM_SUPPORTED
+#define PNG_cICP_SUPPORTED
+#define PNG_cLLI_SUPPORTED
#define PNG_eXIf_SUPPORTED
#define PNG_gAMA_SUPPORTED
#define PNG_hIST_SUPPORTED
#define PNG_iCCP_SUPPORTED
#define PNG_iTXt_SUPPORTED
+#define PNG_mDCV_SUPPORTED
#define PNG_oFFs_SUPPORTED
#define PNG_pCAL_SUPPORTED
#define PNG_pHYs_SUPPORTED
diff --git a/src/libs/Irrlicht/irrlicht-svn/source/Irrlicht/libpng/pngmem.c b/src/libs/Irrlicht/irrlicht-svn/source/Irrlicht/libpng/pngmem.c
index 5780e764..fe559195 100644
--- a/src/libs/Irrlicht/irrlicht-svn/source/Irrlicht/libpng/pngmem.c
+++ b/src/libs/Irrlicht/irrlicht-svn/source/Irrlicht/libpng/pngmem.c
@@ -1,7 +1,6 @@
-
/* pngmem.c - stub functions for memory allocation
*
- * Copyright (c) 2018 Cosmin Truta
+ * Copyright (c) 2018-2025 Cosmin Truta
* Copyright (c) 1998-2002,2004,2006-2014,2016 Glenn Randers-Pehrson
* Copyright (c) 1996-1997 Andreas Dilger
* Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
@@ -47,7 +46,8 @@ png_destroy_png_struct(png_structrp png_ptr)
* have the ability to do that.
*/
PNG_FUNCTION(png_voidp,PNGAPI
-png_calloc,(png_const_structrp png_ptr, png_alloc_size_t size),PNG_ALLOCATED)
+png_calloc,(png_const_structrp png_ptr, png_alloc_size_t size),
+ PNG_ALLOCATED)
{
png_voidp ret;
@@ -73,30 +73,29 @@ png_malloc_base,(png_const_structrp png_ptr, png_alloc_size_t size),
* to implement a user memory handler. This checks to be sure it isn't
* called with big numbers.
*/
-#ifndef PNG_USER_MEM_SUPPORTED
- PNG_UNUSED(png_ptr)
-#endif
+# ifdef PNG_MAX_MALLOC_64K
+ /* This is support for legacy systems which had segmented addressing
+ * limiting the maximum allocation size to 65536. It takes precedence
+ * over PNG_SIZE_MAX which is set to 65535 on true 16-bit systems.
+ *
+ * TODO: libpng-1.8: finally remove both cases.
+ */
+ if (size > 65536U) return NULL;
+# endif
- /* Some compilers complain that this is always true. However, it
- * can be false when integer overflow happens.
+ /* This is checked too because the system malloc call below takes a (size_t).
*/
- if (size > 0 && size <= PNG_SIZE_MAX
-# ifdef PNG_MAX_MALLOC_64K
- && size <= 65536U
-# endif
- )
- {
-#ifdef PNG_USER_MEM_SUPPORTED
+ if (size > PNG_SIZE_MAX) return NULL;
+
+# ifdef PNG_USER_MEM_SUPPORTED
if (png_ptr != NULL && png_ptr->malloc_fn != NULL)
return png_ptr->malloc_fn(png_constcast(png_structrp,png_ptr), size);
+# else
+ PNG_UNUSED(png_ptr)
+# endif
- else
-#endif
- return malloc((size_t)size); /* checked for truncation above */
- }
-
- else
- return NULL;
+ /* Use the system malloc */
+ return malloc((size_t)/*SAFE*/size); /* checked for truncation above */
}
#if defined(PNG_TEXT_SUPPORTED) || defined(PNG_sPLT_SUPPORTED) ||\
@@ -120,7 +119,8 @@ png_malloc_array_checked(png_const_structrp png_ptr, int nelements,
PNG_FUNCTION(png_voidp /* PRIVATE */,
png_malloc_array,(png_const_structrp png_ptr, int nelements,
- size_t element_size),PNG_ALLOCATED)
+ size_t element_size),
+ PNG_ALLOCATED)
{
if (nelements <= 0 || element_size == 0)
png_error(png_ptr, "internal error: array alloc");
@@ -130,7 +130,8 @@ png_malloc_array,(png_const_structrp png_ptr, int nelements,
PNG_FUNCTION(png_voidp /* PRIVATE */,
png_realloc_array,(png_const_structrp png_ptr, png_const_voidp old_array,
- int old_elements, int add_elements, size_t element_size),PNG_ALLOCATED)
+ int old_elements, int add_elements, size_t element_size),
+ PNG_ALLOCATED)
{
/* These are internal errors: */
if (add_elements <= 0 || element_size == 0 || old_elements < 0 ||
@@ -169,7 +170,8 @@ png_realloc_array,(png_const_structrp png_ptr, png_const_voidp old_array,
* function png_malloc_default is also provided.
*/
PNG_FUNCTION(png_voidp,PNGAPI
-png_malloc,(png_const_structrp png_ptr, png_alloc_size_t size),PNG_ALLOCATED)
+png_malloc,(png_const_structrp png_ptr, png_alloc_size_t size),
+ PNG_ALLOCATED)
{
png_voidp ret;
@@ -243,7 +245,8 @@ png_free(png_const_structrp png_ptr, png_voidp ptr)
}
PNG_FUNCTION(void,PNGAPI
-png_free_default,(png_const_structrp png_ptr, png_voidp ptr),PNG_DEPRECATED)
+png_free_default,(png_const_structrp png_ptr, png_voidp ptr),
+ PNG_DEPRECATED)
{
if (png_ptr == NULL || ptr == NULL)
return;
@@ -257,8 +260,8 @@ png_free_default,(png_const_structrp png_ptr, png_voidp ptr),PNG_DEPRECATED)
* of allocating and freeing memory.
*/
void PNGAPI
-png_set_mem_fn(png_structrp png_ptr, png_voidp mem_ptr, png_malloc_ptr
- malloc_fn, png_free_ptr free_fn)
+png_set_mem_fn(png_structrp png_ptr, png_voidp mem_ptr,
+ png_malloc_ptr malloc_fn, png_free_ptr free_fn)
{
if (png_ptr != NULL)
{
diff --git a/src/libs/Irrlicht/irrlicht-svn/source/Irrlicht/libpng/pngpread.c b/src/libs/Irrlicht/irrlicht-svn/source/Irrlicht/libpng/pngpread.c
index b2306c07..5d1a4e00 100644
--- a/src/libs/Irrlicht/irrlicht-svn/source/Irrlicht/libpng/pngpread.c
+++ b/src/libs/Irrlicht/irrlicht-svn/source/Irrlicht/libpng/pngpread.c
@@ -1,7 +1,6 @@
-
/* pngpread.c - read a png file in push mode
*
- * Copyright (c) 2018 Cosmin Truta
+ * Copyright (c) 2018-2025 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.
@@ -32,6 +31,21 @@ if (png_ptr->push_length + 4 > png_ptr->buffer_size) \
if (png_ptr->buffer_size < N) \
{ png_push_save_buffer(png_ptr); return; }
+#ifdef PNG_READ_INTERLACING_SUPPORTED
+/* Arrays to facilitate interlacing - use pass (0 - 6) as index. */
+
+/* Start of interlace block */
+static const png_byte png_pass_start[7] = {0, 4, 0, 2, 0, 1, 0};
+/* Offset to next interlace block */
+static const png_byte png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1};
+/* Start of interlace block in the y direction */
+static const png_byte png_pass_ystart[7] = {0, 0, 4, 0, 2, 0, 1};
+/* Offset to next interlace block in the y direction */
+static const png_byte png_pass_yinc[7] = {8, 8, 8, 4, 4, 2, 2};
+
+/* TODO: Move these arrays to a common utility module to avoid duplication. */
+#endif
+
void PNGAPI
png_process_data(png_structrp png_ptr, png_inforp info_ptr,
png_bytep buffer, size_t buffer_size)
@@ -145,10 +159,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
@@ -179,17 +193,8 @@ png_push_read_chunk(png_structrp png_ptr, png_inforp info_ptr)
*/
if ((png_ptr->mode & PNG_HAVE_CHUNK_HEADER) == 0)
{
- png_byte chunk_length[4];
- png_byte chunk_tag[4];
-
PNG_PUSH_SAVE_BUFFER_IF_LT(8)
- png_push_fill_buffer(png_ptr, chunk_length, 4);
- png_ptr->push_length = png_get_uint_31(png_ptr, chunk_length);
- png_reset_crc(png_ptr);
- png_crc_read(png_ptr, chunk_tag, 4);
- png_ptr->chunk_name = PNG_CHUNK_FROM_STRING(chunk_tag);
- png_check_chunk_name(png_ptr, png_ptr->chunk_name);
- png_check_chunk_length(png_ptr, png_ptr->push_length);
+ png_ptr->push_length = png_read_chunk_header(png_ptr);
png_ptr->mode |= PNG_HAVE_CHUNK_HEADER;
}
@@ -224,19 +229,27 @@ png_push_read_chunk(png_structrp png_ptr, png_inforp info_ptr)
png_benign_error(png_ptr, "Too many IDATs found");
}
+ else if ((png_ptr->mode & PNG_HAVE_IDAT) != 0)
+ {
+ /* These flags must be set consistently for all non-IDAT chunks,
+ * including the unknown chunks.
+ */
+ png_ptr->mode |= PNG_HAVE_CHUNK_AFTER_IDAT | PNG_AFTER_IDAT;
+ }
+
if (chunk_name == png_IHDR)
{
if (png_ptr->push_length != 13)
png_error(png_ptr, "Invalid IHDR length");
PNG_PUSH_SAVE_BUFFER_IF_FULL
- png_handle_IHDR(png_ptr, info_ptr, png_ptr->push_length);
+ png_handle_chunk(png_ptr, info_ptr, png_ptr->push_length);
}
else if (chunk_name == png_IEND)
{
PNG_PUSH_SAVE_BUFFER_IF_FULL
- png_handle_IEND(png_ptr, info_ptr, png_ptr->push_length);
+ png_handle_chunk(png_ptr, info_ptr, png_ptr->push_length);
png_ptr->process_mode = PNG_READ_DONE_MODE;
png_push_have_end(png_ptr, info_ptr);
@@ -253,12 +266,6 @@ png_push_read_chunk(png_structrp png_ptr, png_inforp info_ptr)
}
#endif
- else if (chunk_name == png_PLTE)
- {
- PNG_PUSH_SAVE_BUFFER_IF_FULL
- png_handle_PLTE(png_ptr, info_ptr, png_ptr->push_length);
- }
-
else if (chunk_name == png_IDAT)
{
png_ptr->idat_size = png_ptr->push_length;
@@ -271,147 +278,10 @@ png_push_read_chunk(png_structrp png_ptr, png_inforp info_ptr)
return;
}
-#ifdef PNG_READ_gAMA_SUPPORTED
- else if (png_ptr->chunk_name == png_gAMA)
- {
- PNG_PUSH_SAVE_BUFFER_IF_FULL
- png_handle_gAMA(png_ptr, info_ptr, png_ptr->push_length);
- }
-
-#endif
-#ifdef PNG_READ_sBIT_SUPPORTED
- else if (png_ptr->chunk_name == png_sBIT)
- {
- PNG_PUSH_SAVE_BUFFER_IF_FULL
- png_handle_sBIT(png_ptr, info_ptr, png_ptr->push_length);
- }
-
-#endif
-#ifdef PNG_READ_cHRM_SUPPORTED
- else if (png_ptr->chunk_name == png_cHRM)
- {
- PNG_PUSH_SAVE_BUFFER_IF_FULL
- png_handle_cHRM(png_ptr, info_ptr, png_ptr->push_length);
- }
-
-#endif
-#ifdef PNG_READ_sRGB_SUPPORTED
- else if (chunk_name == png_sRGB)
- {
- PNG_PUSH_SAVE_BUFFER_IF_FULL
- png_handle_sRGB(png_ptr, info_ptr, png_ptr->push_length);
- }
-
-#endif
-#ifdef PNG_READ_iCCP_SUPPORTED
- else if (png_ptr->chunk_name == png_iCCP)
- {
- PNG_PUSH_SAVE_BUFFER_IF_FULL
- png_handle_iCCP(png_ptr, info_ptr, png_ptr->push_length);
- }
-
-#endif
-#ifdef PNG_READ_sPLT_SUPPORTED
- else if (chunk_name == png_sPLT)
- {
- PNG_PUSH_SAVE_BUFFER_IF_FULL
- png_handle_sPLT(png_ptr, info_ptr, png_ptr->push_length);
- }
-
-#endif
-#ifdef PNG_READ_tRNS_SUPPORTED
- else if (chunk_name == png_tRNS)
- {
- PNG_PUSH_SAVE_BUFFER_IF_FULL
- png_handle_tRNS(png_ptr, info_ptr, png_ptr->push_length);
- }
-
-#endif
-#ifdef PNG_READ_bKGD_SUPPORTED
- else if (chunk_name == png_bKGD)
- {
- PNG_PUSH_SAVE_BUFFER_IF_FULL
- png_handle_bKGD(png_ptr, info_ptr, png_ptr->push_length);
- }
-
-#endif
-#ifdef PNG_READ_hIST_SUPPORTED
- else if (chunk_name == png_hIST)
- {
- PNG_PUSH_SAVE_BUFFER_IF_FULL
- png_handle_hIST(png_ptr, info_ptr, png_ptr->push_length);
- }
-
-#endif
-#ifdef PNG_READ_pHYs_SUPPORTED
- else if (chunk_name == png_pHYs)
- {
- PNG_PUSH_SAVE_BUFFER_IF_FULL
- png_handle_pHYs(png_ptr, info_ptr, png_ptr->push_length);
- }
-
-#endif
-#ifdef PNG_READ_oFFs_SUPPORTED
- else if (chunk_name == png_oFFs)
- {
- PNG_PUSH_SAVE_BUFFER_IF_FULL
- png_handle_oFFs(png_ptr, info_ptr, png_ptr->push_length);
- }
-#endif
-
-#ifdef PNG_READ_pCAL_SUPPORTED
- else if (chunk_name == png_pCAL)
- {
- PNG_PUSH_SAVE_BUFFER_IF_FULL
- png_handle_pCAL(png_ptr, info_ptr, png_ptr->push_length);
- }
-
-#endif
-#ifdef PNG_READ_sCAL_SUPPORTED
- else if (chunk_name == png_sCAL)
- {
- PNG_PUSH_SAVE_BUFFER_IF_FULL
- png_handle_sCAL(png_ptr, info_ptr, png_ptr->push_length);
- }
-
-#endif
-#ifdef PNG_READ_tIME_SUPPORTED
- else if (chunk_name == png_tIME)
- {
- PNG_PUSH_SAVE_BUFFER_IF_FULL
- png_handle_tIME(png_ptr, info_ptr, png_ptr->push_length);
- }
-
-#endif
-#ifdef PNG_READ_tEXt_SUPPORTED
- else if (chunk_name == png_tEXt)
- {
- PNG_PUSH_SAVE_BUFFER_IF_FULL
- png_handle_tEXt(png_ptr, info_ptr, png_ptr->push_length);
- }
-
-#endif
-#ifdef PNG_READ_zTXt_SUPPORTED
- else if (chunk_name == png_zTXt)
- {
- PNG_PUSH_SAVE_BUFFER_IF_FULL
- png_handle_zTXt(png_ptr, info_ptr, png_ptr->push_length);
- }
-
-#endif
-#ifdef PNG_READ_iTXt_SUPPORTED
- else if (chunk_name == png_iTXt)
- {
- PNG_PUSH_SAVE_BUFFER_IF_FULL
- png_handle_iTXt(png_ptr, info_ptr, png_ptr->push_length);
- }
-#endif
-
else
{
PNG_PUSH_SAVE_BUFFER_IF_FULL
- png_handle_unknown(png_ptr, info_ptr, png_ptr->push_length,
- PNG_HANDLE_CHUNK_AS_DEFAULT);
+ png_handle_chunk(png_ptr, info_ptr, png_ptr->push_length);
}
png_ptr->mode &= ~PNG_HAVE_CHUNK_HEADER;
@@ -968,27 +838,6 @@ png_push_process_row(png_structrp png_ptr)
void /* PRIVATE */
png_read_push_finish_row(png_structrp png_ptr)
{
-#ifdef PNG_READ_INTERLACING_SUPPORTED
- /* Arrays to facilitate easy interlacing - use pass (0 - 6) as index */
-
- /* Start of interlace block */
- static const png_byte png_pass_start[] = {0, 4, 0, 2, 0, 1, 0};
-
- /* Offset to next interlace block */
- static const png_byte png_pass_inc[] = {8, 8, 4, 4, 2, 2, 1};
-
- /* Start of interlace block in the y direction */
- static const png_byte png_pass_ystart[] = {0, 0, 4, 0, 2, 0, 1};
-
- /* Offset to next interlace block in the y direction */
- static const png_byte png_pass_yinc[] = {8, 8, 8, 4, 4, 2, 2};
-
- /* Height of interlace block. This is not currently used - if you need
- * it, uncomment it here and in png.h
- static const png_byte png_pass_height[] = {8, 8, 4, 4, 2, 2, 1};
- */
-#endif
-
png_ptr->row_number++;
if (png_ptr->row_number < png_ptr->num_rows)
return;
@@ -1089,7 +938,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/src/libs/Irrlicht/irrlicht-svn/source/Irrlicht/libpng/pngpriv.h b/src/libs/Irrlicht/irrlicht-svn/source/Irrlicht/libpng/pngpriv.h
index 2a5b4234..9d775a91 100644
--- a/src/libs/Irrlicht/irrlicht-svn/source/Irrlicht/libpng/pngpriv.h
+++ b/src/libs/Irrlicht/irrlicht-svn/source/Irrlicht/libpng/pngpriv.h
@@ -1,7 +1,6 @@
-
/* pngpriv.h - private declarations for use inside libpng
*
- * Copyright (c) 2018-2019 Cosmin Truta
+ * Copyright (c) 2018-2025 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.
@@ -20,8 +19,20 @@
* they should be well aware of the issues that may arise from doing so.
*/
+
+/* pngpriv.h must be included first in each translation unit inside libpng.
+ * On the other hand, it must not be included at all, directly or indirectly,
+ * by any application code that uses the libpng API.
+ */
#ifndef PNGPRIV_H
-#define PNGPRIV_H
+# define PNGPRIV_H
+#else
+# error Duplicate inclusion of pngpriv.h; please check the libpng source files
+#endif
+
+#if defined(PNG_H) || defined(PNGCONF_H) || defined(PNGLCONF_H)
+# error This file must not be included by applications; please include
+#endif
/* Feature Test Macros. The following are defined here to ensure that correctly
* implemented libraries reveal the APIs libpng needs to build and hide those
@@ -36,7 +47,7 @@
* still required (as of 2011-05-02.)
*/
#ifndef _POSIX_SOURCE
-# define _POSIX_SOURCE 1 /* Just the POSIX 1003.1 and C89 APIs */
+# define _POSIX_SOURCE 1 /* Just the POSIX 1003.1 and C89 APIs */
#endif
#ifndef PNG_VERSION_INFO_ONLY
@@ -58,7 +69,6 @@
*/
#if defined(HAVE_CONFIG_H) && !defined(PNG_NO_CONFIG_H)
# include
-
/* Pick up the definition of 'restrict' from config.h if it was read: */
# define PNG_RESTRICT restrict
#endif
@@ -68,9 +78,7 @@
* are not internal definitions may be required. This is handled below just
* before png.h is included, but load the configuration now if it is available.
*/
-#ifndef PNGLCONF_H
-# include "pnglibconf.h"
-#endif
+#include "pnglibconf.h"
/* Local renames may change non-exported API functions from png.h */
#if defined(PNG_PREFIX) && !defined(PNGPREFIX_H)
@@ -135,66 +143,55 @@
# endif
#endif
+#ifndef PNG_RISCV_RVV_OPT
+ /* RISCV_RVV optimizations are being controlled by the compiler settings,
+ * typically the target compiler will define __riscv but the rvv extension
+ * availability has to be explicitly stated. This is why if no
+ * PNG_RISCV_RVV_OPT was defined then a runtime check will be executed.
+ *
+ * To enable RISCV_RVV optimizations unconditionally, and compile the
+ * associated code, pass --enable-riscv-rvv=yes or --enable-riscv-rvv=on
+ * to configure or put -DPNG_RISCV_RVV_OPT=2 in CPPFLAGS.
+ */
+
+# define PNG_RISCV_RVV_OPT 0
+#endif
+
#if PNG_ARM_NEON_OPT > 0
/* NEON optimizations are to be at least considered by libpng, so enable the
* callbacks to do this.
*/
# define PNG_FILTER_OPTIMIZATIONS png_init_filter_functions_neon
-
- /* By default the 'intrinsics' code in arm/filter_neon_intrinsics.c is used
- * if possible - if __ARM_NEON__ is set and the compiler version is not known
- * to be broken. This is controlled by PNG_ARM_NEON_IMPLEMENTATION which can
- * be:
- *
- * 1 The intrinsics code (the default with __ARM_NEON__)
- * 2 The hand coded assembler (the default without __ARM_NEON__)
- *
- * It is possible to set PNG_ARM_NEON_IMPLEMENTATION in CPPFLAGS, however
- * this is *NOT* supported and may cease to work even after a minor revision
- * to libpng. It *is* valid to do this for testing purposes, e.g. speed
- * testing or a new compiler, but the results should be communicated to the
- * libpng implementation list for incorporation in the next minor release.
- */
-# ifndef PNG_ARM_NEON_IMPLEMENTATION
-# if defined(__ARM_NEON__) || defined(__ARM_NEON)
-# if defined(__clang__)
- /* At present it is unknown by the libpng developers which versions
- * of clang support the intrinsics, however some or perhaps all
- * versions do not work with the assembler so this may be
- * irrelevant, so just use the default (do nothing here.)
- */
-# elif defined(__GNUC__)
- /* GCC 4.5.4 NEON support is known to be broken. 4.6.3 is known to
- * work, so if this *is* GCC, or G++, look for a version >4.5
- */
-# if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 6)
-# define PNG_ARM_NEON_IMPLEMENTATION 2
-# endif /* no GNUC support */
-# endif /* __GNUC__ */
-# else /* !defined __ARM_NEON__ */
- /* The 'intrinsics' code simply won't compile without this -mfpu=neon:
- */
-# if !defined(__aarch64__)
- /* The assembler code currently does not work on ARM64 */
-# define PNG_ARM_NEON_IMPLEMENTATION 2
-# endif /* __aarch64__ */
-# endif /* __ARM_NEON__ */
-# endif /* !PNG_ARM_NEON_IMPLEMENTATION */
-
# ifndef PNG_ARM_NEON_IMPLEMENTATION
/* Use the intrinsics code by default. */
# define PNG_ARM_NEON_IMPLEMENTATION 1
# endif
+#else /* PNG_ARM_NEON_OPT == 0 */
+# define PNG_ARM_NEON_IMPLEMENTATION 0
#endif /* PNG_ARM_NEON_OPT > 0 */
#ifndef PNG_MIPS_MSA_OPT
-# if defined(__mips_msa) && (__mips_isa_rev >= 5) && defined(PNG_ALIGNED_MEMORY_SUPPORTED)
+# if defined(__mips_msa) && (__mips_isa_rev >= 5) && \
+ defined(PNG_ALIGNED_MEMORY_SUPPORTED)
# define PNG_MIPS_MSA_OPT 2
# else
# define PNG_MIPS_MSA_OPT 0
# 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
@@ -203,13 +200,21 @@
# 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
* enable SSE optimizations. This means that these optimizations will
* be off by default. See contrib/intel for more details.
*/
-# if defined(__SSE4_1__) || defined(__AVX__) || defined(__SSSE3__) || \
+# if defined(__SSE4_1__) || defined(__AVX__) || defined(__SSSE3__) || \
defined(__SSE2__) || defined(_M_X64) || defined(_M_AMD64) || \
(defined(_M_IX86_FP) && _M_IX86_FP >= 2)
# define PNG_INTEL_SSE_OPT 1
@@ -246,7 +251,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__)
@@ -262,14 +266,51 @@
# 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
+#else
+# 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
+#if PNG_RISCV_RVV_OPT > 0 && __riscv_v >= 1000000
+# define PNG_FILTER_OPTIMIZATIONS png_init_filter_functions_rvv
+# ifndef PNG_RISCV_RVV_IMPLEMENTATION
+ /* Use the intrinsics code by default. */
+# define PNG_RISCV_RVV_IMPLEMENTATION 1
+# endif
+#else
+# define PNG_RISCV_RVV_IMPLEMENTATION 0
+#endif /* PNG_RISCV_RVV_OPT > 0 && __riscv_v >= 1000000 */
/* 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
@@ -492,16 +533,7 @@
static_cast(static_cast(value))
#else
# define png_voidcast(type, value) (value)
-# ifdef _WIN64
-# ifdef __GNUC__
- typedef unsigned long long png_ptruint;
-# else
- typedef unsigned __int64 png_ptruint;
-# endif
-# else
- typedef unsigned long png_ptruint;
-# endif
-# define png_constcast(type, value) ((type)(png_ptruint)(const void*)(value))
+# define png_constcast(type, value) ((type)(void*)(const void*)(value))
# define png_aligncast(type, value) ((void*)(value))
# define png_aligncastconst(type, value) ((const void*)(value))
#endif /* __cplusplus */
@@ -517,18 +549,8 @@
*/
# include
-# if (defined(__MWERKS__) && defined(macintosh)) || defined(applec) || \
- defined(THINK_C) || defined(__SC__) || defined(TARGET_OS_MAC)
- /* We need to check that hasn't already been included earlier
- * as it seems it doesn't agree with , yet we should really use
- * if possible.
- */
-# if !defined(__MATH_H__) && !defined(__MATH_H) && !defined(__cmath__)
-# include
-# endif
-# else
-# include
-# endif
+# include
+
# if defined(_AMIGA) && defined(__SASC) && defined(_M68881)
/* Amiga SAS/C: We must include builtin FPU functions when compiling using
* MATH=68881
@@ -543,9 +565,8 @@
# include
#endif
-#if defined(WIN32) || defined(_Windows) || defined(_WINDOWS) || \
- defined(_WIN32) || defined(__WIN32__)
-# include /* defines _WINDOWS_ macro */
+#if defined(_WIN32) || defined(__WIN32__) || defined(__NT__)
+# include
#endif
#endif /* PNG_VERSION_INFO_ONLY */
@@ -554,24 +575,20 @@
* functions that are passed far data must be model-independent.
*/
-/* Memory model/platform independent fns */
+/* Platform-independent functions */
#ifndef PNG_ABORT
-# ifdef _WINDOWS_
-# define PNG_ABORT() ExitProcess(0)
-# else
-# define PNG_ABORT() abort()
-# endif
+# define PNG_ABORT() abort()
#endif
/* These macros may need to be architecture dependent. */
-#define PNG_ALIGN_NONE 0 /* do not use data alignment */
-#define PNG_ALIGN_ALWAYS 1 /* assume unaligned accesses are OK */
+#define PNG_ALIGN_NONE 0 /* do not use data alignment */
+#define PNG_ALIGN_ALWAYS 1 /* assume unaligned accesses are OK */
#ifdef offsetof
-# define PNG_ALIGN_OFFSET 2 /* use offsetof to determine alignment */
+# define PNG_ALIGN_OFFSET 2 /* use offsetof to determine alignment */
#else
# define PNG_ALIGN_OFFSET -1 /* prevent the use of this */
#endif
-#define PNG_ALIGN_SIZE 3 /* use sizeof to determine alignment */
+#define PNG_ALIGN_SIZE 3 /* use sizeof to determine alignment */
#ifndef PNG_ALIGN_TYPE
/* Default to using aligned access optimizations and requiring alignment to a
@@ -585,26 +602,25 @@
/* This is used because in some compiler implementations non-aligned
* structure members are supported, so the offsetof approach below fails.
* Set PNG_ALIGN_SIZE=0 for compiler combinations where unaligned access
- * is good for performance. Do not do this unless you have tested the result
- * and understand it.
+ * is good for performance. Do not do this unless you have tested the
+ * result and understand it.
*/
-# define png_alignof(type) (sizeof (type))
+# define png_alignof(type) (sizeof(type))
#else
# if PNG_ALIGN_TYPE == PNG_ALIGN_OFFSET
-# define png_alignof(type) offsetof(struct{char c; type t;}, t)
+# define png_alignof(type) offsetof(struct{char c; type t;}, t)
# else
-# if PNG_ALIGN_TYPE == PNG_ALIGN_ALWAYS
-# define png_alignof(type) (1)
-# endif
- /* Else leave png_alignof undefined to prevent use thereof */
+# if PNG_ALIGN_TYPE == PNG_ALIGN_ALWAYS
+# define png_alignof(type) 1
+# endif
+ /* Else leave png_alignof undefined to prevent use thereof */
# endif
#endif
-/* This implicitly assumes alignment is always to a power of 2. */
+/* This implicitly assumes alignment is always a multiple of 2. */
#ifdef png_alignof
-# define png_isaligned(ptr, type)\
- (((type)((const char*)ptr-(const char*)0) & \
- (type)(png_alignof(type)-1)) == 0)
+# define png_isaligned(ptr, type) \
+ (((type)(size_t)((const void*)(ptr)) & (type)(png_alignof(type)-1)) == 0)
#else
# define png_isaligned(ptr, type) 0
#endif
@@ -635,7 +651,7 @@
#define PNG_BACKGROUND_IS_GRAY 0x800U
#define PNG_HAVE_PNG_SIGNATURE 0x1000U
#define PNG_HAVE_CHUNK_AFTER_IDAT 0x2000U /* Have another chunk after IDAT */
- /* 0x4000U (unused) */
+#define PNG_WROTE_eXIf 0x4000U
#define PNG_IS_READ_STRUCT 0x8000U /* Else is a write struct */
/* Flags for the transformations the PNG library does on the image data */
@@ -688,13 +704,13 @@
#define PNG_FLAG_CRC_ANCILLARY_NOWARN 0x0200U
#define PNG_FLAG_CRC_CRITICAL_USE 0x0400U
#define PNG_FLAG_CRC_CRITICAL_IGNORE 0x0800U
-#define PNG_FLAG_ASSUME_sRGB 0x1000U /* Added to libpng-1.5.4 */
+/* PNG_FLAG_ASSUME_sRGB unused 0x1000U * Added to libpng-1.5.4 */
#define PNG_FLAG_OPTIMIZE_ALPHA 0x2000U /* Added to libpng-1.5.4 */
#define PNG_FLAG_DETECT_UNINITIALIZED 0x4000U /* Added to libpng-1.5.4 */
/* #define PNG_FLAG_KEEP_UNKNOWN_CHUNKS 0x8000U */
/* #define PNG_FLAG_KEEP_UNSAFE_CHUNKS 0x10000U */
#define PNG_FLAG_LIBRARY_MISMATCH 0x20000U
-#define PNG_FLAG_STRIP_ERROR_NUMBERS 0x40000U
+ /* 0x40000U unused */
#define PNG_FLAG_STRIP_ERROR_TEXT 0x80000U
#define PNG_FLAG_BENIGN_ERRORS_WARN 0x100000U /* Added to libpng-1.4.0 */
#define PNG_FLAG_APP_WARNINGS_WARN 0x200000U /* Added to libpng-1.6.0 */
@@ -799,6 +815,8 @@
#ifdef PNG_FIXED_POINT_MACRO_SUPPORTED
#define png_fixed(png_ptr, fp, s) ((fp) <= 21474 && (fp) >= -21474 ?\
((png_fixed_point)(100000 * (fp))) : (png_fixed_error(png_ptr, s),0))
+#define png_fixed_ITU(png_ptr, fp, s) ((fp) <= 214748 && (fp) >= 0 ?\
+ ((png_uint_32)(10000 * (fp))) : (png_fixed_error(png_ptr, s),0))
#endif
/* else the corresponding function is defined below, inside the scope of the
* cplusplus test.
@@ -817,11 +835,31 @@
*
* PNG_32b correctly produces a value shifted by up to 24 bits, even on
* architectures where (int) is only 16 bits.
+ *
+ * 1.6.47: PNG_32b was made into a preprocessor evaluable macro by replacing the
+ * static_cast with a promoting binary operation using a guaranteed 32-bit
+ * (minimum) unsigned value.
*/
-#define PNG_32b(b,s) ((png_uint_32)(b) << (s))
+#define PNG_32b(b,s) (((0xFFFFFFFFU)&(b)) << (s))
#define PNG_U32(b1,b2,b3,b4) \
(PNG_32b(b1,24) | PNG_32b(b2,16) | PNG_32b(b3,8) | PNG_32b(b4,0))
+/* Chunk name validation. When using these macros all the arguments should be
+ * constants, otherwise code bloat may well occur. The macros are provided
+ * primarily for use in #if checks.
+ *
+ * PNG_32to8 produces a byte value with the right shift; used to extract the
+ * byte value from a chunk name.
+ */
+#define PNG_32to8(cn,s) (((cn) >> (s)) & 0xffU)
+#define PNG_CN_VALID_UPPER(b) ((b) >= 65 && (b) <= 90) /* upper-case ASCII */
+#define PNG_CN_VALID_ASCII(b) PNG_CN_VALID_UPPER((b) & ~32U)
+#define PNG_CHUNK_NAME_VALID(cn) (\
+ PNG_CN_VALID_ASCII(PNG_32to8(cn,24)) && /* critical, !ancillary */\
+ PNG_CN_VALID_ASCII(PNG_32to8(cn,16)) && /* public, !privately defined */\
+ PNG_CN_VALID_UPPER(PNG_32to8(cn, 8)) && /* VALID, !reserved */\
+ PNG_CN_VALID_ASCII(PNG_32to8(cn, 0)) /* data-dependent, !copy ok */)
+
/* Constants for known chunk types.
*
* MAINTAINERS: If you need to add a chunk, define the name here.
@@ -849,9 +887,14 @@
#define png_IEND PNG_U32( 73, 69, 78, 68)
#define png_IHDR PNG_U32( 73, 72, 68, 82)
#define png_PLTE PNG_U32( 80, 76, 84, 69)
+#define png_acTL PNG_U32( 97, 99, 84, 76) /* PNGv3: APNG */
#define png_bKGD PNG_U32( 98, 75, 71, 68)
#define png_cHRM PNG_U32( 99, 72, 82, 77)
+#define png_cICP PNG_U32( 99, 73, 67, 80) /* PNGv3 */
+#define png_cLLI PNG_U32( 99, 76, 76, 73) /* PNGv3 */
#define png_eXIf PNG_U32(101, 88, 73, 102) /* registered July 2017 */
+#define png_fcTL PNG_U32(102, 99, 84, 76) /* PNGv3: APNG */
+#define png_fdAT PNG_U32(102, 100, 65, 84) /* PNGv3: APNG */
#define png_fRAc PNG_U32(102, 82, 65, 99) /* registered, not defined */
#define png_gAMA PNG_U32(103, 65, 77, 65)
#define png_gIFg PNG_U32(103, 73, 70, 103)
@@ -860,6 +903,7 @@
#define png_hIST PNG_U32(104, 73, 83, 84)
#define png_iCCP PNG_U32(105, 67, 67, 80)
#define png_iTXt PNG_U32(105, 84, 88, 116)
+#define png_mDCV PNG_U32(109, 68, 67, 86) /* PNGv3 */
#define png_oFFs PNG_U32(111, 70, 70, 115)
#define png_pCAL PNG_U32(112, 67, 65, 76)
#define png_pHYs PNG_U32(112, 72, 89, 115)
@@ -900,11 +944,74 @@
#define PNG_CHUNK_RESERVED(c) (1 & ((c) >> 13))
#define PNG_CHUNK_SAFE_TO_COPY(c) (1 & ((c) >> 5))
+/* Known chunks. All supported chunks must be listed here. The macro PNG_CHUNK
+ * contains the four character ASCII name by which the chunk is identified. The
+ * macro is implemented as required to build tables or switch statements which
+ * require entries for every known chunk. The macro also contains an index
+ * value which should be in order (this is checked in png.c).
+ *
+ * Notice that "known" does not require "SUPPORTED"; tables should be built in
+ * such a way that chunks unsupported in a build require no more than the table
+ * entry (which should be small.) In particular function pointers for
+ * unsupported chunks should be NULL.
+ *
+ * At present these index values are not exported (not part of the public API)
+ * so can be changed at will. For convenience the names are in lexical sort
+ * order but with the critical chunks at the start in the order of occurence in
+ * a PNG.
+ *
+ * PNG_INFO_ values do not exist for every one of these chunk handles; for
+ * example PNG_INFO_{IDAT,IEND,tEXt,iTXt,zTXt} and possibly other chunks in the
+ * future.
+ */
+#define PNG_KNOWN_CHUNKS\
+ PNG_CHUNK(IHDR, 0)\
+ PNG_CHUNK(PLTE, 1)\
+ PNG_CHUNK(IDAT, 2)\
+ PNG_CHUNK(IEND, 3)\
+ PNG_CHUNK(acTL, 4)\
+ PNG_CHUNK(bKGD, 5)\
+ PNG_CHUNK(cHRM, 6)\
+ PNG_CHUNK(cICP, 7)\
+ PNG_CHUNK(cLLI, 8)\
+ PNG_CHUNK(eXIf, 9)\
+ PNG_CHUNK(fcTL, 10)\
+ PNG_CHUNK(fdAT, 11)\
+ PNG_CHUNK(gAMA, 12)\
+ PNG_CHUNK(hIST, 13)\
+ PNG_CHUNK(iCCP, 14)\
+ PNG_CHUNK(iTXt, 15)\
+ PNG_CHUNK(mDCV, 16)\
+ PNG_CHUNK(oFFs, 17)\
+ PNG_CHUNK(pCAL, 18)\
+ PNG_CHUNK(pHYs, 19)\
+ PNG_CHUNK(sBIT, 20)\
+ PNG_CHUNK(sCAL, 21)\
+ PNG_CHUNK(sPLT, 22)\
+ PNG_CHUNK(sRGB, 23)\
+ PNG_CHUNK(tEXt, 24)\
+ PNG_CHUNK(tIME, 25)\
+ PNG_CHUNK(tRNS, 26)\
+ PNG_CHUNK(zTXt, 27)
+
/* Gamma values (new at libpng-1.5.4): */
#define PNG_GAMMA_MAC_OLD 151724 /* Assume '1.8' is really 2.2/1.45! */
#define PNG_GAMMA_MAC_INVERSE 65909
#define PNG_GAMMA_sRGB_INVERSE 45455
+/* gamma sanity check. libpng cannot implement gamma transforms outside a
+ * certain limit because of its use of 16-bit fixed point intermediate values.
+ * Gamma values that are too large or too small will zap the 16-bit values all
+ * to 0 or 65535 resulting in an obvious 'bad' image.
+ *
+ * In libpng 1.6.0 the limits were changed from 0.07..3 to 0.01..100 to
+ * accommodate the optimal 16-bit gamma of 36 and its reciprocal.
+ *
+ * These are png_fixed_point integral values:
+ */
+#define PNG_LIB_GAMMA_MIN 1000
+#define PNG_LIB_GAMMA_MAX 10000000
+
/* Almost everything below is C specific; the #defines above can be used in
* non-C code (so long as it is C-preprocessed) the rest of this stuff cannot.
*/
@@ -917,17 +1024,15 @@
* must match that used in the build, or we must be using pnglibconf.h.prebuilt:
*/
#if PNG_ZLIB_VERNUM != 0 && PNG_ZLIB_VERNUM != ZLIB_VERNUM
-# error ZLIB_VERNUM != PNG_ZLIB_VERNUM \
- "-I (include path) error: see the notes in pngpriv.h"
- /* This means that when pnglibconf.h was built the copy of zlib.h that it
- * used is not the same as the one being used here. Because the build of
- * libpng makes decisions to use inflateInit2 and inflateReset2 based on the
- * zlib version number and because this affects handling of certain broken
- * PNG files the -I directives must match.
+# error The include path of is incorrect
+ /* When pnglibconf.h was built, the copy of zlib.h that it used was not the
+ * same as the one being used here. Considering how libpng makes decisions
+ * to use the zlib API based on the zlib version number, the -I options must
+ * match.
*
- * The most likely explanation is that you passed a -I in CFLAGS. This will
- * not work; all the preprocessor directives and in particular all the -I
- * directives must be in CPPFLAGS.
+ * A possible cause of this mismatch is that you passed an -I option in
+ * CFLAGS, which is unlikely to work. All the preprocessor options, and all
+ * the -I options in particular, should be in CPPFLAGS.
*/
#endif
@@ -968,18 +1073,19 @@ extern "C" {
*
* All of these functions must be declared with PNG_INTERNAL_FUNCTION.
*/
-
/* Zlib support */
#define PNG_UNEXPECTED_ZLIB_RETURN (-7)
-PNG_INTERNAL_FUNCTION(void, png_zstream_error,(png_structrp png_ptr, int ret),
+PNG_INTERNAL_FUNCTION(void, png_zstream_error,
+ (png_structrp png_ptr, int ret),
PNG_EMPTY);
/* Used by the zlib handling functions to ensure that z_stream::msg is always
* set before they return.
*/
#ifdef PNG_WRITE_SUPPORTED
-PNG_INTERNAL_FUNCTION(void,png_free_buffer_list,(png_structrp png_ptr,
- png_compression_bufferp *list),PNG_EMPTY);
+PNG_INTERNAL_FUNCTION(void, png_free_buffer_list,
+ (png_structrp png_ptr, png_compression_bufferp *list),
+ PNG_EMPTY);
/* Free the buffer list used by the compressed write code. */
#endif
@@ -987,41 +1093,75 @@ PNG_INTERNAL_FUNCTION(void,png_free_buffer_list,(png_structrp png_ptr,
!defined(PNG_FIXED_POINT_MACRO_SUPPORTED) && \
(defined(PNG_gAMA_SUPPORTED) || defined(PNG_cHRM_SUPPORTED) || \
defined(PNG_sCAL_SUPPORTED) || defined(PNG_READ_BACKGROUND_SUPPORTED) || \
+ defined(PNG_mDCV_SUPPORTED) || \
defined(PNG_READ_RGB_TO_GRAY_SUPPORTED)) || \
(defined(PNG_sCAL_SUPPORTED) && \
defined(PNG_FLOATING_ARITHMETIC_SUPPORTED))
-PNG_INTERNAL_FUNCTION(png_fixed_point,png_fixed,(png_const_structrp png_ptr,
- double fp, png_const_charp text),PNG_EMPTY);
+PNG_INTERNAL_FUNCTION(png_fixed_point, png_fixed,
+ (png_const_structrp png_ptr, double fp, png_const_charp text),
+ PNG_EMPTY);
+#endif
+
+#if defined(PNG_FLOATING_POINT_SUPPORTED) && \
+ !defined(PNG_FIXED_POINT_MACRO_SUPPORTED) && \
+ (defined(PNG_cLLI_SUPPORTED) || defined(PNG_mDCV_SUPPORTED))
+PNG_INTERNAL_FUNCTION(png_uint_32, png_fixed_ITU,
+ (png_const_structrp png_ptr, double fp, png_const_charp text),
+ PNG_EMPTY);
#endif
/* Check the user version string for compatibility, returns false if the version
* numbers aren't compatible.
*/
-PNG_INTERNAL_FUNCTION(int,png_user_version_check,(png_structrp png_ptr,
- png_const_charp user_png_ver),PNG_EMPTY);
+PNG_INTERNAL_FUNCTION(int, png_user_version_check,
+ (png_structrp png_ptr, png_const_charp user_png_ver),
+ PNG_EMPTY);
+
+#ifdef PNG_READ_SUPPORTED /* should only be used on read */
+/* Security: read limits on the largest allocations while reading a PNG. This
+ * avoids very large allocations caused by PNG files with damaged or altered
+ * chunk 'length' fields.
+ */
+#ifdef PNG_SET_USER_LIMITS_SUPPORTED /* run-time limit */
+# define png_chunk_max(png_ptr) ((png_ptr)->user_chunk_malloc_max)
+
+#elif PNG_USER_CHUNK_MALLOC_MAX > 0 /* compile-time limit */
+# define png_chunk_max(png_ptr) ((void)png_ptr, PNG_USER_CHUNK_MALLOC_MAX)
+
+#elif (defined PNG_MAX_MALLOC_64K) /* legacy system limit */
+# define png_chunk_max(png_ptr) ((void)png_ptr, 65536U)
+
+#else /* modern system limit SIZE_MAX (C99) */
+# define png_chunk_max(png_ptr) ((void)png_ptr, PNG_SIZE_MAX)
+#endif
+#endif /* READ */
/* Internal base allocator - no messages, NULL on failure to allocate. This
* does, however, call the application provided allocator and that could call
* png_error (although that would be a bug in the application implementation.)
*/
-PNG_INTERNAL_FUNCTION(png_voidp,png_malloc_base,(png_const_structrp png_ptr,
- png_alloc_size_t size),PNG_ALLOCATED);
+PNG_INTERNAL_FUNCTION(png_voidp, png_malloc_base,
+ (png_const_structrp png_ptr, png_alloc_size_t size),
+ PNG_ALLOCATED);
#if defined(PNG_TEXT_SUPPORTED) || defined(PNG_sPLT_SUPPORTED) ||\
defined(PNG_STORE_UNKNOWN_CHUNKS_SUPPORTED)
/* Internal array allocator, outputs no error or warning messages on failure,
* just returns NULL.
*/
-PNG_INTERNAL_FUNCTION(png_voidp,png_malloc_array,(png_const_structrp png_ptr,
- int nelements, size_t element_size),PNG_ALLOCATED);
+PNG_INTERNAL_FUNCTION(png_voidp, png_malloc_array,
+ (png_const_structrp png_ptr, int nelements, size_t element_size),
+ PNG_ALLOCATED);
/* The same but an existing array is extended by add_elements. This function
* also memsets the new elements to 0 and copies the old elements. The old
* array is not freed or altered.
*/
-PNG_INTERNAL_FUNCTION(png_voidp,png_realloc_array,(png_const_structrp png_ptr,
- png_const_voidp array, int old_elements, int add_elements,
- size_t element_size),PNG_ALLOCATED);
+PNG_INTERNAL_FUNCTION(png_voidp, png_realloc_array,
+ (png_const_structrp png_ptr,
+ png_const_voidp array, int old_elements, int add_elements,
+ size_t element_size),
+ PNG_ALLOCATED);
#endif /* text, sPLT or unknown chunks */
/* Magic to create a struct when there is no struct to call the user supplied
@@ -1030,87 +1170,106 @@ PNG_INTERNAL_FUNCTION(png_voidp,png_realloc_array,(png_const_structrp png_ptr,
* restriction so libpng has to assume that the 'free' handler, at least, might
* call png_error.
*/
-PNG_INTERNAL_FUNCTION(png_structp,png_create_png_struct,
- (png_const_charp user_png_ver, png_voidp error_ptr, png_error_ptr error_fn,
- png_error_ptr warn_fn, png_voidp mem_ptr, png_malloc_ptr malloc_fn,
- png_free_ptr free_fn),PNG_ALLOCATED);
+PNG_INTERNAL_FUNCTION(png_structp, png_create_png_struct,
+ (png_const_charp user_png_ver,
+ png_voidp error_ptr, png_error_ptr error_fn, png_error_ptr warn_fn,
+ png_voidp mem_ptr, png_malloc_ptr malloc_fn, png_free_ptr free_fn),
+ PNG_ALLOCATED);
/* Free memory from internal libpng struct */
-PNG_INTERNAL_FUNCTION(void,png_destroy_png_struct,(png_structrp png_ptr),
+PNG_INTERNAL_FUNCTION(void, png_destroy_png_struct,
+ (png_structrp png_ptr),
PNG_EMPTY);
/* Free an allocated jmp_buf (always succeeds) */
-PNG_INTERNAL_FUNCTION(void,png_free_jmpbuf,(png_structrp png_ptr),PNG_EMPTY);
+PNG_INTERNAL_FUNCTION(void, png_free_jmpbuf,
+ (png_structrp png_ptr),
+ PNG_EMPTY);
/* Function to allocate memory for zlib. PNGAPI is disallowed. */
-PNG_INTERNAL_FUNCTION(voidpf,png_zalloc,(voidpf png_ptr, uInt items, uInt size),
+PNG_INTERNAL_FUNCTION(voidpf, png_zalloc,
+ (voidpf png_ptr, uInt items, uInt size),
PNG_ALLOCATED);
/* Function to free memory for zlib. PNGAPI is disallowed. */
-PNG_INTERNAL_FUNCTION(void,png_zfree,(voidpf png_ptr, voidpf ptr),PNG_EMPTY);
+PNG_INTERNAL_FUNCTION(void, png_zfree,
+ (voidpf png_ptr, voidpf ptr),
+ PNG_EMPTY);
/* Next four functions are used internally as callbacks. PNGCBAPI is required
* but not PNG_EXPORT. PNGAPI added at libpng version 1.2.3, changed to
* PNGCBAPI at 1.5.0
*/
-PNG_INTERNAL_FUNCTION(void PNGCBAPI,png_default_read_data,(png_structp png_ptr,
- png_bytep data, size_t length),PNG_EMPTY);
+PNG_INTERNAL_FUNCTION(void PNGCBAPI, png_default_read_data,
+ (png_structp png_ptr, png_bytep data, size_t length),
+ PNG_EMPTY);
#ifdef PNG_PROGRESSIVE_READ_SUPPORTED
-PNG_INTERNAL_FUNCTION(void PNGCBAPI,png_push_fill_buffer,(png_structp png_ptr,
- png_bytep buffer, size_t length),PNG_EMPTY);
+PNG_INTERNAL_FUNCTION(void PNGCBAPI, png_push_fill_buffer,
+ (png_structp png_ptr, png_bytep buffer, size_t length),
+ PNG_EMPTY);
#endif
-PNG_INTERNAL_FUNCTION(void PNGCBAPI,png_default_write_data,(png_structp png_ptr,
- png_bytep data, size_t length),PNG_EMPTY);
+PNG_INTERNAL_FUNCTION(void PNGCBAPI, png_default_write_data,
+ (png_structp png_ptr, png_bytep data, size_t length),
+ PNG_EMPTY);
#ifdef PNG_WRITE_FLUSH_SUPPORTED
# ifdef PNG_STDIO_SUPPORTED
-PNG_INTERNAL_FUNCTION(void PNGCBAPI,png_default_flush,(png_structp png_ptr),
+PNG_INTERNAL_FUNCTION(void PNGCBAPI, png_default_flush,
+ (png_structp png_ptr),
PNG_EMPTY);
# endif
#endif
/* Reset the CRC variable */
-PNG_INTERNAL_FUNCTION(void,png_reset_crc,(png_structrp png_ptr),PNG_EMPTY);
+PNG_INTERNAL_FUNCTION(void, png_reset_crc,
+ (png_structrp png_ptr),
+ PNG_EMPTY);
/* Write the "data" buffer to whatever output you are using */
-PNG_INTERNAL_FUNCTION(void,png_write_data,(png_structrp png_ptr,
- png_const_bytep data, size_t length),PNG_EMPTY);
+PNG_INTERNAL_FUNCTION(void, png_write_data,
+ (png_structrp png_ptr, png_const_bytep data, size_t length),
+ PNG_EMPTY);
/* Read and check the PNG file signature */
-PNG_INTERNAL_FUNCTION(void,png_read_sig,(png_structrp png_ptr,
- png_inforp info_ptr),PNG_EMPTY);
+PNG_INTERNAL_FUNCTION(void, png_read_sig,
+ (png_structrp png_ptr, png_inforp info_ptr),
+ PNG_EMPTY);
/* Read the chunk header (length + type name) */
-PNG_INTERNAL_FUNCTION(png_uint_32,png_read_chunk_header,(png_structrp png_ptr),
+PNG_INTERNAL_FUNCTION(png_uint_32, png_read_chunk_header,
+ (png_structrp png_ptr),
PNG_EMPTY);
/* Read data from whatever input you are using into the "data" buffer */
-PNG_INTERNAL_FUNCTION(void,png_read_data,(png_structrp png_ptr, png_bytep data,
- size_t length),PNG_EMPTY);
+PNG_INTERNAL_FUNCTION(void, png_read_data,
+ (png_structrp png_ptr, png_bytep data, size_t length),
+ PNG_EMPTY);
/* Read bytes into buf, and update png_ptr->crc */
-PNG_INTERNAL_FUNCTION(void,png_crc_read,(png_structrp png_ptr, png_bytep buf,
- png_uint_32 length),PNG_EMPTY);
+PNG_INTERNAL_FUNCTION(void, png_crc_read,
+ (png_structrp png_ptr, png_bytep buf, png_uint_32 length),
+ PNG_EMPTY);
/* Read "skip" bytes, read the file crc, and (optionally) verify png_ptr->crc */
-PNG_INTERNAL_FUNCTION(int,png_crc_finish,(png_structrp png_ptr,
- png_uint_32 skip),PNG_EMPTY);
-
-/* Read the CRC from the file and compare it to the libpng calculated CRC */
-PNG_INTERNAL_FUNCTION(int,png_crc_error,(png_structrp png_ptr),PNG_EMPTY);
+PNG_INTERNAL_FUNCTION(int, png_crc_finish,
+ (png_structrp png_ptr, png_uint_32 skip),
+ PNG_EMPTY);
/* Calculate the CRC over a section of data. Note that we are only
* passing a maximum of 64K on systems that have this as a memory limit,
* since this is the maximum buffer size we can specify.
*/
-PNG_INTERNAL_FUNCTION(void,png_calculate_crc,(png_structrp png_ptr,
- png_const_bytep ptr, size_t length),PNG_EMPTY);
+PNG_INTERNAL_FUNCTION(void, png_calculate_crc,
+ (png_structrp png_ptr, png_const_bytep ptr, size_t length),
+ PNG_EMPTY);
#ifdef PNG_WRITE_FLUSH_SUPPORTED
-PNG_INTERNAL_FUNCTION(void,png_flush,(png_structrp png_ptr),PNG_EMPTY);
+PNG_INTERNAL_FUNCTION(void, png_flush,
+ (png_structrp png_ptr),
+ PNG_EMPTY);
#endif
/* Write various chunks */
@@ -1118,131 +1277,193 @@ PNG_INTERNAL_FUNCTION(void,png_flush,(png_structrp png_ptr),PNG_EMPTY);
/* Write the IHDR chunk, and update the png_struct with the necessary
* information.
*/
-PNG_INTERNAL_FUNCTION(void,png_write_IHDR,(png_structrp png_ptr,
- png_uint_32 width, png_uint_32 height, int bit_depth, int color_type,
- int compression_method, int filter_method, int interlace_method),PNG_EMPTY);
+PNG_INTERNAL_FUNCTION(void, png_write_IHDR,
+ (png_structrp png_ptr,
+ png_uint_32 width, png_uint_32 height, int bit_depth, int color_type,
+ int compression_method, int filter_method, int interlace_method),
+ PNG_EMPTY);
-PNG_INTERNAL_FUNCTION(void,png_write_PLTE,(png_structrp png_ptr,
- png_const_colorp palette, png_uint_32 num_pal),PNG_EMPTY);
+PNG_INTERNAL_FUNCTION(void, png_write_PLTE,
+ (png_structrp png_ptr,
+ png_const_colorp palette, png_uint_32 num_pal),
+ PNG_EMPTY);
-PNG_INTERNAL_FUNCTION(void,png_compress_IDAT,(png_structrp png_ptr,
- png_const_bytep row_data, png_alloc_size_t row_data_length, int flush),
+PNG_INTERNAL_FUNCTION(void, png_compress_IDAT,
+ (png_structrp png_ptr,
+ png_const_bytep row_data, png_alloc_size_t row_data_length, int flush),
PNG_EMPTY);
-PNG_INTERNAL_FUNCTION(void,png_write_IEND,(png_structrp png_ptr),PNG_EMPTY);
+PNG_INTERNAL_FUNCTION(void, png_write_IEND,
+ (png_structrp png_ptr),
+ PNG_EMPTY);
#ifdef PNG_WRITE_gAMA_SUPPORTED
-PNG_INTERNAL_FUNCTION(void,png_write_gAMA_fixed,(png_structrp png_ptr,
- png_fixed_point file_gamma),PNG_EMPTY);
+PNG_INTERNAL_FUNCTION(void, png_write_gAMA_fixed,
+ (png_structrp png_ptr, png_fixed_point file_gamma),
+ PNG_EMPTY);
#endif
#ifdef PNG_WRITE_sBIT_SUPPORTED
-PNG_INTERNAL_FUNCTION(void,png_write_sBIT,(png_structrp png_ptr,
- png_const_color_8p sbit, int color_type),PNG_EMPTY);
+PNG_INTERNAL_FUNCTION(void, png_write_sBIT,
+ (png_structrp png_ptr, png_const_color_8p sbit, int color_type),
+ PNG_EMPTY);
#endif
#ifdef PNG_WRITE_cHRM_SUPPORTED
-PNG_INTERNAL_FUNCTION(void,png_write_cHRM_fixed,(png_structrp png_ptr,
- const png_xy *xy), PNG_EMPTY);
+PNG_INTERNAL_FUNCTION(void, png_write_cHRM_fixed,
+ (png_structrp png_ptr, const png_xy *xy),
+ PNG_EMPTY);
/* The xy value must have been previously validated */
#endif
+#ifdef PNG_WRITE_cICP_SUPPORTED
+PNG_INTERNAL_FUNCTION(void, png_write_cICP,
+ (png_structrp png_ptr,
+ png_byte colour_primaries, png_byte transfer_function,
+ png_byte matrix_coefficients, png_byte video_full_range_flag),
+ PNG_EMPTY);
+#endif
+
+#ifdef PNG_WRITE_cLLI_SUPPORTED
+PNG_INTERNAL_FUNCTION(void, png_write_cLLI_fixed,
+ (png_structrp png_ptr, png_uint_32 maxCLL, png_uint_32 maxFALL),
+ PNG_EMPTY);
+#endif
+
+#ifdef PNG_WRITE_mDCV_SUPPORTED
+PNG_INTERNAL_FUNCTION(void, png_write_mDCV_fixed,
+ (png_structrp png_ptr,
+ png_uint_16 red_x, png_uint_16 red_y,
+ png_uint_16 green_x, png_uint_16 green_y,
+ png_uint_16 blue_x, png_uint_16 blue_y,
+ png_uint_16 white_x, png_uint_16 white_y,
+ png_uint_32 maxDL, png_uint_32 minDL),
+ PNG_EMPTY);
+#endif
+
#ifdef PNG_WRITE_sRGB_SUPPORTED
-PNG_INTERNAL_FUNCTION(void,png_write_sRGB,(png_structrp png_ptr,
- int intent),PNG_EMPTY);
+PNG_INTERNAL_FUNCTION(void, png_write_sRGB,
+ (png_structrp png_ptr, int intent),
+ PNG_EMPTY);
#endif
#ifdef PNG_WRITE_eXIf_SUPPORTED
-PNG_INTERNAL_FUNCTION(void,png_write_eXIf,(png_structrp png_ptr,
- png_bytep exif, int num_exif),PNG_EMPTY);
+PNG_INTERNAL_FUNCTION(void, png_write_eXIf,
+ (png_structrp png_ptr, png_bytep exif, int num_exif),
+ PNG_EMPTY);
#endif
#ifdef PNG_WRITE_iCCP_SUPPORTED
-PNG_INTERNAL_FUNCTION(void,png_write_iCCP,(png_structrp png_ptr,
- png_const_charp name, png_const_bytep profile), PNG_EMPTY);
- /* The profile must have been previously validated for correctness, the
- * length comes from the first four bytes. Only the base, deflate,
- * compression is supported.
+PNG_INTERNAL_FUNCTION(void, png_write_iCCP,
+ (png_structrp png_ptr,
+ png_const_charp name, png_const_bytep profile, png_uint_32 proflen),
+ PNG_EMPTY);
+ /* Writes a previously 'set' profile. The profile argument is **not**
+ * compressed.
*/
#endif
#ifdef PNG_WRITE_sPLT_SUPPORTED
-PNG_INTERNAL_FUNCTION(void,png_write_sPLT,(png_structrp png_ptr,
- png_const_sPLT_tp palette),PNG_EMPTY);
+PNG_INTERNAL_FUNCTION(void, png_write_sPLT,
+ (png_structrp png_ptr, png_const_sPLT_tp palette),
+ PNG_EMPTY);
#endif
#ifdef PNG_WRITE_tRNS_SUPPORTED
-PNG_INTERNAL_FUNCTION(void,png_write_tRNS,(png_structrp png_ptr,
+PNG_INTERNAL_FUNCTION(void, png_write_tRNS,
+ (png_structrp png_ptr,
png_const_bytep trans, png_const_color_16p values, int number,
- int color_type),PNG_EMPTY);
+ int color_type),
+ PNG_EMPTY);
#endif
#ifdef PNG_WRITE_bKGD_SUPPORTED
-PNG_INTERNAL_FUNCTION(void,png_write_bKGD,(png_structrp png_ptr,
- png_const_color_16p values, int color_type),PNG_EMPTY);
+PNG_INTERNAL_FUNCTION(void, png_write_bKGD,
+ (png_structrp png_ptr, png_const_color_16p values, int color_type),
+ PNG_EMPTY);
#endif
#ifdef PNG_WRITE_hIST_SUPPORTED
-PNG_INTERNAL_FUNCTION(void,png_write_hIST,(png_structrp png_ptr,
- png_const_uint_16p hist, int num_hist),PNG_EMPTY);
+PNG_INTERNAL_FUNCTION(void, png_write_hIST,
+ (png_structrp png_ptr, png_const_uint_16p hist, int num_hist),
+ PNG_EMPTY);
#endif
/* Chunks that have keywords */
#ifdef PNG_WRITE_tEXt_SUPPORTED
-PNG_INTERNAL_FUNCTION(void,png_write_tEXt,(png_structrp png_ptr,
- png_const_charp key, png_const_charp text, size_t text_len),PNG_EMPTY);
+PNG_INTERNAL_FUNCTION(void, png_write_tEXt,
+ (png_structrp png_ptr,
+ png_const_charp key, png_const_charp text, size_t text_len),
+ PNG_EMPTY);
#endif
#ifdef PNG_WRITE_zTXt_SUPPORTED
-PNG_INTERNAL_FUNCTION(void,png_write_zTXt,(png_structrp png_ptr, png_const_charp
- key, png_const_charp text, int compression),PNG_EMPTY);
+PNG_INTERNAL_FUNCTION(void, png_write_zTXt,
+ (png_structrp png_ptr,
+ png_const_charp key, png_const_charp text, int compression),
+ PNG_EMPTY);
#endif
#ifdef PNG_WRITE_iTXt_SUPPORTED
-PNG_INTERNAL_FUNCTION(void,png_write_iTXt,(png_structrp png_ptr,
+PNG_INTERNAL_FUNCTION(void, png_write_iTXt,
+ (png_structrp png_ptr,
int compression, png_const_charp key, png_const_charp lang,
- png_const_charp lang_key, png_const_charp text),PNG_EMPTY);
+ png_const_charp lang_key, png_const_charp text),
+ PNG_EMPTY);
#endif
#ifdef PNG_TEXT_SUPPORTED /* Added at version 1.0.14 and 1.2.4 */
-PNG_INTERNAL_FUNCTION(int,png_set_text_2,(png_const_structrp png_ptr,
- png_inforp info_ptr, png_const_textp text_ptr, int num_text),PNG_EMPTY);
+PNG_INTERNAL_FUNCTION(int, png_set_text_2,
+ (png_const_structrp png_ptr,
+ png_inforp info_ptr, png_const_textp text_ptr, int num_text),
+ PNG_EMPTY);
#endif
#ifdef PNG_WRITE_oFFs_SUPPORTED
-PNG_INTERNAL_FUNCTION(void,png_write_oFFs,(png_structrp png_ptr,
- png_int_32 x_offset, png_int_32 y_offset, int unit_type),PNG_EMPTY);
+PNG_INTERNAL_FUNCTION(void, png_write_oFFs,
+ (png_structrp png_ptr,
+ png_int_32 x_offset, png_int_32 y_offset, int unit_type),
+ PNG_EMPTY);
#endif
#ifdef PNG_WRITE_pCAL_SUPPORTED
-PNG_INTERNAL_FUNCTION(void,png_write_pCAL,(png_structrp png_ptr,
- png_charp purpose, png_int_32 X0, png_int_32 X1, int type, int nparams,
- png_const_charp units, png_charpp params),PNG_EMPTY);
+PNG_INTERNAL_FUNCTION(void, png_write_pCAL,
+ (png_structrp png_ptr,
+ png_charp purpose, png_int_32 X0, png_int_32 X1,
+ int type, int nparams, png_const_charp units, png_charpp params),
+ PNG_EMPTY);
#endif
#ifdef PNG_WRITE_pHYs_SUPPORTED
-PNG_INTERNAL_FUNCTION(void,png_write_pHYs,(png_structrp png_ptr,
+PNG_INTERNAL_FUNCTION(void, png_write_pHYs,
+ (png_structrp png_ptr,
png_uint_32 x_pixels_per_unit, png_uint_32 y_pixels_per_unit,
- int unit_type),PNG_EMPTY);
+ int unit_type),
+ PNG_EMPTY);
#endif
#ifdef PNG_WRITE_tIME_SUPPORTED
-PNG_INTERNAL_FUNCTION(void,png_write_tIME,(png_structrp png_ptr,
- png_const_timep mod_time),PNG_EMPTY);
+PNG_INTERNAL_FUNCTION(void, png_write_tIME,
+ (png_structrp png_ptr, png_const_timep mod_time),
+ PNG_EMPTY);
#endif
#ifdef PNG_WRITE_sCAL_SUPPORTED
-PNG_INTERNAL_FUNCTION(void,png_write_sCAL_s,(png_structrp png_ptr,
- int unit, png_const_charp width, png_const_charp height),PNG_EMPTY);
+PNG_INTERNAL_FUNCTION(void, png_write_sCAL_s,
+ (png_structrp png_ptr,
+ int unit, png_const_charp width, png_const_charp height),
+ PNG_EMPTY);
#endif
/* Called when finished processing a row of data */
-PNG_INTERNAL_FUNCTION(void,png_write_finish_row,(png_structrp png_ptr),
- PNG_EMPTY);
+PNG_INTERNAL_FUNCTION(void, png_write_finish_row,
+ (png_structrp png_ptr),
+ PNG_EMPTY);
/* Internal use only. Called before first row of data */
-PNG_INTERNAL_FUNCTION(void,png_write_start_row,(png_structrp png_ptr),
- PNG_EMPTY);
+PNG_INTERNAL_FUNCTION(void, png_write_start_row,
+ (png_structrp png_ptr),
+ PNG_EMPTY);
/* Combine a row of data, dealing with alpha, etc. if requested. 'row' is an
* array of png_ptr->width pixels. If the image is not interlaced or this
@@ -1270,8 +1491,9 @@ PNG_INTERNAL_FUNCTION(void,png_write_start_row,(png_structrp png_ptr),
#ifndef PNG_USE_COMPILE_TIME_MASKS
# define PNG_USE_COMPILE_TIME_MASKS 1
#endif
-PNG_INTERNAL_FUNCTION(void,png_combine_row,(png_const_structrp png_ptr,
- png_bytep row, int display),PNG_EMPTY);
+PNG_INTERNAL_FUNCTION(void, png_combine_row,
+ (png_const_structrp png_ptr, png_bytep row, int display),
+ PNG_EMPTY);
#ifdef PNG_READ_INTERLACING_SUPPORTED
/* Expand an interlaced row: the 'row_info' describes the pass data that has
@@ -1280,119 +1502,230 @@ PNG_INTERNAL_FUNCTION(void,png_combine_row,(png_const_structrp png_ptr,
* the pixels are *replicated* to the intervening space. This is essential for
* the correct operation of png_combine_row, above.
*/
-PNG_INTERNAL_FUNCTION(void,png_do_read_interlace,(png_row_infop row_info,
- png_bytep row, int pass, png_uint_32 transformations),PNG_EMPTY);
+PNG_INTERNAL_FUNCTION(void, png_do_read_interlace,
+ (png_row_infop row_info,
+ png_bytep row, int pass, png_uint_32 transformations),
+ PNG_EMPTY);
#endif
/* GRR TO DO (2.0 or whenever): simplify other internal calling interfaces */
#ifdef PNG_WRITE_INTERLACING_SUPPORTED
/* Grab pixels out of a row for an interlaced pass */
-PNG_INTERNAL_FUNCTION(void,png_do_write_interlace,(png_row_infop row_info,
- png_bytep row, int pass),PNG_EMPTY);
+PNG_INTERNAL_FUNCTION(void, png_do_write_interlace,
+ (png_row_infop row_info, png_bytep row, int pass),
+ PNG_EMPTY);
#endif
/* Unfilter a row: check the filter value before calling this, there is no point
* calling it for PNG_FILTER_VALUE_NONE.
*/
-PNG_INTERNAL_FUNCTION(void,png_read_filter_row,(png_structrp pp, png_row_infop
- row_info, png_bytep row, png_const_bytep prev_row, int filter),PNG_EMPTY);
+PNG_INTERNAL_FUNCTION(void, png_read_filter_row,
+ (png_structrp pp, png_row_infop row_info,
+ png_bytep row, png_const_bytep prev_row, int filter),
+ PNG_EMPTY);
#if PNG_ARM_NEON_OPT > 0
-PNG_INTERNAL_FUNCTION(void,png_read_filter_row_up_neon,(png_row_infop row_info,
- png_bytep row, png_const_bytep prev_row),PNG_EMPTY);
-PNG_INTERNAL_FUNCTION(void,png_read_filter_row_sub3_neon,(png_row_infop
- row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);
-PNG_INTERNAL_FUNCTION(void,png_read_filter_row_sub4_neon,(png_row_infop
- row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);
-PNG_INTERNAL_FUNCTION(void,png_read_filter_row_avg3_neon,(png_row_infop
- row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);
-PNG_INTERNAL_FUNCTION(void,png_read_filter_row_avg4_neon,(png_row_infop
- row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);
-PNG_INTERNAL_FUNCTION(void,png_read_filter_row_paeth3_neon,(png_row_infop
- row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);
-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);
+PNG_INTERNAL_FUNCTION(void, png_read_filter_row_up_neon,
+ (png_row_infop row_info, png_bytep row, png_const_bytep prev_row),
+ PNG_EMPTY);
+PNG_INTERNAL_FUNCTION(void, png_read_filter_row_sub3_neon,
+ (png_row_infop row_info, png_bytep row, png_const_bytep prev_row),
+ PNG_EMPTY);
+PNG_INTERNAL_FUNCTION(void, png_read_filter_row_sub4_neon,
+ (png_row_infop row_info, png_bytep row, png_const_bytep prev_row),
+ PNG_EMPTY);
+PNG_INTERNAL_FUNCTION(void, png_read_filter_row_avg3_neon,
+ (png_row_infop row_info, png_bytep row, png_const_bytep prev_row),
+ PNG_EMPTY);
+PNG_INTERNAL_FUNCTION(void, png_read_filter_row_avg4_neon,
+ (png_row_infop row_info, png_bytep row, png_const_bytep prev_row),
+ PNG_EMPTY);
+PNG_INTERNAL_FUNCTION(void, png_read_filter_row_paeth3_neon,
+ (png_row_infop row_info, png_bytep row, png_const_bytep prev_row),
+ PNG_EMPTY);
+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
-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
- row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);
-PNG_INTERNAL_FUNCTION(void,png_read_filter_row_sub4_msa,(png_row_infop
- row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);
-PNG_INTERNAL_FUNCTION(void,png_read_filter_row_avg3_msa,(png_row_infop
- row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);
-PNG_INTERNAL_FUNCTION(void,png_read_filter_row_avg4_msa,(png_row_infop
- row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);
-PNG_INTERNAL_FUNCTION(void,png_read_filter_row_paeth3_msa,(png_row_infop
- row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);
-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);
+#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 row_info, png_bytep row, png_const_bytep prev_row),
+ PNG_EMPTY);
+PNG_INTERNAL_FUNCTION(void, png_read_filter_row_sub4_msa,
+ (png_row_infop row_info, png_bytep row, png_const_bytep prev_row),
+ PNG_EMPTY);
+PNG_INTERNAL_FUNCTION(void, png_read_filter_row_avg3_msa,
+ (png_row_infop row_info, png_bytep row, png_const_bytep prev_row),
+ PNG_EMPTY);
+PNG_INTERNAL_FUNCTION(void, png_read_filter_row_avg4_msa,
+ (png_row_infop row_info, png_bytep row, png_const_bytep prev_row),
+ PNG_EMPTY);
+PNG_INTERNAL_FUNCTION(void, png_read_filter_row_paeth3_msa,
+ (png_row_infop row_info, png_bytep row, png_const_bytep prev_row),
+ PNG_EMPTY);
+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);
-PNG_INTERNAL_FUNCTION(void,png_read_filter_row_sub3_vsx,(png_row_infop
- row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);
-PNG_INTERNAL_FUNCTION(void,png_read_filter_row_sub4_vsx,(png_row_infop
- row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);
-PNG_INTERNAL_FUNCTION(void,png_read_filter_row_avg3_vsx,(png_row_infop
- row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);
-PNG_INTERNAL_FUNCTION(void,png_read_filter_row_avg4_vsx,(png_row_infop
- row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);
-PNG_INTERNAL_FUNCTION(void,png_read_filter_row_paeth3_vsx,(png_row_infop
- row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);
-PNG_INTERNAL_FUNCTION(void,png_read_filter_row_paeth4_vsx,(png_row_infop
- row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);
+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);
+PNG_INTERNAL_FUNCTION(void, png_read_filter_row_sub3_vsx,
+ (png_row_infop row_info, png_bytep row, png_const_bytep prev_row),
+ PNG_EMPTY);
+PNG_INTERNAL_FUNCTION(void, png_read_filter_row_sub4_vsx,
+ (png_row_infop row_info, png_bytep row, png_const_bytep prev_row),
+ PNG_EMPTY);
+PNG_INTERNAL_FUNCTION(void, png_read_filter_row_avg3_vsx,
+ (png_row_infop row_info, png_bytep row, png_const_bytep prev_row),
+ PNG_EMPTY);
+PNG_INTERNAL_FUNCTION(void, png_read_filter_row_avg4_vsx,
+ (png_row_infop row_info, png_bytep row, png_const_bytep prev_row),
+ PNG_EMPTY);
+PNG_INTERNAL_FUNCTION(void, png_read_filter_row_paeth3_vsx,
+ (png_row_infop row_info, png_bytep row, png_const_bytep prev_row),
+ PNG_EMPTY);
+PNG_INTERNAL_FUNCTION(void, png_read_filter_row_paeth4_vsx,
+ (png_row_infop row_info, png_bytep row, png_const_bytep prev_row),
+ PNG_EMPTY);
#endif
#if PNG_INTEL_SSE_IMPLEMENTATION > 0
-PNG_INTERNAL_FUNCTION(void,png_read_filter_row_sub3_sse2,(png_row_infop
- row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);
-PNG_INTERNAL_FUNCTION(void,png_read_filter_row_sub4_sse2,(png_row_infop
- row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);
-PNG_INTERNAL_FUNCTION(void,png_read_filter_row_avg3_sse2,(png_row_infop
- row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);
-PNG_INTERNAL_FUNCTION(void,png_read_filter_row_avg4_sse2,(png_row_infop
- row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);
-PNG_INTERNAL_FUNCTION(void,png_read_filter_row_paeth3_sse2,(png_row_infop
- row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);
-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);
+PNG_INTERNAL_FUNCTION(void, png_read_filter_row_sub3_sse2,
+ (png_row_infop row_info, png_bytep row, png_const_bytep prev_row),
+ PNG_EMPTY);
+PNG_INTERNAL_FUNCTION(void, png_read_filter_row_sub4_sse2,
+ (png_row_infop row_info, png_bytep row, png_const_bytep prev_row),
+ PNG_EMPTY);
+PNG_INTERNAL_FUNCTION(void, png_read_filter_row_avg3_sse2,
+ (png_row_infop row_info, png_bytep row, png_const_bytep prev_row),
+ PNG_EMPTY);
+PNG_INTERNAL_FUNCTION(void, png_read_filter_row_avg4_sse2,
+ (png_row_infop row_info, png_bytep row, png_const_bytep prev_row),
+ PNG_EMPTY);
+PNG_INTERNAL_FUNCTION(void, png_read_filter_row_paeth3_sse2,
+ (png_row_infop row_info, png_bytep row, png_const_bytep prev_row),
+ PNG_EMPTY);
+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
+
+#if PNG_RISCV_RVV_IMPLEMENTATION == 1
+PNG_INTERNAL_FUNCTION(void, png_read_filter_row_up_rvv,
+ (png_row_infop row_info, png_bytep row, png_const_bytep prev_row),
+ PNG_EMPTY);
+PNG_INTERNAL_FUNCTION(void, png_read_filter_row_sub3_rvv,
+ (png_row_infop row_info, png_bytep row, png_const_bytep prev_row),
+ PNG_EMPTY);
+PNG_INTERNAL_FUNCTION(void, png_read_filter_row_sub4_rvv,
+ (png_row_infop row_info, png_bytep row, png_const_bytep prev_row),
+ PNG_EMPTY);
+PNG_INTERNAL_FUNCTION(void, png_read_filter_row_avg3_rvv,
+ (png_row_infop row_info, png_bytep row, png_const_bytep prev_row),
+ PNG_EMPTY);
+PNG_INTERNAL_FUNCTION(void, png_read_filter_row_avg4_rvv,
+ (png_row_infop row_info, png_bytep row, png_const_bytep prev_row),
+ PNG_EMPTY);
+PNG_INTERNAL_FUNCTION(void, png_read_filter_row_paeth3_rvv,
+ (png_row_infop row_info, png_bytep row, png_const_bytep prev_row),
+ PNG_EMPTY);
+PNG_INTERNAL_FUNCTION(void, png_read_filter_row_paeth4_rvv,
+ (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);
+PNG_INTERNAL_FUNCTION(void, png_write_find_filter,
+ (png_structrp png_ptr, png_row_infop row_info),
+ PNG_EMPTY);
#ifdef PNG_SEQUENTIAL_READ_SUPPORTED
-PNG_INTERNAL_FUNCTION(void,png_read_IDAT_data,(png_structrp png_ptr,
- png_bytep output, png_alloc_size_t avail_out),PNG_EMPTY);
+PNG_INTERNAL_FUNCTION(void, png_read_IDAT_data,
+ (png_structrp png_ptr, png_bytep output, png_alloc_size_t avail_out),
+ PNG_EMPTY);
/* Read 'avail_out' bytes of data from the IDAT stream. If the output buffer
* is NULL the function checks, instead, for the end of the stream. In this
* case a benign error will be issued if the stream end is not found or if
* extra data has to be consumed.
*/
-PNG_INTERNAL_FUNCTION(void,png_read_finish_IDAT,(png_structrp png_ptr),
+PNG_INTERNAL_FUNCTION(void, png_read_finish_IDAT,
+ (png_structrp png_ptr),
PNG_EMPTY);
/* This cleans up when the IDAT LZ stream does not end when the last image
* byte is read; there is still some pending input.
*/
-PNG_INTERNAL_FUNCTION(void,png_read_finish_row,(png_structrp png_ptr),
+PNG_INTERNAL_FUNCTION(void, png_read_finish_row,
+ (png_structrp png_ptr),
PNG_EMPTY);
/* Finish a row while reading, dealing with interlacing passes, etc. */
#endif /* SEQUENTIAL_READ */
/* Initialize the row buffers, etc. */
-PNG_INTERNAL_FUNCTION(void,png_read_start_row,(png_structrp png_ptr),PNG_EMPTY);
+PNG_INTERNAL_FUNCTION(void, png_read_start_row,
+ (png_structrp png_ptr),
+ PNG_EMPTY);
#if ZLIB_VERNUM >= 0x1240
-PNG_INTERNAL_FUNCTION(int,png_zlib_inflate,(png_structrp png_ptr, int flush),
- PNG_EMPTY);
+PNG_INTERNAL_FUNCTION(int, png_zlib_inflate,
+ (png_structrp png_ptr, int flush),
+ PNG_EMPTY);
# define PNG_INFLATE(pp, flush) png_zlib_inflate(pp, flush)
#else /* Zlib < 1.2.4 */
# define PNG_INFLATE(pp, flush) inflate(&(pp)->zstream, flush)
@@ -1400,160 +1733,85 @@ PNG_INTERNAL_FUNCTION(int,png_zlib_inflate,(png_structrp png_ptr, int flush),
#ifdef PNG_READ_TRANSFORMS_SUPPORTED
/* Optional call to update the users info structure */
-PNG_INTERNAL_FUNCTION(void,png_read_transform_info,(png_structrp png_ptr,
- png_inforp info_ptr),PNG_EMPTY);
+PNG_INTERNAL_FUNCTION(void, png_read_transform_info,
+ (png_structrp png_ptr, png_inforp info_ptr),
+ PNG_EMPTY);
#endif
/* Shared transform functions, defined in pngtran.c */
#if defined(PNG_WRITE_FILLER_SUPPORTED) || \
defined(PNG_READ_STRIP_ALPHA_SUPPORTED)
-PNG_INTERNAL_FUNCTION(void,png_do_strip_channel,(png_row_infop row_info,
- png_bytep row, int at_start),PNG_EMPTY);
+PNG_INTERNAL_FUNCTION(void, png_do_strip_channel,
+ (png_row_infop row_info, png_bytep row, int at_start),
+ PNG_EMPTY);
#endif
#ifdef PNG_16BIT_SUPPORTED
#if defined(PNG_READ_SWAP_SUPPORTED) || defined(PNG_WRITE_SWAP_SUPPORTED)
-PNG_INTERNAL_FUNCTION(void,png_do_swap,(png_row_infop row_info,
- png_bytep row),PNG_EMPTY);
+PNG_INTERNAL_FUNCTION(void, png_do_swap,
+ (png_row_infop row_info, png_bytep row),
+ PNG_EMPTY);
#endif
#endif
#if defined(PNG_READ_PACKSWAP_SUPPORTED) || \
defined(PNG_WRITE_PACKSWAP_SUPPORTED)
-PNG_INTERNAL_FUNCTION(void,png_do_packswap,(png_row_infop row_info,
- png_bytep row),PNG_EMPTY);
+PNG_INTERNAL_FUNCTION(void, png_do_packswap,
+ (png_row_infop row_info, png_bytep row),
+ PNG_EMPTY);
#endif
#if defined(PNG_READ_INVERT_SUPPORTED) || defined(PNG_WRITE_INVERT_SUPPORTED)
-PNG_INTERNAL_FUNCTION(void,png_do_invert,(png_row_infop row_info,
- png_bytep row),PNG_EMPTY);
+PNG_INTERNAL_FUNCTION(void, png_do_invert,
+ (png_row_infop row_info, png_bytep row),
+ PNG_EMPTY);
#endif
#if defined(PNG_READ_BGR_SUPPORTED) || defined(PNG_WRITE_BGR_SUPPORTED)
-PNG_INTERNAL_FUNCTION(void,png_do_bgr,(png_row_infop row_info,
- png_bytep row),PNG_EMPTY);
+PNG_INTERNAL_FUNCTION(void, png_do_bgr,
+ (png_row_infop row_info, png_bytep row),
+ PNG_EMPTY);
#endif
/* The following decodes the appropriate chunks, and does error correction,
* then calls the appropriate callback for the chunk if it is valid.
*/
-
-/* Decode the IHDR chunk */
-PNG_INTERNAL_FUNCTION(void,png_handle_IHDR,(png_structrp png_ptr,
- png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);
-PNG_INTERNAL_FUNCTION(void,png_handle_PLTE,(png_structrp png_ptr,
- png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);
-PNG_INTERNAL_FUNCTION(void,png_handle_IEND,(png_structrp png_ptr,
- png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);
-
-#ifdef PNG_READ_bKGD_SUPPORTED
-PNG_INTERNAL_FUNCTION(void,png_handle_bKGD,(png_structrp png_ptr,
- png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);
-#endif
-
-#ifdef PNG_READ_cHRM_SUPPORTED
-PNG_INTERNAL_FUNCTION(void,png_handle_cHRM,(png_structrp png_ptr,
- png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);
-#endif
-
-#ifdef PNG_READ_eXIf_SUPPORTED
-PNG_INTERNAL_FUNCTION(void,png_handle_eXIf,(png_structrp png_ptr,
- png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);
-#endif
-
-#ifdef PNG_READ_gAMA_SUPPORTED
-PNG_INTERNAL_FUNCTION(void,png_handle_gAMA,(png_structrp png_ptr,
- png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);
-#endif
-
-#ifdef PNG_READ_hIST_SUPPORTED
-PNG_INTERNAL_FUNCTION(void,png_handle_hIST,(png_structrp png_ptr,
- png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);
-#endif
-
-#ifdef PNG_READ_iCCP_SUPPORTED
-PNG_INTERNAL_FUNCTION(void,png_handle_iCCP,(png_structrp png_ptr,
- png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);
-#endif /* READ_iCCP */
-
-#ifdef PNG_READ_iTXt_SUPPORTED
-PNG_INTERNAL_FUNCTION(void,png_handle_iTXt,(png_structrp png_ptr,
- png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);
-#endif
-
-#ifdef PNG_READ_oFFs_SUPPORTED
-PNG_INTERNAL_FUNCTION(void,png_handle_oFFs,(png_structrp png_ptr,
- png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);
-#endif
-
-#ifdef PNG_READ_pCAL_SUPPORTED
-PNG_INTERNAL_FUNCTION(void,png_handle_pCAL,(png_structrp png_ptr,
- png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);
-#endif
-
-#ifdef PNG_READ_pHYs_SUPPORTED
-PNG_INTERNAL_FUNCTION(void,png_handle_pHYs,(png_structrp png_ptr,
- png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);
-#endif
-
-#ifdef PNG_READ_sBIT_SUPPORTED
-PNG_INTERNAL_FUNCTION(void,png_handle_sBIT,(png_structrp png_ptr,
- png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);
-#endif
-
-#ifdef PNG_READ_sCAL_SUPPORTED
-PNG_INTERNAL_FUNCTION(void,png_handle_sCAL,(png_structrp png_ptr,
- png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);
-#endif
-
-#ifdef PNG_READ_sPLT_SUPPORTED
-PNG_INTERNAL_FUNCTION(void,png_handle_sPLT,(png_structrp png_ptr,
- png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);
-#endif /* READ_sPLT */
-
-#ifdef PNG_READ_sRGB_SUPPORTED
-PNG_INTERNAL_FUNCTION(void,png_handle_sRGB,(png_structrp png_ptr,
- png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);
-#endif
-
-#ifdef PNG_READ_tEXt_SUPPORTED
-PNG_INTERNAL_FUNCTION(void,png_handle_tEXt,(png_structrp png_ptr,
- png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);
-#endif
-
-#ifdef PNG_READ_tIME_SUPPORTED
-PNG_INTERNAL_FUNCTION(void,png_handle_tIME,(png_structrp png_ptr,
- png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);
-#endif
-
-#ifdef PNG_READ_tRNS_SUPPORTED
-PNG_INTERNAL_FUNCTION(void,png_handle_tRNS,(png_structrp png_ptr,
- png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);
-#endif
-
-#ifdef PNG_READ_zTXt_SUPPORTED
-PNG_INTERNAL_FUNCTION(void,png_handle_zTXt,(png_structrp png_ptr,
- png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);
-#endif
-
-PNG_INTERNAL_FUNCTION(void,png_check_chunk_name,(png_const_structrp png_ptr,
- png_uint_32 chunk_name),PNG_EMPTY);
-
-PNG_INTERNAL_FUNCTION(void,png_check_chunk_length,(png_const_structrp png_ptr,
- png_uint_32 chunk_length),PNG_EMPTY);
-
-PNG_INTERNAL_FUNCTION(void,png_handle_unknown,(png_structrp png_ptr,
- png_inforp info_ptr, png_uint_32 length, int keep),PNG_EMPTY);
+typedef enum
+{
+ /* Result of a call to png_handle_chunk made to handle the current chunk
+ * png_struct::chunk_name on read. Always informational, either the stream
+ * is read for the next chunk or the routine will call png_error.
+ *
+ * NOTE: order is important internally. handled_saved and above are regarded
+ * as handling the chunk.
+ */
+ handled_error = 0, /* bad crc or known and bad format or too long */
+ handled_discarded, /* not saved in the unknown chunk list */
+ handled_saved, /* saved in the unknown chunk list */
+ handled_ok /* known, supported and handled without error */
+} png_handle_result_code;
+
+PNG_INTERNAL_FUNCTION(png_handle_result_code, png_handle_unknown,
+ (png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length, int keep),
+ PNG_EMPTY);
/* This is the function that gets called for unknown chunks. The 'keep'
* argument is either non-zero for a known chunk that has been set to be
* handled as unknown or zero for an unknown chunk. By default the function
* just skips the chunk or errors out if it is critical.
*/
+PNG_INTERNAL_FUNCTION(png_handle_result_code, png_handle_chunk,
+ (png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length),
+ PNG_EMPTY);
+ /* This handles the current chunk png_ptr->chunk_name with unread
+ * data[length] and returns one of the above result codes.
+ */
+
#if defined(PNG_READ_UNKNOWN_CHUNKS_SUPPORTED) ||\
defined(PNG_HANDLE_AS_UNKNOWN_SUPPORTED)
-PNG_INTERNAL_FUNCTION(int,png_chunk_unknown_handling,
- (png_const_structrp png_ptr, png_uint_32 chunk_name),PNG_EMPTY);
+PNG_INTERNAL_FUNCTION(int, png_chunk_unknown_handling,
+ (png_const_structrp png_ptr, png_uint_32 chunk_name),
+ PNG_EMPTY);
/* Exactly as the API png_handle_as_unknown() except that the argument is a
* 32-bit chunk name, not a string.
*/
@@ -1561,176 +1819,122 @@ PNG_INTERNAL_FUNCTION(int,png_chunk_unknown_handling,
/* Handle the transformations for reading and writing */
#ifdef PNG_READ_TRANSFORMS_SUPPORTED
-PNG_INTERNAL_FUNCTION(void,png_do_read_transformations,(png_structrp png_ptr,
- png_row_infop row_info),PNG_EMPTY);
+PNG_INTERNAL_FUNCTION(void, png_do_read_transformations,
+ (png_structrp png_ptr, png_row_infop row_info),
+ PNG_EMPTY);
#endif
#ifdef PNG_WRITE_TRANSFORMS_SUPPORTED
-PNG_INTERNAL_FUNCTION(void,png_do_write_transformations,(png_structrp png_ptr,
- png_row_infop row_info),PNG_EMPTY);
+PNG_INTERNAL_FUNCTION(void, png_do_write_transformations,
+ (png_structrp png_ptr, png_row_infop row_info),
+ PNG_EMPTY);
#endif
#ifdef PNG_READ_TRANSFORMS_SUPPORTED
-PNG_INTERNAL_FUNCTION(void,png_init_read_transformations,(png_structrp png_ptr),
- PNG_EMPTY);
+PNG_INTERNAL_FUNCTION(void, png_init_read_transformations,
+ (png_structrp png_ptr),
+ PNG_EMPTY);
#endif
#ifdef PNG_PROGRESSIVE_READ_SUPPORTED
-PNG_INTERNAL_FUNCTION(void,png_push_read_chunk,(png_structrp png_ptr,
- png_inforp info_ptr),PNG_EMPTY);
-PNG_INTERNAL_FUNCTION(void,png_push_read_sig,(png_structrp png_ptr,
- png_inforp info_ptr),PNG_EMPTY);
-PNG_INTERNAL_FUNCTION(void,png_push_check_crc,(png_structrp png_ptr),PNG_EMPTY);
-PNG_INTERNAL_FUNCTION(void,png_push_save_buffer,(png_structrp png_ptr),
- PNG_EMPTY);
-PNG_INTERNAL_FUNCTION(void,png_push_restore_buffer,(png_structrp png_ptr,
- png_bytep buffer, size_t buffer_length),PNG_EMPTY);
-PNG_INTERNAL_FUNCTION(void,png_push_read_IDAT,(png_structrp png_ptr),PNG_EMPTY);
-PNG_INTERNAL_FUNCTION(void,png_process_IDAT_data,(png_structrp png_ptr,
- png_bytep buffer, size_t buffer_length),PNG_EMPTY);
-PNG_INTERNAL_FUNCTION(void,png_push_process_row,(png_structrp png_ptr),
- PNG_EMPTY);
-PNG_INTERNAL_FUNCTION(void,png_push_handle_unknown,(png_structrp png_ptr,
- png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);
-PNG_INTERNAL_FUNCTION(void,png_push_have_info,(png_structrp png_ptr,
- png_inforp info_ptr),PNG_EMPTY);
-PNG_INTERNAL_FUNCTION(void,png_push_have_end,(png_structrp png_ptr,
- png_inforp info_ptr),PNG_EMPTY);
-PNG_INTERNAL_FUNCTION(void,png_push_have_row,(png_structrp png_ptr,
- png_bytep row),PNG_EMPTY);
-PNG_INTERNAL_FUNCTION(void,png_push_read_end,(png_structrp png_ptr,
- png_inforp info_ptr),PNG_EMPTY);
-PNG_INTERNAL_FUNCTION(void,png_process_some_data,(png_structrp png_ptr,
- png_inforp info_ptr),PNG_EMPTY);
-PNG_INTERNAL_FUNCTION(void,png_read_push_finish_row,(png_structrp png_ptr),
- PNG_EMPTY);
-# ifdef PNG_READ_tEXt_SUPPORTED
-PNG_INTERNAL_FUNCTION(void,png_push_handle_tEXt,(png_structrp png_ptr,
- png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);
-PNG_INTERNAL_FUNCTION(void,png_push_read_tEXt,(png_structrp png_ptr,
- png_inforp info_ptr),PNG_EMPTY);
-# endif
-# ifdef PNG_READ_zTXt_SUPPORTED
-PNG_INTERNAL_FUNCTION(void,png_push_handle_zTXt,(png_structrp png_ptr,
- png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);
-PNG_INTERNAL_FUNCTION(void,png_push_read_zTXt,(png_structrp png_ptr,
- png_inforp info_ptr),PNG_EMPTY);
-# endif
-# ifdef PNG_READ_iTXt_SUPPORTED
-PNG_INTERNAL_FUNCTION(void,png_push_handle_iTXt,(png_structrp png_ptr,
- png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);
-PNG_INTERNAL_FUNCTION(void,png_push_read_iTXt,(png_structrp png_ptr,
- png_inforp info_ptr),PNG_EMPTY);
-# endif
-
+PNG_INTERNAL_FUNCTION(void, png_push_read_chunk,
+ (png_structrp png_ptr, png_inforp info_ptr),
+ PNG_EMPTY);
+PNG_INTERNAL_FUNCTION(void, png_push_read_sig,
+ (png_structrp png_ptr, png_inforp info_ptr),
+ PNG_EMPTY);
+PNG_INTERNAL_FUNCTION(void, png_push_check_crc,
+ (png_structrp png_ptr),
+ PNG_EMPTY);
+PNG_INTERNAL_FUNCTION(void, png_push_save_buffer,
+ (png_structrp png_ptr),
+ PNG_EMPTY);
+PNG_INTERNAL_FUNCTION(void, png_push_restore_buffer,
+ (png_structrp png_ptr, png_bytep buffer, size_t buffer_length),
+ PNG_EMPTY);
+PNG_INTERNAL_FUNCTION(void, png_push_read_IDAT,
+ (png_structrp png_ptr),
+ PNG_EMPTY);
+PNG_INTERNAL_FUNCTION(void, png_process_IDAT_data,
+ (png_structrp png_ptr, png_bytep buffer, size_t buffer_length),
+ PNG_EMPTY);
+PNG_INTERNAL_FUNCTION(void, png_push_process_row,
+ (png_structrp png_ptr),
+ PNG_EMPTY);
+PNG_INTERNAL_FUNCTION(void, png_push_have_info,
+ (png_structrp png_ptr, png_inforp info_ptr),
+ PNG_EMPTY);
+PNG_INTERNAL_FUNCTION(void, png_push_have_end,
+ (png_structrp png_ptr, png_inforp info_ptr),
+ PNG_EMPTY);
+PNG_INTERNAL_FUNCTION(void, png_push_have_row,
+ (png_structrp png_ptr, png_bytep row),
+ PNG_EMPTY);
+PNG_INTERNAL_FUNCTION(void, png_push_read_end,
+ (png_structrp png_ptr, png_inforp info_ptr),
+ PNG_EMPTY);
+PNG_INTERNAL_FUNCTION(void, png_process_some_data,
+ (png_structrp png_ptr, png_inforp info_ptr),
+ PNG_EMPTY);
+PNG_INTERNAL_FUNCTION(void, png_read_push_finish_row,
+ (png_structrp png_ptr),
+ PNG_EMPTY);
#endif /* PROGRESSIVE_READ */
-/* Added at libpng version 1.6.0 */
-#ifdef PNG_GAMMA_SUPPORTED
-PNG_INTERNAL_FUNCTION(void,png_colorspace_set_gamma,(png_const_structrp png_ptr,
- png_colorspacerp colorspace, png_fixed_point gAMA), PNG_EMPTY);
- /* Set the colorspace gamma with a value provided by the application or by
- * the gAMA chunk on read. The value will override anything set by an ICC
- * profile.
- */
-
-PNG_INTERNAL_FUNCTION(void,png_colorspace_sync_info,(png_const_structrp png_ptr,
- png_inforp info_ptr), PNG_EMPTY);
- /* Synchronize the info 'valid' flags with the colorspace */
-
-PNG_INTERNAL_FUNCTION(void,png_colorspace_sync,(png_const_structrp png_ptr,
- png_inforp info_ptr), PNG_EMPTY);
- /* Copy the png_struct colorspace to the info_struct and call the above to
- * synchronize the flags. Checks for NULL info_ptr and does nothing.
- */
-#endif
-
-/* Added at libpng version 1.4.0 */
-#ifdef PNG_COLORSPACE_SUPPORTED
-/* These internal functions are for maintaining the colorspace structure within
- * a png_info or png_struct (or, indeed, both).
- */
-PNG_INTERNAL_FUNCTION(int,png_colorspace_set_chromaticities,
- (png_const_structrp png_ptr, png_colorspacerp colorspace, const png_xy *xy,
- int preferred), PNG_EMPTY);
-
-PNG_INTERNAL_FUNCTION(int,png_colorspace_set_endpoints,
- (png_const_structrp png_ptr, png_colorspacerp colorspace, const png_XYZ *XYZ,
- int preferred), PNG_EMPTY);
-
-#ifdef PNG_sRGB_SUPPORTED
-PNG_INTERNAL_FUNCTION(int,png_colorspace_set_sRGB,(png_const_structrp png_ptr,
- png_colorspacerp colorspace, int intent), PNG_EMPTY);
- /* This does set the colorspace gAMA and cHRM values too, but doesn't set the
- * flags to write them, if it returns false there was a problem and an error
- * message has already been output (but the colorspace may still need to be
- * synced to record the invalid flag).
- */
-#endif /* sRGB */
-
#ifdef PNG_iCCP_SUPPORTED
-PNG_INTERNAL_FUNCTION(int,png_colorspace_set_ICC,(png_const_structrp png_ptr,
- png_colorspacerp colorspace, png_const_charp name,
- png_uint_32 profile_length, png_const_bytep profile, int color_type),
- PNG_EMPTY);
- /* The 'name' is used for information only */
-
/* Routines for checking parts of an ICC profile. */
#ifdef PNG_READ_iCCP_SUPPORTED
-PNG_INTERNAL_FUNCTION(int,png_icc_check_length,(png_const_structrp png_ptr,
- png_colorspacerp colorspace, png_const_charp name,
- png_uint_32 profile_length), PNG_EMPTY);
+PNG_INTERNAL_FUNCTION(int, png_icc_check_length,
+ (png_const_structrp png_ptr,
+ png_const_charp name, png_uint_32 profile_length),
+ PNG_EMPTY);
#endif /* READ_iCCP */
-PNG_INTERNAL_FUNCTION(int,png_icc_check_header,(png_const_structrp png_ptr,
- png_colorspacerp colorspace, png_const_charp name,
- png_uint_32 profile_length,
- png_const_bytep profile /* first 132 bytes only */, int color_type),
- PNG_EMPTY);
-PNG_INTERNAL_FUNCTION(int,png_icc_check_tag_table,(png_const_structrp png_ptr,
- png_colorspacerp colorspace, png_const_charp name,
- png_uint_32 profile_length,
- png_const_bytep profile /* header plus whole tag table */), PNG_EMPTY);
-#ifdef PNG_sRGB_SUPPORTED
-PNG_INTERNAL_FUNCTION(void,png_icc_set_sRGB,(
- png_const_structrp png_ptr, png_colorspacerp colorspace,
- png_const_bytep profile, uLong adler), PNG_EMPTY);
- /* 'adler' is the Adler32 checksum of the uncompressed profile data. It may
- * be zero to indicate that it is not available. It is used, if provided,
- * as a fast check on the profile when checking to see if it is sRGB.
- */
-#endif
+PNG_INTERNAL_FUNCTION(int, png_icc_check_header,
+ (png_const_structrp png_ptr,
+ png_const_charp name, png_uint_32 profile_length,
+ png_const_bytep profile /* first 132 bytes only */, int color_type),
+ PNG_EMPTY);
+PNG_INTERNAL_FUNCTION(int, png_icc_check_tag_table,
+ (png_const_structrp png_ptr,
+ png_const_charp name, png_uint_32 profile_length,
+ png_const_bytep profile /* header plus whole tag table */),
+ PNG_EMPTY);
#endif /* iCCP */
#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED
-PNG_INTERNAL_FUNCTION(void,png_colorspace_set_rgb_coefficients,
- (png_structrp png_ptr), PNG_EMPTY);
- /* Set the rgb_to_gray coefficients from the colorspace Y values */
+PNG_INTERNAL_FUNCTION(void, png_set_rgb_coefficients,
+ (png_structrp png_ptr),
+ PNG_EMPTY);
+ /* Set the rgb_to_gray coefficients from the cHRM Y values (if unset) */
#endif /* READ_RGB_TO_GRAY */
-#endif /* COLORSPACE */
/* Added at libpng version 1.4.0 */
-PNG_INTERNAL_FUNCTION(void,png_check_IHDR,(png_const_structrp png_ptr,
- png_uint_32 width, png_uint_32 height, int bit_depth,
- int color_type, int interlace_type, int compression_type,
- int filter_type),PNG_EMPTY);
+PNG_INTERNAL_FUNCTION(void, png_check_IHDR,
+ (png_const_structrp png_ptr,
+ png_uint_32 width, png_uint_32 height, int bit_depth, int color_type,
+ int interlace_type, int compression_type, int filter_type),
+ PNG_EMPTY);
/* Added at libpng version 1.5.10 */
#if defined(PNG_READ_CHECK_FOR_INVALID_INDEX_SUPPORTED) || \
defined(PNG_WRITE_CHECK_FOR_INVALID_INDEX_SUPPORTED)
-PNG_INTERNAL_FUNCTION(void,png_do_check_palette_indexes,
- (png_structrp png_ptr, png_row_infop row_info),PNG_EMPTY);
+PNG_INTERNAL_FUNCTION(void, png_do_check_palette_indexes,
+ (png_structrp png_ptr, png_row_infop row_info),
+ PNG_EMPTY);
#endif
#if defined(PNG_FLOATING_POINT_SUPPORTED) && defined(PNG_ERROR_TEXT_SUPPORTED)
-PNG_INTERNAL_FUNCTION(void,png_fixed_error,(png_const_structrp png_ptr,
- png_const_charp name),PNG_NORETURN);
+PNG_INTERNAL_FUNCTION(void, png_fixed_error,
+ (png_const_structrp png_ptr, png_const_charp name),
+ PNG_NORETURN);
#endif
/* Puts 'string' into 'buffer' at buffer[pos], taking care never to overwrite
* the end. Always leaves the buffer nul terminated. Never errors out (and
* there is no error code.)
*/
-PNG_INTERNAL_FUNCTION(size_t,png_safecat,(png_charp buffer, size_t bufsize,
- size_t pos, png_const_charp string),PNG_EMPTY);
+PNG_INTERNAL_FUNCTION(size_t, png_safecat,
+ (png_charp buffer, size_t bufsize, size_t pos, png_const_charp string),
+ PNG_EMPTY);
/* Various internal functions to handle formatted warning messages, currently
* only implemented for warnings.
@@ -1741,8 +1945,9 @@ PNG_INTERNAL_FUNCTION(size_t,png_safecat,(png_charp buffer, size_t bufsize,
* Returns the pointer to the start of the formatted string. This utility only
* does unsigned values.
*/
-PNG_INTERNAL_FUNCTION(png_charp,png_format_number,(png_const_charp start,
- png_charp end, int format, png_alloc_size_t number),PNG_EMPTY);
+PNG_INTERNAL_FUNCTION(png_charp, png_format_number,
+ (png_const_charp start, png_charp end, int format, png_alloc_size_t number),
+ PNG_EMPTY);
/* Convenience macro that takes an array: */
#define PNG_FORMAT_NUMBER(buffer,format,number) \
@@ -1774,23 +1979,26 @@ PNG_INTERNAL_FUNCTION(png_charp,png_format_number,(png_const_charp start,
typedef char png_warning_parameters[PNG_WARNING_PARAMETER_COUNT][
PNG_WARNING_PARAMETER_SIZE];
-PNG_INTERNAL_FUNCTION(void,png_warning_parameter,(png_warning_parameters p,
- int number, png_const_charp string),PNG_EMPTY);
+PNG_INTERNAL_FUNCTION(void, png_warning_parameter,
+ (png_warning_parameters p, int number, png_const_charp string),
+ PNG_EMPTY);
/* Parameters are limited in size to PNG_WARNING_PARAMETER_SIZE characters,
* including the trailing '\0'.
*/
-PNG_INTERNAL_FUNCTION(void,png_warning_parameter_unsigned,
+PNG_INTERNAL_FUNCTION(void, png_warning_parameter_unsigned,
(png_warning_parameters p, int number, int format, png_alloc_size_t value),
PNG_EMPTY);
/* Use png_alloc_size_t because it is an unsigned type as big as any we
* need to output. Use the following for a signed value.
*/
-PNG_INTERNAL_FUNCTION(void,png_warning_parameter_signed,
+PNG_INTERNAL_FUNCTION(void, png_warning_parameter_signed,
(png_warning_parameters p, int number, int format, png_int_32 value),
PNG_EMPTY);
-PNG_INTERNAL_FUNCTION(void,png_formatted_warning,(png_const_structrp png_ptr,
- png_warning_parameters p, png_const_charp message),PNG_EMPTY);
+PNG_INTERNAL_FUNCTION(void, png_formatted_warning,
+ (png_const_structrp png_ptr,
+ png_warning_parameters p, png_const_charp message),
+ PNG_EMPTY);
/* 'message' follows the X/Open approach of using @1, @2 to insert
* parameters previously supplied using the above functions. Errors in
* specifying the parameters will simply result in garbage substitutions.
@@ -1812,14 +2020,16 @@ PNG_INTERNAL_FUNCTION(void,png_formatted_warning,(png_const_structrp png_ptr,
* If benign errors aren't supported they end up as the corresponding base call
* (png_warning or png_error.)
*/
-PNG_INTERNAL_FUNCTION(void,png_app_warning,(png_const_structrp png_ptr,
- png_const_charp message),PNG_EMPTY);
+PNG_INTERNAL_FUNCTION(void, png_app_warning,
+ (png_const_structrp png_ptr, png_const_charp message),
+ PNG_EMPTY);
/* The application provided invalid parameters to an API function or called
* an API function at the wrong time, libpng can completely recover.
*/
-PNG_INTERNAL_FUNCTION(void,png_app_error,(png_const_structrp png_ptr,
- png_const_charp message),PNG_EMPTY);
+PNG_INTERNAL_FUNCTION(void, png_app_error,
+ (png_const_structrp png_ptr, png_const_charp message),
+ PNG_EMPTY);
/* As above but libpng will ignore the call, or attempt some other partial
* recovery from the error.
*/
@@ -1828,8 +2038,9 @@ PNG_INTERNAL_FUNCTION(void,png_app_error,(png_const_structrp png_ptr,
# define png_app_error(pp,s) png_error(pp,s)
#endif
-PNG_INTERNAL_FUNCTION(void,png_chunk_report,(png_const_structrp png_ptr,
- png_const_charp message, int error),PNG_EMPTY);
+PNG_INTERNAL_FUNCTION(void, png_chunk_report,
+ (png_const_structrp png_ptr, png_const_charp message, int error),
+ PNG_EMPTY);
/* Report a recoverable issue in chunk data. On read this is used to report
* a problem found while reading a particular chunk and the
* png_chunk_benign_error or png_chunk_warning function is used as
@@ -1855,14 +2066,17 @@ PNG_INTERNAL_FUNCTION(void,png_chunk_report,(png_const_structrp png_ptr,
#define PNG_sCAL_MAX_DIGITS (PNG_sCAL_PRECISION+1/*.*/+1/*E*/+10/*exponent*/)
#ifdef PNG_FLOATING_POINT_SUPPORTED
-PNG_INTERNAL_FUNCTION(void,png_ascii_from_fp,(png_const_structrp png_ptr,
- png_charp ascii, size_t size, double fp, unsigned int precision),
+PNG_INTERNAL_FUNCTION(void, png_ascii_from_fp,
+ (png_const_structrp png_ptr,
+ png_charp ascii, size_t size, double fp, unsigned int precision),
PNG_EMPTY);
#endif /* FLOATING_POINT */
#ifdef PNG_FIXED_POINT_SUPPORTED
-PNG_INTERNAL_FUNCTION(void,png_ascii_from_fixed,(png_const_structrp png_ptr,
- png_charp ascii, size_t size, png_fixed_point fp),PNG_EMPTY);
+PNG_INTERNAL_FUNCTION(void, png_ascii_from_fixed,
+ (png_const_structrp png_ptr,
+ png_charp ascii, size_t size, png_fixed_point fp),
+ PNG_EMPTY);
#endif /* FIXED_POINT */
#endif /* sCAL */
@@ -1919,7 +2133,7 @@ PNG_INTERNAL_FUNCTION(void,png_ascii_from_fixed,(png_const_structrp png_ptr,
*/
#define PNG_FP_INVALID 512 /* Available for callers as a distinct value */
-/* Result codes for the parser (boolean - true meants ok, false means
+/* Result codes for the parser (boolean - true means ok, false means
* not ok yet.)
*/
#define PNG_FP_MAYBE 0 /* The number may be valid in the future */
@@ -1954,8 +2168,9 @@ PNG_INTERNAL_FUNCTION(void,png_ascii_from_fixed,(png_const_structrp png_ptr,
* that omits the last character (i.e. set the size to the index of
* the problem character.) This has not been tested within libpng.
*/
-PNG_INTERNAL_FUNCTION(int,png_check_fp_number,(png_const_charp string,
- size_t size, int *statep, png_size_tp whereami),PNG_EMPTY);
+PNG_INTERNAL_FUNCTION(int, png_check_fp_number,
+ (png_const_charp string, size_t size, int *statep, size_t *whereami),
+ PNG_EMPTY);
/* This is the same but it checks a complete string and returns true
* only if it just contains a floating point number. As of 1.5.4 this
@@ -1963,52 +2178,61 @@ PNG_INTERNAL_FUNCTION(int,png_check_fp_number,(png_const_charp string,
* it was valid (otherwise it returns 0.) This can be used for testing
* for negative or zero values using the sticky flag.
*/
-PNG_INTERNAL_FUNCTION(int,png_check_fp_string,(png_const_charp string,
- size_t size),PNG_EMPTY);
+PNG_INTERNAL_FUNCTION(int, png_check_fp_string,
+ (png_const_charp string, size_t size),
+ PNG_EMPTY);
#endif /* pCAL || sCAL */
-#if defined(PNG_GAMMA_SUPPORTED) ||\
- defined(PNG_INCH_CONVERSIONS_SUPPORTED) || defined(PNG_READ_pHYs_SUPPORTED)
+#if defined(PNG_READ_GAMMA_SUPPORTED) ||\
+ defined(PNG_COLORSPACE_SUPPORTED) ||\
+ defined(PNG_INCH_CONVERSIONS_SUPPORTED) ||\
+ defined(PNG_READ_pHYs_SUPPORTED)
/* Added at libpng version 1.5.0 */
/* This is a utility to provide a*times/div (rounded) and indicate
* if there is an overflow. The result is a boolean - false (0)
* for overflow, true (1) if no overflow, in which case *res
* holds the result.
*/
-PNG_INTERNAL_FUNCTION(int,png_muldiv,(png_fixed_point_p res, png_fixed_point a,
- png_int_32 multiplied_by, png_int_32 divided_by),PNG_EMPTY);
-#endif
-
-#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_INCH_CONVERSIONS_SUPPORTED)
-/* Same deal, but issue a warning on overflow and return 0. */
-PNG_INTERNAL_FUNCTION(png_fixed_point,png_muldiv_warn,
- (png_const_structrp png_ptr, png_fixed_point a, png_int_32 multiplied_by,
- png_int_32 divided_by),PNG_EMPTY);
-#endif
+PNG_INTERNAL_FUNCTION(int, png_muldiv,
+ (png_fixed_point_p res, png_fixed_point a,
+ png_int_32 multiplied_by, png_int_32 divided_by),
+ PNG_EMPTY);
-#ifdef PNG_GAMMA_SUPPORTED
/* Calculate a reciprocal - used for gamma values. This returns
* 0 if the argument is 0 in order to maintain an undefined value;
* there are no warnings.
*/
-PNG_INTERNAL_FUNCTION(png_fixed_point,png_reciprocal,(png_fixed_point a),
+PNG_INTERNAL_FUNCTION(png_fixed_point, png_reciprocal,
+ (png_fixed_point a),
PNG_EMPTY);
+#endif
#ifdef PNG_READ_GAMMA_SUPPORTED
/* The same but gives a reciprocal of the product of two fixed point
* values. Accuracy is suitable for gamma calculations but this is
* not exact - use png_muldiv for that. Only required at present on read.
*/
-PNG_INTERNAL_FUNCTION(png_fixed_point,png_reciprocal2,(png_fixed_point a,
- png_fixed_point b),PNG_EMPTY);
-#endif
+PNG_INTERNAL_FUNCTION(png_fixed_point, png_reciprocal2,
+ (png_fixed_point a, png_fixed_point b),
+ PNG_EMPTY);
/* Return true if the gamma value is significantly different from 1.0 */
-PNG_INTERNAL_FUNCTION(int,png_gamma_significant,(png_fixed_point gamma_value),
+PNG_INTERNAL_FUNCTION(int, png_gamma_significant,
+ (png_fixed_point gamma_value),
+ PNG_EMPTY);
+
+/* PNGv3: 'resolve' the file gamma according to the new PNGv3 rules for colour
+ * space information.
+ *
+ * NOTE: this uses precisely those chunks that libpng supports. For example it
+ * doesn't use iCCP and it can only use cICP for known and manageable
+ * transforms. For this reason a gamma specified by png_set_gamma always takes
+ * precedence.
+ */
+PNG_INTERNAL_FUNCTION(png_fixed_point, png_resolve_file_gamma,
+ (png_const_structrp png_ptr),
PNG_EMPTY);
-#endif
-#ifdef PNG_READ_GAMMA_SUPPORTED
/* Internal fixed point gamma correction. These APIs are called as
* required to convert single values - they don't need to be fast,
* they are not used when processing image pixel values.
@@ -2016,21 +2240,45 @@ PNG_INTERNAL_FUNCTION(int,png_gamma_significant,(png_fixed_point gamma_value),
* While the input is an 'unsigned' value it must actually be the
* correct bit value - 0..255 or 0..65535 as required.
*/
-PNG_INTERNAL_FUNCTION(png_uint_16,png_gamma_correct,(png_structrp png_ptr,
- unsigned int value, png_fixed_point gamma_value),PNG_EMPTY);
-PNG_INTERNAL_FUNCTION(png_uint_16,png_gamma_16bit_correct,(unsigned int value,
- png_fixed_point gamma_value),PNG_EMPTY);
-PNG_INTERNAL_FUNCTION(png_byte,png_gamma_8bit_correct,(unsigned int value,
- png_fixed_point gamma_value),PNG_EMPTY);
-PNG_INTERNAL_FUNCTION(void,png_destroy_gamma_table,(png_structrp png_ptr),
+PNG_INTERNAL_FUNCTION(png_uint_16, png_gamma_correct,
+ (png_structrp png_ptr, unsigned int value, png_fixed_point gamma_value),
+ PNG_EMPTY);
+PNG_INTERNAL_FUNCTION(png_uint_16, png_gamma_16bit_correct,
+ (unsigned int value, png_fixed_point gamma_value),
+ PNG_EMPTY);
+PNG_INTERNAL_FUNCTION(png_byte, png_gamma_8bit_correct,
+ (unsigned int value, png_fixed_point gamma_value),
+ PNG_EMPTY);
+PNG_INTERNAL_FUNCTION(void, png_destroy_gamma_table,
+ (png_structrp png_ptr),
+ PNG_EMPTY);
+PNG_INTERNAL_FUNCTION(void, png_build_gamma_table,
+ (png_structrp png_ptr, int bit_depth),
+ PNG_EMPTY);
+#endif /* READ_GAMMA */
+
+#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED
+/* Set the RGB coefficients if not already set by png_set_rgb_to_gray */
+PNG_INTERNAL_FUNCTION(void, png_set_rgb_coefficients,
+ (png_structrp png_ptr),
+ PNG_EMPTY);
+#endif
+
+#if defined(PNG_cHRM_SUPPORTED) || defined(PNG_READ_RGB_TO_GRAY_SUPPORTED)
+PNG_INTERNAL_FUNCTION(int, png_XYZ_from_xy,
+ (png_XYZ *XYZ, const png_xy *xy),
+ PNG_EMPTY);
+#endif /* cHRM || READ_RGB_TO_GRAY */
+
+#ifdef PNG_COLORSPACE_SUPPORTED
+PNG_INTERNAL_FUNCTION(int, png_xy_from_XYZ,
+ (png_xy *xy, const png_XYZ *XYZ),
PNG_EMPTY);
-PNG_INTERNAL_FUNCTION(void,png_build_gamma_table,(png_structrp png_ptr,
- int bit_depth),PNG_EMPTY);
#endif
/* SIMPLIFIED READ/WRITE SUPPORT */
#if defined(PNG_SIMPLIFIED_READ_SUPPORTED) ||\
- defined(PNG_SIMPLIFIED_WRITE_SUPPORTED)
+ defined(PNG_SIMPLIFIED_WRITE_SUPPORTED)
/* The internal structure that png_image::opaque points to. */
typedef struct png_control
{
@@ -2058,28 +2306,34 @@ typedef struct png_control
* errors that might occur. Returns true on success, false on failure (either
* of the function or as a result of a png_error.)
*/
-PNG_INTERNAL_CALLBACK(void,png_safe_error,(png_structp png_ptr,
- png_const_charp error_message),PNG_NORETURN);
+PNG_INTERNAL_CALLBACK(void, png_safe_error,
+ (png_structp png_ptr, png_const_charp error_message),
+ PNG_NORETURN);
#ifdef PNG_WARNINGS_SUPPORTED
-PNG_INTERNAL_CALLBACK(void,png_safe_warning,(png_structp png_ptr,
- png_const_charp warning_message),PNG_EMPTY);
+PNG_INTERNAL_CALLBACK(void, png_safe_warning,
+ (png_structp png_ptr, png_const_charp warning_message),
+ PNG_EMPTY);
#else
# define png_safe_warning 0/*dummy argument*/
#endif
-PNG_INTERNAL_FUNCTION(int,png_safe_execute,(png_imagep image,
- int (*function)(png_voidp), png_voidp arg),PNG_EMPTY);
+PNG_INTERNAL_FUNCTION(int, png_safe_execute,
+ (png_imagep image, int (*function)(png_voidp), png_voidp arg),
+ PNG_EMPTY);
/* Utility to log an error; this also cleans up the png_image; the function
* always returns 0 (false).
*/
-PNG_INTERNAL_FUNCTION(int,png_image_error,(png_imagep image,
- png_const_charp error_message),PNG_EMPTY);
+PNG_INTERNAL_FUNCTION(int, png_image_error,
+ (png_imagep image, png_const_charp error_message),
+ PNG_EMPTY);
#ifndef PNG_SIMPLIFIED_READ_SUPPORTED
/* png_image_free is used by the write code but not exported */
-PNG_INTERNAL_FUNCTION(void, png_image_free, (png_imagep image), PNG_EMPTY);
+PNG_INTERNAL_FUNCTION(void, png_image_free,
+ (png_imagep image),
+ PNG_EMPTY);
#endif /* !SIMPLIFIED_READ */
#endif /* SIMPLIFIED READ/WRITE */
@@ -2090,8 +2344,9 @@ PNG_INTERNAL_FUNCTION(void, png_image_free, (png_imagep image), PNG_EMPTY);
* the generic code is used.
*/
#ifdef PNG_FILTER_OPTIMIZATIONS
-PNG_INTERNAL_FUNCTION(void, PNG_FILTER_OPTIMIZATIONS, (png_structp png_ptr,
- unsigned int bpp), PNG_EMPTY);
+PNG_INTERNAL_FUNCTION(void, PNG_FILTER_OPTIMIZATIONS,
+ (png_structp png_ptr, unsigned int bpp),
+ PNG_EMPTY);
/* Just declare the optimization that will be used */
#else
/* List *all* the possible optimizations here - this branch is required if
@@ -2100,22 +2355,44 @@ PNG_INTERNAL_FUNCTION(void, PNG_FILTER_OPTIMIZATIONS, (png_structp png_ptr,
*/
# if PNG_ARM_NEON_OPT > 0
PNG_INTERNAL_FUNCTION(void, png_init_filter_functions_neon,
- (png_structp png_ptr, unsigned int bpp), PNG_EMPTY);
+ (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,
- (png_structp png_ptr, unsigned int bpp), PNG_EMPTY);
+#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);
+ (png_structp png_ptr, unsigned int bpp),
+ PNG_EMPTY);
# endif
#endif
-PNG_INTERNAL_FUNCTION(png_uint_32, png_check_keyword, (png_structrp png_ptr,
- png_const_charp key, png_bytep new_key), PNG_EMPTY);
+#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
+
+# if PNG_RISCV_RVV_IMPLEMENTATION == 1
+PNG_INTERNAL_FUNCTION(void, png_init_filter_functions_rvv,
+ (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);
#if PNG_ARM_NEON_IMPLEMENTATION == 1
PNG_INTERNAL_FUNCTION(void,
@@ -2149,4 +2426,3 @@ PNG_INTERNAL_FUNCTION(int,
#endif
#endif /* PNG_VERSION_INFO_ONLY */
-#endif /* PNGPRIV_H */
diff --git a/src/libs/Irrlicht/irrlicht-svn/source/Irrlicht/libpng/pngread.c b/src/libs/Irrlicht/irrlicht-svn/source/Irrlicht/libpng/pngread.c
index de5a3a7f..fff3c213 100644
--- a/src/libs/Irrlicht/irrlicht-svn/source/Irrlicht/libpng/pngread.c
+++ b/src/libs/Irrlicht/irrlicht-svn/source/Irrlicht/libpng/pngread.c
@@ -1,7 +1,6 @@
-
/* pngread.c - read a PNG file
*
- * Copyright (c) 2018-2019 Cosmin Truta
+ * Copyright (c) 2018-2026 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.
@@ -24,7 +23,8 @@
/* Create a PNG structure for reading, and allocate any memory needed. */
PNG_FUNCTION(png_structp,PNGAPI
png_create_read_struct,(png_const_charp user_png_ver, png_voidp error_ptr,
- png_error_ptr error_fn, png_error_ptr warn_fn),PNG_ALLOCATED)
+ png_error_ptr error_fn, png_error_ptr warn_fn),
+ PNG_ALLOCATED)
{
#ifndef PNG_USER_MEM_SUPPORTED
png_structp png_ptr = png_create_png_struct(user_png_ver, error_ptr,
@@ -40,7 +40,8 @@ png_create_read_struct,(png_const_charp user_png_ver, png_voidp error_ptr,
PNG_FUNCTION(png_structp,PNGAPI
png_create_read_struct_2,(png_const_charp user_png_ver, png_voidp error_ptr,
png_error_ptr error_fn, png_error_ptr warn_fn, png_voidp mem_ptr,
- png_malloc_ptr malloc_fn, png_free_ptr free_fn),PNG_ALLOCATED)
+ png_malloc_ptr malloc_fn, png_free_ptr free_fn),
+ PNG_ALLOCATED)
{
png_structp png_ptr = png_create_png_struct(user_png_ver, error_ptr,
error_fn, warn_fn, mem_ptr, malloc_fn, free_fn);
@@ -132,14 +133,11 @@ png_read_info(png_structrp png_ptr, png_inforp info_ptr)
png_ptr->mode |= PNG_AFTER_IDAT;
}
- /* This should be a binary subdivision search or a hash for
- * matching the chunk name rather than a linear search.
- */
if (chunk_name == png_IHDR)
- png_handle_IHDR(png_ptr, info_ptr, length);
+ png_handle_chunk(png_ptr, info_ptr, length);
else if (chunk_name == png_IEND)
- png_handle_IEND(png_ptr, info_ptr, length);
+ png_handle_chunk(png_ptr, info_ptr, length);
#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED
else if ((keep = png_chunk_unknown_handling(png_ptr, chunk_name)) != 0)
@@ -156,8 +154,6 @@ png_read_info(png_structrp png_ptr, png_inforp info_ptr)
}
}
#endif
- else if (chunk_name == png_PLTE)
- png_handle_PLTE(png_ptr, info_ptr, length);
else if (chunk_name == png_IDAT)
{
@@ -165,99 +161,8 @@ png_read_info(png_structrp png_ptr, png_inforp info_ptr)
break;
}
-#ifdef PNG_READ_bKGD_SUPPORTED
- else if (chunk_name == png_bKGD)
- png_handle_bKGD(png_ptr, info_ptr, length);
-#endif
-
-#ifdef PNG_READ_cHRM_SUPPORTED
- else if (chunk_name == png_cHRM)
- png_handle_cHRM(png_ptr, info_ptr, length);
-#endif
-
-#ifdef PNG_READ_eXIf_SUPPORTED
- else if (chunk_name == png_eXIf)
- png_handle_eXIf(png_ptr, info_ptr, length);
-#endif
-
-#ifdef PNG_READ_gAMA_SUPPORTED
- else if (chunk_name == png_gAMA)
- png_handle_gAMA(png_ptr, info_ptr, length);
-#endif
-
-#ifdef PNG_READ_hIST_SUPPORTED
- else if (chunk_name == png_hIST)
- png_handle_hIST(png_ptr, info_ptr, length);
-#endif
-
-#ifdef PNG_READ_oFFs_SUPPORTED
- else if (chunk_name == png_oFFs)
- png_handle_oFFs(png_ptr, info_ptr, length);
-#endif
-
-#ifdef PNG_READ_pCAL_SUPPORTED
- else if (chunk_name == png_pCAL)
- png_handle_pCAL(png_ptr, info_ptr, length);
-#endif
-
-#ifdef PNG_READ_sCAL_SUPPORTED
- else if (chunk_name == png_sCAL)
- png_handle_sCAL(png_ptr, info_ptr, length);
-#endif
-
-#ifdef PNG_READ_pHYs_SUPPORTED
- else if (chunk_name == png_pHYs)
- png_handle_pHYs(png_ptr, info_ptr, length);
-#endif
-
-#ifdef PNG_READ_sBIT_SUPPORTED
- else if (chunk_name == png_sBIT)
- png_handle_sBIT(png_ptr, info_ptr, length);
-#endif
-
-#ifdef PNG_READ_sRGB_SUPPORTED
- else if (chunk_name == png_sRGB)
- png_handle_sRGB(png_ptr, info_ptr, length);
-#endif
-
-#ifdef PNG_READ_iCCP_SUPPORTED
- else if (chunk_name == png_iCCP)
- png_handle_iCCP(png_ptr, info_ptr, length);
-#endif
-
-#ifdef PNG_READ_sPLT_SUPPORTED
- else if (chunk_name == png_sPLT)
- png_handle_sPLT(png_ptr, info_ptr, length);
-#endif
-
-#ifdef PNG_READ_tEXt_SUPPORTED
- else if (chunk_name == png_tEXt)
- png_handle_tEXt(png_ptr, info_ptr, length);
-#endif
-
-#ifdef PNG_READ_tIME_SUPPORTED
- else if (chunk_name == png_tIME)
- png_handle_tIME(png_ptr, info_ptr, length);
-#endif
-
-#ifdef PNG_READ_tRNS_SUPPORTED
- else if (chunk_name == png_tRNS)
- png_handle_tRNS(png_ptr, info_ptr, length);
-#endif
-
-#ifdef PNG_READ_zTXt_SUPPORTED
- else if (chunk_name == png_zTXt)
- png_handle_zTXt(png_ptr, info_ptr, length);
-#endif
-
-#ifdef PNG_READ_iTXt_SUPPORTED
- else if (chunk_name == png_iTXt)
- png_handle_iTXt(png_ptr, info_ptr, length);
-#endif
-
else
- png_handle_unknown(png_ptr, info_ptr, length,
- PNG_HANDLE_CHUNK_AS_DEFAULT);
+ png_handle_chunk(png_ptr, info_ptr, length);
}
}
#endif /* SEQUENTIAL_READ */
@@ -568,7 +473,11 @@ 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
+# ifdef PNG_CHECK_FOR_INVALID_INDEX_SUPPORTED
+ || png_ptr->num_palette_max >= 0
+# endif
+ )
png_do_read_transformations(png_ptr, &row_info);
#endif
@@ -612,7 +521,6 @@ png_read_row(png_structrp png_ptr, png_bytep row, png_bytep dsp_row)
if (png_ptr->read_row_fn != NULL)
(*(png_ptr->read_row_fn))(png_ptr, png_ptr->row_number, png_ptr->pass);
-
}
#endif /* SEQUENTIAL_READ */
@@ -785,7 +693,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
@@ -795,13 +703,18 @@ png_read_end(png_structrp png_ptr, png_inforp info_ptr)
png_uint_32 chunk_name = png_ptr->chunk_name;
if (chunk_name != png_IDAT)
- png_ptr->mode |= PNG_HAVE_CHUNK_AFTER_IDAT;
+ {
+ /* These flags must be set consistently for all non-IDAT chunks,
+ * including the unknown chunks.
+ */
+ png_ptr->mode |= PNG_HAVE_CHUNK_AFTER_IDAT | PNG_AFTER_IDAT;
+ }
if (chunk_name == png_IEND)
- png_handle_IEND(png_ptr, info_ptr, length);
+ png_handle_chunk(png_ptr, info_ptr, length);
else if (chunk_name == png_IHDR)
- png_handle_IHDR(png_ptr, info_ptr, length);
+ png_handle_chunk(png_ptr, info_ptr, length);
else if (info_ptr == NULL)
png_crc_finish(png_ptr, length);
@@ -835,102 +748,9 @@ png_read_end(png_structrp png_ptr, png_inforp info_ptr)
png_crc_finish(png_ptr, length);
}
- else if (chunk_name == png_PLTE)
- png_handle_PLTE(png_ptr, info_ptr, length);
-
-#ifdef PNG_READ_bKGD_SUPPORTED
- else if (chunk_name == png_bKGD)
- png_handle_bKGD(png_ptr, info_ptr, length);
-#endif
-
-#ifdef PNG_READ_cHRM_SUPPORTED
- else if (chunk_name == png_cHRM)
- png_handle_cHRM(png_ptr, info_ptr, length);
-#endif
-
-#ifdef PNG_READ_eXIf_SUPPORTED
- else if (chunk_name == png_eXIf)
- png_handle_eXIf(png_ptr, info_ptr, length);
-#endif
-
-#ifdef PNG_READ_gAMA_SUPPORTED
- else if (chunk_name == png_gAMA)
- png_handle_gAMA(png_ptr, info_ptr, length);
-#endif
-
-#ifdef PNG_READ_hIST_SUPPORTED
- else if (chunk_name == png_hIST)
- png_handle_hIST(png_ptr, info_ptr, length);
-#endif
-
-#ifdef PNG_READ_oFFs_SUPPORTED
- else if (chunk_name == png_oFFs)
- png_handle_oFFs(png_ptr, info_ptr, length);
-#endif
-
-#ifdef PNG_READ_pCAL_SUPPORTED
- else if (chunk_name == png_pCAL)
- png_handle_pCAL(png_ptr, info_ptr, length);
-#endif
-
-#ifdef PNG_READ_sCAL_SUPPORTED
- else if (chunk_name == png_sCAL)
- png_handle_sCAL(png_ptr, info_ptr, length);
-#endif
-
-#ifdef PNG_READ_pHYs_SUPPORTED
- else if (chunk_name == png_pHYs)
- png_handle_pHYs(png_ptr, info_ptr, length);
-#endif
-
-#ifdef PNG_READ_sBIT_SUPPORTED
- else if (chunk_name == png_sBIT)
- png_handle_sBIT(png_ptr, info_ptr, length);
-#endif
-
-#ifdef PNG_READ_sRGB_SUPPORTED
- else if (chunk_name == png_sRGB)
- png_handle_sRGB(png_ptr, info_ptr, length);
-#endif
-
-#ifdef PNG_READ_iCCP_SUPPORTED
- else if (chunk_name == png_iCCP)
- png_handle_iCCP(png_ptr, info_ptr, length);
-#endif
-
-#ifdef PNG_READ_sPLT_SUPPORTED
- else if (chunk_name == png_sPLT)
- png_handle_sPLT(png_ptr, info_ptr, length);
-#endif
-
-#ifdef PNG_READ_tEXt_SUPPORTED
- else if (chunk_name == png_tEXt)
- png_handle_tEXt(png_ptr, info_ptr, length);
-#endif
-
-#ifdef PNG_READ_tIME_SUPPORTED
- else if (chunk_name == png_tIME)
- png_handle_tIME(png_ptr, info_ptr, length);
-#endif
-
-#ifdef PNG_READ_tRNS_SUPPORTED
- else if (chunk_name == png_tRNS)
- png_handle_tRNS(png_ptr, info_ptr, length);
-#endif
-
-#ifdef PNG_READ_zTXt_SUPPORTED
- else if (chunk_name == png_zTXt)
- png_handle_zTXt(png_ptr, info_ptr, length);
-#endif
-
-#ifdef PNG_READ_iTXt_SUPPORTED
- else if (chunk_name == png_iTXt)
- png_handle_iTXt(png_ptr, info_ptr, length);
-#endif
else
- png_handle_unknown(png_ptr, info_ptr, length,
- PNG_HANDLE_CHUNK_AS_DEFAULT);
+ png_handle_chunk(png_ptr, info_ptr, length);
} while ((png_ptr->mode & PNG_HAVE_IEND) == 0);
}
#endif /* SEQUENTIAL_READ */
@@ -995,7 +815,8 @@ png_read_destroy(png_structrp png_ptr)
#endif
#if defined(PNG_READ_EXPAND_SUPPORTED) && \
- defined(PNG_ARM_NEON_IMPLEMENTATION)
+ (defined(PNG_ARM_NEON_IMPLEMENTATION) || \
+ defined(PNG_RISCV_RVV_IMPLEMENTATION))
png_free(png_ptr, png_ptr->riffled_palette);
png_ptr->riffled_palette = NULL;
#endif
@@ -1047,8 +868,10 @@ png_set_read_status_fn(png_structrp png_ptr, png_read_status_ptr read_row_fn)
#ifdef PNG_INFO_IMAGE_SUPPORTED
void PNGAPI
png_read_png(png_structrp png_ptr, png_inforp info_ptr,
- int transforms, voidp params)
+ int transforms, png_voidp params)
{
+ png_debug(1, "in png_read_png");
+
if (png_ptr == NULL || info_ptr == NULL)
return;
@@ -1282,19 +1105,20 @@ png_read_png(png_structrp png_ptr, png_inforp info_ptr,
typedef struct
{
- /* Arguments: */
+ /* Arguments */
png_imagep image;
- png_voidp buffer;
+ png_voidp buffer;
png_int_32 row_stride;
- png_voidp colormap;
+ png_voidp colormap;
png_const_colorp background;
- /* Local variables: */
- png_voidp local_row;
- png_voidp first_row;
- ptrdiff_t row_bytes; /* step between rows */
- int file_encoding; /* E_ values above */
- png_fixed_point gamma_to_linear; /* For P_FILE, reciprocal of gamma */
- int colormap_processing; /* PNG_CMAP_ values above */
+
+ /* Instance variables */
+ png_voidp local_row;
+ png_voidp first_row;
+ ptrdiff_t row_step; /* step between rows */
+ int file_encoding; /* E_ values above */
+ png_fixed_point gamma_to_linear; /* For P_FILE, reciprocal of gamma */
+ int colormap_processing; /* PNG_CMAP_ values above */
} png_image_read_control;
/* Do all the *safe* initialization - 'safe' means that png_error won't be
@@ -1379,6 +1203,31 @@ png_image_format(png_structrp png_ptr)
return format;
}
+static int
+chromaticities_match_sRGB(const png_xy *xy)
+{
+# define sRGB_TOLERANCE 1000
+ static const png_xy sRGB_xy = /* From ITU-R BT.709-3 */
+ {
+ /* color x y */
+ /* red */ 64000, 33000,
+ /* green */ 30000, 60000,
+ /* blue */ 15000, 6000,
+ /* white */ 31270, 32900
+ };
+
+ if (PNG_OUT_OF_RANGE(xy->whitex, sRGB_xy.whitex,sRGB_TOLERANCE) ||
+ PNG_OUT_OF_RANGE(xy->whitey, sRGB_xy.whitey,sRGB_TOLERANCE) ||
+ PNG_OUT_OF_RANGE(xy->redx, sRGB_xy.redx, sRGB_TOLERANCE) ||
+ PNG_OUT_OF_RANGE(xy->redy, sRGB_xy.redy, sRGB_TOLERANCE) ||
+ PNG_OUT_OF_RANGE(xy->greenx, sRGB_xy.greenx,sRGB_TOLERANCE) ||
+ PNG_OUT_OF_RANGE(xy->greeny, sRGB_xy.greeny,sRGB_TOLERANCE) ||
+ PNG_OUT_OF_RANGE(xy->bluex, sRGB_xy.bluex, sRGB_TOLERANCE) ||
+ PNG_OUT_OF_RANGE(xy->bluey, sRGB_xy.bluey, sRGB_TOLERANCE))
+ return 0;
+ return 1;
+}
+
/* Is the given gamma significantly different from sRGB? The test is the same
* one used in pngrtran.c when deciding whether to do gamma correction. The
* arithmetic optimizes the division by using the fact that the inverse of the
@@ -1387,22 +1236,44 @@ png_image_format(png_structrp png_ptr)
static int
png_gamma_not_sRGB(png_fixed_point g)
{
- if (g < PNG_FP_1)
- {
- /* An uninitialized gamma is assumed to be sRGB for the simplified API. */
- if (g == 0)
- return 0;
-
- return png_gamma_significant((g * 11 + 2)/5 /* i.e. *2.2, rounded */);
- }
+ /* 1.6.47: use the same sanity checks as used in pngrtran.c */
+ if (g < PNG_LIB_GAMMA_MIN || g > PNG_LIB_GAMMA_MAX)
+ return 0; /* Includes the uninitialized value 0 */
- return 1;
+ return png_gamma_significant((g * 11 + 2)/5 /* i.e. *2.2, rounded */);
}
/* Do the main body of a 'png_image_begin_read' function; read the PNG file
* header and fill in all the information. This is executed in a safe context,
* unlike the init routine above.
*/
+static int
+png_image_is_not_sRGB(png_const_structrp png_ptr)
+{
+ /* Does the colorspace **not** match sRGB? The flag is only set if the
+ * answer can be determined reliably.
+ *
+ * png_struct::chromaticities always exists since the simplified API
+ * requires rgb-to-gray. The mDCV, cICP and cHRM chunks may all set it to
+ * a non-sRGB value, so it needs to be checked but **only** if one of
+ * those chunks occured in the file.
+ */
+ /* Highest priority: check to be safe. */
+ if (png_has_chunk(png_ptr, cICP) || png_has_chunk(png_ptr, mDCV))
+ return !chromaticities_match_sRGB(&png_ptr->chromaticities);
+
+ /* If the image is marked as sRGB then it is... */
+ if (png_has_chunk(png_ptr, sRGB))
+ return 0;
+
+ /* Last stop: cHRM, must check: */
+ if (png_has_chunk(png_ptr, cHRM))
+ return !chromaticities_match_sRGB(&png_ptr->chromaticities);
+
+ /* Else default to sRGB */
+ return 0;
+}
+
static int
png_image_read_header(png_voidp argument)
{
@@ -1424,17 +1295,13 @@ png_image_read_header(png_voidp argument)
image->format = format;
-#ifdef PNG_COLORSPACE_SUPPORTED
- /* Does the colorspace match sRGB? If there is no color endpoint
- * (colorant) information assume yes, otherwise require the
- * 'ENDPOINTS_MATCHP_sRGB' colorspace flag to have been set. If the
- * colorspace has been determined to be invalid ignore it.
+ /* Greyscale images don't (typically) have colour space information and
+ * using it is pretty much impossible, so use sRGB for grayscale (it
+ * doesn't matter r==g==b so the transform is irrelevant.)
*/
- if ((format & PNG_FORMAT_FLAG_COLOR) != 0 && ((png_ptr->colorspace.flags
- & (PNG_COLORSPACE_HAVE_ENDPOINTS|PNG_COLORSPACE_ENDPOINTS_MATCH_sRGB|
- PNG_COLORSPACE_INVALID)) == PNG_COLORSPACE_HAVE_ENDPOINTS))
+ if ((format & PNG_FORMAT_FLAG_COLOR) != 0 &&
+ png_image_is_not_sRGB(png_ptr))
image->flags |= PNG_IMAGE_FLAG_COLORSPACE_NOT_sRGB;
-#endif
}
/* We need the maximum number of entries regardless of the format the
@@ -1469,7 +1336,7 @@ png_image_read_header(png_voidp argument)
#ifdef PNG_STDIO_SUPPORTED
int PNGAPI
-png_image_begin_read_from_stdio(png_imagep image, FILE* file)
+png_image_begin_read_from_stdio(png_imagep image, FILE *file)
{
if (image != NULL && image->version == PNG_IMAGE_VERSION)
{
@@ -1622,21 +1489,18 @@ png_image_skip_unused_chunks(png_structrp png_ptr)
* potential vulnerability to security problems in the unused chunks.
*
* At present the iCCP chunk data isn't used, so iCCP chunk can be ignored
- * too. This allows the simplified API to be compiled without iCCP support,
- * however if the support is there the chunk is still checked to detect
- * errors (which are unfortunately quite common.)
+ * too. This allows the simplified API to be compiled without iCCP support.
*/
{
static const png_byte chunks_to_process[] = {
98, 75, 71, 68, '\0', /* bKGD */
99, 72, 82, 77, '\0', /* cHRM */
+ 99, 73, 67, 80, '\0', /* cICP */
103, 65, 77, 65, '\0', /* gAMA */
-# ifdef PNG_READ_iCCP_SUPPORTED
- 105, 67, 67, 80, '\0', /* iCCP */
-# endif
+ 109, 68, 67, 86, '\0', /* mDCV */
115, 66, 73, 84, '\0', /* sBIT */
115, 82, 71, 66, '\0', /* sRGB */
- };
+ };
/* Ignore unknown chunks and all other chunks except for the
* IHDR, PLTE, tRNS, IDAT, and IEND chunks.
@@ -1665,7 +1529,15 @@ png_image_skip_unused_chunks(png_structrp png_ptr)
static void
set_file_encoding(png_image_read_control *display)
{
- png_fixed_point g = display->image->opaque->png_ptr->colorspace.gamma;
+ png_structrp png_ptr = display->image->opaque->png_ptr;
+ png_fixed_point g = png_resolve_file_gamma(png_ptr);
+
+ /* PNGv3: the result may be 0 however the 'default_gamma' should have been
+ * set before this is called so zero is an error:
+ */
+ if (g == 0)
+ png_error(png_ptr, "internal: default gamma not set");
+
if (png_gamma_significant(g) != 0)
{
if (png_gamma_not_sRGB(g) != 0)
@@ -2153,24 +2025,18 @@ png_image_read_colormap(png_voidp argument)
/* Default the input file gamma if required - this is necessary because
* libpng assumes that if no gamma information is present the data is in the
* output format, but the simplified API deduces the gamma from the input
- * format.
+ * format. The 'default' gamma value is also set by png_set_alpha_mode, but
+ * this is happening before any such call, so:
+ *
+ * TODO: should be an internal API and all this code should be copied into a
+ * single common gamma+colorspace file.
*/
- if ((png_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_GAMMA) == 0)
- {
- /* Do this directly, not using the png_colorspace functions, to ensure
- * that it happens even if the colorspace is invalid (though probably if
- * it is the setting will be ignored) Note that the same thing can be
- * achieved at the application interface with png_set_gAMA.
- */
- if (png_ptr->bit_depth == 16 &&
- (image->flags & PNG_IMAGE_FLAG_16BIT_sRGB) == 0)
- png_ptr->colorspace.gamma = PNG_GAMMA_LINEAR;
-
- else
- png_ptr->colorspace.gamma = PNG_GAMMA_sRGB_INVERSE;
+ if (png_ptr->bit_depth == 16 &&
+ (image->flags & PNG_IMAGE_FLAG_16BIT_sRGB) == 0)
+ png_ptr->default_gamma = PNG_GAMMA_LINEAR;
- png_ptr->colorspace.flags |= PNG_COLORSPACE_HAVE_GAMMA;
- }
+ else
+ png_ptr->default_gamma = PNG_GAMMA_sRGB_INVERSE;
/* Decide what to do based on the PNG color type of the input data. The
* utility function png_create_colormap_entry deals with most aspects of the
@@ -2548,6 +2414,8 @@ png_image_read_colormap(png_voidp argument)
else
{
+ const png_fixed_point gamma = png_resolve_file_gamma(png_ptr);
+
/* Either the input or the output has no alpha channel, so there
* will be no non-opaque pixels in the color-map; it will just be
* grayscale.
@@ -2562,10 +2430,13 @@ png_image_read_colormap(png_voidp argument)
* this case and doing it in the palette; this will result in
* duplicate palette entries, but that's better than the
* alternative of double gamma correction.
+ *
+ * NOTE: PNGv3: check the resolved result of all the potentially
+ * different colour space chunks.
*/
if ((png_ptr->color_type == PNG_COLOR_TYPE_RGB_ALPHA ||
png_ptr->num_trans > 0) &&
- png_gamma_not_sRGB(png_ptr->colorspace.gamma) != 0)
+ png_gamma_not_sRGB(gamma) != 0)
{
cmap_entries = (unsigned int)make_gray_file_colormap(display);
data_encoding = P_FILE;
@@ -2597,8 +2468,8 @@ png_image_read_colormap(png_voidp argument)
if (output_encoding == P_sRGB)
gray = png_sRGB_table[gray]; /* now P_LINEAR */
- gray = PNG_DIV257(png_gamma_16bit_correct(gray,
- png_ptr->colorspace.gamma)); /* now P_FILE */
+ gray = PNG_DIV257(png_gamma_16bit_correct(gray, gamma));
+ /* now P_FILE */
/* And make sure the corresponding palette entry contains
* exactly the required sRGB value.
@@ -2968,17 +2839,17 @@ png_image_read_and_map(png_voidp argument)
}
{
- png_uint_32 height = image->height;
- png_uint_32 width = image->width;
- int proc = display->colormap_processing;
- png_bytep first_row = png_voidcast(png_bytep, display->first_row);
- ptrdiff_t step_row = display->row_bytes;
+ png_uint_32 height = image->height;
+ png_uint_32 width = image->width;
+ int proc = display->colormap_processing;
+ png_bytep first_row = png_voidcast(png_bytep, display->first_row);
+ ptrdiff_t row_step = display->row_step;
int pass;
for (pass = 0; pass < passes; ++pass)
{
- unsigned int startx, stepx, stepy;
- png_uint_32 y;
+ unsigned int startx, stepx, stepy;
+ png_uint_32 y;
if (png_ptr->interlaced == PNG_INTERLACE_ADAM7)
{
@@ -3002,7 +2873,7 @@ png_image_read_and_map(png_voidp argument)
for (; ylocal_row);
- png_bytep outrow = first_row + y * step_row;
+ png_bytep outrow = first_row + y * row_step;
png_const_bytep end_row = outrow + width;
/* Read read the libpng data into the temporary buffer. */
@@ -3211,20 +3082,20 @@ png_image_read_colormapped(png_voidp argument)
*/
{
png_voidp first_row = display->buffer;
- ptrdiff_t row_bytes = display->row_stride;
+ ptrdiff_t row_step = display->row_stride;
- /* The following expression is designed to work correctly whether it gives
- * a signed or an unsigned result.
+ /* The following adjustment is to ensure that calculations are correct,
+ * regardless whether row_step is positive or negative.
*/
- if (row_bytes < 0)
+ if (row_step < 0)
{
char *ptr = png_voidcast(char*, first_row);
- ptr += (image->height-1) * (-row_bytes);
+ ptr += (image->height-1) * (-row_step);
first_row = png_voidcast(png_voidp, ptr);
}
display->first_row = first_row;
- display->row_bytes = row_bytes;
+ display->row_step = row_step;
}
if (passes == 0)
@@ -3242,17 +3113,17 @@ png_image_read_colormapped(png_voidp argument)
else
{
- png_alloc_size_t row_bytes = (png_alloc_size_t)display->row_bytes;
+ ptrdiff_t row_step = display->row_step;
while (--passes >= 0)
{
- png_uint_32 y = image->height;
- png_bytep row = png_voidcast(png_bytep, display->first_row);
+ png_uint_32 y = image->height;
+ png_bytep row = png_voidcast(png_bytep, display->first_row);
for (; y > 0; --y)
{
png_read_row(png_ptr, row, NULL);
- row += row_bytes;
+ row += row_step;
}
}
@@ -3260,6 +3131,61 @@ png_image_read_colormapped(png_voidp argument)
}
}
+/* Row reading for interlaced 16-to-8 bit depth conversion with local buffer. */
+static int
+png_image_read_direct_scaled(png_voidp argument)
+{
+ png_image_read_control *display = png_voidcast(png_image_read_control*,
+ argument);
+ png_imagep image = display->image;
+ png_structrp png_ptr = image->opaque->png_ptr;
+ png_inforp info_ptr = image->opaque->info_ptr;
+ png_bytep local_row = png_voidcast(png_bytep, display->local_row);
+ png_bytep first_row = png_voidcast(png_bytep, display->first_row);
+ ptrdiff_t row_step = display->row_step;
+ size_t row_bytes = png_get_rowbytes(png_ptr, info_ptr);
+ int passes;
+
+ /* Handle interlacing. */
+ switch (png_ptr->interlaced)
+ {
+ case PNG_INTERLACE_NONE:
+ passes = 1;
+ break;
+
+ case PNG_INTERLACE_ADAM7:
+ passes = PNG_INTERLACE_ADAM7_PASSES;
+ break;
+
+ default:
+ png_error(png_ptr, "unknown interlace type");
+ }
+
+ /* Read each pass using local_row as intermediate buffer. */
+ while (--passes >= 0)
+ {
+ png_uint_32 y = image->height;
+ png_bytep output_row = first_row;
+
+ for (; y > 0; --y)
+ {
+ /* Read into local_row (gets transformed 8-bit data). */
+ png_read_row(png_ptr, local_row, NULL);
+
+ /* Copy from local_row to user buffer.
+ * Use row_bytes (i.e. the actual size in bytes of the row data) for
+ * copying into output_row. Use row_step for advancing output_row,
+ * to respect the caller's stride for padding or negative (bottom-up)
+ * layouts.
+ */
+ memcpy(output_row, local_row, row_bytes);
+ output_row += row_step;
+ }
+ }
+
+ return 1;
+}
+
/* Just the row reading part of png_image_read. */
static int
png_image_read_composite(png_voidp argument)
@@ -3285,17 +3211,18 @@ png_image_read_composite(png_voidp argument)
}
{
- png_uint_32 height = image->height;
- png_uint_32 width = image->width;
- ptrdiff_t step_row = display->row_bytes;
+ png_uint_32 height = image->height;
+ png_uint_32 width = image->width;
+ ptrdiff_t row_step = display->row_step;
unsigned int channels =
(image->format & PNG_FORMAT_FLAG_COLOR) != 0 ? 3 : 1;
+ int optimize_alpha = (png_ptr->flags & PNG_FLAG_OPTIMIZE_ALPHA) != 0;
int pass;
for (pass = 0; pass < passes; ++pass)
{
- unsigned int startx, stepx, stepy;
- png_uint_32 y;
+ unsigned int startx, stepx, stepy;
+ png_uint_32 y;
if (png_ptr->interlaced == PNG_INTERLACE_ADAM7)
{
@@ -3327,7 +3254,7 @@ png_image_read_composite(png_voidp argument)
png_read_row(png_ptr, inrow, NULL);
outrow = png_voidcast(png_bytep, display->first_row);
- outrow += y * step_row;
+ outrow += y * row_step;
end_row = outrow + width * channels;
/* Now do the composition on each pixel in this row. */
@@ -3346,20 +3273,44 @@ png_image_read_composite(png_voidp argument)
if (alpha < 255) /* else just use component */
{
- /* This is PNG_OPTIMIZED_ALPHA, the component value
- * is a linear 8-bit value. Combine this with the
- * current outrow[c] value which is sRGB encoded.
- * Arithmetic here is 16-bits to preserve the output
- * values correctly.
- */
- component *= 257*255; /* =65535 */
- component += (255-alpha)*png_sRGB_table[outrow[c]];
+ if (optimize_alpha != 0)
+ {
+ /* This is PNG_OPTIMIZED_ALPHA, the component value
+ * is a linear 8-bit value. Combine this with the
+ * current outrow[c] value which is sRGB encoded.
+ * Arithmetic here is 16-bits to preserve the output
+ * values correctly.
+ */
+ component *= 257*255; /* =65535 */
+ component += (255-alpha)*png_sRGB_table[outrow[c]];
- /* So 'component' is scaled by 255*65535 and is
- * therefore appropriate for the sRGB to linear
- * conversion table.
- */
- component = PNG_sRGB_FROM_LINEAR(component);
+ /* Clamp to the valid range to defend against
+ * unforeseen cases where the data might be sRGB
+ * instead of linear premultiplied.
+ * (Belt-and-suspenders for CVE-2025-66293.)
+ */
+ if (component > 255*65535)
+ component = 255*65535;
+
+ /* So 'component' is scaled by 255*65535 and is
+ * therefore appropriate for the sRGB-to-linear
+ * conversion table.
+ */
+ component = PNG_sRGB_FROM_LINEAR(component);
+ }
+ else
+ {
+ /* Compositing was already done on the palette
+ * entries. The data is sRGB premultiplied on black.
+ * Composite with the background in sRGB space.
+ * This is not gamma-correct, but matches what was
+ * done to the palette.
+ */
+ png_uint_32 background = outrow[c];
+ component += ((255-alpha) * background + 127) / 255;
+ if (component > 255)
+ component = 255;
+ }
}
outrow[c] = (png_byte)component;
@@ -3448,13 +3399,12 @@ png_image_read_background(png_voidp argument)
*/
{
png_bytep first_row = png_voidcast(png_bytep, display->first_row);
- ptrdiff_t step_row = display->row_bytes;
+ ptrdiff_t row_step = display->row_step;
for (pass = 0; pass < passes; ++pass)
{
- png_bytep row = png_voidcast(png_bytep, display->first_row);
- unsigned int startx, stepx, stepy;
- png_uint_32 y;
+ unsigned int startx, stepx, stepy;
+ png_uint_32 y;
if (png_ptr->interlaced == PNG_INTERLACE_ADAM7)
{
@@ -3481,7 +3431,7 @@ png_image_read_background(png_voidp argument)
{
png_bytep inrow = png_voidcast(png_bytep,
display->local_row);
- png_bytep outrow = first_row + y * step_row;
+ png_bytep outrow = first_row + y * row_step;
png_const_bytep end_row = outrow + width;
/* Read the row, which is packed: */
@@ -3526,7 +3476,7 @@ png_image_read_background(png_voidp argument)
{
png_bytep inrow = png_voidcast(png_bytep,
display->local_row);
- png_bytep outrow = first_row + y * step_row;
+ png_bytep outrow = first_row + y * row_step;
png_const_bytep end_row = outrow + width;
/* Read the row, which is packed: */
@@ -3557,8 +3507,6 @@ png_image_read_background(png_voidp argument)
inrow += 2; /* gray and alpha channel */
}
-
- row += display->row_bytes;
}
}
}
@@ -3574,9 +3522,9 @@ png_image_read_background(png_voidp argument)
png_uint_16p first_row = png_voidcast(png_uint_16p,
display->first_row);
/* The division by two is safe because the caller passed in a
- * stride which was multiplied by 2 (below) to get row_bytes.
+ * stride which was multiplied by 2 (below) to get row_step.
*/
- ptrdiff_t step_row = display->row_bytes / 2;
+ ptrdiff_t row_step = display->row_step / 2;
unsigned int preserve_alpha = (image->format &
PNG_FORMAT_FLAG_ALPHA) != 0;
unsigned int outchannels = 1U+preserve_alpha;
@@ -3590,8 +3538,8 @@ png_image_read_background(png_voidp argument)
for (pass = 0; pass < passes; ++pass)
{
- unsigned int startx, stepx, stepy;
- png_uint_32 y;
+ unsigned int startx, stepx, stepy;
+ png_uint_32 y;
/* The 'x' start and step are adjusted to output components here.
*/
@@ -3618,7 +3566,7 @@ png_image_read_background(png_voidp argument)
for (; ydefault_gamma should have been set after the
+ * info-before-IDAT was read in png_image_read_header.
+ *
+ * TODO: 1.8: remove this and see what happens.
+ */
png_fixed_point input_gamma_default;
if ((base_format & PNG_FORMAT_FLAG_LINEAR) != 0 &&
@@ -3765,13 +3720,13 @@ png_image_read_direct(png_voidp argument)
mode = PNG_ALPHA_PNG;
output_gamma = PNG_DEFAULT_sRGB;
}
-
+
if ((change & PNG_FORMAT_FLAG_ASSOCIATED_ALPHA) != 0)
{
mode = PNG_ALPHA_OPTIMIZED;
change &= ~PNG_FORMAT_FLAG_ASSOCIATED_ALPHA;
}
-
+
/* If 'do_local_background' is set check for the presence of gamma
* correction; this is part of the work-round for the libpng bug
* described above.
@@ -3787,8 +3742,9 @@ png_image_read_direct(png_voidp argument)
* yet; it's set below. png_struct::gamma, however, is set to the
* final value.
*/
- if (png_muldiv(>est, output_gamma, png_ptr->colorspace.gamma,
- PNG_FP_1) != 0 && png_gamma_significant(gtest) == 0)
+ if (png_muldiv(>est, output_gamma,
+ png_resolve_file_gamma(png_ptr), PNG_FP_1) != 0 &&
+ png_gamma_significant(gtest) == 0)
do_local_background = 0;
else if (mode == PNG_ALPHA_STANDARD)
@@ -3807,8 +3763,16 @@ png_image_read_direct(png_voidp argument)
png_set_expand_16(png_ptr);
else /* 8-bit output */
+ {
png_set_scale_16(png_ptr);
+ /* For interlaced images, use local_row buffer to avoid overflow
+ * in png_combine_row() which writes using IHDR bit-depth.
+ */
+ if (png_ptr->interlaced != 0)
+ do_local_scale = 1;
+ }
+
change &= ~PNG_FORMAT_FLAG_LINEAR;
}
@@ -4039,23 +4003,23 @@ png_image_read_direct(png_voidp argument)
*/
{
png_voidp first_row = display->buffer;
- ptrdiff_t row_bytes = display->row_stride;
+ ptrdiff_t row_step = display->row_stride;
if (linear != 0)
- row_bytes *= 2;
+ row_step *= 2;
- /* The following expression is designed to work correctly whether it gives
- * a signed or an unsigned result.
+ /* The following adjustment is to ensure that calculations are correct,
+ * regardless whether row_step is positive or negative.
*/
- if (row_bytes < 0)
+ if (row_step < 0)
{
char *ptr = png_voidcast(char*, first_row);
- ptr += (image->height-1) * (-row_bytes);
+ ptr += (image->height - 1) * (-row_step);
first_row = png_voidcast(png_voidp, ptr);
}
display->first_row = first_row;
- display->row_bytes = row_bytes;
+ display->row_step = row_step;
}
if (do_local_compose != 0)
@@ -4084,19 +4048,37 @@ png_image_read_direct(png_voidp argument)
return result;
}
+ else if (do_local_scale != 0)
+ {
+ /* For interlaced 16-to-8 conversion, use an intermediate row buffer
+ * to avoid buffer overflows in png_combine_row. The local_row is sized
+ * for the transformed (8-bit) output, preventing the overflow that would
+ * occur if png_combine_row wrote 16-bit data directly to the user buffer.
+ */
+ int result;
+ png_voidp row = png_malloc(png_ptr, png_get_rowbytes(png_ptr, info_ptr));
+
+ display->local_row = row;
+ result = png_safe_execute(image, png_image_read_direct_scaled, display);
+ display->local_row = NULL;
+ png_free(png_ptr, row);
+
+ return result;
+ }
+
else
{
- png_alloc_size_t row_bytes = (png_alloc_size_t)display->row_bytes;
+ ptrdiff_t row_step = display->row_step;
while (--passes >= 0)
{
- png_uint_32 y = image->height;
- png_bytep row = png_voidcast(png_bytep, display->first_row);
+ png_uint_32 y = image->height;
+ png_bytep row = png_voidcast(png_bytep, display->first_row);
for (; y > 0; --y)
{
png_read_row(png_ptr, row, NULL);
- row += row_bytes;
+ row += row_step;
}
}
diff --git a/src/libs/Irrlicht/irrlicht-svn/source/Irrlicht/libpng/pngrio.c b/src/libs/Irrlicht/irrlicht-svn/source/Irrlicht/libpng/pngrio.c
index 7d30c7a5..843860cd 100644
--- a/src/libs/Irrlicht/irrlicht-svn/source/Irrlicht/libpng/pngrio.c
+++ b/src/libs/Irrlicht/irrlicht-svn/source/Irrlicht/libpng/pngrio.c
@@ -1,7 +1,6 @@
-
/* pngrio.c - functions for data input
*
- * Copyright (c) 2018 Cosmin Truta
+ * Copyright (c) 2018-2025 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.
@@ -57,7 +56,7 @@ png_default_read_data(png_structp png_ptr, png_bytep data, size_t length)
/* fread() returns 0 on error, so it is OK to store this in a size_t
* instead of an int, which is what fread() actually returns.
*/
- check = fread(data, 1, length, png_voidcast(png_FILE_p, png_ptr->io_ptr));
+ check = fread(data, 1, length, png_voidcast(FILE *, png_ptr->io_ptr));
if (check != length)
png_error(png_ptr, "Read Error");
diff --git a/src/libs/Irrlicht/irrlicht-svn/source/Irrlicht/libpng/pngrtran.c b/src/libs/Irrlicht/irrlicht-svn/source/Irrlicht/libpng/pngrtran.c
index a3cac0fc..37621523 100644
--- a/src/libs/Irrlicht/irrlicht-svn/source/Irrlicht/libpng/pngrtran.c
+++ b/src/libs/Irrlicht/irrlicht-svn/source/Irrlicht/libpng/pngrtran.c
@@ -1,7 +1,6 @@
-
/* pngrtran.c - transforms the data in a row for PNG readers
*
- * Copyright (c) 2018-2019 Cosmin Truta
+ * Copyright (c) 2018-2025 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.
@@ -21,7 +20,7 @@
#ifdef PNG_ARM_NEON_IMPLEMENTATION
# if PNG_ARM_NEON_IMPLEMENTATION == 1
# define PNG_ARM_NEON_INTRINSICS_AVAILABLE
-# if defined(_MSC_VER) && defined(_M_ARM64)
+# if defined(_MSC_VER) && !defined(__clang__) && defined(_M_ARM64)
# include
# else
# include
@@ -29,6 +28,12 @@
# endif
#endif
+#ifdef PNG_RISCV_RVV_IMPLEMENTATION
+# if PNG_RISCV_RVV_IMPLEMENTATION == 1
+# define PNG_RISCV_RVV_INTRINSICS_AVAILABLE
+# endif
+#endif
+
#ifdef PNG_READ_SUPPORTED
/* Set the action on getting a CRC error for an ancillary or critical chunk. */
@@ -219,9 +224,59 @@ png_set_strip_alpha(png_structrp png_ptr)
#endif
#if defined(PNG_READ_ALPHA_MODE_SUPPORTED) || defined(PNG_READ_GAMMA_SUPPORTED)
+/* PNGv3 conformance: this private API exists to resolve the now mandatory error
+ * resolution when multiple conflicting sources of gamma or colour space
+ * information are available.
+ *
+ * Terminology (assuming power law, "gamma", encodings):
+ * "screen" gamma: a power law imposed by the output device when digital
+ * samples are converted to visible light output. The EOTF - volage to
+ * luminance on output.
+ *
+ * "file" gamma: a power law used to encode luminance levels from the input
+ * data (the scene or the mastering display system) into digital voltages.
+ * The OETF - luminance to voltage on input.
+ *
+ * gamma "correction": a power law matching the **inverse** of the overall
+ * transfer function from input luminance levels to output levels. The
+ * **inverse** of the OOTF; the correction "corrects" for the OOTF by aiming
+ * to make the overall OOTF (including the correction) linear.
+ *
+ * It is important to understand this terminology because the defined terms are
+ * scattered throughout the libpng code and it is very easy to end up with the
+ * inverse of the power law required.
+ *
+ * Variable and struct::member names:
+ * file_gamma OETF how the PNG data was encoded
+ *
+ * screen_gamma EOTF how the screen will decode digital levels
+ *
+ * -- not used -- OOTF the net effect OETF x EOTF
+ * gamma_correction the inverse of OOTF to make the result linear
+ *
+ * All versions of libpng require a call to "png_set_gamma" to establish the
+ * "screen" gamma, the power law representing the EOTF. png_set_gamma may also
+ * set or default the "file" gamma; the OETF. gamma_correction is calculated
+ * internally.
+ *
+ * The earliest libpng versions required file_gamma to be supplied to set_gamma.
+ * Later versions started allowing png_set_gamma and, later, png_set_alpha_mode,
+ * to cause defaulting from the file data.
+ *
+ * PNGv3 mandated a particular form for this defaulting, one that is compatible
+ * with what libpng did except that if libpng detected inconsistencies it marked
+ * all the chunks as "invalid". PNGv3 effectively invalidates this prior code.
+ *
+ * Behaviour implemented below:
+ * translate_gamma_flags(gamma, is_screen)
+ * The libpng-1.6 API for the gamma parameters to libpng APIs
+ * (png_set_gamma and png_set_alpha_mode at present). This allows the
+ * 'gamma' value to be passed as a png_fixed_point number or as one of a
+ * set of integral values for specific "well known" examples of transfer
+ * functions. This is compatible with PNGv3.
+ */
static png_fixed_point
-translate_gamma_flags(png_structrp png_ptr, png_fixed_point output_gamma,
- int is_screen)
+translate_gamma_flags(png_fixed_point output_gamma, int is_screen)
{
/* Check for flag values. The main reason for having the old Mac value as a
* flag is that it is pretty near impossible to work out what the correct
@@ -231,14 +286,6 @@ translate_gamma_flags(png_structrp png_ptr, png_fixed_point output_gamma,
if (output_gamma == PNG_DEFAULT_sRGB ||
output_gamma == PNG_FP_1 / PNG_DEFAULT_sRGB)
{
- /* If there is no sRGB support this just sets the gamma to the standard
- * sRGB value. (This is a side effect of using this function!)
- */
-# ifdef PNG_READ_sRGB_SUPPORTED
- png_ptr->flags |= PNG_FLAG_ASSUME_sRGB;
-# else
- PNG_UNUSED(png_ptr)
-# endif
if (is_screen != 0)
output_gamma = PNG_GAMMA_sRGB;
else
@@ -280,6 +327,33 @@ convert_gamma_value(png_structrp png_ptr, double output_gamma)
return (png_fixed_point)output_gamma;
}
# endif
+
+static int
+unsupported_gamma(png_structrp png_ptr, png_fixed_point gamma, int warn)
+{
+ /* Validate a gamma value to ensure it is in a reasonable range. The value
+ * is expected to be 1 or greater, but this range test allows for some
+ * viewing correction values. The intent is to weed out the API users
+ * who might use the inverse of the gamma value accidentally!
+ *
+ * 1.6.47: apply the test in png_set_gamma as well but only warn and return
+ * false if it fires.
+ *
+ * TODO: 1.8: make this an app_error in png_set_gamma as well.
+ */
+ if (gamma < PNG_LIB_GAMMA_MIN || gamma > PNG_LIB_GAMMA_MAX)
+ {
+# define msg "gamma out of supported range"
+ if (warn)
+ png_app_warning(png_ptr, msg);
+ else
+ png_app_error(png_ptr, msg);
+ return 1;
+# undef msg
+ }
+
+ return 0;
+}
#endif /* READ_ALPHA_MODE || READ_GAMMA */
#ifdef PNG_READ_ALPHA_MODE_SUPPORTED
@@ -287,32 +361,29 @@ void PNGFAPI
png_set_alpha_mode_fixed(png_structrp png_ptr, int mode,
png_fixed_point output_gamma)
{
- int compose = 0;
png_fixed_point file_gamma;
+ int compose = 0;
- 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;
- output_gamma = translate_gamma_flags(png_ptr, output_gamma, 1/*screen*/);
-
- /* Validate the value to ensure it is in a reasonable range. The value
- * is expected to be 1 or greater, but this range test allows for some
- * viewing correction values. The intent is to weed out users of this API
- * who use the inverse of the gamma value accidentally! Since some of these
- * values are reasonable this may have to be changed:
- *
- * 1.6.x: changed from 0.07..3 to 0.01..100 (to accommodate the optimal 16-bit
- * gamma of 36, and its reciprocal.)
- */
- if (output_gamma < 1000 || output_gamma > 10000000)
- png_error(png_ptr, "output gamma out of expected range");
+ output_gamma = translate_gamma_flags(output_gamma, 1/*screen*/);
+ if (unsupported_gamma(png_ptr, output_gamma, 0/*error*/))
+ return;
/* The default file gamma is the inverse of the output gamma; the output
- * gamma may be changed below so get the file value first:
+ * gamma may be changed below so get the file value first. The default_gamma
+ * is set here and from the simplified API (which uses a different algorithm)
+ * so don't overwrite a set value:
*/
- file_gamma = png_reciprocal(output_gamma);
+ file_gamma = png_ptr->default_gamma;
+ if (file_gamma == 0)
+ {
+ file_gamma = png_reciprocal(output_gamma);
+ png_ptr->default_gamma = file_gamma;
+ }
/* There are really 8 possibilities here, composed of any combination
* of:
@@ -363,17 +434,7 @@ png_set_alpha_mode_fixed(png_structrp png_ptr, int mode,
png_error(png_ptr, "invalid alpha mode");
}
- /* Only set the default gamma if the file gamma has not been set (this has
- * the side effect that the gamma in a second call to png_set_alpha_mode will
- * be ignored.)
- */
- if (png_ptr->colorspace.gamma == 0)
- {
- png_ptr->colorspace.gamma = file_gamma;
- png_ptr->colorspace.flags |= PNG_COLORSPACE_HAVE_GAMMA;
- }
-
- /* But always set the output gamma: */
+ /* Set the screen gamma values: */
png_ptr->screen_gamma = output_gamma;
/* Finally, if pre-multiplying, set the background fields to achieve the
@@ -383,7 +444,7 @@ png_set_alpha_mode_fixed(png_structrp png_ptr, int mode,
{
/* And obtain alpha pre-multiplication by composing on black: */
memset(&png_ptr->background, 0, (sizeof png_ptr->background));
- png_ptr->background_gamma = png_ptr->colorspace.gamma; /* just in case */
+ png_ptr->background_gamma = file_gamma; /* just in case */
png_ptr->background_gamma_type = PNG_BACKGROUND_GAMMA_FILE;
png_ptr->transformations &= ~PNG_BACKGROUND_EXPAND;
@@ -440,9 +501,19 @@ png_set_quantize(png_structrp png_ptr, png_colorp palette,
{
int i;
+ /* Initialize the array to index colors.
+ *
+ * Ensure quantize_index can fit 256 elements (PNG_MAX_PALETTE_LENGTH)
+ * rather than num_palette elements. This is to prevent buffer overflows
+ * caused by malformed PNG files with out-of-range palette indices.
+ *
+ * Be careful to avoid leaking memory. Applications are allowed to call
+ * this function more than once per png_struct.
+ */
+ png_free(png_ptr, png_ptr->quantize_index);
png_ptr->quantize_index = (png_bytep)png_malloc(png_ptr,
- (png_alloc_size_t)((png_uint_32)num_palette * (sizeof (png_byte))));
- for (i = 0; i < num_palette; i++)
+ PNG_MAX_PALETTE_LENGTH);
+ for (i = 0; i < PNG_MAX_PALETTE_LENGTH; i++)
png_ptr->quantize_index[i] = (png_byte)i;
}
@@ -454,15 +525,14 @@ png_set_quantize(png_structrp png_ptr, png_colorp palette,
* Perhaps not the best solution, but good enough.
*/
- int i;
-
- /* Initialize an array to sort colors */
- png_ptr->quantize_sort = (png_bytep)png_malloc(png_ptr,
- (png_alloc_size_t)((png_uint_32)num_palette * (sizeof (png_byte))));
+ png_bytep quantize_sort;
+ int i, j;
- /* Initialize the quantize_sort array */
+ /* Initialize the local array to sort colors. */
+ quantize_sort = (png_bytep)png_malloc(png_ptr,
+ (png_alloc_size_t)num_palette);
for (i = 0; i < num_palette; i++)
- png_ptr->quantize_sort[i] = (png_byte)i;
+ quantize_sort[i] = (png_byte)i;
/* Find the least used palette entries by starting a
* bubble sort, and running it until we have sorted
@@ -474,19 +544,18 @@ png_set_quantize(png_structrp png_ptr, png_colorp palette,
for (i = num_palette - 1; i >= maximum_colors; i--)
{
int done; /* To stop early if the list is pre-sorted */
- int j;
done = 1;
for (j = 0; j < i; j++)
{
- if (histogram[png_ptr->quantize_sort[j]]
- < histogram[png_ptr->quantize_sort[j + 1]])
+ if (histogram[quantize_sort[j]]
+ < histogram[quantize_sort[j + 1]])
{
png_byte t;
- t = png_ptr->quantize_sort[j];
- png_ptr->quantize_sort[j] = png_ptr->quantize_sort[j + 1];
- png_ptr->quantize_sort[j + 1] = t;
+ t = quantize_sort[j];
+ quantize_sort[j] = quantize_sort[j + 1];
+ quantize_sort[j + 1] = t;
done = 0;
}
}
@@ -498,18 +567,18 @@ png_set_quantize(png_structrp png_ptr, png_colorp palette,
/* Swap the palette around, and set up a table, if necessary */
if (full_quantize != 0)
{
- int j = num_palette;
+ j = num_palette;
/* Put all the useful colors within the max, but don't
* move the others.
*/
for (i = 0; i < maximum_colors; i++)
{
- if ((int)png_ptr->quantize_sort[i] >= maximum_colors)
+ if ((int)quantize_sort[i] >= maximum_colors)
{
do
j--;
- while ((int)png_ptr->quantize_sort[j] >= maximum_colors);
+ while ((int)quantize_sort[j] >= maximum_colors);
palette[i] = palette[j];
}
@@ -517,7 +586,7 @@ png_set_quantize(png_structrp png_ptr, png_colorp palette,
}
else
{
- int j = num_palette;
+ j = num_palette;
/* Move all the used colors inside the max limit, and
* develop a translation table.
@@ -525,13 +594,13 @@ png_set_quantize(png_structrp png_ptr, png_colorp palette,
for (i = 0; i < maximum_colors; i++)
{
/* Only move the colors we need to */
- if ((int)png_ptr->quantize_sort[i] >= maximum_colors)
+ if ((int)quantize_sort[i] >= maximum_colors)
{
png_color tmp_color;
do
j--;
- while ((int)png_ptr->quantize_sort[j] >= maximum_colors);
+ while ((int)quantize_sort[j] >= maximum_colors);
tmp_color = palette[j];
palette[j] = palette[i];
@@ -569,8 +638,7 @@ png_set_quantize(png_structrp png_ptr, png_colorp palette,
}
}
}
- png_free(png_ptr, png_ptr->quantize_sort);
- png_ptr->quantize_sort = NULL;
+ png_free(png_ptr, quantize_sort);
}
else
{
@@ -592,11 +660,9 @@ png_set_quantize(png_structrp png_ptr, png_colorp palette,
/* Initialize palette index arrays */
png_ptr->index_to_palette = (png_bytep)png_malloc(png_ptr,
- (png_alloc_size_t)((png_uint_32)num_palette *
- (sizeof (png_byte))));
+ (png_alloc_size_t)num_palette);
png_ptr->palette_to_index = (png_bytep)png_malloc(png_ptr,
- (png_alloc_size_t)((png_uint_32)num_palette *
- (sizeof (png_byte))));
+ (png_alloc_size_t)num_palette);
/* Initialize the sort array */
for (i = 0; i < num_palette; i++)
@@ -761,12 +827,11 @@ png_set_quantize(png_structrp png_ptr, png_colorp palette,
size_t num_entries = ((size_t)1 << total_bits);
png_ptr->palette_lookup = (png_bytep)png_calloc(png_ptr,
- (png_alloc_size_t)(num_entries * (sizeof (png_byte))));
+ (png_alloc_size_t)(num_entries));
- distance = (png_bytep)png_malloc(png_ptr, (png_alloc_size_t)(num_entries *
- (sizeof (png_byte))));
+ distance = (png_bytep)png_malloc(png_ptr, (png_alloc_size_t)num_entries);
- memset(distance, 0xff, num_entries * (sizeof (png_byte)));
+ memset(distance, 0xff, num_entries);
for (i = 0; i < num_palette; i++)
{
@@ -824,8 +889,8 @@ png_set_gamma_fixed(png_structrp png_ptr, png_fixed_point scrn_gamma,
return;
/* New in libpng-1.5.4 - reserve particular negative values as flags. */
- scrn_gamma = translate_gamma_flags(png_ptr, scrn_gamma, 1/*screen*/);
- file_gamma = translate_gamma_flags(png_ptr, file_gamma, 0/*file*/);
+ scrn_gamma = translate_gamma_flags(scrn_gamma, 1/*screen*/);
+ file_gamma = translate_gamma_flags(file_gamma, 0/*file*/);
/* Checking the gamma values for being >0 was added in 1.5.4 along with the
* premultiplied alpha support; this actually hides an undocumented feature
@@ -839,17 +904,19 @@ png_set_gamma_fixed(png_structrp png_ptr, png_fixed_point scrn_gamma,
* libpng-1.6.0.
*/
if (file_gamma <= 0)
- png_error(png_ptr, "invalid file gamma in png_set_gamma");
-
+ png_app_error(png_ptr, "invalid file gamma in png_set_gamma");
if (scrn_gamma <= 0)
- png_error(png_ptr, "invalid screen gamma in png_set_gamma");
+ png_app_error(png_ptr, "invalid screen gamma in png_set_gamma");
+
+ if (unsupported_gamma(png_ptr, file_gamma, 1/*warn*/) ||
+ unsupported_gamma(png_ptr, scrn_gamma, 1/*warn*/))
+ return;
- /* Set the gamma values unconditionally - this overrides the value in the PNG
- * file if a gAMA chunk was present. png_set_alpha_mode provides a
- * different, easier, way to default the file gamma.
+ /* 1.6.47: png_struct::file_gamma and png_struct::screen_gamma are now only
+ * written by this API. This removes dependencies on the order of API calls
+ * and allows the complex gamma checks to be delayed until needed.
*/
- png_ptr->colorspace.gamma = file_gamma;
- png_ptr->colorspace.flags |= PNG_COLORSPACE_HAVE_GAMMA;
+ png_ptr->file_gamma = file_gamma;
png_ptr->screen_gamma = scrn_gamma;
}
@@ -970,7 +1037,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 */
@@ -1027,26 +1094,9 @@ png_set_rgb_to_gray_fixed(png_structrp png_ptr, int error_action,
png_ptr->rgb_to_gray_coefficients_set = 1;
}
- else
- {
- if (red >= 0 && green >= 0)
- png_app_warning(png_ptr,
- "ignoring out of range rgb_to_gray coefficients");
-
- /* Use the defaults, from the cHRM chunk if set, else the historical
- * values which are close to the sRGB/HDTV/ITU-Rec 709 values. See
- * png_do_rgb_to_gray for more discussion of the values. In this case
- * the coefficients are not marked as 'set' and are not overwritten if
- * something has already provided a default.
- */
- if (png_ptr->rgb_to_gray_red_coeff == 0 &&
- png_ptr->rgb_to_gray_green_coeff == 0)
- {
- png_ptr->rgb_to_gray_red_coeff = 6968;
- png_ptr->rgb_to_gray_green_coeff = 23434;
- /* png_ptr->rgb_to_gray_blue_coeff = 2366; */
- }
- }
+ else if (red >= 0 && green >= 0)
+ png_app_warning(png_ptr,
+ "ignoring out of range rgb_to_gray coefficients");
}
}
@@ -1070,8 +1120,8 @@ png_set_rgb_to_gray(png_structrp png_ptr, int error_action, double red,
#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \
defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED)
void PNGAPI
-png_set_read_user_transform_fn(png_structrp png_ptr, png_user_transform_ptr
- read_user_transform_fn)
+png_set_read_user_transform_fn(png_structrp png_ptr,
+ png_user_transform_ptr read_user_transform_fn)
{
png_debug(1, "in png_set_read_user_transform_fn");
@@ -1287,6 +1337,80 @@ png_init_rgb_transformations(png_structrp png_ptr)
#endif /* READ_EXPAND && READ_BACKGROUND */
}
+#ifdef PNG_READ_GAMMA_SUPPORTED
+png_fixed_point /* PRIVATE */
+png_resolve_file_gamma(png_const_structrp png_ptr)
+{
+ png_fixed_point file_gamma;
+
+ /* The file gamma is determined by these precedence rules, in this order
+ * (i.e. use the first value found):
+ *
+ * png_set_gamma; png_struct::file_gammma if not zero, then:
+ * png_struct::chunk_gamma if not 0 (determined the PNGv3 rules), then:
+ * png_set_gamma; 1/png_struct::screen_gamma if not zero
+ *
+ * 0 (i.e. do no gamma handling)
+ */
+ file_gamma = png_ptr->file_gamma;
+ if (file_gamma != 0)
+ return file_gamma;
+
+ file_gamma = png_ptr->chunk_gamma;
+ if (file_gamma != 0)
+ return file_gamma;
+
+ file_gamma = png_ptr->default_gamma;
+ if (file_gamma != 0)
+ return file_gamma;
+
+ /* If png_reciprocal oveflows it returns 0 which indicates to the caller that
+ * there is no usable file gamma. (The checks added to png_set_gamma and
+ * png_set_alpha_mode should prevent a screen_gamma which would overflow.)
+ */
+ if (png_ptr->screen_gamma != 0)
+ file_gamma = png_reciprocal(png_ptr->screen_gamma);
+
+ return file_gamma;
+}
+
+static int
+png_init_gamma_values(png_structrp png_ptr)
+{
+ /* The following temporary indicates if overall gamma correction is
+ * required.
+ */
+ int gamma_correction = 0;
+ png_fixed_point file_gamma, screen_gamma;
+
+ /* Resolve the file_gamma. See above: if png_ptr::screen_gamma is set
+ * file_gamma will always be set here:
+ */
+ file_gamma = png_resolve_file_gamma(png_ptr);
+ screen_gamma = png_ptr->screen_gamma;
+
+ if (file_gamma > 0) /* file has been set */
+ {
+ if (screen_gamma > 0) /* screen set too */
+ gamma_correction = png_gamma_threshold(file_gamma, screen_gamma);
+
+ else
+ /* Assume the output matches the input; a long time default behavior
+ * of libpng, although the standard has nothing to say about this.
+ */
+ screen_gamma = png_reciprocal(file_gamma);
+ }
+
+ else /* both unset, prevent corrections: */
+ file_gamma = screen_gamma = PNG_FP_1;
+
+ png_ptr->file_gamma = file_gamma;
+ png_ptr->screen_gamma = screen_gamma;
+ return gamma_correction;
+
+}
+#endif /* READ_GAMMA */
+
void /* PRIVATE */
png_init_read_transformations(png_structrp png_ptr)
{
@@ -1306,59 +1430,22 @@ png_init_read_transformations(png_structrp png_ptr)
* the test needs to be performed later - here. In addition prior to 1.5.4
* the tests were repeated for the PALETTE color type here - this is no
* longer necessary (and doesn't seem to have been necessary before.)
+ *
+ * PNGv3: the new mandatory precedence/priority rules for colour space chunks
+ * are handled here (by calling the above function).
+ *
+ * Turn the gamma transformation on or off as appropriate. Notice that
+ * PNG_GAMMA just refers to the file->screen correction. Alpha composition
+ * may independently cause gamma correction because it needs linear data
+ * (e.g. if the file has a gAMA chunk but the screen gamma hasn't been
+ * specified.) In any case this flag may get turned off in the code
+ * immediately below if the transform can be handled outside the row loop.
*/
- {
- /* The following temporary indicates if overall gamma correction is
- * required.
- */
- int gamma_correction = 0;
-
- if (png_ptr->colorspace.gamma != 0) /* has been set */
- {
- if (png_ptr->screen_gamma != 0) /* screen set too */
- gamma_correction = png_gamma_threshold(png_ptr->colorspace.gamma,
- png_ptr->screen_gamma);
+ if (png_init_gamma_values(png_ptr) != 0)
+ png_ptr->transformations |= PNG_GAMMA;
- else
- /* Assume the output matches the input; a long time default behavior
- * of libpng, although the standard has nothing to say about this.
- */
- png_ptr->screen_gamma = png_reciprocal(png_ptr->colorspace.gamma);
- }
-
- else if (png_ptr->screen_gamma != 0)
- /* The converse - assume the file matches the screen, note that this
- * perhaps undesirable default can (from 1.5.4) be changed by calling
- * png_set_alpha_mode (even if the alpha handling mode isn't required
- * or isn't changed from the default.)
- */
- png_ptr->colorspace.gamma = png_reciprocal(png_ptr->screen_gamma);
-
- else /* neither are set */
- /* Just in case the following prevents any processing - file and screen
- * are both assumed to be linear and there is no way to introduce a
- * third gamma value other than png_set_background with 'UNIQUE', and,
- * prior to 1.5.4
- */
- png_ptr->screen_gamma = png_ptr->colorspace.gamma = PNG_FP_1;
-
- /* We have a gamma value now. */
- png_ptr->colorspace.flags |= PNG_COLORSPACE_HAVE_GAMMA;
-
- /* Now turn the gamma transformation on or off as appropriate. Notice
- * that PNG_GAMMA just refers to the file->screen correction. Alpha
- * composition may independently cause gamma correction because it needs
- * linear data (e.g. if the file has a gAMA chunk but the screen gamma
- * hasn't been specified.) In any case this flag may get turned off in
- * the code immediately below if the transform can be handled outside the
- * row loop.
- */
- if (gamma_correction != 0)
- png_ptr->transformations |= PNG_GAMMA;
-
- else
- png_ptr->transformations &= ~PNG_GAMMA;
- }
+ else
+ png_ptr->transformations &= ~PNG_GAMMA;
#endif
/* Certain transformations have the effect of preventing other
@@ -1430,7 +1517,7 @@ png_init_read_transformations(png_structrp png_ptr)
* appropriately.
*/
if ((png_ptr->transformations & PNG_RGB_TO_GRAY) != 0)
- png_colorspace_set_rgb_coefficients(png_ptr);
+ png_set_rgb_coefficients(png_ptr);
#endif
#ifdef PNG_READ_GRAY_TO_RGB_SUPPORTED
@@ -1573,10 +1660,10 @@ png_init_read_transformations(png_structrp png_ptr)
*/
if ((png_ptr->transformations & PNG_GAMMA) != 0 ||
((png_ptr->transformations & PNG_RGB_TO_GRAY) != 0 &&
- (png_gamma_significant(png_ptr->colorspace.gamma) != 0 ||
+ (png_gamma_significant(png_ptr->file_gamma) != 0 ||
png_gamma_significant(png_ptr->screen_gamma) != 0)) ||
((png_ptr->transformations & PNG_COMPOSE) != 0 &&
- (png_gamma_significant(png_ptr->colorspace.gamma) != 0 ||
+ (png_gamma_significant(png_ptr->file_gamma) != 0 ||
png_gamma_significant(png_ptr->screen_gamma) != 0
# ifdef PNG_READ_BACKGROUND_SUPPORTED
|| (png_ptr->background_gamma_type == PNG_BACKGROUND_GAMMA_UNIQUE &&
@@ -1632,8 +1719,8 @@ png_init_read_transformations(png_structrp png_ptr)
break;
case PNG_BACKGROUND_GAMMA_FILE:
- g = png_reciprocal(png_ptr->colorspace.gamma);
- gs = png_reciprocal2(png_ptr->colorspace.gamma,
+ g = png_reciprocal(png_ptr->file_gamma);
+ gs = png_reciprocal2(png_ptr->file_gamma,
png_ptr->screen_gamma);
break;
@@ -1694,19 +1781,51 @@ png_init_read_transformations(png_structrp png_ptr)
}
else /* if (png_ptr->trans_alpha[i] != 0xff) */
{
- png_byte v, w;
-
- v = png_ptr->gamma_to_1[palette[i].red];
- png_composite(w, v, png_ptr->trans_alpha[i], back_1.red);
- palette[i].red = png_ptr->gamma_from_1[w];
-
- v = png_ptr->gamma_to_1[palette[i].green];
- png_composite(w, v, png_ptr->trans_alpha[i], back_1.green);
- palette[i].green = png_ptr->gamma_from_1[w];
-
- v = png_ptr->gamma_to_1[palette[i].blue];
- png_composite(w, v, png_ptr->trans_alpha[i], back_1.blue);
- palette[i].blue = png_ptr->gamma_from_1[w];
+ if ((png_ptr->flags & PNG_FLAG_OPTIMIZE_ALPHA) != 0)
+ {
+ /* Premultiply only:
+ * component = round((component * alpha) / 255)
+ */
+ png_uint_32 component;
+
+ component = png_ptr->gamma_to_1[palette[i].red];
+ component =
+ (component * png_ptr->trans_alpha[i] + 128) / 255;
+ palette[i].red = png_ptr->gamma_from_1[component];
+
+ component = png_ptr->gamma_to_1[palette[i].green];
+ component =
+ (component * png_ptr->trans_alpha[i] + 128) / 255;
+ palette[i].green = png_ptr->gamma_from_1[component];
+
+ component = png_ptr->gamma_to_1[palette[i].blue];
+ component =
+ (component * png_ptr->trans_alpha[i] + 128) / 255;
+ palette[i].blue = png_ptr->gamma_from_1[component];
+ }
+ else
+ {
+ /* Composite with background color:
+ * component =
+ * alpha * component + (1 - alpha) * background
+ */
+ png_byte v, w;
+
+ v = png_ptr->gamma_to_1[palette[i].red];
+ png_composite(w, v,
+ png_ptr->trans_alpha[i], back_1.red);
+ palette[i].red = png_ptr->gamma_from_1[w];
+
+ v = png_ptr->gamma_to_1[palette[i].green];
+ png_composite(w, v,
+ png_ptr->trans_alpha[i], back_1.green);
+ palette[i].green = png_ptr->gamma_from_1[w];
+
+ v = png_ptr->gamma_to_1[palette[i].blue];
+ png_composite(w, v,
+ png_ptr->trans_alpha[i], back_1.blue);
+ palette[i].blue = png_ptr->gamma_from_1[w];
+ }
}
}
else
@@ -1724,6 +1843,7 @@ png_init_read_transformations(png_structrp png_ptr)
* transformations elsewhere.
*/
png_ptr->transformations &= ~(PNG_COMPOSE | PNG_GAMMA);
+ png_ptr->flags &= ~PNG_FLAG_OPTIMIZE_ALPHA;
} /* color_type == PNG_COLOR_TYPE_PALETTE */
/* if (png_ptr->background_gamma_type!=PNG_BACKGROUND_GAMMA_UNKNOWN) */
@@ -1741,8 +1861,8 @@ png_init_read_transformations(png_structrp png_ptr)
break;
case PNG_BACKGROUND_GAMMA_FILE:
- g = png_reciprocal(png_ptr->colorspace.gamma);
- gs = png_reciprocal2(png_ptr->colorspace.gamma,
+ g = png_reciprocal(png_ptr->file_gamma);
+ gs = png_reciprocal2(png_ptr->file_gamma,
png_ptr->screen_gamma);
break;
@@ -1992,11 +2112,11 @@ png_read_transform_info(png_structrp png_ptr, png_inforp info_ptr)
* been called before this from png_read_update_info->png_read_start_row
* sometimes does the gamma transform and cancels the flag.
*
- * TODO: this looks wrong; the info_ptr should end up with a gamma equal to
- * the screen_gamma value. The following probably results in weirdness if
- * the info_ptr is used by the app after the rows have been read.
+ * TODO: this is confusing. It only changes the result of png_get_gAMA and,
+ * yes, it does return the value that the transformed data effectively has
+ * but does any app really understand this?
*/
- info_ptr->colorspace.gamma = png_ptr->colorspace.gamma;
+ info_ptr->gamma = png_ptr->file_gamma;
#endif
if (info_ptr->bit_depth == 16)
@@ -4929,13 +5049,8 @@ png_do_read_transformations(png_structrp png_ptr, png_row_infop row_info)
#ifdef PNG_READ_QUANTIZE_SUPPORTED
if ((png_ptr->transformations & PNG_QUANTIZE) != 0)
- {
png_do_quantize(row_info, png_ptr->row_buf + 1,
png_ptr->palette_lookup, png_ptr->quantize_index);
-
- if (row_info->rowbytes == 0)
- png_error(png_ptr, "png_do_quantize returned rowbytes=0");
- }
#endif /* READ_QUANTIZE */
#ifdef PNG_READ_EXPAND_16_SUPPORTED
diff --git a/src/libs/Irrlicht/irrlicht-svn/source/Irrlicht/libpng/pngrutil.c b/src/libs/Irrlicht/irrlicht-svn/source/Irrlicht/libpng/pngrutil.c
index 242dcc0d..392ccc70 100644
--- a/src/libs/Irrlicht/irrlicht-svn/source/Irrlicht/libpng/pngrutil.c
+++ b/src/libs/Irrlicht/irrlicht-svn/source/Irrlicht/libpng/pngrutil.c
@@ -1,7 +1,6 @@
-
/* pngrutil.c - utilities to read a PNG file
*
- * Copyright (c) 2018 Cosmin Truta
+ * Copyright (c) 2018-2025 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.
@@ -18,6 +17,26 @@
#ifdef PNG_READ_SUPPORTED
+/* The minimum 'zlib' stream is assumed to be just the 2 byte header, 5 bytes
+ * minimum 'deflate' stream, and the 4 byte checksum.
+ */
+#define LZ77Min (2U+5U+4U)
+
+#ifdef PNG_READ_INTERLACING_SUPPORTED
+/* Arrays to facilitate interlacing - use pass (0 - 6) as index. */
+
+/* Start of interlace block */
+static const png_byte png_pass_start[7] = {0, 4, 0, 2, 0, 1, 0};
+/* Offset to next interlace block */
+static const png_byte png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1};
+/* Start of interlace block in the y direction */
+static const png_byte png_pass_ystart[7] = {0, 0, 4, 0, 2, 0, 1};
+/* Offset to next interlace block in the y direction */
+static const png_byte png_pass_yinc[7] = {8, 8, 8, 4, 4, 2, 2};
+
+/* TODO: Move these arrays to a common utility module to avoid duplication. */
+#endif
+
png_uint_32 PNGAPI
png_get_uint_31(png_const_structrp png_ptr, png_const_bytep buf)
{
@@ -26,32 +45,8 @@ 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);
-}
-
-#if defined(PNG_READ_gAMA_SUPPORTED) || defined(PNG_READ_cHRM_SUPPORTED)
-/* The following is a variation on the above for use with the fixed
- * point values used for gAMA and cHRM. Instead of png_error it
- * issues a warning and returns (-1) - an invalid value because both
- * gAMA and cHRM use *unsigned* integers for fixed point values.
- */
-#define PNG_FIXED_ERROR (-1)
-
-static png_fixed_point /* PRIVATE */
-png_get_fixed_point(png_structrp png_ptr, png_const_bytep buf)
-{
- png_uint_32 uval = png_get_uint_32(buf);
-
- if (uval <= PNG_UINT_31_MAX)
- return (png_fixed_point)uval; /* known to be in range */
-
- /* The caller can turn off the warning by passing NULL. */
- if (png_ptr != NULL)
- png_warning(png_ptr, "PNG fixed point integer out of range");
-
- return PNG_FIXED_ERROR;
+ return uval;
}
-#endif
#ifdef PNG_READ_INT_FUNCTIONS_SUPPORTED
/* NOTE: the read macros will obscure these definitions, so that if
@@ -140,7 +135,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");
@@ -149,6 +144,38 @@ png_read_sig(png_structrp png_ptr, png_inforp info_ptr)
png_ptr->mode |= PNG_HAVE_PNG_SIGNATURE;
}
+/* This function is called to verify that a chunk name is valid.
+ * Do this using the bit-whacking approach from contrib/tools/pngfix.c
+ *
+ * Copied from libpng 1.7.
+ */
+static int
+check_chunk_name(png_uint_32 name)
+{
+ png_uint_32 t;
+
+ /* Remove bit 5 from all but the reserved byte; this means
+ * every 8-bit unit must be in the range 65-90 to be valid.
+ * So bit 5 must be zero, bit 6 must be set and bit 7 zero.
+ */
+ name &= ~PNG_U32(32,32,0,32);
+ t = (name & ~0x1f1f1f1fU) ^ 0x40404040U;
+
+ /* Subtract 65 for each 8-bit quantity, this must not
+ * overflow and each byte must then be in the range 0-25.
+ */
+ name -= PNG_U32(65,65,65,65);
+ t |= name;
+
+ /* Subtract 26, handling the overflow which should set the
+ * top three bits of each byte.
+ */
+ name -= PNG_U32(25,25,25,26);
+ t |= ~name;
+
+ return (t & 0xe0e0e0e0U) == 0U;
+}
+
/* Read the chunk header (length + type name).
* Put the type name into png_ptr->chunk_name, and return the length.
*/
@@ -156,33 +183,36 @@ png_uint_32 /* PRIVATE */
png_read_chunk_header(png_structrp png_ptr)
{
png_byte buf[8];
- png_uint_32 length;
+ png_uint_32 chunk_name, length;
#ifdef PNG_IO_STATE_SUPPORTED
png_ptr->io_state = PNG_IO_READING | PNG_IO_CHUNK_HDR;
#endif
- /* Read the length and the chunk name.
- * This must be performed in a single I/O call.
+ /* Read the length and the chunk name. png_struct::chunk_name is immediately
+ * updated even if they are detectably wrong. This aids error message
+ * handling by allowing png_chunk_error to be used.
*/
png_read_data(png_ptr, buf, 8);
length = png_get_uint_31(png_ptr, buf);
-
- /* 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",
- (unsigned long)png_ptr->chunk_name, (unsigned long)length);
+ png_ptr->chunk_name = chunk_name = PNG_CHUNK_FROM_STRING(buf+4);
/* Reset the crc and run it over the chunk name. */
png_reset_crc(png_ptr);
png_calculate_crc(png_ptr, buf + 4, 4);
- /* Check to see if chunk name is valid. */
- png_check_chunk_name(png_ptr, png_ptr->chunk_name);
+ png_debug2(0, "Reading chunk typeid = 0x%lx, length = %lu",
+ (unsigned long)png_ptr->chunk_name, (unsigned long)length);
- /* Check for too-large chunk length */
- png_check_chunk_length(png_ptr, length);
+ /* Sanity check the length (first by <= 0x80) and the chunk name. An error
+ * here indicates a broken stream and libpng has no recovery from this.
+ */
+ if (buf[0] >= 0x80U)
+ png_chunk_error(png_ptr, "bad header (invalid length)");
+
+ /* Check to see if chunk name is valid. */
+ if (!check_chunk_name(chunk_name))
+ png_chunk_error(png_ptr, "bad header (invalid type)");
#ifdef PNG_IO_STATE_SUPPORTED
png_ptr->io_state = PNG_IO_READING | PNG_IO_CHUNK_DATA;
@@ -202,13 +232,85 @@ png_crc_read(png_structrp png_ptr, png_bytep buf, png_uint_32 length)
png_calculate_crc(png_ptr, buf, length);
}
+/* Compare the CRC stored in the PNG file with that calculated by libpng from
+ * the data it has read thus far.
+ */
+static int
+png_crc_error(png_structrp png_ptr, int handle_as_ancillary)
+{
+ png_byte crc_bytes[4];
+ png_uint_32 crc;
+ int need_crc = 1;
+
+ /* There are four flags two for ancillary and two for critical chunks. The
+ * default setting of these flags is all zero.
+ *
+ * PNG_FLAG_CRC_ANCILLARY_USE
+ * PNG_FLAG_CRC_ANCILLARY_NOWARN
+ * USE+NOWARN: no CRC calculation (implemented here), else;
+ * NOWARN: png_chunk_error on error (implemented in png_crc_finish)
+ * else: png_chunk_warning on error (implemented in png_crc_finish)
+ * This is the default.
+ *
+ * I.e. NOWARN without USE produces png_chunk_error. The default setting
+ * where neither are set does the same thing.
+ *
+ * PNG_FLAG_CRC_CRITICAL_USE
+ * PNG_FLAG_CRC_CRITICAL_IGNORE
+ * IGNORE: no CRC calculation (implemented here), else;
+ * USE: png_chunk_warning on error (implemented in png_crc_finish)
+ * else: png_chunk_error on error (implemented in png_crc_finish)
+ * This is the default.
+ *
+ * This arose because of original mis-implementation and has persisted for
+ * compatibility reasons.
+ *
+ * TODO: the flag names are internal so maybe this can be changed to
+ * something comprehensible.
+ */
+ if (handle_as_ancillary || PNG_CHUNK_ANCILLARY(png_ptr->chunk_name) != 0)
+ {
+ if ((png_ptr->flags & PNG_FLAG_CRC_ANCILLARY_MASK) ==
+ (PNG_FLAG_CRC_ANCILLARY_USE | PNG_FLAG_CRC_ANCILLARY_NOWARN))
+ need_crc = 0;
+ }
+
+ else /* critical */
+ {
+ if ((png_ptr->flags & PNG_FLAG_CRC_CRITICAL_IGNORE) != 0)
+ need_crc = 0;
+ }
+
+#ifdef PNG_IO_STATE_SUPPORTED
+ png_ptr->io_state = PNG_IO_READING | PNG_IO_CHUNK_CRC;
+#endif
+
+ /* The chunk CRC must be serialized in a single I/O call. */
+ png_read_data(png_ptr, crc_bytes, 4);
+
+ if (need_crc != 0)
+ {
+ crc = png_get_uint_32(crc_bytes);
+ return crc != png_ptr->crc;
+ }
+
+ else
+ return 0;
+}
+
/* Optionally skip data and then check the CRC. Depending on whether we
* are reading an ancillary or critical chunk, and how the program has set
* things up, we may calculate the CRC on the data and print a message.
* Returns '1' if there was a CRC error, '0' otherwise.
+ *
+ * There is one public version which is used in most places and another which
+ * takes the value for the 'critical' flag to check. This allows PLTE and IEND
+ * handling code to ignore the CRC error and removes some confusing code
+ * duplication.
*/
-int /* PRIVATE */
-png_crc_finish(png_structrp png_ptr, png_uint_32 skip)
+static int
+png_crc_finish_critical(png_structrp png_ptr, png_uint_32 skip,
+ int handle_as_ancillary)
{
/* The size of the local buffer for inflate is a good guess as to a
* reasonable size to use for buffering reads from the application.
@@ -226,82 +328,59 @@ png_crc_finish(png_structrp png_ptr, png_uint_32 skip)
png_crc_read(png_ptr, tmpbuf, len);
}
- if (png_crc_error(png_ptr) != 0)
+ /* If 'handle_as_ancillary' has been requested and this is a critical chunk
+ * but PNG_FLAG_CRC_CRITICAL_IGNORE was set then png_read_crc did not, in
+ * fact, calculate the CRC so the ANCILLARY settings should not be used
+ * instead.
+ */
+ if (handle_as_ancillary &&
+ (png_ptr->flags & PNG_FLAG_CRC_CRITICAL_IGNORE) != 0)
+ handle_as_ancillary = 0;
+
+ /* TODO: this might be more comprehensible if png_crc_error was inlined here.
+ */
+ if (png_crc_error(png_ptr, handle_as_ancillary) != 0)
{
- if (PNG_CHUNK_ANCILLARY(png_ptr->chunk_name) != 0 ?
+ /* See above for the explanation of how the flags work. */
+ if (handle_as_ancillary || PNG_CHUNK_ANCILLARY(png_ptr->chunk_name) != 0 ?
(png_ptr->flags & PNG_FLAG_CRC_ANCILLARY_NOWARN) == 0 :
(png_ptr->flags & PNG_FLAG_CRC_CRITICAL_USE) != 0)
- {
png_chunk_warning(png_ptr, "CRC error");
- }
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
- * the data it has read thus far.
- */
int /* PRIVATE */
-png_crc_error(png_structrp png_ptr)
+png_crc_finish(png_structrp png_ptr, png_uint_32 skip)
{
- png_byte crc_bytes[4];
- png_uint_32 crc;
- int need_crc = 1;
-
- if (PNG_CHUNK_ANCILLARY(png_ptr->chunk_name) != 0)
- {
- if ((png_ptr->flags & PNG_FLAG_CRC_ANCILLARY_MASK) ==
- (PNG_FLAG_CRC_ANCILLARY_USE | PNG_FLAG_CRC_ANCILLARY_NOWARN))
- need_crc = 0;
- }
-
- else /* critical */
- {
- if ((png_ptr->flags & PNG_FLAG_CRC_CRITICAL_IGNORE) != 0)
- need_crc = 0;
- }
-
-#ifdef PNG_IO_STATE_SUPPORTED
- png_ptr->io_state = PNG_IO_READING | PNG_IO_CHUNK_CRC;
-#endif
-
- /* The chunk CRC must be serialized in a single I/O call. */
- png_read_data(png_ptr, crc_bytes, 4);
-
- if (need_crc != 0)
- {
- crc = png_get_uint_32(crc_bytes);
- return ((int)(crc != png_ptr->crc));
- }
-
- else
- return (0);
+ return png_crc_finish_critical(png_ptr, skip, 0/*critical handling*/);
}
#if defined(PNG_READ_iCCP_SUPPORTED) || defined(PNG_READ_iTXt_SUPPORTED) ||\
defined(PNG_READ_pCAL_SUPPORTED) || defined(PNG_READ_sCAL_SUPPORTED) ||\
defined(PNG_READ_sPLT_SUPPORTED) || defined(PNG_READ_tEXt_SUPPORTED) ||\
- defined(PNG_READ_zTXt_SUPPORTED) || defined(PNG_SEQUENTIAL_READ_SUPPORTED)
+ defined(PNG_READ_zTXt_SUPPORTED) || defined(PNG_READ_eXIf_SUPPORTED) ||\
+ defined(PNG_SEQUENTIAL_READ_SUPPORTED)
/* Manage the read buffer; this simply reallocates the buffer if it is not small
* enough (or if it is not allocated). The routine returns a pointer to the
* buffer; if an error occurs and 'warn' is set the routine returns NULL, else
- * it will call png_error (via png_malloc) on failure. (warn == 2 means
- * 'silent').
+ * it will call png_error on failure.
*/
static png_bytep
-png_read_buffer(png_structrp png_ptr, png_alloc_size_t new_size, int warn)
+png_read_buffer(png_structrp png_ptr, png_alloc_size_t new_size)
{
png_bytep buffer = png_ptr->read_buffer;
+ if (new_size > png_chunk_max(png_ptr)) return NULL;
+
if (buffer != NULL && new_size > png_ptr->read_buffer_size)
{
- png_ptr->read_buffer = NULL;
png_ptr->read_buffer = NULL;
png_ptr->read_buffer_size = 0;
png_free(png_ptr, buffer);
@@ -314,24 +393,17 @@ png_read_buffer(png_structrp png_ptr, png_alloc_size_t new_size, int warn)
if (buffer != NULL)
{
- memset(buffer, 0, new_size); /* just in case */
+# ifndef PNG_NO_MEMZERO /* for detecting UIM bugs **only** */
+ memset(buffer, 0, new_size); /* just in case */
+# endif
png_ptr->read_buffer = buffer;
png_ptr->read_buffer_size = new_size;
}
-
- else if (warn < 2) /* else silent */
- {
- if (warn != 0)
- png_chunk_warning(png_ptr, "insufficient memory to read chunk");
-
- else
- png_chunk_error(png_ptr, "insufficient memory to read chunk");
- }
}
return buffer;
}
-#endif /* READ_iCCP|iTXt|pCAL|sCAL|sPLT|tEXt|zTXt|SEQUENTIAL_READ */
+#endif /* READ_iCCP|iTXt|pCAL|sCAL|sPLT|tEXt|zTXt|eXIf|SEQUENTIAL_READ */
/* png_inflate_claim: claim the zstream for some nefarious purpose that involves
* decompression. Returns Z_OK on success, else a zlib error code. It checks
@@ -422,8 +494,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);
@@ -619,16 +690,7 @@ png_decompress_chunk(png_structrp png_ptr,
* maybe a '\0' terminator too. We have to assume that 'prefix_size' is
* limited only by the maximum chunk size.
*/
- png_alloc_size_t limit = PNG_SIZE_MAX;
-
-# ifdef PNG_SET_USER_LIMITS_SUPPORTED
- if (png_ptr->user_chunk_malloc_max > 0 &&
- png_ptr->user_chunk_malloc_max < limit)
- limit = png_ptr->user_chunk_malloc_max;
-# elif PNG_USER_CHUNK_MALLOC_MAX > 0
- if (PNG_USER_CHUNK_MALLOC_MAX < limit)
- limit = PNG_USER_CHUNK_MALLOC_MAX;
-# endif
+ png_alloc_size_t limit = png_chunk_max(png_ptr);
if (limit >= prefix_size + (terminate != 0))
{
@@ -833,9 +895,9 @@ png_inflate_read(png_structrp png_ptr, png_bytep read_buffer, uInt read_size,
}
#endif /* READ_iCCP */
+/* CHUNK HANDLING */
/* Read and check the IDHR chunk */
-
-void /* PRIVATE */
+static png_handle_result_code
png_handle_IHDR(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
{
png_byte buf[13];
@@ -845,12 +907,7 @@ png_handle_IHDR(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
png_debug(1, "in png_handle_IHDR");
- if ((png_ptr->mode & PNG_HAVE_IHDR) != 0)
- png_chunk_error(png_ptr, "out of place");
-
- /* Check the length */
- if (length != 13)
- png_chunk_error(png_ptr, "invalid");
+ /* Length and position are checked by the caller. */
png_ptr->mode |= PNG_HAVE_IHDR;
@@ -904,257 +961,196 @@ png_handle_IHDR(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
png_debug1(3, "bit_depth = %d", png_ptr->bit_depth);
png_debug1(3, "channels = %d", png_ptr->channels);
png_debug1(3, "rowbytes = %lu", (unsigned long)png_ptr->rowbytes);
+
+ /* Rely on png_set_IHDR to completely validate the data and call png_error if
+ * it's wrong.
+ */
png_set_IHDR(png_ptr, info_ptr, width, height, bit_depth,
color_type, interlace_type, compression_type, filter_type);
+
+ return handled_ok;
+ PNG_UNUSED(length)
}
/* Read and check the palette */
-void /* PRIVATE */
+/* TODO: there are several obvious errors in this code when handling
+ * out-of-place chunks and there is much over-complexity caused by trying to
+ * patch up the problems.
+ */
+static png_handle_result_code
png_handle_PLTE(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
{
- png_color palette[PNG_MAX_PALETTE_LENGTH];
- int max_palette_length, num, i;
-#ifdef PNG_POINTER_INDEXING_SUPPORTED
- png_colorp pal_ptr;
-#endif
+ png_const_charp errmsg = NULL;
png_debug(1, "in png_handle_PLTE");
- if ((png_ptr->mode & PNG_HAVE_IHDR) == 0)
- png_chunk_error(png_ptr, "missing IHDR");
-
- /* Moved to before the 'after IDAT' check below because otherwise duplicate
- * PLTE chunks are potentially ignored (the spec says there shall not be more
- * than one PLTE, the error is not treated as benign, so this check trumps
- * the requirement that PLTE appears before IDAT.)
+ /* 1.6.47: consistency. This used to be especially treated as a critical
+ * error even in an image which is not colour mapped, there isn't a good
+ * justification for treating some errors here one way and others another so
+ * everything uses the same logic.
*/
- else if ((png_ptr->mode & PNG_HAVE_PLTE) != 0)
- png_chunk_error(png_ptr, "duplicate");
+ if ((png_ptr->mode & PNG_HAVE_PLTE) != 0)
+ errmsg = "duplicate";
else if ((png_ptr->mode & PNG_HAVE_IDAT) != 0)
- {
- /* This is benign because the non-benign error happened before, when an
- * IDAT was encountered in a color-mapped image with no PLTE.
- */
- png_crc_finish(png_ptr, length);
- png_chunk_benign_error(png_ptr, "out of place");
- return;
- }
+ errmsg = "out of place";
- png_ptr->mode |= PNG_HAVE_PLTE;
+ else if ((png_ptr->color_type & PNG_COLOR_MASK_COLOR) == 0)
+ errmsg = "ignored in grayscale PNG";
- if ((png_ptr->color_type & PNG_COLOR_MASK_COLOR) == 0)
- {
- png_crc_finish(png_ptr, length);
- png_chunk_benign_error(png_ptr, "ignored in grayscale PNG");
- return;
- }
+ else if (length > 3*PNG_MAX_PALETTE_LENGTH || (length % 3) != 0)
+ errmsg = "invalid";
-#ifndef PNG_READ_OPT_PLTE_SUPPORTED
- if (png_ptr->color_type != PNG_COLOR_TYPE_PALETTE)
- {
- png_crc_finish(png_ptr, length);
- return;
- }
-#endif
+ /* This drops PLTE in favour of tRNS or bKGD because both of those chunks
+ * can have an effect on the rendering of the image whereas PLTE only matters
+ * in the case of an 8-bit display with a decoder which controls the palette.
+ *
+ * The alternative here is to ignore the error and store the palette anyway;
+ * destroying the tRNS will definately cause problems.
+ *
+ * NOTE: the case of PNG_COLOR_TYPE_PALETTE need not be considered because
+ * the png_handle_ routines for the three 'after PLTE' chunks tRNS, bKGD and
+ * hIST all check for a preceding PLTE in these cases.
+ */
+ else if (png_ptr->color_type != PNG_COLOR_TYPE_PALETTE &&
+ (png_has_chunk(png_ptr, tRNS) || png_has_chunk(png_ptr, bKGD)))
+ errmsg = "out of place";
- if (length > 3*PNG_MAX_PALETTE_LENGTH || length % 3)
+ else
{
- png_crc_finish(png_ptr, length);
-
- if (png_ptr->color_type != PNG_COLOR_TYPE_PALETTE)
- png_chunk_benign_error(png_ptr, "invalid");
+ /* If the palette has 256 or fewer entries but is too large for the bit
+ * depth we don't issue an error to preserve the behavior of previous
+ * libpng versions. We silently truncate the unused extra palette entries
+ * here.
+ */
+ const unsigned max_palette_length =
+ (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE) ?
+ 1U << png_ptr->bit_depth : PNG_MAX_PALETTE_LENGTH;
- else
- png_chunk_error(png_ptr, "invalid");
+ /* The cast is safe because 'length' is less than
+ * 3*PNG_MAX_PALETTE_LENGTH
+ */
+ const unsigned num = (length > 3U*max_palette_length) ?
+ max_palette_length : (unsigned)length / 3U;
- return;
- }
+ unsigned i, j;
+ png_byte buf[3*PNG_MAX_PALETTE_LENGTH];
+ png_color palette[PNG_MAX_PALETTE_LENGTH];
- /* The cast is safe because 'length' is less than 3*PNG_MAX_PALETTE_LENGTH */
- num = (int)length / 3;
+ /* Read the chunk into the buffer then read to the end of the chunk. */
+ png_crc_read(png_ptr, buf, num*3U);
+ png_crc_finish_critical(png_ptr, length - 3U*num,
+ /* Handle as ancillary if PLTE is optional: */
+ png_ptr->color_type != PNG_COLOR_TYPE_PALETTE);
- /* If the palette has 256 or fewer entries but is too large for the bit
- * depth, we don't issue an error, to preserve the behavior of previous
- * libpng versions. We silently truncate the unused extra palette entries
- * here.
- */
- if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
- max_palette_length = (1 << png_ptr->bit_depth);
- else
- max_palette_length = PNG_MAX_PALETTE_LENGTH;
-
- if (num > max_palette_length)
- num = max_palette_length;
+ for (i = 0U, j = 0U; i < num; i++)
+ {
+ palette[i].red = buf[j++];
+ palette[i].green = buf[j++];
+ palette[i].blue = buf[j++];
+ }
-#ifdef PNG_POINTER_INDEXING_SUPPORTED
- for (i = 0, pal_ptr = palette; i < num; i++, pal_ptr++)
- {
- png_byte buf[3];
+ /* A valid PLTE chunk has been read */
+ png_ptr->mode |= PNG_HAVE_PLTE;
- png_crc_read(png_ptr, buf, 3);
- pal_ptr->red = buf[0];
- pal_ptr->green = buf[1];
- pal_ptr->blue = buf[2];
- }
-#else
- for (i = 0; i < num; i++)
- {
- png_byte buf[3];
-
- png_crc_read(png_ptr, buf, 3);
- /* Don't depend upon png_color being any order */
- palette[i].red = buf[0];
- palette[i].green = buf[1];
- palette[i].blue = buf[2];
+ /* TODO: png_set_PLTE has the side effect of setting png_ptr->palette to
+ * its own copy of the palette. This has the side effect that when
+ * png_start_row is called (this happens after any call to
+ * png_read_update_info) the info_ptr palette gets changed. This is
+ * extremely unexpected and confusing.
+ *
+ * REVIEW: there have been consistent bugs in the past about gamma and
+ * similar transforms to colour mapped images being useless because the
+ * modified palette cannot be accessed because of the above.
+ *
+ * CONSIDER: Fix this by not sharing the palette in this way. But does
+ * this completely fix the problem?
+ */
+ png_set_PLTE(png_ptr, info_ptr, palette, num);
+ return handled_ok;
}
-#endif
- /* If we actually need the PLTE chunk (ie for a paletted image), we do
- * whatever the normal CRC configuration tells us. However, if we
- * have an RGB image, the PLTE can be considered ancillary, so
- * we will act as though it is.
- */
-#ifndef PNG_READ_OPT_PLTE_SUPPORTED
+ /* Here on error: errmsg is non NULL. */
if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
-#endif
{
- png_crc_finish(png_ptr, (png_uint_32) (length - (unsigned int)num * 3));
+ png_crc_finish(png_ptr, length);
+ png_chunk_error(png_ptr, errmsg);
}
-#ifndef PNG_READ_OPT_PLTE_SUPPORTED
- else if (png_crc_error(png_ptr) != 0) /* Only if we have a CRC error */
+ else /* not critical to this image */
{
- /* If we don't want to use the data from an ancillary chunk,
- * we have two options: an error abort, or a warning and we
- * ignore the data in this chunk (which should be OK, since
- * it's considered ancillary for a RGB or RGBA image).
- *
- * IMPLEMENTATION NOTE: this is only here because png_crc_finish uses the
- * chunk type to determine whether to check the ancillary or the critical
- * flags.
- */
- if ((png_ptr->flags & PNG_FLAG_CRC_ANCILLARY_USE) == 0)
- {
- if ((png_ptr->flags & PNG_FLAG_CRC_ANCILLARY_NOWARN) != 0)
- return;
-
- else
- png_chunk_error(png_ptr, "CRC error");
- }
-
- /* Otherwise, we (optionally) emit a warning and use the chunk. */
- else if ((png_ptr->flags & PNG_FLAG_CRC_ANCILLARY_NOWARN) == 0)
- png_chunk_warning(png_ptr, "CRC error");
+ png_crc_finish_critical(png_ptr, length, 1/*handle as ancillary*/);
+ png_chunk_benign_error(png_ptr, errmsg);
}
-#endif
- /* TODO: png_set_PLTE has the side effect of setting png_ptr->palette to its
- * own copy of the palette. This has the side effect that when png_start_row
- * is called (this happens after any call to png_read_update_info) the
- * info_ptr palette gets changed. This is extremely unexpected and
- * confusing.
- *
- * Fix this by not sharing the palette in this way.
- */
- png_set_PLTE(png_ptr, info_ptr, palette, num);
-
- /* The three chunks, bKGD, hIST and tRNS *must* appear after PLTE and before
- * IDAT. Prior to 1.6.0 this was not checked; instead the code merely
- * checked the apparent validity of a tRNS chunk inserted before PLTE on a
- * palette PNG. 1.6.0 attempts to rigorously follow the standard and
- * therefore does a benign error if the erroneous condition is detected *and*
- * cancels the tRNS if the benign error returns. The alternative is to
- * amend the standard since it would be rather hypocritical of the standards
- * maintainers to ignore it.
+ /* Because PNG_UNUSED(errmsg) does not work if all the uses are compiled out
+ * (this does happen).
*/
-#ifdef PNG_READ_tRNS_SUPPORTED
- if (png_ptr->num_trans > 0 ||
- (info_ptr != NULL && (info_ptr->valid & PNG_INFO_tRNS) != 0))
- {
- /* Cancel this because otherwise it would be used if the transforms
- * require it. Don't cancel the 'valid' flag because this would prevent
- * detection of duplicate chunks.
- */
- png_ptr->num_trans = 0;
-
- if (info_ptr != NULL)
- info_ptr->num_trans = 0;
-
- png_chunk_benign_error(png_ptr, "tRNS must be after");
- }
-#endif
-
-#ifdef PNG_READ_hIST_SUPPORTED
- if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_hIST) != 0)
- png_chunk_benign_error(png_ptr, "hIST must be after");
-#endif
-
-#ifdef PNG_READ_bKGD_SUPPORTED
- if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_bKGD) != 0)
- png_chunk_benign_error(png_ptr, "bKGD must be after");
-#endif
+ return errmsg != NULL ? handled_error : handled_error;
}
-void /* PRIVATE */
+/* On read the IDAT chunk is always handled specially, even if marked for
+ * unknown handling (this is allowed), so:
+ */
+#define png_handle_IDAT NULL
+
+static png_handle_result_code
png_handle_IEND(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
{
png_debug(1, "in png_handle_IEND");
- if ((png_ptr->mode & PNG_HAVE_IHDR) == 0 ||
- (png_ptr->mode & PNG_HAVE_IDAT) == 0)
- png_chunk_error(png_ptr, "out of place");
-
png_ptr->mode |= (PNG_AFTER_IDAT | PNG_HAVE_IEND);
- png_crc_finish(png_ptr, length);
-
if (length != 0)
png_chunk_benign_error(png_ptr, "invalid");
+ png_crc_finish_critical(png_ptr, length, 1/*handle as ancillary*/);
+
+ return handled_ok;
PNG_UNUSED(info_ptr)
}
#ifdef PNG_READ_gAMA_SUPPORTED
-void /* PRIVATE */
+static png_handle_result_code
png_handle_gAMA(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
{
- png_fixed_point igamma;
+ png_uint_32 ugamma;
png_byte buf[4];
png_debug(1, "in png_handle_gAMA");
- if ((png_ptr->mode & PNG_HAVE_IHDR) == 0)
- png_chunk_error(png_ptr, "missing IHDR");
+ png_crc_read(png_ptr, buf, 4);
- else if ((png_ptr->mode & (PNG_HAVE_IDAT|PNG_HAVE_PLTE)) != 0)
- {
- png_crc_finish(png_ptr, length);
- png_chunk_benign_error(png_ptr, "out of place");
- return;
- }
+ if (png_crc_finish(png_ptr, 0) != 0)
+ return handled_error;
- if (length != 4)
+ ugamma = png_get_uint_32(buf);
+
+ if (ugamma > PNG_UINT_31_MAX)
{
- png_crc_finish(png_ptr, length);
png_chunk_benign_error(png_ptr, "invalid");
- return;
+ return handled_error;
}
- png_crc_read(png_ptr, buf, 4);
+ png_set_gAMA_fixed(png_ptr, info_ptr, (png_fixed_point)/*SAFE*/ugamma);
- if (png_crc_finish(png_ptr, 0) != 0)
- return;
-
- igamma = png_get_fixed_point(NULL, buf);
+#ifdef PNG_READ_GAMMA_SUPPORTED
+ /* PNGv3: chunk precedence for gamma is cICP, [iCCP], sRGB, gAMA. gAMA is
+ * at the end of the chain so simply check for an unset value.
+ */
+ if (png_ptr->chunk_gamma == 0)
+ png_ptr->chunk_gamma = (png_fixed_point)/*SAFE*/ugamma;
+#endif /*READ_GAMMA*/
- png_colorspace_set_gamma(png_ptr, &png_ptr->colorspace, igamma);
- png_colorspace_sync(png_ptr, info_ptr);
+ return handled_ok;
+ PNG_UNUSED(length)
}
+#else
+# define png_handle_gAMA NULL
#endif
#ifdef PNG_READ_sBIT_SUPPORTED
-void /* PRIVATE */
+static png_handle_result_code /* PRIVATE */
png_handle_sBIT(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
{
unsigned int truelen, i;
@@ -1163,23 +1159,6 @@ png_handle_sBIT(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
png_debug(1, "in png_handle_sBIT");
- if ((png_ptr->mode & PNG_HAVE_IHDR) == 0)
- png_chunk_error(png_ptr, "missing IHDR");
-
- else if ((png_ptr->mode & (PNG_HAVE_IDAT|PNG_HAVE_PLTE)) != 0)
- {
- png_crc_finish(png_ptr, length);
- png_chunk_benign_error(png_ptr, "out of place");
- return;
- }
-
- if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_sBIT) != 0)
- {
- png_crc_finish(png_ptr, length);
- png_chunk_benign_error(png_ptr, "duplicate");
- return;
- }
-
if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
{
truelen = 3;
@@ -1192,25 +1171,25 @@ png_handle_sBIT(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
sample_depth = png_ptr->bit_depth;
}
- if (length != truelen || length > 4)
+ if (length != truelen)
{
- png_chunk_benign_error(png_ptr, "invalid");
png_crc_finish(png_ptr, length);
- return;
+ png_chunk_benign_error(png_ptr, "bad length");
+ return handled_error;
}
buf[0] = buf[1] = buf[2] = buf[3] = sample_depth;
png_crc_read(png_ptr, buf, truelen);
if (png_crc_finish(png_ptr, 0) != 0)
- return;
+ return handled_error;
for (i=0; i sample_depth)
{
png_chunk_benign_error(png_ptr, "invalid");
- return;
+ return handled_error;
}
}
@@ -1222,7 +1201,7 @@ png_handle_sBIT(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
png_ptr->sig_bit.alpha = buf[3];
}
- else
+ else /* grayscale */
{
png_ptr->sig_bit.gray = buf[0];
png_ptr->sig_bit.red = buf[0];
@@ -1232,133 +1211,132 @@ png_handle_sBIT(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
}
png_set_sBIT(png_ptr, info_ptr, &(png_ptr->sig_bit));
+ return handled_ok;
}
+#else
+# define png_handle_sBIT NULL
#endif
#ifdef PNG_READ_cHRM_SUPPORTED
-void /* PRIVATE */
-png_handle_cHRM(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
+static png_int_32
+png_get_int_32_checked(png_const_bytep buf, int *error)
{
- png_byte buf[32];
- png_xy xy;
+ png_uint_32 uval = png_get_uint_32(buf);
+ if ((uval & 0x80000000) == 0) /* non-negative */
+ return (png_int_32)uval;
- png_debug(1, "in png_handle_cHRM");
+ uval = (uval ^ 0xffffffff) + 1; /* 2's complement: -x = ~x+1 */
+ if ((uval & 0x80000000) == 0) /* no overflow */
+ return -(png_int_32)uval;
- if ((png_ptr->mode & PNG_HAVE_IHDR) == 0)
- png_chunk_error(png_ptr, "missing IHDR");
+ /* This version of png_get_int_32 has a way of returning the error to the
+ * caller, so:
+ */
+ *error = 1;
+ return 0; /* Safe */
+}
- else if ((png_ptr->mode & (PNG_HAVE_IDAT|PNG_HAVE_PLTE)) != 0)
- {
- png_crc_finish(png_ptr, length);
- png_chunk_benign_error(png_ptr, "out of place");
- return;
- }
+static png_handle_result_code /* PRIVATE */
+png_handle_cHRM(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
+{
+ int error = 0;
+ png_xy xy;
+ png_byte buf[32];
- if (length != 32)
- {
- png_crc_finish(png_ptr, length);
- png_chunk_benign_error(png_ptr, "invalid");
- return;
- }
+ png_debug(1, "in png_handle_cHRM");
png_crc_read(png_ptr, buf, 32);
if (png_crc_finish(png_ptr, 0) != 0)
- return;
+ return handled_error;
+
+ xy.whitex = png_get_int_32_checked(buf + 0, &error);
+ xy.whitey = png_get_int_32_checked(buf + 4, &error);
+ xy.redx = png_get_int_32_checked(buf + 8, &error);
+ xy.redy = png_get_int_32_checked(buf + 12, &error);
+ xy.greenx = png_get_int_32_checked(buf + 16, &error);
+ xy.greeny = png_get_int_32_checked(buf + 20, &error);
+ xy.bluex = png_get_int_32_checked(buf + 24, &error);
+ xy.bluey = png_get_int_32_checked(buf + 28, &error);
- xy.whitex = png_get_fixed_point(NULL, buf);
- xy.whitey = png_get_fixed_point(NULL, buf + 4);
- xy.redx = png_get_fixed_point(NULL, buf + 8);
- xy.redy = png_get_fixed_point(NULL, buf + 12);
- xy.greenx = png_get_fixed_point(NULL, buf + 16);
- xy.greeny = png_get_fixed_point(NULL, buf + 20);
- xy.bluex = png_get_fixed_point(NULL, buf + 24);
- xy.bluey = png_get_fixed_point(NULL, buf + 28);
-
- if (xy.whitex == PNG_FIXED_ERROR ||
- xy.whitey == PNG_FIXED_ERROR ||
- xy.redx == PNG_FIXED_ERROR ||
- xy.redy == PNG_FIXED_ERROR ||
- xy.greenx == PNG_FIXED_ERROR ||
- xy.greeny == PNG_FIXED_ERROR ||
- xy.bluex == PNG_FIXED_ERROR ||
- xy.bluey == PNG_FIXED_ERROR)
+ if (error)
{
- png_chunk_benign_error(png_ptr, "invalid values");
- return;
+ png_chunk_benign_error(png_ptr, "invalid");
+ return handled_error;
}
- /* If a colorspace error has already been output skip this chunk */
- if ((png_ptr->colorspace.flags & PNG_COLORSPACE_INVALID) != 0)
- return;
+ /* png_set_cHRM may complain about some of the values but this doesn't matter
+ * because it was a cHRM and it did have vaguely (if, perhaps, ridiculous)
+ * values. Ridiculousity will be checked if the values are used later.
+ */
+ png_set_cHRM_fixed(png_ptr, info_ptr, xy.whitex, xy.whitey, xy.redx, xy.redy,
+ xy.greenx, xy.greeny, xy.bluex, xy.bluey);
- if ((png_ptr->colorspace.flags & PNG_COLORSPACE_FROM_cHRM) != 0)
- {
- png_ptr->colorspace.flags |= PNG_COLORSPACE_INVALID;
- png_colorspace_sync(png_ptr, info_ptr);
- png_chunk_benign_error(png_ptr, "duplicate");
- return;
- }
+ /* We only use 'chromaticities' for RGB to gray */
+# ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED
+ /* There is no need to check sRGB here, cICP is NYI and iCCP is not
+ * supported so just check mDCV.
+ */
+ if (!png_has_chunk(png_ptr, mDCV))
+ {
+ png_ptr->chromaticities = xy;
+ }
+# endif /* READ_RGB_TO_GRAY */
- png_ptr->colorspace.flags |= PNG_COLORSPACE_FROM_cHRM;
- (void)png_colorspace_set_chromaticities(png_ptr, &png_ptr->colorspace, &xy,
- 1/*prefer cHRM values*/);
- png_colorspace_sync(png_ptr, info_ptr);
+ return handled_ok;
+ PNG_UNUSED(length)
}
+#else
+# define png_handle_cHRM NULL
#endif
#ifdef PNG_READ_sRGB_SUPPORTED
-void /* PRIVATE */
+static png_handle_result_code /* PRIVATE */
png_handle_sRGB(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
{
png_byte intent;
png_debug(1, "in png_handle_sRGB");
- if ((png_ptr->mode & PNG_HAVE_IHDR) == 0)
- png_chunk_error(png_ptr, "missing IHDR");
-
- else if ((png_ptr->mode & (PNG_HAVE_IDAT|PNG_HAVE_PLTE)) != 0)
- {
- png_crc_finish(png_ptr, length);
- png_chunk_benign_error(png_ptr, "out of place");
- return;
- }
-
- if (length != 1)
- {
- png_crc_finish(png_ptr, length);
- png_chunk_benign_error(png_ptr, "invalid");
- return;
- }
-
png_crc_read(png_ptr, &intent, 1);
if (png_crc_finish(png_ptr, 0) != 0)
- return;
-
- /* If a colorspace error has already been output skip this chunk */
- if ((png_ptr->colorspace.flags & PNG_COLORSPACE_INVALID) != 0)
- return;
+ return handled_error;
- /* Only one sRGB or iCCP chunk is allowed, use the HAVE_INTENT flag to detect
- * this.
+ /* This checks the range of the "rendering intent" because it is specified in
+ * the PNG spec itself; the "reserved" values will result in the chunk not
+ * being accepted, just as they do with the various "reserved" values in
+ * IHDR.
*/
- if ((png_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_INTENT) != 0)
+ if (intent > 3/*PNGv3 spec*/)
{
- png_ptr->colorspace.flags |= PNG_COLORSPACE_INVALID;
- png_colorspace_sync(png_ptr, info_ptr);
- png_chunk_benign_error(png_ptr, "too many profiles");
- return;
+ png_chunk_benign_error(png_ptr, "invalid");
+ return handled_error;
}
- (void)png_colorspace_set_sRGB(png_ptr, &png_ptr->colorspace, intent);
- png_colorspace_sync(png_ptr, info_ptr);
+ png_set_sRGB(png_ptr, info_ptr, intent);
+ /* NOTE: png_struct::chromaticities is not set here because the RGB to gray
+ * coefficients are known without a need for the chromaticities.
+ */
+
+#ifdef PNG_READ_GAMMA_SUPPORTED
+ /* PNGv3: chunk precedence for gamma is cICP, [iCCP], sRGB, gAMA. iCCP is
+ * not supported by libpng so the only requirement is to check for cICP
+ * setting the gamma (this is NYI, but this check is safe.)
+ */
+ if (!png_has_chunk(png_ptr, cICP) || png_ptr->chunk_gamma == 0)
+ png_ptr->chunk_gamma = PNG_GAMMA_sRGB_INVERSE;
+#endif /*READ_GAMMA*/
+
+ return handled_ok;
+ PNG_UNUSED(length)
}
+#else
+# define png_handle_sRGB NULL
#endif /* READ_sRGB */
#ifdef PNG_READ_iCCP_SUPPORTED
-void /* PRIVATE */
+static png_handle_result_code /* PRIVATE */
png_handle_iCCP(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
/* Note: this does not properly handle profiles that are > 64K under DOS */
{
@@ -1367,44 +1345,10 @@ png_handle_iCCP(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
png_debug(1, "in png_handle_iCCP");
- if ((png_ptr->mode & PNG_HAVE_IHDR) == 0)
- png_chunk_error(png_ptr, "missing IHDR");
-
- else if ((png_ptr->mode & (PNG_HAVE_IDAT|PNG_HAVE_PLTE)) != 0)
- {
- png_crc_finish(png_ptr, length);
- png_chunk_benign_error(png_ptr, "out of place");
- return;
- }
-
- /* Consistent with all the above colorspace handling an obviously *invalid*
- * chunk is just ignored, so does not invalidate the color space. An
- * alternative is to set the 'invalid' flags at the start of this routine
- * and only clear them in they were not set before and all the tests pass.
- */
-
- /* The keyword must be at least one character and there is a
- * terminator (0) byte and the compression method byte, and the
- * 'zlib' datastream is at least 11 bytes.
+ /* PNGv3: allow PNG files with both sRGB and iCCP because the PNG spec only
+ * ever said that there "should" be only one, not "shall" and the PNGv3
+ * colour chunk precedence rules give a handling for this case anyway.
*/
- if (length < 14)
- {
- png_crc_finish(png_ptr, length);
- png_chunk_benign_error(png_ptr, "too short");
- return;
- }
-
- /* If a colorspace error has already been output skip this chunk */
- if ((png_ptr->colorspace.flags & PNG_COLORSPACE_INVALID) != 0)
- {
- png_crc_finish(png_ptr, length);
- return;
- }
-
- /* Only one sRGB or iCCP chunk is allowed, use the HAVE_INTENT flag to detect
- * this.
- */
- if ((png_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_INTENT) == 0)
{
uInt read_length, keyword_length;
char keyword[81];
@@ -1414,19 +1358,16 @@ png_handle_iCCP(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
*/
read_length = 81; /* maximum */
if (read_length > length)
- read_length = (uInt)length;
+ read_length = (uInt)/*SAFE*/length;
png_crc_read(png_ptr, (png_bytep)keyword, read_length);
length -= read_length;
- /* The minimum 'zlib' stream is assumed to be just the 2 byte header,
- * 5 bytes minimum 'deflate' stream, and the 4 byte checksum.
- */
- if (length < 11)
+ if (length < LZ77Min)
{
png_crc_finish(png_ptr, length);
png_chunk_benign_error(png_ptr, "too short");
- return;
+ return handled_error;
}
keyword_length = 0;
@@ -1463,15 +1404,14 @@ png_handle_iCCP(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
*/
png_uint_32 profile_length = png_get_uint_32(profile_header);
- if (png_icc_check_length(png_ptr, &png_ptr->colorspace,
- keyword, profile_length) != 0)
+ if (png_icc_check_length(png_ptr, keyword, profile_length) !=
+ 0)
{
/* The length is apparently ok, so we can check the 132
* byte header.
*/
- if (png_icc_check_header(png_ptr, &png_ptr->colorspace,
- keyword, profile_length, profile_header,
- png_ptr->color_type) != 0)
+ if (png_icc_check_header(png_ptr, keyword, profile_length,
+ profile_header, png_ptr->color_type) != 0)
{
/* Now read the tag table; a variable size buffer is
* needed at this point, allocate one for the whole
@@ -1481,7 +1421,7 @@ png_handle_iCCP(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
png_uint_32 tag_count =
png_get_uint_32(profile_header + 128);
png_bytep profile = png_read_buffer(png_ptr,
- profile_length, 2/*silent*/);
+ profile_length);
if (profile != NULL)
{
@@ -1500,8 +1440,7 @@ png_handle_iCCP(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
if (size == 0)
{
if (png_icc_check_tag_table(png_ptr,
- &png_ptr->colorspace, keyword, profile_length,
- profile) != 0)
+ keyword, profile_length, profile) != 0)
{
/* The profile has been validated for basic
* security issues, so read the whole thing in.
@@ -1533,13 +1472,6 @@ png_handle_iCCP(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
png_crc_finish(png_ptr, length);
finished = 1;
-# if defined(PNG_sRGB_SUPPORTED) && PNG_sRGB_PROFILE_CHECKS >= 0
- /* Check for a match against sRGB */
- png_icc_set_sRGB(png_ptr,
- &png_ptr->colorspace, profile,
- png_ptr->zstream.adler);
-# endif
-
/* Steal the profile for info_ptr. */
if (info_ptr != NULL)
{
@@ -1562,11 +1494,7 @@ png_handle_iCCP(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
}
else
- {
- png_ptr->colorspace.flags |=
- PNG_COLORSPACE_INVALID;
errmsg = "out of memory";
- }
}
/* else the profile remains in the read
@@ -1574,13 +1502,10 @@ png_handle_iCCP(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
* chunks.
*/
- if (info_ptr != NULL)
- png_colorspace_sync(png_ptr, info_ptr);
-
if (errmsg == NULL)
{
png_ptr->zowner = 0;
- return;
+ return handled_ok;
}
}
if (errmsg == NULL)
@@ -1621,22 +1546,21 @@ png_handle_iCCP(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
errmsg = "bad keyword";
}
- else
- errmsg = "too many profiles";
-
/* Failure: the reason is in 'errmsg' */
if (finished == 0)
png_crc_finish(png_ptr, length);
- png_ptr->colorspace.flags |= PNG_COLORSPACE_INVALID;
- png_colorspace_sync(png_ptr, info_ptr);
if (errmsg != NULL) /* else already output */
png_chunk_benign_error(png_ptr, errmsg);
+
+ return handled_error;
}
+#else
+# define png_handle_iCCP NULL
#endif /* READ_iCCP */
#ifdef PNG_READ_sPLT_SUPPORTED
-void /* PRIVATE */
+static png_handle_result_code /* PRIVATE */
png_handle_sPLT(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
/* Note: this does not properly handle chunks that are > 64K under DOS */
{
@@ -1657,43 +1581,24 @@ png_handle_sPLT(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
if (png_ptr->user_chunk_cache_max == 1)
{
png_crc_finish(png_ptr, length);
- return;
+ return handled_error;
}
if (--png_ptr->user_chunk_cache_max == 1)
{
png_warning(png_ptr, "No space in chunk cache for sPLT");
png_crc_finish(png_ptr, length);
- return;
+ return handled_error;
}
}
#endif
- if ((png_ptr->mode & PNG_HAVE_IHDR) == 0)
- png_chunk_error(png_ptr, "missing IHDR");
-
- else if ((png_ptr->mode & PNG_HAVE_IDAT) != 0)
- {
- png_crc_finish(png_ptr, length);
- png_chunk_benign_error(png_ptr, "out of place");
- return;
- }
-
-#ifdef PNG_MAX_MALLOC_64K
- if (length > 65535U)
- {
- png_crc_finish(png_ptr, length);
- png_chunk_benign_error(png_ptr, "too large to fit in memory");
- return;
- }
-#endif
-
- buffer = png_read_buffer(png_ptr, length+1, 2/*silent*/);
+ buffer = png_read_buffer(png_ptr, length+1);
if (buffer == NULL)
{
png_crc_finish(png_ptr, length);
png_chunk_benign_error(png_ptr, "out of memory");
- return;
+ return handled_error;
}
@@ -1704,7 +1609,7 @@ png_handle_sPLT(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
png_crc_read(png_ptr, buffer, length);
if (png_crc_finish(png_ptr, skip) != 0)
- return;
+ return handled_error;
buffer[length] = 0;
@@ -1717,7 +1622,7 @@ png_handle_sPLT(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
if (length < 2U || entry_start > buffer + (length - 2U))
{
png_warning(png_ptr, "malformed sPLT chunk");
- return;
+ return handled_error;
}
new_palette.depth = *entry_start++;
@@ -1731,7 +1636,7 @@ png_handle_sPLT(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
if ((data_length % (unsigned int)entry_size) != 0)
{
png_warning(png_ptr, "sPLT chunk has bad length");
- return;
+ return handled_error;
}
dl = (png_uint_32)(data_length / (unsigned int)entry_size);
@@ -1740,7 +1645,7 @@ png_handle_sPLT(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
if (dl > max_dl)
{
png_warning(png_ptr, "sPLT chunk too long");
- return;
+ return handled_error;
}
new_palette.nentries = (png_int_32)(data_length / (unsigned int)entry_size);
@@ -1751,10 +1656,9 @@ png_handle_sPLT(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
if (new_palette.entries == NULL)
{
png_warning(png_ptr, "sPLT chunk requires too much memory");
- return;
+ return handled_error;
}
-#ifdef PNG_POINTER_INDEXING_SUPPORTED
for (i = 0; i < new_palette.nentries; i++)
{
pp = new_palette.entries + i;
@@ -1777,31 +1681,6 @@ png_handle_sPLT(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
pp->frequency = png_get_uint_16(entry_start); entry_start += 2;
}
-#else
- pp = new_palette.entries;
-
- for (i = 0; i < new_palette.nentries; i++)
- {
-
- if (new_palette.depth == 8)
- {
- pp[i].red = *entry_start++;
- pp[i].green = *entry_start++;
- pp[i].blue = *entry_start++;
- pp[i].alpha = *entry_start++;
- }
-
- else
- {
- pp[i].red = png_get_uint_16(entry_start); entry_start += 2;
- pp[i].green = png_get_uint_16(entry_start); entry_start += 2;
- pp[i].blue = png_get_uint_16(entry_start); entry_start += 2;
- pp[i].alpha = png_get_uint_16(entry_start); entry_start += 2;
- }
-
- pp[i].frequency = png_get_uint_16(entry_start); entry_start += 2;
- }
-#endif
/* Discard all chunk data except the name and stash that */
new_palette.name = (png_charp)buffer;
@@ -1809,34 +1688,20 @@ png_handle_sPLT(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
png_set_sPLT(png_ptr, info_ptr, &new_palette, 1);
png_free(png_ptr, new_palette.entries);
+ return handled_ok;
}
+#else
+# define png_handle_sPLT NULL
#endif /* READ_sPLT */
#ifdef PNG_READ_tRNS_SUPPORTED
-void /* PRIVATE */
+static png_handle_result_code /* PRIVATE */
png_handle_tRNS(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
{
png_byte readbuf[PNG_MAX_PALETTE_LENGTH];
png_debug(1, "in png_handle_tRNS");
- if ((png_ptr->mode & PNG_HAVE_IHDR) == 0)
- png_chunk_error(png_ptr, "missing IHDR");
-
- else if ((png_ptr->mode & PNG_HAVE_IDAT) != 0)
- {
- png_crc_finish(png_ptr, length);
- png_chunk_benign_error(png_ptr, "out of place");
- return;
- }
-
- else if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_tRNS) != 0)
- {
- png_crc_finish(png_ptr, length);
- png_chunk_benign_error(png_ptr, "duplicate");
- return;
- }
-
if (png_ptr->color_type == PNG_COLOR_TYPE_GRAY)
{
png_byte buf[2];
@@ -1845,7 +1710,7 @@ png_handle_tRNS(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
{
png_crc_finish(png_ptr, length);
png_chunk_benign_error(png_ptr, "invalid");
- return;
+ return handled_error;
}
png_crc_read(png_ptr, buf, 2);
@@ -1861,7 +1726,7 @@ png_handle_tRNS(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
{
png_crc_finish(png_ptr, length);
png_chunk_benign_error(png_ptr, "invalid");
- return;
+ return handled_error;
}
png_crc_read(png_ptr, buf, length);
@@ -1875,10 +1740,9 @@ png_handle_tRNS(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
{
if ((png_ptr->mode & PNG_HAVE_PLTE) == 0)
{
- /* TODO: is this actually an error in the ISO spec? */
png_crc_finish(png_ptr, length);
png_chunk_benign_error(png_ptr, "out of place");
- return;
+ return handled_error;
}
if (length > (unsigned int) png_ptr->num_palette ||
@@ -1887,7 +1751,7 @@ png_handle_tRNS(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
{
png_crc_finish(png_ptr, length);
png_chunk_benign_error(png_ptr, "invalid");
- return;
+ return handled_error;
}
png_crc_read(png_ptr, readbuf, length);
@@ -1898,13 +1762,13 @@ png_handle_tRNS(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
{
png_crc_finish(png_ptr, length);
png_chunk_benign_error(png_ptr, "invalid with alpha channel");
- return;
+ return handled_error;
}
if (png_crc_finish(png_ptr, 0) != 0)
{
png_ptr->num_trans = 0;
- return;
+ return handled_error;
}
/* TODO: this is a horrible side effect in the palette case because the
@@ -1913,11 +1777,14 @@ png_handle_tRNS(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
*/
png_set_tRNS(png_ptr, info_ptr, readbuf, png_ptr->num_trans,
&(png_ptr->trans_color));
+ return handled_ok;
}
+#else
+# define png_handle_tRNS NULL
#endif
#ifdef PNG_READ_bKGD_SUPPORTED
-void /* PRIVATE */
+static png_handle_result_code /* PRIVATE */
png_handle_bKGD(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
{
unsigned int truelen;
@@ -1926,27 +1793,17 @@ png_handle_bKGD(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
png_debug(1, "in png_handle_bKGD");
- if ((png_ptr->mode & PNG_HAVE_IHDR) == 0)
- png_chunk_error(png_ptr, "missing IHDR");
-
- else if ((png_ptr->mode & PNG_HAVE_IDAT) != 0 ||
- (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE &&
- (png_ptr->mode & PNG_HAVE_PLTE) == 0))
- {
- png_crc_finish(png_ptr, length);
- png_chunk_benign_error(png_ptr, "out of place");
- return;
- }
-
- else if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_bKGD) != 0)
+ if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
{
- png_crc_finish(png_ptr, length);
- png_chunk_benign_error(png_ptr, "duplicate");
- return;
- }
+ if ((png_ptr->mode & PNG_HAVE_PLTE) == 0)
+ {
+ png_crc_finish(png_ptr, length);
+ png_chunk_benign_error(png_ptr, "out of place");
+ return handled_error;
+ }
- if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
truelen = 1;
+ }
else if ((png_ptr->color_type & PNG_COLOR_MASK_COLOR) != 0)
truelen = 6;
@@ -1958,13 +1815,13 @@ png_handle_bKGD(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
{
png_crc_finish(png_ptr, length);
png_chunk_benign_error(png_ptr, "invalid");
- return;
+ return handled_error;
}
png_crc_read(png_ptr, buf, truelen);
if (png_crc_finish(png_ptr, 0) != 0)
- return;
+ return handled_error;
/* We convert the index value into RGB components so that we can allow
* arbitrary RGB values for background when we have transparency, and
@@ -1980,7 +1837,7 @@ png_handle_bKGD(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
if (buf[0] >= info_ptr->num_palette)
{
png_chunk_benign_error(png_ptr, "invalid index");
- return;
+ return handled_error;
}
background.red = (png_uint_16)png_ptr->palette[buf[0]].red;
@@ -2001,7 +1858,7 @@ png_handle_bKGD(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
if (buf[0] != 0 || buf[1] >= (unsigned int)(1 << png_ptr->bit_depth))
{
png_chunk_benign_error(png_ptr, "invalid gray level");
- return;
+ return handled_error;
}
}
@@ -2019,7 +1876,7 @@ png_handle_bKGD(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
if (buf[0] != 0 || buf[2] != 0 || buf[4] != 0)
{
png_chunk_benign_error(png_ptr, "invalid color");
- return;
+ return handled_error;
}
}
@@ -2031,74 +1888,174 @@ png_handle_bKGD(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
}
png_set_bKGD(png_ptr, info_ptr, &background);
+ return handled_ok;
+}
+#else
+# define png_handle_bKGD NULL
+#endif
+
+#ifdef PNG_READ_cICP_SUPPORTED
+static png_handle_result_code /* PRIVATE */
+png_handle_cICP(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
+{
+ png_byte buf[4];
+
+ png_debug(1, "in png_handle_cICP");
+
+ png_crc_read(png_ptr, buf, 4);
+
+ if (png_crc_finish(png_ptr, 0) != 0)
+ return handled_error;
+
+ png_set_cICP(png_ptr, info_ptr, buf[0], buf[1], buf[2], buf[3]);
+
+ /* We only use 'chromaticities' for RGB to gray */
+# ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED
+ if (!png_has_chunk(png_ptr, mDCV))
+ {
+ /* TODO: png_ptr->chromaticities = chromaticities; */
+ }
+# endif /* READ_RGB_TO_GRAY */
+
+#ifdef PNG_READ_GAMMA_SUPPORTED
+ /* PNGv3: chunk precedence for gamma is cICP, [iCCP], sRGB, gAMA. cICP is
+ * at the head so simply set the gamma if it can be determined. If not
+ * chunk_gamma remains unchanged; sRGB and gAMA handling check it for
+ * being zero.
+ */
+ /* TODO: set png_struct::chunk_gamma when possible */
+#endif /*READ_GAMMA*/
+
+ return handled_ok;
+ PNG_UNUSED(length)
+}
+#else
+# define png_handle_cICP NULL
+#endif
+
+#ifdef PNG_READ_cLLI_SUPPORTED
+static png_handle_result_code /* PRIVATE */
+png_handle_cLLI(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
+{
+ png_byte buf[8];
+
+ png_debug(1, "in png_handle_cLLI");
+
+ png_crc_read(png_ptr, buf, 8);
+
+ if (png_crc_finish(png_ptr, 0) != 0)
+ return handled_error;
+
+ /* The error checking happens here, this puts it in just one place: */
+ png_set_cLLI_fixed(png_ptr, info_ptr, png_get_uint_32(buf),
+ png_get_uint_32(buf+4));
+ return handled_ok;
+ PNG_UNUSED(length)
}
+#else
+# define png_handle_cLLI NULL
+#endif
+
+#ifdef PNG_READ_mDCV_SUPPORTED
+static png_handle_result_code /* PRIVATE */
+png_handle_mDCV(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
+{
+ png_xy chromaticities;
+ png_byte buf[24];
+
+ png_debug(1, "in png_handle_mDCV");
+
+ png_crc_read(png_ptr, buf, 24);
+
+ if (png_crc_finish(png_ptr, 0) != 0)
+ return handled_error;
+
+ /* The error checking happens here, this puts it in just one place. The
+ * odd /50000 scaling factor makes it more difficult but the (x.y) values are
+ * only two bytes so a <<1 is safe.
+ *
+ * WARNING: the PNG specification defines the cHRM chunk to **start** with
+ * the white point (x,y). The W3C PNG v3 specification puts the white point
+ * **after* R,G,B. The x,y values in mDCV are also scaled by 50,000 and
+ * stored in just two bytes, whereas those in cHRM are scaled by 100,000 and
+ * stored in four bytes. This is very, very confusing. These APIs remove
+ * the confusion by copying the existing, well established, API.
+ */
+ chromaticities.redx = png_get_uint_16(buf+ 0U) << 1; /* red x */
+ chromaticities.redy = png_get_uint_16(buf+ 2U) << 1; /* red y */
+ chromaticities.greenx = png_get_uint_16(buf+ 4U) << 1; /* green x */
+ chromaticities.greeny = png_get_uint_16(buf+ 6U) << 1; /* green y */
+ chromaticities.bluex = png_get_uint_16(buf+ 8U) << 1; /* blue x */
+ chromaticities.bluey = png_get_uint_16(buf+10U) << 1; /* blue y */
+ chromaticities.whitex = png_get_uint_16(buf+12U) << 1; /* white x */
+ chromaticities.whitey = png_get_uint_16(buf+14U) << 1; /* white y */
+
+ png_set_mDCV_fixed(png_ptr, info_ptr,
+ chromaticities.whitex, chromaticities.whitey,
+ chromaticities.redx, chromaticities.redy,
+ chromaticities.greenx, chromaticities.greeny,
+ chromaticities.bluex, chromaticities.bluey,
+ png_get_uint_32(buf+16U), /* peak luminance */
+ png_get_uint_32(buf+20U));/* minimum perceivable luminance */
+
+ /* We only use 'chromaticities' for RGB to gray */
+# ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED
+ png_ptr->chromaticities = chromaticities;
+# endif /* READ_RGB_TO_GRAY */
+
+ return handled_ok;
+ PNG_UNUSED(length)
+}
+#else
+# define png_handle_mDCV NULL
#endif
#ifdef PNG_READ_eXIf_SUPPORTED
-void /* PRIVATE */
+static png_handle_result_code /* PRIVATE */
png_handle_eXIf(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
{
- unsigned int i;
+ png_bytep buffer = NULL;
png_debug(1, "in png_handle_eXIf");
- if ((png_ptr->mode & PNG_HAVE_IHDR) == 0)
- png_chunk_error(png_ptr, "missing IHDR");
-
- if (length < 2)
- {
- png_crc_finish(png_ptr, length);
- png_chunk_benign_error(png_ptr, "too short");
- return;
- }
+ buffer = png_read_buffer(png_ptr, length);
- else if (info_ptr == NULL || (info_ptr->valid & PNG_INFO_eXIf) != 0)
+ if (buffer == NULL)
{
png_crc_finish(png_ptr, length);
- png_chunk_benign_error(png_ptr, "duplicate");
- return;
+ png_chunk_benign_error(png_ptr, "out of memory");
+ return handled_error;
}
- info_ptr->free_me |= PNG_FREE_EXIF;
+ png_crc_read(png_ptr, buffer, length);
- info_ptr->eXIf_buf = png_voidcast(png_bytep,
- png_malloc_warn(png_ptr, length));
+ if (png_crc_finish(png_ptr, 0) != 0)
+ return handled_error;
- if (info_ptr->eXIf_buf == NULL)
+ /* PNGv3: the code used to check the byte order mark at the start for MM or
+ * II, however PNGv3 states that the the first 4 bytes should be checked.
+ * The caller ensures that there are four bytes available.
+ */
{
- png_crc_finish(png_ptr, length);
- png_chunk_benign_error(png_ptr, "out of memory");
- return;
- }
+ png_uint_32 header = png_get_uint_32(buffer);
- for (i = 0; i < length; i++)
- {
- png_byte buf[1];
- png_crc_read(png_ptr, buf, 1);
- info_ptr->eXIf_buf[i] = buf[0];
- if (i == 1 && buf[0] != 'M' && buf[0] != 'I'
- && info_ptr->eXIf_buf[0] != buf[0])
+ /* These numbers are copied from the PNGv3 spec: */
+ if (header != 0x49492A00 && header != 0x4D4D002A)
{
- png_crc_finish(png_ptr, length);
- png_chunk_benign_error(png_ptr, "incorrect byte-order specifier");
- png_free(png_ptr, info_ptr->eXIf_buf);
- info_ptr->eXIf_buf = NULL;
- return;
+ png_chunk_benign_error(png_ptr, "invalid");
+ return handled_error;
}
}
- if (png_crc_finish(png_ptr, 0) != 0)
- return;
-
- png_set_eXIf_1(png_ptr, info_ptr, length, info_ptr->eXIf_buf);
-
- png_free(png_ptr, info_ptr->eXIf_buf);
- info_ptr->eXIf_buf = NULL;
+ png_set_eXIf_1(png_ptr, info_ptr, length, buffer);
+ return handled_ok;
}
+#else
+# define png_handle_eXIf NULL
#endif
#ifdef PNG_READ_hIST_SUPPORTED
-void /* PRIVATE */
+static png_handle_result_code /* PRIVATE */
png_handle_hIST(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
{
unsigned int num, i;
@@ -2106,32 +2063,21 @@ png_handle_hIST(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
png_debug(1, "in png_handle_hIST");
- if ((png_ptr->mode & PNG_HAVE_IHDR) == 0)
- png_chunk_error(png_ptr, "missing IHDR");
-
- else if ((png_ptr->mode & PNG_HAVE_IDAT) != 0 ||
- (png_ptr->mode & PNG_HAVE_PLTE) == 0)
- {
- png_crc_finish(png_ptr, length);
- png_chunk_benign_error(png_ptr, "out of place");
- return;
- }
-
- else if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_hIST) != 0)
- {
- png_crc_finish(png_ptr, length);
- png_chunk_benign_error(png_ptr, "duplicate");
- return;
- }
-
- num = length / 2 ;
+ /* This cast is safe because the chunk definition limits the length to a
+ * maximum of 1024 bytes.
+ *
+ * TODO: maybe use png_uint_32 anyway, not unsigned int, to reduce the
+ * casts.
+ */
+ num = (unsigned int)length / 2 ;
- if (num != (unsigned int) png_ptr->num_palette ||
- num > (unsigned int) PNG_MAX_PALETTE_LENGTH)
+ if (length != num * 2 ||
+ num != (unsigned int)png_ptr->num_palette ||
+ num > (unsigned int)PNG_MAX_PALETTE_LENGTH)
{
png_crc_finish(png_ptr, length);
png_chunk_benign_error(png_ptr, "invalid");
- return;
+ return handled_error;
}
for (i = 0; i < num; i++)
@@ -2143,14 +2089,17 @@ png_handle_hIST(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
}
if (png_crc_finish(png_ptr, 0) != 0)
- return;
+ return handled_error;
png_set_hIST(png_ptr, info_ptr, readbuf);
+ return handled_ok;
}
+#else
+# define png_handle_hIST NULL
#endif
#ifdef PNG_READ_pHYs_SUPPORTED
-void /* PRIVATE */
+static png_handle_result_code /* PRIVATE */
png_handle_pHYs(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
{
png_byte buf[9];
@@ -2159,44 +2108,24 @@ png_handle_pHYs(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
png_debug(1, "in png_handle_pHYs");
- if ((png_ptr->mode & PNG_HAVE_IHDR) == 0)
- png_chunk_error(png_ptr, "missing IHDR");
-
- else if ((png_ptr->mode & PNG_HAVE_IDAT) != 0)
- {
- png_crc_finish(png_ptr, length);
- png_chunk_benign_error(png_ptr, "out of place");
- return;
- }
-
- else if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_pHYs) != 0)
- {
- png_crc_finish(png_ptr, length);
- png_chunk_benign_error(png_ptr, "duplicate");
- return;
- }
-
- if (length != 9)
- {
- png_crc_finish(png_ptr, length);
- png_chunk_benign_error(png_ptr, "invalid");
- return;
- }
-
png_crc_read(png_ptr, buf, 9);
if (png_crc_finish(png_ptr, 0) != 0)
- return;
+ return handled_error;
res_x = png_get_uint_32(buf);
res_y = png_get_uint_32(buf + 4);
unit_type = buf[8];
png_set_pHYs(png_ptr, info_ptr, res_x, res_y, unit_type);
+ return handled_ok;
+ PNG_UNUSED(length)
}
+#else
+# define png_handle_pHYs NULL
#endif
#ifdef PNG_READ_oFFs_SUPPORTED
-void /* PRIVATE */
+static png_handle_result_code /* PRIVATE */
png_handle_oFFs(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
{
png_byte buf[9];
@@ -2205,45 +2134,25 @@ png_handle_oFFs(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
png_debug(1, "in png_handle_oFFs");
- if ((png_ptr->mode & PNG_HAVE_IHDR) == 0)
- png_chunk_error(png_ptr, "missing IHDR");
-
- else if ((png_ptr->mode & PNG_HAVE_IDAT) != 0)
- {
- png_crc_finish(png_ptr, length);
- png_chunk_benign_error(png_ptr, "out of place");
- return;
- }
-
- else if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_oFFs) != 0)
- {
- png_crc_finish(png_ptr, length);
- png_chunk_benign_error(png_ptr, "duplicate");
- return;
- }
-
- if (length != 9)
- {
- png_crc_finish(png_ptr, length);
- png_chunk_benign_error(png_ptr, "invalid");
- return;
- }
-
png_crc_read(png_ptr, buf, 9);
if (png_crc_finish(png_ptr, 0) != 0)
- return;
+ return handled_error;
offset_x = png_get_int_32(buf);
offset_y = png_get_int_32(buf + 4);
unit_type = buf[8];
png_set_oFFs(png_ptr, info_ptr, offset_x, offset_y, unit_type);
+ return handled_ok;
+ PNG_UNUSED(length)
}
+#else
+# define png_handle_oFFs NULL
#endif
#ifdef PNG_READ_pCAL_SUPPORTED
/* Read the pCAL chunk (described in the PNG Extensions document) */
-void /* PRIVATE */
+static png_handle_result_code /* PRIVATE */
png_handle_pCAL(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
{
png_int_32 X0, X1;
@@ -2253,40 +2162,22 @@ png_handle_pCAL(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
int i;
png_debug(1, "in png_handle_pCAL");
-
- if ((png_ptr->mode & PNG_HAVE_IHDR) == 0)
- png_chunk_error(png_ptr, "missing IHDR");
-
- else if ((png_ptr->mode & PNG_HAVE_IDAT) != 0)
- {
- png_crc_finish(png_ptr, length);
- png_chunk_benign_error(png_ptr, "out of place");
- return;
- }
-
- else if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_pCAL) != 0)
- {
- png_crc_finish(png_ptr, length);
- png_chunk_benign_error(png_ptr, "duplicate");
- return;
- }
-
png_debug1(2, "Allocating and reading pCAL chunk data (%u bytes)",
length + 1);
- buffer = png_read_buffer(png_ptr, length+1, 2/*silent*/);
+ buffer = png_read_buffer(png_ptr, length+1);
if (buffer == NULL)
{
png_crc_finish(png_ptr, length);
png_chunk_benign_error(png_ptr, "out of memory");
- return;
+ return handled_error;
}
png_crc_read(png_ptr, buffer, length);
if (png_crc_finish(png_ptr, 0) != 0)
- return;
+ return handled_error;
buffer[length] = 0; /* Null terminate the last string */
@@ -2302,7 +2193,7 @@ png_handle_pCAL(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
if (endptr - buf <= 12)
{
png_chunk_benign_error(png_ptr, "invalid");
- return;
+ return handled_error;
}
png_debug(3, "Reading pCAL X0, X1, type, nparams, and units");
@@ -2322,7 +2213,7 @@ png_handle_pCAL(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
(type == PNG_EQUATION_HYPERBOLIC && nparams != 4))
{
png_chunk_benign_error(png_ptr, "invalid parameter count");
- return;
+ return handled_error;
}
else if (type >= PNG_EQUATION_LAST)
@@ -2341,7 +2232,7 @@ png_handle_pCAL(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
if (params == NULL)
{
png_chunk_benign_error(png_ptr, "out of memory");
- return;
+ return handled_error;
}
/* Get pointers to the start of each parameter string. */
@@ -2359,20 +2250,29 @@ png_handle_pCAL(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
{
png_free(png_ptr, params);
png_chunk_benign_error(png_ptr, "invalid data");
- return;
+ return handled_error;
}
}
png_set_pCAL(png_ptr, info_ptr, (png_charp)buffer, X0, X1, type, nparams,
(png_charp)units, params);
+ /* TODO: BUG: png_set_pCAL calls png_chunk_report which, in this case, calls
+ * png_benign_error and that can error out.
+ *
+ * png_read_buffer needs to be allocated with space for both nparams and the
+ * parameter strings. Not hard to do.
+ */
png_free(png_ptr, params);
+ return handled_ok;
}
+#else
+# define png_handle_pCAL NULL
#endif
#ifdef PNG_READ_sCAL_SUPPORTED
/* Read the sCAL chunk */
-void /* PRIVATE */
+static png_handle_result_code /* PRIVATE */
png_handle_sCAL(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
{
png_bytep buffer;
@@ -2380,55 +2280,29 @@ png_handle_sCAL(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
int state;
png_debug(1, "in png_handle_sCAL");
-
- if ((png_ptr->mode & PNG_HAVE_IHDR) == 0)
- png_chunk_error(png_ptr, "missing IHDR");
-
- else if ((png_ptr->mode & PNG_HAVE_IDAT) != 0)
- {
- png_crc_finish(png_ptr, length);
- png_chunk_benign_error(png_ptr, "out of place");
- return;
- }
-
- else if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_sCAL) != 0)
- {
- png_crc_finish(png_ptr, length);
- png_chunk_benign_error(png_ptr, "duplicate");
- return;
- }
-
- /* Need unit type, width, \0, height: minimum 4 bytes */
- else if (length < 4)
- {
- png_crc_finish(png_ptr, length);
- png_chunk_benign_error(png_ptr, "invalid");
- return;
- }
-
png_debug1(2, "Allocating and reading sCAL chunk data (%u bytes)",
length + 1);
- buffer = png_read_buffer(png_ptr, length+1, 2/*silent*/);
+ buffer = png_read_buffer(png_ptr, length+1);
if (buffer == NULL)
{
- png_chunk_benign_error(png_ptr, "out of memory");
png_crc_finish(png_ptr, length);
- return;
+ png_chunk_benign_error(png_ptr, "out of memory");
+ return handled_error;
}
png_crc_read(png_ptr, buffer, length);
buffer[length] = 0; /* Null terminate the last string */
if (png_crc_finish(png_ptr, 0) != 0)
- return;
+ return handled_error;
/* Validate the unit. */
if (buffer[0] != 1 && buffer[0] != 2)
{
png_chunk_benign_error(png_ptr, "invalid unit");
- return;
+ return handled_error;
}
/* Validate the ASCII numbers, need two ASCII numbers separated by
@@ -2457,15 +2331,22 @@ png_handle_sCAL(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
png_chunk_benign_error(png_ptr, "non-positive height");
else
+ {
/* This is the (only) success case. */
png_set_sCAL_s(png_ptr, info_ptr, buffer[0],
(png_charp)buffer+1, (png_charp)buffer+heighti);
+ return handled_ok;
+ }
}
+
+ return handled_error;
}
+#else
+# define png_handle_sCAL NULL
#endif
#ifdef PNG_READ_tIME_SUPPORTED
-void /* PRIVATE */
+static png_handle_result_code /* PRIVATE */
png_handle_tIME(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
{
png_byte buf[7];
@@ -2473,30 +2354,17 @@ png_handle_tIME(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
png_debug(1, "in png_handle_tIME");
- if ((png_ptr->mode & PNG_HAVE_IHDR) == 0)
- png_chunk_error(png_ptr, "missing IHDR");
-
- else if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_tIME) != 0)
- {
- png_crc_finish(png_ptr, length);
- png_chunk_benign_error(png_ptr, "duplicate");
- return;
- }
-
+ /* TODO: what is this doing here? It should be happened in pngread.c and
+ * pngpread.c, although it could be moved to png_handle_chunk below and
+ * thereby avoid some code duplication.
+ */
if ((png_ptr->mode & PNG_HAVE_IDAT) != 0)
png_ptr->mode |= PNG_AFTER_IDAT;
- if (length != 7)
- {
- png_crc_finish(png_ptr, length);
- png_chunk_benign_error(png_ptr, "invalid");
- return;
- }
-
png_crc_read(png_ptr, buf, 7);
if (png_crc_finish(png_ptr, 0) != 0)
- return;
+ return handled_error;
mod_time.second = buf[6];
mod_time.minute = buf[5];
@@ -2506,15 +2374,19 @@ png_handle_tIME(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
mod_time.year = png_get_uint_16(buf);
png_set_tIME(png_ptr, info_ptr, &mod_time);
+ return handled_ok;
+ PNG_UNUSED(length)
}
+#else
+# define png_handle_tIME NULL
#endif
#ifdef PNG_READ_tEXt_SUPPORTED
/* Note: this does not properly handle chunks that are > 64K under DOS */
-void /* PRIVATE */
+static png_handle_result_code /* PRIVATE */
png_handle_tEXt(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
{
- png_text text_info;
+ png_text text_info;
png_bytep buffer;
png_charp key;
png_charp text;
@@ -2528,45 +2400,31 @@ png_handle_tEXt(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
if (png_ptr->user_chunk_cache_max == 1)
{
png_crc_finish(png_ptr, length);
- return;
+ return handled_error;
}
if (--png_ptr->user_chunk_cache_max == 1)
{
png_crc_finish(png_ptr, length);
png_chunk_benign_error(png_ptr, "no space in chunk cache");
- return;
+ return handled_error;
}
}
#endif
- if ((png_ptr->mode & PNG_HAVE_IHDR) == 0)
- png_chunk_error(png_ptr, "missing IHDR");
-
- if ((png_ptr->mode & PNG_HAVE_IDAT) != 0)
- png_ptr->mode |= PNG_AFTER_IDAT;
-
-#ifdef PNG_MAX_MALLOC_64K
- if (length > 65535U)
- {
- png_crc_finish(png_ptr, length);
- png_chunk_benign_error(png_ptr, "too large to fit in memory");
- return;
- }
-#endif
-
- buffer = png_read_buffer(png_ptr, length+1, 1/*warn*/);
+ buffer = png_read_buffer(png_ptr, length+1);
if (buffer == NULL)
{
+ png_crc_finish(png_ptr, length);
png_chunk_benign_error(png_ptr, "out of memory");
- return;
+ return handled_error;
}
png_crc_read(png_ptr, buffer, length);
if (png_crc_finish(png_ptr, skip) != 0)
- return;
+ return handled_error;
key = (png_charp)buffer;
key[length] = 0;
@@ -2585,19 +2443,24 @@ png_handle_tEXt(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
text_info.text = text;
text_info.text_length = strlen(text);
- if (png_set_text_2(png_ptr, info_ptr, &text_info, 1) != 0)
- png_warning(png_ptr, "Insufficient memory to process text chunk");
+ if (png_set_text_2(png_ptr, info_ptr, &text_info, 1) == 0)
+ return handled_ok;
+
+ png_chunk_benign_error(png_ptr, "out of memory");
+ return handled_error;
}
+#else
+# define png_handle_tEXt NULL
#endif
#ifdef PNG_READ_zTXt_SUPPORTED
/* Note: this does not correctly handle chunks that are > 64K under DOS */
-void /* PRIVATE */
+static png_handle_result_code /* PRIVATE */
png_handle_zTXt(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
{
png_const_charp errmsg = NULL;
- png_bytep buffer;
- png_uint_32 keyword_length;
+ png_bytep buffer;
+ png_uint_32 keyword_length;
png_debug(1, "in png_handle_zTXt");
@@ -2607,40 +2470,35 @@ png_handle_zTXt(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
if (png_ptr->user_chunk_cache_max == 1)
{
png_crc_finish(png_ptr, length);
- return;
+ return handled_error;
}
if (--png_ptr->user_chunk_cache_max == 1)
{
png_crc_finish(png_ptr, length);
png_chunk_benign_error(png_ptr, "no space in chunk cache");
- return;
+ return handled_error;
}
}
#endif
- if ((png_ptr->mode & PNG_HAVE_IHDR) == 0)
- png_chunk_error(png_ptr, "missing IHDR");
-
- if ((png_ptr->mode & PNG_HAVE_IDAT) != 0)
- png_ptr->mode |= PNG_AFTER_IDAT;
-
/* Note, "length" is sufficient here; we won't be adding
- * a null terminator later.
+ * a null terminator later. The limit check in png_handle_chunk should be
+ * sufficient.
*/
- buffer = png_read_buffer(png_ptr, length, 2/*silent*/);
+ buffer = png_read_buffer(png_ptr, length);
if (buffer == NULL)
{
png_crc_finish(png_ptr, length);
png_chunk_benign_error(png_ptr, "out of memory");
- return;
+ return handled_error;
}
png_crc_read(png_ptr, buffer, length);
if (png_crc_finish(png_ptr, 0) != 0)
- return;
+ return handled_error;
/* TODO: also check that the keyword contents match the spec! */
for (keyword_length = 0;
@@ -2693,8 +2551,10 @@ png_handle_zTXt(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
text.lang = NULL;
text.lang_key = NULL;
- if (png_set_text_2(png_ptr, info_ptr, &text, 1) != 0)
- errmsg = "insufficient memory";
+ if (png_set_text_2(png_ptr, info_ptr, &text, 1) == 0)
+ return handled_ok;
+
+ errmsg = "out of memory";
}
}
@@ -2702,14 +2562,16 @@ png_handle_zTXt(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
errmsg = png_ptr->zstream.msg;
}
- if (errmsg != NULL)
- png_chunk_benign_error(png_ptr, errmsg);
+ png_chunk_benign_error(png_ptr, errmsg);
+ return handled_error;
}
+#else
+# define png_handle_zTXt NULL
#endif
#ifdef PNG_READ_iTXt_SUPPORTED
/* Note: this does not correctly handle chunks that are > 64K under DOS */
-void /* PRIVATE */
+static png_handle_result_code /* PRIVATE */
png_handle_iTXt(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
{
png_const_charp errmsg = NULL;
@@ -2724,37 +2586,31 @@ png_handle_iTXt(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
if (png_ptr->user_chunk_cache_max == 1)
{
png_crc_finish(png_ptr, length);
- return;
+ return handled_error;
}
if (--png_ptr->user_chunk_cache_max == 1)
{
png_crc_finish(png_ptr, length);
png_chunk_benign_error(png_ptr, "no space in chunk cache");
- return;
+ return handled_error;
}
}
#endif
- if ((png_ptr->mode & PNG_HAVE_IHDR) == 0)
- png_chunk_error(png_ptr, "missing IHDR");
-
- if ((png_ptr->mode & PNG_HAVE_IDAT) != 0)
- png_ptr->mode |= PNG_AFTER_IDAT;
-
- buffer = png_read_buffer(png_ptr, length+1, 1/*warn*/);
+ buffer = png_read_buffer(png_ptr, length+1);
if (buffer == NULL)
{
png_crc_finish(png_ptr, length);
png_chunk_benign_error(png_ptr, "out of memory");
- return;
+ return handled_error;
}
png_crc_read(png_ptr, buffer, length);
if (png_crc_finish(png_ptr, 0) != 0)
- return;
+ return handled_error;
/* First the keyword. */
for (prefix_length=0;
@@ -2844,8 +2700,10 @@ png_handle_iTXt(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
text.text_length = 0;
text.itxt_length = uncompressed_length;
- if (png_set_text_2(png_ptr, info_ptr, &text, 1) != 0)
- errmsg = "insufficient memory";
+ if (png_set_text_2(png_ptr, info_ptr, &text, 1) == 0)
+ return handled_ok;
+
+ errmsg = "out of memory";
}
}
@@ -2854,7 +2712,10 @@ png_handle_iTXt(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
if (errmsg != NULL)
png_chunk_benign_error(png_ptr, errmsg);
+ return handled_error;
}
+#else
+# define png_handle_iTXt NULL
#endif
#ifdef PNG_READ_UNKNOWN_CHUNKS_SUPPORTED
@@ -2862,7 +2723,7 @@ png_handle_iTXt(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
static int
png_cache_unknown_chunk(png_structrp png_ptr, png_uint_32 length)
{
- png_alloc_size_t limit = PNG_SIZE_MAX;
+ const png_alloc_size_t limit = png_chunk_max(png_ptr);
if (png_ptr->unknown_chunk.data != NULL)
{
@@ -2870,16 +2731,6 @@ png_cache_unknown_chunk(png_structrp png_ptr, png_uint_32 length)
png_ptr->unknown_chunk.data = NULL;
}
-# ifdef PNG_SET_USER_LIMITS_SUPPORTED
- if (png_ptr->user_chunk_malloc_max > 0 &&
- png_ptr->user_chunk_malloc_max < limit)
- limit = png_ptr->user_chunk_malloc_max;
-
-# elif PNG_USER_CHUNK_MALLOC_MAX > 0
- if (PNG_USER_CHUNK_MALLOC_MAX < limit)
- limit = PNG_USER_CHUNK_MALLOC_MAX;
-# endif
-
if (length <= limit)
{
PNG_CSTRING_FROM_CHUNK(png_ptr->unknown_chunk.name, png_ptr->chunk_name);
@@ -2918,11 +2769,11 @@ png_cache_unknown_chunk(png_structrp png_ptr, png_uint_32 length)
#endif /* READ_UNKNOWN_CHUNKS */
/* Handle an unknown, or known but disabled, chunk */
-void /* PRIVATE */
+png_handle_result_code /*PRIVATE*/
png_handle_unknown(png_structrp png_ptr, png_inforp info_ptr,
png_uint_32 length, int keep)
{
- int handled = 0; /* the chunk was handled */
+ png_handle_result_code handled = handled_discarded; /* the default */
png_debug(1, "in png_handle_unknown");
@@ -2969,7 +2820,7 @@ png_handle_unknown(png_structrp png_ptr, png_inforp info_ptr,
* error at this point unless it is to be saved.
* positive: The chunk was handled, libpng will ignore/discard it.
*/
- if (ret < 0)
+ if (ret < 0) /* handled_error */
png_chunk_error(png_ptr, "error in user chunk");
else if (ret == 0)
@@ -3003,7 +2854,7 @@ png_handle_unknown(png_structrp png_ptr, png_inforp info_ptr,
else /* chunk was handled */
{
- handled = 1;
+ handled = handled_ok;
/* Critical chunks can be safely discarded at this point. */
keep = PNG_HANDLE_CHUNK_NEVER;
}
@@ -3088,7 +2939,7 @@ png_handle_unknown(png_structrp png_ptr, png_inforp info_ptr,
*/
png_set_unknown_chunks(png_ptr, info_ptr,
&png_ptr->unknown_chunk, 1);
- handled = 1;
+ handled = handled_saved;
# ifdef PNG_USER_LIMITS_SUPPORTED
break;
}
@@ -3114,79 +2965,267 @@ png_handle_unknown(png_structrp png_ptr, png_inforp info_ptr,
#endif /* !READ_UNKNOWN_CHUNKS */
/* Check for unhandled critical chunks */
- if (handled == 0 && PNG_CHUNK_CRITICAL(png_ptr->chunk_name))
+ if (handled < handled_saved && PNG_CHUNK_CRITICAL(png_ptr->chunk_name))
png_chunk_error(png_ptr, "unhandled critical chunk");
+
+ return handled;
}
-/* This function is called to verify that a chunk name is valid.
- * This function can't have the "critical chunk check" incorporated
- * into it, since in the future we will need to be able to call user
- * functions to handle unknown critical chunks after we check that
- * the chunk name itself is valid.
+/* APNG handling: the minimal implementation of APNG handling in libpng 1.6
+ * requires that those significant applications which already handle APNG not
+ * get hosed. To do this ensure the code here will have to ensure than APNG
+ * data by default (at least in 1.6) gets stored in the unknown chunk list.
+ * Maybe this can be relaxed in a few years but at present it's just the only
+ * safe way.
+ *
+ * ATM just cause unknown handling for all three chunks:
*/
+#define png_handle_acTL NULL
+#define png_handle_fcTL NULL
+#define png_handle_fdAT NULL
-/* Bit hacking: the test for an invalid byte in the 4 byte chunk name is:
+/*
+ * 1.6.47: This is the new table driven interface to all the chunk handling.
+ *
+ * The table describes the PNG standard rules for **reading** known chunks -
+ * every chunk which has an entry in PNG_KNOWN_CHUNKS. The table contains an
+ * entry for each PNG_INDEX_cHNK describing the rules.
*
- * ((c) < 65 || (c) > 122 || ((c) > 90 && (c) < 97))
+ * In this initial version the only information in the entry is the
+ * png_handle_cHNK function for the chunk in question. When chunk support is
+ * compiled out the entry will be NULL.
*/
-
-void /* PRIVATE */
-png_check_chunk_name(png_const_structrp png_ptr, png_uint_32 chunk_name)
+static const struct
{
- int i;
- png_uint_32 cn=chunk_name;
-
- png_debug(1, "in png_check_chunk_name");
+ png_handle_result_code (*handler)(
+ png_structrp, png_inforp, png_uint_32 length);
+ /* A chunk-specific 'handler', NULL if the chunk is not supported in this
+ * build.
+ */
- for (i=1; i<=4; ++i)
+ /* Crushing these values helps on modern 32-bit architectures because the
+ * pointer and the following bit fields both end up requiring 32 bits.
+ * Typically this will halve the table size. On 64-bit architectures the
+ * table entries will typically be 8 bytes.
+ */
+ png_uint_32 max_length :12; /* Length min, max in bytes */
+ png_uint_32 min_length :8;
+ /* Length errors on critical chunks have special handling to preserve the
+ * existing behaviour in libpng 1.6. Anciallary chunks are checked below
+ * and produce a 'benign' error.
+ */
+ png_uint_32 pos_before :4; /* PNG_HAVE_ values chunk must precede */
+ png_uint_32 pos_after :4; /* PNG_HAVE_ values chunk must follow */
+ /* NOTE: PLTE, tRNS and bKGD require special handling which depends on
+ * the colour type of the base image.
+ */
+ png_uint_32 multiple :1; /* Multiple occurences permitted */
+ /* This is enabled for PLTE because PLTE may, in practice, be optional */
+}
+read_chunks[PNG_INDEX_unknown] =
+{
+ /* Definitions as above but done indirectly by #define so that
+ * PNG_KNOWN_CHUNKS can be used safely to build the table in order.
+ *
+ * Each CDcHNK definition lists the values for the parameters **after**
+ * the first, 'handler', function. 'handler' is NULL when the chunk has no
+ * compiled in support.
+ */
+# define NoCheck 0x801U /* Do not check the maximum length */
+# define Limit 0x802U /* Limit to png_chunk_max bytes */
+# define LKMin 3U+LZ77Min /* Minimum length of keyword+LZ77 */
+
+#define hIHDR PNG_HAVE_IHDR
+#define hPLTE PNG_HAVE_PLTE
+#define hIDAT PNG_HAVE_IDAT
+ /* For the two chunks, tRNS and bKGD which can occur in PNGs without a PLTE
+ * but must occur after the PLTE use this and put the check in the handler
+ * routine for colour mapped images were PLTE is required. Also put a check
+ * in PLTE for other image types to drop the PLTE if tRNS or bKGD have been
+ * seen.
+ */
+#define hCOL (PNG_HAVE_PLTE|PNG_HAVE_IDAT)
+ /* Used for the decoding chunks which must be before PLTE. */
+#define aIDAT PNG_AFTER_IDAT
+
+ /* Chunks from W3C PNG v3: */
+ /* cHNK max_len, min, before, after, multiple */
+# define CDIHDR 13U, 13U, hIHDR, 0, 0
+# define CDPLTE NoCheck, 0U, 0, hIHDR, 1
+ /* PLTE errors are only critical for colour-map images, consequently the
+ * hander does all the checks.
+ */
+# define CDIDAT NoCheck, 0U, aIDAT, hIHDR, 1
+# define CDIEND NoCheck, 0U, 0, aIDAT, 0
+ /* Historically data was allowed in IEND */
+# define CDtRNS 256U, 0U, hIDAT, hIHDR, 0
+# define CDcHRM 32U, 32U, hCOL, hIHDR, 0
+# define CDgAMA 4U, 4U, hCOL, hIHDR, 0
+# define CDiCCP NoCheck, LKMin, hCOL, hIHDR, 0
+# define CDsBIT 4U, 1U, hCOL, hIHDR, 0
+# define CDsRGB 1U, 1U, hCOL, hIHDR, 0
+# define CDcICP 4U, 4U, hCOL, hIHDR, 0
+# define CDmDCV 24U, 24U, hCOL, hIHDR, 0
+# define CDeXIf Limit, 4U, 0, hIHDR, 0
+# define CDcLLI 8U, 8U, hCOL, hIHDR, 0
+# define CDtEXt NoCheck, 2U, 0, hIHDR, 1
+ /* Allocates 'length+1'; checked in the handler */
+# define CDzTXt Limit, LKMin, 0, hIHDR, 1
+# define CDiTXt NoCheck, 6U, 0, hIHDR, 1
+ /* Allocates 'length+1'; checked in the handler */
+# define CDbKGD 6U, 1U, hIDAT, hIHDR, 0
+# define CDhIST 1024U, 0U, hPLTE, hIHDR, 0
+# define CDpHYs 9U, 9U, hIDAT, hIHDR, 0
+# define CDsPLT NoCheck, 3U, hIDAT, hIHDR, 1
+ /* Allocates 'length+1'; checked in the handler */
+# define CDtIME 7U, 7U, 0, hIHDR, 0
+# define CDacTL 8U, 8U, hIDAT, hIHDR, 0
+# define CDfcTL 25U, 26U, 0, hIHDR, 1
+# define CDfdAT Limit, 4U, hIDAT, hIHDR, 1
+ /* Supported chunks from PNG extensions 1.5.0, NYI so limit */
+# define CDoFFs 9U, 9U, hIDAT, hIHDR, 0
+# define CDpCAL NoCheck, 14U, hIDAT, hIHDR, 0
+ /* Allocates 'length+1'; checked in the handler */
+# define CDsCAL Limit, 4U, hIDAT, hIHDR, 0
+ /* Allocates 'length+1'; checked in the handler */
+
+# define PNG_CHUNK(cHNK, index) { png_handle_ ## cHNK, CD ## cHNK },
+ PNG_KNOWN_CHUNKS
+# undef PNG_CHUNK
+};
+
+
+static png_index
+png_chunk_index_from_name(png_uint_32 chunk_name)
+{
+ /* For chunk png_cHNK return PNG_INDEX_cHNK. Return PNG_INDEX_unknown if
+ * chunk_name is not known. Notice that in a particular build "known" does
+ * not necessarily mean "supported", although the inverse applies.
+ */
+ switch (chunk_name)
{
- int c = cn & 0xff;
+# define PNG_CHUNK(cHNK, index)\
+ case png_ ## cHNK: return PNG_INDEX_ ## cHNK; /* == index */
- if (c < 65 || c > 122 || (c > 90 && c < 97))
- png_chunk_error(png_ptr, "invalid chunk type");
+ PNG_KNOWN_CHUNKS
- cn >>= 8;
+# undef PNG_CHUNK
+
+ default: return PNG_INDEX_unknown;
}
}
-void /* PRIVATE */
-png_check_chunk_length(png_const_structrp png_ptr, png_uint_32 length)
+png_handle_result_code /*PRIVATE*/
+png_handle_chunk(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
{
- png_alloc_size_t limit = PNG_UINT_31_MAX;
-
-# ifdef PNG_SET_USER_LIMITS_SUPPORTED
- if (png_ptr->user_chunk_malloc_max > 0 &&
- png_ptr->user_chunk_malloc_max < limit)
- limit = png_ptr->user_chunk_malloc_max;
-# elif PNG_USER_CHUNK_MALLOC_MAX > 0
- if (PNG_USER_CHUNK_MALLOC_MAX < limit)
- limit = PNG_USER_CHUNK_MALLOC_MAX;
-# endif
- if (png_ptr->chunk_name == png_IDAT)
+ /* CSE: these things don't change, these autos are just to save typing and
+ * make the code more clear.
+ */
+ const png_uint_32 chunk_name = png_ptr->chunk_name;
+ const png_index chunk_index = png_chunk_index_from_name(chunk_name);
+
+ png_handle_result_code handled = handled_error;
+ png_const_charp errmsg = NULL;
+
+ /* Is this a known chunk? If not there are no checks performed here;
+ * png_handle_unknown does the correct checks. This means that the values
+ * for known but unsupported chunks in the above table are not used here
+ * however the chunks_seen fields in png_struct are still set.
+ */
+ if (chunk_index == PNG_INDEX_unknown ||
+ read_chunks[chunk_index].handler == NULL)
{
- png_alloc_size_t idat_limit = PNG_UINT_31_MAX;
- size_t row_factor =
- (size_t)png_ptr->width
- * (size_t)png_ptr->channels
- * (png_ptr->bit_depth > 8? 2: 1)
- + 1
- + (png_ptr->interlaced? 6: 0);
- if (png_ptr->height > PNG_UINT_32_MAX/row_factor)
- idat_limit = PNG_UINT_31_MAX;
- else
- idat_limit = png_ptr->height * row_factor;
- row_factor = row_factor > 32566? 32566 : row_factor;
- idat_limit += 6 + 5*(idat_limit/row_factor+1); /* zlib+deflate overhead */
- idat_limit=idat_limit < PNG_UINT_31_MAX? idat_limit : PNG_UINT_31_MAX;
- limit = limit < idat_limit? idat_limit : limit;
+ handled = png_handle_unknown(
+ png_ptr, info_ptr, length, PNG_HANDLE_CHUNK_AS_DEFAULT);
+ }
+
+ /* First check the position. The first check is historical; the stream must
+ * start with IHDR and anything else causes libpng to give up immediately.
+ */
+ else if (chunk_index != PNG_INDEX_IHDR &&
+ (png_ptr->mode & PNG_HAVE_IHDR) == 0)
+ png_chunk_error(png_ptr, "missing IHDR"); /* NORETURN */
+
+ /* Before all the pos_before chunks, after all the pos_after chunks. */
+ else if (((png_ptr->mode & read_chunks[chunk_index].pos_before) != 0) ||
+ ((png_ptr->mode & read_chunks[chunk_index].pos_after) !=
+ read_chunks[chunk_index].pos_after))
+ {
+ errmsg = "out of place";
+ }
+
+ /* Now check for duplicates: duplicated critical chunks also produce a
+ * full error.
+ */
+ else if (read_chunks[chunk_index].multiple == 0 &&
+ png_file_has_chunk(png_ptr, chunk_index))
+ {
+ errmsg = "duplicate";
+ }
+
+ else if (length < read_chunks[chunk_index].min_length)
+ errmsg = "too short";
+ else
+ {
+ /* NOTE: apart from IHDR the critical chunks (PLTE, IDAT and IEND) are set
+ * up above not to do any length checks.
+ *
+ * The png_chunk_max check ensures that the variable length chunks are
+ * always checked at this point for being within the system allocation
+ * limits.
+ */
+ unsigned max_length = read_chunks[chunk_index].max_length;
+
+ switch (max_length)
+ {
+ case Limit:
+ /* png_read_chunk_header has already png_error'ed chunks with a
+ * length exceeding the 31-bit PNG limit, so just check the memory
+ * limit:
+ */
+ if (length <= png_chunk_max(png_ptr))
+ goto MeetsLimit;
+
+ errmsg = "length exceeds libpng limit";
+ break;
+
+ default:
+ if (length <= max_length)
+ goto MeetsLimit;
+
+ errmsg = "too long";
+ break;
+
+ case NoCheck:
+ MeetsLimit:
+ handled = read_chunks[chunk_index].handler(
+ png_ptr, info_ptr, length);
+ break;
+ }
+ }
+
+ /* If there was an error or the chunk was simply skipped it is not counted as
+ * 'seen'.
+ */
+ if (errmsg != NULL)
+ {
+ if (PNG_CHUNK_CRITICAL(chunk_name)) /* stop immediately */
+ png_chunk_error(png_ptr, errmsg);
+ else /* ancillary chunk */
+ {
+ /* The chunk data is skipped: */
+ png_crc_finish(png_ptr, length);
+ png_chunk_benign_error(png_ptr, errmsg);
+ }
}
- if (length > limit)
+ else if (handled >= handled_saved)
{
- png_debug2(0," length = %lu, limit = %lu",
- (unsigned long)length,(unsigned long)limit);
- png_chunk_error(png_ptr, "chunk data is too large");
+ if (chunk_index != PNG_INDEX_unknown)
+ png_file_add_chunk(png_ptr, chunk_index);
}
+
+ return handled;
}
/* Combines the row recently read in with the existing pixels in the row. This
@@ -3684,10 +3723,6 @@ void /* PRIVATE */
png_do_read_interlace(png_row_infop row_info, png_bytep row, int pass,
png_uint_32 transformations /* Because these may affect the byte layout */)
{
- /* Arrays to facilitate easy interlacing - use pass (0 - 6) as index */
- /* Offset to next interlace block */
- static const unsigned int png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1};
-
png_debug(1, "in png_do_read_interlace");
if (row != NULL && row_info != NULL)
{
@@ -4180,6 +4215,9 @@ png_read_IDAT_data(png_structrp png_ptr, png_bytep output,
avail_in = png_ptr->IDAT_read_size;
+ if (avail_in > png_chunk_max(png_ptr))
+ avail_in = (uInt)/*SAFE*/png_chunk_max(png_ptr);
+
if (avail_in > png_ptr->idat_size)
avail_in = (uInt)png_ptr->idat_size;
@@ -4187,8 +4225,13 @@ png_read_IDAT_data(png_structrp png_ptr, png_bytep output,
* to minimize memory usage by causing lots of re-allocs, but
* realistically doing IDAT_read_size re-allocs is not likely to be a
* big problem.
+ *
+ * An error here corresponds to the system being out of memory.
*/
- buffer = png_read_buffer(png_ptr, avail_in, 0/*error*/);
+ buffer = png_read_buffer(png_ptr, avail_in);
+
+ if (buffer == NULL)
+ png_chunk_error(png_ptr, "out of memory");
png_crc_read(png_ptr, buffer, avail_in);
png_ptr->idat_size -= avail_in;
@@ -4325,20 +4368,6 @@ png_read_finish_IDAT(png_structrp png_ptr)
void /* PRIVATE */
png_read_finish_row(png_structrp png_ptr)
{
- /* Arrays to facilitate easy interlacing - use pass (0 - 6) as index */
-
- /* Start of interlace block */
- static const png_byte png_pass_start[7] = {0, 4, 0, 2, 0, 1, 0};
-
- /* Offset to next interlace block */
- static const png_byte png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1};
-
- /* Start of interlace block in the y direction */
- static const png_byte png_pass_ystart[7] = {0, 0, 4, 0, 2, 0, 1};
-
- /* Offset to next interlace block in the y direction */
- static const png_byte png_pass_yinc[7] = {8, 8, 8, 4, 4, 2, 2};
-
png_debug(1, "in png_read_finish_row");
png_ptr->row_number++;
if (png_ptr->row_number < png_ptr->num_rows)
@@ -4390,20 +4419,6 @@ png_read_finish_row(png_structrp png_ptr)
void /* PRIVATE */
png_read_start_row(png_structrp png_ptr)
{
- /* Arrays to facilitate easy interlacing - use pass (0 - 6) as index */
-
- /* Start of interlace block */
- static const png_byte png_pass_start[7] = {0, 4, 0, 2, 0, 1, 0};
-
- /* Offset to next interlace block */
- static const png_byte png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1};
-
- /* Start of interlace block in the y direction */
- static const png_byte png_pass_ystart[7] = {0, 0, 4, 0, 2, 0, 1};
-
- /* Offset to next interlace block in the y direction */
- static const png_byte png_pass_yinc[7] = {8, 8, 8, 4, 4, 2, 2};
-
unsigned int max_pixel_depth;
size_t row_bytes;
@@ -4621,14 +4636,13 @@ defined(PNG_USER_TRANSFORM_PTR_SUPPORTED)
*/
{
png_bytep temp = png_ptr->big_row_buf + 32;
- int extra = (int)((temp - (png_bytep)0) & 0x0f);
+ size_t extra = (size_t)temp & 0x0f;
png_ptr->row_buf = temp - extra - 1/*filter byte*/;
temp = png_ptr->big_prev_row + 32;
- extra = (int)((temp - (png_bytep)0) & 0x0f);
+ extra = (size_t)temp & 0x0f;
png_ptr->prev_row = temp - extra - 1/*filter byte*/;
}
-
#else
/* Use 31 bytes of padding before and 17 bytes after row_buf. */
png_ptr->row_buf = png_ptr->big_row_buf + 31;
diff --git a/src/libs/Irrlicht/irrlicht-svn/source/Irrlicht/libpng/pngset.c b/src/libs/Irrlicht/irrlicht-svn/source/Irrlicht/libpng/pngset.c
index b8889be7..4d82db16 100644
--- a/src/libs/Irrlicht/irrlicht-svn/source/Irrlicht/libpng/pngset.c
+++ b/src/libs/Irrlicht/irrlicht-svn/source/Irrlicht/libpng/pngset.c
@@ -1,7 +1,6 @@
-
/* pngset.c - storage of image information into info struct
*
- * Copyright (c) 2018 Cosmin Truta
+ * Copyright (c) 2018-2025 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.
@@ -42,27 +41,21 @@ png_set_cHRM_fixed(png_const_structrp png_ptr, png_inforp info_ptr,
png_fixed_point red_y, png_fixed_point green_x, png_fixed_point green_y,
png_fixed_point blue_x, png_fixed_point blue_y)
{
- png_xy xy;
-
png_debug1(1, "in %s storage function", "cHRM fixed");
if (png_ptr == NULL || info_ptr == NULL)
return;
- xy.redx = red_x;
- xy.redy = red_y;
- xy.greenx = green_x;
- xy.greeny = green_y;
- xy.bluex = blue_x;
- xy.bluey = blue_y;
- xy.whitex = white_x;
- xy.whitey = white_y;
+ info_ptr->cHRM.redx = red_x;
+ info_ptr->cHRM.redy = red_y;
+ info_ptr->cHRM.greenx = green_x;
+ info_ptr->cHRM.greeny = green_y;
+ info_ptr->cHRM.bluex = blue_x;
+ info_ptr->cHRM.bluey = blue_y;
+ info_ptr->cHRM.whitex = white_x;
+ info_ptr->cHRM.whitey = white_y;
- if (png_colorspace_set_chromaticities(png_ptr, &info_ptr->colorspace, &xy,
- 2/* override with app values*/) != 0)
- info_ptr->colorspace.flags |= PNG_COLORSPACE_FROM_cHRM;
-
- png_colorspace_sync_info(png_ptr, info_ptr);
+ info_ptr->valid |= PNG_INFO_cHRM;
}
void PNGFAPI
@@ -74,6 +67,7 @@ png_set_cHRM_XYZ_fixed(png_const_structrp png_ptr, png_inforp info_ptr,
png_fixed_point int_blue_Z)
{
png_XYZ XYZ;
+ png_xy xy;
png_debug1(1, "in %s storage function", "cHRM XYZ fixed");
@@ -90,11 +84,14 @@ png_set_cHRM_XYZ_fixed(png_const_structrp png_ptr, png_inforp info_ptr,
XYZ.blue_Y = int_blue_Y;
XYZ.blue_Z = int_blue_Z;
- if (png_colorspace_set_endpoints(png_ptr, &info_ptr->colorspace,
- &XYZ, 2) != 0)
- info_ptr->colorspace.flags |= PNG_COLORSPACE_FROM_cHRM;
+ if (png_xy_from_XYZ(&xy, &XYZ) == 0)
+ {
+ info_ptr->cHRM = xy;
+ info_ptr->valid |= PNG_INFO_cHRM;
+ }
- png_colorspace_sync_info(png_ptr, info_ptr);
+ else
+ png_app_error(png_ptr, "invalid cHRM XYZ");
}
# ifdef PNG_FLOATING_POINT_SUPPORTED
@@ -134,49 +131,226 @@ png_set_cHRM_XYZ(png_const_structrp png_ptr, png_inforp info_ptr, double red_X,
#endif /* cHRM */
+#ifdef PNG_cICP_SUPPORTED
+void PNGAPI
+png_set_cICP(png_const_structrp png_ptr, png_inforp info_ptr,
+ png_byte colour_primaries, png_byte transfer_function,
+ png_byte matrix_coefficients, png_byte video_full_range_flag)
+{
+ png_debug1(1, "in %s storage function", "cICP");
+
+ if (png_ptr == NULL || info_ptr == NULL)
+ return;
+
+ info_ptr->cicp_colour_primaries = colour_primaries;
+ info_ptr->cicp_transfer_function = transfer_function;
+ info_ptr->cicp_matrix_coefficients = matrix_coefficients;
+ info_ptr->cicp_video_full_range_flag = video_full_range_flag;
+
+ if (info_ptr->cicp_matrix_coefficients != 0)
+ {
+ png_warning(png_ptr, "Invalid cICP matrix coefficients");
+ return;
+ }
+
+ info_ptr->valid |= PNG_INFO_cICP;
+}
+#endif /* cICP */
+
+#ifdef PNG_cLLI_SUPPORTED
+void PNGFAPI
+png_set_cLLI_fixed(png_const_structrp png_ptr, png_inforp info_ptr,
+ /* The values below are in cd/m2 (nits) and are scaled by 10,000; not
+ * 100,000 as in the case of png_fixed_point.
+ */
+ png_uint_32 maxCLL, png_uint_32 maxFALL)
+{
+ png_debug1(1, "in %s storage function", "cLLI");
+
+ if (png_ptr == NULL || info_ptr == NULL)
+ return;
+
+ /* Check the light level range: */
+ if (maxCLL > 0x7FFFFFFFU || maxFALL > 0x7FFFFFFFU)
+ {
+ /* The limit is 200kcd/m2; somewhat bright but not inconceivable because
+ * human vision is said to run up to 100Mcd/m2. The sun is about 2Gcd/m2.
+ *
+ * The reference sRGB monitor is 80cd/m2 and the limit of PQ encoding is
+ * 2kcd/m2.
+ */
+ png_chunk_report(png_ptr, "cLLI light level exceeds PNG limit",
+ PNG_CHUNK_WRITE_ERROR);
+ return;
+ }
+
+ info_ptr->maxCLL = maxCLL;
+ info_ptr->maxFALL = maxFALL;
+ info_ptr->valid |= PNG_INFO_cLLI;
+}
+
+# ifdef PNG_FLOATING_POINT_SUPPORTED
+void PNGAPI
+png_set_cLLI(png_const_structrp png_ptr, png_inforp info_ptr,
+ double maxCLL, double maxFALL)
+{
+ png_set_cLLI_fixed(png_ptr, info_ptr,
+ png_fixed_ITU(png_ptr, maxCLL, "png_set_cLLI(maxCLL)"),
+ png_fixed_ITU(png_ptr, maxFALL, "png_set_cLLI(maxFALL)"));
+}
+# endif /* FLOATING_POINT */
+#endif /* cLLI */
+
+#ifdef PNG_mDCV_SUPPORTED
+static png_uint_16
+png_ITU_fixed_16(int *error, png_fixed_point v)
+{
+ /* Return a safe uint16_t value scaled according to the ITU H273 rules for
+ * 16-bit display chromaticities. Functions like the corresponding
+ * png_fixed() internal function with regard to errors: it's an error on
+ * write, a chunk_benign_error on read: See the definition of
+ * png_chunk_report in pngpriv.h.
+ */
+ v /= 2; /* rounds to 0 in C: avoids insignificant arithmetic errors */
+ if (v > 65535 || v < 0)
+ {
+ *error = 1;
+ return 0;
+ }
+
+ return (png_uint_16)/*SAFE*/v;
+}
+
+void PNGAPI
+png_set_mDCV_fixed(png_const_structrp png_ptr, png_inforp info_ptr,
+ png_fixed_point white_x, png_fixed_point white_y,
+ png_fixed_point red_x, png_fixed_point red_y,
+ png_fixed_point green_x, png_fixed_point green_y,
+ png_fixed_point blue_x, png_fixed_point blue_y,
+ png_uint_32 maxDL,
+ png_uint_32 minDL)
+{
+ png_uint_16 rx, ry, gx, gy, bx, by, wx, wy;
+ int error;
+
+ png_debug1(1, "in %s storage function", "mDCV");
+
+ if (png_ptr == NULL || info_ptr == NULL)
+ return;
+
+ /* Check the input values to ensure they are in the expected range: */
+ error = 0;
+ rx = png_ITU_fixed_16(&error, red_x);
+ ry = png_ITU_fixed_16(&error, red_y);
+ gx = png_ITU_fixed_16(&error, green_x);
+ gy = png_ITU_fixed_16(&error, green_y);
+ bx = png_ITU_fixed_16(&error, blue_x);
+ by = png_ITU_fixed_16(&error, blue_y);
+ wx = png_ITU_fixed_16(&error, white_x);
+ wy = png_ITU_fixed_16(&error, white_y);
+
+ if (error)
+ {
+ png_chunk_report(png_ptr,
+ "mDCV chromaticities outside representable range",
+ PNG_CHUNK_WRITE_ERROR);
+ return;
+ }
+
+ /* Check the light level range: */
+ if (maxDL > 0x7FFFFFFFU || minDL > 0x7FFFFFFFU)
+ {
+ /* The limit is 200kcd/m2; somewhat bright but not inconceivable because
+ * human vision is said to run up to 100Mcd/m2. The sun is about 2Gcd/m2.
+ *
+ * The reference sRGB monitor is 80cd/m2 and the limit of PQ encoding is
+ * 2kcd/m2.
+ */
+ png_chunk_report(png_ptr, "mDCV display light level exceeds PNG limit",
+ PNG_CHUNK_WRITE_ERROR);
+ return;
+ }
+
+ /* All values are safe, the settings are accepted.
+ *
+ * IMPLEMENTATION NOTE: in practice the values can be checked and assigned
+ * but the result is confusing if a writing app calls png_set_mDCV more than
+ * once, the second time with an invalid value. This approach is more
+ * obviously correct at the cost of typing and a very slight machine
+ * overhead.
+ */
+ info_ptr->mastering_red_x = rx;
+ info_ptr->mastering_red_y = ry;
+ info_ptr->mastering_green_x = gx;
+ info_ptr->mastering_green_y = gy;
+ info_ptr->mastering_blue_x = bx;
+ info_ptr->mastering_blue_y = by;
+ info_ptr->mastering_white_x = wx;
+ info_ptr->mastering_white_y = wy;
+ info_ptr->mastering_maxDL = maxDL;
+ info_ptr->mastering_minDL = minDL;
+ info_ptr->valid |= PNG_INFO_mDCV;
+}
+
+# ifdef PNG_FLOATING_POINT_SUPPORTED
+void PNGAPI
+png_set_mDCV(png_const_structrp png_ptr, png_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,
+ double maxDL, double minDL)
+{
+ png_set_mDCV_fixed(png_ptr, info_ptr,
+ png_fixed(png_ptr, white_x, "png_set_mDCV(white(x))"),
+ png_fixed(png_ptr, white_y, "png_set_mDCV(white(y))"),
+ png_fixed(png_ptr, red_x, "png_set_mDCV(red(x))"),
+ png_fixed(png_ptr, red_y, "png_set_mDCV(red(y))"),
+ png_fixed(png_ptr, green_x, "png_set_mDCV(green(x))"),
+ png_fixed(png_ptr, green_y, "png_set_mDCV(green(y))"),
+ png_fixed(png_ptr, blue_x, "png_set_mDCV(blue(x))"),
+ png_fixed(png_ptr, blue_y, "png_set_mDCV(blue(y))"),
+ png_fixed_ITU(png_ptr, maxDL, "png_set_mDCV(maxDL)"),
+ png_fixed_ITU(png_ptr, minDL, "png_set_mDCV(minDL)"));
+}
+# endif /* FLOATING_POINT */
+#endif /* mDCV */
+
#ifdef PNG_eXIf_SUPPORTED
void PNGAPI
png_set_eXIf(png_const_structrp png_ptr, png_inforp info_ptr,
- png_bytep eXIf_buf)
+ png_bytep exif)
{
png_warning(png_ptr, "png_set_eXIf does not work; use png_set_eXIf_1");
PNG_UNUSED(info_ptr)
- PNG_UNUSED(eXIf_buf)
+ PNG_UNUSED(exif)
}
void PNGAPI
png_set_eXIf_1(png_const_structrp png_ptr, png_inforp info_ptr,
- png_uint_32 num_exif, png_bytep eXIf_buf)
+ png_uint_32 num_exif, png_bytep exif)
{
- int i;
+ png_bytep new_exif;
png_debug1(1, "in %s storage function", "eXIf");
- if (png_ptr == NULL || info_ptr == NULL)
+ if (png_ptr == NULL || info_ptr == NULL ||
+ (png_ptr->mode & PNG_WROTE_eXIf) != 0)
return;
- if (info_ptr->exif)
- {
- png_free(png_ptr, info_ptr->exif);
- info_ptr->exif = NULL;
- }
-
- info_ptr->num_exif = num_exif;
-
- info_ptr->exif = png_voidcast(png_bytep, png_malloc_warn(png_ptr,
- info_ptr->num_exif));
+ new_exif = png_voidcast(png_bytep, png_malloc_warn(png_ptr, num_exif));
- if (info_ptr->exif == NULL)
+ if (new_exif == NULL)
{
png_warning(png_ptr, "Insufficient memory for eXIf chunk data");
return;
}
- info_ptr->free_me |= PNG_FREE_EXIF;
+ memcpy(new_exif, exif, (size_t)num_exif);
- for (i = 0; i < (int) info_ptr->num_exif; i++)
- info_ptr->exif[i] = eXIf_buf[i];
+ png_free_data(png_ptr, info_ptr, PNG_FREE_EXIF, 0);
+ info_ptr->num_exif = num_exif;
+ info_ptr->exif = new_exif;
+ info_ptr->free_me |= PNG_FREE_EXIF;
info_ptr->valid |= PNG_INFO_eXIf;
}
#endif /* eXIf */
@@ -191,8 +365,8 @@ png_set_gAMA_fixed(png_const_structrp png_ptr, png_inforp info_ptr,
if (png_ptr == NULL || info_ptr == NULL)
return;
- png_colorspace_set_gamma(png_ptr, &info_ptr->colorspace, file_gamma);
- png_colorspace_sync_info(png_ptr, info_ptr);
+ info_ptr->gamma = file_gamma;
+ info_ptr->valid |= PNG_INFO_gAMA;
}
# ifdef PNG_FLOATING_POINT_SUPPORTED
@@ -237,15 +411,13 @@ png_set_hIST(png_const_structrp png_ptr, png_inforp info_ptr,
if (info_ptr->hist == NULL)
{
png_warning(png_ptr, "Insufficient memory for hIST chunk data");
-
return;
}
- info_ptr->free_me |= PNG_FREE_HIST;
-
for (i = 0; i < info_ptr->num_palette; i++)
info_ptr->hist[i] = hist[i];
+ info_ptr->free_me |= PNG_FREE_HIST;
info_ptr->valid |= PNG_INFO_hIST;
}
#endif
@@ -367,6 +539,8 @@ png_set_pCAL(png_const_structrp png_ptr, png_inforp info_ptr,
memcpy(info_ptr->pcal_purpose, purpose, length);
+ info_ptr->free_me |= PNG_FREE_PCAL;
+
png_debug(3, "storing X0, X1, type, and nparams in info");
info_ptr->pcal_X0 = X0;
info_ptr->pcal_X1 = X1;
@@ -383,7 +557,6 @@ png_set_pCAL(png_const_structrp png_ptr, png_inforp info_ptr,
if (info_ptr->pcal_units == NULL)
{
png_warning(png_ptr, "Insufficient memory for pCAL units");
-
return;
}
@@ -395,7 +568,6 @@ png_set_pCAL(png_const_structrp png_ptr, png_inforp info_ptr,
if (info_ptr->pcal_params == NULL)
{
png_warning(png_ptr, "Insufficient memory for pCAL params");
-
return;
}
@@ -413,7 +585,6 @@ png_set_pCAL(png_const_structrp png_ptr, png_inforp info_ptr,
if (info_ptr->pcal_params[i] == NULL)
{
png_warning(png_ptr, "Insufficient memory for pCAL parameter");
-
return;
}
@@ -421,7 +592,6 @@ png_set_pCAL(png_const_structrp png_ptr, png_inforp info_ptr,
}
info_ptr->valid |= PNG_INFO_pCAL;
- info_ptr->free_me |= PNG_FREE_PCAL;
}
#endif
@@ -478,18 +648,17 @@ png_set_sCAL_s(png_const_structrp png_ptr, png_inforp info_ptr,
if (info_ptr->scal_s_height == NULL)
{
- png_free (png_ptr, info_ptr->scal_s_width);
+ png_free(png_ptr, info_ptr->scal_s_width);
info_ptr->scal_s_width = NULL;
png_warning(png_ptr, "Memory allocation failed while processing sCAL");
-
return;
}
memcpy(info_ptr->scal_s_height, sheight, lengthh);
- info_ptr->valid |= PNG_INFO_sCAL;
info_ptr->free_me |= PNG_FREE_SCAL;
+ info_ptr->valid |= PNG_INFO_sCAL;
}
# ifdef PNG_FLOATING_POINT_SUPPORTED
@@ -625,11 +794,10 @@ png_set_PLTE(png_structrp png_ptr, png_inforp info_ptr,
if (num_palette > 0)
memcpy(png_ptr->palette, palette, (unsigned int)num_palette *
(sizeof (png_color)));
+
info_ptr->palette = png_ptr->palette;
info_ptr->num_palette = png_ptr->num_palette = (png_uint_16)num_palette;
-
info_ptr->free_me |= PNG_FREE_PLTE;
-
info_ptr->valid |= PNG_INFO_PLTE;
}
@@ -657,8 +825,8 @@ png_set_sRGB(png_const_structrp png_ptr, png_inforp info_ptr, int srgb_intent)
if (png_ptr == NULL || info_ptr == NULL)
return;
- (void)png_colorspace_set_sRGB(png_ptr, &info_ptr->colorspace, srgb_intent);
- png_colorspace_sync_info(png_ptr, info_ptr);
+ info_ptr->rendering_intent = srgb_intent;
+ info_ptr->valid |= PNG_INFO_sRGB;
}
void PNGAPI
@@ -670,15 +838,20 @@ png_set_sRGB_gAMA_and_cHRM(png_const_structrp png_ptr, png_inforp info_ptr,
if (png_ptr == NULL || info_ptr == NULL)
return;
- if (png_colorspace_set_sRGB(png_ptr, &info_ptr->colorspace,
- srgb_intent) != 0)
- {
- /* This causes the gAMA and cHRM to be written too */
- info_ptr->colorspace.flags |=
- PNG_COLORSPACE_FROM_gAMA|PNG_COLORSPACE_FROM_cHRM;
- }
+ png_set_sRGB(png_ptr, info_ptr, srgb_intent);
+
+# ifdef PNG_gAMA_SUPPORTED
+ png_set_gAMA_fixed(png_ptr, info_ptr, PNG_GAMMA_sRGB_INVERSE);
+# endif /* gAMA */
- png_colorspace_sync_info(png_ptr, info_ptr);
+# ifdef PNG_cHRM_SUPPORTED
+ png_set_cHRM_fixed(png_ptr, info_ptr,
+ /* color x y */
+ /* white */ 31270, 32900,
+ /* red */ 64000, 33000,
+ /* green */ 30000, 60000,
+ /* blue */ 15000, 6000);
+# endif /* cHRM */
}
#endif /* sRGB */
@@ -701,27 +874,6 @@ png_set_iCCP(png_const_structrp png_ptr, png_inforp info_ptr,
if (compression_type != PNG_COMPRESSION_TYPE_BASE)
png_app_error(png_ptr, "Invalid iCCP compression method");
- /* Set the colorspace first because this validates the profile; do not
- * override previously set app cHRM or gAMA here (because likely as not the
- * application knows better than libpng what the correct values are.) Pass
- * the info_ptr color_type field to png_colorspace_set_ICC because in the
- * write case it has not yet been stored in png_ptr.
- */
- {
- int result = png_colorspace_set_ICC(png_ptr, &info_ptr->colorspace, name,
- proflen, profile, info_ptr->color_type);
-
- png_colorspace_sync_info(png_ptr, info_ptr);
-
- /* Don't do any of the copying if the profile was bad, or inconsistent. */
- if (result == 0)
- return;
-
- /* But do write the gAMA and cHRM chunks from the profile. */
- info_ptr->colorspace.flags |=
- PNG_COLORSPACE_FROM_gAMA|PNG_COLORSPACE_FROM_cHRM;
- }
-
length = strlen(name)+1;
new_iccp_name = png_voidcast(png_charp, png_malloc_warn(png_ptr, length));
@@ -775,11 +927,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
@@ -959,7 +1111,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
@@ -1019,6 +1171,9 @@ png_set_tRNS(png_structrp png_ptr, png_inforp info_ptr,
info_ptr->trans_alpha = png_voidcast(png_bytep,
png_malloc(png_ptr, PNG_MAX_PALETTE_LENGTH));
memcpy(info_ptr->trans_alpha, trans_alpha, (size_t)num_trans);
+
+ info_ptr->free_me |= PNG_FREE_TRNS;
+ info_ptr->valid |= PNG_INFO_tRNS;
}
png_ptr->trans_alpha = info_ptr->trans_alpha;
}
@@ -1051,8 +1206,8 @@ png_set_tRNS(png_structrp png_ptr, png_inforp info_ptr,
if (num_trans != 0)
{
- info_ptr->valid |= PNG_INFO_tRNS;
info_ptr->free_me |= PNG_FREE_TRNS;
+ info_ptr->valid |= PNG_INFO_tRNS;
}
}
#endif
@@ -1072,6 +1227,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;
@@ -1086,11 +1243,11 @@ png_set_sPLT(png_const_structrp png_ptr,
{
/* Out of memory or too many chunks */
png_chunk_report(png_ptr, "too many sPLT chunks", PNG_CHUNK_WRITE_ERROR);
-
return;
}
png_free(png_ptr, info_ptr->splt_palettes);
+
info_ptr->splt_palettes = np;
info_ptr->free_me |= PNG_FREE_SPLT;
@@ -1244,11 +1401,11 @@ png_set_unknown_chunks(png_const_structrp png_ptr,
{
png_chunk_report(png_ptr, "too many unknown chunks",
PNG_CHUNK_WRITE_ERROR);
-
return;
}
png_free(png_ptr, info_ptr->unknown_chunks);
+
info_ptr->unknown_chunks = np; /* safe because it is initialized */
info_ptr->free_me |= PNG_FREE_UNKN;
@@ -1326,7 +1483,7 @@ png_set_unknown_chunk_location(png_const_structrp png_ptr, png_inforp info_ptr,
#ifdef PNG_MNG_FEATURES_SUPPORTED
png_uint_32 PNGAPI
-png_permit_mng_features (png_structrp png_ptr, png_uint_32 mng_features)
+png_permit_mng_features(png_structrp png_ptr, png_uint_32 mng_features)
{
png_debug(1, "in png_permit_mng_features");
@@ -1402,11 +1559,14 @@ png_set_keep_unknown_chunks(png_structrp png_ptr, int keep,
static const png_byte chunks_to_ignore[] = {
98, 75, 71, 68, '\0', /* bKGD */
99, 72, 82, 77, '\0', /* cHRM */
+ 99, 73, 67, 80, '\0', /* cICP */
+ 99, 76, 76, 73, '\0', /* cLLI */
101, 88, 73, 102, '\0', /* eXIf */
103, 65, 77, 65, '\0', /* gAMA */
104, 73, 83, 84, '\0', /* hIST */
105, 67, 67, 80, '\0', /* iCCP */
105, 84, 88, 116, '\0', /* iTXt */
+ 109, 68, 67, 86, '\0', /* mDCV */
111, 70, 70, 115, '\0', /* oFFs */
112, 67, 65, 76, '\0', /* pCAL */
112, 72, 89, 115, '\0', /* pHYs */
@@ -1546,7 +1706,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;
@@ -1565,6 +1725,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;
@@ -1633,9 +1795,11 @@ png_set_invalid(png_const_structrp png_ptr, png_inforp info_ptr, int mask)
#ifdef PNG_SET_USER_LIMITS_SUPPORTED
/* This function was added to libpng 1.2.6 */
void PNGAPI
-png_set_user_limits (png_structrp png_ptr, png_uint_32 user_width_max,
+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.
@@ -1649,19 +1813,39 @@ png_set_user_limits (png_structrp png_ptr, png_uint_32 user_width_max,
/* This function was added to libpng 1.4.0 */
void PNGAPI
-png_set_chunk_cache_max (png_structrp png_ptr, png_uint_32 user_chunk_cache_max)
+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;
}
/* This function was added to libpng 1.4.1 */
void PNGAPI
-png_set_chunk_malloc_max (png_structrp png_ptr,
+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");
+
+ /* pngstruct::user_chunk_malloc_max is initialized to a non-zero value in
+ * png.c. This API supports '0' for unlimited, make sure the correct
+ * (unlimited) value is set here to avoid a need to check for 0 everywhere
+ * the parameter is used.
+ */
if (png_ptr != NULL)
- png_ptr->user_chunk_malloc_max = user_chunk_malloc_max;
+ {
+ if (user_chunk_malloc_max == 0U) /* unlimited */
+ {
+# ifdef PNG_MAX_MALLOC_64K
+ png_ptr->user_chunk_malloc_max = 65536U;
+# else
+ png_ptr->user_chunk_malloc_max = PNG_SIZE_MAX;
+# endif
+ }
+ else
+ png_ptr->user_chunk_malloc_max = user_chunk_malloc_max;
+ }
}
#endif /* ?SET_USER_LIMITS */
diff --git a/src/libs/Irrlicht/irrlicht-svn/source/Irrlicht/libpng/pngstruct.h b/src/libs/Irrlicht/irrlicht-svn/source/Irrlicht/libpng/pngstruct.h
index 00d82ab5..fbf0947e 100644
--- a/src/libs/Irrlicht/irrlicht-svn/source/Irrlicht/libpng/pngstruct.h
+++ b/src/libs/Irrlicht/irrlicht-svn/source/Irrlicht/libpng/pngstruct.h
@@ -1,7 +1,6 @@
-
-/* pngstruct.h - header file for PNG reference library
+/* pngstruct.h - internal structures for libpng
*
- * Copyright (c) 2018-2019 Cosmin Truta
+ * Copyright (c) 2018-2025 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.
@@ -11,11 +10,9 @@
* and license in png.h
*/
-/* The structure that holds the information to read and write PNG files.
- * The only people who need to care about what is inside of this are the
- * people who will be modifying the library for their own special needs.
- * It should NOT be accessed directly by an application.
- */
+#ifndef PNGPRIV_H
+# error This file must not be included by applications; please include
+#endif
#ifndef PNGSTRUCT_H
#define PNGSTRUCT_H
@@ -27,12 +24,8 @@
/* We must ensure that zlib uses 'const' in declarations. */
# define ZLIB_CONST
#endif
-
-/* Irrlicht change:
+/* Irrlicht change:
Avoid that build-in png uses a different zlib than the rest of Irrlicht.
- Note: This also would allow removing zlib from the include paths, which
- probably was done just to hide this bug. Anyway, it's less broken now
- than it was and the rest is up to Irrlicht 1.9.
*/
#include "IrrCompileConfig.h"
#ifndef _IRR_USE_NON_SYSTEM_ZLIB_
@@ -40,7 +33,6 @@
#else
#include "../zlib/zlib.h"
#endif
-
#ifdef const
/* zlib.h sometimes #defines const to nothing, undo this. */
# undef const
@@ -83,13 +75,7 @@ typedef struct png_compression_buffer
/* Colorspace support; structures used in png_struct, png_info and in internal
* functions to hold and communicate information about the color space.
- *
- * PNG_COLORSPACE_SUPPORTED is only required if the application will perform
- * colorspace corrections, otherwise all the colorspace information can be
- * skipped and the size of libpng can be reduced (significantly) by compiling
- * out the colorspace support.
*/
-#ifdef PNG_COLORSPACE_SUPPORTED
/* The chromaticities of the red, green and blue colorants and the chromaticity
* of the corresponding white point (i.e. of rgb(1.0,1.0,1.0)).
*/
@@ -110,48 +96,36 @@ typedef struct png_XYZ
png_fixed_point green_X, green_Y, green_Z;
png_fixed_point blue_X, blue_Y, blue_Z;
} png_XYZ;
-#endif /* COLORSPACE */
-#if defined(PNG_COLORSPACE_SUPPORTED) || defined(PNG_GAMMA_SUPPORTED)
-/* A colorspace is all the above plus, potentially, profile information;
- * however at present libpng does not use the profile internally so it is only
- * stored in the png_info struct (if iCCP is supported.) The rendering intent
- * is retained here and is checked.
- *
- * The file gamma encoding information is also stored here and gamma correction
- * is done by libpng, whereas color correction must currently be done by the
- * application.
+/* Chunk index values as an enum, PNG_INDEX_unknown is also a count of the
+ * number of chunks.
*/
-typedef struct png_colorspace
+#define PNG_CHUNK(cHNK, i) PNG_INDEX_ ## cHNK = (i),
+typedef enum
{
-#ifdef PNG_GAMMA_SUPPORTED
- png_fixed_point gamma; /* File gamma */
-#endif
+ PNG_KNOWN_CHUNKS
+ PNG_INDEX_unknown
+} png_index;
+#undef PNG_CHUNK
-#ifdef PNG_COLORSPACE_SUPPORTED
- png_xy end_points_xy; /* End points as chromaticities */
- png_XYZ end_points_XYZ; /* End points as CIE XYZ colorant values */
- png_uint_16 rendering_intent; /* Rendering intent of a profile */
-#endif
-
- /* Flags are always defined to simplify the code. */
- png_uint_16 flags; /* As defined below */
-} png_colorspace, * PNG_RESTRICT png_colorspacerp;
+/* Chunk flag values. These are (png_uint_32 values) with exactly one bit set
+ * and can be combined into a flag set with bitwise 'or'.
+ *
+ * TODO: C23: convert these macros to C23 inlines (which are static).
+ */
+#define png_chunk_flag_from_index(i) (0x80000000U >> (31 - (i)))
+ /* The flag coresponding to the given png_index enum value. This is defined
+ * for png_unknown as well (until it reaches the value 32) but this should
+ * not be relied on.
+ */
-typedef const png_colorspace * PNG_RESTRICT png_const_colorspacerp;
+#define png_file_has_chunk(png_ptr, i)\
+ (((png_ptr)->chunks & png_chunk_flag_from_index(i)) != 0)
+ /* The chunk has been recorded in png_struct */
-/* General flags for the 'flags' field */
-#define PNG_COLORSPACE_HAVE_GAMMA 0x0001
-#define PNG_COLORSPACE_HAVE_ENDPOINTS 0x0002
-#define PNG_COLORSPACE_HAVE_INTENT 0x0004
-#define PNG_COLORSPACE_FROM_gAMA 0x0008
-#define PNG_COLORSPACE_FROM_cHRM 0x0010
-#define PNG_COLORSPACE_FROM_sRGB 0x0020
-#define PNG_COLORSPACE_ENDPOINTS_MATCH_sRGB 0x0040
-#define PNG_COLORSPACE_MATCHES_sRGB 0x0080 /* exact match on profile */
-#define PNG_COLORSPACE_INVALID 0x8000
-#define PNG_COLORSPACE_CANCEL(flags) (0xffff ^ (flags))
-#endif /* COLORSPACE || GAMMA */
+#define png_file_add_chunk(pnt_ptr, i)\
+ ((void)((png_ptr)->chunks |= png_chunk_flag_from_index(i)))
+ /* Record the chunk in the png_struct */
struct png_struct_def
{
@@ -223,6 +197,11 @@ struct png_struct_def
int zlib_set_strategy;
#endif
+ png_uint_32 chunks; /* PNG_CF_ for every chunk read or (NYI) written */
+# define png_has_chunk(png_ptr, cHNK)\
+ png_file_has_chunk(png_ptr, PNG_INDEX_ ## cHNK)
+ /* Convenience accessor - use this to check for a known chunk by name */
+
png_uint_32 width; /* width of image in pixels */
png_uint_32 height; /* height of image in pixels */
png_uint_32 num_rows; /* number of rows in current pass */
@@ -299,9 +278,16 @@ struct png_struct_def
png_uint_32 flush_rows; /* number of rows written since last flush */
#endif
+#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED
+ png_xy chromaticities; /* From mDVC, cICP, [iCCP], sRGB or cHRM */
+#endif
+
#ifdef PNG_READ_GAMMA_SUPPORTED
int gamma_shift; /* number of "insignificant" bits in 16-bit gamma */
- png_fixed_point screen_gamma; /* screen gamma value (display_exponent) */
+ png_fixed_point screen_gamma; /* screen gamma value (display exponent) */
+ png_fixed_point file_gamma; /* file gamma value (encoding exponent) */
+ png_fixed_point chunk_gamma; /* from cICP, iCCP, sRGB or gAMA */
+ png_fixed_point default_gamma;/* from png_set_alpha_mode */
png_bytep gamma_table; /* gamma table for 8-bit depth files */
png_uint_16pp gamma_16_table; /* gamma table for 16-bit depth files */
@@ -313,7 +299,7 @@ struct png_struct_def
png_uint_16pp gamma_16_from_1; /* converts from 1.0 to screen */
png_uint_16pp gamma_16_to_1; /* converts from file to 1.0 */
#endif /* READ_BACKGROUND || READ_ALPHA_MODE || RGB_TO_GRAY */
-#endif
+#endif /* READ_GAMMA */
#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_sBIT_SUPPORTED)
png_color_8 sig_bit; /* significant bits in each available channel */
@@ -347,18 +333,8 @@ struct png_struct_def
size_t current_buffer_size; /* amount of data now in current_buffer */
int process_mode; /* what push library is currently doing */
int cur_palette; /* current push library palette index */
-
#endif /* PROGRESSIVE_READ */
-#if defined(__TURBOC__) && !defined(_Windows) && !defined(__FLAT__)
-/* For the Borland special 64K segment handler */
- png_bytepp offset_table_ptr;
- png_bytep offset_table;
- png_uint_16 offset_table_number;
- png_uint_16 offset_table_count;
- png_uint_16 offset_table_count_free;
-#endif
-
#ifdef PNG_READ_QUANTIZE_SUPPORTED
png_bytep palette_lookup; /* lookup table for quantizing */
png_bytep quantize_index; /* index translation for palette files */
@@ -373,8 +349,8 @@ struct png_struct_def
/* To do: remove this from libpng-1.7 */
#ifdef PNG_TIME_RFC1123_SUPPORTED
char time_buffer[29]; /* String to hold RFC 1123 time text */
-#endif
-#endif
+#endif /* TIME_RFC1123 */
+#endif /* LIBPNG_VER < 10700 */
/* New members added in libpng-1.0.6 */
@@ -384,8 +360,8 @@ struct png_struct_def
png_voidp user_chunk_ptr;
#ifdef PNG_READ_USER_CHUNKS_SUPPORTED
png_user_chunk_ptr read_user_chunk_fn; /* user read chunk handler */
-#endif
-#endif
+#endif /* READ_USER_CHUNKS */
+#endif /* USER_CHUNKS */
#ifdef PNG_SET_UNKNOWN_CHUNKS_SUPPORTED
int unknown_default; /* As PNG_HANDLE_* */
@@ -407,7 +383,8 @@ struct png_struct_def
/* New member added in libpng-1.6.36 */
#if defined(PNG_READ_EXPAND_SUPPORTED) && \
- defined(PNG_ARM_NEON_IMPLEMENTATION)
+ (defined(PNG_ARM_NEON_IMPLEMENTATION) || \
+ defined(PNG_RISCV_RVV_IMPLEMENTATION))
png_bytep riffled_palette; /* buffer for accelerated palette expansion */
#endif
@@ -436,7 +413,6 @@ struct png_struct_def
#ifdef PNG_READ_QUANTIZE_SUPPORTED
/* The following three members were added at version 1.0.14 and 1.2.4 */
- png_bytep quantize_sort; /* working sort array */
png_bytep index_to_palette; /* where the original index currently is
in the palette */
png_bytep palette_to_index; /* which original index points to this
@@ -492,11 +468,5 @@ struct png_struct_def
/* New member added in libpng-1.5.7 */
void (*read_filter[PNG_FILTER_VALUE_LAST-1])(png_row_infop row_info,
png_bytep row, png_const_bytep prev_row);
-
-#ifdef PNG_READ_SUPPORTED
-#if defined(PNG_COLORSPACE_SUPPORTED) || defined(PNG_GAMMA_SUPPORTED)
- png_colorspace colorspace;
-#endif
-#endif
};
#endif /* PNGSTRUCT_H */
diff --git a/src/libs/Irrlicht/irrlicht-svn/source/Irrlicht/libpng/pngtest.c b/src/libs/Irrlicht/irrlicht-svn/source/Irrlicht/libpng/pngtest.c
index de626384..633eacab 100644
--- a/src/libs/Irrlicht/irrlicht-svn/source/Irrlicht/libpng/pngtest.c
+++ b/src/libs/Irrlicht/irrlicht-svn/source/Irrlicht/libpng/pngtest.c
@@ -1,7 +1,6 @@
-
-/* pngtest.c - a simple test program to test libpng
+/* pngtest.c - a test program for libpng
*
- * Copyright (c) 2018-2019 Cosmin Truta
+ * Copyright (c) 2018-2025 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.
@@ -37,73 +36,87 @@
#include
#include
-/* Defined so I can write to a file on gui/windowing platforms */
-/* #define STDERR stderr */
-#define STDERR stdout /* For DOS */
+#ifdef PNG_ZLIB_HEADER
+# include PNG_ZLIB_HEADER /* defined by pnglibconf.h from 1.7 */
+#else
+# include
+#endif
#include "png.h"
-/* Known chunks that exist in pngtest.png must be supported or pngtest will fail
- * simply as a result of re-ordering them. This may be fixed in 1.7
+/* This hack was introduced for historical reasons, and we are
+ * still keeping it in libpng-1.6.x for compatibility reasons.
+ */
+#define STDERR stdout
+
+/* Generate a compiler error if there is an old png.h in the search path. */
+typedef png_libpng_version_1_6_54 Your_png_h_is_not_version_1_6_54;
+
+/* Ensure that all version numbers in png.h are consistent with one another. */
+#if (PNG_LIBPNG_VER != PNG_LIBPNG_VER_MAJOR * 10000 + \
+ PNG_LIBPNG_VER_MINOR * 100 + \
+ PNG_LIBPNG_VER_RELEASE) || \
+ (PNG_LIBPNG_VER_SHAREDLIB != PNG_LIBPNG_VER_MAJOR * 10 + \
+ PNG_LIBPNG_VER_MINOR) || \
+ (PNG_LIBPNG_VER_SHAREDLIB != PNG_LIBPNG_VER_SONUM) || \
+ (PNG_LIBPNG_VER_SHAREDLIB != PNG_LIBPNG_VER_DLLNUM)
+# error Inconsistent version numbers in "png.h"
+#endif
+
+/* In version 1.6.1, we added support for the configure test harness, which
+ * uses 77 to indicate a skipped test. On the other hand, in cmake build tests,
+ * we still need to succeed on a skipped test, so:
+ */
+#if defined(HAVE_CONFIG_H)
+# define SKIP 77
+#else
+# define SKIP 0
+#endif
+
+/* Known chunks that exist in pngtest.png must be supported, or pngtest will
+ * fail simply as a result of re-ordering them. This may be fixed in the next
+ * generation of libpng.
*
* pngtest allocates a single row buffer for each row and overwrites it,
* therefore if the write side doesn't support the writing of interlaced images
* nothing can be done for an interlaced image (and the code below will fail
* horribly trying to write extra data after writing garbage).
*/
-#if defined PNG_READ_SUPPORTED && /* else nothing can be done */\
- defined PNG_READ_bKGD_SUPPORTED &&\
- defined PNG_READ_cHRM_SUPPORTED &&\
- defined PNG_READ_gAMA_SUPPORTED &&\
- defined PNG_READ_oFFs_SUPPORTED &&\
- defined PNG_READ_pCAL_SUPPORTED &&\
- defined PNG_READ_pHYs_SUPPORTED &&\
- defined PNG_READ_sBIT_SUPPORTED &&\
- defined PNG_READ_sCAL_SUPPORTED &&\
- defined PNG_READ_sRGB_SUPPORTED &&\
- defined PNG_READ_sPLT_SUPPORTED &&\
- defined PNG_READ_tEXt_SUPPORTED &&\
- defined PNG_READ_tIME_SUPPORTED &&\
- defined PNG_READ_zTXt_SUPPORTED &&\
- (defined PNG_WRITE_INTERLACING_SUPPORTED || PNG_LIBPNG_VER >= 10700)
-
-#ifdef PNG_ZLIB_HEADER
-# include PNG_ZLIB_HEADER /* defined by pnglibconf.h from 1.7 */
-#else
-# include "zlib.h"
-#endif
+#if defined PNG_READ_SUPPORTED && /* else nothing can be done */ \
+ defined PNG_READ_bKGD_SUPPORTED && \
+ defined PNG_READ_cHRM_SUPPORTED && \
+ defined PNG_READ_gAMA_SUPPORTED && \
+ defined PNG_READ_oFFs_SUPPORTED && \
+ defined PNG_READ_pCAL_SUPPORTED && \
+ defined PNG_READ_pHYs_SUPPORTED && \
+ defined PNG_READ_sBIT_SUPPORTED && \
+ defined PNG_READ_sCAL_SUPPORTED && \
+ defined PNG_READ_sRGB_SUPPORTED && \
+ defined PNG_READ_sPLT_SUPPORTED && \
+ defined PNG_READ_tEXt_SUPPORTED && \
+ defined PNG_READ_tIME_SUPPORTED && \
+ defined PNG_READ_zTXt_SUPPORTED && \
+ (defined PNG_WRITE_INTERLACING_SUPPORTED || PNG_LIBPNG_VER >= 10700)
/* Copied from pngpriv.h but only used in error messages below. */
#ifndef PNG_ZBUF_SIZE
# define PNG_ZBUF_SIZE 8192
#endif
-#define FCLOSE(file) fclose(file)
-#ifndef PNG_STDIO_SUPPORTED
-typedef FILE * png_FILE_p;
-#endif
-
-/* Makes pngtest verbose so we can find problems. */
#ifndef PNG_DEBUG
# define PNG_DEBUG 0
#endif
#if PNG_DEBUG > 1
-# define pngtest_debug(m) ((void)fprintf(stderr, m "\n"))
-# define pngtest_debug1(m,p1) ((void)fprintf(stderr, m "\n", p1))
-# define pngtest_debug2(m,p1,p2) ((void)fprintf(stderr, m "\n", p1, p2))
-#else
-# define pngtest_debug(m) ((void)0)
-# define pngtest_debug1(m,p1) ((void)0)
-# define pngtest_debug2(m,p1,p2) ((void)0)
-#endif
-
-#if !PNG_DEBUG
-# define SINGLE_ROWBUF_ALLOC /* Makes buffer overruns easier to nail */
-#endif
-
-#ifndef PNG_UNUSED
-# define PNG_UNUSED(param) (void)param;
+# define pngtest_debug(m) ((void)fprintf(stderr, m "\n"))
+# define pngtest_debug1(m, p1) ((void)fprintf(stderr, m "\n", p1))
+# define pngtest_debug2(m, p1, p2) ((void)fprintf(stderr, m "\n", p1, p2))
+#elif PNG_DEBUG == 0 || PNG_DEBUG == 1
+# define pngtest_debug(m) ((void)0)
+# define pngtest_debug1(m, p1) ((void)0)
+# define pngtest_debug2(m, p1, p2) ((void)0)
+#else /* PNG_DEBUG < 0 */
+# error Bad PNG_DEBUG value
#endif
/* Turn on CPU timing
@@ -120,25 +133,11 @@ static float t_start, t_stop, t_decode, t_encode, t_misc;
#endif
#ifdef PNG_TIME_RFC1123_SUPPORTED
-#define PNG_tIME_STRING_LENGTH 29
static int tIME_chunk_present = 0;
-static char tIME_string[PNG_tIME_STRING_LENGTH] = "tIME chunk is not present";
-
-#if PNG_LIBPNG_VER < 10619
-#define png_convert_to_rfc1123_buffer(ts, t) tIME_to_str(read_ptr, ts, t)
-
-static int
-tIME_to_str(png_structp png_ptr, png_charp ts, png_const_timep t)
-{
- png_const_charp str = png_convert_to_rfc1123(png_ptr, t);
-
- if (str == NULL)
- return 0;
-
- strcpy(ts, str);
- return 1;
-}
-#endif /* older libpng */
+static char tIME_string[29] = "tIME chunk is not present";
+/* This use case is deprecated.
+ * See the declaration of png_convert_to_rfc1123_buffer for more details.
+ */
#endif
static int verbose = 0;
@@ -149,22 +148,6 @@ static int unsupported_chunks = 0; /* chunk unsupported by libpng in input */
static int error_count = 0; /* count calls to png_error */
static int warning_count = 0; /* count calls to png_warning */
-/* Define png_jmpbuf() in case we are using a pre-1.0.6 version of libpng */
-#ifndef png_jmpbuf
-# define png_jmpbuf(png_ptr) png_ptr->jmpbuf
-#endif
-
-/* Defines for unknown chunk handling if required. */
-#ifndef PNG_HANDLE_CHUNK_ALWAYS
-# define PNG_HANDLE_CHUNK_ALWAYS 3
-#endif
-#ifndef PNG_HANDLE_CHUNK_IF_SAFE
-# define PNG_HANDLE_CHUNK_IF_SAFE 2
-#endif
-
-/* Utility to save typing/errors, the argument must be a name */
-#define MEMZERO(var) ((void)memset(&var, 0, sizeof var))
-
/* Example of using row callbacks to make a simple progress meter */
static int status_pass = 1;
static int status_dots_requested = 0;
@@ -173,8 +156,13 @@ static int status_dots = 1;
static void PNGCBAPI
read_row_callback(png_structp png_ptr, png_uint_32 row_number, int pass)
{
- if (png_ptr == NULL || row_number > PNG_UINT_31_MAX)
- return;
+ /* The callback should always receive correct parameters. */
+ if (png_ptr == NULL)
+ png_error(png_ptr, "read_row_callback: bad png_ptr");
+ if (row_number > PNG_UINT_31_MAX)
+ png_error(png_ptr, "read_row_callback: bad row number");
+ if (pass < 0 || pass > 7)
+ png_error(png_ptr, "read_row_callback: bad pass");
if (status_pass != pass)
{
@@ -188,7 +176,7 @@ read_row_callback(png_structp png_ptr, png_uint_32 row_number, int pass)
if (status_dots == 0)
{
fprintf(stdout, "\n ");
- status_dots=30;
+ status_dots = 30;
}
fprintf(stdout, "r");
@@ -198,8 +186,13 @@ read_row_callback(png_structp png_ptr, png_uint_32 row_number, int pass)
static void PNGCBAPI
write_row_callback(png_structp png_ptr, png_uint_32 row_number, int pass)
{
- if (png_ptr == NULL || row_number > PNG_UINT_31_MAX || pass > 7)
- return;
+ /* The callback should always receive correct parameters. */
+ if (png_ptr == NULL)
+ png_error(png_ptr, "write_row_callback: bad png_ptr");
+ if (row_number > PNG_UINT_31_MAX)
+ png_error(png_ptr, "write_row_callback: bad row number");
+ if (pass < 0 || pass > 7)
+ png_error(png_ptr, "write_row_callback: bad pass");
fprintf(stdout, "w");
}
@@ -212,9 +205,13 @@ write_row_callback(png_structp png_ptr, png_uint_32 row_number, int pass)
static void PNGCBAPI
read_user_callback(png_structp png_ptr, png_row_infop row_info, png_bytep data)
{
- PNG_UNUSED(png_ptr)
- PNG_UNUSED(row_info)
- PNG_UNUSED(data)
+ /* The callback should always receive correct parameters. */
+ if (png_ptr == NULL)
+ png_error(png_ptr, "read_user_callback: bad png_ptr");
+ if (row_info == NULL)
+ png_error(png_ptr, "read_user_callback: bad row info");
+ if (data == NULL)
+ png_error(png_ptr, "read_user_callback: bad data");
}
#endif
@@ -229,8 +226,14 @@ static void PNGCBAPI
count_zero_samples(png_structp png_ptr, png_row_infop row_info, png_bytep data)
{
png_bytep dp = data;
+
+ /* The callback should always receive correct parameters. */
if (png_ptr == NULL)
- return;
+ png_error(png_ptr, "count_zero_samples: bad png_ptr");
+ if (row_info == NULL)
+ png_error(png_ptr, "count_zero_samples: bad row info");
+ if (data == NULL)
+ png_error(png_ptr, "count_zero_samples: bad data");
/* Contents of row_info:
* png_uint_32 width width of row
@@ -248,7 +251,7 @@ count_zero_samples(png_structp png_ptr, png_row_infop row_info, png_bytep data)
int pos = 0;
png_uint_32 n, nstop;
- for (n = 0, nstop=row_info->width; nwidth; n < nstop; n++)
{
if (row_info->bit_depth == 1)
{
@@ -294,7 +297,7 @@ count_zero_samples(png_structp png_ptr, png_row_infop row_info, png_bytep data)
{
if ((*dp | *(dp+1)) == 0)
zero_samples++;
- dp+=2;
+ dp += 2;
}
}
}
@@ -306,7 +309,7 @@ count_zero_samples(png_structp png_ptr, png_row_infop row_info, png_bytep data)
if (row_info->color_type > 3)
color_channels--;
- for (n = 0, nstop=row_info->width; nwidth; n < nstop; n++)
{
for (channel = 0; channel < color_channels; channel++)
{
@@ -319,7 +322,7 @@ count_zero_samples(png_structp png_ptr, png_row_infop row_info, png_bytep data)
if ((*dp | *(dp+1)) == 0)
zero_samples++;
- dp+=2;
+ dp += 2;
}
}
if (row_info->color_type > 3)
@@ -345,9 +348,6 @@ count_zero_samples(png_structp png_ptr, png_row_infop row_info, png_bytep data)
#ifdef PNG_IO_STATE_SUPPORTED
void
-pngtest_check_io_state(png_structp png_ptr, size_t data_length,
- png_uint_32 io_op);
-void
pngtest_check_io_state(png_structp png_ptr, size_t data_length,
png_uint_32 io_op)
{
@@ -361,7 +361,7 @@ pngtest_check_io_state(png_structp png_ptr, size_t data_length,
/* Check if the buffer size specific to the current location
* (file signature / header / data / crc) is as expected.
*/
- switch (io_state & PNG_IO_MASK_LOC)
+ switch ((io_state & PNG_IO_MASK_LOC) != 0)
{
case PNG_IO_SIGNATURE:
if (data_length > 8)
@@ -391,19 +391,18 @@ pngtest_read_data(png_structp png_ptr, png_bytep data, size_t length)
size_t check = 0;
png_voidp io_ptr;
+ if (png_ptr == NULL)
+ png_error(png_ptr, "pngtest_read_data: bad png_ptr");
+
/* fread() returns 0 on error, so it is OK to store this in a size_t
* instead of an int, which is what fread() actually returns.
*/
io_ptr = png_get_io_ptr(png_ptr);
if (io_ptr != NULL)
- {
- check = fread(data, 1, length, (png_FILE_p)io_ptr);
- }
+ check = fread(data, 1, length, (FILE *)io_ptr);
if (check != length)
- {
png_error(png_ptr, "Read Error");
- }
#ifdef PNG_IO_STATE_SUPPORTED
pngtest_check_io_state(png_ptr, length, PNG_IO_READING);
@@ -414,8 +413,10 @@ pngtest_read_data(png_structp png_ptr, png_bytep data, size_t length)
static void PNGCBAPI
pngtest_flush(png_structp png_ptr)
{
+ if (png_ptr == NULL)
+ png_error(png_ptr, "pngtest_flush: bad png_ptr");
+
/* Do nothing; fflush() is said to be just a waste of energy. */
- PNG_UNUSED(png_ptr) /* Stifle compiler warning */
}
#endif
@@ -429,12 +430,13 @@ pngtest_write_data(png_structp png_ptr, png_bytep data, size_t length)
{
size_t check;
- check = fwrite(data, 1, length, (png_FILE_p)png_get_io_ptr(png_ptr));
+ if (png_ptr == NULL)
+ png_error(png_ptr, "pngtest_write_data: bad png_ptr");
+
+ check = fwrite(data, 1, length, (FILE *)png_get_io_ptr(png_ptr));
if (check != length)
- {
png_error(png_ptr, "Write Error");
- }
#ifdef PNG_IO_STATE_SUPPORTED
pngtest_check_io_state(png_ptr, length, PNG_IO_WRITING);
@@ -499,8 +501,8 @@ pngtest_error(png_structp png_ptr, png_const_charp message)
*/
typedef struct memory_information
{
- png_alloc_size_t size;
- png_voidp pointer;
+ png_alloc_size_t size;
+ png_voidp pointer;
struct memory_information *next;
} memory_information;
typedef memory_information *memory_infop;
@@ -511,9 +513,9 @@ static int maximum_allocation = 0;
static int total_allocation = 0;
static int num_allocations = 0;
-png_voidp PNGCBAPI png_debug_malloc PNGARG((png_structp png_ptr,
- png_alloc_size_t size));
-void PNGCBAPI png_debug_free PNGARG((png_structp png_ptr, png_voidp ptr));
+png_voidp PNGCBAPI png_debug_malloc(png_structp png_ptr,
+ png_alloc_size_t size);
+void PNGCBAPI png_debug_free(png_structp png_ptr, png_voidp ptr);
png_voidp
PNGCBAPI png_debug_malloc(png_structp png_ptr, png_alloc_size_t size)
@@ -524,7 +526,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. */
@@ -537,7 +539,7 @@ PNGCBAPI png_debug_malloc(png_structp png_ptr, png_alloc_size_t size)
pinfo->size = size;
current_allocation += size;
total_allocation += size;
- num_allocations ++;
+ ++num_allocations;
if (current_allocation > maximum_allocation)
maximum_allocation = current_allocation;
@@ -565,7 +567,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;
}
}
@@ -635,15 +637,14 @@ png_debug_free(png_structp png_ptr, png_voidp ptr)
/* (sTER is a public chunk not yet known by libpng. vpAg is a private
chunk used in ImageMagick to store "virtual page" size). */
-static struct user_chunk_data
+typedef struct user_chunk_info_def
{
png_const_infop info_ptr;
- png_uint_32 vpAg_width, vpAg_height;
- png_byte vpAg_units;
- png_byte sTER_mode;
- int location[2];
-}
-user_chunk_data;
+ png_uint_32 vpAg_width, vpAg_height;
+ png_byte vpAg_units;
+ png_byte sTER_mode;
+ int location[2];
+} user_chunk_info;
/* Used for location and order; zero means nothing. */
#define have_sTER 0x01
@@ -653,37 +654,38 @@ user_chunk_data;
#define after_IDAT 0x40
static void
-init_callback_info(png_const_infop info_ptr)
+init_user_chunk_info(png_const_infop info_ptr, user_chunk_info *chunk_data)
{
- MEMZERO(user_chunk_data);
- user_chunk_data.info_ptr = info_ptr;
+ memset(chunk_data, 0, sizeof(*chunk_data));
+ chunk_data->info_ptr = info_ptr;
}
static int
-set_location(png_structp png_ptr, struct user_chunk_data *data, int what)
+set_chunk_location(png_structp png_ptr, user_chunk_info *chunk_data, int what)
{
int location;
- if ((data->location[0] & what) != 0 || (data->location[1] & what) != 0)
- return 0; /* already have one of these */
+ if ((chunk_data->location[0] & what) != 0 ||
+ (chunk_data->location[1] & what) != 0)
+ return 0; /* we already have one of these */
/* Find where we are (the code below zeroes info_ptr to indicate that the
* chunks before the first IDAT have been read.)
*/
- if (data->info_ptr == NULL) /* after IDAT */
+ if (chunk_data->info_ptr == NULL) /* after IDAT */
location = what | after_IDAT;
- else if (png_get_valid(png_ptr, data->info_ptr, PNG_INFO_PLTE) != 0)
+ else if (png_get_valid(png_ptr, chunk_data->info_ptr, PNG_INFO_PLTE) != 0)
location = what | before_IDAT;
else
location = what | before_PLTE;
- if (data->location[0] == 0)
- data->location[0] = location;
+ if (chunk_data->location[0] == 0)
+ chunk_data->location[0] = location;
else
- data->location[1] = location;
+ chunk_data->location[1] = location;
return 1; /* handled */
}
@@ -691,16 +693,16 @@ set_location(png_structp png_ptr, struct user_chunk_data *data, int what)
static int PNGCBAPI
read_user_chunk_callback(png_struct *png_ptr, png_unknown_chunkp chunk)
{
- struct user_chunk_data *my_user_chunk_data =
- (struct user_chunk_data*)png_get_user_chunk_ptr(png_ptr);
+ user_chunk_info *my_user_chunk_data =
+ (user_chunk_info*)png_get_user_chunk_ptr(png_ptr);
if (my_user_chunk_data == NULL)
- png_error(png_ptr, "lost user chunk pointer");
+ png_error(png_ptr, "lost pointer to user chunk data");
/* 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,54 +717,54 @@ 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)
+ if (set_chunk_location(png_ptr, my_user_chunk_data, have_sTER) != 0)
{
- my_user_chunk_data->sTER_mode=chunk->data[0];
- return (1);
+ my_user_chunk_data->sTER_mode = chunk->data[0];
+ 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 */
+ if (set_chunk_location(png_ptr, my_user_chunk_data, have_vpAg) == 0)
+ 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
static void
-write_sTER_chunk(png_structp write_ptr)
+write_sTER_chunk(png_structp write_ptr, user_chunk_info *data)
{
png_byte sTER[5] = {115, 84, 69, 82, '\0'};
if (verbose != 0)
- fprintf(STDERR, "\n stereo mode = %d\n", user_chunk_data.sTER_mode);
+ fprintf(STDERR, "\n stereo mode = %d\n", data->sTER_mode);
- png_write_chunk(write_ptr, sTER, &user_chunk_data.sTER_mode, 1);
+ png_write_chunk(write_ptr, sTER, &data->sTER_mode, 1);
}
static void
-write_vpAg_chunk(png_structp write_ptr)
+write_vpAg_chunk(png_structp write_ptr, user_chunk_info *data)
{
png_byte vpAg[5] = {118, 112, 65, 103, '\0'};
@@ -770,18 +772,18 @@ write_vpAg_chunk(png_structp write_ptr)
if (verbose != 0)
fprintf(STDERR, " vpAg = %lu x %lu, units = %d\n",
- (unsigned long)user_chunk_data.vpAg_width,
- (unsigned long)user_chunk_data.vpAg_height,
- user_chunk_data.vpAg_units);
+ (unsigned long)data->vpAg_width,
+ (unsigned long)data->vpAg_height,
+ data->vpAg_units);
- png_save_uint_32(vpag_chunk_data, user_chunk_data.vpAg_width);
- png_save_uint_32(vpag_chunk_data + 4, user_chunk_data.vpAg_height);
- vpag_chunk_data[8] = user_chunk_data.vpAg_units;
+ png_save_uint_32(vpag_chunk_data, data->vpAg_width);
+ png_save_uint_32(vpag_chunk_data + 4, data->vpAg_height);
+ vpag_chunk_data[8] = data->vpAg_units;
png_write_chunk(write_ptr, vpAg, vpag_chunk_data, 9);
}
static void
-write_chunks(png_structp write_ptr, int location)
+write_chunks(png_structp write_ptr, user_chunk_info *data, int location)
{
int i;
@@ -791,13 +793,13 @@ write_chunks(png_structp write_ptr, int location)
* vpAg chunks, resulting in an error later. This is not worth worrying
* about - the chunks should not be duplicated!
*/
- for (i=0; i<2; ++i)
+ for (i = 0; i < 2; ++i)
{
- if (user_chunk_data.location[i] == (location | have_sTER))
- write_sTER_chunk(write_ptr);
+ if (data->location[i] == (location | have_sTER))
+ write_sTER_chunk(write_ptr, data);
- else if (user_chunk_data.location[i] == (location | have_vpAg))
- write_vpAg_chunk(write_ptr);
+ else if (data->location[i] == (location | have_vpAg))
+ write_vpAg_chunk(write_ptr, data);
}
}
#endif /* WRITE */
@@ -852,8 +854,8 @@ pngtest_check_text_support(png_structp png_ptr, png_textp text_ptr,
static int
test_one_file(const char *inname, const char *outname)
{
- static png_FILE_p fpin;
- static png_FILE_p fpout; /* "static" prevents setjmp corruption */
+ static FILE *fpin;
+ static FILE *fpout; /* "static" prevents setjmp corruption */
pngtest_error_parameters error_parameters;
png_structp read_ptr;
png_infop read_info_ptr, end_info_ptr;
@@ -872,9 +874,9 @@ test_one_file(const char *inname, const char *outname)
png_bytep row_buf;
png_uint_32 y;
png_uint_32 width, height;
- volatile int num_passes;
- int pass;
int bit_depth, color_type;
+ user_chunk_info my_user_chunk_data;
+ int pass, num_passes;
row_buf = NULL;
error_parameters.file_name = inname;
@@ -882,14 +884,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);
+ fclose(fpin);
+ return 1;
}
pngtest_debug("Allocating read and write structures");
@@ -925,8 +927,8 @@ test_one_file(const char *inname, const char *outname)
#endif
#ifdef PNG_READ_USER_CHUNKS_SUPPORTED
- init_callback_info(read_info_ptr);
- png_set_read_user_chunk_fn(read_ptr, &user_chunk_data,
+ init_user_chunk_info(read_info_ptr, &my_user_chunk_data);
+ png_set_read_user_chunk_fn(read_ptr, &my_user_chunk_data,
read_user_chunk_callback);
#endif
@@ -946,9 +948,9 @@ test_one_file(const char *inname, const char *outname)
png_destroy_info_struct(write_ptr, &write_end_info_ptr);
png_destroy_write_struct(&write_ptr, &write_info_ptr);
#endif
- FCLOSE(fpin);
- FCLOSE(fpout);
- return (1);
+ fclose(fpin);
+ fclose(fpout);
+ return 1;
}
#ifdef PNG_WRITE_SUPPORTED
@@ -966,9 +968,9 @@ test_one_file(const char *inname, const char *outname)
fprintf(STDERR, " destroying write structs\n");
png_destroy_info_struct(write_ptr, &write_end_info_ptr);
png_destroy_write_struct(&write_ptr, &write_info_ptr);
- FCLOSE(fpin);
- FCLOSE(fpout);
- return (1);
+ fclose(fpin);
+ fclose(fpout);
+ return 1;
}
#endif
#endif
@@ -1053,13 +1055,13 @@ test_one_file(const char *inname, const char *outname)
#endif
#ifdef PNG_SET_UNKNOWN_CHUNKS_SUPPORTED
- /* Preserve all the unknown chunks, if possible. If this is disabled then,
+ /* Preserve all the unknown chunks, if possible. If this is disabled, then
* even if the png_{get,set}_unknown_chunks stuff is enabled, we can't use
* libpng to *save* the unknown chunks on read (because we can't switch the
* save option on!)
*
- * Notice that if SET_UNKNOWN_CHUNKS is *not* supported read will discard all
- * unknown chunks and write will write them all.
+ * Notice that if SET_UNKNOWN_CHUNKS is *not* supported, the reader will
+ * discard all unknown chunks, and the writer will write them all.
*/
#ifdef PNG_SAVE_UNKNOWN_CHUNKS_SUPPORTED
png_set_keep_unknown_chunks(read_ptr, PNG_HANDLE_CHUNK_ALWAYS,
@@ -1080,7 +1082,7 @@ test_one_file(const char *inname, const char *outname)
* remove the info_ptr (which is only used to determine position relative to
* PLTE) here to indicate that we are after the IDAT.
*/
- user_chunk_data.info_ptr = NULL;
+ my_user_chunk_data.info_ptr = NULL;
#endif
pngtest_debug("Transferring info struct");
@@ -1136,6 +1138,30 @@ test_one_file(const char *inname, const char *outname)
png_set_gAMA_fixed(write_ptr, write_info_ptr, gamma);
}
#endif
+#ifdef PNG_cLLI_SUPPORTED
+ {
+ png_uint_32 maxCLL;
+ png_uint_32 maxFALL;
+
+ if (png_get_cLLI_fixed(read_ptr, read_info_ptr, &maxCLL, &maxFALL) != 0)
+ png_set_cLLI_fixed(write_ptr, write_info_ptr, maxCLL, maxFALL);
+ }
+#endif
+#ifdef PNG_mDCV_SUPPORTED
+ {
+ png_fixed_point white_x, white_y, red_x, red_y, green_x, green_y, blue_x,
+ blue_y;
+ png_uint_32 maxDL;
+ png_uint_32 minDL;
+
+ if (png_get_mDCV_fixed(read_ptr, read_info_ptr, &white_x, &white_y,
+ &red_x, &red_y, &green_x, &green_y, &blue_x, &blue_y,
+ &maxDL, &minDL) != 0)
+ png_set_mDCV_fixed(write_ptr, write_info_ptr, white_x, white_y,
+ red_x, red_y, green_x, green_y, blue_x, blue_y,
+ maxDL, minDL);
+ }
+#endif
#else /* Use floating point versions */
#ifdef PNG_FLOATING_POINT_SUPPORTED
#ifdef PNG_cHRM_SUPPORTED
@@ -1159,8 +1185,46 @@ test_one_file(const char *inname, const char *outname)
png_set_gAMA(write_ptr, write_info_ptr, gamma);
}
#endif
+#ifdef PNG_cLLI_SUPPORTED
+ {
+ double maxCLL;
+ double maxFALL;
+
+ if (png_get_cLLI(read_ptr, read_info_ptr, &maxCLL, &maxFALL) != 0)
+ png_set_cLLI(write_ptr, write_info_ptr, maxCLL, maxFALL);
+ }
+#endif
+#ifdef PNG_mDCV_SUPPORTED
+ {
+ double white_x, white_y, red_x, red_y, green_x, green_y, blue_x, blue_y;
+ double maxDL;
+ double minDL;
+
+ if (png_get_mDCV(read_ptr, read_info_ptr, &white_x, &white_y,
+ &red_x, &red_y, &green_x, &green_y, &blue_x, &blue_y,
+ &maxDL, &minDL) != 0)
+ png_set_mDCV(write_ptr, write_info_ptr, white_x, white_y,
+ red_x, red_y, green_x, green_y, blue_x, blue_y,
+ maxDL, minDL);
+ }
+#endif
#endif /* Floating point */
#endif /* Fixed point */
+#ifdef PNG_cICP_SUPPORTED
+ {
+ png_byte colour_primaries;
+ png_byte transfer_function;
+ png_byte matrix_coefficients;
+ png_byte video_full_range_flag;
+
+ if (png_get_cICP(read_ptr, read_info_ptr,
+ &colour_primaries, &transfer_function,
+ &matrix_coefficients, &video_full_range_flag) != 0)
+ png_set_cICP(write_ptr, write_info_ptr,
+ colour_primaries, transfer_function,
+ matrix_coefficients, video_full_range_flag);
+ }
+#endif
#ifdef PNG_iCCP_SUPPORTED
{
png_charp name;
@@ -1196,14 +1260,12 @@ test_one_file(const char *inname, const char *outname)
png_color_16p background;
if (png_get_bKGD(read_ptr, read_info_ptr, &background) != 0)
- {
png_set_bKGD(write_ptr, write_info_ptr, background);
- }
}
#endif
#ifdef PNG_READ_eXIf_SUPPORTED
{
- png_bytep exif=NULL;
+ png_bytep exif = NULL;
png_uint_32 exif_length;
if (png_get_eXIf_1(read_ptr, read_info_ptr, &exif_length, &exif) != 0)
@@ -1232,9 +1294,7 @@ test_one_file(const char *inname, const char *outname)
if (png_get_oFFs(read_ptr, read_info_ptr, &offset_x, &offset_y,
&unit_type) != 0)
- {
png_set_oFFs(write_ptr, write_info_ptr, offset_x, offset_y, unit_type);
- }
}
#endif
#ifdef PNG_pCAL_SUPPORTED
@@ -1246,10 +1306,8 @@ test_one_file(const char *inname, const char *outname)
if (png_get_pCAL(read_ptr, read_info_ptr, &purpose, &X0, &X1, &type,
&nparams, &units, ¶ms) != 0)
- {
png_set_pCAL(write_ptr, write_info_ptr, purpose, X0, X1, type,
nparams, units, params);
- }
}
#endif
#ifdef PNG_pHYs_SUPPORTED
@@ -1279,9 +1337,7 @@ test_one_file(const char *inname, const char *outname)
if (png_get_sCAL(read_ptr, read_info_ptr, &unit, &scal_width,
&scal_height) != 0)
- {
png_set_sCAL(write_ptr, write_info_ptr, unit, scal_width, scal_height);
- }
}
#else
#ifdef PNG_FIXED_POINT_SUPPORTED
@@ -1304,11 +1360,9 @@ test_one_file(const char *inname, const char *outname)
{
png_sPLT_tp entries;
- int num_entries = (int) png_get_sPLT(read_ptr, read_info_ptr, &entries);
- if (num_entries)
- {
+ int num_entries = png_get_sPLT(read_ptr, read_info_ptr, &entries);
+ if (num_entries != 0)
png_set_sPLT(write_ptr, write_info_ptr, entries, num_entries);
- }
}
#endif
@@ -1328,7 +1382,7 @@ test_one_file(const char *inname, const char *outname)
int i;
fprintf(STDERR,"\n");
- for (i=0; iinterlaced != 0)
{
png_ptr->transformations |= PNG_INTERLACE;
- return (7);
+ return 7;
}
- return (1);
+ return 1;
}
#endif
@@ -498,6 +497,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 +699,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 +711,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)
{
@@ -799,8 +802,8 @@ png_do_check_palette_indexes(png_structrp png_ptr, png_row_infop row_info)
defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED)
#ifdef PNG_USER_TRANSFORM_PTR_SUPPORTED
void PNGAPI
-png_set_user_transform_info(png_structrp png_ptr, png_voidp
- user_transform_ptr, int user_transform_depth, int user_transform_channels)
+png_set_user_transform_info(png_structrp png_ptr, png_voidp user_transform_ptr,
+ int user_transform_depth, int user_transform_channels)
{
png_debug(1, "in png_set_user_transform_info");
@@ -833,7 +836,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/src/libs/Irrlicht/irrlicht-svn/source/Irrlicht/libpng/pngwio.c b/src/libs/Irrlicht/irrlicht-svn/source/Irrlicht/libpng/pngwio.c
index b6adfd53..9f3fdc4f 100644
--- a/src/libs/Irrlicht/irrlicht-svn/source/Irrlicht/libpng/pngwio.c
+++ b/src/libs/Irrlicht/irrlicht-svn/source/Irrlicht/libpng/pngwio.c
@@ -1,7 +1,6 @@
-
/* pngwio.c - functions for data output
*
- * Copyright (c) 2018 Cosmin Truta
+ * Copyright (c) 2018-2025 Cosmin Truta
* Copyright (c) 1998-2002,2004,2006-2014,2016,2018 Glenn Randers-Pehrson
* Copyright (c) 1996-1997 Andreas Dilger
* Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
@@ -55,7 +54,7 @@ png_default_write_data(png_structp png_ptr, png_bytep data, size_t length)
if (png_ptr == NULL)
return;
- check = fwrite(data, 1, length, (png_FILE_p)(png_ptr->io_ptr));
+ check = fwrite(data, 1, length, (FILE *)png_ptr->io_ptr);
if (check != length)
png_error(png_ptr, "Write Error");
@@ -78,12 +77,12 @@ png_flush(png_structrp png_ptr)
void PNGCBAPI
png_default_flush(png_structp png_ptr)
{
- png_FILE_p io_ptr;
+ FILE *io_ptr;
if (png_ptr == NULL)
return;
- io_ptr = png_voidcast(png_FILE_p, (png_ptr->io_ptr));
+ io_ptr = png_voidcast(FILE *, png_ptr->io_ptr);
fflush(io_ptr);
}
# endif
diff --git a/src/libs/Irrlicht/irrlicht-svn/source/Irrlicht/libpng/pngwrite.c b/src/libs/Irrlicht/irrlicht-svn/source/Irrlicht/libpng/pngwrite.c
index 85ec5a46..24f2b2f8 100644
--- a/src/libs/Irrlicht/irrlicht-svn/source/Irrlicht/libpng/pngwrite.c
+++ b/src/libs/Irrlicht/irrlicht-svn/source/Irrlicht/libpng/pngwrite.c
@@ -1,7 +1,6 @@
-
/* pngwrite.c - general routines to write a PNG file
*
- * Copyright (c) 2018-2019 Cosmin Truta
+ * Copyright (c) 2018-2026 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.
@@ -75,10 +74,10 @@ write_unknown_chunks(png_structrp png_ptr, png_const_inforp info_ptr,
* library. If you have a new chunk to add, make a function to write it,
* and put it in the correct location here. If you want the chunk written
* after the image data, put it in png_write_end(). I strongly encourage
- * you to supply a PNG_INFO_ flag, and check info_ptr->valid before writing
- * the chunk, as that will keep the code from breaking if you want to just
- * write a plain PNG file. If you have long comments, I suggest writing
- * them in png_write_end(), and compressing them.
+ * you to supply a PNG_INFO_ flag, and check info_ptr->valid before
+ * writing the chunk, as that will keep the code from breaking if you want
+ * to just write a plain PNG file. If you have long comments, I suggest
+ * writing them in png_write_end(), and compressing them.
*/
void PNGAPI
png_write_info_before_PLTE(png_structrp png_ptr, png_const_inforp info_ptr)
@@ -128,61 +127,93 @@ png_write_info_before_PLTE(png_structrp png_ptr, png_const_inforp info_ptr)
* the application continues writing the PNG. So check the 'invalid'
* flag here too.
*/
-#ifdef PNG_GAMMA_SUPPORTED
-# ifdef PNG_WRITE_gAMA_SUPPORTED
- if ((info_ptr->colorspace.flags & PNG_COLORSPACE_INVALID) == 0 &&
- (info_ptr->colorspace.flags & PNG_COLORSPACE_FROM_gAMA) != 0 &&
- (info_ptr->valid & PNG_INFO_gAMA) != 0)
- png_write_gAMA_fixed(png_ptr, info_ptr->colorspace.gamma);
-# endif
+#ifdef PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED
+ /* Write unknown chunks first; PNG v3 establishes a precedence order
+ * for colourspace chunks. It is certain therefore that new
+ * colourspace chunks will have a precedence and very likely it will be
+ * higher than all known so far. Writing the unknown chunks here is
+ * most likely to present the chunks in the most convenient order.
+ *
+ * FUTURE: maybe write chunks in the order the app calls png_set_chnk
+ * to give the app control.
+ */
+ write_unknown_chunks(png_ptr, info_ptr, PNG_HAVE_IHDR);
#endif
-#ifdef PNG_COLORSPACE_SUPPORTED
- /* Write only one of sRGB or an ICC profile. If a profile was supplied
- * and it matches one of the known sRGB ones issue a warning.
- */
-# ifdef PNG_WRITE_iCCP_SUPPORTED
- if ((info_ptr->colorspace.flags & PNG_COLORSPACE_INVALID) == 0 &&
- (info_ptr->valid & PNG_INFO_iCCP) != 0)
- {
-# ifdef PNG_WRITE_sRGB_SUPPORTED
- if ((info_ptr->valid & PNG_INFO_sRGB) != 0)
- png_app_warning(png_ptr,
- "profile matches sRGB but writing iCCP instead");
-# endif
+#ifdef PNG_WRITE_sBIT_SUPPORTED
+ /* PNG v3: a streaming app will need to see this before cICP because
+ * the information is helpful in handling HLG encoding (which is
+ * natively 10 bits but gets expanded to 16 in PNG.)
+ *
+ * The app shouldn't care about the order ideally, but it might have
+ * no choice. In PNG v3, apps are allowed to reject PNGs where the
+ * APNG chunks are out of order so it behooves libpng to be nice here.
+ */
+ if ((info_ptr->valid & PNG_INFO_sBIT) != 0)
+ png_write_sBIT(png_ptr, &(info_ptr->sig_bit), info_ptr->color_type);
+#endif
+ /* PNG v3: the July 2004 version of the TR introduced the concept of colour
+ * space priority. As above it therefore behooves libpng to write the colour
+ * space chunks in the priority order so that a streaming app need not buffer
+ * them.
+ *
+ * PNG v3: Chunks mDCV and cLLI provide ancillary information for the
+ * interpretation of the colourspace chunkgs but do not require support for
+ * those chunks so are outside the "COLORSPACE" check but before the write of
+ * the colourspace chunks themselves.
+ */
+#ifdef PNG_WRITE_cLLI_SUPPORTED
+ if ((info_ptr->valid & PNG_INFO_cLLI) != 0)
+ {
+ png_write_cLLI_fixed(png_ptr, info_ptr->maxCLL, info_ptr->maxFALL);
+ }
+#endif
+#ifdef PNG_WRITE_mDCV_SUPPORTED
+ if ((info_ptr->valid & PNG_INFO_mDCV) != 0)
+ {
+ png_write_mDCV_fixed(png_ptr,
+ info_ptr->mastering_red_x, info_ptr->mastering_red_y,
+ info_ptr->mastering_green_x, info_ptr->mastering_green_y,
+ info_ptr->mastering_blue_x, info_ptr->mastering_blue_y,
+ info_ptr->mastering_white_x, info_ptr->mastering_white_y,
+ info_ptr->mastering_maxDL, info_ptr->mastering_minDL);
+ }
+#endif
+
+# ifdef PNG_WRITE_cICP_SUPPORTED /* Priority 4 */
+ if ((info_ptr->valid & PNG_INFO_cICP) != 0)
+ {
+ png_write_cICP(png_ptr,
+ info_ptr->cicp_colour_primaries,
+ info_ptr->cicp_transfer_function,
+ info_ptr->cicp_matrix_coefficients,
+ info_ptr->cicp_video_full_range_flag);
+ }
+# endif
+
+# ifdef PNG_WRITE_iCCP_SUPPORTED /* Priority 3 */
+ if ((info_ptr->valid & PNG_INFO_iCCP) != 0)
+ {
png_write_iCCP(png_ptr, info_ptr->iccp_name,
- info_ptr->iccp_profile);
+ info_ptr->iccp_profile, info_ptr->iccp_proflen);
}
-# ifdef PNG_WRITE_sRGB_SUPPORTED
- else
-# endif
# endif
-# ifdef PNG_WRITE_sRGB_SUPPORTED
- if ((info_ptr->colorspace.flags & PNG_COLORSPACE_INVALID) == 0 &&
- (info_ptr->valid & PNG_INFO_sRGB) != 0)
- png_write_sRGB(png_ptr, info_ptr->colorspace.rendering_intent);
+# ifdef PNG_WRITE_sRGB_SUPPORTED /* Priority 2 */
+ if ((info_ptr->valid & PNG_INFO_sRGB) != 0)
+ png_write_sRGB(png_ptr, info_ptr->rendering_intent);
# endif /* WRITE_sRGB */
-#endif /* COLORSPACE */
-#ifdef PNG_WRITE_sBIT_SUPPORTED
- if ((info_ptr->valid & PNG_INFO_sBIT) != 0)
- png_write_sBIT(png_ptr, &(info_ptr->sig_bit), info_ptr->color_type);
-#endif
-
-#ifdef PNG_COLORSPACE_SUPPORTED
-# ifdef PNG_WRITE_cHRM_SUPPORTED
- if ((info_ptr->colorspace.flags & PNG_COLORSPACE_INVALID) == 0 &&
- (info_ptr->colorspace.flags & PNG_COLORSPACE_FROM_cHRM) != 0 &&
- (info_ptr->valid & PNG_INFO_cHRM) != 0)
- png_write_cHRM_fixed(png_ptr, &info_ptr->colorspace.end_points_xy);
+# ifdef PNG_WRITE_gAMA_SUPPORTED /* Priority 1 */
+ if ((info_ptr->valid & PNG_INFO_gAMA) != 0)
+ png_write_gAMA_fixed(png_ptr, info_ptr->gamma);
# endif
-#endif
-#ifdef PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED
- write_unknown_chunks(png_ptr, info_ptr, PNG_HAVE_IHDR);
-#endif
+# ifdef PNG_WRITE_cHRM_SUPPORTED /* Also priority 1 */
+ if ((info_ptr->valid & PNG_INFO_cHRM) != 0)
+ png_write_cHRM_fixed(png_ptr, &info_ptr->cHRM);
+# endif
png_ptr->mode |= PNG_WROTE_INFO_BEFORE_PLTE;
}
@@ -239,7 +270,10 @@ png_write_info(png_structrp png_ptr, png_const_inforp info_ptr)
#ifdef PNG_WRITE_eXIf_SUPPORTED
if ((info_ptr->valid & PNG_INFO_eXIf) != 0)
+ {
png_write_eXIf(png_ptr, info_ptr->exif, info_ptr->num_exif);
+ png_ptr->mode |= PNG_WROTE_eXIf;
+ }
#endif
#ifdef PNG_WRITE_hIST_SUPPORTED
@@ -366,7 +400,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
@@ -439,8 +474,9 @@ png_write_end(png_structrp png_ptr, png_inforp info_ptr)
#endif
#ifdef PNG_WRITE_eXIf_SUPPORTED
- if ((info_ptr->valid & PNG_INFO_eXIf) != 0)
- png_write_eXIf(png_ptr, info_ptr->exif, info_ptr->num_exif);
+ if ((info_ptr->valid & PNG_INFO_eXIf) != 0 &&
+ (png_ptr->mode & PNG_WROTE_eXIf) == 0)
+ png_write_eXIf(png_ptr, info_ptr->exif, info_ptr->num_exif);
#endif
#ifdef PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED
@@ -489,6 +525,16 @@ png_convert_from_time_t(png_timep ptime, time_t ttime)
png_debug(1, "in png_convert_from_time_t");
tbuf = gmtime(&ttime);
+ if (tbuf == NULL)
+ {
+ /* TODO: add a safe function which takes a png_ptr argument and raises
+ * a png_error if the ttime argument is invalid and the call to gmtime
+ * fails as a consequence.
+ */
+ memset(ptime, 0, sizeof(*ptime));
+ return;
+ }
+
png_convert_from_struct_tm(ptime, tbuf);
}
#endif
@@ -496,7 +542,8 @@ png_convert_from_time_t(png_timep ptime, time_t ttime)
/* Initialize png_ptr structure, and allocate any memory needed */
PNG_FUNCTION(png_structp,PNGAPI
png_create_write_struct,(png_const_charp user_png_ver, png_voidp error_ptr,
- png_error_ptr error_fn, png_error_ptr warn_fn),PNG_ALLOCATED)
+ png_error_ptr error_fn, png_error_ptr warn_fn),
+ PNG_ALLOCATED)
{
#ifndef PNG_USER_MEM_SUPPORTED
png_structrp png_ptr = png_create_png_struct(user_png_ver, error_ptr,
@@ -510,7 +557,8 @@ png_create_write_struct,(png_const_charp user_png_ver, png_voidp error_ptr,
PNG_FUNCTION(png_structp,PNGAPI
png_create_write_struct_2,(png_const_charp user_png_ver, png_voidp error_ptr,
png_error_ptr error_fn, png_error_ptr warn_fn, png_voidp mem_ptr,
- png_malloc_ptr malloc_fn, png_free_ptr free_fn),PNG_ALLOCATED)
+ png_malloc_ptr malloc_fn, png_free_ptr free_fn),
+ PNG_ALLOCATED)
{
png_structrp png_ptr = png_create_png_struct(user_png_ver, error_ptr,
error_fn, warn_fn, mem_ptr, malloc_fn, free_fn);
@@ -700,12 +748,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)
{
@@ -1196,6 +1244,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;
@@ -1279,6 +1329,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;
@@ -1316,6 +1368,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;
@@ -1324,8 +1378,8 @@ png_set_write_status_fn(png_structrp png_ptr, png_write_status_ptr write_row_fn)
#ifdef PNG_WRITE_USER_TRANSFORM_SUPPORTED
void PNGAPI
-png_set_write_user_transform_fn(png_structrp png_ptr, png_user_transform_ptr
- write_user_transform_fn)
+png_set_write_user_transform_fn(png_structrp png_ptr,
+ png_user_transform_ptr write_user_transform_fn)
{
png_debug(1, "in png_set_write_user_transform_fn");
@@ -1341,8 +1395,10 @@ png_set_write_user_transform_fn(png_structrp png_ptr, png_user_transform_ptr
#ifdef PNG_INFO_IMAGE_SUPPORTED
void PNGAPI
png_write_png(png_structrp png_ptr, png_inforp info_ptr,
- int transforms, voidp params)
+ int transforms, png_voidp params)
{
+ png_debug(1, "in png_write_png");
+
if (png_ptr == NULL || info_ptr == NULL)
return;
@@ -1504,18 +1560,20 @@ png_image_write_init(png_imagep image)
/* Arguments to png_image_write_main: */
typedef struct
{
- /* Arguments: */
- png_imagep image;
+ /* Arguments */
+ png_imagep image;
png_const_voidp buffer;
- png_int_32 row_stride;
+ png_int_32 row_stride;
png_const_voidp colormap;
- int convert_to_8bit;
- /* Local variables: */
+ int convert_to_8bit;
+
+ /* Instance variables */
png_const_voidp first_row;
- ptrdiff_t row_bytes;
- png_voidp local_row;
+ png_voidp local_row;
+ ptrdiff_t row_step;
+
/* Byte count for memory writing */
- png_bytep memory;
+ png_bytep memory;
png_alloc_size_t memory_bytes; /* not used for STDIO */
png_alloc_size_t output_bytes; /* running total */
} png_image_write_control;
@@ -1622,7 +1680,7 @@ png_write_image_16bit(png_voidp argument)
}
png_write_row(png_ptr, png_voidcast(png_const_bytep, display->local_row));
- input_row += (png_uint_16)display->row_bytes/(sizeof (png_uint_16));
+ input_row += display->row_step / 2;
}
return 1;
@@ -1748,7 +1806,7 @@ png_write_image_8bit(png_voidp argument)
png_write_row(png_ptr, png_voidcast(png_const_bytep,
display->local_row));
- input_row += (png_uint_16)display->row_bytes/(sizeof (png_uint_16));
+ input_row += display->row_step / 2;
} /* while y */
}
@@ -1773,7 +1831,7 @@ png_write_image_8bit(png_voidp argument)
}
png_write_row(png_ptr, output_row);
- input_row += (png_uint_16)display->row_bytes/(sizeof (png_uint_16));
+ input_row += display->row_step / 2;
}
}
@@ -2089,16 +2147,16 @@ png_image_write_main(png_voidp argument)
{
png_const_bytep row = png_voidcast(png_const_bytep, display->buffer);
- ptrdiff_t row_bytes = display->row_stride;
+ ptrdiff_t row_step = display->row_stride;
if (linear != 0)
- row_bytes *= (sizeof (png_uint_16));
+ row_step *= 2;
- if (row_bytes < 0)
- row += (image->height-1) * (-row_bytes);
+ if (row_step < 0)
+ row += (image->height-1) * (-row_step);
display->first_row = row;
- display->row_bytes = row_bytes;
+ display->row_step = row_step;
}
/* Apply 'fast' options if the flag is set. */
@@ -2119,8 +2177,7 @@ png_image_write_main(png_voidp argument)
* before it is written. This only applies when the input is 16-bit and
* either there is an alpha channel or it is converted to 8-bit.
*/
- if ((linear != 0 && alpha != 0 ) ||
- (colormap == 0 && display->convert_to_8bit != 0))
+ if (linear != 0 && (alpha != 0 || display->convert_to_8bit != 0))
{
png_bytep row = png_voidcast(png_bytep, png_malloc(png_ptr,
png_get_rowbytes(png_ptr, info_ptr)));
@@ -2146,13 +2203,13 @@ png_image_write_main(png_voidp argument)
else
{
png_const_bytep row = png_voidcast(png_const_bytep, display->first_row);
- ptrdiff_t row_bytes = display->row_bytes;
+ ptrdiff_t row_step = display->row_step;
png_uint_32 y = image->height;
for (; y > 0; --y)
{
png_write_row(png_ptr, row);
- row += row_bytes;
+ row += row_step;
}
}
@@ -2279,7 +2336,7 @@ int PNGAPI
png_image_write_to_stdio(png_imagep image, FILE *file, int convert_to_8bit,
const void *buffer, png_int_32 row_stride, const void *colormap)
{
- /* Write the image to the given (FILE*). */
+ /* Write the image to the given FILE object. */
if (image != NULL && image->version == PNG_IMAGE_VERSION)
{
if (file != NULL && buffer != NULL)
diff --git a/src/libs/Irrlicht/irrlicht-svn/source/Irrlicht/libpng/pngwtran.c b/src/libs/Irrlicht/irrlicht-svn/source/Irrlicht/libpng/pngwtran.c
index 473c3b87..b0afd973 100644
--- a/src/libs/Irrlicht/irrlicht-svn/source/Irrlicht/libpng/pngwtran.c
+++ b/src/libs/Irrlicht/irrlicht-svn/source/Irrlicht/libpng/pngwtran.c
@@ -1,4 +1,3 @@
-
/* pngwtran.c - transforms the data in a row for PNG writers
*
* Copyright (c) 2018 Cosmin Truta
diff --git a/src/libs/Irrlicht/irrlicht-svn/source/Irrlicht/libpng/pngwutil.c b/src/libs/Irrlicht/irrlicht-svn/source/Irrlicht/libpng/pngwutil.c
index a479a682..5cc2a475 100644
--- a/src/libs/Irrlicht/irrlicht-svn/source/Irrlicht/libpng/pngwutil.c
+++ b/src/libs/Irrlicht/irrlicht-svn/source/Irrlicht/libpng/pngwutil.c
@@ -1,7 +1,6 @@
-
/* pngwutil.c - utilities to write a PNG file
*
- * Copyright (c) 2018 Cosmin Truta
+ * Copyright (c) 2018-2025 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.
@@ -9,12 +8,30 @@
* This code is released under the libpng license.
* For conditions of distribution and use, see the disclaimer
* and license in png.h
+ *
+ * This file contains routines that are only called from within
+ * libpng itself during the course of writing an image.
*/
#include "pngpriv.h"
#ifdef PNG_WRITE_SUPPORTED
+#ifdef PNG_WRITE_INTERLACING_SUPPORTED
+/* Arrays to facilitate interlacing - use pass (0 - 6) as index. */
+
+/* Start of interlace block */
+static const png_byte png_pass_start[7] = {0, 4, 0, 2, 0, 1, 0};
+/* Offset to next interlace block */
+static const png_byte png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1};
+/* Start of interlace block in the y direction */
+static const png_byte png_pass_ystart[7] = {0, 0, 4, 0, 2, 0, 1};
+/* Offset to next interlace block in the y direction */
+static const png_byte png_pass_yinc[7] = {8, 8, 8, 4, 4, 2, 2};
+
+/* TODO: Move these arrays to a common utility module to avoid duplication. */
+#endif
+
#ifdef PNG_WRITE_INT_FUNCTIONS_SUPPORTED
/* Place a 32-bit number into a buffer in PNG byte order. We work
* with unsigned numbers for convenience, although one supported
@@ -468,10 +485,10 @@ png_free_buffer_list(png_structrp png_ptr, png_compression_bufferp *listp)
*/
typedef struct
{
- png_const_bytep input; /* The uncompressed input data */
- png_alloc_size_t input_len; /* Its length */
- png_uint_32 output_len; /* Final compressed length */
- png_byte output[1024]; /* First block of output */
+ png_const_bytep input; /* The uncompressed input data */
+ png_alloc_size_t input_len; /* Its length */
+ png_uint_32 output_len; /* Final compressed length */
+ png_byte output[1024]; /* First block of output */
} compression_state;
static void
@@ -1115,10 +1132,9 @@ png_write_sRGB(png_structrp png_ptr, int srgb_intent)
/* Write an iCCP chunk */
void /* PRIVATE */
png_write_iCCP(png_structrp png_ptr, png_const_charp name,
- png_const_bytep profile)
+ png_const_bytep profile, png_uint_32 profile_len)
{
png_uint_32 name_len;
- png_uint_32 profile_len;
png_byte new_name[81]; /* 1 byte for the compression byte */
compression_state comp;
png_uint_32 temp;
@@ -1131,11 +1147,12 @@ png_write_iCCP(png_structrp png_ptr, png_const_charp name,
if (profile == NULL)
png_error(png_ptr, "No profile for iCCP chunk"); /* internal error */
- profile_len = png_get_uint_32(profile);
-
if (profile_len < 132)
png_error(png_ptr, "ICC profile too short");
+ if (png_get_uint_32(profile) != profile_len)
+ png_error(png_ptr, "Incorrect data in iCCP");
+
temp = (png_uint_32) (*(profile+8));
if (temp > 3 && (profile_len & 0x03))
png_error(png_ptr, "ICC profile length invalid (not a multiple of 4)");
@@ -1471,6 +1488,73 @@ png_write_bKGD(png_structrp png_ptr, png_const_color_16p back, int color_type)
}
#endif
+#ifdef PNG_WRITE_cICP_SUPPORTED
+/* Write the cICP data */
+void /* PRIVATE */
+png_write_cICP(png_structrp png_ptr,
+ png_byte colour_primaries, png_byte transfer_function,
+ png_byte matrix_coefficients, png_byte video_full_range_flag)
+{
+ png_byte buf[4];
+
+ png_debug(1, "in png_write_cICP");
+
+ png_write_chunk_header(png_ptr, png_cICP, 4);
+
+ buf[0] = colour_primaries;
+ buf[1] = transfer_function;
+ buf[2] = matrix_coefficients;
+ buf[3] = video_full_range_flag;
+ png_write_chunk_data(png_ptr, buf, 4);
+
+ png_write_chunk_end(png_ptr);
+}
+#endif
+
+#ifdef PNG_WRITE_cLLI_SUPPORTED
+void /* PRIVATE */
+png_write_cLLI_fixed(png_structrp png_ptr, png_uint_32 maxCLL,
+ png_uint_32 maxFALL)
+{
+ png_byte buf[8];
+
+ png_debug(1, "in png_write_cLLI_fixed");
+
+ png_save_uint_32(buf, maxCLL);
+ png_save_uint_32(buf + 4, maxFALL);
+
+ png_write_complete_chunk(png_ptr, png_cLLI, buf, 8);
+}
+#endif
+
+#ifdef PNG_WRITE_mDCV_SUPPORTED
+void /* PRIVATE */
+png_write_mDCV_fixed(png_structrp png_ptr,
+ png_uint_16 red_x, png_uint_16 red_y,
+ png_uint_16 green_x, png_uint_16 green_y,
+ png_uint_16 blue_x, png_uint_16 blue_y,
+ png_uint_16 white_x, png_uint_16 white_y,
+ png_uint_32 maxDL, png_uint_32 minDL)
+{
+ png_byte buf[24];
+
+ png_debug(1, "in png_write_mDCV_fixed");
+
+ png_save_uint_16(buf + 0, red_x);
+ png_save_uint_16(buf + 2, red_y);
+ png_save_uint_16(buf + 4, green_x);
+ png_save_uint_16(buf + 6, green_y);
+ png_save_uint_16(buf + 8, blue_x);
+ png_save_uint_16(buf + 10, blue_y);
+ png_save_uint_16(buf + 12, white_x);
+ png_save_uint_16(buf + 14, white_y);
+ png_save_uint_32(buf + 16, maxDL);
+ png_save_uint_32(buf + 20, minDL);
+
+ png_write_complete_chunk(png_ptr, png_mDCV, buf, 24);
+}
+#endif
+
#ifdef PNG_WRITE_eXIf_SUPPORTED
/* Write the Exif data */
void /* PRIVATE */
@@ -1747,7 +1831,7 @@ png_write_pCAL(png_structrp png_ptr, png_charp purpose, png_int_32 X0,
{
png_uint_32 purpose_len;
size_t units_len, total_len;
- png_size_tp params_len;
+ size_t *params_len;
png_byte buf[10];
png_byte new_purpose[80];
int i;
@@ -1769,7 +1853,7 @@ png_write_pCAL(png_structrp png_ptr, png_charp purpose, png_int_32 X0,
png_debug1(3, "pCAL units length = %d", (int)units_len);
total_len = purpose_len + units_len + 10;
- params_len = (png_size_tp)png_malloc(png_ptr,
+ params_len = (size_t *)png_malloc(png_ptr,
(png_alloc_size_t)((png_alloc_size_t)nparams * (sizeof (size_t))));
/* Find the length of each parameter, making sure we don't count the
@@ -1889,22 +1973,6 @@ png_write_tIME(png_structrp png_ptr, png_const_timep mod_time)
void /* PRIVATE */
png_write_start_row(png_structrp png_ptr)
{
-#ifdef PNG_WRITE_INTERLACING_SUPPORTED
- /* Arrays to facilitate easy interlacing - use pass (0 - 6) as index */
-
- /* Start of interlace block */
- static const png_byte png_pass_start[7] = {0, 4, 0, 2, 0, 1, 0};
-
- /* Offset to next interlace block */
- static const png_byte png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1};
-
- /* Start of interlace block in the y direction */
- static const png_byte png_pass_ystart[7] = {0, 0, 4, 0, 2, 0, 1};
-
- /* Offset to next interlace block in the y direction */
- static const png_byte png_pass_yinc[7] = {8, 8, 8, 4, 4, 2, 2};
-#endif
-
png_alloc_size_t buf_size;
int usr_pixel_depth;
@@ -2004,22 +2072,6 @@ png_write_start_row(png_structrp png_ptr)
void /* PRIVATE */
png_write_finish_row(png_structrp png_ptr)
{
-#ifdef PNG_WRITE_INTERLACING_SUPPORTED
- /* Arrays to facilitate easy interlacing - use pass (0 - 6) as index */
-
- /* Start of interlace block */
- static const png_byte png_pass_start[7] = {0, 4, 0, 2, 0, 1, 0};
-
- /* Offset to next interlace block */
- static const png_byte png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1};
-
- /* Start of interlace block in the y direction */
- static const png_byte png_pass_ystart[7] = {0, 0, 4, 0, 2, 0, 1};
-
- /* Offset to next interlace block in the y direction */
- static const png_byte png_pass_yinc[7] = {8, 8, 8, 4, 4, 2, 2};
-#endif
-
png_debug(1, "in png_write_finish_row");
/* Next row */
@@ -2095,14 +2147,6 @@ png_write_finish_row(png_structrp png_ptr)
void /* PRIVATE */
png_do_write_interlace(png_row_infop row_info, png_bytep row, int pass)
{
- /* Arrays to facilitate easy interlacing - use pass (0 - 6) as index */
-
- /* Start of interlace block */
- static const png_byte png_pass_start[7] = {0, 4, 0, 2, 0, 1, 0};
-
- /* Offset to next interlace block */
- static const png_byte png_pass_inc[7] = {8, 8, 4, 4, 2, 2, 1};
-
png_debug(1, "in png_do_write_interlace");
/* We don't have to do anything on the last pass (6) */
@@ -2311,7 +2355,7 @@ png_setup_sub_row(png_structrp png_ptr, png_uint_32 bpp,
break;
}
- return (sum);
+ return sum;
}
static void /* PRIVATE */
@@ -2361,7 +2405,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 +2461,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 +2544,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,