[libpng] Update: v1.6.44 -> v1.6.46

[debian] copyright: Update libpng.
This commit is contained in:
David Korth 2025-01-27 18:22:34 -05:00
parent 5178e6b25e
commit 9de5720776
100 changed files with 2585 additions and 1187 deletions

3
debian/copyright vendored
View File

@ -70,7 +70,8 @@ License: BSD-3-clause
Files:
extlib/libpng/*
Copyright: Copyright (c) 1998-2018 Glenn Randers-Pehrson
Copyright: Copyright (c) 2018-2025 Cosmin Truta
Copyright (c) 1998-2018 Glenn Randers-Pehrson
License: libpng
Files:

View File

@ -1,5 +1,5 @@
libpng 1.6.44 - September 12, 2024
==================================
libpng 1.6.46 - January 23, 2025
================================
This is a public release of libpng, intended for use in production code.
@ -9,13 +9,13 @@ Files available for download
Source files with LF line endings (for Unix/Linux):
* libpng-1.6.44.tar.xz (LZMA-compressed, recommended)
* libpng-1.6.44.tar.gz (deflate-compressed)
* libpng-1.6.46.tar.xz (LZMA-compressed, recommended)
* libpng-1.6.46.tar.gz (deflate-compressed)
Source files with CRLF line endings (for Windows):
* lpng1644.7z (LZMA-compressed, recommended)
* lpng1644.zip (deflate-compressed)
* lpng1646.7z (LZMA-compressed, recommended)
* lpng1646.zip (deflate-compressed)
Other information:
@ -25,29 +25,17 @@ Other information:
* TRADEMARK.md
Changes from version 1.6.43 to version 1.6.44
Changes from version 1.6.45 to version 1.6.46
---------------------------------------------
* 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.
* Added support for the mDCV and cLLI chunks.
(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.
* 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.
Send comments/corrections/commendations to png-mng-implement at lists.sf.net.

View File

@ -17,6 +17,7 @@ Authors, for copyright and licensing purposes.
* James Yu
* John Bowler
* Kevin Bracey
* Lucas Chollet
* Magnus Holmgren
* Mandar Sahastrabuddhe
* Mans Rullgard

21
extlib/libpng/CHANGES vendored
View File

@ -6218,6 +6218,27 @@ Version 1.6.44 [September 12, 2024]
(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.
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

View File

@ -1,9 +1,9 @@
# CMakeLists.txt - CMake lists for libpng
#
# Copyright (c) 2018-2024 Cosmin Truta.
# Copyright (c) 2007-2018 Glenn Randers-Pehrson.
# Originally written by Christian Ehrlicher, 2007.
# Copyright (c) 2018-2025 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.
@ -17,12 +17,12 @@
# rom-properties: Disabled; use the main project policies.
IF(0)
cmake_minimum_required(VERSION 3.6)
cmake_minimum_required(VERSION 3.14)
ENDIF(0) # rom-properties
set(PNGLIB_MAJOR 1)
set(PNGLIB_MINOR 6)
set(PNGLIB_REVISION 44)
set(PNGLIB_REVISION 46)
set(PNGLIB_SUBREVISION 0)
#set(PNGLIB_SUBREVISION "git")
set(PNGLIB_VERSION ${PNGLIB_MAJOR}.${PNGLIB_MINOR}.${PNGLIB_REVISION})
@ -77,7 +77,7 @@ 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)
if(ANDROID OR IOS)
option(PNG_TOOLS "Build the libpng tools" OFF)
else()
option(PNG_TOOLS "Build the libpng tools" ON)
@ -107,7 +107,7 @@ ENDIF(0) # rom-properties
# 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)
if(APPLE AND CMAKE_OSX_ARCHITECTURES)
string(TOLOWER "${CMAKE_OSX_ARCHITECTURES}" PNG_TARGET_ARCHITECTURE)
else()
string(TOLOWER "${CMAKE_SYSTEM_PROCESSOR}" PNG_TARGET_ARCHITECTURE)
@ -115,28 +115,30 @@ endif()
message(STATUS "Building for target architecture: ${PNG_TARGET_ARCHITECTURE}")
# Allow the users to specify a custom location of zlib.
# This option is deprecated, and no longer needed with CMake 3.12 and newer.
# Under the CMake policy CMP0074, if zlib is being built alongside libpng as a
# subproject, its location can be passed on to CMake via the ZLIB_ROOT variable.
# With CMake 3.12 and newer, this option is no longer necessary.
# rom-properties: Don't use option() here; it's set by extlib.
IF(0)
option(PNG_BUILD_ZLIB "Custom zlib location, else find_package is used" OFF)
option(PNG_BUILD_ZLIB "[Deprecated; please use ZLIB_ROOT]" OFF)
ENDIF(0) # rom-properties
if(NOT PNG_BUILD_ZLIB)
find_package(ZLIB REQUIRED)
elseif(POLICY CMP0074)
if(PNG_BUILD_ZLIB)
if("x${ZLIB_ROOT}" STREQUAL "x")
#message(SEND_ERROR
message(DEPRECATION
"The option PNG_BUILD_ZLIB has been deprecated; please use ZLIB_ROOT instead")
"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} and "
"the variable ZLIB_ROOT=\"${ZLIB_ROOT}\" are mutually exclusive")
"The option PNG_BUILD_ZLIB=${PNG_BUILD_ZLIB} is no longer supported; "
"using ZLIB_ROOT=\"${ZLIB_ROOT}\"")
endif()
else()
find_package(ZLIB REQUIRED)
endif()
if(UNIX AND NOT APPLE AND NOT BEOS AND NOT HAIKU AND NOT EMSCRIPTEN)
if(UNIX
AND NOT (APPLE OR BEOS OR HAIKU)
AND NOT EMSCRIPTEN)
find_library(M_LIBRARY m)
if(M_LIBRARY)
set(M_LIBRARY m)
@ -149,217 +151,217 @@ endif()
if(PNG_HARDWARE_OPTIMIZATIONS)
# 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()
endif()
# 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()
endif()
# 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()
endif()
# rom-properties: Enable Intel SSE2 optimizations on x86.
# Supercedes the above block.
if(PNG_TARGET_ARCHITECTURE MATCHES "^i?86" OR
PNG_TARGET_ARCHITECTURE MATCHES "^x86_64*")
SET(libpng_sources
${libpng_sources}
intel/filter_sse2_intrinsics.c
intel/intel_init.c
)
ADD_DEFINITIONS(-DPNG_INTEL_SSE)
# Enable SSE2 for filter_sse2_intrinsics.c only.
# NOTE: SSE2 is always enabled on AMD64.
IF(MSVC AND NOT CMAKE_CL_64)
SET(SSE2_FLAG "/arch:SSE2")
IF(MSVC_VERSION LESS 1900)
# NOTE: We have to compile as C++ in versions
# of MSVC older than 2015 due to declarations
# of variables after code.
SET_SOURCE_FILES_PROPERTIES(intel/filter_sse2_intrinsics.c
PROPERTIES LANGUAGE CXX)
ENDIF(MSVC_VERSION LESS 1900)
ELSEIF(NOT MSVC)
# TODO: Other compilers?
SET(SSE2_FLAG "-msse2")
ENDIF()
SET_SOURCE_FILES_PROPERTIES(intel/filter_sse2_intrinsics.c
APPEND_STRING PROPERTIES COMPILE_FLAGS " ${SSE2_FLAG} ")
ENDIF()
# 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)
# 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()
message(FATAL_ERROR "Compiler does not support -mlsx option")
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()
endif()
# 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()
endif()
# 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()
endif()
# rom-properties: Enable Intel SSE2 optimizations on x86.
# Supercedes the above block.
if(PNG_TARGET_ARCHITECTURE MATCHES "^i?86" OR
PNG_TARGET_ARCHITECTURE MATCHES "^x86_64*")
SET(libpng_sources
${libpng_sources}
intel/filter_sse2_intrinsics.c
intel/intel_init.c
)
ADD_DEFINITIONS(-DPNG_INTEL_SSE)
# Enable SSE2 for filter_sse2_intrinsics.c only.
# NOTE: SSE2 is always enabled on AMD64.
IF(MSVC AND NOT CMAKE_CL_64)
SET(SSE2_FLAG "/arch:SSE2")
IF(MSVC_VERSION LESS 1900)
# NOTE: We have to compile as C++ in versions
# of MSVC older than 2015 due to declarations
# of variables after code.
SET_SOURCE_FILES_PROPERTIES(intel/filter_sse2_intrinsics.c
PROPERTIES LANGUAGE CXX)
ENDIF(MSVC_VERSION LESS 1900)
ELSEIF(NOT MSVC)
# TODO: Other compilers?
SET(SSE2_FLAG "-msse2")
ENDIF()
SET_SOURCE_FILES_PROPERTIES(intel/filter_sse2_intrinsics.c
APPEND_STRING PROPERTIES COMPILE_FLAGS " ${SSE2_FLAG} ")
ENDIF()
# 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 "Compiler does not support -mlsx option")
endif()
else()
add_definitions(-DPNG_LOONGARCH_LSX_OPT=0)
endif()
else()
add_definitions(-DPNG_LOONGARCH_LSX_OPT=0)
endif()
endif()
else(PNG_HARDWARE_OPTIMIZATIONS)
# 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 ARM.
if(PNG_TARGET_ARCHITECTURE MATCHES "^(arm|aarch)")
add_definitions(-DPNG_ARM_NEON_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 PowerPC.
if(PNG_TARGET_ARCHITECTURE MATCHES "^(powerpc|ppc64)")
add_definitions(-DPNG_POWERPC_VSX_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 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(PNG_TARGET_ARCHITECTURE MATCHES "^(mipsel|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()
# Set definitions and sources for LoongArch.
if(PNG_TARGET_ARCHITECTURE MATCHES "^(loongarch)")
add_definitions(-DPNG_LOONGARCH_LSX_OPT=0)
endif()
# Set definitions and sources for LoongArch.
if(PNG_TARGET_ARCHITECTURE MATCHES "^(loongarch)")
add_definitions(-DPNG_LOONGARCH_LSX_OPT=0)
endif()
endif(PNG_HARDWARE_OPTIMIZATIONS)
option(ld-version-script "Enable linker version script" ON)
if(ld-version-script AND NOT ANDROID 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: sym1; local: *; };
@ -405,12 +407,15 @@ else()
message(STATUS "Could not find an AWK-compatible program")
endif()
if(NOT AWK OR ANDROID OR IOS)
if(NOT AWK OR (ANDROID OR IOS))
# 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(png_genfiles)
else()
# Include the internal module PNGGenConfig.cmake
include(${CMAKE_CURRENT_SOURCE_DIR}/scripts/cmake/PNGGenConfig.cmake)
# Copy the awk scripts, converting their line endings to Unix (LF)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/scripts/checksym.awk
${CMAKE_CURRENT_BINARY_DIR}/scripts/checksym.awk
@ -425,93 +430,6 @@ else()
@ONLY
NEWLINE_STYLE LF)
# 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/cmake/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/cmake/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/cmake/gensrc.cmake"
DEPENDS ${_GSO_DEPENDS}
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}")
endfunction()
# Copy file
# generate_copy(INPUT inputfile OUTPUT outputfile [DEPENDS dep1 [dep2...]])
function(generate_copy)
set(options)
set(oneValueArgs INPUT OUTPUT)
set(multiValueArgs DEPENDS)
cmake_parse_arguments(_GCO "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
if(NOT _GCO_INPUT)
message(FATAL_ERROR "generate_copy: Missing INPUT argument")
endif()
if(NOT _GCO_OUTPUT)
message(FATAL_ERROR "generate_copy: Missing OUTPUT argument")
endif()
add_custom_command(OUTPUT "${_GCO_OUTPUT}"
COMMAND "${CMAKE_COMMAND}"
-E remove "${_GCO_OUTPUT}"
COMMAND "${CMAKE_COMMAND}"
-E copy "${_GCO_INPUT}" "${_GCO_OUTPUT}"
DEPENDS "${source}" ${_GCO_DEPENDS})
endfunction()
# Generate scripts/pnglibconf.h
generate_source(OUTPUT "scripts/pnglibconf.c"
DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/scripts/pnglibconf.dfa"
@ -633,7 +551,7 @@ else()
"${CMAKE_CURRENT_BINARY_DIR}/scripts/symbols.chk" png_scripts_symbols_chk
"${CMAKE_CURRENT_BINARY_DIR}/scripts/symbols.out" png_scripts_symbols_out
"${CMAKE_CURRENT_BINARY_DIR}/scripts/vers.out" png_scripts_vers_out)
endif(NOT AWK OR ANDROID OR IOS)
endif(NOT AWK OR (ANDROID OR IOS))
# List the source code files.
set(libpng_public_hdrs
@ -647,7 +565,7 @@ set(libpng_private_hdrs
pnginfo.h
pngstruct.h
)
if(AWK AND NOT ANDROID AND NOT IOS)
if(AWK AND NOT (ANDROID OR IOS))
list(APPEND libpng_private_hdrs "${CMAKE_CURRENT_BINARY_DIR}/pngprefix.h")
endif()
set(libpng_sources
@ -851,30 +769,8 @@ endif()
if(PNG_TESTS AND PNG_SHARED)
enable_testing()
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}")
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/scripts/cmake/test.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/tests/${_PAT_NAME}.cmake"
@ONLY)
add_test(NAME "${_PAT_NAME}"
COMMAND "${CMAKE_COMMAND}"
"-DLIBPNG=$<TARGET_FILE:png_shared>"
"-DTEST_COMMAND=$<TARGET_FILE:${_PAT_COMMAND}>"
-P "${CMAKE_CURRENT_BINARY_DIR}/tests/${_PAT_NAME}.cmake")
endfunction()
# 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.
@ -882,6 +778,8 @@ if(PNG_TESTS AND PNG_SHARED)
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")
@ -892,6 +790,10 @@ if(PNG_TESTS AND PNG_SHARED)
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 PRIVATE png_shared)
@ -1048,9 +950,14 @@ if(PNG_SHARED AND PNG_TOOLS)
list(APPEND PNG_BIN_TARGETS png-fix-itxt)
endif()
# Create a symlink from src to dest (if possible), or, alternatively,
# copy src to dest if different.
# 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(<destfile> [FILE <file> | TARGET <target>])
function(create_symlink DEST_FILE)
# 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 FILE or TARGET argument")

View File

@ -1,4 +1,3 @@
Installing libpng
Contents

View File

@ -4,8 +4,8 @@ COPYRIGHT NOTICE, DISCLAIMER, and LICENSE
PNG Reference Library License version 2
---------------------------------------
* Copyright (c) 1995-2024 The PNG Reference Library Authors.
* Copyright (c) 2018-2024 Cosmin Truta.
* Copyright (c) 1995-2025 The PNG Reference Library Authors.
* Copyright (c) 2018-2025 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.

View File

@ -1,4 +1,4 @@
README for libpng version 1.6.44
README for libpng version 1.6.46
================================
See the note about version numbers near the top of `png.h`.
@ -157,8 +157,6 @@ Files included in this distribution
"PNG: The Definitive Guide" by Greg Roelofs,
O'Reilly, 1999
libtests/ => Test programs
oss-fuzz/ => Files used by the OSS-Fuzz project for fuzz-testing
libpng
pngexif/ => Program to inspect the EXIF information in PNG files
pngminim/ => Minimal decoder, encoder, and progressive decoder
programs demonstrating the use of pngusr.dfa

View File

@ -1,9 +1,9 @@
This copy of libpng-1.6.44 is a modified version of the original.
This copy of libpng-1.6.46 is a modified version of the original.
commit f5e92d76973a7a53f517579bc95d61483bf108c0
Release libpng version 1.6.44
commit 0024abd279d3a06435c0309a3f4172eed7c7a19a
Release libpng version 1.6.46
Tag: v1.6.44
Tag: v1.6.46
The following changes have been made to the original:
@ -14,5 +14,5 @@ The following changes have been made to the original:
- APNG support has been added via the APNG patch:
http://sourceforge.net/projects/libpng-apng/
To obtain the original libpng-1.6.44, visit:
To obtain the original libpng-1.6.46, visit:
http://www.libpng.org/pub/png/libpng.html

View File

@ -1,4 +1,3 @@
/* arm_init.c - NEON optimised filter functions
*
* Copyright (c) 2018-2022 Cosmin Truta

View File

@ -1,4 +1,3 @@
/* filter_neon.S - placeholder file
*
* Copyright (c) 2024 Cosmin Truta

View File

@ -1,4 +1,3 @@
/* filter_neon_intrinsics.c - NEON optimised filter functions
*
* Copyright (c) 2018 Cosmin Truta

View File

@ -1,4 +1,3 @@
/* palette_neon_intrinsics.c - NEON optimised palette expansion functions
*
* Copyright (c) 2018-2019 Cosmin Truta
@ -64,7 +63,7 @@ png_do_expand_palette_rgba8_neon(png_structrp png_ptr, png_row_infop row_info,
{
png_uint_32 row_width = row_info->width;
const png_uint_32 *riffled_palette =
(const png_uint_32 *)png_ptr->riffled_palette;
png_aligncastconst(png_const_uint_32p, png_ptr->riffled_palette);
const png_uint_32 pixels_per_chunk = 4;
png_uint_32 i;

View File

@ -1,3 +1,5 @@
External contributions to libpng
--------------------------------
This "contrib" directory contains contributions which are not necessarily under
the libpng license, although all are open source. They are not part of

141
extlib/libpng/contrib/mips-mmi/linux.c vendored Normal file
View File

@ -0,0 +1,141 @@
/* contrib/mips-mmi/linux.c
*
* Copyright (c) 2024 Cosmin Truta
* Written by guxiwei, 2023
*
* This code is released under the libpng license.
* For conditions of distribution and use, see the disclaimer
* and license in png.h
*/
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include <sys/auxv.h>
/*
* parse_r var, r - Helper assembler macro for parsing register names.
*
* This converts the register name in $n form provided in \r to the
* corresponding register number, which is assigned to the variable \var. It is
* needed to allow explicit encoding of instructions in inline assembly where
* registers are chosen by the compiler in $n form, allowing us to avoid using
* fixed register numbers.
*
* It also allows newer instructions (not implemented by the assembler) to be
* transparently implemented using assembler macros, instead of needing separate
* cases depending on toolchain support.
*
* Simple usage example:
* __asm__ __volatile__("parse_r __rt, %0\n\t"
* ".insn\n\t"
* "# di %0\n\t"
* ".word (0x41606000 | (__rt << 16))"
* : "=r" (status);
*/
/* Match an individual register number and assign to \var */
#define _IFC_REG(n) \
".ifc \\r, $" #n "\n\t" \
"\\var = " #n "\n\t" \
".endif\n\t"
__asm__(".macro parse_r var r\n\t"
"\\var = -1\n\t"
_IFC_REG(0) _IFC_REG(1) _IFC_REG(2) _IFC_REG(3)
_IFC_REG(4) _IFC_REG(5) _IFC_REG(6) _IFC_REG(7)
_IFC_REG(8) _IFC_REG(9) _IFC_REG(10) _IFC_REG(11)
_IFC_REG(12) _IFC_REG(13) _IFC_REG(14) _IFC_REG(15)
_IFC_REG(16) _IFC_REG(17) _IFC_REG(18) _IFC_REG(19)
_IFC_REG(20) _IFC_REG(21) _IFC_REG(22) _IFC_REG(23)
_IFC_REG(24) _IFC_REG(25) _IFC_REG(26) _IFC_REG(27)
_IFC_REG(28) _IFC_REG(29) _IFC_REG(30) _IFC_REG(31)
".iflt \\var\n\t"
".error \"Unable to parse register name \\r\"\n\t"
".endif\n\t"
".endm");
#define HWCAP_LOONGSON_CPUCFG (1 << 14)
static int cpucfg_available(void)
{
return getauxval(AT_HWCAP) & HWCAP_LOONGSON_CPUCFG;
}
static int strstart(const char *str, const char *pfx, const char **ptr)
{
while (*pfx && *pfx == *str) {
pfx++;
str++;
}
if (!*pfx && ptr)
*ptr = str;
return !*pfx;
}
/* Most toolchains have no CPUCFG support yet */
static uint32_t read_cpucfg(uint32_t reg)
{
uint32_t __res;
__asm__ __volatile__(
"parse_r __res,%0\n\t"
"parse_r reg,%1\n\t"
".insn \n\t"
".word (0xc8080118 | (reg << 21) | (__res << 11))\n\t"
:"=r"(__res)
:"r"(reg)
:
);
return __res;
}
#define LOONGSON_CFG1 0x1
#define LOONGSON_CFG1_MMI (1 << 4)
static int cpu_flags_cpucfg(void)
{
int flags = 0;
uint32_t cfg1 = read_cpucfg(LOONGSON_CFG1);
if (cfg1 & LOONGSON_CFG1_MMI)
flags = 1;
return flags;
}
static int cpu_flags_cpuinfo(void)
{
FILE *f = fopen("/proc/cpuinfo", "r");
char buf[200];
int flags = 0;
if (!f)
return flags;
while (fgets(buf, sizeof(buf), f)) {
/* Legacy kernel may not export MMI in ASEs implemented */
if (strstart(buf, "cpu model", NULL)) {
if (strstr(buf, "Loongson-3 "))
flags = 1;
break;
}
if (strstart(buf, "ASEs implemented", NULL)) {
if (strstr(buf, " loongson-mmi"))
flags = 1;
break;
}
}
fclose(f);
return flags;
}
static int png_have_mmi()
{
if (cpucfg_available())
return cpu_flags_cpucfg();
else
return cpu_flags_cpuinfo();
return 0;
}

View File

@ -1,4 +1,3 @@
/* contrib/mips-msa/linux.c
*
* Copyright (c) 2020-2023 Cosmin Truta

View File

@ -1,4 +1,3 @@
#if 0 /* in case someone actually tries to compile this */
/* example.c - an example of using libpng

View File

@ -1,4 +1,3 @@
/* filter_sse2_intrinsics.c - SSE2 optimized filter functions
*
* Copyright (c) 2018 Cosmin Truta

View File

@ -1,4 +1,3 @@
/* intel_init.c - SSE2 optimized filter functions
*
* Copyright (c) 2018 Cosmin Truta

View File

@ -1,6 +1,6 @@
libpng-manual.txt - A description on how to use and modify libpng
Copyright (c) 2018-2024 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.44 - September 2024
libpng version 1.6.36, December 2018, through 1.6.46 - January 2025
Updated and distributed by Cosmin Truta
Copyright (c) 2018-2024 Cosmin Truta
Copyright (c) 2018-2025 Cosmin Truta
libpng versions 0.97, January 1998, through 1.6.35 - July 2018
Updated and distributed by Glenn Randers-Pehrson
@ -5173,7 +5173,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

View File

@ -1,6 +1,6 @@
.TH LIBPNG 3 "September 12, 2024"
.TH LIBPNG 3 "January 23, 2025"
.SH NAME
libpng \- Portable Network Graphics (PNG) Reference Library 1.6.44
libpng \- Portable Network Graphics (PNG) Reference Library 1.6.46
.SH SYNOPSIS
\fB#include <png.h>\fP
@ -519,7 +519,7 @@ Following is a copy of the libpng-manual.txt file that accompanies libpng.
.SH LIBPNG.TXT
libpng-manual.txt - A description on how to use and modify libpng
Copyright (c) 2018-2024 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.44 - September 2024
libpng version 1.6.36, December 2018, through 1.6.46 - January 2025
Updated and distributed by Cosmin Truta
Copyright (c) 2018-2024 Cosmin Truta
Copyright (c) 2018-2025 Cosmin Truta
libpng versions 0.97, January 1998, through 1.6.35 - July 2018
Updated and distributed by Glenn Randers-Pehrson
@ -5692,7 +5692,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

View File

@ -1,6 +1,6 @@
.TH LIBPNGPF 3 "September 12, 2024"
.TH LIBPNGPF 3 "January 23, 2025"
.SH NAME
libpng \- Portable Network Graphics (PNG) Reference Library 1.6.44
libpng \- Portable Network Graphics (PNG) Reference Library 1.6.46
(private functions)
.SH SYNOPSIS

View File

@ -1,4 +1,3 @@
/* filter_msa_intrinsics.c - MSA optimised filter functions
*
* Copyright (c) 2018-2024 Cosmin Truta
@ -47,7 +46,7 @@
uint8_t *psrc_lw_m = (uint8_t *) (psrc); \
uint32_t val_m; \
\
asm volatile ( \
__asm__ volatile ( \
"lw %[val_m], %[psrc_lw_m] \n\t" \
\
: [val_m] "=r" (val_m) \
@ -62,7 +61,7 @@
uint8_t *pdst_sh_m = (uint8_t *) (pdst); \
uint16_t val_m = (val); \
\
asm volatile ( \
__asm__ volatile ( \
"sh %[val_m], %[pdst_sh_m] \n\t" \
\
: [pdst_sh_m] "=m" (*pdst_sh_m) \
@ -75,7 +74,7 @@
uint8_t *pdst_sw_m = (uint8_t *) (pdst); \
uint32_t val_m = (val); \
\
asm volatile ( \
__asm__ volatile ( \
"sw %[val_m], %[pdst_sw_m] \n\t" \
\
: [pdst_sw_m] "=m" (*pdst_sw_m) \
@ -83,20 +82,20 @@
); \
}
#if (__mips == 64)
#if __mips == 64
#define SD(val, pdst) \
{ \
uint8_t *pdst_sd_m = (uint8_t *) (pdst); \
uint64_t val_m = (val); \
\
asm volatile ( \
__asm__ volatile ( \
"sd %[val_m], %[pdst_sd_m] \n\t" \
\
: [pdst_sd_m] "=m" (*pdst_sd_m) \
: [val_m] "r" (val_m) \
); \
}
#else
#else
#define SD(val, pdst) \
{ \
uint8_t *pdst_sd_m = (uint8_t *) (pdst); \
@ -108,17 +107,17 @@
SW(val0_m, pdst_sd_m); \
SW(val1_m, pdst_sd_m + 4); \
}
#endif
#endif /* __mips == 64 */
#else
#define MSA_SRLI_B(a, b) (a >> b)
#if (__mips_isa_rev >= 6)
#if __mips_isa_rev >= 6
#define LW(psrc) \
( { \
uint8_t *psrc_lw_m = (uint8_t *) (psrc); \
uint32_t val_m; \
\
asm volatile ( \
__asm__ volatile ( \
"lw %[val_m], %[psrc_lw_m] \n\t" \
\
: [val_m] "=r" (val_m) \
@ -133,7 +132,7 @@
uint8_t *pdst_sh_m = (uint8_t *) (pdst); \
uint16_t val_m = (val); \
\
asm volatile ( \
__asm__ volatile ( \
"sh %[val_m], %[pdst_sh_m] \n\t" \
\
: [pdst_sh_m] "=m" (*pdst_sh_m) \
@ -146,7 +145,7 @@
uint8_t *pdst_sw_m = (uint8_t *) (pdst); \
uint32_t val_m = (val); \
\
asm volatile ( \
__asm__ volatile ( \
"sw %[val_m], %[pdst_sw_m] \n\t" \
\
: [pdst_sw_m] "=m" (*pdst_sw_m) \
@ -154,20 +153,20 @@
); \
}
#if (__mips == 64)
#if __mips == 64
#define SD(val, pdst) \
{ \
uint8_t *pdst_sd_m = (uint8_t *) (pdst); \
uint64_t val_m = (val); \
\
asm volatile ( \
__asm__ volatile ( \
"sd %[val_m], %[pdst_sd_m] \n\t" \
\
: [pdst_sd_m] "=m" (*pdst_sd_m) \
: [val_m] "r" (val_m) \
); \
}
#else
#else
#define SD(val, pdst) \
{ \
uint8_t *pdst_sd_m = (uint8_t *) (pdst); \
@ -179,14 +178,14 @@
SW(val0_m, pdst_sd_m); \
SW(val1_m, pdst_sd_m + 4); \
}
#endif
#else // !(__mips_isa_rev >= 6)
#endif /* __mips == 64 */
#else
#define LW(psrc) \
( { \
uint8_t *psrc_lw_m = (uint8_t *) (psrc); \
uint32_t val_m; \
\
asm volatile ( \
__asm__ volatile ( \
"ulw %[val_m], %[psrc_lw_m] \n\t" \
\
: [val_m] "=r" (val_m) \
@ -201,7 +200,7 @@
uint8_t *pdst_sh_m = (uint8_t *) (pdst); \
uint16_t val_m = (val); \
\
asm volatile ( \
__asm__ volatile ( \
"ush %[val_m], %[pdst_sh_m] \n\t" \
\
: [pdst_sh_m] "=m" (*pdst_sh_m) \
@ -214,7 +213,7 @@
uint8_t *pdst_sw_m = (uint8_t *) (pdst); \
uint32_t val_m = (val); \
\
asm volatile ( \
__asm__ volatile ( \
"usw %[val_m], %[pdst_sw_m] \n\t" \
\
: [pdst_sw_m] "=m" (*pdst_sw_m) \
@ -222,7 +221,7 @@
); \
}
#define SD(val, pdst) \
#define SD(val, pdst) \
{ \
uint8_t *pdst_sd_m = (uint8_t *) (pdst); \
uint32_t val0_m, val1_m; \
@ -238,14 +237,14 @@
{ \
uint8_t *pdst_m = (uint8_t *) (pdst); \
\
asm volatile ( \
__asm__ volatile ( \
"usw $0, %[pdst_m] \n\t" \
\
: [pdst_m] "=m" (*pdst_m) \
: \
); \
}
#endif // (__mips_isa_rev >= 6)
#endif /* __mips_isa_rev >= 6 */
#endif
#define LD_B(RTYPE, psrc) *((RTYPE *) (psrc))

View File

@ -1,4 +1,3 @@
/* mips_init.c - MSA optimised filter functions
*
* Copyright (c) 2018-2024 Cosmin Truta

7
extlib/libpng/png.5 vendored
View File

@ -1,4 +1,4 @@
.TH PNG 5 "September 12, 2024"
.TH PNG 5 "January 23, 2025"
.SH NAME
png \- Portable Network Graphics (PNG) format
@ -20,6 +20,11 @@ matching on heterogeneous platforms.
.SH "SEE ALSO"
.BR "libpng"(3), " zlib"(3), " deflate"(5), " " and " zlib"(5)
.LP
PNG Specification (Third Edition) Candidate Recommendation Draft, July 2024:
.IP
.br
https://www.w3.org/TR/2024/CRD-png-3-20240718/
.LP
PNG Specification (Second Edition), November 2003:
.IP
.br

286
extlib/libpng/png.c vendored
View File

@ -1,7 +1,6 @@
/* png.c - location for general purpose libpng functions
*
* Copyright (c) 2018-2024 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.
@ -14,7 +13,7 @@
#include "pngpriv.h"
/* Generate a compiler error if there is an old png.h in the search path. */
typedef png_libpng_version_1_6_44 Your_png_h_is_not_version_1_6_44;
typedef png_libpng_version_1_6_46 Your_png_h_is_not_version_1_6_46;
/* 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
@ -794,8 +793,8 @@ png_get_copyright(png_const_structrp png_ptr)
return PNG_STRING_COPYRIGHT
#else
return PNG_STRING_NEWLINE \
"libpng version 1.6.44" PNG_STRING_NEWLINE \
"Copyright (c) 2018-2024 Cosmin Truta" PNG_STRING_NEWLINE \
"libpng version 1.6.46" PNG_STRING_NEWLINE \
"Copyright (c) 2018-2025 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 \
@ -1203,22 +1202,66 @@ png_colorspace_sync(png_const_structrp png_ptr, png_inforp info_ptr)
#endif /* GAMMA */
#ifdef PNG_COLORSPACE_SUPPORTED
static int
png_safe_add(png_int_32 *addend0_and_result, png_int_32 addend1,
png_int_32 addend2) {
/* Safely add three integers. Returns 0 on success, 1 on overlow.
static png_int_32
png_fp_add(png_int_32 addend0, png_int_32 addend1, int *error)
{
/* 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.
*/
int addend0 = *addend0_and_result;
if (0x7fffffff - addend0 < addend1)
return 1;
addend0 += addend1;
if (0x7fffffff - addend1 < addend2)
return 1;
*addend0_and_result = addend0 + addend2;
return 0;
if (addend0 > 0)
{
if (0x7fffffff - addend0 >= addend1)
return addend0+addend1;
}
else if (addend0 < 0)
{
if (-0x7fffffff - addend0 <= addend1)
return addend0+addend1;
}
else
return addend1;
*error = 1;
return PNG_FP_1/2;
}
static png_int_32
png_fp_sub(png_int_32 addend0, png_int_32 addend1, int *error)
{
/* As above but calculate addend0-addend1. */
if (addend1 > 0)
{
if (-0x7fffffff + addend1 <= addend0)
return addend0-addend1;
}
else if (addend1 < 0)
{
if (0x7fffffff + addend1 >= addend0)
return addend0-addend1;
}
else
return addend0;
*error = 1;
return PNG_FP_1/2;
}
static int
png_safe_add(png_int_32 *addend0_and_result, png_int_32 addend1,
png_int_32 addend2)
{
/* 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;
}
/* Added at libpng-1.5.5 to support read and write of true CIEXYZ values for
@ -1229,7 +1272,7 @@ png_safe_add(png_int_32 *addend0_and_result, png_int_32 addend1,
static int
png_xy_from_XYZ(png_xy *xy, const png_XYZ *XYZ)
{
png_int_32 d, dred, dgreen, dwhite, whiteX, whiteY;
png_int_32 d, dred, dgreen, dblue, dwhite, whiteX, whiteY;
/* '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).
@ -1237,44 +1280,52 @@ png_xy_from_XYZ(png_xy *xy, const png_XYZ *XYZ)
d = XYZ->red_X;
if (png_safe_add(&d, XYZ->red_Y, XYZ->red_Z))
return 1;
if (png_muldiv(&xy->redx, XYZ->red_X, PNG_FP_1, d) == 0)
return 1;
if (png_muldiv(&xy->redy, XYZ->red_Y, PNG_FP_1, d) == 0)
return 1;
dred = d;
whiteX = XYZ->red_X;
whiteY = XYZ->red_Y;
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;
d = XYZ->green_X;
if (png_safe_add(&d, XYZ->green_Y, XYZ->green_Z))
return 1;
if (png_muldiv(&xy->greenx, XYZ->green_X, PNG_FP_1, d) == 0)
return 1;
if (png_muldiv(&xy->greeny, XYZ->green_Y, PNG_FP_1, d) == 0)
return 1;
dgreen = d;
whiteX += XYZ->green_X;
whiteY += XYZ->green_Y;
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;
d = XYZ->blue_X;
if (png_safe_add(&d, XYZ->blue_Y, XYZ->blue_Z))
return 1;
if (png_muldiv(&xy->bluex, XYZ->blue_X, PNG_FP_1, d) == 0)
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, d) == 0)
if (png_muldiv(&xy->bluey, XYZ->blue_Y, PNG_FP_1, dblue) == 0)
return 1;
whiteX += XYZ->blue_X;
whiteY += XYZ->blue_Y;
/* 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;
/* 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)
@ -1289,6 +1340,29 @@ png_XYZ_from_xy(png_XYZ *XYZ, const png_xy *xy)
png_fixed_point red_inverse, green_inverse, blue_scale;
png_fixed_point left, right, denominator;
/* Check xy and, implicitly, z. Note that wide gamut color spaces typically
* 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.
*/
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
* derived values were recorded in the cHRM chunk;
@ -1432,18 +1506,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
@ -1465,49 +1544,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.
{
int error = 0;
/* 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;
/* 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. 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(&left, xy->greenx-xy->bluex, xy->redy - xy->bluey, 7) == 0)
return 1;
if (png_muldiv(&right, xy->greeny-xy->bluey, xy->redx - xy->bluex, 7) == 0)
return 1;
denominator = left - right;
/* Now find the red numerator. */
if (png_muldiv(&left, xy->greenx-xy->bluex, xy->whitey-xy->bluey, 7) == 0)
return 1;
if (png_muldiv(&right, xy->greeny-xy->bluey, xy->whitex-xy->bluex, 7) == 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, left-right) == 0 ||
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, 7) == 0)
return 1;
if (png_muldiv(&right, xy->redx-xy->bluex, xy->whitey-xy->bluey, 7) == 0)
return 1;
if (png_muldiv(&green_inverse, xy->whitey, denominator, left-right) == 0 ||
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_reciprocal(xy->whitey) - png_reciprocal(red_inverse) -
png_reciprocal(green_inverse);
if (blue_scale <= 0)
return 1;
/* And fill in the png_XYZ: */
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)
@ -3299,6 +3393,26 @@ png_fixed(png_const_structrp png_ptr, double fp, png_const_charp text)
}
#endif
#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_GAMMA_SUPPORTED) || defined(PNG_COLORSPACE_SUPPORTED) ||\
defined(PNG_INCH_CONVERSIONS_SUPPORTED) || defined(PNG_READ_pHYs_SUPPORTED)
/* muldiv functions */

179
extlib/libpng/png.h vendored
View File

@ -1,9 +1,8 @@
/* png.h - header file for PNG reference library
*
* libpng version 1.6.44
* libpng version 1.6.46
*
* Copyright (c) 2018-2024 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.
@ -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.44, September 2024:
* libpng versions 1.6.36, December 2018, through 1.6.46, January 2025:
* Cosmin Truta
* See also "Contributing Authors", below.
*/
@ -27,8 +26,8 @@
* PNG Reference Library License version 2
* ---------------------------------------
*
* * Copyright (c) 1995-2024 The PNG Reference Library Authors.
* * Copyright (c) 2018-2024 Cosmin Truta.
* * Copyright (c) 1995-2025 The PNG Reference Library Authors.
* * Copyright (c) 2018-2025 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.44 16 10644 16.so.16.44[.0]
* 1.6.46 16 10646 16.so.16.46[.0]
*
* Henceforth the source version will match the shared-library major and
* minor numbers; the shared-library major version number will be used for
@ -275,7 +274,7 @@
*/
/* Version information for png.h - this should match the version in png.c */
#define PNG_LIBPNG_VER_STRING "1.6.44"
#define PNG_LIBPNG_VER_STRING "1.6.46"
#define PNG_HEADER_VERSION_STRING " libpng version " PNG_LIBPNG_VER_STRING "\n"
/* The versions of shared library builds should stay in sync, going forward */
@ -286,7 +285,7 @@
/* These should match the first 3 components of PNG_LIBPNG_VER_STRING: */
#define PNG_LIBPNG_VER_MAJOR 1
#define PNG_LIBPNG_VER_MINOR 6
#define PNG_LIBPNG_VER_RELEASE 44
#define PNG_LIBPNG_VER_RELEASE 46
/* This should be zero for a public release, or non-zero for a
* development version.
@ -317,7 +316,7 @@
* From version 1.0.1 it is:
* XXYYZZ, where XX=major, YY=minor, ZZ=release
*/
#define PNG_LIBPNG_VER 10644 /* 1.6.44 */
#define PNG_LIBPNG_VER 10646 /* 1.6.46 */
/* Library configuration: these options cannot be changed after
* the library has been built.
@ -442,7 +441,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_44;
typedef char* png_libpng_version_1_6_46;
/* Basic control structions. Read libpng-manual.txt or libpng.3 for more info.
*
@ -760,10 +759,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 */
#ifdef PNG_APNG_SUPPORTED
#define PNG_INFO_acTL 0x20000U
#define PNG_INFO_fcTL 0x40000U
#endif
#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
@ -1997,6 +2007,46 @@ PNG_FIXED_EXPORT(233, void, png_set_cHRM_XYZ_fixed, (png_const_structrp png_ptr,
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));
@ -2041,6 +2091,60 @@ PNG_EXPORT(144, void, png_set_IHDR, (png_const_structrp png_ptr,
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
#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,
@ -3252,71 +3356,72 @@ PNG_EXPORT(244, int, png_set_option, (png_structrp png_ptr, int option,
/*******************************************************************************
* END OF HARDWARE AND SOFTWARE OPTIONS
******************************************************************************/
#ifdef PNG_APNG_SUPPORTED
PNG_EXPORT(250, png_uint_32, png_get_acTL, (png_structp png_ptr,
PNG_EXPORT(260, png_uint_32, png_get_acTL, (png_structp png_ptr,
png_infop info_ptr, png_uint_32 *num_frames, png_uint_32 *num_plays));
PNG_EXPORT(251, png_uint_32, png_set_acTL, (png_structp png_ptr,
PNG_EXPORT(261, png_uint_32, png_set_acTL, (png_structp png_ptr,
png_infop info_ptr, png_uint_32 num_frames, png_uint_32 num_plays));
PNG_EXPORT(252, png_uint_32, png_get_num_frames, (png_structp png_ptr,
PNG_EXPORT(262, png_uint_32, png_get_num_frames, (png_structp png_ptr,
png_infop info_ptr));
PNG_EXPORT(253, png_uint_32, png_get_num_plays, (png_structp png_ptr,
PNG_EXPORT(263, png_uint_32, png_get_num_plays, (png_structp png_ptr,
png_infop info_ptr));
PNG_EXPORT(254, png_uint_32, png_get_next_frame_fcTL,
PNG_EXPORT(264, png_uint_32, png_get_next_frame_fcTL,
(png_structp png_ptr, png_infop info_ptr, png_uint_32 *width,
png_uint_32 *height, png_uint_32 *x_offset, png_uint_32 *y_offset,
png_uint_16 *delay_num, png_uint_16 *delay_den, png_byte *dispose_op,
png_byte *blend_op));
PNG_EXPORT(255, png_uint_32, png_set_next_frame_fcTL,
PNG_EXPORT(265, png_uint_32, png_set_next_frame_fcTL,
(png_structp png_ptr, png_infop info_ptr, png_uint_32 width,
png_uint_32 height, png_uint_32 x_offset, png_uint_32 y_offset,
png_uint_16 delay_num, png_uint_16 delay_den, png_byte dispose_op,
png_byte blend_op));
PNG_EXPORT(256, png_uint_32, png_get_next_frame_width,
PNG_EXPORT(266, png_uint_32, png_get_next_frame_width,
(png_structp png_ptr, png_infop info_ptr));
PNG_EXPORT(257, png_uint_32, png_get_next_frame_height,
PNG_EXPORT(267, png_uint_32, png_get_next_frame_height,
(png_structp png_ptr, png_infop info_ptr));
PNG_EXPORT(258, png_uint_32, png_get_next_frame_x_offset,
PNG_EXPORT(268, png_uint_32, png_get_next_frame_x_offset,
(png_structp png_ptr, png_infop info_ptr));
PNG_EXPORT(259, png_uint_32, png_get_next_frame_y_offset,
PNG_EXPORT(269, png_uint_32, png_get_next_frame_y_offset,
(png_structp png_ptr, png_infop info_ptr));
PNG_EXPORT(260, png_uint_16, png_get_next_frame_delay_num,
PNG_EXPORT(270, png_uint_16, png_get_next_frame_delay_num,
(png_structp png_ptr, png_infop info_ptr));
PNG_EXPORT(261, png_uint_16, png_get_next_frame_delay_den,
PNG_EXPORT(271, png_uint_16, png_get_next_frame_delay_den,
(png_structp png_ptr, png_infop info_ptr));
PNG_EXPORT(262, png_byte, png_get_next_frame_dispose_op,
PNG_EXPORT(272, png_byte, png_get_next_frame_dispose_op,
(png_structp png_ptr, png_infop info_ptr));
PNG_EXPORT(263, png_byte, png_get_next_frame_blend_op,
PNG_EXPORT(273, png_byte, png_get_next_frame_blend_op,
(png_structp png_ptr, png_infop info_ptr));
PNG_EXPORT(264, png_byte, png_get_first_frame_is_hidden,
PNG_EXPORT(274, png_byte, png_get_first_frame_is_hidden,
(png_structp png_ptr, png_infop info_ptr));
PNG_EXPORT(265, png_uint_32, png_set_first_frame_is_hidden,
PNG_EXPORT(275, png_uint_32, png_set_first_frame_is_hidden,
(png_structp png_ptr, png_infop info_ptr, png_byte is_hidden));
#ifdef PNG_READ_APNG_SUPPORTED
PNG_EXPORT(266, void, png_read_frame_head, (png_structp png_ptr,
PNG_EXPORT(276, void, png_read_frame_head, (png_structp png_ptr,
png_infop info_ptr));
#ifdef PNG_PROGRESSIVE_READ_SUPPORTED
PNG_EXPORT(267, void, png_set_progressive_frame_fn, (png_structp png_ptr,
PNG_EXPORT(277, void, png_set_progressive_frame_fn, (png_structp png_ptr,
png_progressive_frame_ptr frame_info_fn,
png_progressive_frame_ptr frame_end_fn));
#endif /* PNG_PROGRESSIVE_READ_SUPPORTED */
#endif /* PNG_READ_APNG_SUPPORTED */
#ifdef PNG_WRITE_APNG_SUPPORTED
PNG_EXPORT(268, void, png_write_frame_head, (png_structp png_ptr,
PNG_EXPORT(278, void, png_write_frame_head, (png_structp png_ptr,
png_infop info_ptr, png_bytepp row_pointers,
png_uint_32 width, png_uint_32 height,
png_uint_32 x_offset, png_uint_32 y_offset,
png_uint_16 delay_num, png_uint_16 delay_den, png_byte dispose_op,
png_byte blend_op));
PNG_EXPORT(269, void, png_write_frame_tail, (png_structp png_ptr,
PNG_EXPORT(279, void, png_write_frame_tail, (png_structp png_ptr,
png_infop info_ptr));
#endif /* PNG_WRITE_APNG_SUPPORTED */
#endif /* PNG_APNG_SUPPORTED */
@ -3330,9 +3435,9 @@ PNG_EXPORT(269, void, png_write_frame_tail, (png_structp png_ptr,
*/
#ifdef PNG_EXPORT_LAST_ORDINAL
#ifdef PNG_APNG_SUPPORTED
PNG_EXPORT_LAST_ORDINAL(269);
PNG_EXPORT_LAST_ORDINAL(279);
#else
PNG_EXPORT_LAST_ORDINAL(249);
PNG_EXPORT_LAST_ORDINAL(259);
#endif /* PNG_APNG_SUPPORTED */
#endif

View File

@ -1,9 +1,8 @@
/* pngconf.h - machine-configurable file for libpng
*
* libpng version 1.6.44
* libpng version 1.6.46
*
* Copyright (c) 2018-2024 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.

View File

@ -1,4 +1,3 @@
/* pngdebug.h - Debugging macros for libpng, also used in pngtest.c
*
* Copyright (c) 2018 Cosmin Truta

View File

@ -1,4 +1,3 @@
/* pngerror.c - stub functions for i/o and memory allocation
*
* Copyright (c) 2018-2024 Cosmin Truta

131
extlib/libpng/pngget.c vendored
View File

@ -1,4 +1,3 @@
/* pngget.c - retrieval of values from info struct
*
* Copyright (c) 2018-2024 Cosmin Truta
@ -785,6 +784,136 @@ png_get_sPLT(png_const_structrp png_ptr, png_inforp info_ptr,
}
#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,

View File

@ -1,4 +1,3 @@
/* pnginfo.h - header file for PNG reference library
*
* Copyright (c) 2018 Cosmin Truta
@ -101,6 +100,14 @@ struct png_info_def
png_colorspace colorspace;
#endif
#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
/* iCCP chunk data. */
png_charp iccp_name; /* profile name */
@ -108,6 +115,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.

View File

@ -1,4 +1,3 @@
/* pngmem.c - stub functions for memory allocation
*
* Copyright (c) 2018 Cosmin Truta

View File

@ -1,4 +1,3 @@
/* pngpread.c - read a png file in push mode
*
* Copyright (c) 2018-2024 Cosmin Truta
@ -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)
@ -397,6 +411,30 @@ png_push_read_chunk(png_structrp png_ptr, png_inforp info_ptr)
png_handle_cHRM(png_ptr, info_ptr, png_ptr->push_length);
}
#endif
#ifdef PNG_READ_cICP_SUPPORTED
else if (png_ptr->chunk_name == png_cICP)
{
PNG_PUSH_SAVE_BUFFER_IF_FULL
png_handle_cICP(png_ptr, info_ptr, png_ptr->push_length);
}
#endif
#ifdef PNG_READ_cLLI_SUPPORTED
else if (png_ptr->chunk_name == png_cLLI)
{
PNG_PUSH_SAVE_BUFFER_IF_FULL
png_handle_cLLI(png_ptr, info_ptr, png_ptr->push_length);
}
#endif
#ifdef PNG_READ_mDCV_SUPPORTED
else if (png_ptr->chunk_name == png_mDCV)
{
PNG_PUSH_SAVE_BUFFER_IF_FULL
png_handle_mDCV(png_ptr, info_ptr, png_ptr->push_length);
}
#endif
#ifdef PNG_READ_eXIf_SUPPORTED
else if (png_ptr->chunk_name == png_eXIf)
@ -1163,27 +1201,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;

View File

@ -759,6 +759,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.
@ -811,6 +813,8 @@
#define png_PLTE PNG_U32( 80, 76, 84, 69)
#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_fRAc PNG_U32(102, 82, 65, 99) /* registered, not defined */
#define png_gAMA PNG_U32(103, 65, 77, 65)
@ -820,6 +824,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)
@ -957,6 +962,7 @@ 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))
@ -964,6 +970,13 @@ 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.
*/
@ -1117,6 +1130,26 @@ PNG_INTERNAL_FUNCTION(void,png_write_cHRM_fixed,(png_structrp png_ptr,
/* 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);
@ -1460,6 +1493,16 @@ 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_cICP_SUPPORTED
PNG_INTERNAL_FUNCTION(void,png_handle_cICP,(png_structrp png_ptr,
png_inforp info_ptr, png_uint_32 length),PNG_EMPTY);
#endif
#ifdef PNG_READ_cLLI_SUPPORTED
PNG_INTERNAL_FUNCTION(void,png_handle_cLLI,(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);
@ -1485,6 +1528,11 @@ 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_mDCV_SUPPORTED
PNG_INTERNAL_FUNCTION(void,png_handle_mDCV,(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);

View File

@ -1,7 +1,6 @@
/* pngread.c - read a PNG file
*
* Copyright (c) 2018-2024 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.
@ -178,6 +177,16 @@ png_read_info(png_structrp png_ptr, png_inforp info_ptr)
png_handle_cHRM(png_ptr, info_ptr, length);
#endif
#ifdef PNG_READ_cICP_SUPPORTED
else if (chunk_name == png_cICP)
png_handle_cICP(png_ptr, info_ptr, length);
#endif
#ifdef PNG_READ_cLLI_SUPPORTED
else if (chunk_name == png_cLLI)
png_handle_cLLI(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);
@ -193,6 +202,11 @@ png_read_info(png_structrp png_ptr, png_inforp info_ptr)
png_handle_hIST(png_ptr, info_ptr, length);
#endif
#ifdef PNG_READ_mDCV_SUPPORTED
else if (chunk_name == png_mDCV)
png_handle_mDCV(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);
@ -932,6 +946,16 @@ png_read_end(png_structrp png_ptr, png_inforp info_ptr)
png_handle_cHRM(png_ptr, info_ptr, length);
#endif
#ifdef PNG_READ_cICP_SUPPORTED
else if (chunk_name == png_cICP)
png_handle_cICP(png_ptr, info_ptr, length);
#endif
#ifdef PNG_READ_cLLI_SUPPORTED
else if (chunk_name == png_cLLI)
png_handle_cLLI(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);
@ -947,6 +971,11 @@ png_read_end(png_structrp png_ptr, png_inforp info_ptr)
png_handle_hIST(png_ptr, info_ptr, length);
#endif
#ifdef PNG_READ_mDCV_SUPPORTED
else if (chunk_name == png_mDCV)
png_handle_mDCV(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);

View File

@ -1,4 +1,3 @@
/* pngrio.c - functions for data input
*
* Copyright (c) 2018 Cosmin Truta

View File

@ -1,4 +1,3 @@
/* pngrtran.c - transforms the data in a row for PNG readers
*
* Copyright (c) 2018-2024 Cosmin Truta

View File

@ -1,4 +1,3 @@
/* pngrutil.c - utilities to read a PNG file
*
* Copyright (c) 2018-2024 Cosmin Truta
@ -18,6 +17,21 @@
#ifdef PNG_READ_SUPPORTED
#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)
{
@ -2037,6 +2051,152 @@ png_handle_bKGD(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
}
#endif
#ifdef PNG_READ_cICP_SUPPORTED
void /* 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");
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;
}
else if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_cICP) != 0)
{
png_crc_finish(png_ptr, length);
png_chunk_benign_error(png_ptr, "duplicate");
return;
}
else if (length != 4)
{
png_crc_finish(png_ptr, length);
png_chunk_benign_error(png_ptr, "invalid");
return;
}
png_crc_read(png_ptr, buf, 4);
if (png_crc_finish(png_ptr, 0) != 0)
return;
png_set_cICP(png_ptr, info_ptr, buf[0], buf[1], buf[2], buf[3]);
}
#endif
#ifdef PNG_READ_cLLI_SUPPORTED
void /* 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");
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;
}
else if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_cLLI) != 0)
{
png_crc_finish(png_ptr, length);
png_chunk_benign_error(png_ptr, "duplicate");
return;
}
else if (length != 8)
{
png_crc_finish(png_ptr, length);
png_chunk_benign_error(png_ptr, "invalid");
return;
}
png_crc_read(png_ptr, buf, 8);
if (png_crc_finish(png_ptr, 0) != 0)
return;
/* 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));
}
#endif
#ifdef PNG_READ_mDCV_SUPPORTED
void /* PRIVATE */
png_handle_mDCV(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
{
png_byte buf[24];
png_debug(1, "in png_handle_mDCV");
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;
}
else if (info_ptr != NULL && (info_ptr->valid & PNG_INFO_mDCV) != 0)
{
png_crc_finish(png_ptr, length);
png_chunk_benign_error(png_ptr, "duplicate");
return;
}
else if (length != 24)
{
png_crc_finish(png_ptr, length);
png_chunk_benign_error(png_ptr, "invalid");
return;
}
png_crc_read(png_ptr, buf, 24);
if (png_crc_finish(png_ptr, 0) != 0)
return;
/* 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.
*/
png_set_mDCV_fixed(png_ptr, info_ptr,
png_get_uint_16(buf+12U) << 1U, /* white x */
png_get_uint_16(buf+14U) << 1U, /* white y */
png_get_uint_16(buf+ 0U) << 1U, /* red x */
png_get_uint_16(buf+ 2U) << 1U, /* red y */
png_get_uint_16(buf+ 4U) << 1U, /* green x */
png_get_uint_16(buf+ 6U) << 1U, /* green y */
png_get_uint_16(buf+ 8U) << 1U, /* blue x */
png_get_uint_16(buf+10U) << 1U, /* blue y */
png_get_uint_32(buf+16U), /* peak luminance */
png_get_uint_32(buf+20U));/* minimum perceivable luminance */
}
#endif
#ifdef PNG_READ_eXIf_SUPPORTED
void /* PRIVATE */
png_handle_eXIf(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
@ -3862,10 +4022,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)
{
@ -4537,20 +4693,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)
@ -4602,20 +4744,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;

184
extlib/libpng/pngset.c vendored
View File

@ -1,7 +1,6 @@
/* pngset.c - storage of image information into info struct
*
* Copyright (c) 2018-2024 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.
@ -134,6 +133,184 @@ 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(png_const_structrp png_ptr, png_fixed_point v,
png_const_charp text)
{
/* 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)
png_fixed_error(png_ptr, text);
# ifndef PNG_ERROR_TEXT_SUPPORTED
PNG_UNUSED(text)
# endif
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;
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: */
rx = png_ITU_fixed_16(png_ptr, red_x, "png_set_mDCV(red(x))");
ry = png_ITU_fixed_16(png_ptr, red_y, "png_set_mDCV(red(y))");
gx = png_ITU_fixed_16(png_ptr, green_x, "png_set_mDCV(green(x))");
gy = png_ITU_fixed_16(png_ptr, green_y, "png_set_mDCV(green(y))");
bx = png_ITU_fixed_16(png_ptr, blue_x, "png_set_mDCV(blue(x))");
by = png_ITU_fixed_16(png_ptr, blue_y, "png_set_mDCV(blue(y))");
wx = png_ITU_fixed_16(png_ptr, white_x, "png_set_mDCV(white(x))");
wy = png_ITU_fixed_16(png_ptr, white_y, "png_set_mDCV(white(y))");
/* 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,
/* The ITU approach is to scale by 50,000, not 100,000 so just divide
* the input values by 2 and use png_fixed:
*/
png_fixed(png_ptr, white_x / 2, "png_set_mDCV(white(x))"),
png_fixed(png_ptr, white_y / 2, "png_set_mDCV(white(y))"),
png_fixed(png_ptr, red_x / 2, "png_set_mDCV(red(x))"),
png_fixed(png_ptr, red_y / 2, "png_set_mDCV(red(y))"),
png_fixed(png_ptr, green_x / 2, "png_set_mDCV(green(x))"),
png_fixed(png_ptr, green_y / 2, "png_set_mDCV(green(y))"),
png_fixed(png_ptr, blue_x / 2, "png_set_mDCV(blue(x))"),
png_fixed(png_ptr, blue_y / 2, "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,
@ -1541,11 +1718,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 */

View File

@ -1,4 +1,3 @@
/* pngstruct.h - header file for PNG reference library
*
* Copyright (c) 2018-2022 Cosmin Truta

View File

@ -1,7 +1,6 @@
/* pngtest.c - a test program for libpng
*
* Copyright (c) 2018-2024 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.
@ -51,7 +50,7 @@
#define STDERR stdout
/* Generate a compiler error if there is an old png.h in the search path. */
typedef png_libpng_version_1_6_44 Your_png_h_is_not_version_1_6_44;
typedef png_libpng_version_1_6_46 Your_png_h_is_not_version_1_6_46;
/* Ensure that all version numbers in png.h are consistent with one another. */
#if (PNG_LIBPNG_VER != PNG_LIBPNG_VER_MAJOR * 10000 + \
@ -1147,6 +1146,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
@ -1170,8 +1193,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;

View File

@ -1,4 +1,3 @@
/* pngtrans.c - transforms the data in a row (used by both readers and writers)
*
* Copyright (c) 2018-2024 Cosmin Truta

View File

@ -1,4 +1,3 @@
/* pngwio.c - functions for data output
*
* Copyright (c) 2018 Cosmin Truta

View File

@ -1,7 +1,6 @@
/* pngwrite.c - general routines to write a PNG file
*
* Copyright (c) 2018-2024 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.
@ -129,32 +128,88 @@ png_write_info_before_PLTE(png_structrp png_ptr, png_const_inforp info_ptr)
* flag here too.
*/
#ifdef PNG_WRITE_APNG_SUPPORTED
if (info_ptr->valid & PNG_INFO_acTL)
png_write_acTL(png_ptr, info_ptr->num_frames, info_ptr->num_plays);
if ((info_ptr->valid & PNG_INFO_acTL) != 0)
png_write_acTL(png_ptr, info_ptr->num_frames, info_ptr->num_plays);
#endif
#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_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_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_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
/* PNG v3 change: it is now permitted to write both sRGB and ICC profiles,
* however because the libpng code auto-generates an sRGB for the
* corresponding ICC profiles and because PNG v2 disallowed this we need
* to only write one.
*
* Remove the PNG v2 warning about writing an sRGB ICC profile as well
* because it's invalid with PNG v3.
*/
# ifdef PNG_WRITE_iCCP_SUPPORTED
# ifdef PNG_WRITE_iCCP_SUPPORTED /* Priority 3 */
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
png_write_iCCP(png_ptr, info_ptr->iccp_name,
info_ptr->iccp_profile);
}
@ -163,20 +218,24 @@ png_write_info_before_PLTE(png_structrp png_ptr, png_const_inforp info_ptr)
# endif
# endif
# ifdef PNG_WRITE_sRGB_SUPPORTED
# ifdef PNG_WRITE_sRGB_SUPPORTED /* Priority 2 */
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);
# 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);
#ifdef PNG_GAMMA_SUPPORTED
# ifdef PNG_WRITE_gAMA_SUPPORTED /* Priority 1 */
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
#endif
#ifdef PNG_COLORSPACE_SUPPORTED
# ifdef PNG_WRITE_cHRM_SUPPORTED
# ifdef PNG_WRITE_cHRM_SUPPORTED /* Also priority 1 */
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)
@ -184,10 +243,6 @@ png_write_info_before_PLTE(png_structrp png_ptr, png_const_inforp info_ptr)
# endif
#endif
#ifdef PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED
write_unknown_chunks(png_ptr, info_ptr, PNG_HAVE_IHDR);
#endif
png_ptr->mode |= PNG_WROTE_INFO_BEFORE_PLTE;
}
}

View File

@ -1,4 +1,3 @@
/* pngwtran.c - transforms the data in a row for PNG writers
*
* Copyright (c) 2018 Cosmin Truta

View File

@ -1,4 +1,3 @@
/* pngwutil.c - utilities to write a PNG file
*
* Copyright (c) 2018-2024 Cosmin Truta
@ -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
@ -1495,6 +1512,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 */
@ -1989,22 +2073,6 @@ png_write_fdAT(png_structp png_ptr,
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;
@ -2104,22 +2172,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 */
@ -2195,14 +2247,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) */

View File

@ -1,4 +1,3 @@
/* powerpc_init.c - POWERPC optimised filter functions
*
* Copyright (c) 2018 Cosmin Truta

View File

@ -1,79 +1,74 @@
Scripts and makefiles for libpng
--------------------------------
Makefiles for libpng
pnglibconf.h.prebuilt => Configuration settings
pnglibconf.h.prebuilt => Configuration settings
makefile.linux => Linux/ELF makefile
(gcc, creates shared libpng16.so.16.1.6.*)
makefile.linux-opt=> Linux/ELF makefile with hardware optimizations on
(gcc, creates shared libpng16.so.16.1.6.*)
makefile.gcc => Generic makefile (gcc, creates static libpng.a)
makefile.acorn => Acorn makefile
makefile.aix => AIX/gcc makefile
makefile.amiga => Amiga makefile
makefile.atari => Atari makefile
makefile.bc32 => 32-bit Borland C++ (all modules compiled in C mode)
makefile.beos => BeOS makefile
makefile.clang => Generic clang makefile
makefile.darwin => Darwin makefile, for macOS (formerly Mac OS X)
makefile.dec => DEC Alpha UNIX makefile
makefile.dj2 => DJGPP 2 makefile
makefile.freebsd => FreeBSD makefile
makefile.gcc => Generic gcc makefile
makefile.hpgcc => HPUX makefile using gcc
makefile.hpux => HPUX (10.20 and 11.00) makefile
makefile.hp64 => HPUX (10.20 and 11.00) makefile, 64-bit
makefile.ibmc => IBM C/C++ version 3.x for Win32 and OS/2 (static)
makefile.intel => Intel C/C++ version 4.0 and later
makefile.mips => MIPS makefile
makefile.netbsd => NetBSD/cc makefile, makes shared libpng.so
makefile.openbsd => OpenBSD makefile
makefile.sco => SCO OSr5 ELF and Unixware 7 with Native cc
makefile.sggcc => Silicon Graphics makefile
(gcc, creates shared libpng16.so.16.1.6.*)
makefile.sgi => Silicon Graphics IRIX makefile (cc, creates static lib)
makefile.solaris => Solaris 2.X makefile
(gcc, creates shared libpng16.so.16.1.6.*)
makefile.so9 => Solaris 9 makefile
(gcc, creates shared libpng16.so.16.1.6.*)
makefile.std => Generic UNIX makefile (cc, creates static libpng.a)
makefile.sunos => Sun makefile
makefile.32sunu => Sun Ultra 32-bit makefile
makefile.64sunu => Sun Ultra 64-bit makefile
makefile.vcwin32 => makefile for Microsoft Visual C++ 4.0 and later
makevms.com => VMS build script
smakefile.ppc => AMIGA smakefile for SAS C V6.58/7.00 PPC compiler
(Requires SCOPTIONS, copied from scripts/SCOPTIONS.ppc)
makefile.aix => AIX/gcc makefile
makefile.amiga => Amiga makefile
makefile.atari => Atari makefile
makefile.bc32 => Borland C makefile, for Win32
makefile.beos => BeOS makefile
makefile.c89 => Generic UNIX makefile for C89 (cc -std=c89)
makefile.clang => Generic clang makefile
makefile.darwin => Darwin makefile, for macOS (formerly Mac OS X)
makefile.dec => DEC Alpha UNIX makefile
makefile.dj2 => DJGPP 2 makefile
makefile.emcc => Emscripten makefile
makefile.freebsd => FreeBSD makefile
makefile.gcc => Generic gcc makefile
makefile.hpgcc => HPUX makefile using gcc
makefile.hpux => HPUX (10.20 and 11.00) makefile
makefile.hp64 => HPUX (10.20 and 11.00) makefile, 64-bit
makefile.ibmc => IBM C/C++ version 3.x for Win32 and OS/2 (static lib)
makefile.intel => Intel C/C++ version 4.0 and later
makefile.linux => Linux/ELF makefile
(gcc, creates shared libpng16.so.16.1.6.*)
makefile.mips => MIPS makefile
makefile.msys => MSYS (MinGW) makefile
makefile.netbsd => NetBSD/cc makefile, makes shared libpng.so
makefile.openbsd => OpenBSD makefile
makefile.riscos => Acorn RISCOS makefile
makefile.sco => SCO OSr5 ELF and Unixware 7 with Native cc
makefile.sgi => Silicon Graphics IRIX makefile (cc, static lib)
makefile.sggcc => Silicon Graphics makefile
(gcc, creates shared libpng16.so.16.1.6.*)
makefile.solaris => Solaris 2.X makefile
(gcc, creates shared libpng16.so.16.1.6.*)
makefile.so9 => Solaris 9 makefile
(gcc, creates shared libpng16.so.16.1.6.*)
makefile.std => Generic UNIX makefile (cc, static lib)
makefile.sunos => Sun makefile
makefile.32sunu => Sun Ultra 32-bit makefile
makefile.64sunu => Sun Ultra 64-bit makefile
makefile.vcwin32 => makefile for Microsoft Visual C++ 4.0 and later
makevms.com => VMS build script
smakefile.ppc => AMIGA smakefile for SAS C V6.58/7.00 PPC compiler
(Requires SCOPTIONS, copied from SCOPTIONS.ppc)
Other supporting scripts:
README.txt => This file
descrip.mms => VMS makefile for MMS or MMK
libpng-config-body.in => used by several makefiles to create libpng-config
libpng-config-head.in => used by several makefiles to create libpng-config
libpng.pc.in => Used by several makefiles to create libpng.pc
pngwin.rc => Used by the visualc71 project
pngwin.def => Used by makefile.os2
pngwin.dfn => Used to maintain pngwin.def
SCOPTIONS.ppc => Used with smakefile.ppc
Other supporting scripts
------------------------
checksym.awk => Used for maintaining pnglibconf.h
def.dfn => Used for maintaining pnglibconf.h
options.awk => Used for maintaining pnglibconf.h
pnglibconf.dfa => Used for maintaining pnglibconf.h
pnglibconf.mak => Used for maintaining pnglibconf.h
sym.dfn => Used for symbol versioning
symbols.def => Used for symbol versioning
symbols.dfn => Used for symbol versioning
vers.dfn => Used for symbol versioning
README.txt => This file
descrip.mms => VMS makefile for MMS or MMK
libpng-config-body.in => used by several makefiles to create libpng-config
libpng-config-head.in => used by several makefiles to create libpng-config
libpng.pc.in => Used by several makefiles to create libpng.pc
macro.lst => Used by GNU Autotools
pngwin.rc => Used by the visualc71 project
pngwin.def => Used by makefile.os2
pngwin.dfn => Used to maintain pngwin.def
SCOPTIONS.ppc => Used with smakefile.ppc
libtool.m4 => Used by autoconf tools
ltoptions.m4 => Used by autoconf tools
ltsugar.m4 => Used by autoconf tools
ltversion.m4 => Used by autoconf tools
lt~obsolete.m4 => Used by autoconf tools
intprefix.dfn => Used by autoconf tools
macro.lst => Used by autoconf tools
prefix.dfn => Used by autoconf tools
checksym.awk => Used for maintaining pnglibconf.h
dfn.awk => Used for maintaining pnglibconf.h
options.awk => Used for maintaining pnglibconf.h
pnglibconf.dfa => Used for maintaining pnglibconf.h
pnglibconf.mak => Used for maintaining pnglibconf.h
intprefix.c => Used for symbol versioning
prefix.c => Used for symbol versioning
sym.c => Used for symbol versioning
symbols.c => Used for symbol versioning
vers.c => Used for symbol versioning
Further information can be found in comments in the individual scripts and
makefiles.

22
extlib/libpng/scripts/TODO vendored Normal file
View File

@ -0,0 +1,22 @@
TODO list for libpng
--------------------
* 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.

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,6 @@
# Helper functions for option handling. -*- Autoconf -*-
#
# Copyright (C) 2004-2005, 2007-2009, 2011-2019, 2021-2022 Free
# Copyright (C) 2004-2005, 2007-2009, 2011-2019, 2021-2024 Free
# Software Foundation, Inc.
# Written by Gary V. Vaughan, 2004
#
@ -8,7 +8,7 @@
# unlimited permission to copy and/or distribute it, with or without
# modifications, as long as this notice is preserved.
# serial 8 ltoptions.m4
# serial 10 ltoptions.m4
# This is to help aclocal find these macros, as it can't see m4_define.
AC_DEFUN([LTOPTIONS_VERSION], [m4_if([1])])
@ -128,7 +128,7 @@ LT_OPTION_DEFINE([LT_INIT], [win32-dll],
[enable_win32_dll=yes
case $host in
*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-cegcc*)
*-*-cygwin* | *-*-mingw* | *-*-windows* | *-*-pw32* | *-*-cegcc*)
AC_CHECK_TOOL(AS, as, false)
AC_CHECK_TOOL(DLLTOOL, dlltool, false)
AC_CHECK_TOOL(OBJDUMP, objdump, false)
@ -323,29 +323,39 @@ dnl AC_DEFUN([AM_DISABLE_FAST_INSTALL], [])
# _LT_WITH_AIX_SONAME([DEFAULT])
# ----------------------------------
# implement the --with-aix-soname flag, and support the `aix-soname=aix'
# and `aix-soname=both' and `aix-soname=svr4' LT_INIT options. DEFAULT
# is either `aix', `both' or `svr4'. If omitted, it defaults to `aix'.
# implement the --enable-aix-soname configure option, and support the
# `aix-soname=aix' and `aix-soname=both' and `aix-soname=svr4' LT_INIT options.
# DEFAULT is either `aix', `both', or `svr4'. If omitted, it defaults to `aix'.
m4_define([_LT_WITH_AIX_SONAME],
[m4_define([_LT_WITH_AIX_SONAME_DEFAULT], [m4_if($1, svr4, svr4, m4_if($1, both, both, aix))])dnl
shared_archive_member_spec=
case $host,$enable_shared in
power*-*-aix[[5-9]]*,yes)
AC_MSG_CHECKING([which variant of shared library versioning to provide])
AC_ARG_WITH([aix-soname],
[AS_HELP_STRING([--with-aix-soname=aix|svr4|both],
AC_ARG_ENABLE([aix-soname],
[AS_HELP_STRING([--enable-aix-soname=aix|svr4|both],
[shared library versioning (aka "SONAME") variant to provide on AIX, @<:@default=]_LT_WITH_AIX_SONAME_DEFAULT[@:>@.])],
[case $withval in
aix|svr4|both)
;;
*)
AC_MSG_ERROR([Unknown argument to --with-aix-soname])
;;
esac
lt_cv_with_aix_soname=$with_aix_soname],
[AC_CACHE_VAL([lt_cv_with_aix_soname],
[lt_cv_with_aix_soname=]_LT_WITH_AIX_SONAME_DEFAULT)
with_aix_soname=$lt_cv_with_aix_soname])
[case $enableval in
aix|svr4|both)
;;
*)
AC_MSG_ERROR([Unknown argument to --enable-aix-soname])
;;
esac
lt_cv_with_aix_soname=$enable_aix_soname],
[_AC_ENABLE_IF([with], [aix-soname],
[case $withval in
aix|svr4|both)
;;
*)
AC_MSG_ERROR([Unknown argument to --with-aix-soname])
;;
esac
lt_cv_with_aix_soname=$with_aix_soname],
[AC_CACHE_VAL([lt_cv_with_aix_soname],
[lt_cv_with_aix_soname=]_LT_WITH_AIX_SONAME_DEFAULT)])
enable_aix_soname=$lt_cv_with_aix_soname])
with_aix_soname=$enable_aix_soname
AC_MSG_RESULT([$with_aix_soname])
if test aix != "$with_aix_soname"; then
# For the AIX way of multilib, we name the shared archive member
@ -376,30 +386,50 @@ LT_OPTION_DEFINE([LT_INIT], [aix-soname=svr4], [_LT_WITH_AIX_SONAME([svr4])])
# _LT_WITH_PIC([MODE])
# --------------------
# implement the --with-pic flag, and support the 'pic-only' and 'no-pic'
# implement the --enable-pic flag, and support the 'pic-only' and 'no-pic'
# LT_INIT options.
# MODE is either 'yes' or 'no'. If omitted, it defaults to 'both'.
m4_define([_LT_WITH_PIC],
[AC_ARG_WITH([pic],
[AS_HELP_STRING([--with-pic@<:@=PKGS@:>@],
[AC_ARG_ENABLE([pic],
[AS_HELP_STRING([--enable-pic@<:@=PKGS@:>@],
[try to use only PIC/non-PIC objects @<:@default=use both@:>@])],
[lt_p=${PACKAGE-default}
case $withval in
yes|no) pic_mode=$withval ;;
*)
pic_mode=default
# Look at the argument we got. We use all the common list separators.
lt_save_ifs=$IFS; IFS=$IFS$PATH_SEPARATOR,
for lt_pkg in $withval; do
IFS=$lt_save_ifs
if test "X$lt_pkg" = "X$lt_p"; then
pic_mode=yes
fi
done
IFS=$lt_save_ifs
;;
esac],
[pic_mode=m4_default([$1], [default])])
case $enableval in
yes|no) pic_mode=$enableval ;;
*)
pic_mode=default
# Look at the argument we got. We use all the common list separators.
lt_save_ifs=$IFS; IFS=$IFS$PATH_SEPARATOR,
for lt_pkg in $enableval; do
IFS=$lt_save_ifs
if test "X$lt_pkg" = "X$lt_p"; then
pic_mode=yes
fi
done
IFS=$lt_save_ifs
;;
esac],
[dnl Continue to support --with-pic and --without-pic, for backward
dnl compatibility.
_AC_ENABLE_IF([with], [pic],
[lt_p=${PACKAGE-default}
case $withval in
yes|no) pic_mode=$withval ;;
*)
pic_mode=default
# Look at the argument we got. We use all the common list separators.
lt_save_ifs=$IFS; IFS=$IFS$PATH_SEPARATOR,
for lt_pkg in $withval; do
IFS=$lt_save_ifs
if test "X$lt_pkg" = "X$lt_p"; then
pic_mode=yes
fi
done
IFS=$lt_save_ifs
;;
esac],
[pic_mode=m4_default([$1], [default])])]
)
_LT_DECL([], [pic_mode], [0], [What type of objects to build])dnl
])# _LT_WITH_PIC

View File

@ -1,6 +1,6 @@
# ltsugar.m4 -- libtool m4 base layer. -*-Autoconf-*-
#
# Copyright (C) 2004-2005, 2007-2008, 2011-2019, 2021-2022 Free Software
# Copyright (C) 2004-2005, 2007-2008, 2011-2019, 2021-2024 Free Software
# Foundation, Inc.
# Written by Gary V. Vaughan, 2004
#

View File

@ -1,6 +1,6 @@
# ltversion.m4 -- version numbers -*- Autoconf -*-
#
# Copyright (C) 2004, 2011-2019, 2021-2022 Free Software Foundation,
# Copyright (C) 2004, 2011-2019, 2021-2024 Free Software Foundation,
# Inc.
# Written by Scott James Remnant, 2004
#
@ -10,15 +10,15 @@
# @configure_input@
# serial 4245 ltversion.m4
# serial 4441 ltversion.m4
# This file is part of GNU Libtool
m4_define([LT_PACKAGE_VERSION], [2.4.7])
m4_define([LT_PACKAGE_REVISION], [2.4.7])
m4_define([LT_PACKAGE_VERSION], [2.5.4])
m4_define([LT_PACKAGE_REVISION], [2.5.4])
AC_DEFUN([LTVERSION_VERSION],
[macro_version='2.4.7'
macro_revision='2.4.7'
[macro_version='2.5.4'
macro_revision='2.5.4'
_LT_DECL(, macro_version, 0, [Which release of libtool.m4 was used?])
_LT_DECL(, macro_revision, 0)
])

View File

@ -1,6 +1,6 @@
# lt~obsolete.m4 -- aclocal satisfying obsolete definitions. -*-Autoconf-*-
#
# Copyright (C) 2004-2005, 2007, 2009, 2011-2019, 2021-2022 Free
# Copyright (C) 2004-2005, 2007, 2009, 2011-2019, 2021-2024 Free
# Software Foundation, Inc.
# Written by Scott James Remnant, 2004.
#

View File

@ -1,15 +1,28 @@
include(CMakeFindDependencyMacro)
find_dependency(ZLIB REQUIRED)
include("${CMAKE_CURRENT_LIST_DIR}/PNGTargets.cmake")
if(NOT TARGET PNG::PNG)
if(TARGET PNG::png_shared)
add_library(PNG::PNG INTERFACE IMPORTED)
target_link_libraries(PNG::PNG INTERFACE PNG::png_shared)
elseif(TARGET PNG::png_static)
add_library(PNG::PNG INTERFACE IMPORTED)
target_link_libraries(PNG::PNG INTERFACE PNG::png_static)
endif()
endif()
# PNGConfig.cmake
# CMake config file compatible with the FindPNG module.
# Copyright (c) 2024 Cosmin Truta
# Written by Benjamin Buch, 2024
#
# Use, modification and distribution are subject to
# the same licensing terms and conditions as libpng.
# Please see the copyright notice in png.h or visit
# http://libpng.org/pub/png/src/libpng-LICENSE.txt
#
# SPDX-License-Identifier: libpng-2.0
include(CMakeFindDependencyMacro)
find_dependency(ZLIB REQUIRED)
include("${CMAKE_CURRENT_LIST_DIR}/PNGTargets.cmake")
if(NOT TARGET PNG::PNG)
if(TARGET PNG::png_shared)
add_library(PNG::PNG INTERFACE IMPORTED)
target_link_libraries(PNG::PNG INTERFACE PNG::png_shared)
elseif(TARGET PNG::png_static)
add_library(PNG::PNG INTERFACE IMPORTED)
target_link_libraries(PNG::PNG INTERFACE PNG::png_static)
endif()
endif()

View File

@ -0,0 +1,104 @@
# PNGGenConfig.cmake
# Utility functions for configuring and building libpng
# Copyright (c) 2018-2025 Cosmin Truta
# Copyright (c) 2016-2018 Glenn Randers-Pehrson
# Written by Roger Leigh, 2016
#
# Use, modification and distribution are subject to
# the same licensing terms and conditions as libpng.
# Please see the copyright notice in png.h or visit
# http://libpng.org/pub/png/src/libpng-LICENSE.txt
#
# SPDX-License-Identifier: libpng-2.0
# Generate .chk from .out with awk, based upon the automake logic:
# generate_chk(INPUT <file> OUTPUT <file> [DEPENDS <deps>...])
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()
# Run genchk.cmake to generate the .chk file.
add_custom_command(OUTPUT "${_GC_OUTPUT}"
COMMAND "${CMAKE_COMMAND}"
"-DINPUT=${_GC_INPUT}"
"-DOUTPUT=${_GC_OUTPUT}"
-P "${CMAKE_CURRENT_BINARY_DIR}/scripts/cmake/genchk.cmake"
DEPENDS "${_GC_INPUT}" ${_GC_DEPENDS}
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}")
endfunction()
# Generate .out from C source file with awk:
# generate_out(INPUT <file> OUTPUT <file> [DEPENDS <deps>...])
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()
# Run genout.cmake to generate the .out file.
add_custom_command(OUTPUT "${_GO_OUTPUT}"
COMMAND "${CMAKE_COMMAND}"
"-DINPUT=${_GO_INPUT}"
"-DOUTPUT=${_GO_OUTPUT}"
-P "${CMAKE_CURRENT_BINARY_DIR}/scripts/cmake/genout.cmake"
DEPENDS "${_GO_INPUT}" ${_GO_DEPENDS}
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}")
endfunction()
# Generate a source file with awk:
# generate_source(OUTPUT <file> [DEPENDS <deps>...])
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()
# Run gensrc.cmake to generate the source file.
add_custom_command(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${_GSO_OUTPUT}"
COMMAND "${CMAKE_COMMAND}"
"-DOUTPUT=${_GSO_OUTPUT}"
-P "${CMAKE_CURRENT_BINARY_DIR}/scripts/cmake/gensrc.cmake"
DEPENDS ${_GSO_DEPENDS}
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}")
endfunction()
# Generate an identical file copy:
# generate_copy(INPUT <file> OUTPUT <file> [DEPENDS <deps>...])
function(generate_copy)
set(options)
set(oneValueArgs INPUT OUTPUT)
set(multiValueArgs DEPENDS)
cmake_parse_arguments(_GCO "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
if(NOT _GCO_INPUT)
message(FATAL_ERROR "generate_copy: Missing INPUT argument")
endif()
if(NOT _GCO_OUTPUT)
message(FATAL_ERROR "generate_copy: Missing OUTPUT argument")
endif()
# Make a forced file copy, overwriting any pre-existing output file.
add_custom_command(OUTPUT "${_GCO_OUTPUT}"
COMMAND "${CMAKE_COMMAND}"
-E remove "${_GCO_OUTPUT}"
COMMAND "${CMAKE_COMMAND}"
-E copy "${_GCO_INPUT}" "${_GCO_OUTPUT}"
DEPENDS "${source}" ${_GCO_DEPENDS})
endfunction()

View File

@ -0,0 +1,42 @@
# PNGTest.cmake
# Utility functions for testing libpng
# Copyright (c) 2018-2025 Cosmin Truta
# Copyright (c) 2016-2018 Glenn Randers-Pehrson
# Written by Roger Leigh, 2016
#
# Use, modification and distribution are subject to
# the same licensing terms and conditions as libpng.
# Please see the copyright notice in png.h or visit
# http://libpng.org/pub/png/src/libpng-LICENSE.txt
#
# SPDX-License-Identifier: libpng-2.0
# Add a custom target to run a test:
# png_add_test(NAME <test> COMMAND <command> [OPTIONS <options>...] [FILES <files>...])
function(png_add_test)
set(options)
set(oneValueArgs NAME COMMAND)
set(multiValueArgs OPTIONS FILES)
cmake_parse_arguments(_PAT "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
if(NOT _PAT_NAME)
message(FATAL_ERROR "png_add_test: Missing NAME argument")
endif()
if(NOT _PAT_COMMAND)
message(FATAL_ERROR "png_add_test: Missing COMMAND argument")
endif()
# Initialize the global variables used by the "${_PAT_NAME}.cmake" script.
set(TEST_OPTIONS "${_PAT_OPTIONS}")
set(TEST_FILES "${_PAT_FILES}")
# Generate and run the "${_PAT_NAME}.cmake" script.
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/scripts/cmake/test.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/tests/${_PAT_NAME}.cmake"
@ONLY)
add_test(NAME "${_PAT_NAME}"
COMMAND "${CMAKE_COMMAND}"
"-DLIBPNG=$<TARGET_FILE:png_shared>"
"-DTEST_COMMAND=$<TARGET_FILE:${_PAT_COMMAND}>"
-P "${CMAKE_CURRENT_BINARY_DIR}/tests/${_PAT_NAME}.cmake")
endfunction()

View File

@ -26,7 +26,8 @@ if(WIN32)
set(ENV{PATH} "${LIBPNG_DIR};$ENV{PATH}")
endif()
message("Running ${TEST_COMMAND}" ${TEST_OPTIONS} ${NATIVE_TEST_FILES})
string(JOIN " " TEST_COMMAND_STRING "${TEST_COMMAND}" ${TEST_OPTIONS} ${NATIVE_TEST_FILES})
message(STATUS "Running ${TEST_COMMAND_STRING}")
execute_process(COMMAND "${TEST_COMMAND}" ${TEST_OPTIONS} ${NATIVE_TEST_FILES}
RESULT_VARIABLE TEST_STATUS)
if(TEST_STATUS)

View File

@ -1,4 +1,3 @@
cc_defs = /inc=$(ZLIBSRC)
c_deb =

View File

@ -1,4 +1,3 @@
/* intprefix.c - generate an unprefixed internal symbol list
*
* Copyright (c) 2013-2014 Glenn Randers-Pehrson

View File

@ -1,4 +1,3 @@
usage()
{
cat <<EOF

View File

@ -11,7 +11,7 @@
# Modeled after libxml-config.
version=1.6.44
version=1.6.46
prefix=""
libdir=""
libs=""

View File

@ -5,6 +5,6 @@ includedir=@includedir@/libpng16
Name: libpng
Description: Loads and saves PNG files
Version: 1.6.44
Version: 1.6.46
Libs: -L${libdir} -lpng16
Cflags: -I${includedir}

View File

@ -1,6 +1,6 @@
# makefile for libpng on Solaris 2.x with cc
# Contributed by William L. Sebok, based on makefile.linux
# Copyright (C) 2020-2024 Cosmin Truta
# Copyright (C) 2018-2025 Cosmin Truta
# Copyright (C) 2002, 2006, 2010-2014 Glenn Randers-Pehrson
# Copyright (C) 1998 Greg Roelofs
# Copyright (C) 1996, 1997 Andreas Dilger
@ -36,13 +36,10 @@ SUN_LD_FLAGS=-fast -xtarget=ultra
ZLIBLIB=/usr/lib
ZLIBINC=/usr/include
WARNMORE=-Wwrite-strings -Wpointer-arith -Wshadow \
-Wmissing-declarations -Wtraditional -Wcast-align \
-Wstrict-prototypes -Wmissing-prototypes # -Wconversion
CPPFLAGS=-I$(ZLIBINC) # -DPNG_DEBUG=5
CFLAGS=$(SUN_CC_FLAGS) # $(WARNMORE) -g
CFLAGS=$(SUN_CC_FLAGS) # -g
ARFLAGS=rc
LDFLAGS=$(SUN_LD_FLAGS) -L$(ZLIBLIB) -R$(ZLIBLIB) libpng.a -lz -lm
LDFLAGS=$(SUN_LD_FLAGS) -L$(ZLIBLIB) -R$(ZLIBLIB) libpng.a -lz -lm # -g
OBJS = png.o pngerror.o pngget.o pngmem.o pngpread.o \
pngread.o pngrio.o pngrtran.o pngrutil.o pngset.o \
@ -53,7 +50,7 @@ OBJSDLL = $(OBJS:.o=.pic.o)
.SUFFIXES: .c .o .pic.o
.c.o:
$(CC) -c $(CPPFLAGS) $(CFLAGS) -o $@ $<
$(CC) -c $(CPPFLAGS) $(CFLAGS) -o $@ $*.c
.c.pic.o:
$(CC) -c $(CPPFLAGS) $(CFLAGS) -KPIC -o $@ $*.c

View File

@ -1,6 +1,6 @@
# makefile for libpng on Solaris 2.x with cc
# Contributed by William L. Sebok, based on makefile.linux
# Copyright (C) 2020-2024 Cosmin Truta
# Copyright (C) 2018-2025 Cosmin Truta
# Copyright (C) 2002, 2006, 2010-2014 Glenn Randers-Pehrson
# Copyright (C) 1998 Greg Roelofs
# Copyright (C) 1996, 1997 Andreas Dilger
@ -36,13 +36,10 @@ SUN_LD_FLAGS=-fast -xtarget=ultra -xarch=v9
ZLIBLIB=/usr/lib
ZLIBINC=/usr/include
WARNMORE=-Wwrite-strings -Wpointer-arith -Wshadow \
-Wmissing-declarations -Wtraditional -Wcast-align \
-Wstrict-prototypes -Wmissing-prototypes # -Wconversion
CPPFLAGS=-I$(ZLIBINC) # -DPNG_DEBUG=5
CFLAGS=$(SUN_CC_FLAGS) # $(WARNMORE) -g
CFLAGS=$(SUN_CC_FLAGS) # -g
ARFLAGS=rc
LDFLAGS=-L. -R. $(SUN_LD_FLAGS) -L$(ZLIBLIB) -R$(ZLIBLIB) -lpng16 -lz -lm
LDFLAGS=-L. -R. $(SUN_LD_FLAGS) -L$(ZLIBLIB) -R$(ZLIBLIB) -lpng16 -lz -lm # -g
OBJS = png.o pngerror.o pngget.o pngmem.o pngpread.o \
pngread.o pngrio.o pngrtran.o pngrutil.o pngset.o \
@ -53,7 +50,7 @@ OBJSDLL = $(OBJS:.o=.pic.o)
.SUFFIXES: .c .o .pic.o
.c.o:
$(CC) -c $(CPPFLAGS) $(CFLAGS) -o $@ $<
$(CC) -c $(CPPFLAGS) $(CFLAGS) -o $@ $*.c
.c.pic.o:
$(CC) -c $(CPPFLAGS) $(CFLAGS) -KPIC -o $@ $*.c

View File

@ -1,5 +1,5 @@
# makefile for libpng using gcc (generic, static library)
# Copyright (C) 2000, 2020-2024 Cosmin Truta
# Copyright (C) 2000, 2020-2025 Cosmin Truta
# Copyright (C) 2002, 2006-2009, 2014 Glenn Randers-Pehrson
# Copyright (C) 2000 Marc O. Gloor (AIX support added, from makefile.gcc)
# Copyright (C) 1995 Guy Eric Schalnat, Group 42, Inc.
@ -22,9 +22,8 @@ RM_F = rm -f
LIBNAME = libpng16
PNGMAJ = 16
WARNMORE =
CPPFLAGS = -I$(ZLIBINC) # -DPNG_DEBUG=5
CFLAGS = -O2 -Wall -Wextra -Wundef # $(WARNMORE) -g
CFLAGS = -O2 # -g
ARFLAGS = rc
LDFLAGS = -L. -L$(ZLIBLIB) -lpng16 -lz -lm # -g
@ -35,7 +34,7 @@ OBJS = png.o pngerror.o pngget.o pngmem.o pngpread.o \
# Targets
.c.o:
$(CC) -c $(CPPFLAGS) $(CFLAGS) -o $@ $<
$(CC) -c $(CPPFLAGS) $(CFLAGS) -o $@ $*.c
all: $(LIBNAME).a pngtest

View File

@ -1,5 +1,5 @@
# makefile for libpng
# Copyright (C) 2022 Cosmin Truta
# Copyright (C) 2022-2025 Cosmin Truta
# Copyright (C) 2002, 2014 Glenn Randers-Pehrson
# Copyright (C) 1995 Guy Eric Schalnat, Group 42, Inc.
#
@ -28,7 +28,7 @@ OBJS = $(LBR)(png.o) $(LBR)(pngerror.o) $(LBR)(pngget.o) $(LBR)(pngmem.o) \
all: $(LBR) pngtest.ttp
.c.o:
$(CC) -c $(CPPFLAGS) $(CFLAGS) $<
$(CC) -c $(CPPFLAGS) $(CFLAGS) $*.c
$(LBR): $(OBJS)

View File

@ -1,6 +1,6 @@
# makefile for libpng on BeOS x86 ELF with gcc
# modified from makefile.linux by Sander Stoks
# Copyright (C) 2020-2024 Cosmin Truta
# Copyright (C) 2020-2025 Cosmin Truta
# Copyright (C) 2002, 2006, 2008, 2010-2014 Glenn Randers-Pehrson
# Copyright (C) 1999 Greg Roelofs
# Copyright (C) 1996, 1997 Andreas Dilger
@ -33,14 +33,10 @@ ALIGN=
# For i386:
# ALIGN=-malign-loops=2 -malign-functions=2
WARNMORE=-Wwrite-strings -Wpointer-arith -Wshadow \
-Wmissing-declarations -Wtraditional -Wcast-align \
-Wstrict-prototypes -Wmissing-prototypes # -Wconversion
# On BeOS, -O1 is actually better than -O3. This is a known bug but it's
# still here in R4.5
CPPFLAGS=-I$(ZLIBINC) # -DPNG_DEBUG=5
CFLAGS=-O1 -funroll-loops $(ALIGN) -Wall -Wextra -Wundef # $(WARNMORE) -g
CFLAGS=-O1 -funroll-loops $(ALIGN) # -g
ARFLAGS=rc
# LDFLAGS=-L. -Wl,-rpath,. -L$(ZLIBLIB) -Wl,-rpath,$(ZLIBLIB) -lpng -lz
LDFLAGS=-L. -Wl,-soname=$(LIBSOMAJ) -L$(ZLIBLIB) -lz # -g
@ -58,7 +54,7 @@ OBJSDLL = $(OBJS)
.SUFFIXES: .c .o
.c.o:
$(CC) -c $(CPPFLAGS) $(CFLAGS) -o $@ $<
$(CC) -c $(CPPFLAGS) $(CFLAGS) -o $@ $*.c
all: libpng.a $(LIBSO) pngtest

97
extlib/libpng/scripts/makefile.c89 vendored Normal file
View File

@ -0,0 +1,97 @@
# makefile for libpng using an ANSI C89 compiler
# Copyright (C) 2000, 2014, 2019-2025 Cosmin Truta
# Copyright (C) 2008, 2014 Glenn Randers-Pehrson
# Copyright (C) 1995 Guy Eric Schalnat, Group 42, Inc.
#
# This code is released under the libpng license.
# For conditions of distribution and use, see the disclaimer
# and license in png.h
# Location of the zlib library and include files
ZLIBINC = ../zlib
ZLIBLIB = ../zlib
# Compiler, linker, lib and other tools
#CC = c89
CC = cc
LD = $(CC)
AR = ar
RANLIB = ranlib
CP = cp
RM_F = rm -f
# Compiler and linker flags
NOHWOPT = -DPNG_ARM_NEON_OPT=0 -DPNG_MIPS_MSA_OPT=0 \
-DPNG_POWERPC_VSX_OPT=0 -DPNG_INTEL_SSE_OPT=0
STDC = -pedantic-errors -std=c89
WARN = -Wall -Wextra -Wundef
WARNMORE = -Wcast-align -Wconversion -Wshadow -Wpointer-arith -Wwrite-strings \
-Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes
LOCAL_CPPFLAGS = $(NOHWOPT)
CPPFLAGS = -I$(ZLIBINC) # -DPNG_DEBUG=5
ALL_CPPFLAGS = $(LOCAL_CPPFLAGS) $(CPPFLAGS)
LOCAL_CFLAGS = $(STDC) $(WARN) # $(WARNMORE)
CFLAGS = -O2 # -g
ALL_CFLAGS = $(LOCAL_CFLAGS) $(CFLAGS)
ARFLAGS = rc
LDFLAGS = -L$(ZLIBLIB) # -g
LIBS = -lz -lm
# File extensions
EXEEXT =
# Pre-built configuration
# See scripts/pnglibconf.mak for more options
PNGLIBCONF_H_PREBUILT = scripts/pnglibconf.h.prebuilt
# File lists
OBJS = png.o pngerror.o pngget.o pngmem.o pngpread.o \
pngread.o pngrio.o pngrtran.o pngrutil.o pngset.o \
pngtrans.o pngwio.o pngwrite.o pngwtran.o pngwutil.o
# Targets
all: static
pnglibconf.h: $(PNGLIBCONF_H_PREBUILT)
$(CP) $(PNGLIBCONF_H_PREBUILT) $@
.c.o:
$(CC) -c $(ALL_CPPFLAGS) $(ALL_CFLAGS) -o $@ $*.c
static: libpng.a pngtest$(EXEEXT)
shared:
@echo This is a generic makefile that cannot create shared libraries.
@echo Please use a configuration that is specific to your platform.
@false
libpng.a: $(OBJS)
$(AR) $(ARFLAGS) $@ $(OBJS)
$(RANLIB) $@
test: pngtest$(EXEEXT)
./pngtest$(EXEEXT)
pngtest$(EXEEXT): pngtest.o libpng.a
$(LD) $(LDFLAGS) -o $@ pngtest.o libpng.a $(LIBS)
clean:
$(RM_F) *.o libpng.a pngtest$(EXEEXT) pngout.png pnglibconf.h
png.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
pngerror.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
pngget.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
pngmem.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
pngpread.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
pngread.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
pngrio.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
pngrtran.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
pngrutil.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
pngset.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
pngtrans.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
pngwio.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
pngwrite.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
pngwtran.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
pngwutil.o: png.h pngconf.h pnglibconf.h pngpriv.h pngstruct.h pnginfo.h pngdebug.h
pngtest.o: png.h pngconf.h pnglibconf.h

View File

@ -1,5 +1,5 @@
# makefile for libpng using clang (generic, static library)
# Copyright (C) 2000, 2014, 2019-2024 Cosmin Truta
# Copyright (C) 2000, 2014, 2019-2025 Cosmin Truta
# Copyright (C) 2008, 2014 Glenn Randers-Pehrson
# Copyright (C) 1995 Guy Eric Schalnat, Group 42, Inc.
#
@ -21,13 +21,17 @@ RM_F = rm -f
# Compiler and linker flags
NOHWOPT = -DPNG_ARM_NEON_OPT=0 -DPNG_MIPS_MSA_OPT=0 \
-DPNG_POWERPC_VSX_OPT=0 -DPNG_INTEL_SSE_OPT=0
WARNMORE = -Wwrite-strings -Wpointer-arith -Wshadow \
-Wmissing-declarations -Wtraditional -Wcast-align \
-Wstrict-prototypes -Wmissing-prototypes # -Wconversion
DEFS = $(NOHWOPT)
CPPFLAGS = -I$(ZLIBINC) $(DEFS) # -DPNG_DEBUG=5
CFLAGS = -O2 -Wall -Wextra -Wundef # $(WARNMORE) -g
-DPNG_POWERPC_VSX_OPT=0 -DPNG_INTEL_SSE_OPT=0
STDC = -pedantic-errors # -std=c99
WARN = -Wall -Wextra -Wundef
WARNMORE = -Wcast-align -Wconversion -Wshadow -Wpointer-arith -Wwrite-strings \
-Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes
LOCAL_CPPFLAGS = $(NOHWOPT)
CPPFLAGS = -I$(ZLIBINC) # -DPNG_DEBUG=5
ALL_CPPFLAGS = $(LOCAL_CPPFLAGS) $(CPPFLAGS)
LOCAL_CFLAGS = $(STDC) $(WARN) # $(WARNMORE)
CFLAGS = -O2 # -g
ALL_CFLAGS = $(LOCAL_CFLAGS) $(CFLAGS)
ARFLAGS = rc
LDFLAGS = -L$(ZLIBLIB) # -g
LIBS = -lz -lm
@ -51,7 +55,7 @@ pnglibconf.h: $(PNGLIBCONF_H_PREBUILT)
$(CP) $(PNGLIBCONF_H_PREBUILT) $@
.c.o:
$(CC) -c $(CPPFLAGS) $(CFLAGS) -o $@ $<
$(CC) -c $(ALL_CPPFLAGS) $(ALL_CFLAGS) -o $@ $*.c
static: libpng.a pngtest$(EXEEXT)

View File

@ -1,5 +1,5 @@
# makefile for libpng on Darwin / macOS
# Copyright (C) 2020-2024 Cosmin Truta
# Copyright (C) 2014, 2018-2025 Cosmin Truta
# Copyright (C) 2002, 2004, 2006, 2008, 2010-2014 Glenn Randers-Pehrson
# Copyright (C) 2001 Christoph Pfisterer
# derived from makefile.linux:
@ -10,10 +10,6 @@
# For conditions of distribution and use, see the disclaimer
# and license in png.h
# Where the zlib library and include files are located
ZLIBLIB=/usr/lib
ZLIBINC=/usr/include
# Library name:
LIBNAME=libpng16
PNGMAJ=16
@ -30,13 +26,22 @@ LN_SF=ln -sf
CP=cp
RM_F=rm -f
NOHWOPT=-DPNG_ARM_NEON_OPT=0 -DPNG_MIPS_MSA_OPT=0 \
-DPNG_POWERPC_VSX_OPT=0 -DPNG_INTEL_SSE_OPT=0
DEFS=$(NOHWOPT)
CPPFLAGS=-I$(ZLIBINC) $(DEFS)
CFLAGS=-O3 -funroll-loops -Wall -Wextra -Wundef
ARFLAGS=rc
LDFLAGS=-L. -L$(ZLIBLIB) -lpng16 -lz
# Compiler and linker flags
NOHWOPT = -DPNG_ARM_NEON_OPT=0 -DPNG_MIPS_MSA_OPT=0 \
-DPNG_POWERPC_VSX_OPT=0 -DPNG_INTEL_SSE_OPT=0
STDC = -pedantic-errors
WARN = -Wall -Wextra -Wundef
WARNMORE = -Wcast-align -Wconversion -Wshadow -Wpointer-arith -Wwrite-strings \
-Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes
LOCAL_CPPFLAGS = $(NOHWOPT)
CPPFLAGS = # -DPNG_DEBUG=5
ALL_CPPFLAGS = $(LOCAL_CPPFLAGS) $(CPPFLAGS)
LOCAL_CFLAGS = $(STDC) $(WARN) # $(WARNMORE)
CFLAGS = -O3 -funroll-loops # -g
ALL_CFLAGS = $(LOCAL_CFLAGS) $(CFLAGS)
ARFLAGS = rc
LDFLAGS = -L. -lpng16 -lz # -g
LDFLAGS_A = libpng.a -lz -lm # -g
# Pre-built configuration
# See scripts/pnglibconf.mak for more options
@ -52,12 +57,12 @@ OBJSDLL = $(OBJS:.o=.pic.o)
.SUFFIXES: .c .o .pic.o
.c.o:
$(CC) -c $(CPPFLAGS) $(CFLAGS) -o $@ $<
$(CC) -c $(ALL_CPPFLAGS) $(ALL_CFLAGS) -o $@ $*.c
.c.pic.o:
$(CC) -c $(CPPFLAGS) $(CFLAGS) -fno-common -o $@ $*.c
$(CC) -c $(ALL_CPPFLAGS) $(ALL_CFLAGS) -fno-common -o $@ $*.c
all: libpng.a $(LIBSO) pngtest
all: libpng.a $(LIBSO) pngtest pngtest-static
pnglibconf.h: $(PNGLIBCONF_H_PREBUILT)
$(CP) $(PNGLIBCONF_H_PREBUILT) $@
@ -71,15 +76,25 @@ $(LIBSO): $(LIBSOMAJ)
$(LIBSOMAJ): $(OBJSDLL)
$(CC) -dynamiclib \
-current_version 16 -compatibility_version 16 \
-o $(LIBSOMAJ) \
$(OBJSDLL) -L$(ZLIBLIB) -lz
-current_version 16 -compatibility_version 16 \
-o $(LIBSOMAJ) \
$(OBJSDLL) -lz
pngtest: pngtest.o $(LIBSO)
$(CC) -o pngtest $(CFLAGS) pngtest.o $(LDFLAGS)
test: pngtest
pngtest-static: pngtest.o libpng.a
$(CC) -o pngtest-static $(CFLAGS) pngtest.o $(LDFLAGS_A)
test: pngtest pngtest-static
@echo ""
@echo " Running pngtest dynamically linked with $(LIBSO):"
@echo ""
./pngtest
@echo ""
@echo " Running pngtest statically linked with libpng.a:"
@echo ""
./pngtest-static
install:
@echo "The $@ target is no longer supported by this makefile."
@ -94,8 +109,9 @@ install-shared:
@false
clean:
$(RM_F) *.o libpng.a pngtest pngout.png
$(RM_F) $(OBJS) $(OBJSDLL) libpng.a
$(RM_F) $(LIBNAME).*dylib pnglibconf.h
$(RM_F) pngtest*.o pngtest pngtest-static pngout.png
# DO NOT DELETE THIS LINE -- make depend depends on it.

View File

@ -1,5 +1,5 @@
# makefile for libpng on DEC Alpha Unix
# Copyright (C) 2020-2024 Cosmin Truta
# Copyright (C) 2020-2025 Cosmin Truta
# Copyright (C) 2000-2002, 2006, 2010-2014 Glenn Randers-Pehrson
# Copyright (C) 1995 Guy Eric Schalnat, Group 42, Inc.
#
@ -30,7 +30,7 @@ ZLIBLIB=../zlib
ZLIBINC=../zlib
CPPFLAGS=-I$(ZLIBINC) # -DPNG_DEBUG=5
CFLAGS=-std -w1 -O # -g
CFLAGS=-std -w1 -O
ARFLAGS=rc
LDFLAGS=-L$(ZLIBLIB) -rpath $(ZLIBLIB) libpng.a -lz -lm
@ -43,7 +43,7 @@ OBJS = png.o pngerror.o pngget.o pngmem.o pngpread.o \
pngtrans.o pngwio.o pngwrite.o pngwtran.o pngwutil.o
.c.o:
$(CC) -c $(CPPFLAGS) $(CFLAGS) -o $@ $<
$(CC) -c $(CPPFLAGS) $(CFLAGS) -o $@ $*.c
all: $(LIBSO) libpng.a pngtest

View File

@ -1,5 +1,5 @@
# DJGPP (DOS gcc) makefile for libpng
# Copyright (C) 2020-2024 Cosmin Truta
# Copyright (C) 2020-2025 Cosmin Truta
# Copyright (C) 2002, 2006, 2009-2014 Glenn Randers-Pehrson
# Copyright (C) 1995 Guy Eric Schalnat, Group 42, Inc.
#
@ -11,7 +11,7 @@ CC=gcc
AR=ar
RANLIB=ranlib
CPPFLAGS=-I../zlib -DPNG_NO_SNPRINTF
CFLAGS=-O
CFLAGS=-O2 -Wall -Wextra -Wundef
ARFLAGS=rc
LDFLAGS=-L. -L../zlib/ -lpng -lz -lm
@ -27,7 +27,7 @@ OBJS = png.o pngerror.o pngget.o pngmem.o pngpread.o \
pngtrans.o pngwio.o pngwrite.o pngwtran.o pngwutil.o
.c.o:
$(CC) -c $(CPPFLAGS) $(CFLAGS) -o $@ $<
$(CC) -c $(CPPFLAGS) $(CFLAGS) -o $@ $*.c
all: libpng.a pngtest

View File

@ -1,5 +1,5 @@
# makefile for libpng using emscripten
# Copyright (C) 2000, 2014, 2019-2024 Cosmin Truta
# Copyright (C) 2000, 2014, 2019-2025 Cosmin Truta
# Copyright (C) 2021 Kirk Roerig
# Copyright (C) 2008, 2014 Glenn Randers-Pehrson
# Copyright (C) 1995 Guy Eric Schalnat, Group 42, Inc.
@ -20,8 +20,16 @@ RANLIB = emranlib
CP = cp
RM_F = rm -f
STDC = -pedantic-errors # -std=c99
WARN = -Wall -Wextra -Wundef
WARNMORE = -Wcast-align -Wconversion -Wshadow -Wpointer-arith -Wwrite-strings \
-Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes
LOCAL_CPPFLAGS =
CPPFLAGS = -I$(ZLIBINC) # -DPNG_DEBUG=5
CFLAGS = -O2 -Wall -Wextra -Wundef
ALL_CPPFLAGS = $(LOCAL_CPPFLAGS) $(CPPFLAGS)
LOCAL_CFLAGS = $(STDC) $(WARN) # $(WARNMORE)
CFLAGS = -O2
ALL_CFLAGS = $(LOCAL_CFLAGS) $(CFLAGS)
ARFLAGS = rc
LDFLAGS = -L$(ZLIBLIB)
PNGTEST_LDFLAGS = --preload-file=pngtest.png
@ -43,7 +51,7 @@ pnglibconf.h: $(PNGLIBCONF_H_PREBUILT)
$(CP) $(PNGLIBCONF_H_PREBUILT) $@
.c.o:
$(CC) -c $(CPPFLAGS) $(CFLAGS) -o $@ $<
$(CC) -c $(ALL_CPPFLAGS) $(ALL_CFLAGS) -o $@ $*.c
static: libpng.a pngtest

View File

@ -1,5 +1,5 @@
# makefile for libpng under FreeBSD
# Copyright (C) 2020-2022 Cosmin Truta
# Copyright (C) 2018-2025 Cosmin Truta
# Copyright (C) 2014 Glenn Randers-Pehrson and Andrey A. Chernov
# Copyright (C) 2002, 2007, 2009 Glenn Randers-Pehrson and Andrey A. Chernov
#
@ -35,7 +35,7 @@ SRCS= png.c pngerror.c pngget.c pngmem.c pngpread.c \
pngtrans.c pngwio.c pngwrite.c pngwtran.c pngwutil.c
.c.o:
${CC} -c ${CPPFLAGS} ${CFLAGS} -o $@ $<
${CC} -c ${CPPFLAGS} ${CFLAGS} -o $@ $*.c
pnglibconf.h: ${PNGLIBCONF_H_PREBUILT}
cp ${PNGLIBCONF_H_PREBUILT} $@

View File

@ -1,5 +1,5 @@
# makefile for libpng using gcc (generic, static library)
# Copyright (C) 2000, 2014, 2019-2024 Cosmin Truta
# Copyright (C) 2000, 2014, 2019-2025 Cosmin Truta
# Copyright (C) 2008, 2014 Glenn Randers-Pehrson
# Copyright (C) 1995 Guy Eric Schalnat, Group 42, Inc.
#
@ -21,13 +21,17 @@ RM_F = rm -f
# Compiler and linker flags
NOHWOPT = -DPNG_ARM_NEON_OPT=0 -DPNG_MIPS_MSA_OPT=0 \
-DPNG_POWERPC_VSX_OPT=0 -DPNG_INTEL_SSE_OPT=0
WARNMORE = -Wwrite-strings -Wpointer-arith -Wshadow \
-Wmissing-declarations -Wtraditional -Wcast-align \
-Wstrict-prototypes -Wmissing-prototypes # -Wconversion
DEFS = $(NOHWOPT)
CPPFLAGS = -I$(ZLIBINC) $(DEFS) # -DPNG_DEBUG=5
CFLAGS = -O2 -Wall -Wextra -Wundef # $(WARNMORE) -g
-DPNG_POWERPC_VSX_OPT=0 -DPNG_INTEL_SSE_OPT=0
STDC = -pedantic-errors # -std=c99
WARN = -Wall -Wextra -Wundef
WARNMORE = -Wcast-align -Wconversion -Wshadow -Wpointer-arith -Wwrite-strings \
-Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes
LOCAL_CPPFLAGS = $(NOHWOPT)
CPPFLAGS = -I$(ZLIBINC) # -DPNG_DEBUG=5
ALL_CPPFLAGS = $(LOCAL_CPPFLAGS) $(CPPFLAGS)
LOCAL_CFLAGS = $(STDC) $(WARN) # $(WARNMORE)
CFLAGS = -O2 # -g
ALL_CFLAGS = $(LOCAL_CFLAGS) $(CFLAGS)
ARFLAGS = rc
LDFLAGS = -L$(ZLIBLIB) # -g
LIBS = -lz -lm
@ -51,7 +55,7 @@ pnglibconf.h: $(PNGLIBCONF_H_PREBUILT)
$(CP) $(PNGLIBCONF_H_PREBUILT) $@
.c.o:
$(CC) -c $(CPPFLAGS) $(CFLAGS) -o $@ $<
$(CC) -c $(ALL_CPPFLAGS) $(ALL_CFLAGS) -o $@ $*.c
static: libpng.a pngtest$(EXEEXT)

View File

@ -1,5 +1,5 @@
# makefile for libpng, HPUX (10.20 and 11.00) using the ANSI/C product.
# Copyright (C) 2020-2024 Cosmin Truta
# Copyright (C) 2018-2025 Cosmin Truta
# Copyright (C) 1999-2002, 2006, 2009, 2010-2014 Glenn Randers-Pehrson
# Copyright (C) 1995 Guy Eric Schalnat, Group 42
# Contributed by Jim Rice and updated by Chris Schleicher, Hewlett Packard
@ -56,7 +56,7 @@ OBJSDLL = $(OBJS:.o=.pic.o)
.SUFFIXES: .c .o .pic.o
.c.o:
$(CC) -c $(CPPFLAGS) $(CFLAGS) -o $@ $<
$(CC) -c $(CPPFLAGS) $(CFLAGS) -o $@ $*.c
.c.pic.o:
$(CC) -c $(CPPFLAGS) $(CFLAGS) +z -o $@ $*.c

View File

@ -1,5 +1,5 @@
# makefile for libpng on HP-UX using GCC with the HP ANSI/C linker.
# Copyright (C) 2020-2024 Cosmin Truta
# Copyright (C) 2018-2025 Cosmin Truta
# Copyright (C) 2002, 2006-2008, 2010-2014 Glenn Randers-Pehrson
# Copyright (C) 2001, Laurent faillie
# Copyright (C) 1998, 1999 Greg Roelofs
@ -37,12 +37,8 @@ ZLIBINC=/opt/zlib/include
# LDSHARED=ld -b
# SHAREDLIB=libz.sl
WARNMORE=-Wwrite-strings -Wpointer-arith -Wshadow \
-Wmissing-declarations -Wtraditional -Wcast-align \
-Wstrict-prototypes -Wmissing-prototypes # -Wconversion
CPPFLAGS=-I$(ZLIBINC) # -DPNG_DEBUG=5
CFLAGS=-O3 -funroll-loops -Wall -Wextra -Wundef # $(WARNMORE) -g
CFLAGS=-O3 -funroll-loops # -g
ARFLAGS=rc
#LDFLAGS=-L. -Wl,-rpath,. -L$(ZLIBLIB) -Wl,-rpath,$(ZLIBLIB) -lpng16 -lz -lm # -g
LDFLAGS=-L. -L$(ZLIBLIB) -lpng16 -lz -lm # -g
@ -56,7 +52,7 @@ OBJSDLL = $(OBJS:.o=.pic.o)
.SUFFIXES: .c .o .pic.o
.c.o:
$(CC) -c $(CPPFLAGS) $(CFLAGS) -o $@ $<
$(CC) -c $(CPPFLAGS) $(CFLAGS) -o $@ $*.c
.c.pic.o:
$(CC) -c $(CPPFLAGS) $(CFLAGS) -fPIC -o $@ $*.c

View File

@ -1,5 +1,5 @@
# makefile for libpng, HPUX (10.20 and 11.00) using the ANSI/C product.
# Copyright (C) 2020-2024 Cosmin Truta
# Copyright (C) 2018-2025 Cosmin Truta
# Copyright (C) 1999-2002, 2006, 2010-2014 Glenn Randers-Pehrson
# Copyright (C) 1995 Guy Eric Schalnat, Group 42
# Contributed by Jim Rice and updated by Chris Schleicher, Hewlett Packard
@ -55,7 +55,7 @@ OBJSDLL = $(OBJS:.o=.pic.o)
.SUFFIXES: .c .o .pic.o
.c.o:
$(CC) -c $(CPPFLAGS) $(CFLAGS) -o $@ $<
$(CC) -c $(CPPFLAGS) $(CFLAGS) -o $@ $*.c
.c.pic.o:
$(CC) -c $(CPPFLAGS) $(CFLAGS) +z -o $@ $*.c

View File

@ -1,7 +1,7 @@
# Makefile for libpng (static)
# IBM C version 3.x for Win32 and OS/2
# Copyright (C) 2006, 2014 Glenn Randers-Pehrson
# Copyright (C) 2000, 2020 Cosmin Truta
# Copyright (C) 2000, 2020-2025 Cosmin Truta
#
# This code is released under the libpng license.
# For conditions of distribution and use, see the disclaimer
@ -46,7 +46,7 @@ LIBS = libpng$(A) $(ZLIBLIB)/zlib$(A)
# Targets
.c$(O):
$(CC) -c $(CPPFLAGS) $(CFLAGS) $<
$(CC) -c $(CPPFLAGS) $(CFLAGS) $*.c
all: libpng$(A) pngtest$(E)

View File

@ -1,5 +1,5 @@
# makefile for libpng.a and libpng16.so on Linux ELF with gcc
# Copyright (C) 2020-2024 Cosmin Truta
# Copyright (C) 2018-2025 Cosmin Truta
# Copyright (C) 1998, 1999, 2002, 2006, 2008, 2010-2014 Greg Roelofs and
# Glenn Randers-Pehrson
# Copyright (C) 1996, 1997 Andreas Dilger
@ -24,24 +24,22 @@ LN_SF=ln -sf
CP=cp
RM_F=rm -f
# Where the zlib library and include files are located.
#ZLIBLIB=/usr/local/lib
#ZLIBINC=/usr/local/include
ZLIBLIB=../zlib
ZLIBINC=../zlib
# Compiler and linker flags
NOHWOPT=-DPNG_ARM_NEON_OPT=0 -DPNG_MIPS_MSA_OPT=0 \
-DPNG_POWERPC_VSX_OPT=0 -DPNG_INTEL_SSE_OPT=0
WARNMORE=-Wwrite-strings -Wpointer-arith -Wshadow \
-Wmissing-declarations -Wtraditional -Wcast-align \
-Wstrict-prototypes -Wmissing-prototypes # -Wconversion
DEFS=$(NOHWOPT)
CPPFLAGS=-I$(ZLIBINC) $(DEFS) # -DPNG_DEBUG=5
CFLAGS=-O3 -funroll-loops -Wall -Wextra -Wundef # $(WARNMORE) -g
ARFLAGS=rc
LDFLAGS=-L. -Wl,-rpath,. -L$(ZLIBLIB) -Wl,-rpath,$(ZLIBLIB) -lpng16 -lz -lm # -g
LDFLAGS_A=-L$(ZLIBLIB) -Wl,-rpath,$(ZLIBLIB) libpng.a -lz -lm # -g
NOHWOPT = -DPNG_ARM_NEON_OPT=0 -DPNG_MIPS_MSA_OPT=0 \
-DPNG_POWERPC_VSX_OPT=0 -DPNG_INTEL_SSE_OPT=0
STDC = -pedantic-errors
WARN = -Wall -Wextra -Wundef
WARNMORE = -Wcast-align -Wconversion -Wshadow -Wpointer-arith -Wwrite-strings \
-Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes
LOCAL_CPPFLAGS = $(NOHWOPT)
CPPFLAGS = # -DPNG_DEBUG=5
ALL_CPPFLAGS = $(LOCAL_CPPFLAGS) $(CPPFLAGS)
LOCAL_CFLAGS = $(STDC) $(WARN) # $(WARNMORE)
CFLAGS = -O3 -funroll-loops # -g
ALL_CFLAGS = $(LOCAL_CFLAGS) $(CFLAGS)
ARFLAGS = rc
LDFLAGS = -L. -Wl,-rpath,. -lpng16 -lz -lm # -g
LDFLAGS_A = libpng.a -lz -lm # -g
# Pre-built configuration
# See scripts/pnglibconf.mak for more options
@ -57,10 +55,10 @@ OBJSDLL = $(OBJS:.o=.pic.o)
.SUFFIXES: .c .o .pic.o
.c.o:
$(CC) -c $(CPPFLAGS) $(CFLAGS) -o $@ $<
$(CC) -c $(ALL_CPPFLAGS) $(ALL_CFLAGS) -o $@ $*.c
.c.pic.o:
$(CC) -c $(CPPFLAGS) $(CFLAGS) -fPIC -o $@ $*.c
$(CC) -c $(ALL_CPPFLAGS) $(ALL_CFLAGS) -fPIC -o $@ $*.c
all: libpng.a $(LIBSO) pngtest pngtest-static

View File

@ -1,5 +1,5 @@
# makefile for libpng
# Copyright (C) 2020-2024 Cosmin Truta
# Copyright (C) 2018-2025 Cosmin Truta
# Copyright (C) 1998-2014 Glenn Randers-Pehrson
# Copyright (C) 1995 Guy Eric Schalnat, Group 42, Inc.
#
@ -26,7 +26,7 @@ OBJS = png.o pngerror.o pngget.o pngmem.o pngpread.o \
pngtrans.o pngwio.o pngwrite.o pngwtran.o pngwutil.o
.c.o:
$(CC) -c $(CPPFLAGS) $(CFLAGS) -o $@ $<
$(CC) -c $(CPPFLAGS) $(CFLAGS) -o $@ $*.c
all: libpng.a pngtest

View File

@ -1,5 +1,5 @@
# makefile for libpng using MSYS/gcc (shared, static library)
# Copyright (C) 2000, 2019-2024 Cosmin Truta
# Copyright (C) 2000, 2019-2025 Cosmin Truta
# Copyright (C) 2012 Glenn Randers-Pehrson and Christopher M. Wheeler
#
# Portions taken from makefile.linux and makefile.gcc:
@ -21,23 +21,28 @@ PNGMAJ=16
LIBSO=$(LIBNAME).dll
LIBSOMAJ=$(LIBNAME).dll.$(PNGMAJ)
# Where the zlib library and include files are located.
#ZLIBLIB=../zlib
#ZLIBINC=../zlib
ZLIBLIB=/usr/local/lib
ZLIBINC=/usr/local/include
# Compiler, linker, lib and other tools
CC = gcc
LD = $(CC)
AR = ar
RANLIB = ranlib
CP = cp
RM_F = rm -rf
RM_F = rm -f
LN_SF = ln -sf
# Compiler and linker flags
NOHWOPT = -DPNG_ARM_NEON_OPT=0 -DPNG_MIPS_MSA_OPT=0 \
-DPNG_POWERPC_VSX_OPT=0 -DPNG_INTEL_SSE_OPT=0
STDC = -pedantic-errors
WARN = -Wall -Wextra -Wundef
WARNMORE = -Wcast-align -Wconversion -Wshadow -Wpointer-arith -Wwrite-strings \
-Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes
LOCAL_CPPFLAGS = $(NOHWOPT)
CPPFLAGS = # -DPNG_DEBUG=5
CFLAGS = -O2 -Wall -Wextra -Wundef # -g
ALL_CPPFLAGS = $(LOCAL_CPPFLAGS) $(CPPFLAGS)
LOCAL_CFLAGS = $(STDC) $(WARN) # $(WARNMORE)
CFLAGS = -O2 # -g
ALL_CFLAGS = $(LOCAL_CFLAGS) $(CFLAGS)
ARFLAGS = rc
LDFLAGS = # -g
LIBS = -lz -lm
@ -61,7 +66,7 @@ pnglibconf.h: $(PNGLIBCONF_H_PREBUILT)
$(CP) $(PNGLIBCONF_H_PREBUILT) $@
.c.o:
$(CC) -c $(CPPFLAGS) $(CFLAGS) $<
$(CC) -c $(ALL_CPPFLAGS) $(ALL_CFLAGS) -o $@ $*.c
static: libpng.a pngtest$(EXEEXT)

View File

@ -1,5 +1,5 @@
# makefile for libpng on NetBSD
# Copyright (C) 2020-2022 Cosmin Truta
# Copyright (C) 2018-2025 Cosmin Truta
# Copyright (C) 2007-2009, 2014 Glenn Randers-Pehrson
# Copyright (C) 2002 Patrick R.L. Welche
#
@ -32,7 +32,7 @@ PNGLIBCONF_H_PREBUILT= scripts/pnglibconf.h.prebuilt
# .endif
.c.o:
${CC} -c ${CPPFLAGS} ${CFLAGS} -o $@ $<
${CC} -c ${CPPFLAGS} ${CFLAGS} -o $@ $*.c
pnglibconf.h: ${PNGLIBCONF_H_PREBUILT}
cp ${PNGLIBCONF_H_PREBUILT} $@

View File

@ -1,5 +1,5 @@
# makefile for libpng
# Copyright (C) 2020-2022 Cosmin Truta
# Copyright (C) 2018-2025 Cosmin Truta
# Copyright (C) 2007-2009, 2014 Glenn Randers-Pehrson
# Copyright (C) 1995 Guy Eric Schalnat, Group 42, Inc.
#
@ -26,7 +26,7 @@ CLEANFILES+= pngtest.o pngtest pnglibconf.h
PNGLIBCONF_H_PREBUILT= scripts/pnglibconf.h.prebuilt
.c.o:
${CC} -c ${CPPFLAGS} ${CFLAGS} -o $@ $<
${CC} -c ${CPPFLAGS} ${CFLAGS} -o $@ $*.c
pnglibconf.h: ${PNGLIBCONF_H_PREBUILT}
cp ${PNGLIBCONF_H_PREBUILT} $@

View File

@ -1,7 +1,7 @@
# makefile for SCO OSr5 ELF and Unixware 7 with Native cc
# Contributed by Mike Hopkirk (hops at sco.com) modified from Makefile.lnx
# force ELF build dynamic linking, SONAME setting in lib and RPATH in app
# Copyright (C) 2020-2024 Cosmin Truta
# Copyright (C) 2018-2025 Cosmin Truta
# Copyright (C) 2002, 2006, 2010-2014 Glenn Randers-Pehrson
# Copyright (C) 1998 Greg Roelofs
# Copyright (C) 1996, 1997 Andreas Dilger
@ -50,7 +50,7 @@ OBJSDLL = $(OBJS:.o=.pic.o)
.SUFFIXES: .c .o .pic.o
.c.o:
$(CC) -c $(CPPFLAGS) $(CFLAGS) -o $@ $<
$(CC) -c $(CPPFLAGS) $(CFLAGS) -o $@ $*.c
.c.pic.o:
$(CC) -c $(CPPFLAGS) $(CFLAGS) -KPIC -o $@ $*.c

View File

@ -1,5 +1,5 @@
# makefile for libpng.a and libpng16.so, SGI IRIX with 'cc'
# Copyright (C) 2020-2024 Cosmin Truta
# Copyright (C) 2018-2025 Cosmin Truta
# Copyright (C) 2001-2002, 2006, 2010-2014 Glenn Randers-Pehrson
# Copyright (C) 1995 Guy Eric Schalnat, Group 42, Inc.
#
@ -35,9 +35,8 @@ ZLIBINC=../zlib
# See "man abi". zlib must be built with the same ABI.
ABI=
WARNMORE=
CPPFLAGS=-I$(ZLIBINC) # -DPNG_DEBUG=5
CFLAGS=$(ABI) -O $(WARNMORE) -fPIC -mabi=n32 # -g
CFLAGS=$(ABI) -O -fPIC -mabi=n32 # -g
ARFLAGS=rc
LDFLAGS=$(ABI) -L. -L$(ZLIBLIB) -lpng -lz -lm # -g
LDSHARED=cc $(ABI) -shared -soname $(LIBSOMAJ) \
@ -53,7 +52,7 @@ OBJS = png.o pngerror.o pngget.o pngmem.o pngpread.o \
pngtrans.o pngwio.o pngwrite.o pngwtran.o pngwutil.o
.c.o:
$(CC) -c $(CPPFLAGS) $(CFLAGS) -o $@ $<
$(CC) -c $(CPPFLAGS) $(CFLAGS) -o $@ $*.c
all: libpng.a pngtest shared

View File

@ -1,5 +1,5 @@
# makefile for libpng.a and libpng16.so, SGI IRIX with 'cc'
# Copyright (C) 2020-2024 Cosmin Truta
# Copyright (C) 2018-2025 Cosmin Truta
# Copyright (C) 2001-2002, 2006, 2007, 2010-2014 Glenn Randers-Pehrson
# Copyright (C) 1995 Guy Eric Schalnat, Group 42, Inc.
#
@ -35,11 +35,10 @@ ZLIBINC=../zlib
# See "man abi". zlib must be built with the same ABI.
ABI=
WARNMORE=-fullwarn
# Note: -KPIC is the default anyhow
CPPFLAGS=-I$(ZLIBINC) # -DPNG_DEBUG=5
#CFLAGS= $(ABI) -O $(WARNMORE) -KPIC # -g
CFLAGS=$(ABI) -O $(WARNMORE) # -g
#CFLAGS=$(ABI) -O -fullwarn -KPIC # -g
CFLAGS=$(ABI) -O -fullwarn # -g
ARFLAGS=rc
LDFLAGS_A=$(ABI) -L. -L$(ZLIBLIB) -lpng16 -lz -lm # -g
LDFLAGS=$(ABI) -L. -L$(ZLIBLIB) -lpng -lz -lm # -g
@ -56,7 +55,7 @@ OBJS = png.o pngerror.o pngget.o pngmem.o pngpread.o \
pngtrans.o pngwio.o pngwrite.o pngwtran.o pngwutil.o
.c.o:
$(CC) -c $(CPPFLAGS) $(CFLAGS) -o $@ $<
$(CC) -c $(CPPFLAGS) $(CFLAGS) -o $@ $*.c
all: libpng.a pngtest shared

View File

@ -1,7 +1,7 @@
# makefile for libpng on Solaris 9 (beta) with Forte cc
# Updated by Chad Schrock for Solaris 9
# Contributed by William L. Sebok, based on makefile.linux
# Copyright (C) 2020-2024 Cosmin Truta
# Copyright (C) 2018-2025 Cosmin Truta
# Copyright (C) 2002, 2006, 2008, 2010-2014 Glenn Randers-Pehrson
# Copyright (C) 1998-2001 Greg Roelofs
# Copyright (C) 1996-1997 Andreas Dilger
@ -19,7 +19,6 @@ LIBSO=$(LIBNAME).so
LIBSOMAJ=$(LIBNAME).so.$(PNGMAJ)
# Utilities:
# gcc 2.95 doesn't work.
CC=cc
AR=ar
RANLIB=echo
@ -56,7 +55,7 @@ OBJSDLL = $(OBJS:.o=.pic.o)
.SUFFIXES: .c .o .pic.o
.c.o:
$(CC) -c $(CPPFLAGS) $(CFLAGS) -o $@ $<
$(CC) -c $(CPPFLAGS) $(CFLAGS) -o $@ $*.c
.c.pic.o:
$(CC) -c $(CPPFLAGS) $(CFLAGS) -KPIC -o $@ $*.c

View File

@ -1,5 +1,5 @@
# makefile for libpng on Solaris 2.x with gcc
# Copyright (C) 2020-2024 Cosmin Truta
# Copyright (C) 2018-2025 Cosmin Truta
# Copyright (C) 2004, 2006-2008, 2010-2014 Glenn Randers-Pehrson
# Contributed by William L. Sebok, based on makefile.linux
# Copyright (C) 1998 Greg Roelofs
@ -34,11 +34,8 @@ RM_F=/bin/rm -f
ZLIBLIB=/usr/local/lib
ZLIBINC=/usr/local/include
WARNMORE=-Wwrite-strings -Wpointer-arith -Wshadow \
-Wmissing-declarations -Wtraditional -Wcast-align \
-Wstrict-prototypes -Wmissing-prototypes # -Wconversion
CPPFLAGS=-I$(ZLIBINC) # -DPNG_DEBUG=5
CFLAGS=-O -Wall -Wextra -Wundef # $(WARNMORE) -g
CFLAGS=-O # -g
ARFLAGS=rc
LDFLAGS=-L. -R. -L$(ZLIBLIB) -R$(ZLIBLIB) -lpng16 -lz -lm # -g
@ -55,7 +52,7 @@ OBJSDLL = $(OBJS:.o=.pic.o)
.SUFFIXES: .c .o .pic.o
.c.o:
$(CC) -c $(CPPFLAGS) $(CFLAGS) -o $@ $<
$(CC) -c $(CPPFLAGS) $(CFLAGS) -o $@ $*.c
.c.pic.o:
$(CC) -c $(CPPFLAGS) $(CFLAGS) -fPIC -o $@ $*.c

View File

@ -1,5 +1,5 @@
# makefile for libpng
# Copyright (C) 2020-2024 Cosmin Truta
# Copyright (C) 2015, 2018-2025 Cosmin Truta
# Copyright (C) 2002, 2006, 2014 Glenn Randers-Pehrson
# Copyright (C) 1995 Guy Eric Schalnat, Group 42, Inc.
#
@ -23,7 +23,7 @@ RM_F = rm -f
AWK = awk
NOHWOPT = -DPNG_ARM_NEON_OPT=0 -DPNG_MIPS_MSA_OPT=0 \
-DPNG_POWERPC_VSX_OPT=0 -DPNG_INTEL_SSE_OPT=0
-DPNG_POWERPC_VSX_OPT=0 -DPNG_INTEL_SSE_OPT=0
DFNFLAGS = # DFNFLAGS contains -D options to use in the libpng build
DFA_EXTRA = # extra files that can be used to control configuration
CPPFLAGS = -I$(ZLIBINC) $(NOHWOPT) # -DPNG_DEBUG=5
@ -41,7 +41,7 @@ OBJS = png.o pngerror.o pngget.o pngmem.o pngpread.o \
pngtrans.o pngwio.o pngwrite.o pngwtran.o pngwutil.o
.c.o:
$(CC) -c $(CPPFLAGS) $(CFLAGS) -o $@ $<
$(CC) -c $(CPPFLAGS) $(CFLAGS) -o $@ $*.c
all: libpng.a pngtest

View File

@ -1,5 +1,5 @@
# makefile for libpng
# Copyright (C) 2020-2024 Cosmin Truta
# Copyright (C) 2018-2025 Cosmin Truta
# Copyright (C) 2002, 2006, 2014 Glenn Randers-Pehrson
# Copyright (C) 1995 Guy Eric Schalnat, Group 42, Inc.
#
@ -33,7 +33,7 @@ OBJS = png.o pngerror.o pngget.o pngmem.o pngpread.o \
pngtrans.o pngwio.o pngwrite.o pngwtran.o pngwutil.o
.c.o:
$(CC) -c $(CPPFLAGS) $(CFLAGS) -o $@ $<
$(CC) -c $(CPPFLAGS) $(CFLAGS) -o $@ $*.c
all: libpng.a pngtest

View File

@ -8,7 +8,7 @@ com pnglibconf.h - library build configuration
com
version
com
com Copyright (c) 2018-2024 Cosmin Truta
com Copyright (c) 2018-2025 Cosmin Truta
com Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson
com
com This code is released under the libpng license.
@ -846,11 +846,14 @@ setting IDAT_READ_SIZE default PNG_ZBUF_SIZE
# Ancillary chunks
chunk bKGD
chunk cHRM enables COLORSPACE
chunk cICP enables COLORSPACE, GAMMA
chunk cLLI
chunk eXIf
chunk gAMA enables GAMMA
chunk hIST
chunk iCCP enables COLORSPACE, GAMMA
chunk iTXt enables TEXT
chunk mDCV
chunk oFFs
chunk pCAL
chunk pHYs

View File

@ -1,8 +1,8 @@
/* pnglibconf.h - library build configuration */
/* libpng version 1.6.44 */
/* libpng version 1.6.46 */
/* Copyright (c) 2018-2024 Cosmin Truta */
/* Copyright (c) 2018-2025 Cosmin Truta */
/* Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson */
/* This code is released under the libpng license. */
@ -88,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
@ -158,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
@ -176,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

View File

@ -1,4 +1,3 @@
/* prefix.c - generate an unprefixed symbol list
*
* Copyright (c) 2013-2014 Glenn Randers-Pehrson

View File

@ -1,4 +1,3 @@
/* sym.c - define format of libpng.sym
*
* Copyright (c) 2011-2014 Glenn Randers-Pehrson

View File

@ -1,4 +1,3 @@
/* symbols.c - find all exported symbols
*
* Copyright (c) 2011-2014 Glenn Randers-Pehrson

View File

@ -253,23 +253,33 @@ EXPORTS
png_set_eXIf @247
png_get_eXIf_1 @248
png_set_eXIf_1 @249
png_get_acTL @250
png_set_acTL @251
png_get_num_frames @252
png_get_num_plays @253
png_get_next_frame_fcTL @254
png_set_next_frame_fcTL @255
png_get_next_frame_width @256
png_get_next_frame_height @257
png_get_next_frame_x_offset @258
png_get_next_frame_y_offset @259
png_get_next_frame_delay_num @260
png_get_next_frame_delay_den @261
png_get_next_frame_dispose_op @262
png_get_next_frame_blend_op @263
png_get_first_frame_is_hidden @264
png_set_first_frame_is_hidden @265
png_read_frame_head @266
png_set_progressive_frame_fn @267
png_write_frame_head @268
png_write_frame_tail @269
png_get_cICP @250
png_set_cICP @251
png_get_cLLI @252
png_get_cLLI_fixed @253
png_set_cLLI @254
png_set_cLLI_fixed @255
png_get_mDCV @256
png_get_mDCV_fixed @257
png_set_mDCV @258
png_set_mDCV_fixed @259
png_get_acTL @260
png_set_acTL @261
png_get_num_frames @262
png_get_num_plays @263
png_get_next_frame_fcTL @264
png_set_next_frame_fcTL @265
png_get_next_frame_width @266
png_get_next_frame_height @267
png_get_next_frame_x_offset @268
png_get_next_frame_y_offset @269
png_get_next_frame_delay_num @270
png_get_next_frame_delay_den @271
png_get_next_frame_dispose_op @272
png_get_next_frame_blend_op @273
png_get_first_frame_is_hidden @274
png_set_first_frame_is_hidden @275
png_read_frame_head @276
png_set_progressive_frame_fn @277
png_write_frame_head @278
png_write_frame_tail @279

View File

@ -1,4 +1,3 @@
/* vers.c - define format of libpng.vers
*
* Copyright (c) 2011-2014 Glenn Randers-Pehrson