mirror of
https://github.com/opencv/opencv.git
synced 2024-11-23 18:50:21 +08:00
Merge pull request #25580 from sturkmen72:libpng_1_6_43
3rdparty: update libpng 1.6.43 #25580 ### Pull Request Readiness Checklist See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request - [x] I agree to contribute to the project under Apache 2 License. - [x] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV - [x] The PR is proposed to the proper branch - [ ] There is a reference to the original bug report and related work - [ ] There is accuracy test, performance test and test data in opencv_extra repository, if applicable Patch to opencv_extra has the same branch name. - [ ] The feature is well documented and sample code can be built with the project CMake
This commit is contained in:
parent
8393885a39
commit
e765c9f9c8
117
3rdparty/libpng/CHANGES
vendored
117
3rdparty/libpng/CHANGES
vendored
@ -204,7 +204,7 @@ Version 0.97 [January, 1998]
|
||||
Added simple sRGB support (Glenn R-P)
|
||||
Easier conditional compiling, e.g.,
|
||||
define PNG_READ/WRITE_NOT_FULLY_SUPPORTED;
|
||||
all configurable options can be selected from command-line instead
|
||||
all configurable options can be selected from command line instead
|
||||
of having to edit pngconf.h (Glenn R-P)
|
||||
Fixed memory leak in pngwrite.c (free info_ptr->text) (Glenn R-P)
|
||||
Added more conditions for png_do_background, to avoid changing
|
||||
@ -942,7 +942,7 @@ Version 1.0.8 [July 24, 2000]
|
||||
Version 1.0.9beta1 [November 10, 2000]
|
||||
Fixed typo in scripts/makefile.hpux
|
||||
Updated makevms.com in scripts and contrib/* and contrib/* (Martin Zinser)
|
||||
Fixed seqence-point bug in contrib/pngminus/png2pnm (Martin Zinser)
|
||||
Fixed sequence-point bug in contrib/pngminus/png2pnm (Martin Zinser)
|
||||
Changed "cdrom.com" in documentation to "libpng.org"
|
||||
Revised pnggccrd.c to get it all working, and updated makefile.gcmmx (Greg).
|
||||
Changed type of "params" from voidp to png_voidp in png_read|write_png().
|
||||
@ -2295,7 +2295,7 @@ Version 1.4.0beta58 [May 14, 2009]
|
||||
Clarified usage of sig_bit versus sig_bit_p in example.c (Vincent Torri)
|
||||
|
||||
Version 1.4.0beta59 [May 15, 2009]
|
||||
Reformated sources in libpng style (3-space intentation, comment format)
|
||||
Reformatted sources in libpng style (3-space indentation, comment format)
|
||||
Fixed typo in libpng docs (PNG_FILTER_AVE should be PNG_FILTER_AVG)
|
||||
Added sections about the git repository and our coding style to the
|
||||
documentation
|
||||
@ -2661,7 +2661,7 @@ Version 1.4.1beta06 [January 28, 2010]
|
||||
|
||||
Version 1.4.1beta07 [February 6, 2010]
|
||||
Folded some long lines in the source files.
|
||||
Added defineable PNG_USER_CHUNK_CACHE_MAX, PNG_USER_CHUNK_MALLOC_MAX,
|
||||
Added definable PNG_USER_CHUNK_CACHE_MAX, PNG_USER_CHUNK_MALLOC_MAX,
|
||||
and a PNG_USER_LIMITS_SUPPORTED flag.
|
||||
Eliminated use of png_ptr->irowbytes and reused the slot in png_ptr as
|
||||
png_ptr->png_user_chunk_malloc_max.
|
||||
@ -3886,7 +3886,7 @@ Version 1.6.0beta06 [January 24, 2012]
|
||||
Version 1.6.0beta07 [January 28, 2012]
|
||||
Eliminated Intel icc/icl compiler warnings. The Intel (GCC derived)
|
||||
compiler issues slightly different warnings from those issued by the
|
||||
current vesions of GCC. This eliminates those warnings by
|
||||
current versions of GCC. This eliminates those warnings by
|
||||
adding/removing casts and small code rewrites.
|
||||
Updated configure.ac from autoupdate: added --enable-werror option.
|
||||
Also some layout regularization and removal of introduced tab characters
|
||||
@ -3919,7 +3919,7 @@ Version 1.6.0beta08 [February 1, 2012]
|
||||
version checking to configure.ac
|
||||
Improved pngstest speed by not doing redundant tests and add const to
|
||||
the background parameter of png_image_finish_read. The --background
|
||||
option is now done automagically only when required, so that commandline
|
||||
option is now done automagically only when required, so that command-line
|
||||
option no longer exists.
|
||||
Cleaned up pngpriv.h to consistently declare all functions and data.
|
||||
Also eliminated PNG_CONST_DATA, which is apparently not needed but we
|
||||
@ -4052,7 +4052,7 @@ Version 1.6.0beta16 [March 6, 2012]
|
||||
(in fact this is harmless, but the PNG data produced may be sub-optimal).
|
||||
|
||||
Version 1.6.0beta17 [March 10, 2012]
|
||||
Fixed PNG_LIBPNG_BUILD_BASE_TYPE definition.
|
||||
Fixed PNG_LIBPNG_BUILD_BASE_TYPE definition.
|
||||
Reject all iCCP chunks after the first, even if the first one is invalid.
|
||||
Deflate/inflate was reworked to move common zlib calls into single
|
||||
functions [rw]util.c. A new shared keyword check routine was also added
|
||||
@ -4962,7 +4962,7 @@ Version 1.6.13beta01 [July 4, 2014]
|
||||
Changed "if defined(__ARM_NEON__)" to
|
||||
"if (defined(__ARM_NEON__) || defined(__ARM_NEON))" (James Wu).
|
||||
Fixed clang no-warning builds: png_digit was defined but never used.
|
||||
|
||||
|
||||
Version 1.6.13beta02 [July 21, 2014]
|
||||
Fixed an incorrect separator ("/" should be "\") in scripts/makefile.vcwin32
|
||||
(bug report from Wolfgang S. Kechel). Bug was introduced in libpng-1.6.11.
|
||||
@ -5453,7 +5453,7 @@ Version 1.6.21beta01 [December 11, 2015]
|
||||
Version 1.6.21beta02 [December 14, 2015]
|
||||
Moved png_check_keyword() from pngwutil.c to pngset.c
|
||||
Removed LE/BE dependencies in pngvalid, to 'fix' the current problem
|
||||
in the BigEndian tests by not testing it, making the BE code the same
|
||||
in the BigEndian tests by not testing it, making the BE code the same
|
||||
as the LE version.
|
||||
Fixes to pngvalid for various reduced build configurations (eliminate unused
|
||||
statics) and a fix for the case in rgb_to_gray when the digitize option
|
||||
@ -5517,7 +5517,7 @@ Version 1.6.22beta03 [March 9, 2016]
|
||||
Added a common-law trademark notice and export control information
|
||||
to the LICENSE file, png.h, and the man page.
|
||||
Restored "& 0xff" in png_save_uint_16() and png_save_uint_32() that
|
||||
were accidentally removed from libpng-1.6.17.
|
||||
were accidentally removed from libpng-1.6.17.
|
||||
Changed PNG_INFO_cHNK and PNG_FREE_cHNK from 0xnnnn to 0xnnnnU in png.h
|
||||
(Robert C. Seacord).
|
||||
Removed dubious "#if INT_MAX" test from png.h that was added to
|
||||
@ -5927,7 +5927,7 @@ Version 1.6.32beta03 [August 2, 2017]
|
||||
(Bug report from the OSS-fuzz project).
|
||||
|
||||
Version 1.6.32beta04 [August 2, 2017]
|
||||
Replaced local eXIf_buf with info_ptr-eXIf_buf in png_handle_eXIf().
|
||||
Replaced local eXIf_buf with info_ptr->eXIf_buf in png_handle_eXIf().
|
||||
Update libpng.3 and libpng-manual.txt about eXIf functions.
|
||||
|
||||
Version 1.6.32beta05 [August 2, 2017]
|
||||
@ -5950,7 +5950,7 @@ Version 1.6.32beta09 [August 3, 2017]
|
||||
Require cmake-2.8.8 in CMakeLists.txt. Revised symlink creation,
|
||||
no longer using deprecated cmake LOCATION feature (Clifford Yapp).
|
||||
Fixed five-byte error in the calculation of IDAT maximum possible size.
|
||||
|
||||
|
||||
Version 1.6.32beta10 [August 5, 2017]
|
||||
Moved chunk-length check into a png_check_chunk_length() private
|
||||
function (Suggested by Max Stepin).
|
||||
@ -6103,6 +6103,99 @@ Version 1.6.37 [April 14, 2019]
|
||||
Added makefiles for AddressSanitizer-enabled builds.
|
||||
Cleaned up various makefiles.
|
||||
|
||||
Version 1.6.38 [September 14, 2022]
|
||||
Added configurations and scripts for continuous integration.
|
||||
Fixed various errors in the handling of tRNS, hIST and eXIf.
|
||||
Implemented many stability improvements across all platforms.
|
||||
Updated the internal documentation.
|
||||
|
||||
Version 1.6.39 [November 20, 2022]
|
||||
Changed the error handler of oversized chunks (i.e. larger than
|
||||
PNG_USER_CHUNK_MALLOC_MAX) from png_chunk_error to png_benign_error.
|
||||
Fixed a buffer overflow error in contrib/tools/pngfix.
|
||||
Fixed a memory leak (CVE-2019-6129) in contrib/tools/pngcp.
|
||||
Disabled the ARM Neon optimizations by default in the CMake file,
|
||||
following the default behavior of the configure script.
|
||||
Allowed configure.ac to work with the trunk version of autoconf.
|
||||
Removed the support for "install" targets from the legacy makefiles;
|
||||
removed the obsolete makefile.cegcc.
|
||||
Cleaned up the code and updated the internal documentation.
|
||||
|
||||
Version 1.6.40 [June 21, 2023]
|
||||
Fixed the eXIf chunk multiplicity checks.
|
||||
Fixed a memory leak in pCAL processing.
|
||||
Corrected the validity report about tRNS inside png_get_valid().
|
||||
Fixed various build issues on *BSD, Mac and Windows.
|
||||
Updated the configurations and the scripts for continuous integration.
|
||||
Cleaned up the code, the build scripts, and the documentation.
|
||||
|
||||
Version 1.6.41 [January 24, 2024]
|
||||
Added SIMD-optimized code for the LoongArch LSX hardware.
|
||||
(Contributed by GuXiWei, JinBo and ZhangLixia)
|
||||
Fixed the run-time discovery of MIPS MSA hardware.
|
||||
(Contributed by Sui Jingfeng)
|
||||
Fixed an off-by-one error in the function png_do_check_palette_indexes(),
|
||||
which failed to recognize errors that might have existed in the first
|
||||
column of a broken palette-encoded image. This was a benign regression
|
||||
accidentally introduced in libpng-1.6.33. No pixel was harmed.
|
||||
(Contributed by Adam Richter; reviewed by John Bowler)
|
||||
Fixed, improved and modernized the contrib/pngminus programs, i.e.,
|
||||
png2pnm.c and pnm2png.c
|
||||
Removed old and peculiar portability hacks that were meant to silence
|
||||
warnings issued by gcc version 7.1 alone.
|
||||
(Contributed by John Bowler)
|
||||
Fixed and modernized the CMake file, and raised the minimum required
|
||||
CMake version from 3.1 to 3.6.
|
||||
(Contributed by Clinton Ingram, Timothy Lyanguzov, Tyler Kropp, et al.)
|
||||
Allowed the configure script to disable the building of auxiliary tools
|
||||
and tests, thus catching up with the CMake file.
|
||||
(Contributed by Carlo Bramini)
|
||||
Fixed a build issue on Mac.
|
||||
(Contributed by Zixu Wang)
|
||||
Moved the Autoconf macro files to scripts/autoconf.
|
||||
Moved the CMake files (except for the main CMakeLists.txt) to
|
||||
scripts/cmake and moved the list of their contributing authors to
|
||||
scripts/cmake/AUTHORS.md
|
||||
Updated the CI configurations and scripts.
|
||||
Relicensed the CI scripts to the MIT License.
|
||||
Improved the test coverage.
|
||||
(Contributed by John Bowler)
|
||||
|
||||
Version 1.6.42 [January 29, 2024]
|
||||
Fixed the implementation of the macro function png_check_sig().
|
||||
This was an API regression, introduced in libpng-1.6.41.
|
||||
(Reported by Matthieu Darbois)
|
||||
Fixed and updated the libpng manual.
|
||||
|
||||
Version 1.6.43 [February 23, 2024]
|
||||
Fixed the row width check in png_check_IHDR().
|
||||
This corrected a bug that was specific to the 16-bit platforms,
|
||||
and removed a spurious compiler warning from the 64-bit builds.
|
||||
(Reported by Jacek Caban; fixed by John Bowler)
|
||||
Added eXIf chunk support to the push-mode reader in pngpread.c.
|
||||
(Contributed by Chris Blume)
|
||||
Added contrib/pngexif for the benefit of the users who would like
|
||||
to inspect the content of eXIf chunks.
|
||||
Added contrib/conftest/basic.dfa, a basic build-time configuration.
|
||||
(Contributed by John Bowler)
|
||||
Fixed a preprocessor condition in pngread.c that broke build-time
|
||||
configurations like contrib/conftest/pngcp.dfa.
|
||||
(Contributed by John Bowler)
|
||||
Added CMake build support for LoongArch LSX.
|
||||
(Contributed by GuXiWei)
|
||||
Fixed a CMake build error that occurred under a peculiar state of the
|
||||
dependency tree. This was a regression introduced in libpng-1.6.41.
|
||||
(Contributed by Dan Rosser)
|
||||
Marked the installed libpng headers as system headers in CMake.
|
||||
(Contributed by Benjamin Buch)
|
||||
Updated the build support for RISCOS.
|
||||
(Contributed by Cameron Cawley)
|
||||
Updated the makefiles to allow cross-platform builds to initialize
|
||||
conventional make variables like AR and ARFLAGS.
|
||||
Added various improvements to the CI scripts in areas like version
|
||||
consistency verification and text linting.
|
||||
Added version consistency verification to pngtest.c also.
|
||||
|
||||
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
|
||||
|
212
3rdparty/libpng/CMakeLists.txt
vendored
212
3rdparty/libpng/CMakeLists.txt
vendored
@ -9,17 +9,15 @@ else()
|
||||
project(${PNG_LIBRARY} C)
|
||||
endif()
|
||||
|
||||
if(NOT WIN32)
|
||||
find_library(M_LIBRARY
|
||||
NAMES m
|
||||
PATHS /usr/lib /usr/local/lib
|
||||
)
|
||||
if(NOT M_LIBRARY)
|
||||
message(STATUS "math lib 'libm' not found; floating point support disabled")
|
||||
if(UNIX AND NOT APPLE AND NOT BEOS AND NOT HAIKU AND NOT EMSCRIPTEN)
|
||||
find_library(M_LIBRARY m)
|
||||
if(M_LIBRARY)
|
||||
set(M_LIBRARY m)
|
||||
else()
|
||||
set(M_LIBRARY "")
|
||||
endif()
|
||||
else()
|
||||
# not needed on windows
|
||||
set(M_LIBRARY "")
|
||||
# libm is not available or not needed.
|
||||
endif()
|
||||
|
||||
ocv_include_directories("${CMAKE_CURRENT_SOURCE_DIR}" ${ZLIB_INCLUDE_DIRS})
|
||||
@ -27,45 +25,191 @@ ocv_include_directories("${CMAKE_CURRENT_SOURCE_DIR}" ${ZLIB_INCLUDE_DIRS})
|
||||
file(GLOB lib_srcs *.c)
|
||||
file(GLOB lib_hdrs *.h)
|
||||
|
||||
# CMake currently sets CMAKE_SYSTEM_PROCESSOR to one of x86_64 or arm64 on macOS,
|
||||
# based upon the OS architecture, not the target architecture. As such, we need
|
||||
# to check CMAKE_OSX_ARCHITECTURES to identify which hardware-specific flags to
|
||||
# enable. Note that this will fail if you attempt to build a universal binary in
|
||||
# a single CMake invocation.
|
||||
if(APPLE AND CMAKE_OSX_ARCHITECTURES)
|
||||
set(TARGET_ARCH ${CMAKE_OSX_ARCHITECTURES})
|
||||
else()
|
||||
set(TARGET_ARCH ${CMAKE_SYSTEM_PROCESSOR})
|
||||
endif()
|
||||
|
||||
if(ARM OR AARCH64)
|
||||
if(ENABLE_NEON)
|
||||
if(NOT AARCH64)
|
||||
OCV_OPTION(PNG_HARDWARE_OPTIMIZATIONS "Enable Hardware Optimizations, if available for this platform" (NOT CV_DISABLE_OPTIMIZATION))
|
||||
|
||||
if(PNG_HARDWARE_OPTIMIZATIONS)
|
||||
|
||||
# Set definitions and sources for ARM.
|
||||
if(TARGET_ARCH MATCHES "^(ARM|arm|aarch)")
|
||||
if(TARGET_ARCH MATCHES "^(ARM64|arm64|aarch64)")
|
||||
set(PNG_ARM_NEON_POSSIBLE_VALUES on off)
|
||||
set(PNG_ARM_NEON "on"
|
||||
CACHE STRING "Enable ARM NEON optimizations: on|off; on is default")
|
||||
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")
|
||||
list(APPEND lib_srcs arm/arm_init.c arm/filter_neon_intrinsics.c arm/palette_neon_intrinsics.c)
|
||||
if(NOT MSVC)
|
||||
list(APPEND lib_srcs arm/filter_neon.S)
|
||||
endif()
|
||||
list(APPEND lib_srcs arm/arm_init.c arm/filter_neon_intrinsics.c arm/palette_neon_intrinsics.c)
|
||||
add_definitions(-DPNG_ARM_NEON_OPT=2)
|
||||
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) # NEON assembler is not supported
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(";${CPU_BASELINE_FINAL};" MATCHES "SSE2"
|
||||
AND (NOT MSVC OR (MSVC_VERSION GREATER 1799))) # MSVS2013+ (issue #7232)
|
||||
list(APPEND lib_srcs intel/intel_init.c intel/filter_sse2_intrinsics.c)
|
||||
add_definitions(-DPNG_INTEL_SSE)
|
||||
endif()
|
||||
|
||||
# set definitions and sources for MIPS
|
||||
if(";${CPU_BASELINE_FINAL};" MATCHES "MSA")
|
||||
list(APPEND lib_srcs mips/mips_init.c mips/filter_msa_intrinsics.c)
|
||||
add_definitions(-DPNG_MIPS_MSA_OPT=2)
|
||||
ocv_warnings_disable(CMAKE_C_FLAGS -Wshadow)
|
||||
else()
|
||||
add_definitions(-DPNG_MIPS_MSA_OPT=0)
|
||||
endif()
|
||||
|
||||
if(PPC64LE OR PPC64)
|
||||
# VSX3 features are backwards compatible
|
||||
if(";${CPU_BASELINE_FINAL};" MATCHES "VSX.*"
|
||||
AND NOT PPC64)
|
||||
# Set definitions and sources for PowerPC.
|
||||
if(TARGET_ARCH MATCHES "^(powerpc|ppc64)")
|
||||
set(PNG_POWERPC_VSX_POSSIBLE_VALUES on off)
|
||||
set(PNG_POWERPC_VSX "on"
|
||||
CACHE STRING "Enable POWERPC VSX optimizations: on|off; on is default")
|
||||
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")
|
||||
list(APPEND lib_srcs powerpc/powerpc_init.c powerpc/filter_vsx_intrinsics.c)
|
||||
add_definitions(-DPNG_POWERPC_VSX_OPT=2)
|
||||
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(TARGET_ARCH MATCHES "^(i[3-6]86|x86|AMD64)")
|
||||
set(PNG_INTEL_SSE_POSSIBLE_VALUES on off)
|
||||
set(PNG_INTEL_SSE "on"
|
||||
CACHE STRING "Enable INTEL_SSE optimizations: on|off; on is default")
|
||||
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")
|
||||
list(APPEND lib_srcs 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()
|
||||
|
||||
# Set definitions and sources for MIPS.
|
||||
if(TARGET_ARCH MATCHES "^(mipsel|mips64el)")
|
||||
set(PNG_MIPS_MSA_POSSIBLE_VALUES on off)
|
||||
set(PNG_MIPS_MSA "on"
|
||||
CACHE STRING "Enable MIPS_MSA optimizations: on|off; on is default")
|
||||
set_property(CACHE PNG_MIPS_MSA
|
||||
PROPERTY STRINGS ${PNG_MIPS_MSA_POSSIBLE_VALUES})
|
||||
list(FIND PNG_MIPS_MSA_POSSIBLE_VALUES ${PNG_MIPS_MSA} index_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")
|
||||
list(APPEND lib_srcs 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")
|
||||
list(APPEND lib_srcs 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")
|
||||
list(APPEND lib_srcs 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(TARGET_ARCH 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")
|
||||
list(APPEND lib_srcs ${libpng_loongarch_sources})
|
||||
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()
|
||||
endif()
|
||||
|
||||
else(PNG_HARDWARE_OPTIMIZATIONS)
|
||||
|
||||
# Set definitions and sources for ARM.
|
||||
if(TARGET_ARCH MATCHES "^(ARM|arm|aarch)")
|
||||
add_definitions(-DPNG_ARM_NEON_OPT=0)
|
||||
endif()
|
||||
|
||||
# Set definitions and sources for PowerPC.
|
||||
if(TARGET_ARCH MATCHES "^(powerpc|ppc64)")
|
||||
add_definitions(-DPNG_POWERPC_VSX_OPT=0)
|
||||
endif()
|
||||
|
||||
# Set definitions and sources for Intel.
|
||||
if(TARGET_ARCH MATCHES "^(i[3-6]86|x86|AMD64)")
|
||||
add_definitions(-DPNG_INTEL_SSE_OPT=0)
|
||||
endif()
|
||||
|
||||
# Set definitions and sources for MIPS.
|
||||
if(TARGET_ARCH MATCHES "^(mipsel|mips64el)")
|
||||
add_definitions(-DPNG_MIPS_MSA_OPT=0)
|
||||
endif()
|
||||
|
||||
# Set definitions and sources for LoongArch.
|
||||
if(TARGET_ARCH MATCHES "^(loongarch)")
|
||||
add_definitions(-DPNG_LOONGARCH_LSX_OPT=0)
|
||||
endif()
|
||||
|
||||
endif(PNG_HARDWARE_OPTIMIZATIONS)
|
||||
|
||||
# ----------------------------------------------------------------------------------
|
||||
# Define the library target:
|
||||
# ----------------------------------------------------------------------------------
|
||||
|
4
3rdparty/libpng/LICENSE
vendored
4
3rdparty/libpng/LICENSE
vendored
@ -4,8 +4,8 @@ COPYRIGHT NOTICE, DISCLAIMER, and LICENSE
|
||||
PNG Reference Library License version 2
|
||||
---------------------------------------
|
||||
|
||||
* Copyright (c) 1995-2019 The PNG Reference Library Authors.
|
||||
* Copyright (c) 2018-2019 Cosmin Truta.
|
||||
* Copyright (c) 1995-2024 The PNG Reference Library Authors.
|
||||
* Copyright (c) 2018-2024 Cosmin Truta.
|
||||
* Copyright (c) 2000-2002, 2004, 2006-2018 Glenn Randers-Pehrson.
|
||||
* Copyright (c) 1996-1997 Andreas Dilger.
|
||||
* Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
|
||||
|
299
3rdparty/libpng/README
vendored
299
3rdparty/libpng/README
vendored
@ -1,57 +1,88 @@
|
||||
README for libpng version 1.6.37 - April 14, 2019
|
||||
=================================================
|
||||
README for libpng version 1.6.43
|
||||
================================
|
||||
|
||||
See the note about version numbers near the top of png.h.
|
||||
See INSTALL for instructions on how to install libpng.
|
||||
See the note about version numbers near the top of `png.h`.
|
||||
See `INSTALL` for instructions on how to install libpng.
|
||||
|
||||
Libpng comes in several distribution formats. Get libpng-*.tar.gz or
|
||||
libpng-*.tar.xz or if you want UNIX-style line endings in the text
|
||||
files, or lpng*.7z or lpng*.zip if you want DOS-style line endings.
|
||||
Libpng comes in several distribution formats. Get `libpng-*.tar.gz`
|
||||
or `libpng-*.tar.xz` if you want UNIX-style line endings in the text
|
||||
files, or `lpng*.7z` or `lpng*.zip` if you want DOS-style line endings.
|
||||
|
||||
Version 0.89 was the first official release of libpng. Don't let the
|
||||
fact that it's the first release fool you. The libpng library has been
|
||||
in extensive use and testing since mid-1995. By late 1997 it had
|
||||
finally gotten to the stage where there hadn't been significant
|
||||
changes to the API in some time, and people have a bad feeling about
|
||||
libraries with versions < 1.0. Version 1.0.0 was released in
|
||||
March 1998.
|
||||
For a detailed description on using libpng, read `libpng-manual.txt`.
|
||||
For examples of libpng in a program, see `example.c` and `pngtest.c`.
|
||||
For usage information and restrictions (what little they are) on libpng,
|
||||
see `png.h`. For a description on using zlib (the compression library
|
||||
used by libpng) and zlib's restrictions, see `zlib.h`.
|
||||
|
||||
****
|
||||
Note that some of the changes to the png_info structure render this
|
||||
You should use zlib 1.0.4 or later to run this, but it _may_ work with
|
||||
versions as old as zlib 0.95. Even so, there are bugs in older zlib
|
||||
versions which can cause the output of invalid compression streams for
|
||||
some images.
|
||||
|
||||
You should also note that zlib is a compression library that is useful
|
||||
for more things than just PNG files. You can use zlib as a drop-in
|
||||
replacement for `fread()` and `fwrite()`, if you are so inclined.
|
||||
|
||||
zlib should be available at the same place that libpng is, or at
|
||||
https://zlib.net .
|
||||
|
||||
You may also want a copy of the PNG specification. It is available
|
||||
as an RFC, a W3C Recommendation, and an ISO/IEC Standard. You can find
|
||||
these at http://www.libpng.org/pub/png/pngdocs.html .
|
||||
|
||||
This code is currently being archived at https://libpng.sourceforge.io
|
||||
in the download area, and at http://libpng.download/src .
|
||||
|
||||
This release, based in a large way on Glenn's, Guy's and Andreas'
|
||||
earlier work, was created and will be supported by myself and the PNG
|
||||
development group.
|
||||
|
||||
Send comments, corrections and commendations to `png-mng-implement`
|
||||
at `lists.sourceforge.net`. (Subscription is required; visit
|
||||
https://lists.sourceforge.net/lists/listinfo/png-mng-implement
|
||||
to subscribe.)
|
||||
|
||||
Send general questions about the PNG specification to `png-mng-misc`
|
||||
at `lists.sourceforge.net`. (Subscription is required; visit
|
||||
https://lists.sourceforge.net/lists/listinfo/png-mng-misc
|
||||
to subscribe.)
|
||||
|
||||
Historical notes
|
||||
----------------
|
||||
|
||||
The libpng library has been in extensive use and testing since mid-1995.
|
||||
Version 0.89, published a year later, was the first official release.
|
||||
By late 1997, it had finally gotten to the stage where there hadn't
|
||||
been significant changes to the API in some time, and people have a bad
|
||||
feeling about libraries with versions below 1.0. Version 1.0.0 was
|
||||
released in March 1998.
|
||||
|
||||
Note that some of the changes to the `png_info` structure render this
|
||||
version of the library binary incompatible with libpng-0.89 or
|
||||
earlier versions if you are using a shared library. The type of the
|
||||
"filler" parameter for png_set_filler() has changed from png_byte to
|
||||
png_uint_32, which will affect shared-library applications that use
|
||||
this function.
|
||||
`filler` parameter for `png_set_filler()` has changed from `png_byte`
|
||||
to `png_uint_32`, which will affect shared-library applications that
|
||||
use this function.
|
||||
|
||||
To avoid problems with changes to the internals of the png info_struct,
|
||||
To avoid problems with changes to the internals of the `info_struct`,
|
||||
new APIs have been made available in 0.95 to avoid direct application
|
||||
access to info_ptr. These functions are the png_set_<chunk> and
|
||||
png_get_<chunk> functions. These functions should be used when
|
||||
accessing/storing the info_struct data, rather than manipulating it
|
||||
access to `info_ptr`. These functions are the `png_set_<chunk>` and
|
||||
`png_get_<chunk>` functions. These functions should be used when
|
||||
accessing/storing the `info_struct` data, rather than manipulating it
|
||||
directly, to avoid such problems in the future.
|
||||
|
||||
It is important to note that the APIs did not make current programs
|
||||
that access the info struct directly incompatible with the new
|
||||
library, through libpng-1.2.x. In libpng-1.4.x, which was meant to
|
||||
be a transitional release, members of the png_struct and the
|
||||
info_struct can still be accessed, but the compiler will issue a
|
||||
be a transitional release, members of the `png_struct` and the
|
||||
`info_struct` can still be accessed, but the compiler will issue a
|
||||
warning about deprecated usage. Since libpng-1.5.0, direct access
|
||||
to these structs is not allowed, and the definitions of the structs
|
||||
reside in private pngstruct.h and pnginfo.h header files that are not
|
||||
accessible to applications. It is strongly suggested that new
|
||||
programs use the new APIs (as shown in example.c and pngtest.c), and
|
||||
older programs be converted to the new format, to facilitate upgrades
|
||||
in the future.
|
||||
****
|
||||
|
||||
Additions since 0.90 include the ability to compile libpng as a
|
||||
Windows DLL, and new APIs for accessing data in the info struct.
|
||||
Experimental functions include the ability to set weighting and cost
|
||||
factors for row filter selection, direct reads of integers from buffers
|
||||
on big-endian processors that support misaligned data access, faster
|
||||
methods of doing alpha composition, and more accurate 16->8 bit color
|
||||
conversion.
|
||||
reside in private `pngstruct.h` and `pnginfo.h` header files that are
|
||||
not accessible to applications. It is strongly suggested that new
|
||||
programs use the new APIs (as shown in `example.c` and `pngtest.c`),
|
||||
and older programs be converted to the new format, to facilitate
|
||||
upgrades in the future.
|
||||
|
||||
The additions since 0.89 include the ability to read from a PNG stream
|
||||
which has had some (or all) of the signature bytes read by the calling
|
||||
@ -61,118 +92,88 @@ the library action on the detection of chunk CRC errors. It is possible
|
||||
to set different actions based on whether the CRC error occurred in a
|
||||
critical or an ancillary chunk.
|
||||
|
||||
For a detailed description on using libpng, read libpng-manual.txt.
|
||||
For examples of libpng in a program, see example.c and pngtest.c. For
|
||||
usage information and restrictions (what little they are) on libpng,
|
||||
see png.h. For a description on using zlib (the compression library
|
||||
used by libpng) and zlib's restrictions, see zlib.h
|
||||
The additions since 0.90 include the ability to compile libpng as a
|
||||
Windows DLL, and new APIs for accessing data in the `info_struct`.
|
||||
Experimental functions included the ability to set weighting and cost
|
||||
factors for row filter selection, direct reads of integers from buffers
|
||||
on big-endian processors that support misaligned data access, faster
|
||||
methods of doing alpha composition, and more accurate 16-to-8 bit color
|
||||
conversion. Some of these experimental functions, such as the weighted
|
||||
filter heuristics, have since been removed.
|
||||
|
||||
I have included a general makefile, as well as several machine and
|
||||
compiler specific ones, but you may have to modify one for your own
|
||||
needs.
|
||||
Files included in this distribution
|
||||
-----------------------------------
|
||||
|
||||
You should use zlib 1.0.4 or later to run this, but it MAY work with
|
||||
versions as old as zlib 0.95. Even so, there are bugs in older zlib
|
||||
versions which can cause the output of invalid compression streams for
|
||||
some images.
|
||||
|
||||
You should also note that zlib is a compression library that is useful
|
||||
for more things than just PNG files. You can use zlib as a drop-in
|
||||
replacement for fread() and fwrite(), if you are so inclined.
|
||||
|
||||
zlib should be available at the same place that libpng is, or at
|
||||
https://zlib.net.
|
||||
|
||||
You may also want a copy of the PNG specification. It is available
|
||||
as an RFC, a W3C Recommendation, and an ISO/IEC Standard. You can find
|
||||
these at http://www.libpng.org/pub/png/pngdocs.html .
|
||||
|
||||
This code is currently being archived at libpng.sourceforge.io in the
|
||||
[DOWNLOAD] area, and at http://libpng.download/src .
|
||||
|
||||
This release, based in a large way on Glenn's, Guy's and Andreas'
|
||||
earlier work, was created and will be supported by myself and the PNG
|
||||
development group.
|
||||
|
||||
Send comments/corrections/commendations to png-mng-implement at
|
||||
lists.sourceforge.net (subscription required; visit
|
||||
https://lists.sourceforge.net/lists/listinfo/png-mng-implement
|
||||
to subscribe).
|
||||
|
||||
Send general questions about the PNG specification to png-mng-misc
|
||||
at lists.sourceforge.net (subscription required; visit
|
||||
https://lists.sourceforge.net/lists/listinfo/png-mng-misc to
|
||||
subscribe).
|
||||
|
||||
Files in this distribution:
|
||||
|
||||
ANNOUNCE => Announcement of this version, with recent changes
|
||||
AUTHORS => List of contributing authors
|
||||
CHANGES => Description of changes between libpng versions
|
||||
KNOWNBUG => List of known bugs and deficiencies
|
||||
LICENSE => License to use and redistribute libpng
|
||||
README => This file
|
||||
TODO => Things not implemented in the current library
|
||||
TRADEMARK => Trademark information
|
||||
example.c => Example code for using libpng functions
|
||||
libpng.3 => manual page for libpng (includes libpng-manual.txt)
|
||||
libpng-manual.txt => Description of libpng and its functions
|
||||
libpngpf.3 => manual page for libpng's private functions
|
||||
png.5 => manual page for the PNG format
|
||||
png.c => Basic interface functions common to library
|
||||
png.h => Library function and interface declarations (public)
|
||||
pngpriv.h => Library function and interface declarations (private)
|
||||
pngconf.h => System specific library configuration (public)
|
||||
pngstruct.h => png_struct declaration (private)
|
||||
pnginfo.h => png_info struct declaration (private)
|
||||
pngdebug.h => debugging macros (private)
|
||||
pngerror.c => Error/warning message I/O functions
|
||||
pngget.c => Functions for retrieving info from struct
|
||||
pngmem.c => Memory handling functions
|
||||
pngbar.png => PNG logo, 88x31
|
||||
pngnow.png => PNG logo, 98x31
|
||||
pngpread.c => Progressive reading functions
|
||||
pngread.c => Read data/helper high-level functions
|
||||
pngrio.c => Lowest-level data read I/O functions
|
||||
pngrtran.c => Read data transformation functions
|
||||
pngrutil.c => Read data utility functions
|
||||
pngset.c => Functions for storing data into the info_struct
|
||||
pngtest.c => Library test program
|
||||
pngtest.png => Library test sample image
|
||||
pngtrans.c => Common data transformation functions
|
||||
pngwio.c => Lowest-level write I/O functions
|
||||
pngwrite.c => High-level write functions
|
||||
pngwtran.c => Write data transformations
|
||||
pngwutil.c => Write utility functions
|
||||
arm => Contains optimized code for the ARM platform
|
||||
powerpc => Contains optimized code for the PowerPC platform
|
||||
contrib => Contributions
|
||||
arm-neon => Optimized code for ARM-NEON platform
|
||||
powerpc-vsx => Optimized code for POWERPC-VSX platform
|
||||
examples => Example programs
|
||||
gregbook => source code for PNG reading and writing, from
|
||||
Greg Roelofs' "PNG: The Definitive Guide",
|
||||
O'Reilly, 1999
|
||||
libtests => Test programs
|
||||
mips-msa => Optimized code for MIPS-MSA platform
|
||||
pngminim => Minimal decoder, encoder, and progressive decoder
|
||||
programs demonstrating use of pngusr.dfa
|
||||
pngminus => Simple pnm2png and png2pnm programs
|
||||
pngsuite => Test images
|
||||
testpngs
|
||||
tools => Various tools
|
||||
visupng => Contains a MSVC workspace for VisualPng
|
||||
intel => Optimized code for INTEL-SSE2 platform
|
||||
mips => Optimized code for MIPS platform
|
||||
projects => Contains project files and workspaces for
|
||||
building a DLL
|
||||
owatcom => Contains a WATCOM project for building libpng
|
||||
visualc71 => Contains a Microsoft Visual C++ (MSVC)
|
||||
workspace for building libpng and zlib
|
||||
vstudio => Contains a Microsoft Visual C++ (MSVC)
|
||||
workspace for building libpng and zlib
|
||||
scripts => Directory containing scripts for building libpng:
|
||||
(see scripts/README.txt for the list of scripts)
|
||||
ANNOUNCE => Announcement of this version, with recent changes
|
||||
AUTHORS => List of contributing authors
|
||||
CHANGES => Description of changes between libpng versions
|
||||
INSTALL => Instructions to install libpng
|
||||
LICENSE => License to use and redistribute libpng
|
||||
README => This file
|
||||
TODO => Things not implemented in the current library
|
||||
TRADEMARK => Trademark information
|
||||
example.c => Example code for using libpng functions
|
||||
libpng.3 => Manual page for libpng (includes libpng-manual.txt)
|
||||
libpng-manual.txt => Description of libpng and its functions
|
||||
libpngpf.3 => Manual page for libpng's private functions (deprecated)
|
||||
png.5 => Manual page for the PNG format
|
||||
png.c => Basic interface functions common to library
|
||||
png.h => Library function and interface declarations (public)
|
||||
pngpriv.h => Library function and interface declarations (private)
|
||||
pngconf.h => System specific library configuration (public)
|
||||
pngstruct.h => png_struct declaration (private)
|
||||
pnginfo.h => png_info struct declaration (private)
|
||||
pngdebug.h => debugging macros (private)
|
||||
pngerror.c => Error/warning message I/O functions
|
||||
pngget.c => Functions for retrieving info from struct
|
||||
pngmem.c => Memory handling functions
|
||||
pngbar.png => PNG logo, 88x31
|
||||
pngnow.png => PNG logo, 98x31
|
||||
pngpread.c => Progressive reading functions
|
||||
pngread.c => Read data/helper high-level functions
|
||||
pngrio.c => Lowest-level data read I/O functions
|
||||
pngrtran.c => Read data transformation functions
|
||||
pngrutil.c => Read data utility functions
|
||||
pngset.c => Functions for storing data into the info_struct
|
||||
pngtest.c => Library test program
|
||||
pngtest.png => Library test sample image
|
||||
pngtrans.c => Common data transformation functions
|
||||
pngwio.c => Lowest-level write I/O functions
|
||||
pngwrite.c => High-level write functions
|
||||
pngwtran.c => Write data transformations
|
||||
pngwutil.c => Write utility functions
|
||||
arm/ => Optimized code for ARM Neon
|
||||
intel/ => Optimized code for INTEL SSE2
|
||||
loongarch/ => Optimized code for LoongArch LSX
|
||||
mips/ => Optimized code for MIPS MSA and MIPS MMI
|
||||
powerpc/ => Optimized code for PowerPC VSX
|
||||
ci/ => Scripts for continuous integration
|
||||
contrib/ => External contributions
|
||||
arm-neon/ => Optimized code for the ARM-NEON platform
|
||||
mips-msa/ => Optimized code for the MIPS-MSA platform
|
||||
powerpc-vsx/ => Optimized code for the POWERPC-VSX platform
|
||||
examples/ => Examples of libpng usage
|
||||
gregbook/ => Source code for PNG reading and writing, from
|
||||
"PNG: The Definitive Guide" by Greg Roelofs,
|
||||
O'Reilly, 1999
|
||||
libtests/ => Test programs
|
||||
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
|
||||
pngminus/ => Simple pnm2png and png2pnm programs
|
||||
pngsuite/ => Test images
|
||||
testpngs/ => Test images
|
||||
tools/ => Various tools
|
||||
visupng/ => VisualPng, a Windows viewer for PNG images
|
||||
projects/ => Project files and workspaces for various IDEs
|
||||
owatcom/ => OpenWatcom project
|
||||
visualc71/ => Microsoft Visual C++ 7.1 workspace
|
||||
vstudio/ => Microsoft Visual Studio workspace
|
||||
scripts/ => Scripts and makefiles for building libpng
|
||||
(see scripts/README.txt for the complete list)
|
||||
tests/ => Test scripts
|
||||
|
||||
Good luck, and happy coding!
|
||||
|
||||
|
31
3rdparty/libpng/arm/arm_init.c
vendored
31
3rdparty/libpng/arm/arm_init.c
vendored
@ -1,7 +1,7 @@
|
||||
|
||||
/* arm_init.c - NEON optimised filter functions
|
||||
*
|
||||
* Copyright (c) 2018 Cosmin Truta
|
||||
* Copyright (c) 2018-2022 Cosmin Truta
|
||||
* Copyright (c) 2014,2016 Glenn Randers-Pehrson
|
||||
* Written by Mans Rullgard, 2011.
|
||||
*
|
||||
@ -10,9 +10,7 @@
|
||||
* and license in png.h
|
||||
*/
|
||||
|
||||
/* Below, after checking __linux__, various non-C90 POSIX 1003.1 functions are
|
||||
* called.
|
||||
*/
|
||||
/* This module requires POSIX 1003.1 functions. */
|
||||
#define _POSIX_SOURCE 1
|
||||
|
||||
#include "../pngpriv.h"
|
||||
@ -33,21 +31,26 @@
|
||||
* has partial support is contrib/arm-neon/linux.c - a generic Linux
|
||||
* implementation which reads /proc/cpufino.
|
||||
*/
|
||||
#include <signal.h> /* for sig_atomic_t */
|
||||
|
||||
#ifndef PNG_ARM_NEON_FILE
|
||||
# ifdef __linux__
|
||||
# define PNG_ARM_NEON_FILE "contrib/arm-neon/linux.c"
|
||||
# if defined(__aarch64__) || defined(_M_ARM64)
|
||||
/* ARM Neon is expected to be unconditionally available on ARM64. */
|
||||
# error "PNG_ARM_NEON_CHECK_SUPPORTED must not be defined on ARM64"
|
||||
# elif defined(__ARM_NEON__) || defined(__ARM_NEON)
|
||||
/* ARM Neon is expected to be available on the target CPU architecture. */
|
||||
# error "PNG_ARM_NEON_CHECK_SUPPORTED must not be defined on this CPU arch"
|
||||
# elif defined(__linux__)
|
||||
# define PNG_ARM_NEON_FILE "contrib/arm-neon/linux.c"
|
||||
# else
|
||||
# error "No support for run-time ARM Neon checking; use compile-time options"
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef PNG_ARM_NEON_FILE
|
||||
|
||||
#include <signal.h> /* for sig_atomic_t */
|
||||
static int png_have_neon(png_structp png_ptr);
|
||||
#include PNG_ARM_NEON_FILE
|
||||
|
||||
#else /* PNG_ARM_NEON_FILE */
|
||||
# error "PNG_ARM_NEON_FILE undefined: no support for run-time ARM NEON checks"
|
||||
#endif /* PNG_ARM_NEON_FILE */
|
||||
#ifdef PNG_ARM_NEON_FILE
|
||||
# include PNG_ARM_NEON_FILE
|
||||
#endif
|
||||
#endif /* PNG_ARM_NEON_CHECK_SUPPORTED */
|
||||
|
||||
#ifndef PNG_ALIGNED_MEMORY_SUPPORTED
|
||||
|
2
3rdparty/libpng/arm/filter_neon_intrinsics.c
vendored
2
3rdparty/libpng/arm/filter_neon_intrinsics.c
vendored
@ -18,7 +18,7 @@
|
||||
/* This code requires -mfpu=neon on the command line: */
|
||||
#if PNG_ARM_NEON_IMPLEMENTATION == 1 /* intrinsics code from pngpriv.h */
|
||||
|
||||
#if defined(_MSC_VER) && defined(_M_ARM64)
|
||||
#if defined(_MSC_VER) && !defined(__clang__) && defined(_M_ARM64)
|
||||
# include <arm64_neon.h>
|
||||
#else
|
||||
# include <arm_neon.h>
|
||||
|
14
3rdparty/libpng/arm/palette_neon_intrinsics.c
vendored
14
3rdparty/libpng/arm/palette_neon_intrinsics.c
vendored
@ -14,7 +14,7 @@
|
||||
|
||||
#if PNG_ARM_NEON_IMPLEMENTATION == 1
|
||||
|
||||
#if defined(_MSC_VER) && defined(_M_ARM64)
|
||||
#if defined(_MSC_VER) && !defined(__clang__) && defined(_M_ARM64)
|
||||
# include <arm64_neon.h>
|
||||
#else
|
||||
# include <arm_neon.h>
|
||||
@ -30,8 +30,6 @@ png_riffle_palette_neon(png_structrp png_ptr)
|
||||
int num_trans = png_ptr->num_trans;
|
||||
int i;
|
||||
|
||||
png_debug(1, "in png_riffle_palette_neon");
|
||||
|
||||
/* Initially black, opaque. */
|
||||
uint8x16x4_t w = {{
|
||||
vdupq_n_u8(0x00),
|
||||
@ -40,6 +38,8 @@ png_riffle_palette_neon(png_structrp png_ptr)
|
||||
vdupq_n_u8(0xff),
|
||||
}};
|
||||
|
||||
png_debug(1, "in png_riffle_palette_neon");
|
||||
|
||||
/* First, riffle the RGB colours into an RGBA8 palette.
|
||||
* The alpha component is set to opaque for now.
|
||||
*/
|
||||
@ -65,11 +65,12 @@ 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;
|
||||
const png_int_32 pixels_per_chunk = 4;
|
||||
int i;
|
||||
const png_uint_32 pixels_per_chunk = 4;
|
||||
png_uint_32 i;
|
||||
|
||||
png_debug(1, "in png_do_expand_palette_rgba8_neon");
|
||||
|
||||
PNG_UNUSED(row)
|
||||
if (row_width < pixels_per_chunk)
|
||||
return 0;
|
||||
|
||||
@ -109,10 +110,11 @@ png_do_expand_palette_rgb8_neon(png_structrp png_ptr, png_row_infop row_info,
|
||||
png_uint_32 row_width = row_info->width;
|
||||
png_const_bytep palette = (png_const_bytep)png_ptr->palette;
|
||||
const png_uint_32 pixels_per_chunk = 8;
|
||||
int i;
|
||||
png_uint_32 i;
|
||||
|
||||
png_debug(1, "in png_do_expand_palette_rgb8_neon");
|
||||
|
||||
PNG_UNUSED(row)
|
||||
if (row_width <= pixels_per_chunk)
|
||||
return 0;
|
||||
|
||||
|
@ -259,7 +259,7 @@ void png_read_filter_row_paeth3_sse2(png_row_infop row_info, png_bytep row,
|
||||
a = d; d = _mm_unpacklo_epi8(load4(row ), zero);
|
||||
|
||||
/* (p-a) == (a+b-c - a) == (b-c) */
|
||||
|
||||
|
||||
pa = _mm_sub_epi16(b,c);
|
||||
|
||||
/* (p-b) == (a+b-c - b) == (a-c) */
|
||||
|
412
3rdparty/libpng/loongarch/filter_lsx_intrinsics.c
vendored
Normal file
412
3rdparty/libpng/loongarch/filter_lsx_intrinsics.c
vendored
Normal file
@ -0,0 +1,412 @@
|
||||
/* filter_lsx_intrinsics.c - LSX optimized filter functions
|
||||
*
|
||||
* Copyright (c) 2021 Loongson Technology Corporation Limited
|
||||
* All rights reserved.
|
||||
* Copyright (c) 2018 Cosmin Truta
|
||||
* Copyright (c) 2016 Glenn Randers-Pehrson
|
||||
* Contributed by Jin Bo (jinbo@loongson.cn)
|
||||
*
|
||||
* This code is released under the libpng license.
|
||||
* For conditions of distribution and use, see the disclaimer
|
||||
* and license in png.h
|
||||
*/
|
||||
|
||||
#include "../pngpriv.h"
|
||||
|
||||
#ifdef PNG_READ_SUPPORTED
|
||||
|
||||
#if PNG_LOONGARCH_LSX_IMPLEMENTATION == 1 /* intrinsics code from pngpriv.h */
|
||||
|
||||
#include <lsxintrin.h>
|
||||
|
||||
#define LSX_LD(psrc) __lsx_vld((psrc), 0)
|
||||
|
||||
#define LSX_LD_2(psrc, stride, out0, out1) \
|
||||
{ \
|
||||
out0 = LSX_LD(psrc); \
|
||||
out1 = LSX_LD(psrc + stride); \
|
||||
}
|
||||
|
||||
#define LSX_LD_4(psrc, stride, out0, out1, out2, out3) \
|
||||
{ \
|
||||
LSX_LD_2(psrc, stride, out0, out1); \
|
||||
LSX_LD_2(psrc + stride * 2, stride, out2, out3); \
|
||||
}
|
||||
|
||||
#define LSX_ST(in, pdst) __lsx_vst(in, (pdst), 0)
|
||||
|
||||
#define LSX_ST_2(in0, in1, pdst, stride) \
|
||||
{ \
|
||||
LSX_ST(in0, pdst); \
|
||||
LSX_ST(in1, pdst + stride); \
|
||||
}
|
||||
|
||||
#define LSX_ST_4(in0, in1, in2, in3, pdst, stride) \
|
||||
{ \
|
||||
LSX_ST_2(in0, in1, pdst, stride); \
|
||||
LSX_ST_2(in2, in3, pdst + stride * 2, stride); \
|
||||
}
|
||||
|
||||
#define LSX_ADD_B(in0, in1, out0) \
|
||||
{ \
|
||||
out0 = __lsx_vadd_b(in0, in1); \
|
||||
}
|
||||
|
||||
#define LSX_ADD_B_2(in0, in1, in2, in3, out0, out1) \
|
||||
{ \
|
||||
LSX_ADD_B(in0, in1, out0); \
|
||||
LSX_ADD_B(in2, in3, out1); \
|
||||
}
|
||||
|
||||
#define LSX_ADD_B_4(in0, in1, in2, in3, in4, in5, \
|
||||
in6, in7, out0, out1, out2, out3) \
|
||||
{ \
|
||||
LSX_ADD_B_2(in0, in1, in2, in3, out0, out1); \
|
||||
LSX_ADD_B_2(in4, in5, in6, in7, out2, out3); \
|
||||
}
|
||||
|
||||
#define LSX_ABS_B_3(in0, in1, in2, out0, out1, out2) \
|
||||
{ \
|
||||
out0 = __lsx_vadda_h(in0, zero); \
|
||||
out1 = __lsx_vadda_h(in1, zero); \
|
||||
out2 = __lsx_vadda_h(in2, zero); \
|
||||
}
|
||||
|
||||
#define LSX_ILVL_B(in_h, in_l, out0) \
|
||||
{ \
|
||||
out0 = __lsx_vilvl_b(in_h, in_l); \
|
||||
}
|
||||
|
||||
#define LSX_ILVL_B_2(in0_h, in0_l, in1_h, in1_l, out0, out1) \
|
||||
{ \
|
||||
LSX_ILVL_B(in0_h, in0_l, out0); \
|
||||
LSX_ILVL_B(in1_h, in1_l, out1); \
|
||||
}
|
||||
|
||||
#define LSX_HSUB_HU_BU_2(in0, in1, out0, out1) \
|
||||
{ \
|
||||
out0 = __lsx_vhsubw_hu_bu(in0, in0); \
|
||||
out1 = __lsx_vhsubw_hu_bu(in1, in1); \
|
||||
}
|
||||
|
||||
#define LSX_CMP_PICK_SMALLER(in0, in1, in2, in3, in4, in5, out0) \
|
||||
{ \
|
||||
__m128i _cmph, _cmpb, _in0, _in3; \
|
||||
_cmph = __lsx_vslt_h(in1, in0); \
|
||||
_cmpb = __lsx_vpickev_b(_cmph, _cmph); \
|
||||
_in0 = __lsx_vmin_bu(in0,in1); \
|
||||
_in3 = __lsx_vbitsel_v(in3, in4, _cmpb); \
|
||||
_cmph = __lsx_vslt_h(in2, _in0); \
|
||||
_cmpb = __lsx_vpickev_b(_cmph, _cmph); \
|
||||
_in3 = __lsx_vbitsel_v(_in3, in5, _cmpb); \
|
||||
out0 = __lsx_vadd_b(out0, _in3); \
|
||||
}
|
||||
|
||||
void png_read_filter_row_up_lsx(png_row_infop row_info, png_bytep row,
|
||||
png_const_bytep prev_row)
|
||||
{
|
||||
size_t n = row_info->rowbytes;
|
||||
png_bytep rp = row;
|
||||
png_const_bytep pp = prev_row;
|
||||
__m128i vec_0, vec_1, vec_2, vec_3;
|
||||
__m128i vec_4, vec_5, vec_6, vec_7;
|
||||
|
||||
while (n >= 64)
|
||||
{
|
||||
LSX_LD_4(rp, 16, vec_0, vec_1, vec_2, vec_3);
|
||||
LSX_LD_4(pp, 16, vec_4, vec_5, vec_6, vec_7);
|
||||
pp += 64;
|
||||
LSX_ADD_B_4(vec_0 ,vec_4, vec_1, vec_5, vec_2, vec_6,
|
||||
vec_3, vec_7, vec_0, vec_1, vec_2, vec_3);
|
||||
LSX_ST_4(vec_0, vec_1, vec_2, vec_3, rp, 16);
|
||||
rp += 64;
|
||||
n -= 64;
|
||||
}
|
||||
if (n & 63)
|
||||
{
|
||||
if (n >= 32)
|
||||
{
|
||||
LSX_LD_2(rp, 16, vec_0, vec_1);
|
||||
LSX_LD_2(pp, 16, vec_2, vec_3);
|
||||
pp += 32;
|
||||
LSX_ADD_B_2(vec_0, vec_2, vec_1, vec_3, vec_0, vec_1);
|
||||
LSX_ST_2(vec_0, vec_1, rp, 16);
|
||||
rp += 32;
|
||||
n -= 32;
|
||||
}
|
||||
if (n & 31)
|
||||
{
|
||||
if (n >= 16)
|
||||
{
|
||||
vec_0 = LSX_LD(rp);
|
||||
vec_1 = LSX_LD(pp);
|
||||
pp += 16;
|
||||
LSX_ADD_B(vec_0, vec_1, vec_0);
|
||||
LSX_ST(vec_0, rp);
|
||||
rp += 16;
|
||||
n -= 16;
|
||||
}
|
||||
if (n >= 8)
|
||||
{
|
||||
vec_0 = __lsx_vldrepl_d(rp, 0);
|
||||
vec_1 = __lsx_vldrepl_d(pp, 0);
|
||||
vec_0 = __lsx_vadd_b(vec_0, vec_1);
|
||||
__lsx_vstelm_d(vec_0, rp, 0, 0);
|
||||
rp += 8;
|
||||
pp += 8;
|
||||
n -= 8;
|
||||
}
|
||||
while (n--)
|
||||
{
|
||||
*rp = *rp + *pp++;
|
||||
rp++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void png_read_filter_row_sub3_lsx(png_row_infop row_info, png_bytep row,
|
||||
png_const_bytep prev_row)
|
||||
{
|
||||
size_t n = row_info->rowbytes;
|
||||
png_uint_32 tmp;
|
||||
png_bytep nxt = row;
|
||||
__m128i vec_0, vec_1;
|
||||
|
||||
PNG_UNUSED(prev_row);
|
||||
|
||||
vec_0 = __lsx_vldrepl_w(nxt, 0);
|
||||
nxt += 3;
|
||||
n -= 3;
|
||||
|
||||
while (n >= 3)
|
||||
{
|
||||
vec_1 = __lsx_vldrepl_w(nxt, 0);
|
||||
vec_1 = __lsx_vadd_b(vec_1, vec_0);
|
||||
__lsx_vstelm_h(vec_1, nxt, 0, 0);
|
||||
vec_0 = vec_1;
|
||||
nxt += 2;
|
||||
__lsx_vstelm_b(vec_1, nxt, 0, 2);
|
||||
nxt += 1;
|
||||
n -= 3;
|
||||
}
|
||||
|
||||
row = nxt - 3;
|
||||
while (n--)
|
||||
{
|
||||
*nxt = *nxt + *row++;
|
||||
nxt++;
|
||||
}
|
||||
}
|
||||
|
||||
void png_read_filter_row_sub4_lsx(png_row_infop row_info, png_bytep row,
|
||||
png_const_bytep prev_row)
|
||||
{
|
||||
size_t n = row_info->rowbytes;
|
||||
__m128i vec_0, vec_1;
|
||||
|
||||
PNG_UNUSED(prev_row);
|
||||
|
||||
vec_0 = __lsx_vldrepl_w(row, 0);
|
||||
row += 4;
|
||||
n -= 4;
|
||||
|
||||
while (n >= 4)
|
||||
{
|
||||
vec_1 = __lsx_vldrepl_w(row, 0);
|
||||
vec_1 = __lsx_vadd_b(vec_1, vec_0);
|
||||
__lsx_vstelm_w(vec_1, row, 0, 0);
|
||||
vec_0 = vec_1;
|
||||
row += 4;
|
||||
n -= 4;
|
||||
}
|
||||
}
|
||||
|
||||
void png_read_filter_row_avg3_lsx(png_row_infop row_info, png_bytep row,
|
||||
png_const_bytep prev_row)
|
||||
{
|
||||
size_t n = row_info->rowbytes;
|
||||
png_bytep nxt = row;
|
||||
png_const_bytep prev_nxt = prev_row;
|
||||
__m128i vec_0, vec_1, vec_2;
|
||||
|
||||
vec_0 = __lsx_vldrepl_w(nxt, 0);
|
||||
vec_1 = __lsx_vldrepl_w(prev_nxt, 0);
|
||||
prev_nxt += 3;
|
||||
vec_1 = __lsx_vsrli_b(vec_1, 1);
|
||||
vec_1 = __lsx_vadd_b(vec_1, vec_0);
|
||||
__lsx_vstelm_h(vec_1, nxt, 0, 0);
|
||||
nxt += 2;
|
||||
__lsx_vstelm_b(vec_1, nxt, 0, 2);
|
||||
nxt += 1;
|
||||
n -= 3;
|
||||
|
||||
while (n >= 3)
|
||||
{
|
||||
vec_2 = vec_1;
|
||||
vec_0 = __lsx_vldrepl_w(nxt, 0);
|
||||
vec_1 = __lsx_vldrepl_w(prev_nxt, 0);
|
||||
prev_nxt += 3;
|
||||
|
||||
vec_1 = __lsx_vavg_bu(vec_1, vec_2);
|
||||
vec_1 = __lsx_vadd_b(vec_1, vec_0);
|
||||
|
||||
__lsx_vstelm_h(vec_1, nxt, 0, 0);
|
||||
nxt += 2;
|
||||
__lsx_vstelm_b(vec_1, nxt, 0, 2);
|
||||
nxt += 1;
|
||||
n -= 3;
|
||||
}
|
||||
|
||||
row = nxt - 3;
|
||||
while (n--)
|
||||
{
|
||||
vec_2 = __lsx_vldrepl_b(row, 0);
|
||||
row++;
|
||||
vec_0 = __lsx_vldrepl_b(nxt, 0);
|
||||
vec_1 = __lsx_vldrepl_b(prev_nxt, 0);
|
||||
prev_nxt++;
|
||||
|
||||
vec_1 = __lsx_vavg_bu(vec_1, vec_2);
|
||||
vec_1 = __lsx_vadd_b(vec_1, vec_0);
|
||||
|
||||
__lsx_vstelm_b(vec_1, nxt, 0, 0);
|
||||
nxt++;
|
||||
}
|
||||
}
|
||||
|
||||
void png_read_filter_row_avg4_lsx(png_row_infop row_info, png_bytep row,
|
||||
png_const_bytep prev_row)
|
||||
{
|
||||
size_t n = row_info->rowbytes;
|
||||
__m128i vec_0, vec_1, vec_2;
|
||||
|
||||
vec_0 = __lsx_vldrepl_w(row, 0);
|
||||
vec_1 = __lsx_vldrepl_w(prev_row, 0);
|
||||
prev_row += 4;
|
||||
vec_1 = __lsx_vsrli_b(vec_1, 1);
|
||||
vec_1 = __lsx_vadd_b(vec_1, vec_0);
|
||||
__lsx_vstelm_w(vec_1, row, 0, 0);
|
||||
row += 4;
|
||||
n -= 4;
|
||||
|
||||
while (n >= 4)
|
||||
{
|
||||
vec_2 = vec_1;
|
||||
vec_0 = __lsx_vldrepl_w(row, 0);
|
||||
vec_1 = __lsx_vldrepl_w(prev_row, 0);
|
||||
prev_row += 4;
|
||||
|
||||
vec_1 = __lsx_vavg_bu(vec_1, vec_2);
|
||||
vec_1 = __lsx_vadd_b(vec_1, vec_0);
|
||||
|
||||
__lsx_vstelm_w(vec_1, row, 0, 0);
|
||||
row += 4;
|
||||
n -= 4;
|
||||
}
|
||||
}
|
||||
|
||||
void png_read_filter_row_paeth3_lsx(png_row_infop row_info,
|
||||
png_bytep row,
|
||||
png_const_bytep prev_row)
|
||||
{
|
||||
size_t n = row_info->rowbytes;
|
||||
png_bytep nxt = row;
|
||||
png_const_bytep prev_nxt = prev_row;
|
||||
__m128i vec_a, vec_b, vec_c, vec_d;
|
||||
__m128i vec_pa, vec_pb, vec_pc;
|
||||
__m128i zero = {0};
|
||||
|
||||
vec_a = __lsx_vldrepl_w(nxt, 0);
|
||||
vec_b = __lsx_vldrepl_w(prev_nxt, 0);
|
||||
prev_nxt += 3;
|
||||
vec_d = __lsx_vadd_b(vec_a, vec_b);
|
||||
__lsx_vstelm_h(vec_d, nxt, 0, 0);
|
||||
nxt += 2;
|
||||
__lsx_vstelm_b(vec_d, nxt, 0, 2);
|
||||
nxt += 1;
|
||||
n -= 3;
|
||||
|
||||
while (n >= 3)
|
||||
{
|
||||
vec_a = vec_d;
|
||||
vec_c = vec_b;
|
||||
vec_b = __lsx_vldrepl_w(prev_nxt, 0);
|
||||
prev_nxt += 3;
|
||||
vec_d = __lsx_vldrepl_w(nxt, 0);
|
||||
|
||||
LSX_ILVL_B_2(vec_b, vec_c, vec_a, vec_c, vec_pa, vec_pb);
|
||||
LSX_HSUB_HU_BU_2(vec_pa, vec_pb, vec_pa, vec_pb);
|
||||
vec_pc = __lsx_vadd_h(vec_pa, vec_pb);
|
||||
LSX_ABS_B_3(vec_pa, vec_pb, vec_pc, vec_pa, vec_pb, vec_pc);
|
||||
LSX_CMP_PICK_SMALLER(vec_pa, vec_pb, vec_pc, vec_a, vec_b, vec_c, vec_d);
|
||||
|
||||
__lsx_vstelm_h(vec_d, nxt, 0, 0);
|
||||
nxt += 2;
|
||||
__lsx_vstelm_b(vec_d, nxt, 0, 2);
|
||||
nxt += 1;
|
||||
n -= 3;
|
||||
}
|
||||
|
||||
prev_row = prev_nxt - 3;
|
||||
row = nxt - 3;
|
||||
while (n--)
|
||||
{
|
||||
vec_a = __lsx_vldrepl_b(row, 0);
|
||||
row++;
|
||||
vec_b = __lsx_vldrepl_b(prev_nxt, 0);
|
||||
prev_nxt++;
|
||||
vec_c = __lsx_vldrepl_b(prev_row, 0);
|
||||
prev_row++;
|
||||
vec_d = __lsx_vldrepl_b(nxt, 0);
|
||||
|
||||
LSX_ILVL_B_2(vec_b, vec_c, vec_a, vec_c, vec_pa, vec_pb);
|
||||
LSX_HSUB_HU_BU_2(vec_pa, vec_pb, vec_pa, vec_pb);
|
||||
vec_pc = __lsx_vadd_h(vec_pa, vec_pb);
|
||||
LSX_ABS_B_3(vec_pa, vec_pb, vec_pc, vec_pa, vec_pb, vec_pc);
|
||||
LSX_CMP_PICK_SMALLER(vec_pa, vec_pb, vec_pc, vec_a, vec_b, vec_c, vec_d);
|
||||
|
||||
__lsx_vstelm_b(vec_d, nxt, 0, 0);
|
||||
nxt++;
|
||||
}
|
||||
}
|
||||
|
||||
void png_read_filter_row_paeth4_lsx(png_row_infop row_info,
|
||||
png_bytep row,
|
||||
png_const_bytep prev_row)
|
||||
{
|
||||
size_t n = row_info->rowbytes;
|
||||
__m128i vec_a, vec_b, vec_c, vec_d;
|
||||
__m128i vec_pa, vec_pb, vec_pc;
|
||||
__m128i zero = {0};
|
||||
|
||||
vec_a = __lsx_vldrepl_w(row, 0);
|
||||
vec_b = __lsx_vldrepl_w(prev_row, 0);
|
||||
prev_row += 4;
|
||||
vec_d = __lsx_vadd_b(vec_a, vec_b);
|
||||
__lsx_vstelm_w(vec_d, row, 0, 0);
|
||||
row += 4;
|
||||
n -= 4;
|
||||
|
||||
while (n >= 4)
|
||||
{
|
||||
vec_a = vec_d;
|
||||
vec_c = vec_b;
|
||||
vec_b = __lsx_vldrepl_w(prev_row, 0);
|
||||
prev_row += 4;
|
||||
vec_d = __lsx_vldrepl_w(row, 0);
|
||||
|
||||
LSX_ILVL_B_2(vec_b, vec_c, vec_a, vec_c, vec_pa, vec_pb);
|
||||
LSX_HSUB_HU_BU_2(vec_pa, vec_pb, vec_pa, vec_pb);
|
||||
vec_pc = __lsx_vadd_h(vec_pa, vec_pb);
|
||||
LSX_ABS_B_3(vec_pa, vec_pb, vec_pc, vec_pa, vec_pb, vec_pc);
|
||||
LSX_CMP_PICK_SMALLER(vec_pa, vec_pb, vec_pc, vec_a, vec_b, vec_c, vec_d);
|
||||
|
||||
__lsx_vstelm_w(vec_d, row, 0, 0);
|
||||
row += 4;
|
||||
n -= 4;
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* PNG_LOONGARCH_LSX_IMPLEMENTATION == 1 (intrinsics) */
|
||||
#endif /* PNG_READ_SUPPORTED */
|
65
3rdparty/libpng/loongarch/loongarch_lsx_init.c
vendored
Normal file
65
3rdparty/libpng/loongarch/loongarch_lsx_init.c
vendored
Normal file
@ -0,0 +1,65 @@
|
||||
/* loongarch_lsx_init.c - LSX optimized filter functions
|
||||
*
|
||||
* Copyright (c) 2021 Loongson Technology Corporation Limited
|
||||
* All rights reserved.
|
||||
* Contributed by Jin Bo <jinbo@loongson.cn>
|
||||
*
|
||||
* This code is released under the libpng license.
|
||||
* For conditions of distribution and use, see the disclaimer
|
||||
* and license in png.h
|
||||
*/
|
||||
|
||||
#include "../pngpriv.h"
|
||||
|
||||
#ifdef PNG_READ_SUPPORTED
|
||||
#if PNG_LOONGARCH_LSX_IMPLEMENTATION == 1
|
||||
|
||||
#include <sys/auxv.h>
|
||||
|
||||
#define LA_HWCAP_LSX (1<<4)
|
||||
static int png_has_lsx(void)
|
||||
{
|
||||
int flags = 0;
|
||||
int flag = (int)getauxval(AT_HWCAP);
|
||||
|
||||
if (flag & LA_HWCAP_LSX)
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
png_init_filter_functions_lsx(png_structp pp, unsigned int bpp)
|
||||
{
|
||||
/* IMPORTANT: any new external functions used here must be declared using
|
||||
* PNG_INTERNAL_FUNCTION in ../pngpriv.h. This is required so that the
|
||||
* 'prefix' option to configure works:
|
||||
*
|
||||
* ./configure --with-libpng-prefix=foobar_
|
||||
*
|
||||
* Verify you have got this right by running the above command, doing a build
|
||||
* and examining pngprefix.h; it must contain a #define for every external
|
||||
* function you add. (Notice that this happens automatically for the
|
||||
* initialization function.)
|
||||
*/
|
||||
|
||||
if (png_has_lsx())
|
||||
{
|
||||
pp->read_filter[PNG_FILTER_VALUE_UP-1] = png_read_filter_row_up_lsx;
|
||||
if (bpp == 3)
|
||||
{
|
||||
pp->read_filter[PNG_FILTER_VALUE_SUB-1] = png_read_filter_row_sub3_lsx;
|
||||
pp->read_filter[PNG_FILTER_VALUE_AVG-1] = png_read_filter_row_avg3_lsx;
|
||||
pp->read_filter[PNG_FILTER_VALUE_PAETH-1] = png_read_filter_row_paeth3_lsx;
|
||||
}
|
||||
else if (bpp == 4)
|
||||
{
|
||||
pp->read_filter[PNG_FILTER_VALUE_SUB-1] = png_read_filter_row_sub4_lsx;
|
||||
pp->read_filter[PNG_FILTER_VALUE_AVG-1] = png_read_filter_row_avg4_lsx;
|
||||
pp->read_filter[PNG_FILTER_VALUE_PAETH-1] = png_read_filter_row_paeth4_lsx;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* PNG_LOONGARCH_LSX_IMPLEMENTATION == 1 */
|
||||
#endif /* PNG_READ_SUPPORTED */
|
525
3rdparty/libpng/mips/filter_mmi_inline_assembly.c
vendored
Normal file
525
3rdparty/libpng/mips/filter_mmi_inline_assembly.c
vendored
Normal file
@ -0,0 +1,525 @@
|
||||
/* filter_mmi_intrinsics.c - MMI optimized filter functions
|
||||
*
|
||||
* Copyright (c) 2024 Cosmin Truta
|
||||
* Written by zhanglixia and guxiwei, 2023
|
||||
*
|
||||
* This code is released under the libpng license.
|
||||
* For conditions of distribution and use, see the disclaimer
|
||||
* and license in png.h
|
||||
*/
|
||||
|
||||
#include "../pngpriv.h"
|
||||
|
||||
#ifdef PNG_READ_SUPPORTED
|
||||
|
||||
#if PNG_MIPS_MMI_IMPLEMENTATION == 2 /* Inline Assembly */
|
||||
|
||||
/* Functions in this file look at most 3 pixels (a,b,c) to predict the 4th (d).
|
||||
* They're positioned like this:
|
||||
* prev: c b
|
||||
* row: a d
|
||||
* The Sub filter predicts d=a, Avg d=(a+b)/2, and Paeth predicts d to be
|
||||
* whichever of a, b, or c is closest to p=a+b-c.
|
||||
*/
|
||||
|
||||
void png_read_filter_row_up_mmi(png_row_infop row_info, png_bytep row,
|
||||
png_const_bytep prev_row)
|
||||
{
|
||||
int istop = row_info->rowbytes;
|
||||
double rp,pp;
|
||||
__asm__ volatile (
|
||||
"1: \n\t"
|
||||
"ldc1 %[rp], 0x00(%[row]) \n\t"
|
||||
"ldc1 %[pp], 0x00(%[prev_row]) \n\t"
|
||||
"paddb %[rp], %[rp], %[pp] \n\t"
|
||||
"sdc1 %[rp], 0x00(%[row]) \n\t"
|
||||
|
||||
"daddiu %[row], %[row], 0x08 \n\t"
|
||||
"daddiu %[prev_row], %[prev_row], 0x08 \n\t"
|
||||
"daddiu %[istop], %[istop], -0x08 \n\t"
|
||||
"bgtz %[istop], 1b \n\t"
|
||||
: [rp]"=&f"(rp), [pp]"=&f"(pp)
|
||||
: [row]"r"(row), [prev_row]"r"(prev_row),
|
||||
[istop]"r"(istop)
|
||||
: "memory"
|
||||
);
|
||||
}
|
||||
|
||||
void png_read_filter_row_sub3_mmi(png_row_infop row_info, png_bytep row,
|
||||
png_const_bytep prev)
|
||||
{
|
||||
int istop = row_info->rowbytes;
|
||||
double rp, pp, dest;
|
||||
double eight, sixteen, twenty_four, forty_eight;
|
||||
double tmp0;
|
||||
double ftmp[2];
|
||||
|
||||
__asm__ volatile (
|
||||
"li %[tmp0], 0x08 \n\t"
|
||||
"dmtc1 %[tmp0], %[eight] \n\t"
|
||||
"li %[tmp0], 0x10 \n\t"
|
||||
"dmtc1 %[tmp0], %[sixteen] \n\t"
|
||||
"li %[tmp0], 0x18 \n\t"
|
||||
"dmtc1 %[tmp0], %[twenty_four] \n\t"
|
||||
"li %[tmp0], 0x30 \n\t"
|
||||
"dmtc1 %[tmp0], %[forty_eight] \n\t"
|
||||
"xor %[dest], %[dest], %[dest] \n\t"
|
||||
|
||||
"1: \n\t"
|
||||
"gsldrc1 %[rp], 0x00(%[row]) \n\t"
|
||||
"gsldlc1 %[rp], 0x07(%[row]) \n\t"
|
||||
"gsldrc1 %[pp], 0x08(%[row]) \n\t"
|
||||
"gsldlc1 %[pp], 0x0f(%[row]) \n\t"
|
||||
|
||||
"paddb %[ftmp0], %[dest], %[rp] \n\t"
|
||||
"swc1 %[ftmp0], 0x00(%[row]) \n\t"
|
||||
|
||||
"dsrl %[ftmp1], %[rp], %[twenty_four] \n\t"
|
||||
"paddb %[dest], %[ftmp1], %[ftmp0] \n\t"
|
||||
"gsswrc1 %[dest], 0x03(%[row]) \n\t"
|
||||
"gsswlc1 %[dest], 0x06(%[row]) \n\t"
|
||||
|
||||
"dsrl %[ftmp0], %[rp], %[forty_eight] \n\t"
|
||||
"dsll %[ftmp1], %[pp], %[sixteen] \n\t"
|
||||
"or %[ftmp0], %[ftmp0], %[ftmp1] \n\t"
|
||||
"paddb %[dest], %[dest], %[ftmp0] \n\t"
|
||||
"gsswrc1 %[dest], 0x06(%[row]) \n\t"
|
||||
"gsswlc1 %[dest], 0x09(%[row]) \n\t"
|
||||
|
||||
"dsrl %[ftmp0], %[pp], %[eight] \n\t"
|
||||
"paddb %[dest], %[dest], %[ftmp0] \n\t"
|
||||
"gsswrc1 %[dest], 0x09(%[row]) \n\t"
|
||||
"daddiu %[row], %[row], 0x0c \n\t"
|
||||
"daddiu %[istop], %[istop], -0x0c \n\t"
|
||||
"bgtz %[istop], 1b \n\t"
|
||||
: [rp]"=&f"(rp), [pp]"=&f"(pp), [dest]"=&f"(dest),
|
||||
[tmp0]"=&r"(tmp0), [ftmp0]"=&f"(ftmp[0]),
|
||||
[ftmp1]"=&f"(ftmp[1]), [eight]"=&f"(eight),
|
||||
[sixteen]"=&f"(sixteen), [twenty_four]"=&f"(twenty_four),
|
||||
[forty_eight]"=&f"(forty_eight)
|
||||
: [row]"r"(row), [istop]"r"(istop)
|
||||
: "memory"
|
||||
);
|
||||
|
||||
PNG_UNUSED(prev)
|
||||
}
|
||||
|
||||
void png_read_filter_row_sub4_mmi(png_row_infop row_info, png_bytep row,
|
||||
png_const_bytep prev)
|
||||
{
|
||||
/* The Sub filter predicts each pixel as the previous pixel, a.
|
||||
* There is no pixel to the left of the first pixel. It's encoded directly.
|
||||
* That works with our main loop if we just say that left pixel was zero.
|
||||
*/
|
||||
int istop = row_info->rowbytes;
|
||||
double rp,pp;
|
||||
|
||||
__asm__ volatile (
|
||||
"1: \n\t"
|
||||
"lwc1 %[pp], 0x00(%[row]) \n\t"
|
||||
"lwc1 %[rp], 0x04(%[row]) \n\t"
|
||||
"paddb %[rp], %[rp], %[pp] \n\t"
|
||||
"swc1 %[rp], 0x04(%[row]) \n\t"
|
||||
|
||||
"daddiu %[row], %[row], 0x04 \n\t"
|
||||
"daddiu %[istop], %[istop], -0x04 \n\t"
|
||||
"bgtz %[istop], 1b \n\t"
|
||||
: [rp]"=&f"(rp), [pp]"=&f"(pp)
|
||||
: [row]"r"(row), [istop]"r"(istop)
|
||||
: "memory"
|
||||
);
|
||||
|
||||
PNG_UNUSED(prev)
|
||||
}
|
||||
|
||||
void png_read_filter_row_avg3_mmi(png_row_infop row_info, png_bytep row,
|
||||
png_const_bytep prev)
|
||||
{
|
||||
int istop = row_info->rowbytes;
|
||||
double rp, pp, rp1, pp1;
|
||||
double tmp0;
|
||||
double ftmp[3];
|
||||
double one, dest;
|
||||
double eight, sixteen, twenty_four, forty_eight;
|
||||
|
||||
__asm__ volatile (
|
||||
"li %[tmp0], 0x08 \n\t"
|
||||
"dmtc1 %[tmp0], %[eight] \n\t"
|
||||
"li %[tmp0], 0x10 \n\t"
|
||||
"dmtc1 %[tmp0], %[sixteen] \n\t"
|
||||
"li %[tmp0], 0x18 \n\t"
|
||||
"dmtc1 %[tmp0], %[twenty_four] \n\t"
|
||||
"li %[tmp0], 0x30 \n\t"
|
||||
"dmtc1 %[tmp0], %[forty_eight] \n\t"
|
||||
"xor %[dest], %[dest], %[dest] \n\t"
|
||||
|
||||
"li %[tmp0], 0x01 \n\t"
|
||||
"ins %[tmp0], %[tmp0], 8, 8 \n\t"
|
||||
"dmtc1 %[tmp0], %[one] \n\t"
|
||||
"pshufh %[one], %[one], %[dest] \n\t"
|
||||
|
||||
"1: \n\t"
|
||||
"gsldrc1 %[rp], 0x00(%[row]) \n\t"
|
||||
"gsldlc1 %[rp], 0x07(%[row]) \n\t"
|
||||
"gsldrc1 %[pp], 0x00(%[prev]) \n\t"
|
||||
"gsldlc1 %[pp], 0x07(%[prev]) \n\t"
|
||||
"gsldrc1 %[rp1], 0x08(%[row]) \n\t"
|
||||
"gsldlc1 %[rp1], 0x0f(%[row]) \n\t"
|
||||
"gsldrc1 %[pp1], 0x08(%[prev]) \n\t"
|
||||
"gsldlc1 %[pp1], 0x0f(%[prev]) \n\t"
|
||||
|
||||
"xor %[ftmp0], %[pp], %[dest] \n\t"
|
||||
"pavgb %[ftmp1], %[pp], %[dest] \n\t"
|
||||
"and %[ftmp0], %[ftmp0], %[one] \n\t"
|
||||
"psubb %[ftmp1], %[ftmp1], %[ftmp0] \n\t"
|
||||
"paddb %[dest], %[rp], %[ftmp1] \n\t"
|
||||
"swc1 %[dest], 0x00(%[row]) \n\t"
|
||||
|
||||
"dsrl %[ftmp0], %[rp], %[twenty_four] \n\t"
|
||||
"dsrl %[ftmp1], %[pp], %[twenty_four] \n\t"
|
||||
|
||||
"xor %[ftmp2], %[ftmp1], %[dest] \n\t"
|
||||
"pavgb %[ftmp1], %[ftmp1], %[dest] \n\t"
|
||||
"and %[ftmp2], %[ftmp2], %[one] \n\t"
|
||||
"psubb %[ftmp1], %[ftmp1], %[ftmp2] \n\t"
|
||||
"paddb %[dest], %[ftmp0], %[ftmp1] \n\t"
|
||||
"gsswrc1 %[dest], 0x03(%[row]) \n\t"
|
||||
"gsswlc1 %[dest], 0x06(%[row]) \n\t"
|
||||
|
||||
"dsrl %[ftmp0], %[rp], %[forty_eight] \n\t"
|
||||
"dsll %[ftmp1], %[rp1], %[sixteen] \n\t"
|
||||
"or %[ftmp0], %[ftmp0], %[ftmp1] \n\t"
|
||||
"dsrl %[ftmp2], %[pp], %[forty_eight] \n\t"
|
||||
"dsll %[ftmp1], %[pp1], %[sixteen] \n\t"
|
||||
"or %[ftmp1], %[ftmp2], %[ftmp1] \n\t"
|
||||
|
||||
"xor %[ftmp2], %[ftmp1], %[dest] \n\t"
|
||||
"pavgb %[ftmp1], %[ftmp1], %[dest] \n\t"
|
||||
"and %[ftmp2], %[ftmp2], %[one] \n\t"
|
||||
"psubb %[ftmp1], %[ftmp1], %[ftmp2] \n\t"
|
||||
"paddb %[dest], %[ftmp0], %[ftmp1] \n\t"
|
||||
"gsswrc1 %[dest], 0x06(%[row]) \n\t"
|
||||
"gsswlc1 %[dest], 0x09(%[row]) \n\t"
|
||||
|
||||
"dsrl %[ftmp0], %[rp1], %[eight] \n\t"
|
||||
"dsrl %[ftmp1], %[pp1], %[eight] \n\t"
|
||||
|
||||
"xor %[ftmp2], %[ftmp1], %[dest] \n\t"
|
||||
"pavgb %[ftmp1], %[ftmp1], %[dest] \n\t"
|
||||
"and %[ftmp2], %[ftmp2], %[one] \n\t"
|
||||
"psubb %[ftmp1], %[ftmp1], %[ftmp2] \n\t"
|
||||
"paddb %[dest], %[ftmp0], %[ftmp1] \n\t"
|
||||
"gsswrc1 %[dest], 0x09(%[row]) \n\t"
|
||||
"daddiu %[row], %[row], 0x0c \n\t"
|
||||
"daddiu %[prev], %[prev], 0x0c \n\t"
|
||||
"daddiu %[istop], %[istop], -0x0c \n\t"
|
||||
"bgtz %[istop], 1b \n\t"
|
||||
: [rp]"=&f"(rp), [pp]"=&f"(pp), [rp1]"=&f"(rp1),
|
||||
[pp1]"=&f"(pp1), [tmp0]"=&r"(tmp0), [ftmp0]"=&f"(ftmp[0]),
|
||||
[ftmp1]"=&f"(ftmp[1]), [ftmp2]"=&f"(ftmp[2]), [one]"=&f"(one),
|
||||
[dest]"=&f"(dest), [eight]"=&f"(eight), [sixteen]"=&f"(sixteen),
|
||||
[twenty_four]"=&f"(twenty_four), [forty_eight]"=&f"(forty_eight)
|
||||
: [row]"r"(row), [prev]"r"(prev), [istop]"r"(istop)
|
||||
: "memory"
|
||||
);
|
||||
}
|
||||
|
||||
void png_read_filter_row_avg4_mmi(png_row_infop row_info, png_bytep row,
|
||||
png_const_bytep prev)
|
||||
{
|
||||
int istop = row_info->rowbytes;
|
||||
double rp,pp;
|
||||
double dest;
|
||||
double ftmp[2];
|
||||
double tmp;
|
||||
|
||||
__asm__ volatile (
|
||||
"xor %[dest], %[dest], %[dest] \n\t"
|
||||
"li %[tmp], 0x01 \n\t"
|
||||
"ins %[tmp], %[tmp], 8, 8 \n\t"
|
||||
"dmtc1 %[tmp], %[ftmp1] \n\t"
|
||||
"pshufh %[ftmp1], %[ftmp1], %[dest] \n\t"
|
||||
|
||||
"1: \n\t"
|
||||
"lwc1 %[rp], 0x00(%[row]) \n\t"
|
||||
"lwc1 %[pp], 0x00(%[prev]) \n\t"
|
||||
"xor %[ftmp0], %[pp], %[dest] \n\t"
|
||||
"pavgb %[pp], %[pp], %[dest] \n\t"
|
||||
"and %[ftmp0], %[ftmp0], %[ftmp1] \n\t"
|
||||
"psubb %[pp], %[pp], %[ftmp0] \n\t"
|
||||
"paddb %[dest], %[rp], %[pp] \n\t"
|
||||
"swc1 %[dest], 0x00(%[row]) \n\t"
|
||||
"daddiu %[row], %[row], 0x04 \n\t"
|
||||
"daddiu %[prev], %[prev], 0x04 \n\t"
|
||||
"daddiu %[istop], %[istop], -0x04 \n\t"
|
||||
"bgtz %[istop], 1b \n\t"
|
||||
: [rp]"=&f"(rp), [pp]"=&f"(pp), [ftmp0]"=&f"(ftmp[0]),
|
||||
[ftmp1]"=&f"(ftmp[1]), [dest]"=&f"(dest), [tmp]"=&r"(tmp)
|
||||
: [row]"r"(row), [prev]"r"(prev), [istop]"r"(istop)
|
||||
: "memory"
|
||||
);
|
||||
}
|
||||
|
||||
void png_read_filter_row_paeth3_mmi(png_row_infop row_info, png_bytep row,
|
||||
png_const_bytep prev)
|
||||
{
|
||||
/* Paeth tries to predict pixel d using the pixel to the left of it, a,
|
||||
* and two pixels from the previous row, b and c:
|
||||
* prev: c b
|
||||
* row: a d
|
||||
* The Paeth function predicts d to be whichever of a, b, or c is nearest to
|
||||
* p=a+b-c.
|
||||
*
|
||||
* The first pixel has no left context, and so uses an Up filter, p = b.
|
||||
* This works naturally with our main loop's p = a+b-c if we force a and c
|
||||
* to zero.
|
||||
* Here we zero b and d, which become c and a respectively at the start of
|
||||
* the loop.
|
||||
*/
|
||||
int istop = row_info->rowbytes;
|
||||
double rp, pp, rp1, pp1, zero;
|
||||
double a, b, c, d, pa, pb, pc;
|
||||
double tmp0;
|
||||
double ftmp[3];
|
||||
double eight, sixteen, twenty_four, forty_eight;
|
||||
|
||||
__asm__ volatile (
|
||||
"xor %[a], %[a], %[a] \n\t"
|
||||
"xor %[c], %[c], %[c] \n\t"
|
||||
"xor %[zero], %[zero], %[zero] \n\t"
|
||||
"li %[tmp0], 0x08 \n\t"
|
||||
"dmtc1 %[tmp0], %[eight] \n\t"
|
||||
"li %[tmp0], 0x10 \n\t"
|
||||
"dmtc1 %[tmp0], %[sixteen] \n\t"
|
||||
"li %[tmp0], 0x18 \n\t"
|
||||
"dmtc1 %[tmp0], %[twenty_four] \n\t"
|
||||
"li %[tmp0], 0x30 \n\t"
|
||||
"dmtc1 %[tmp0], %[forty_eight] \n\t"
|
||||
|
||||
"1: \n\t"
|
||||
"gsldrc1 %[rp], 0x00(%[row]) \n\t"
|
||||
"gsldlc1 %[rp], 0x07(%[row]) \n\t"
|
||||
"gsldrc1 %[pp], 0x00(%[prev]) \n\t"
|
||||
"gsldlc1 %[pp], 0x07(%[prev]) \n\t"
|
||||
"gsldrc1 %[rp1], 0x08(%[row]) \n\t"
|
||||
"gsldlc1 %[rp1], 0x0f(%[row]) \n\t"
|
||||
"gsldrc1 %[pp1], 0x08(%[prev]) \n\t"
|
||||
"gsldlc1 %[pp1], 0x0f(%[prev]) \n\t"
|
||||
|
||||
"punpcklbh %[b], %[pp], %[zero] \n\t"
|
||||
"punpcklbh %[d], %[rp], %[zero] \n\t"
|
||||
"packushb %[ftmp0], %[c], %[c] \n\t"
|
||||
"packushb %[ftmp1], %[a], %[a] \n\t"
|
||||
"pasubub %[pa], %[pp], %[ftmp0] \n\t"
|
||||
"pasubub %[pb], %[ftmp1], %[ftmp0] \n\t"
|
||||
"psubh %[ftmp0], %[b], %[c] \n\t"
|
||||
"psubh %[ftmp1], %[a], %[c] \n\t"
|
||||
"paddh %[pc], %[ftmp0], %[ftmp1] \n\t"
|
||||
"pcmpgth %[ftmp0], %[zero], %[pc] \n\t"
|
||||
"xor %[pc], %[pc], %[ftmp0] \n\t"
|
||||
"psubh %[pc], %[pc], %[ftmp0] \n\t"
|
||||
"punpcklbh %[pa], %[pa], %[zero] \n\t"
|
||||
"punpcklbh %[pb], %[pb], %[zero] \n\t"
|
||||
"pcmpgth %[ftmp0], %[pa], %[pb] \n\t"
|
||||
"and %[ftmp1], %[b], %[ftmp0] \n\t"
|
||||
"pandn %[a], %[ftmp0], %[a] \n\t"
|
||||
"or %[a], %[a], %[ftmp1] \n\t"
|
||||
"pminsh %[pa], %[pa], %[pb] \n\t"
|
||||
"pcmpgth %[ftmp0], %[pa], %[pc] \n\t"
|
||||
"and %[ftmp1], %[c], %[ftmp0] \n\t"
|
||||
"pandn %[a], %[ftmp0], %[a] \n\t"
|
||||
"or %[a], %[a], %[ftmp1] \n\t"
|
||||
"paddb %[a], %[a], %[d] \n\t"
|
||||
"packushb %[d], %[a], %[a] \n\t"
|
||||
"punpcklbh %[c], %[pp], %[zero] \n\t"
|
||||
"swc1 %[d], 0x00(%[row]) \n\t"
|
||||
|
||||
"dsrl %[ftmp0], %[rp], %[twenty_four] \n\t"
|
||||
"dsrl %[ftmp2], %[pp], %[twenty_four] \n\t"
|
||||
|
||||
"punpcklbh %[b], %[ftmp2], %[zero] \n\t"
|
||||
"punpcklbh %[d], %[ftmp0], %[zero] \n\t"
|
||||
"packushb %[ftmp0], %[c], %[c] \n\t"
|
||||
"packushb %[ftmp1], %[a], %[a] \n\t"
|
||||
"pasubub %[pa], %[ftmp2], %[ftmp0] \n\t"
|
||||
"pasubub %[pb], %[ftmp1], %[ftmp0] \n\t"
|
||||
"psubh %[ftmp0], %[b], %[c] \n\t"
|
||||
"psubh %[ftmp1], %[a], %[c] \n\t"
|
||||
"paddh %[pc], %[ftmp0], %[ftmp1] \n\t"
|
||||
"pcmpgth %[ftmp0], %[zero], %[pc] \n\t"
|
||||
"xor %[pc], %[pc], %[ftmp0] \n\t"
|
||||
"psubh %[pc], %[pc], %[ftmp0] \n\t"
|
||||
"punpcklbh %[pa], %[pa], %[zero] \n\t"
|
||||
"punpcklbh %[pb], %[pb], %[zero] \n\t"
|
||||
"pcmpgth %[ftmp0], %[pa], %[pb] \n\t"
|
||||
"and %[ftmp1], %[b], %[ftmp0] \n\t"
|
||||
"pandn %[a], %[ftmp0], %[a] \n\t"
|
||||
"or %[a], %[a], %[ftmp1] \n\t"
|
||||
"pminsh %[pa], %[pa], %[pb] \n\t"
|
||||
"pcmpgth %[ftmp0], %[pa], %[pc] \n\t"
|
||||
"and %[ftmp1], %[c], %[ftmp0] \n\t"
|
||||
"pandn %[a], %[ftmp0], %[a] \n\t"
|
||||
"or %[a], %[a], %[ftmp1] \n\t"
|
||||
"paddb %[a], %[a], %[d] \n\t"
|
||||
"packushb %[d], %[a], %[a] \n\t"
|
||||
"punpcklbh %[c], %[ftmp2], %[zero] \n\t"
|
||||
"gsswrc1 %[d], 0x03(%[row]) \n\t"
|
||||
"gsswlc1 %[d], 0x06(%[row]) \n\t"
|
||||
|
||||
"dsrl %[ftmp0], %[rp], %[forty_eight] \n\t"
|
||||
"dsll %[ftmp1], %[rp1], %[sixteen] \n\t"
|
||||
"or %[ftmp0], %[ftmp0], %[ftmp1] \n\t"
|
||||
"dsrl %[ftmp2], %[pp], %[forty_eight] \n\t"
|
||||
"dsll %[ftmp1], %[pp1], %[sixteen] \n\t"
|
||||
"or %[ftmp2], %[ftmp2], %[ftmp1] \n\t"
|
||||
|
||||
"punpcklbh %[b], %[ftmp2], %[zero] \n\t"
|
||||
"punpcklbh %[d], %[ftmp0], %[zero] \n\t"
|
||||
"packushb %[ftmp0], %[c], %[c] \n\t"
|
||||
"packushb %[ftmp1], %[a], %[a] \n\t"
|
||||
"pasubub %[pa], %[ftmp2], %[ftmp0] \n\t"
|
||||
"pasubub %[pb], %[ftmp1], %[ftmp0] \n\t"
|
||||
"psubh %[ftmp0], %[b], %[c] \n\t"
|
||||
"psubh %[ftmp1], %[a], %[c] \n\t"
|
||||
"paddh %[pc], %[ftmp0], %[ftmp1] \n\t"
|
||||
"pcmpgth %[ftmp0], %[zero], %[pc] \n\t"
|
||||
"xor %[pc], %[pc], %[ftmp0] \n\t"
|
||||
"psubh %[pc], %[pc], %[ftmp0] \n\t"
|
||||
"punpcklbh %[pa], %[pa], %[zero] \n\t"
|
||||
"punpcklbh %[pb], %[pb], %[zero] \n\t"
|
||||
"pcmpgth %[ftmp0], %[pa], %[pb] \n\t"
|
||||
"and %[ftmp1], %[b], %[ftmp0] \n\t"
|
||||
"pandn %[a], %[ftmp0], %[a] \n\t"
|
||||
"or %[a], %[a], %[ftmp1] \n\t"
|
||||
"pminsh %[pa], %[pa], %[pb] \n\t"
|
||||
"pcmpgth %[ftmp0], %[pa], %[pc] \n\t"
|
||||
"and %[ftmp1], %[c], %[ftmp0] \n\t"
|
||||
"pandn %[a], %[ftmp0], %[a] \n\t"
|
||||
"or %[a], %[a], %[ftmp1] \n\t"
|
||||
"paddb %[a], %[a], %[d] \n\t"
|
||||
"packushb %[d], %[a], %[a] \n\t"
|
||||
"punpcklbh %[c], %[ftmp2], %[zero] \n\t"
|
||||
"gsswrc1 %[d], 0x06(%[row]) \n\t"
|
||||
"gsswlc1 %[d], 0x09(%[row]) \n\t"
|
||||
|
||||
"dsrl %[ftmp0], %[rp1], %[eight] \n\t"
|
||||
"dsrl %[ftmp2], %[pp1], %[eight] \n\t"
|
||||
|
||||
"punpcklbh %[b], %[ftmp2], %[zero] \n\t"
|
||||
"punpcklbh %[d], %[ftmp0], %[zero] \n\t"
|
||||
"packushb %[ftmp0], %[c], %[c] \n\t"
|
||||
"packushb %[ftmp1], %[a], %[a] \n\t"
|
||||
"pasubub %[pa], %[ftmp2], %[ftmp0] \n\t"
|
||||
"pasubub %[pb], %[ftmp1], %[ftmp0] \n\t"
|
||||
"psubh %[ftmp0], %[b], %[c] \n\t"
|
||||
"psubh %[ftmp1], %[a], %[c] \n\t"
|
||||
"paddh %[pc], %[ftmp0], %[ftmp1] \n\t"
|
||||
"pcmpgth %[ftmp0], %[zero], %[pc] \n\t"
|
||||
"xor %[pc], %[pc], %[ftmp0] \n\t"
|
||||
"psubh %[pc], %[pc], %[ftmp0] \n\t"
|
||||
"punpcklbh %[pa], %[pa], %[zero] \n\t"
|
||||
"punpcklbh %[pb], %[pb], %[zero] \n\t"
|
||||
"pcmpgth %[ftmp0], %[pa], %[pb] \n\t"
|
||||
"and %[ftmp1], %[b], %[ftmp0] \n\t"
|
||||
"pandn %[a], %[ftmp0], %[a] \n\t"
|
||||
"or %[a], %[a], %[ftmp1] \n\t"
|
||||
"pminsh %[pa], %[pa], %[pb] \n\t"
|
||||
"pcmpgth %[ftmp0], %[pa], %[pc] \n\t"
|
||||
"and %[ftmp1], %[c], %[ftmp0] \n\t"
|
||||
"pandn %[a], %[ftmp0], %[a] \n\t"
|
||||
"or %[a], %[a], %[ftmp1] \n\t"
|
||||
"paddb %[a], %[a], %[d] \n\t"
|
||||
"packushb %[d], %[a], %[a] \n\t"
|
||||
"punpcklbh %[c], %[ftmp2], %[zero] \n\t"
|
||||
"gsswrc1 %[d], 0x09(%[row]) \n\t"
|
||||
|
||||
"daddiu %[row], %[row], 0x0c \n\t"
|
||||
"daddiu %[prev], %[prev], 0x0c \n\t"
|
||||
"daddiu %[istop], %[istop], -0x0c \n\t"
|
||||
"bgtz %[istop], 1b \n\t"
|
||||
: [rp]"=&f"(rp), [pp]"=&f"(pp), [rp1]"=&f"(rp1), [pp1]"=&f"(pp1),
|
||||
[zero]"=&f"(zero), [a]"=&f"(a),[b]"=&f"(b), [c]"=&f"(c),
|
||||
[d]"=&f"(d), [pa]"=&f"(pa), [pb]"=&f"(pb), [pc]"=&f"(pc),
|
||||
[tmp0]"=&r"(tmp0), [ftmp0]"=&f"(ftmp[0]), [ftmp1]"=&f"(ftmp[1]),
|
||||
[ftmp2]"=&f"(ftmp[2]), [eight]"=&f"(eight), [sixteen]"=&f"(sixteen),
|
||||
[twenty_four]"=&f"(twenty_four), [forty_eight]"=&f"(forty_eight)
|
||||
: [row]"r"(row), [prev]"r"(prev), [istop]"r"(istop)
|
||||
: "memory"
|
||||
);
|
||||
}
|
||||
|
||||
void png_read_filter_row_paeth4_mmi(png_row_infop row_info, png_bytep row,
|
||||
png_const_bytep prev)
|
||||
{
|
||||
/* Paeth tries to predict pixel d using the pixel to the left of it, a,
|
||||
* and two pixels from the previous row, b and c:
|
||||
* prev: c b
|
||||
* row: a d
|
||||
* The Paeth function predicts d to be whichever of a, b, or c is nearest to
|
||||
* p=a+b-c.
|
||||
*
|
||||
* The first pixel has no left context, and so uses an Up filter, p = b.
|
||||
* This works naturally with our main loop's p = a+b-c if we force a and c
|
||||
* to zero.
|
||||
* Here we zero b and d, which become c and a respectively at the start of
|
||||
* the loop.
|
||||
*/
|
||||
int istop = row_info->rowbytes;
|
||||
double rp, pp, zero;
|
||||
double a, b, c, d, pa, pb, pc;
|
||||
double ftmp[2];
|
||||
|
||||
__asm__ volatile (
|
||||
"xor %[a], %[a], %[a] \n\t"
|
||||
"xor %[c], %[c], %[c] \n\t"
|
||||
"xor %[zero], %[zero], %[zero] \n\t"
|
||||
|
||||
"1: \n\t"
|
||||
"lwc1 %[rp], 0x00(%[row]) \n\t"
|
||||
"lwc1 %[pp], 0x00(%[prev]) \n\t"
|
||||
"punpcklbh %[b], %[pp], %[zero] \n\t"
|
||||
"punpcklbh %[d], %[rp], %[zero] \n\t"
|
||||
|
||||
"packushb %[ftmp0], %[c], %[c] \n\t"
|
||||
"packushb %[ftmp1], %[a], %[a] \n\t"
|
||||
"pasubub %[pa], %[pp], %[ftmp0] \n\t"
|
||||
"pasubub %[pb], %[ftmp1], %[ftmp0] \n\t"
|
||||
"psubh %[ftmp0], %[b], %[c] \n\t"
|
||||
"psubh %[ftmp1], %[a], %[c] \n\t"
|
||||
"paddh %[pc], %[ftmp0], %[ftmp1] \n\t"
|
||||
"pcmpgth %[ftmp0], %[zero], %[pc] \n\t"
|
||||
"xor %[pc], %[pc], %[ftmp0] \n\t"
|
||||
"psubh %[pc], %[pc], %[ftmp0] \n\t"
|
||||
|
||||
"punpcklbh %[pa], %[pa], %[zero] \n\t"
|
||||
"punpcklbh %[pb], %[pb], %[zero] \n\t"
|
||||
|
||||
"pcmpgth %[ftmp0], %[pa], %[pb] \n\t"
|
||||
"and %[ftmp1], %[b], %[ftmp0] \n\t"
|
||||
"pandn %[a], %[ftmp0], %[a] \n\t"
|
||||
"or %[a], %[a], %[ftmp1] \n\t"
|
||||
"pminsh %[pa], %[pa], %[pb] \n\t"
|
||||
|
||||
"pcmpgth %[ftmp0], %[pa], %[pc] \n\t"
|
||||
"and %[ftmp1], %[c], %[ftmp0] \n\t"
|
||||
"pandn %[a], %[ftmp0], %[a] \n\t"
|
||||
"or %[a], %[a], %[ftmp1] \n\t"
|
||||
"paddb %[a], %[a], %[d] \n\t"
|
||||
"packushb %[d], %[a], %[a] \n\t"
|
||||
"swc1 %[d], 0x00(%[row]) \n\t"
|
||||
"punpcklbh %[c], %[pp], %[zero] \n\t"
|
||||
"daddiu %[row], %[row], 0x04 \n\t"
|
||||
"daddiu %[prev], %[prev], 0x04 \n\t"
|
||||
"daddiu %[istop], %[istop], -0x04 \n\t"
|
||||
"bgtz %[istop], 1b \n\t"
|
||||
: [rp]"=&f"(rp), [pp]"=&f"(pp), [zero]"=&f"(zero),
|
||||
[a]"=&f"(a), [b]"=&f"(b), [c]"=&f"(c), [d]"=&f"(d),
|
||||
[pa]"=&f"(pa), [pb]"=&f"(pb), [pc]"=&f"(pc),
|
||||
[ftmp0]"=&f"(ftmp[0]), [ftmp1]"=&f"(ftmp[1])
|
||||
: [row]"r"(row), [prev]"r"(prev), [istop]"r"(istop)
|
||||
: "memory"
|
||||
);
|
||||
}
|
||||
|
||||
#endif /* PNG_MIPS_MMI_IMPLEMENTATION > 0 */
|
||||
#endif /* READ */
|
14
3rdparty/libpng/mips/filter_msa_intrinsics.c
vendored
14
3rdparty/libpng/mips/filter_msa_intrinsics.c
vendored
@ -1,9 +1,9 @@
|
||||
|
||||
/* filter_msa_intrinsics.c - MSA optimised filter functions
|
||||
*
|
||||
* Copyright (c) 2018 Cosmin Truta
|
||||
* Copyright (c) 2018-2024 Cosmin Truta
|
||||
* Copyright (c) 2016 Glenn Randers-Pehrson
|
||||
* Written by Mandar Sahastrabuddhe, August 2016.
|
||||
* Written by Mandar Sahastrabuddhe, August 2016
|
||||
*
|
||||
* This code is released under the libpng license.
|
||||
* For conditions of distribution and use, see the disclaimer
|
||||
@ -11,7 +11,6 @@
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
#include "../pngpriv.h"
|
||||
|
||||
#ifdef PNG_READ_SUPPORTED
|
||||
@ -20,6 +19,7 @@
|
||||
#if PNG_MIPS_MSA_IMPLEMENTATION == 1 /* intrinsics code from pngpriv.h */
|
||||
|
||||
#include <msa.h>
|
||||
#include <stdint.h>
|
||||
|
||||
/* libpng row pointers are not necessarily aligned to any particular boundary,
|
||||
* however this code will only work with appropriate alignment. mips/mips_init.c
|
||||
@ -379,8 +379,8 @@ void png_read_filter_row_up_msa(png_row_infop row_info, png_bytep row,
|
||||
LD_UB4(pp, 16, src4, src5, src6, src7);
|
||||
pp += 64;
|
||||
|
||||
ADD4(src0, src4, src1, src5, src2, src6, src3, src7,
|
||||
src0, src1, src2, src3);
|
||||
ADD4(src0, src4, src1, src5, src2, src6, src3, src7,
|
||||
src0, src1, src2, src3);
|
||||
|
||||
ST_UB4(src0, src1, src2, src3, rp, 16);
|
||||
rp += 64;
|
||||
@ -400,7 +400,7 @@ void png_read_filter_row_up_msa(png_row_infop row_info, png_bytep row,
|
||||
LD_UB4(pp, 16, src4, src5, src6, src7);
|
||||
|
||||
ADD4(src0, src4, src1, src5, src2, src6, src3, src7,
|
||||
src0, src1, src2, src3);
|
||||
src0, src1, src2, src3);
|
||||
|
||||
ST_UB4(src0, src1, src2, src3, rp, 16);
|
||||
rp += 64;
|
||||
@ -425,7 +425,7 @@ void png_read_filter_row_up_msa(png_row_infop row_info, png_bytep row,
|
||||
LD_UB2(rp, 16, src0, src1);
|
||||
LD_UB2(pp, 16, src4, src5);
|
||||
|
||||
ADD2(src0, src4, src1, src5, src0, src1);
|
||||
ADD2(src0, src4, src1, src5, src0, src1);
|
||||
|
||||
ST_UB2(src0, src1, rp, 16);
|
||||
rp += 32;
|
||||
|
99
3rdparty/libpng/mips/mips_init.c
vendored
99
3rdparty/libpng/mips/mips_init.c
vendored
@ -1,9 +1,10 @@
|
||||
|
||||
/* mips_init.c - MSA optimised filter functions
|
||||
*
|
||||
* Copyright (c) 2018 Cosmin Truta
|
||||
* Copyright (c) 2018-2024 Cosmin Truta
|
||||
* Copyright (c) 2016 Glenn Randers-Pehrson
|
||||
* Written by Mandar Sahastrabuddhe, 2016.
|
||||
* Written by Mandar Sahastrabuddhe, 2016
|
||||
* Updated by guxiwei, 2023
|
||||
*
|
||||
* This code is released under the libpng license.
|
||||
* For conditions of distribution and use, see the disclaimer
|
||||
@ -20,8 +21,9 @@
|
||||
|
||||
#ifdef PNG_READ_SUPPORTED
|
||||
|
||||
#if PNG_MIPS_MSA_OPT > 0
|
||||
#ifdef PNG_MIPS_MSA_CHECK_SUPPORTED /* Do run-time checks */
|
||||
#if PNG_MIPS_MSA_IMPLEMENTATION == 1 || PNG_MIPS_MMI_IMPLEMENTATION > 0
|
||||
|
||||
#ifdef PNG_MIPS_MSA_CHECK_SUPPORTED /* Do MIPS MSA run-time checks */
|
||||
/* WARNING: it is strongly recommended that you do not build libpng with
|
||||
* run-time checks for CPU features if at all possible. In the case of the MIPS
|
||||
* MSA instructions there is no processor-specific way of detecting the
|
||||
@ -51,13 +53,83 @@ static int png_have_msa(png_structp png_ptr);
|
||||
#endif /* PNG_MIPS_MSA_FILE */
|
||||
#endif /* PNG_MIPS_MSA_CHECK_SUPPORTED */
|
||||
|
||||
#ifdef PNG_MIPS_MMI_CHECK_SUPPORTED /* Do MIPS MMI run-times checks */
|
||||
#ifndef PNG_MIPS_MMI_FILE
|
||||
# ifdef __linux__
|
||||
# define PNG_MIPS_MMI_FILE "contrib/mips-mmi/linux.c"
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef PNG_MIPS_MMI_FILE
|
||||
|
||||
#include <signal.h> /* for sig_atomic_t */
|
||||
static int png_have_mmi();
|
||||
#include PNG_MIPS_MMI_FILE
|
||||
|
||||
#else /* PNG_MIPS_MMI_FILE */
|
||||
# error "PNG_MIPS_MMI_FILE undefined: no support for run-time MIPS MMI checks"
|
||||
#endif /* PNG_MIPS_MMI_FILE */
|
||||
#endif /* PNG_MIPS_MMI_CHECK_SUPPORTED*/
|
||||
|
||||
#ifndef PNG_ALIGNED_MEMORY_SUPPORTED
|
||||
# error "ALIGNED_MEMORY is required; set: -DPNG_ALIGNED_MEMORY_SUPPORTED"
|
||||
#endif
|
||||
|
||||
/* MIPS supports two optimizations: MMI and MSA. The appropriate
|
||||
* optimization is chosen at runtime
|
||||
*/
|
||||
void
|
||||
png_init_filter_functions_msa(png_structp pp, unsigned int bpp)
|
||||
png_init_filter_functions_mips(png_structp pp, unsigned int bpp)
|
||||
{
|
||||
#if PNG_MIPS_MMI_IMPLEMENTATION > 0
|
||||
#ifdef PNG_MIPS_MMI_API_SUPPORTED
|
||||
switch ((pp->options >> PNG_MIPS_MMI) & 3)
|
||||
{
|
||||
case PNG_OPTION_UNSET:
|
||||
#endif /* PNG_MIPS_MMI_API_SUPPORTED */
|
||||
#ifdef PNG_MIPS_MMI_CHECK_SUPPORTED
|
||||
{
|
||||
static volatile sig_atomic_t no_mmi = -1; /* not checked */
|
||||
|
||||
if (no_mmi < 0)
|
||||
no_mmi = !png_have_mmi();
|
||||
|
||||
if (no_mmi)
|
||||
goto MIPS_MSA_INIT;
|
||||
}
|
||||
#ifdef PNG_MIPS_MMI_API_SUPPORTED
|
||||
break;
|
||||
#endif
|
||||
#endif /* PNG_MIPS_MMI_CHECK_SUPPORTED */
|
||||
|
||||
#ifdef PNG_MIPS_MMI_API_SUPPORTED
|
||||
default: /* OFF or INVALID */
|
||||
goto MIPS_MSA_INIT;
|
||||
|
||||
case PNG_OPTION_ON:
|
||||
/* Option turned on */
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
pp->read_filter[PNG_FILTER_VALUE_UP-1] = png_read_filter_row_up_mmi;
|
||||
if (bpp == 3)
|
||||
{
|
||||
pp->read_filter[PNG_FILTER_VALUE_SUB-1] = png_read_filter_row_sub3_mmi;
|
||||
pp->read_filter[PNG_FILTER_VALUE_AVG-1] = png_read_filter_row_avg3_mmi;
|
||||
pp->read_filter[PNG_FILTER_VALUE_PAETH-1] =
|
||||
png_read_filter_row_paeth3_mmi;
|
||||
}
|
||||
else if (bpp == 4)
|
||||
{
|
||||
pp->read_filter[PNG_FILTER_VALUE_SUB-1] = png_read_filter_row_sub4_mmi;
|
||||
pp->read_filter[PNG_FILTER_VALUE_AVG-1] = png_read_filter_row_avg4_mmi;
|
||||
pp->read_filter[PNG_FILTER_VALUE_PAETH-1] =
|
||||
png_read_filter_row_paeth4_mmi;
|
||||
}
|
||||
#endif /* PNG_MIPS_MMI_IMPLEMENTATION > 0 */
|
||||
|
||||
MIPS_MSA_INIT:
|
||||
#if PNG_MIPS_MSA_IMPLEMENTATION == 1
|
||||
/* The switch statement is compiled in for MIPS_MSA_API, the call to
|
||||
* png_have_msa is compiled in for MIPS_MSA_CHECK. If both are defined
|
||||
* the check is only performed if the API has not set the MSA option on
|
||||
@ -73,6 +145,7 @@ png_init_filter_functions_msa(png_structp pp, unsigned int bpp)
|
||||
* this case will fall through to the 'default' below, which just
|
||||
* returns.
|
||||
*/
|
||||
#endif /* PNG_MIPS_MSA_API_SUPPORTED */
|
||||
#ifdef PNG_MIPS_MSA_CHECK_SUPPORTED
|
||||
{
|
||||
static volatile sig_atomic_t no_msa = -1; /* not checked */
|
||||
@ -83,9 +156,12 @@ png_init_filter_functions_msa(png_structp pp, unsigned int bpp)
|
||||
if (no_msa)
|
||||
return;
|
||||
}
|
||||
#endif /* PNG_MIPS_MSA_CHECK_SUPPORTED */
|
||||
#ifdef PNG_MIPS_MSA_API_SUPPORTED
|
||||
break;
|
||||
#endif
|
||||
#endif /* PNG_MIPS_MSA_CHECK_SUPPORTED */
|
||||
|
||||
#ifdef PNG_MIPS_MSA_API_SUPPORTED
|
||||
default: /* OFF or INVALID */
|
||||
return;
|
||||
|
||||
@ -93,6 +169,8 @@ png_init_filter_functions_msa(png_structp pp, unsigned int bpp)
|
||||
/* Option turned on */
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* IMPORTANT: any new external functions used here must be declared using
|
||||
* PNG_INTERNAL_FUNCTION in ../pngpriv.h. This is required so that the
|
||||
* 'prefix' option to configure works:
|
||||
@ -112,16 +190,15 @@ png_init_filter_functions_msa(png_structp pp, unsigned int bpp)
|
||||
pp->read_filter[PNG_FILTER_VALUE_AVG-1] = png_read_filter_row_avg3_msa;
|
||||
pp->read_filter[PNG_FILTER_VALUE_PAETH-1] = png_read_filter_row_paeth3_msa;
|
||||
}
|
||||
|
||||
else if (bpp == 4)
|
||||
{
|
||||
pp->read_filter[PNG_FILTER_VALUE_SUB-1] = png_read_filter_row_sub4_msa;
|
||||
pp->read_filter[PNG_FILTER_VALUE_AVG-1] = png_read_filter_row_avg4_msa;
|
||||
pp->read_filter[PNG_FILTER_VALUE_PAETH-1] = png_read_filter_row_paeth4_msa;
|
||||
}
|
||||
#else
|
||||
(void)pp;
|
||||
(void)bpp;
|
||||
#endif /* PNG_MIPS_MSA_API_SUPPORTED */
|
||||
#endif /* PNG_MIPS_MSA_IMPLEMENTATION == 1 */
|
||||
return;
|
||||
}
|
||||
#endif /* PNG_MIPS_MSA_OPT > 0 */
|
||||
#endif /* PNG_MIPS_MSA_IMPLEMENTATION == 1 || PNG_MIPS_MMI_IMPLEMENTATION > 0 */
|
||||
#endif /* READ */
|
||||
|
@ -1,17 +0,0 @@
|
||||
diff --git a/3rdparty/libpng/pngrutil.c b/3rdparty/libpng/pngrutil.c
|
||||
index d5fa08c397..4db3de990b 100644
|
||||
--- a/3rdparty/libpng/pngrutil.c
|
||||
+++ b/3rdparty/libpng/pngrutil.c
|
||||
@@ -2087,10 +2087,8 @@ png_handle_eXIf(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
|
||||
}
|
||||
}
|
||||
|
||||
- if (png_crc_finish(png_ptr, 0) != 0)
|
||||
- return;
|
||||
-
|
||||
- png_set_eXIf_1(png_ptr, info_ptr, length, info_ptr->eXIf_buf);
|
||||
+ if (png_crc_finish(png_ptr, 0) == 0)
|
||||
+ png_set_eXIf_1(png_ptr, info_ptr, length, info_ptr->eXIf_buf);
|
||||
|
||||
png_free(png_ptr, info_ptr->eXIf_buf);
|
||||
info_ptr->eXIf_buf = NULL;
|
53
3rdparty/libpng/patches/20190910-msa-patch.diff
vendored
53
3rdparty/libpng/patches/20190910-msa-patch.diff
vendored
@ -1,53 +0,0 @@
|
||||
diff --git a/3rdparty/libpng/mips/mips_init.c b/3rdparty/libpng/mips/mips_init.c
|
||||
index 8dd283deef..6a061cccfa 100644
|
||||
--- a/3rdparty/libpng/mips/mips_init.c
|
||||
+++ b/3rdparty/libpng/mips/mips_init.c
|
||||
@@ -73,7 +73,6 @@ png_init_filter_functions_msa(png_structp pp, unsigned int bpp)
|
||||
* this case will fall through to the 'default' below, which just
|
||||
* returns.
|
||||
*/
|
||||
-#endif /* PNG_MIPS_MSA_API_SUPPORTED */
|
||||
#ifdef PNG_MIPS_MSA_CHECK_SUPPORTED
|
||||
{
|
||||
static volatile sig_atomic_t no_msa = -1; /* not checked */
|
||||
@@ -84,12 +83,9 @@ png_init_filter_functions_msa(png_structp pp, unsigned int bpp)
|
||||
if (no_msa)
|
||||
return;
|
||||
}
|
||||
-#ifdef PNG_MIPS_MSA_API_SUPPORTED
|
||||
- break;
|
||||
-#endif
|
||||
#endif /* PNG_MIPS_MSA_CHECK_SUPPORTED */
|
||||
+ break;
|
||||
|
||||
-#ifdef PNG_MIPS_MSA_API_SUPPORTED
|
||||
default: /* OFF or INVALID */
|
||||
return;
|
||||
|
||||
@@ -97,8 +93,6 @@ png_init_filter_functions_msa(png_structp pp, unsigned int bpp)
|
||||
/* Option turned on */
|
||||
break;
|
||||
}
|
||||
-#endif
|
||||
-
|
||||
/* IMPORTANT: any new external functions used here must be declared using
|
||||
* PNG_INTERNAL_FUNCTION in ../pngpriv.h. This is required so that the
|
||||
* 'prefix' option to configure works:
|
||||
@@ -118,13 +112,16 @@ png_init_filter_functions_msa(png_structp pp, unsigned int bpp)
|
||||
pp->read_filter[PNG_FILTER_VALUE_AVG-1] = png_read_filter_row_avg3_msa;
|
||||
pp->read_filter[PNG_FILTER_VALUE_PAETH-1] = png_read_filter_row_paeth3_msa;
|
||||
}
|
||||
-
|
||||
else if (bpp == 4)
|
||||
{
|
||||
pp->read_filter[PNG_FILTER_VALUE_SUB-1] = png_read_filter_row_sub4_msa;
|
||||
pp->read_filter[PNG_FILTER_VALUE_AVG-1] = png_read_filter_row_avg4_msa;
|
||||
pp->read_filter[PNG_FILTER_VALUE_PAETH-1] = png_read_filter_row_paeth4_msa;
|
||||
}
|
||||
+#else
|
||||
+ (void)pp;
|
||||
+ (void)bpp;
|
||||
+#endif /* PNG_MIPS_MSA_API_SUPPORTED */
|
||||
}
|
||||
#endif /* PNG_MIPS_MSA_OPT > 0 */
|
||||
#endif /* READ */
|
114
3rdparty/libpng/png.c
vendored
114
3rdparty/libpng/png.c
vendored
@ -1,7 +1,7 @@
|
||||
|
||||
/* png.c - location for general purpose libpng functions
|
||||
*
|
||||
* Copyright (c) 2018-2019 Cosmin Truta
|
||||
* Copyright (c) 2018-2024 Cosmin Truta
|
||||
* Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson
|
||||
* Copyright (c) 1996-1997 Andreas Dilger
|
||||
* Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
|
||||
@ -14,27 +14,7 @@
|
||||
#include "pngpriv.h"
|
||||
|
||||
/* Generate a compiler error if there is an old png.h in the search path. */
|
||||
typedef png_libpng_version_1_6_37 Your_png_h_is_not_version_1_6_37;
|
||||
|
||||
#ifdef __GNUC__
|
||||
/* The version tests may need to be added to, but the problem warning has
|
||||
* consistently been fixed in GCC versions which obtain wide-spread release.
|
||||
* The problem is that many versions of GCC rearrange comparison expressions in
|
||||
* the optimizer in such a way that the results of the comparison will change
|
||||
* if signed integer overflow occurs. Such comparisons are not permitted in
|
||||
* ANSI C90, however GCC isn't clever enough to work out that that do not occur
|
||||
* below in png_ascii_from_fp and png_muldiv, so it produces a warning with
|
||||
* -Wextra. Unfortunately this is highly dependent on the optimizer and the
|
||||
* machine architecture so the warning comes and goes unpredictably and is
|
||||
* impossible to "fix", even were that a good idea.
|
||||
*/
|
||||
#if __GNUC__ == 7 && __GNUC_MINOR__ == 1
|
||||
#define GCC_STRICT_OVERFLOW 1
|
||||
#endif /* GNU 7.1.x */
|
||||
#endif /* GNU */
|
||||
#ifndef GCC_STRICT_OVERFLOW
|
||||
#define GCC_STRICT_OVERFLOW 0
|
||||
#endif
|
||||
typedef png_libpng_version_1_6_43 Your_png_h_is_not_version_1_6_43;
|
||||
|
||||
/* Tells libpng that we have already handled the first "num_bytes" bytes
|
||||
* of the PNG file signature. If the PNG data is embedded into another
|
||||
@ -73,21 +53,21 @@ png_set_sig_bytes(png_structrp png_ptr, int num_bytes)
|
||||
int PNGAPI
|
||||
png_sig_cmp(png_const_bytep sig, size_t start, size_t num_to_check)
|
||||
{
|
||||
png_byte png_signature[8] = {137, 80, 78, 71, 13, 10, 26, 10};
|
||||
static const png_byte png_signature[8] = {137, 80, 78, 71, 13, 10, 26, 10};
|
||||
|
||||
if (num_to_check > 8)
|
||||
num_to_check = 8;
|
||||
|
||||
else if (num_to_check < 1)
|
||||
return (-1);
|
||||
return -1;
|
||||
|
||||
if (start > 7)
|
||||
return (-1);
|
||||
return -1;
|
||||
|
||||
if (start + num_to_check > 8)
|
||||
num_to_check = 8 - start;
|
||||
|
||||
return ((int)(memcmp(&sig[start], &png_signature[start], num_to_check)));
|
||||
return memcmp(&sig[start], &png_signature[start], num_to_check);
|
||||
}
|
||||
|
||||
#endif /* READ */
|
||||
@ -447,7 +427,6 @@ png_info_init_3,(png_infopp ptr_ptr, size_t png_info_struct_size),
|
||||
memset(info_ptr, 0, (sizeof *info_ptr));
|
||||
}
|
||||
|
||||
/* The following API is not called internally */
|
||||
void PNGAPI
|
||||
png_data_freer(png_const_structrp png_ptr, png_inforp info_ptr,
|
||||
int freer, png_uint_32 mask)
|
||||
@ -686,9 +665,9 @@ png_voidp PNGAPI
|
||||
png_get_io_ptr(png_const_structrp png_ptr)
|
||||
{
|
||||
if (png_ptr == NULL)
|
||||
return (NULL);
|
||||
return NULL;
|
||||
|
||||
return (png_ptr->io_ptr);
|
||||
return png_ptr->io_ptr;
|
||||
}
|
||||
|
||||
#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED)
|
||||
@ -720,7 +699,7 @@ png_init_io(png_structrp png_ptr, png_FILE_p fp)
|
||||
*
|
||||
* Where UNSIGNED_MAX is the appropriate maximum unsigned value, so when the
|
||||
* negative integral value is added the result will be an unsigned value
|
||||
* correspnding to the 2's complement representation.
|
||||
* corresponding to the 2's complement representation.
|
||||
*/
|
||||
void PNGAPI
|
||||
png_save_int_32(png_bytep buf, png_int_32 i)
|
||||
@ -752,7 +731,7 @@ png_convert_to_rfc1123_buffer(char out[29], png_const_timep ptime)
|
||||
|
||||
{
|
||||
size_t pos = 0;
|
||||
char number_buf[5]; /* enough for a four-digit year */
|
||||
char number_buf[5] = {0, 0, 0, 0, 0}; /* enough for a four-digit year */
|
||||
|
||||
# define APPEND_STRING(string) pos = png_safecat(out, 29, pos, (string))
|
||||
# define APPEND_NUMBER(format, value)\
|
||||
@ -815,8 +794,8 @@ png_get_copyright(png_const_structrp png_ptr)
|
||||
return PNG_STRING_COPYRIGHT
|
||||
#else
|
||||
return PNG_STRING_NEWLINE \
|
||||
"libpng version 1.6.37" PNG_STRING_NEWLINE \
|
||||
"Copyright (c) 2018-2019 Cosmin Truta" PNG_STRING_NEWLINE \
|
||||
"libpng version 1.6.43" PNG_STRING_NEWLINE \
|
||||
"Copyright (c) 2018-2024 Cosmin Truta" PNG_STRING_NEWLINE \
|
||||
"Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson" \
|
||||
PNG_STRING_NEWLINE \
|
||||
"Copyright (c) 1996-1997 Andreas Dilger" PNG_STRING_NEWLINE \
|
||||
@ -977,7 +956,7 @@ png_reset_zstream(png_structrp png_ptr)
|
||||
return Z_STREAM_ERROR;
|
||||
|
||||
/* WARNING: this resets the window bits to the maximum! */
|
||||
return (inflateReset(&png_ptr->zstream));
|
||||
return inflateReset(&png_ptr->zstream);
|
||||
}
|
||||
#endif /* READ */
|
||||
|
||||
@ -986,7 +965,7 @@ png_uint_32 PNGAPI
|
||||
png_access_version_number(void)
|
||||
{
|
||||
/* Version of *.c files used when building libpng */
|
||||
return((png_uint_32)PNG_LIBPNG_VER);
|
||||
return (png_uint_32)PNG_LIBPNG_VER;
|
||||
}
|
||||
|
||||
#if defined(PNG_READ_SUPPORTED) || defined(PNG_WRITE_SUPPORTED)
|
||||
@ -1842,14 +1821,14 @@ png_icc_profile_error(png_const_structrp png_ptr, png_colorspacerp colorspace,
|
||||
}
|
||||
# ifdef PNG_WARNINGS_SUPPORTED
|
||||
else
|
||||
{
|
||||
char number[PNG_NUMBER_BUFFER_SIZE]; /* +24 = 114*/
|
||||
{
|
||||
char number[PNG_NUMBER_BUFFER_SIZE]; /* +24 = 114 */
|
||||
|
||||
pos = png_safecat(message, (sizeof message), pos,
|
||||
png_format_number(number, number+(sizeof number),
|
||||
PNG_NUMBER_FORMAT_x, value));
|
||||
pos = png_safecat(message, (sizeof message), pos, "h: "); /*+2 = 116*/
|
||||
}
|
||||
pos = png_safecat(message, (sizeof message), pos,
|
||||
png_format_number(number, number+(sizeof number),
|
||||
PNG_NUMBER_FORMAT_x, value));
|
||||
pos = png_safecat(message, (sizeof message), pos, "h: "); /* +2 = 116 */
|
||||
}
|
||||
# endif
|
||||
/* The 'reason' is an arbitrary message, allow +79 maximum 195 */
|
||||
pos = png_safecat(message, (sizeof message), pos, reason);
|
||||
@ -2532,17 +2511,6 @@ png_colorspace_set_rgb_coefficients(png_structrp png_ptr)
|
||||
|
||||
#endif /* COLORSPACE */
|
||||
|
||||
#ifdef __GNUC__
|
||||
/* This exists solely to work round a warning from GNU C. */
|
||||
static int /* PRIVATE */
|
||||
png_gt(size_t a, size_t b)
|
||||
{
|
||||
return a > b;
|
||||
}
|
||||
#else
|
||||
# define png_gt(a,b) ((a) > (b))
|
||||
#endif
|
||||
|
||||
void /* PRIVATE */
|
||||
png_check_IHDR(png_const_structrp png_ptr,
|
||||
png_uint_32 width, png_uint_32 height, int bit_depth,
|
||||
@ -2564,8 +2532,16 @@ png_check_IHDR(png_const_structrp png_ptr,
|
||||
error = 1;
|
||||
}
|
||||
|
||||
if (png_gt(((width + 7) & (~7U)),
|
||||
((PNG_SIZE_MAX
|
||||
/* The bit mask on the first line below must be at least as big as a
|
||||
* png_uint_32. "~7U" is not adequate on 16-bit systems because it will
|
||||
* be an unsigned 16-bit value. Casting to (png_alloc_size_t) makes the
|
||||
* type of the result at least as bit (in bits) as the RHS of the > operator
|
||||
* which also avoids a common warning on 64-bit systems that the comparison
|
||||
* of (png_uint_32) against the constant value on the RHS will always be
|
||||
* false.
|
||||
*/
|
||||
if (((width + 7) & ~(png_alloc_size_t)7) >
|
||||
(((PNG_SIZE_MAX
|
||||
- 48 /* big_row_buf hack */
|
||||
- 1) /* filter byte */
|
||||
/ 8) /* 8-byte RGBA pixels */
|
||||
@ -2710,7 +2686,7 @@ png_check_IHDR(png_const_structrp png_ptr,
|
||||
|
||||
int /* PRIVATE */
|
||||
png_check_fp_number(png_const_charp string, size_t size, int *statep,
|
||||
png_size_tp whereami)
|
||||
size_t *whereami)
|
||||
{
|
||||
int state = *statep;
|
||||
size_t i = *whereami;
|
||||
@ -2891,14 +2867,6 @@ png_pow10(int power)
|
||||
/* Function to format a floating point value in ASCII with a given
|
||||
* precision.
|
||||
*/
|
||||
#if GCC_STRICT_OVERFLOW
|
||||
#pragma GCC diagnostic push
|
||||
/* The problem arises below with exp_b10, which can never overflow because it
|
||||
* comes, originally, from frexp and is therefore limited to a range which is
|
||||
* typically +/-710 (log2(DBL_MAX)/log2(DBL_MIN)).
|
||||
*/
|
||||
#pragma GCC diagnostic warning "-Wstrict-overflow=2"
|
||||
#endif /* GCC_STRICT_OVERFLOW */
|
||||
void /* PRIVATE */
|
||||
png_ascii_from_fp(png_const_structrp png_ptr, png_charp ascii, size_t size,
|
||||
double fp, unsigned int precision)
|
||||
@ -3220,10 +3188,6 @@ png_ascii_from_fp(png_const_structrp png_ptr, png_charp ascii, size_t size,
|
||||
/* Here on buffer too small. */
|
||||
png_error(png_ptr, "ASCII conversion buffer too small");
|
||||
}
|
||||
#if GCC_STRICT_OVERFLOW
|
||||
#pragma GCC diagnostic pop
|
||||
#endif /* GCC_STRICT_OVERFLOW */
|
||||
|
||||
# endif /* FLOATING_POINT */
|
||||
|
||||
# ifdef PNG_FIXED_POINT_SUPPORTED
|
||||
@ -3251,7 +3215,7 @@ png_ascii_from_fixed(png_const_structrp png_ptr, png_charp ascii,
|
||||
if (num <= 0x80000000) /* else overflowed */
|
||||
{
|
||||
unsigned int ndigits = 0, first = 16 /* flag value */;
|
||||
char digits[10];
|
||||
char digits[10] = {0};
|
||||
|
||||
while (num)
|
||||
{
|
||||
@ -3336,15 +3300,6 @@ png_fixed(png_const_structrp png_ptr, double fp, png_const_charp text)
|
||||
* the nearest .00001). Overflow and divide by zero are signalled in
|
||||
* the result, a boolean - true on success, false on overflow.
|
||||
*/
|
||||
#if GCC_STRICT_OVERFLOW /* from above */
|
||||
/* It is not obvious which comparison below gets optimized in such a way that
|
||||
* signed overflow would change the result; looking through the code does not
|
||||
* reveal any tests which have the form GCC complains about, so presumably the
|
||||
* optimizer is moving an add or subtract into the 'if' somewhere.
|
||||
*/
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic warning "-Wstrict-overflow=2"
|
||||
#endif /* GCC_STRICT_OVERFLOW */
|
||||
int
|
||||
png_muldiv(png_fixed_point_p res, png_fixed_point a, png_int_32 times,
|
||||
png_int_32 divisor)
|
||||
@ -3459,9 +3414,6 @@ png_muldiv(png_fixed_point_p res, png_fixed_point a, png_int_32 times,
|
||||
|
||||
return 0;
|
||||
}
|
||||
#if GCC_STRICT_OVERFLOW
|
||||
#pragma GCC diagnostic pop
|
||||
#endif /* GCC_STRICT_OVERFLOW */
|
||||
#endif /* READ_GAMMA || INCH_CONVERSIONS */
|
||||
|
||||
#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_INCH_CONVERSIONS_SUPPORTED)
|
||||
|
67
3rdparty/libpng/png.h
vendored
67
3rdparty/libpng/png.h
vendored
@ -1,9 +1,9 @@
|
||||
|
||||
/* png.h - header file for PNG reference library
|
||||
*
|
||||
* libpng version 1.6.37 - April 14, 2019
|
||||
* libpng version 1.6.43
|
||||
*
|
||||
* Copyright (c) 2018-2019 Cosmin Truta
|
||||
* Copyright (c) 2018-2024 Cosmin Truta
|
||||
* Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson
|
||||
* Copyright (c) 1996-1997 Andreas Dilger
|
||||
* Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
|
||||
@ -15,7 +15,7 @@
|
||||
* libpng versions 0.89, June 1996, through 0.96, May 1997: Andreas Dilger
|
||||
* libpng versions 0.97, January 1998, through 1.6.35, July 2018:
|
||||
* Glenn Randers-Pehrson
|
||||
* libpng versions 1.6.36, December 2018, through 1.6.37, April 2019:
|
||||
* libpng versions 1.6.36, December 2018, through 1.6.43, February 2024:
|
||||
* Cosmin Truta
|
||||
* See also "Contributing Authors", below.
|
||||
*/
|
||||
@ -27,8 +27,8 @@
|
||||
* PNG Reference Library License version 2
|
||||
* ---------------------------------------
|
||||
*
|
||||
* * Copyright (c) 1995-2019 The PNG Reference Library Authors.
|
||||
* * Copyright (c) 2018-2019 Cosmin Truta.
|
||||
* * Copyright (c) 1995-2024 The PNG Reference Library Authors.
|
||||
* * Copyright (c) 2018-2024 Cosmin Truta.
|
||||
* * Copyright (c) 2000-2002, 2004, 2006-2018 Glenn Randers-Pehrson.
|
||||
* * Copyright (c) 1996-1997 Andreas Dilger.
|
||||
* * Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
|
||||
@ -239,7 +239,7 @@
|
||||
* ...
|
||||
* 1.5.30 15 10530 15.so.15.30[.0]
|
||||
* ...
|
||||
* 1.6.37 16 10637 16.so.16.37[.0]
|
||||
* 1.6.43 16 10643 16.so.16.43[.0]
|
||||
*
|
||||
* Henceforth the source version will match the shared-library major and
|
||||
* minor numbers; the shared-library major version number will be used for
|
||||
@ -255,9 +255,6 @@
|
||||
* to the info_ptr or png_ptr members through png.h, and the compiled
|
||||
* application is loaded with a different version of the library.
|
||||
*
|
||||
* DLLNUM will change each time there are forward or backward changes
|
||||
* in binary compatibility (e.g., when a new feature is added).
|
||||
*
|
||||
* See libpng.txt or libpng.3 for more information. The PNG specification
|
||||
* is available as a W3C Recommendation and as an ISO/IEC Standard; see
|
||||
* <https://www.w3.org/TR/2003/REC-PNG-20031110/>
|
||||
@ -278,19 +275,21 @@
|
||||
*/
|
||||
|
||||
/* Version information for png.h - this should match the version in png.c */
|
||||
#define PNG_LIBPNG_VER_STRING "1.6.37"
|
||||
#define PNG_HEADER_VERSION_STRING " libpng version 1.6.37 - April 14, 2019\n"
|
||||
#define PNG_LIBPNG_VER_STRING "1.6.43"
|
||||
#define PNG_HEADER_VERSION_STRING " libpng version " PNG_LIBPNG_VER_STRING "\n"
|
||||
|
||||
#define PNG_LIBPNG_VER_SONUM 16
|
||||
#define PNG_LIBPNG_VER_DLLNUM 16
|
||||
/* The versions of shared library builds should stay in sync, going forward */
|
||||
#define PNG_LIBPNG_VER_SHAREDLIB 16
|
||||
#define PNG_LIBPNG_VER_SONUM PNG_LIBPNG_VER_SHAREDLIB /* [Deprecated] */
|
||||
#define PNG_LIBPNG_VER_DLLNUM PNG_LIBPNG_VER_SHAREDLIB /* [Deprecated] */
|
||||
|
||||
/* These should match the first 3 components of PNG_LIBPNG_VER_STRING: */
|
||||
#define PNG_LIBPNG_VER_MAJOR 1
|
||||
#define PNG_LIBPNG_VER_MINOR 6
|
||||
#define PNG_LIBPNG_VER_RELEASE 37
|
||||
#define PNG_LIBPNG_VER_RELEASE 43
|
||||
|
||||
/* This should be zero for a public release, or non-zero for a
|
||||
* development version. [Deprecated]
|
||||
* development version.
|
||||
*/
|
||||
#define PNG_LIBPNG_VER_BUILD 0
|
||||
|
||||
@ -318,7 +317,7 @@
|
||||
* From version 1.0.1 it is:
|
||||
* XXYYZZ, where XX=major, YY=minor, ZZ=release
|
||||
*/
|
||||
#define PNG_LIBPNG_VER 10637 /* 1.6.37 */
|
||||
#define PNG_LIBPNG_VER 10643 /* 1.6.43 */
|
||||
|
||||
/* Library configuration: these options cannot be changed after
|
||||
* the library has been built.
|
||||
@ -428,7 +427,7 @@ extern "C" {
|
||||
/* This triggers a compiler error in png.c, if png.c and png.h
|
||||
* do not agree upon the version number.
|
||||
*/
|
||||
typedef char* png_libpng_version_1_6_37;
|
||||
typedef char* png_libpng_version_1_6_43;
|
||||
|
||||
/* Basic control structions. Read libpng-manual.txt or libpng.3 for more info.
|
||||
*
|
||||
@ -849,7 +848,7 @@ PNG_FUNCTION(void, (PNGCAPI *png_longjmp_ptr), PNGARG((jmp_buf, int)), typedef);
|
||||
#define PNG_TRANSFORM_GRAY_TO_RGB 0x2000 /* read only */
|
||||
/* Added to libpng-1.5.4 */
|
||||
#define PNG_TRANSFORM_EXPAND_16 0x4000 /* read only */
|
||||
#if INT_MAX >= 0x8000 /* else this might break */
|
||||
#if ~0U > 0xffffU /* or else this might break on a 16-bit machine */
|
||||
#define PNG_TRANSFORM_SCALE_16 0x8000 /* read only */
|
||||
#endif
|
||||
|
||||
@ -908,15 +907,15 @@ PNG_EXPORT(2, void, png_set_sig_bytes, (png_structrp png_ptr, int num_bytes));
|
||||
/* Check sig[start] through sig[start + num_to_check - 1] to see if it's a
|
||||
* PNG file. Returns zero if the supplied bytes match the 8-byte PNG
|
||||
* signature, and non-zero otherwise. Having num_to_check == 0 or
|
||||
* start > 7 will always fail (ie return non-zero).
|
||||
* start > 7 will always fail (i.e. return non-zero).
|
||||
*/
|
||||
PNG_EXPORT(3, int, png_sig_cmp, (png_const_bytep sig, size_t start,
|
||||
size_t num_to_check));
|
||||
|
||||
/* Simple signature checking function. This is the same as calling
|
||||
* png_check_sig(sig, n) := !png_sig_cmp(sig, 0, n).
|
||||
* png_check_sig(sig, n) := (png_sig_cmp(sig, 0, n) == 0).
|
||||
*/
|
||||
#define png_check_sig(sig, n) !png_sig_cmp((sig), 0, (n))
|
||||
#define png_check_sig(sig, n) (png_sig_cmp((sig), 0, (n)) == 0) /* DEPRECATED */
|
||||
|
||||
/* Allocate and initialize png_ptr struct for reading, and any other memory. */
|
||||
PNG_EXPORTA(4, png_structp, png_create_read_struct,
|
||||
@ -1446,7 +1445,7 @@ PNG_EXPORT(66, void, png_set_crc_action, (png_structrp png_ptr, int crit_action,
|
||||
* mainly useful for testing, as the defaults should work with most users.
|
||||
* Those users who are tight on memory or want faster performance at the
|
||||
* expense of compression can modify them. See the compression library
|
||||
* header file (zlib.h) for an explination of the compression functions.
|
||||
* header file (zlib.h) for an explanation of the compression functions.
|
||||
*/
|
||||
|
||||
/* Set the filtering method(s) used by libpng. Currently, the only valid
|
||||
@ -1501,7 +1500,7 @@ PNG_FIXED_EXPORT(209, void, png_set_filter_heuristics_fixed,
|
||||
* 0 - 9, corresponding directly to the zlib compression levels 0 - 9
|
||||
* (0 - no compression, 9 - "maximal" compression). Note that tests have
|
||||
* shown that zlib compression levels 3-6 usually perform as well as level 9
|
||||
* for PNG images, and do considerably fewer caclulations. In the future,
|
||||
* for PNG images, and do considerably fewer calculations. In the future,
|
||||
* these values may not correspond directly to the zlib compression levels.
|
||||
*/
|
||||
#ifdef PNG_WRITE_CUSTOMIZE_COMPRESSION_SUPPORTED
|
||||
@ -1730,12 +1729,9 @@ PNG_EXPORT(97, void, png_free, (png_const_structrp png_ptr, png_voidp ptr));
|
||||
PNG_EXPORT(98, void, png_free_data, (png_const_structrp png_ptr,
|
||||
png_inforp info_ptr, png_uint_32 free_me, int num));
|
||||
|
||||
/* Reassign responsibility for freeing existing data, whether allocated
|
||||
/* Reassign the responsibility for freeing existing data, whether allocated
|
||||
* by libpng or by the application; this works on the png_info structure passed
|
||||
* in, it does not change the state for other png_info structures.
|
||||
*
|
||||
* It is unlikely that this function works correctly as of 1.6.0 and using it
|
||||
* may result either in memory leaks or double free of allocated data.
|
||||
* in, without changing the state for other png_info structures.
|
||||
*/
|
||||
PNG_EXPORT(99, void, png_data_freer, (png_const_structrp png_ptr,
|
||||
png_inforp info_ptr, int freer, png_uint_32 mask));
|
||||
@ -3207,11 +3203,18 @@ PNG_EXPORT(245, int, png_image_write_to_memory, (png_imagep image, void *memory,
|
||||
#ifdef PNG_MIPS_MSA_API_SUPPORTED
|
||||
# define PNG_MIPS_MSA 6 /* HARDWARE: MIPS Msa SIMD instructions supported */
|
||||
#endif
|
||||
#define PNG_IGNORE_ADLER32 8
|
||||
#ifdef PNG_POWERPC_VSX_API_SUPPORTED
|
||||
# define PNG_POWERPC_VSX 10 /* HARDWARE: PowerPC VSX SIMD instructions supported */
|
||||
#ifdef PNG_DISABLE_ADLER32_CHECK_SUPPORTED
|
||||
# define PNG_IGNORE_ADLER32 8 /* SOFTWARE: disable Adler32 check on IDAT */
|
||||
#endif
|
||||
#define PNG_OPTION_NEXT 12 /* Next option - numbers must be even */
|
||||
#ifdef PNG_POWERPC_VSX_API_SUPPORTED
|
||||
# define PNG_POWERPC_VSX 10 /* HARDWARE: PowerPC VSX SIMD instructions
|
||||
* supported */
|
||||
#endif
|
||||
#ifdef PNG_MIPS_MMI_API_SUPPORTED
|
||||
# define PNG_MIPS_MMI 12 /* HARDWARE: MIPS MMI SIMD instructions supported */
|
||||
#endif
|
||||
|
||||
#define PNG_OPTION_NEXT 14 /* Next option - numbers must be even */
|
||||
|
||||
/* Return values: NOTE: there are four values and 'off' is *not* zero */
|
||||
#define PNG_OPTION_UNSET 0 /* Unset - defaults to off */
|
||||
|
8
3rdparty/libpng/pngconf.h
vendored
8
3rdparty/libpng/pngconf.h
vendored
@ -1,9 +1,9 @@
|
||||
|
||||
/* pngconf.h - machine-configurable file for libpng
|
||||
*
|
||||
* libpng version 1.6.37
|
||||
* libpng version 1.6.43
|
||||
*
|
||||
* Copyright (c) 2018-2019 Cosmin Truta
|
||||
* Copyright (c) 2018-2024 Cosmin Truta
|
||||
* Copyright (c) 1998-2002,2004,2006-2016,2018 Glenn Randers-Pehrson
|
||||
* Copyright (c) 1996-1997 Andreas Dilger
|
||||
* Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
|
||||
@ -180,8 +180,8 @@
|
||||
* compiler-specific macros to the values required to change the calling
|
||||
* conventions of the various functions.
|
||||
*/
|
||||
#if defined(_Windows) || defined(_WINDOWS) || defined(WIN32) ||\
|
||||
defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)
|
||||
#if defined(_WIN32) || defined(__WIN32__) || defined(__NT__) || \
|
||||
defined(__CYGWIN__)
|
||||
/* Windows system (DOS doesn't support DLLs). Includes builds under Cygwin or
|
||||
* MinGW on any architecture currently supported by Windows. Also includes
|
||||
* Watcom builds but these need special treatment because they are not
|
||||
|
34
3rdparty/libpng/pngerror.c
vendored
34
3rdparty/libpng/pngerror.c
vendored
@ -1,7 +1,7 @@
|
||||
|
||||
/* pngerror.c - stub functions for i/o and memory allocation
|
||||
*
|
||||
* Copyright (c) 2018 Cosmin Truta
|
||||
* Copyright (c) 2018-2024 Cosmin Truta
|
||||
* Copyright (c) 1998-2002,2004,2006-2017 Glenn Randers-Pehrson
|
||||
* Copyright (c) 1996-1997 Andreas Dilger
|
||||
* Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
|
||||
@ -255,7 +255,7 @@ void
|
||||
png_warning_parameter_unsigned(png_warning_parameters p, int number, int format,
|
||||
png_alloc_size_t value)
|
||||
{
|
||||
char buffer[PNG_NUMBER_BUFFER_SIZE];
|
||||
char buffer[PNG_NUMBER_BUFFER_SIZE] = {0};
|
||||
png_warning_parameter(p, number, PNG_FORMAT_NUMBER(buffer, format, value));
|
||||
}
|
||||
|
||||
@ -265,7 +265,7 @@ png_warning_parameter_signed(png_warning_parameters p, int number, int format,
|
||||
{
|
||||
png_alloc_size_t u;
|
||||
png_charp str;
|
||||
char buffer[PNG_NUMBER_BUFFER_SIZE];
|
||||
char buffer[PNG_NUMBER_BUFFER_SIZE] = {0};
|
||||
|
||||
/* Avoid overflow by doing the negate in a png_alloc_size_t: */
|
||||
u = (png_alloc_size_t)value;
|
||||
@ -858,7 +858,7 @@ png_get_error_ptr(png_const_structrp png_ptr)
|
||||
if (png_ptr == NULL)
|
||||
return NULL;
|
||||
|
||||
return ((png_voidp)png_ptr->error_ptr);
|
||||
return (png_voidp)png_ptr->error_ptr;
|
||||
}
|
||||
|
||||
|
||||
@ -933,31 +933,25 @@ png_safe_warning(png_structp png_nonconst_ptr, png_const_charp warning_message)
|
||||
#endif
|
||||
|
||||
int /* PRIVATE */
|
||||
png_safe_execute(png_imagep image_in, int (*function)(png_voidp), png_voidp arg)
|
||||
png_safe_execute(png_imagep image, int (*function)(png_voidp), png_voidp arg)
|
||||
{
|
||||
volatile png_imagep image = image_in;
|
||||
volatile int result;
|
||||
volatile png_voidp saved_error_buf;
|
||||
png_voidp saved_error_buf = image->opaque->error_buf;
|
||||
jmp_buf safe_jmpbuf;
|
||||
int result;
|
||||
|
||||
/* Safely execute function(arg) with png_error returning to this function. */
|
||||
saved_error_buf = image->opaque->error_buf;
|
||||
result = setjmp(safe_jmpbuf) == 0;
|
||||
|
||||
if (result != 0)
|
||||
/* Safely execute function(arg), with png_error returning back here. */
|
||||
if (setjmp(safe_jmpbuf) == 0)
|
||||
{
|
||||
|
||||
image->opaque->error_buf = safe_jmpbuf;
|
||||
result = function(arg);
|
||||
image->opaque->error_buf = saved_error_buf;
|
||||
return result;
|
||||
}
|
||||
|
||||
/* On png_error, return via longjmp, pop the jmpbuf, and free the image. */
|
||||
image->opaque->error_buf = saved_error_buf;
|
||||
|
||||
/* And do the cleanup prior to any failure return. */
|
||||
if (result == 0)
|
||||
png_image_free(image);
|
||||
|
||||
return result;
|
||||
png_image_free(image);
|
||||
return 0;
|
||||
}
|
||||
#endif /* SIMPLIFIED READ || SIMPLIFIED_WRITE */
|
||||
#endif /* READ || WRITE */
|
||||
|
268
3rdparty/libpng/pngget.c
vendored
268
3rdparty/libpng/pngget.c
vendored
@ -1,7 +1,7 @@
|
||||
|
||||
/* pngget.c - retrieval of values from info struct
|
||||
*
|
||||
* Copyright (c) 2018 Cosmin Truta
|
||||
* Copyright (c) 2018-2024 Cosmin Truta
|
||||
* Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson
|
||||
* Copyright (c) 1996-1997 Andreas Dilger
|
||||
* Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
|
||||
@ -21,18 +21,29 @@ png_get_valid(png_const_structrp png_ptr, png_const_inforp info_ptr,
|
||||
png_uint_32 flag)
|
||||
{
|
||||
if (png_ptr != NULL && info_ptr != NULL)
|
||||
return(info_ptr->valid & flag);
|
||||
{
|
||||
#ifdef PNG_READ_tRNS_SUPPORTED
|
||||
/* png_handle_PLTE() may have canceled a valid tRNS chunk but left the
|
||||
* 'valid' flag for the detection of duplicate chunks. Do not report a
|
||||
* valid tRNS chunk in this case.
|
||||
*/
|
||||
if (flag == PNG_INFO_tRNS && png_ptr->num_trans == 0)
|
||||
return 0;
|
||||
#endif
|
||||
|
||||
return(0);
|
||||
return info_ptr->valid & flag;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
size_t PNGAPI
|
||||
png_get_rowbytes(png_const_structrp png_ptr, png_const_inforp info_ptr)
|
||||
{
|
||||
if (png_ptr != NULL && info_ptr != NULL)
|
||||
return(info_ptr->rowbytes);
|
||||
return info_ptr->rowbytes;
|
||||
|
||||
return(0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef PNG_INFO_IMAGE_SUPPORTED
|
||||
@ -40,9 +51,9 @@ png_bytepp PNGAPI
|
||||
png_get_rows(png_const_structrp png_ptr, png_const_inforp info_ptr)
|
||||
{
|
||||
if (png_ptr != NULL && info_ptr != NULL)
|
||||
return(info_ptr->row_pointers);
|
||||
return info_ptr->row_pointers;
|
||||
|
||||
return(0);
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -54,7 +65,7 @@ png_get_image_width(png_const_structrp png_ptr, png_const_inforp info_ptr)
|
||||
if (png_ptr != NULL && info_ptr != NULL)
|
||||
return info_ptr->width;
|
||||
|
||||
return (0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
png_uint_32 PNGAPI
|
||||
@ -63,7 +74,7 @@ png_get_image_height(png_const_structrp png_ptr, png_const_inforp info_ptr)
|
||||
if (png_ptr != NULL && info_ptr != NULL)
|
||||
return info_ptr->height;
|
||||
|
||||
return (0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
png_byte PNGAPI
|
||||
@ -72,7 +83,7 @@ png_get_bit_depth(png_const_structrp png_ptr, png_const_inforp info_ptr)
|
||||
if (png_ptr != NULL && info_ptr != NULL)
|
||||
return info_ptr->bit_depth;
|
||||
|
||||
return (0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
png_byte PNGAPI
|
||||
@ -81,7 +92,7 @@ png_get_color_type(png_const_structrp png_ptr, png_const_inforp info_ptr)
|
||||
if (png_ptr != NULL && info_ptr != NULL)
|
||||
return info_ptr->color_type;
|
||||
|
||||
return (0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
png_byte PNGAPI
|
||||
@ -90,7 +101,7 @@ png_get_filter_type(png_const_structrp png_ptr, png_const_inforp info_ptr)
|
||||
if (png_ptr != NULL && info_ptr != NULL)
|
||||
return info_ptr->filter_type;
|
||||
|
||||
return (0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
png_byte PNGAPI
|
||||
@ -99,7 +110,7 @@ png_get_interlace_type(png_const_structrp png_ptr, png_const_inforp info_ptr)
|
||||
if (png_ptr != NULL && info_ptr != NULL)
|
||||
return info_ptr->interlace_type;
|
||||
|
||||
return (0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
png_byte PNGAPI
|
||||
@ -108,7 +119,7 @@ png_get_compression_type(png_const_structrp png_ptr, png_const_inforp info_ptr)
|
||||
if (png_ptr != NULL && info_ptr != NULL)
|
||||
return info_ptr->compression_type;
|
||||
|
||||
return (0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
png_uint_32 PNGAPI
|
||||
@ -116,21 +127,20 @@ png_get_x_pixels_per_meter(png_const_structrp png_ptr, png_const_inforp
|
||||
info_ptr)
|
||||
{
|
||||
#ifdef PNG_pHYs_SUPPORTED
|
||||
png_debug(1, "in png_get_x_pixels_per_meter");
|
||||
|
||||
if (png_ptr != NULL && info_ptr != NULL &&
|
||||
(info_ptr->valid & PNG_INFO_pHYs) != 0)
|
||||
{
|
||||
png_debug1(1, "in %s retrieval function",
|
||||
"png_get_x_pixels_per_meter");
|
||||
|
||||
if (info_ptr->phys_unit_type == PNG_RESOLUTION_METER)
|
||||
return (info_ptr->x_pixels_per_unit);
|
||||
}
|
||||
{
|
||||
if (info_ptr->phys_unit_type == PNG_RESOLUTION_METER)
|
||||
return info_ptr->x_pixels_per_unit;
|
||||
}
|
||||
#else
|
||||
PNG_UNUSED(png_ptr)
|
||||
PNG_UNUSED(info_ptr)
|
||||
#endif
|
||||
|
||||
return (0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
png_uint_32 PNGAPI
|
||||
@ -138,42 +148,41 @@ png_get_y_pixels_per_meter(png_const_structrp png_ptr, png_const_inforp
|
||||
info_ptr)
|
||||
{
|
||||
#ifdef PNG_pHYs_SUPPORTED
|
||||
png_debug(1, "in png_get_y_pixels_per_meter");
|
||||
|
||||
if (png_ptr != NULL && info_ptr != NULL &&
|
||||
(info_ptr->valid & PNG_INFO_pHYs) != 0)
|
||||
{
|
||||
png_debug1(1, "in %s retrieval function",
|
||||
"png_get_y_pixels_per_meter");
|
||||
|
||||
if (info_ptr->phys_unit_type == PNG_RESOLUTION_METER)
|
||||
return (info_ptr->y_pixels_per_unit);
|
||||
return info_ptr->y_pixels_per_unit;
|
||||
}
|
||||
#else
|
||||
PNG_UNUSED(png_ptr)
|
||||
PNG_UNUSED(info_ptr)
|
||||
#endif
|
||||
|
||||
return (0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
png_uint_32 PNGAPI
|
||||
png_get_pixels_per_meter(png_const_structrp png_ptr, png_const_inforp info_ptr)
|
||||
{
|
||||
#ifdef PNG_pHYs_SUPPORTED
|
||||
png_debug(1, "in png_get_pixels_per_meter");
|
||||
|
||||
if (png_ptr != NULL && info_ptr != NULL &&
|
||||
(info_ptr->valid & PNG_INFO_pHYs) != 0)
|
||||
{
|
||||
png_debug1(1, "in %s retrieval function", "png_get_pixels_per_meter");
|
||||
|
||||
if (info_ptr->phys_unit_type == PNG_RESOLUTION_METER &&
|
||||
info_ptr->x_pixels_per_unit == info_ptr->y_pixels_per_unit)
|
||||
return (info_ptr->x_pixels_per_unit);
|
||||
return info_ptr->x_pixels_per_unit;
|
||||
}
|
||||
#else
|
||||
PNG_UNUSED(png_ptr)
|
||||
PNG_UNUSED(info_ptr)
|
||||
#endif
|
||||
|
||||
return (0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef PNG_FLOATING_POINT_SUPPORTED
|
||||
@ -182,21 +191,21 @@ png_get_pixel_aspect_ratio(png_const_structrp png_ptr, png_const_inforp
|
||||
info_ptr)
|
||||
{
|
||||
#ifdef PNG_READ_pHYs_SUPPORTED
|
||||
png_debug(1, "in png_get_pixel_aspect_ratio");
|
||||
|
||||
if (png_ptr != NULL && info_ptr != NULL &&
|
||||
(info_ptr->valid & PNG_INFO_pHYs) != 0)
|
||||
{
|
||||
png_debug1(1, "in %s retrieval function", "png_get_aspect_ratio");
|
||||
|
||||
if (info_ptr->x_pixels_per_unit != 0)
|
||||
return ((float)((float)info_ptr->y_pixels_per_unit
|
||||
/(float)info_ptr->x_pixels_per_unit));
|
||||
return (float)info_ptr->y_pixels_per_unit
|
||||
/ (float)info_ptr->x_pixels_per_unit;
|
||||
}
|
||||
#else
|
||||
PNG_UNUSED(png_ptr)
|
||||
PNG_UNUSED(info_ptr)
|
||||
#endif
|
||||
|
||||
return ((float)0.0);
|
||||
return (float)0.0;
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -206,6 +215,8 @@ png_get_pixel_aspect_ratio_fixed(png_const_structrp png_ptr,
|
||||
png_const_inforp info_ptr)
|
||||
{
|
||||
#ifdef PNG_READ_pHYs_SUPPORTED
|
||||
png_debug(1, "in png_get_pixel_aspect_ratio_fixed");
|
||||
|
||||
if (png_ptr != NULL && info_ptr != NULL &&
|
||||
(info_ptr->valid & PNG_INFO_pHYs) != 0 &&
|
||||
info_ptr->x_pixels_per_unit > 0 && info_ptr->y_pixels_per_unit > 0 &&
|
||||
@ -214,8 +225,6 @@ png_get_pixel_aspect_ratio_fixed(png_const_structrp png_ptr,
|
||||
{
|
||||
png_fixed_point res;
|
||||
|
||||
png_debug1(1, "in %s retrieval function", "png_get_aspect_ratio_fixed");
|
||||
|
||||
/* The following casts work because a PNG 4 byte integer only has a valid
|
||||
* range of 0..2^31-1; otherwise the cast might overflow.
|
||||
*/
|
||||
@ -236,80 +245,80 @@ png_int_32 PNGAPI
|
||||
png_get_x_offset_microns(png_const_structrp png_ptr, png_const_inforp info_ptr)
|
||||
{
|
||||
#ifdef PNG_oFFs_SUPPORTED
|
||||
png_debug(1, "in png_get_x_offset_microns");
|
||||
|
||||
if (png_ptr != NULL && info_ptr != NULL &&
|
||||
(info_ptr->valid & PNG_INFO_oFFs) != 0)
|
||||
{
|
||||
png_debug1(1, "in %s retrieval function", "png_get_x_offset_microns");
|
||||
|
||||
if (info_ptr->offset_unit_type == PNG_OFFSET_MICROMETER)
|
||||
return (info_ptr->x_offset);
|
||||
return info_ptr->x_offset;
|
||||
}
|
||||
#else
|
||||
PNG_UNUSED(png_ptr)
|
||||
PNG_UNUSED(info_ptr)
|
||||
#endif
|
||||
|
||||
return (0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
png_int_32 PNGAPI
|
||||
png_get_y_offset_microns(png_const_structrp png_ptr, png_const_inforp info_ptr)
|
||||
{
|
||||
#ifdef PNG_oFFs_SUPPORTED
|
||||
png_debug(1, "in png_get_y_offset_microns");
|
||||
|
||||
if (png_ptr != NULL && info_ptr != NULL &&
|
||||
(info_ptr->valid & PNG_INFO_oFFs) != 0)
|
||||
{
|
||||
png_debug1(1, "in %s retrieval function", "png_get_y_offset_microns");
|
||||
|
||||
if (info_ptr->offset_unit_type == PNG_OFFSET_MICROMETER)
|
||||
return (info_ptr->y_offset);
|
||||
return info_ptr->y_offset;
|
||||
}
|
||||
#else
|
||||
PNG_UNUSED(png_ptr)
|
||||
PNG_UNUSED(info_ptr)
|
||||
#endif
|
||||
|
||||
return (0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
png_int_32 PNGAPI
|
||||
png_get_x_offset_pixels(png_const_structrp png_ptr, png_const_inforp info_ptr)
|
||||
{
|
||||
#ifdef PNG_oFFs_SUPPORTED
|
||||
png_debug(1, "in png_get_x_offset_pixels");
|
||||
|
||||
if (png_ptr != NULL && info_ptr != NULL &&
|
||||
(info_ptr->valid & PNG_INFO_oFFs) != 0)
|
||||
{
|
||||
png_debug1(1, "in %s retrieval function", "png_get_x_offset_pixels");
|
||||
|
||||
if (info_ptr->offset_unit_type == PNG_OFFSET_PIXEL)
|
||||
return (info_ptr->x_offset);
|
||||
return info_ptr->x_offset;
|
||||
}
|
||||
#else
|
||||
PNG_UNUSED(png_ptr)
|
||||
PNG_UNUSED(info_ptr)
|
||||
#endif
|
||||
|
||||
return (0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
png_int_32 PNGAPI
|
||||
png_get_y_offset_pixels(png_const_structrp png_ptr, png_const_inforp info_ptr)
|
||||
{
|
||||
#ifdef PNG_oFFs_SUPPORTED
|
||||
png_debug(1, "in png_get_y_offset_pixels");
|
||||
|
||||
if (png_ptr != NULL && info_ptr != NULL &&
|
||||
(info_ptr->valid & PNG_INFO_oFFs) != 0)
|
||||
{
|
||||
png_debug1(1, "in %s retrieval function", "png_get_y_offset_pixels");
|
||||
|
||||
if (info_ptr->offset_unit_type == PNG_OFFSET_PIXEL)
|
||||
return (info_ptr->y_offset);
|
||||
return info_ptr->y_offset;
|
||||
}
|
||||
#else
|
||||
PNG_UNUSED(png_ptr)
|
||||
PNG_UNUSED(info_ptr)
|
||||
#endif
|
||||
|
||||
return (0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef PNG_INCH_CONVERSIONS_SUPPORTED
|
||||
@ -423,11 +432,11 @@ png_get_pHYs_dpi(png_const_structrp png_ptr, png_const_inforp info_ptr,
|
||||
{
|
||||
png_uint_32 retval = 0;
|
||||
|
||||
png_debug1(1, "in %s retrieval function", "pHYs");
|
||||
|
||||
if (png_ptr != NULL && info_ptr != NULL &&
|
||||
(info_ptr->valid & PNG_INFO_pHYs) != 0)
|
||||
{
|
||||
png_debug1(1, "in %s retrieval function", "pHYs");
|
||||
|
||||
if (res_x != NULL)
|
||||
{
|
||||
*res_x = info_ptr->x_pixels_per_unit;
|
||||
@ -453,7 +462,7 @@ png_get_pHYs_dpi(png_const_structrp png_ptr, png_const_inforp info_ptr,
|
||||
}
|
||||
}
|
||||
|
||||
return (retval);
|
||||
return retval;
|
||||
}
|
||||
#endif /* pHYs */
|
||||
#endif /* INCH_CONVERSIONS */
|
||||
@ -467,9 +476,9 @@ png_byte PNGAPI
|
||||
png_get_channels(png_const_structrp png_ptr, png_const_inforp info_ptr)
|
||||
{
|
||||
if (png_ptr != NULL && info_ptr != NULL)
|
||||
return(info_ptr->channels);
|
||||
return info_ptr->channels;
|
||||
|
||||
return (0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef PNG_READ_SUPPORTED
|
||||
@ -477,9 +486,9 @@ png_const_bytep PNGAPI
|
||||
png_get_signature(png_const_structrp png_ptr, png_const_inforp info_ptr)
|
||||
{
|
||||
if (png_ptr != NULL && info_ptr != NULL)
|
||||
return(info_ptr->signature);
|
||||
return info_ptr->signature;
|
||||
|
||||
return (NULL);
|
||||
return NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -488,17 +497,17 @@ png_uint_32 PNGAPI
|
||||
png_get_bKGD(png_const_structrp png_ptr, png_inforp info_ptr,
|
||||
png_color_16p *background)
|
||||
{
|
||||
png_debug1(1, "in %s retrieval function", "bKGD");
|
||||
|
||||
if (png_ptr != NULL && info_ptr != NULL &&
|
||||
(info_ptr->valid & PNG_INFO_bKGD) != 0 &&
|
||||
background != NULL)
|
||||
{
|
||||
png_debug1(1, "in %s retrieval function", "bKGD");
|
||||
|
||||
*background = &(info_ptr->background);
|
||||
return (PNG_INFO_bKGD);
|
||||
return PNG_INFO_bKGD;
|
||||
}
|
||||
|
||||
return (0);
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -513,6 +522,8 @@ png_get_cHRM(png_const_structrp png_ptr, png_const_inforp info_ptr,
|
||||
double *white_x, double *white_y, double *red_x, double *red_y,
|
||||
double *green_x, double *green_y, double *blue_x, double *blue_y)
|
||||
{
|
||||
png_debug1(1, "in %s retrieval function", "cHRM");
|
||||
|
||||
/* Quiet API change: this code used to only return the end points if a cHRM
|
||||
* chunk was present, but the end points can also come from iCCP or sRGB
|
||||
* chunks, so in 1.6.0 the png_get_ APIs return the end points regardless and
|
||||
@ -522,8 +533,6 @@ png_get_cHRM(png_const_structrp png_ptr, png_const_inforp info_ptr,
|
||||
if (png_ptr != NULL && info_ptr != NULL &&
|
||||
(info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_ENDPOINTS) != 0)
|
||||
{
|
||||
png_debug1(1, "in %s retrieval function", "cHRM");
|
||||
|
||||
if (white_x != NULL)
|
||||
*white_x = png_float(png_ptr,
|
||||
info_ptr->colorspace.end_points_xy.whitex, "cHRM white X");
|
||||
@ -548,10 +557,10 @@ png_get_cHRM(png_const_structrp png_ptr, png_const_inforp info_ptr,
|
||||
if (blue_y != NULL)
|
||||
*blue_y = png_float(png_ptr, info_ptr->colorspace.end_points_xy.bluey,
|
||||
"cHRM blue Y");
|
||||
return (PNG_INFO_cHRM);
|
||||
return PNG_INFO_cHRM;
|
||||
}
|
||||
|
||||
return (0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
png_uint_32 PNGAPI
|
||||
@ -560,11 +569,11 @@ png_get_cHRM_XYZ(png_const_structrp png_ptr, png_const_inforp info_ptr,
|
||||
double *green_Y, double *green_Z, double *blue_X, double *blue_Y,
|
||||
double *blue_Z)
|
||||
{
|
||||
png_debug1(1, "in %s retrieval function", "cHRM_XYZ(float)");
|
||||
|
||||
if (png_ptr != NULL && info_ptr != NULL &&
|
||||
(info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_ENDPOINTS) != 0)
|
||||
{
|
||||
png_debug1(1, "in %s retrieval function", "cHRM_XYZ(float)");
|
||||
|
||||
if (red_X != NULL)
|
||||
*red_X = png_float(png_ptr, info_ptr->colorspace.end_points_XYZ.red_X,
|
||||
"cHRM red X");
|
||||
@ -592,10 +601,10 @@ png_get_cHRM_XYZ(png_const_structrp png_ptr, png_const_inforp info_ptr,
|
||||
if (blue_Z != NULL)
|
||||
*blue_Z = png_float(png_ptr,
|
||||
info_ptr->colorspace.end_points_XYZ.blue_Z, "cHRM blue Z");
|
||||
return (PNG_INFO_cHRM);
|
||||
return PNG_INFO_cHRM;
|
||||
}
|
||||
|
||||
return (0);
|
||||
return 0;
|
||||
}
|
||||
# endif
|
||||
|
||||
@ -608,11 +617,11 @@ png_get_cHRM_XYZ_fixed(png_const_structrp png_ptr, png_const_inforp info_ptr,
|
||||
png_fixed_point *int_blue_X, png_fixed_point *int_blue_Y,
|
||||
png_fixed_point *int_blue_Z)
|
||||
{
|
||||
png_debug1(1, "in %s retrieval function", "cHRM_XYZ");
|
||||
|
||||
if (png_ptr != NULL && info_ptr != NULL &&
|
||||
(info_ptr->colorspace.flags & PNG_COLORSPACE_HAVE_ENDPOINTS) != 0)
|
||||
{
|
||||
png_debug1(1, "in %s retrieval function", "cHRM_XYZ");
|
||||
|
||||
if (int_red_X != NULL)
|
||||
*int_red_X = info_ptr->colorspace.end_points_XYZ.red_X;
|
||||
if (int_red_Y != NULL)
|
||||
@ -631,10 +640,10 @@ png_get_cHRM_XYZ_fixed(png_const_structrp png_ptr, png_const_inforp info_ptr,
|
||||
*int_blue_Y = info_ptr->colorspace.end_points_XYZ.blue_Y;
|
||||
if (int_blue_Z != NULL)
|
||||
*int_blue_Z = info_ptr->colorspace.end_points_XYZ.blue_Z;
|
||||
return (PNG_INFO_cHRM);
|
||||
return PNG_INFO_cHRM;
|
||||
}
|
||||
|
||||
return (0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
png_uint_32 PNGAPI
|
||||
@ -664,10 +673,10 @@ png_get_cHRM_fixed(png_const_structrp png_ptr, png_const_inforp info_ptr,
|
||||
*blue_x = info_ptr->colorspace.end_points_xy.bluex;
|
||||
if (blue_y != NULL)
|
||||
*blue_y = info_ptr->colorspace.end_points_xy.bluey;
|
||||
return (PNG_INFO_cHRM);
|
||||
return PNG_INFO_cHRM;
|
||||
}
|
||||
|
||||
return (0);
|
||||
return 0;
|
||||
}
|
||||
# endif
|
||||
#endif
|
||||
@ -685,10 +694,10 @@ png_get_gAMA_fixed(png_const_structrp png_ptr, png_const_inforp info_ptr,
|
||||
file_gamma != NULL)
|
||||
{
|
||||
*file_gamma = info_ptr->colorspace.gamma;
|
||||
return (PNG_INFO_gAMA);
|
||||
return PNG_INFO_gAMA;
|
||||
}
|
||||
|
||||
return (0);
|
||||
return 0;
|
||||
}
|
||||
# endif
|
||||
|
||||
@ -705,10 +714,10 @@ png_get_gAMA(png_const_structrp png_ptr, png_const_inforp info_ptr,
|
||||
{
|
||||
*file_gamma = png_float(png_ptr, info_ptr->colorspace.gamma,
|
||||
"png_get_gAMA");
|
||||
return (PNG_INFO_gAMA);
|
||||
return PNG_INFO_gAMA;
|
||||
}
|
||||
|
||||
return (0);
|
||||
return 0;
|
||||
}
|
||||
# endif
|
||||
#endif
|
||||
@ -724,10 +733,10 @@ png_get_sRGB(png_const_structrp png_ptr, png_const_inforp info_ptr,
|
||||
(info_ptr->valid & PNG_INFO_sRGB) != 0 && file_srgb_intent != NULL)
|
||||
{
|
||||
*file_srgb_intent = info_ptr->colorspace.rendering_intent;
|
||||
return (PNG_INFO_sRGB);
|
||||
return PNG_INFO_sRGB;
|
||||
}
|
||||
|
||||
return (0);
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -751,10 +760,10 @@ png_get_iCCP(png_const_structrp png_ptr, png_inforp info_ptr,
|
||||
*/
|
||||
if (compression_type != NULL)
|
||||
*compression_type = PNG_COMPRESSION_TYPE_BASE;
|
||||
return (PNG_INFO_iCCP);
|
||||
return PNG_INFO_iCCP;
|
||||
}
|
||||
|
||||
return (0);
|
||||
return 0;
|
||||
|
||||
}
|
||||
#endif
|
||||
@ -764,13 +773,15 @@ int PNGAPI
|
||||
png_get_sPLT(png_const_structrp png_ptr, png_inforp info_ptr,
|
||||
png_sPLT_tpp spalettes)
|
||||
{
|
||||
png_debug1(1, "in %s retrieval function", "sPLT");
|
||||
|
||||
if (png_ptr != NULL && info_ptr != NULL && spalettes != NULL)
|
||||
{
|
||||
*spalettes = info_ptr->splt_palettes;
|
||||
return info_ptr->splt_palettes_num;
|
||||
}
|
||||
|
||||
return (0);
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -796,10 +807,10 @@ png_get_eXIf_1(png_const_structrp png_ptr, png_const_inforp info_ptr,
|
||||
{
|
||||
*num_exif = info_ptr->num_exif;
|
||||
*exif = info_ptr->exif;
|
||||
return (PNG_INFO_eXIf);
|
||||
return PNG_INFO_eXIf;
|
||||
}
|
||||
|
||||
return (0);
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -814,10 +825,10 @@ png_get_hIST(png_const_structrp png_ptr, png_inforp info_ptr,
|
||||
(info_ptr->valid & PNG_INFO_hIST) != 0 && hist != NULL)
|
||||
{
|
||||
*hist = info_ptr->hist;
|
||||
return (PNG_INFO_hIST);
|
||||
return PNG_INFO_hIST;
|
||||
}
|
||||
|
||||
return (0);
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -830,7 +841,7 @@ png_get_IHDR(png_const_structrp png_ptr, png_const_inforp info_ptr,
|
||||
png_debug1(1, "in %s retrieval function", "IHDR");
|
||||
|
||||
if (png_ptr == NULL || info_ptr == NULL)
|
||||
return (0);
|
||||
return 0;
|
||||
|
||||
if (width != NULL)
|
||||
*width = info_ptr->width;
|
||||
@ -862,7 +873,7 @@ png_get_IHDR(png_const_structrp png_ptr, png_const_inforp info_ptr,
|
||||
info_ptr->bit_depth, info_ptr->color_type, info_ptr->interlace_type,
|
||||
info_ptr->compression_type, info_ptr->filter_type);
|
||||
|
||||
return (1);
|
||||
return 1;
|
||||
}
|
||||
|
||||
#ifdef PNG_oFFs_SUPPORTED
|
||||
@ -879,10 +890,10 @@ png_get_oFFs(png_const_structrp png_ptr, png_const_inforp info_ptr,
|
||||
*offset_x = info_ptr->x_offset;
|
||||
*offset_y = info_ptr->y_offset;
|
||||
*unit_type = (int)info_ptr->offset_unit_type;
|
||||
return (PNG_INFO_oFFs);
|
||||
return PNG_INFO_oFFs;
|
||||
}
|
||||
|
||||
return (0);
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -906,10 +917,10 @@ png_get_pCAL(png_const_structrp png_ptr, png_inforp info_ptr,
|
||||
*nparams = (int)info_ptr->pcal_nparams;
|
||||
*units = info_ptr->pcal_units;
|
||||
*params = info_ptr->pcal_params;
|
||||
return (PNG_INFO_pCAL);
|
||||
return PNG_INFO_pCAL;
|
||||
}
|
||||
|
||||
return (0);
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -921,6 +932,8 @@ png_uint_32 PNGAPI
|
||||
png_get_sCAL_fixed(png_const_structrp png_ptr, png_const_inforp info_ptr,
|
||||
int *unit, png_fixed_point *width, png_fixed_point *height)
|
||||
{
|
||||
png_debug1(1, "in %s retrieval function", "sCAL");
|
||||
|
||||
if (png_ptr != NULL && info_ptr != NULL &&
|
||||
(info_ptr->valid & PNG_INFO_sCAL) != 0)
|
||||
{
|
||||
@ -932,10 +945,10 @@ png_get_sCAL_fixed(png_const_structrp png_ptr, png_const_inforp info_ptr,
|
||||
*width = png_fixed(png_ptr, atof(info_ptr->scal_s_width), "sCAL width");
|
||||
*height = png_fixed(png_ptr, atof(info_ptr->scal_s_height),
|
||||
"sCAL height");
|
||||
return (PNG_INFO_sCAL);
|
||||
return PNG_INFO_sCAL;
|
||||
}
|
||||
|
||||
return(0);
|
||||
return 0;
|
||||
}
|
||||
# endif /* FLOATING_ARITHMETIC */
|
||||
# endif /* FIXED_POINT */
|
||||
@ -944,32 +957,36 @@ png_uint_32 PNGAPI
|
||||
png_get_sCAL(png_const_structrp png_ptr, png_const_inforp info_ptr,
|
||||
int *unit, double *width, double *height)
|
||||
{
|
||||
png_debug1(1, "in %s retrieval function", "sCAL(float)");
|
||||
|
||||
if (png_ptr != NULL && info_ptr != NULL &&
|
||||
(info_ptr->valid & PNG_INFO_sCAL) != 0)
|
||||
{
|
||||
*unit = info_ptr->scal_unit;
|
||||
*width = atof(info_ptr->scal_s_width);
|
||||
*height = atof(info_ptr->scal_s_height);
|
||||
return (PNG_INFO_sCAL);
|
||||
return PNG_INFO_sCAL;
|
||||
}
|
||||
|
||||
return(0);
|
||||
return 0;
|
||||
}
|
||||
# endif /* FLOATING POINT */
|
||||
png_uint_32 PNGAPI
|
||||
png_get_sCAL_s(png_const_structrp png_ptr, png_const_inforp info_ptr,
|
||||
int *unit, png_charpp width, png_charpp height)
|
||||
{
|
||||
png_debug1(1, "in %s retrieval function", "sCAL(str)");
|
||||
|
||||
if (png_ptr != NULL && info_ptr != NULL &&
|
||||
(info_ptr->valid & PNG_INFO_sCAL) != 0)
|
||||
{
|
||||
*unit = info_ptr->scal_unit;
|
||||
*width = info_ptr->scal_s_width;
|
||||
*height = info_ptr->scal_s_height;
|
||||
return (PNG_INFO_sCAL);
|
||||
return PNG_INFO_sCAL;
|
||||
}
|
||||
|
||||
return(0);
|
||||
return 0;
|
||||
}
|
||||
#endif /* sCAL */
|
||||
|
||||
@ -1004,7 +1021,7 @@ png_get_pHYs(png_const_structrp png_ptr, png_const_inforp info_ptr,
|
||||
}
|
||||
}
|
||||
|
||||
return (retval);
|
||||
return retval;
|
||||
}
|
||||
#endif /* pHYs */
|
||||
|
||||
@ -1020,10 +1037,10 @@ png_get_PLTE(png_const_structrp png_ptr, png_inforp info_ptr,
|
||||
*palette = info_ptr->palette;
|
||||
*num_palette = info_ptr->num_palette;
|
||||
png_debug1(3, "num_palette = %d", *num_palette);
|
||||
return (PNG_INFO_PLTE);
|
||||
return PNG_INFO_PLTE;
|
||||
}
|
||||
|
||||
return (0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef PNG_sBIT_SUPPORTED
|
||||
@ -1037,10 +1054,10 @@ png_get_sBIT(png_const_structrp png_ptr, png_inforp info_ptr,
|
||||
(info_ptr->valid & PNG_INFO_sBIT) != 0 && sig_bit != NULL)
|
||||
{
|
||||
*sig_bit = &(info_ptr->sig_bit);
|
||||
return (PNG_INFO_sBIT);
|
||||
return PNG_INFO_sBIT;
|
||||
}
|
||||
|
||||
return (0);
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -1051,7 +1068,7 @@ png_get_text(png_const_structrp png_ptr, png_inforp info_ptr,
|
||||
{
|
||||
if (png_ptr != NULL && info_ptr != NULL && info_ptr->num_text > 0)
|
||||
{
|
||||
png_debug1(1, "in 0x%lx retrieval function",
|
||||
png_debug1(1, "in text retrieval function, chunk typeid = 0x%lx",
|
||||
(unsigned long)png_ptr->chunk_name);
|
||||
|
||||
if (text_ptr != NULL)
|
||||
@ -1066,7 +1083,7 @@ png_get_text(png_const_structrp png_ptr, png_inforp info_ptr,
|
||||
if (num_text != NULL)
|
||||
*num_text = 0;
|
||||
|
||||
return(0);
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -1081,10 +1098,10 @@ png_get_tIME(png_const_structrp png_ptr, png_inforp info_ptr,
|
||||
(info_ptr->valid & PNG_INFO_tIME) != 0 && mod_time != NULL)
|
||||
{
|
||||
*mod_time = &(info_ptr->mod_time);
|
||||
return (PNG_INFO_tIME);
|
||||
return PNG_INFO_tIME;
|
||||
}
|
||||
|
||||
return (0);
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -1094,11 +1111,12 @@ png_get_tRNS(png_const_structrp png_ptr, png_inforp info_ptr,
|
||||
png_bytep *trans_alpha, int *num_trans, png_color_16p *trans_color)
|
||||
{
|
||||
png_uint_32 retval = 0;
|
||||
|
||||
png_debug1(1, "in %s retrieval function", "tRNS");
|
||||
|
||||
if (png_ptr != NULL && info_ptr != NULL &&
|
||||
(info_ptr->valid & PNG_INFO_tRNS) != 0)
|
||||
{
|
||||
png_debug1(1, "in %s retrieval function", "tRNS");
|
||||
|
||||
if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE)
|
||||
{
|
||||
if (trans_alpha != NULL)
|
||||
@ -1130,7 +1148,7 @@ png_get_tRNS(png_const_structrp png_ptr, png_inforp info_ptr,
|
||||
}
|
||||
}
|
||||
|
||||
return (retval);
|
||||
return retval;
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -1145,13 +1163,13 @@ png_get_unknown_chunks(png_const_structrp png_ptr, png_inforp info_ptr,
|
||||
return info_ptr->unknown_chunks_num;
|
||||
}
|
||||
|
||||
return (0);
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED
|
||||
png_byte PNGAPI
|
||||
png_get_rgb_to_gray_status (png_const_structrp png_ptr)
|
||||
png_get_rgb_to_gray_status(png_const_structrp png_ptr)
|
||||
{
|
||||
return (png_byte)(png_ptr ? png_ptr->rgb_to_gray_status : 0);
|
||||
}
|
||||
@ -1192,27 +1210,27 @@ png_get_compression_buffer_size(png_const_structrp png_ptr)
|
||||
/* These functions were added to libpng 1.2.6 and were enabled
|
||||
* by default in libpng-1.4.0 */
|
||||
png_uint_32 PNGAPI
|
||||
png_get_user_width_max (png_const_structrp png_ptr)
|
||||
png_get_user_width_max(png_const_structrp png_ptr)
|
||||
{
|
||||
return (png_ptr ? png_ptr->user_width_max : 0);
|
||||
}
|
||||
|
||||
png_uint_32 PNGAPI
|
||||
png_get_user_height_max (png_const_structrp png_ptr)
|
||||
png_get_user_height_max(png_const_structrp png_ptr)
|
||||
{
|
||||
return (png_ptr ? png_ptr->user_height_max : 0);
|
||||
}
|
||||
|
||||
/* This function was added to libpng 1.4.0 */
|
||||
png_uint_32 PNGAPI
|
||||
png_get_chunk_cache_max (png_const_structrp png_ptr)
|
||||
png_get_chunk_cache_max(png_const_structrp png_ptr)
|
||||
{
|
||||
return (png_ptr ? png_ptr->user_chunk_cache_max : 0);
|
||||
}
|
||||
|
||||
/* This function was added to libpng 1.4.1 */
|
||||
png_alloc_size_t PNGAPI
|
||||
png_get_chunk_malloc_max (png_const_structrp png_ptr)
|
||||
png_get_chunk_malloc_max(png_const_structrp png_ptr)
|
||||
{
|
||||
return (png_ptr ? png_ptr->user_chunk_malloc_max : 0);
|
||||
}
|
||||
@ -1221,13 +1239,13 @@ png_get_chunk_malloc_max (png_const_structrp png_ptr)
|
||||
/* These functions were added to libpng 1.4.0 */
|
||||
#ifdef PNG_IO_STATE_SUPPORTED
|
||||
png_uint_32 PNGAPI
|
||||
png_get_io_state (png_const_structrp png_ptr)
|
||||
png_get_io_state(png_const_structrp png_ptr)
|
||||
{
|
||||
return png_ptr->io_state;
|
||||
}
|
||||
|
||||
png_uint_32 PNGAPI
|
||||
png_get_io_chunk_type (png_const_structrp png_ptr)
|
||||
png_get_io_chunk_type(png_const_structrp png_ptr)
|
||||
{
|
||||
return png_ptr->chunk_name;
|
||||
}
|
||||
@ -1241,7 +1259,7 @@ png_get_palette_max(png_const_structp png_ptr, png_const_infop info_ptr)
|
||||
if (png_ptr != NULL && info_ptr != NULL)
|
||||
return png_ptr->num_palette_max;
|
||||
|
||||
return (-1);
|
||||
return -1;
|
||||
}
|
||||
# endif
|
||||
#endif
|
||||
|
16
3rdparty/libpng/pngpread.c
vendored
16
3rdparty/libpng/pngpread.c
vendored
@ -1,7 +1,7 @@
|
||||
|
||||
/* pngpread.c - read a png file in push mode
|
||||
*
|
||||
* Copyright (c) 2018 Cosmin Truta
|
||||
* Copyright (c) 2018-2024 Cosmin Truta
|
||||
* Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson
|
||||
* Copyright (c) 1996-1997 Andreas Dilger
|
||||
* Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
|
||||
@ -145,10 +145,10 @@ png_push_read_sig(png_structrp png_ptr, png_inforp info_ptr)
|
||||
num_to_check);
|
||||
png_ptr->sig_bytes = (png_byte)(png_ptr->sig_bytes + num_to_check);
|
||||
|
||||
if (png_sig_cmp(info_ptr->signature, num_checked, num_to_check))
|
||||
if (png_sig_cmp(info_ptr->signature, num_checked, num_to_check) != 0)
|
||||
{
|
||||
if (num_checked < 4 &&
|
||||
png_sig_cmp(info_ptr->signature, num_checked, num_to_check - 4))
|
||||
png_sig_cmp(info_ptr->signature, num_checked, num_to_check - 4) != 0)
|
||||
png_error(png_ptr, "Not a PNG file");
|
||||
|
||||
else
|
||||
@ -294,6 +294,14 @@ 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_eXIf_SUPPORTED
|
||||
else if (png_ptr->chunk_name == png_eXIf)
|
||||
{
|
||||
PNG_PUSH_SAVE_BUFFER_IF_FULL
|
||||
png_handle_eXIf(png_ptr, info_ptr, png_ptr->push_length);
|
||||
}
|
||||
|
||||
#endif
|
||||
#ifdef PNG_READ_sRGB_SUPPORTED
|
||||
else if (chunk_name == png_sRGB)
|
||||
@ -1089,7 +1097,7 @@ png_voidp PNGAPI
|
||||
png_get_progressive_ptr(png_const_structrp png_ptr)
|
||||
{
|
||||
if (png_ptr == NULL)
|
||||
return (NULL);
|
||||
return NULL;
|
||||
|
||||
return png_ptr->io_ptr;
|
||||
}
|
||||
|
187
3rdparty/libpng/pngpriv.h
vendored
187
3rdparty/libpng/pngpriv.h
vendored
@ -1,7 +1,7 @@
|
||||
|
||||
/* pngpriv.h - private declarations for use inside libpng
|
||||
*
|
||||
* Copyright (c) 2018-2019 Cosmin Truta
|
||||
* Copyright (c) 2018-2024 Cosmin Truta
|
||||
* Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson
|
||||
* Copyright (c) 1996-1997 Andreas Dilger
|
||||
* Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
|
||||
@ -36,7 +36,7 @@
|
||||
* still required (as of 2011-05-02.)
|
||||
*/
|
||||
#ifndef _POSIX_SOURCE
|
||||
# define _POSIX_SOURCE 1 /* Just the POSIX 1003.1 and C89 APIs */
|
||||
# define _POSIX_SOURCE 1 /* Just the POSIX 1003.1 and C89 APIs */
|
||||
#endif
|
||||
|
||||
#ifndef PNG_VERSION_INFO_ONLY
|
||||
@ -174,7 +174,7 @@
|
||||
# else /* !defined __ARM_NEON__ */
|
||||
/* The 'intrinsics' code simply won't compile without this -mfpu=neon:
|
||||
*/
|
||||
# if !defined(__aarch64__)
|
||||
# if !defined(__aarch64__) && !defined(_M_ARM64)
|
||||
/* The assembler code currently does not work on ARM64 */
|
||||
# define PNG_ARM_NEON_IMPLEMENTATION 2
|
||||
# endif /* __aarch64__ */
|
||||
@ -185,16 +185,32 @@
|
||||
/* Use the intrinsics code by default. */
|
||||
# define PNG_ARM_NEON_IMPLEMENTATION 1
|
||||
# endif
|
||||
#else /* PNG_ARM_NEON_OPT == 0 */
|
||||
# define PNG_ARM_NEON_IMPLEMENTATION 0
|
||||
#endif /* PNG_ARM_NEON_OPT > 0 */
|
||||
|
||||
#ifndef PNG_MIPS_MSA_OPT
|
||||
# if defined(__mips_msa) && (__mips_isa_rev >= 5) && defined(PNG_ALIGNED_MEMORY_SUPPORTED)
|
||||
# if defined(__mips_msa) && (__mips_isa_rev >= 5) && \
|
||||
defined(PNG_ALIGNED_MEMORY_SUPPORTED)
|
||||
# define PNG_MIPS_MSA_OPT 2
|
||||
# else
|
||||
# define PNG_MIPS_MSA_OPT 0
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef PNG_MIPS_MMI_OPT
|
||||
# ifdef PNG_MIPS_MMI
|
||||
# if defined(__mips_loongson_mmi) && (_MIPS_SIM == _ABI64) && \
|
||||
defined(PNG_ALIGNED_MEMORY_SUPPORTED)
|
||||
# define PNG_MIPS_MMI_OPT 1
|
||||
# else
|
||||
# define PNG_MIPS_MMI_OPT 0
|
||||
# endif
|
||||
# else
|
||||
# define PNG_MIPS_MMI_OPT 0
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef PNG_POWERPC_VSX_OPT
|
||||
# if defined(__PPC64__) && defined(__ALTIVEC__) && defined(__VSX__)
|
||||
# define PNG_POWERPC_VSX_OPT 2
|
||||
@ -203,13 +219,21 @@
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef PNG_LOONGARCH_LSX_OPT
|
||||
# if defined(__loongarch_sx)
|
||||
# define PNG_LOONGARCH_LSX_OPT 1
|
||||
# else
|
||||
# define PNG_LOONGARCH_LSX_OPT 0
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef PNG_INTEL_SSE_OPT
|
||||
# ifdef PNG_INTEL_SSE
|
||||
/* Only check for SSE if the build configuration has been modified to
|
||||
* enable SSE optimizations. This means that these optimizations will
|
||||
* be off by default. See contrib/intel for more details.
|
||||
*/
|
||||
# if defined(__SSE4_1__) || defined(__AVX__) || defined(__SSSE3__) || \
|
||||
# if defined(__SSE4_1__) || defined(__AVX__) || defined(__SSSE3__) || \
|
||||
defined(__SSE2__) || defined(_M_X64) || defined(_M_AMD64) || \
|
||||
(defined(_M_IX86_FP) && _M_IX86_FP >= 2)
|
||||
# define PNG_INTEL_SSE_OPT 1
|
||||
@ -246,7 +270,6 @@
|
||||
#endif
|
||||
|
||||
#if PNG_MIPS_MSA_OPT > 0
|
||||
# define PNG_FILTER_OPTIMIZATIONS png_init_filter_functions_msa
|
||||
# ifndef PNG_MIPS_MSA_IMPLEMENTATION
|
||||
# if defined(__mips_msa)
|
||||
# if defined(__clang__)
|
||||
@ -262,14 +285,41 @@
|
||||
|
||||
# ifndef PNG_MIPS_MSA_IMPLEMENTATION
|
||||
# define PNG_MIPS_MSA_IMPLEMENTATION 1
|
||||
# define PNG_FILTER_OPTIMIZATIONS png_init_filter_functions_mips
|
||||
# endif
|
||||
#else
|
||||
# define PNG_MIPS_MSA_IMPLEMENTATION 0
|
||||
#endif /* PNG_MIPS_MSA_OPT > 0 */
|
||||
|
||||
#if PNG_MIPS_MMI_OPT > 0
|
||||
# ifndef PNG_MIPS_MMI_IMPLEMENTATION
|
||||
# if defined(__mips_loongson_mmi) && (_MIPS_SIM == _ABI64)
|
||||
# define PNG_MIPS_MMI_IMPLEMENTATION 2
|
||||
# else /* !defined __mips_loongson_mmi || _MIPS_SIM != _ABI64 */
|
||||
# define PNG_MIPS_MMI_IMPLEMENTATION 0
|
||||
# endif /* __mips_loongson_mmi && _MIPS_SIM == _ABI64 */
|
||||
# endif /* !PNG_MIPS_MMI_IMPLEMENTATION */
|
||||
|
||||
# if PNG_MIPS_MMI_IMPLEMENTATION > 0
|
||||
# define PNG_FILTER_OPTIMIZATIONS png_init_filter_functions_mips
|
||||
# endif
|
||||
#else
|
||||
# define PNG_MIPS_MMI_IMPLEMENTATION 0
|
||||
#endif /* PNG_MIPS_MMI_OPT > 0 */
|
||||
|
||||
#if PNG_POWERPC_VSX_OPT > 0
|
||||
# define PNG_FILTER_OPTIMIZATIONS png_init_filter_functions_vsx
|
||||
# define PNG_POWERPC_VSX_IMPLEMENTATION 1
|
||||
#else
|
||||
# define PNG_POWERPC_VSX_IMPLEMENTATION 0
|
||||
#endif
|
||||
|
||||
#if PNG_LOONGARCH_LSX_OPT > 0
|
||||
# define PNG_FILTER_OPTIMIZATIONS png_init_filter_functions_lsx
|
||||
# define PNG_LOONGARCH_LSX_IMPLEMENTATION 1
|
||||
#else
|
||||
# define PNG_LOONGARCH_LSX_IMPLEMENTATION 0
|
||||
#endif
|
||||
|
||||
/* Is this a build of a DLL where compilation of the object modules requires
|
||||
* different preprocessor settings to those required for a simple library? If
|
||||
@ -492,16 +542,7 @@
|
||||
static_cast<type>(static_cast<const void*>(value))
|
||||
#else
|
||||
# define png_voidcast(type, value) (value)
|
||||
# ifdef _WIN64
|
||||
# ifdef __GNUC__
|
||||
typedef unsigned long long png_ptruint;
|
||||
# else
|
||||
typedef unsigned __int64 png_ptruint;
|
||||
# endif
|
||||
# else
|
||||
typedef unsigned long png_ptruint;
|
||||
# endif
|
||||
# define png_constcast(type, value) ((type)(png_ptruint)(const void*)(value))
|
||||
# define png_constcast(type, value) ((type)(void*)(const void*)(value))
|
||||
# define png_aligncast(type, value) ((void*)(value))
|
||||
# define png_aligncastconst(type, value) ((const void*)(value))
|
||||
#endif /* __cplusplus */
|
||||
@ -517,18 +558,8 @@
|
||||
*/
|
||||
# include <float.h>
|
||||
|
||||
# if (defined(__MWERKS__) && defined(macintosh)) || defined(applec) || \
|
||||
defined(THINK_C) || defined(__SC__) || defined(TARGET_OS_MAC)
|
||||
/* We need to check that <math.h> hasn't already been included earlier
|
||||
* as it seems it doesn't agree with <fp.h>, yet we should really use
|
||||
* <fp.h> if possible.
|
||||
*/
|
||||
# if !defined(__MATH_H__) && !defined(__MATH_H) && !defined(__cmath__)
|
||||
# include <fp.h>
|
||||
# endif
|
||||
# else
|
||||
# include <math.h>
|
||||
# endif
|
||||
# include <math.h>
|
||||
|
||||
# if defined(_AMIGA) && defined(__SASC) && defined(_M68881)
|
||||
/* Amiga SAS/C: We must include builtin FPU functions when compiling using
|
||||
* MATH=68881
|
||||
@ -543,9 +574,8 @@
|
||||
# include <alloc.h>
|
||||
#endif
|
||||
|
||||
#if defined(WIN32) || defined(_Windows) || defined(_WINDOWS) || \
|
||||
defined(_WIN32) || defined(__WIN32__)
|
||||
# include <windows.h> /* defines _WINDOWS_ macro */
|
||||
#if defined(_WIN32) || defined(__WIN32__) || defined(__NT__)
|
||||
# include <windows.h>
|
||||
#endif
|
||||
#endif /* PNG_VERSION_INFO_ONLY */
|
||||
|
||||
@ -554,24 +584,20 @@
|
||||
* functions that are passed far data must be model-independent.
|
||||
*/
|
||||
|
||||
/* Memory model/platform independent fns */
|
||||
/* Platform-independent functions */
|
||||
#ifndef PNG_ABORT
|
||||
# ifdef _WINDOWS_
|
||||
# define PNG_ABORT() ExitProcess(0)
|
||||
# else
|
||||
# define PNG_ABORT() abort()
|
||||
# endif
|
||||
# define PNG_ABORT() abort()
|
||||
#endif
|
||||
|
||||
/* These macros may need to be architecture dependent. */
|
||||
#define PNG_ALIGN_NONE 0 /* do not use data alignment */
|
||||
#define PNG_ALIGN_ALWAYS 1 /* assume unaligned accesses are OK */
|
||||
#define PNG_ALIGN_NONE 0 /* do not use data alignment */
|
||||
#define PNG_ALIGN_ALWAYS 1 /* assume unaligned accesses are OK */
|
||||
#ifdef offsetof
|
||||
# define PNG_ALIGN_OFFSET 2 /* use offsetof to determine alignment */
|
||||
# define PNG_ALIGN_OFFSET 2 /* use offsetof to determine alignment */
|
||||
#else
|
||||
# define PNG_ALIGN_OFFSET -1 /* prevent the use of this */
|
||||
#endif
|
||||
#define PNG_ALIGN_SIZE 3 /* use sizeof to determine alignment */
|
||||
#define PNG_ALIGN_SIZE 3 /* use sizeof to determine alignment */
|
||||
|
||||
#ifndef PNG_ALIGN_TYPE
|
||||
/* Default to using aligned access optimizations and requiring alignment to a
|
||||
@ -585,26 +611,25 @@
|
||||
/* This is used because in some compiler implementations non-aligned
|
||||
* structure members are supported, so the offsetof approach below fails.
|
||||
* Set PNG_ALIGN_SIZE=0 for compiler combinations where unaligned access
|
||||
* is good for performance. Do not do this unless you have tested the result
|
||||
* and understand it.
|
||||
* is good for performance. Do not do this unless you have tested the
|
||||
* result and understand it.
|
||||
*/
|
||||
# define png_alignof(type) (sizeof (type))
|
||||
# define png_alignof(type) (sizeof(type))
|
||||
#else
|
||||
# if PNG_ALIGN_TYPE == PNG_ALIGN_OFFSET
|
||||
# define png_alignof(type) offsetof(struct{char c; type t;}, t)
|
||||
# define png_alignof(type) offsetof(struct{char c; type t;}, t)
|
||||
# else
|
||||
# if PNG_ALIGN_TYPE == PNG_ALIGN_ALWAYS
|
||||
# define png_alignof(type) (1)
|
||||
# endif
|
||||
/* Else leave png_alignof undefined to prevent use thereof */
|
||||
# if PNG_ALIGN_TYPE == PNG_ALIGN_ALWAYS
|
||||
# define png_alignof(type) 1
|
||||
# endif
|
||||
/* Else leave png_alignof undefined to prevent use thereof */
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* This implicitly assumes alignment is always to a power of 2. */
|
||||
/* This implicitly assumes alignment is always a multiple of 2. */
|
||||
#ifdef png_alignof
|
||||
# define png_isaligned(ptr, type)\
|
||||
(((type)((const char*)ptr-(const char*)0) & \
|
||||
(type)(png_alignof(type)-1)) == 0)
|
||||
# define png_isaligned(ptr, type) \
|
||||
(((type)(size_t)((const void*)(ptr)) & (type)(png_alignof(type)-1)) == 0)
|
||||
#else
|
||||
# define png_isaligned(ptr, type) 0
|
||||
#endif
|
||||
@ -635,7 +660,7 @@
|
||||
#define PNG_BACKGROUND_IS_GRAY 0x800U
|
||||
#define PNG_HAVE_PNG_SIGNATURE 0x1000U
|
||||
#define PNG_HAVE_CHUNK_AFTER_IDAT 0x2000U /* Have another chunk after IDAT */
|
||||
/* 0x4000U (unused) */
|
||||
#define PNG_WROTE_eXIf 0x4000U
|
||||
#define PNG_IS_READ_STRUCT 0x8000U /* Else is a write struct */
|
||||
|
||||
/* Flags for the transformations the PNG library does on the image data */
|
||||
@ -1315,7 +1340,7 @@ PNG_INTERNAL_FUNCTION(void,png_read_filter_row_paeth4_neon,(png_row_infop
|
||||
row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);
|
||||
#endif
|
||||
|
||||
#if PNG_MIPS_MSA_OPT > 0
|
||||
#if PNG_MIPS_MSA_IMPLEMENTATION == 1
|
||||
PNG_INTERNAL_FUNCTION(void,png_read_filter_row_up_msa,(png_row_infop row_info,
|
||||
png_bytep row, png_const_bytep prev_row),PNG_EMPTY);
|
||||
PNG_INTERNAL_FUNCTION(void,png_read_filter_row_sub3_msa,(png_row_infop
|
||||
@ -1332,6 +1357,23 @@ PNG_INTERNAL_FUNCTION(void,png_read_filter_row_paeth4_msa,(png_row_infop
|
||||
row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);
|
||||
#endif
|
||||
|
||||
#if PNG_MIPS_MMI_IMPLEMENTATION > 0
|
||||
PNG_INTERNAL_FUNCTION(void,png_read_filter_row_up_mmi,(png_row_infop row_info,
|
||||
png_bytep row, png_const_bytep prev_row),PNG_EMPTY);
|
||||
PNG_INTERNAL_FUNCTION(void,png_read_filter_row_sub3_mmi,(png_row_infop
|
||||
row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);
|
||||
PNG_INTERNAL_FUNCTION(void,png_read_filter_row_sub4_mmi,(png_row_infop
|
||||
row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);
|
||||
PNG_INTERNAL_FUNCTION(void,png_read_filter_row_avg3_mmi,(png_row_infop
|
||||
row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);
|
||||
PNG_INTERNAL_FUNCTION(void,png_read_filter_row_avg4_mmi,(png_row_infop
|
||||
row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);
|
||||
PNG_INTERNAL_FUNCTION(void,png_read_filter_row_paeth3_mmi,(png_row_infop
|
||||
row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);
|
||||
PNG_INTERNAL_FUNCTION(void,png_read_filter_row_paeth4_mmi,(png_row_infop
|
||||
row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);
|
||||
#endif
|
||||
|
||||
#if PNG_POWERPC_VSX_OPT > 0
|
||||
PNG_INTERNAL_FUNCTION(void,png_read_filter_row_up_vsx,(png_row_infop row_info,
|
||||
png_bytep row, png_const_bytep prev_row),PNG_EMPTY);
|
||||
@ -1364,6 +1406,23 @@ PNG_INTERNAL_FUNCTION(void,png_read_filter_row_paeth4_sse2,(png_row_infop
|
||||
row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);
|
||||
#endif
|
||||
|
||||
#if PNG_LOONGARCH_LSX_IMPLEMENTATION == 1
|
||||
PNG_INTERNAL_FUNCTION(void,png_read_filter_row_up_lsx,(png_row_infop
|
||||
row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);
|
||||
PNG_INTERNAL_FUNCTION(void,png_read_filter_row_sub3_lsx,(png_row_infop
|
||||
row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);
|
||||
PNG_INTERNAL_FUNCTION(void,png_read_filter_row_sub4_lsx,(png_row_infop
|
||||
row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);
|
||||
PNG_INTERNAL_FUNCTION(void,png_read_filter_row_avg3_lsx,(png_row_infop
|
||||
row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);
|
||||
PNG_INTERNAL_FUNCTION(void,png_read_filter_row_avg4_lsx,(png_row_infop
|
||||
row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);
|
||||
PNG_INTERNAL_FUNCTION(void,png_read_filter_row_paeth3_lsx,(png_row_infop
|
||||
row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);
|
||||
PNG_INTERNAL_FUNCTION(void,png_read_filter_row_paeth4_lsx,(png_row_infop
|
||||
row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);
|
||||
#endif
|
||||
|
||||
/* Choose the best filter to use and filter the row data */
|
||||
PNG_INTERNAL_FUNCTION(void,png_write_find_filter,(png_structrp png_ptr,
|
||||
png_row_infop row_info),PNG_EMPTY);
|
||||
@ -1919,7 +1978,7 @@ PNG_INTERNAL_FUNCTION(void,png_ascii_from_fixed,(png_const_structrp png_ptr,
|
||||
*/
|
||||
#define PNG_FP_INVALID 512 /* Available for callers as a distinct value */
|
||||
|
||||
/* Result codes for the parser (boolean - true meants ok, false means
|
||||
/* Result codes for the parser (boolean - true means ok, false means
|
||||
* not ok yet.)
|
||||
*/
|
||||
#define PNG_FP_MAYBE 0 /* The number may be valid in the future */
|
||||
@ -1955,7 +2014,7 @@ PNG_INTERNAL_FUNCTION(void,png_ascii_from_fixed,(png_const_structrp png_ptr,
|
||||
* the problem character.) This has not been tested within libpng.
|
||||
*/
|
||||
PNG_INTERNAL_FUNCTION(int,png_check_fp_number,(png_const_charp string,
|
||||
size_t size, int *statep, png_size_tp whereami),PNG_EMPTY);
|
||||
size_t size, int *statep, size_t *whereami),PNG_EMPTY);
|
||||
|
||||
/* This is the same but it checks a complete string and returns true
|
||||
* only if it just contains a floating point number. As of 1.5.4 this
|
||||
@ -2103,17 +2162,27 @@ PNG_INTERNAL_FUNCTION(void, png_init_filter_functions_neon,
|
||||
(png_structp png_ptr, unsigned int bpp), PNG_EMPTY);
|
||||
#endif
|
||||
|
||||
#if PNG_MIPS_MSA_OPT > 0
|
||||
PNG_INTERNAL_FUNCTION(void, png_init_filter_functions_msa,
|
||||
#if PNG_MIPS_MSA_IMPLEMENTATION == 1
|
||||
PNG_INTERNAL_FUNCTION(void, png_init_filter_functions_mips,
|
||||
(png_structp png_ptr, unsigned int bpp), PNG_EMPTY);
|
||||
#endif
|
||||
|
||||
# if PNG_MIPS_MMI_IMPLEMENTATION > 0
|
||||
PNG_INTERNAL_FUNCTION(void, png_init_filter_functions_mips,
|
||||
(png_structp png_ptr, unsigned int bpp), PNG_EMPTY);
|
||||
# endif
|
||||
|
||||
# if PNG_INTEL_SSE_IMPLEMENTATION > 0
|
||||
PNG_INTERNAL_FUNCTION(void, png_init_filter_functions_sse2,
|
||||
(png_structp png_ptr, unsigned int bpp), PNG_EMPTY);
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if PNG_LOONGARCH_LSX_OPT > 0
|
||||
PNG_INTERNAL_FUNCTION(void, png_init_filter_functions_lsx,
|
||||
(png_structp png_ptr, unsigned int bpp), PNG_EMPTY);
|
||||
#endif
|
||||
|
||||
PNG_INTERNAL_FUNCTION(png_uint_32, png_check_keyword, (png_structrp png_ptr,
|
||||
png_const_charp key, png_bytep new_key), PNG_EMPTY);
|
||||
|
||||
|
19
3rdparty/libpng/pngread.c
vendored
19
3rdparty/libpng/pngread.c
vendored
@ -1,7 +1,7 @@
|
||||
|
||||
/* pngread.c - read a PNG file
|
||||
*
|
||||
* Copyright (c) 2018-2019 Cosmin Truta
|
||||
* Copyright (c) 2018-2024 Cosmin Truta
|
||||
* Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson
|
||||
* Copyright (c) 1996-1997 Andreas Dilger
|
||||
* Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
|
||||
@ -568,7 +568,11 @@ png_read_row(png_structrp png_ptr, png_bytep row, png_bytep dsp_row)
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_TRANSFORMS_SUPPORTED
|
||||
if (png_ptr->transformations)
|
||||
if (png_ptr->transformations
|
||||
# ifdef PNG_CHECK_FOR_INVALID_INDEX_SUPPORTED
|
||||
|| png_ptr->num_palette_max >= 0
|
||||
# endif
|
||||
)
|
||||
png_do_read_transformations(png_ptr, &row_info);
|
||||
#endif
|
||||
|
||||
@ -785,7 +789,7 @@ png_read_end(png_structrp png_ptr, png_inforp info_ptr)
|
||||
#ifdef PNG_READ_CHECK_FOR_INVALID_INDEX_SUPPORTED
|
||||
/* Report invalid palette index; added at libng-1.5.10 */
|
||||
if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE &&
|
||||
png_ptr->num_palette_max > png_ptr->num_palette)
|
||||
png_ptr->num_palette_max >= png_ptr->num_palette)
|
||||
png_benign_error(png_ptr, "Read palette index exceeding num_palette");
|
||||
#endif
|
||||
|
||||
@ -1049,6 +1053,8 @@ void PNGAPI
|
||||
png_read_png(png_structrp png_ptr, png_inforp info_ptr,
|
||||
int transforms, voidp params)
|
||||
{
|
||||
png_debug(1, "in png_read_png");
|
||||
|
||||
if (png_ptr == NULL || info_ptr == NULL)
|
||||
return;
|
||||
|
||||
@ -3452,7 +3458,6 @@ png_image_read_background(png_voidp argument)
|
||||
|
||||
for (pass = 0; pass < passes; ++pass)
|
||||
{
|
||||
png_bytep row = png_voidcast(png_bytep, display->first_row);
|
||||
unsigned int startx, stepx, stepy;
|
||||
png_uint_32 y;
|
||||
|
||||
@ -3557,8 +3562,6 @@ png_image_read_background(png_voidp argument)
|
||||
|
||||
inrow += 2; /* gray and alpha channel */
|
||||
}
|
||||
|
||||
row += display->row_bytes;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -3765,13 +3768,13 @@ png_image_read_direct(png_voidp argument)
|
||||
mode = PNG_ALPHA_PNG;
|
||||
output_gamma = PNG_DEFAULT_sRGB;
|
||||
}
|
||||
|
||||
|
||||
if ((change & PNG_FORMAT_FLAG_ASSOCIATED_ALPHA) != 0)
|
||||
{
|
||||
mode = PNG_ALPHA_OPTIMIZED;
|
||||
change &= ~PNG_FORMAT_FLAG_ASSOCIATED_ALPHA;
|
||||
}
|
||||
|
||||
|
||||
/* If 'do_local_background' is set check for the presence of gamma
|
||||
* correction; this is part of the work-round for the libpng bug
|
||||
* described above.
|
||||
|
36
3rdparty/libpng/pngrtran.c
vendored
36
3rdparty/libpng/pngrtran.c
vendored
@ -1,7 +1,7 @@
|
||||
|
||||
/* pngrtran.c - transforms the data in a row for PNG readers
|
||||
*
|
||||
* Copyright (c) 2018-2019 Cosmin Truta
|
||||
* Copyright (c) 2018-2024 Cosmin Truta
|
||||
* Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson
|
||||
* Copyright (c) 1996-1997 Andreas Dilger
|
||||
* Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
|
||||
@ -21,7 +21,7 @@
|
||||
#ifdef PNG_ARM_NEON_IMPLEMENTATION
|
||||
# if PNG_ARM_NEON_IMPLEMENTATION == 1
|
||||
# define PNG_ARM_NEON_INTRINSICS_AVAILABLE
|
||||
# if defined(_MSC_VER) && defined(_M_ARM64)
|
||||
# if defined(_MSC_VER) && !defined(__clang__) && defined(_M_ARM64)
|
||||
# include <arm64_neon.h>
|
||||
# else
|
||||
# include <arm_neon.h>
|
||||
@ -290,21 +290,20 @@ png_set_alpha_mode_fixed(png_structrp png_ptr, int mode,
|
||||
int compose = 0;
|
||||
png_fixed_point file_gamma;
|
||||
|
||||
png_debug(1, "in png_set_alpha_mode");
|
||||
png_debug(1, "in png_set_alpha_mode_fixed");
|
||||
|
||||
if (png_rtran_ok(png_ptr, 0) == 0)
|
||||
return;
|
||||
|
||||
output_gamma = translate_gamma_flags(png_ptr, output_gamma, 1/*screen*/);
|
||||
|
||||
/* Validate the value to ensure it is in a reasonable range. The value
|
||||
/* Validate the value to ensure it is in a reasonable range. The value
|
||||
* is expected to be 1 or greater, but this range test allows for some
|
||||
* viewing correction values. The intent is to weed out users of this API
|
||||
* who use the inverse of the gamma value accidentally! Since some of these
|
||||
* values are reasonable this may have to be changed:
|
||||
* viewing correction values. The intent is to weed out the API users
|
||||
* who might use the inverse of the gamma value accidentally!
|
||||
*
|
||||
* 1.6.x: changed from 0.07..3 to 0.01..100 (to accommodate the optimal 16-bit
|
||||
* gamma of 36, and its reciprocal.)
|
||||
* In libpng 1.6.0, we changed from 0.07..3 to 0.01..100, to accommodate
|
||||
* the optimal 16-bit gamma of 36 and its reciprocal.
|
||||
*/
|
||||
if (output_gamma < 1000 || output_gamma > 10000000)
|
||||
png_error(png_ptr, "output gamma out of expected range");
|
||||
@ -441,7 +440,7 @@ png_set_quantize(png_structrp png_ptr, png_colorp palette,
|
||||
int i;
|
||||
|
||||
png_ptr->quantize_index = (png_bytep)png_malloc(png_ptr,
|
||||
(png_alloc_size_t)((png_uint_32)num_palette * (sizeof (png_byte))));
|
||||
(png_alloc_size_t)num_palette);
|
||||
for (i = 0; i < num_palette; i++)
|
||||
png_ptr->quantize_index[i] = (png_byte)i;
|
||||
}
|
||||
@ -458,7 +457,7 @@ png_set_quantize(png_structrp png_ptr, png_colorp palette,
|
||||
|
||||
/* Initialize an array to sort colors */
|
||||
png_ptr->quantize_sort = (png_bytep)png_malloc(png_ptr,
|
||||
(png_alloc_size_t)((png_uint_32)num_palette * (sizeof (png_byte))));
|
||||
(png_alloc_size_t)num_palette);
|
||||
|
||||
/* Initialize the quantize_sort array */
|
||||
for (i = 0; i < num_palette; i++)
|
||||
@ -592,11 +591,9 @@ png_set_quantize(png_structrp png_ptr, png_colorp palette,
|
||||
|
||||
/* Initialize palette index arrays */
|
||||
png_ptr->index_to_palette = (png_bytep)png_malloc(png_ptr,
|
||||
(png_alloc_size_t)((png_uint_32)num_palette *
|
||||
(sizeof (png_byte))));
|
||||
(png_alloc_size_t)num_palette);
|
||||
png_ptr->palette_to_index = (png_bytep)png_malloc(png_ptr,
|
||||
(png_alloc_size_t)((png_uint_32)num_palette *
|
||||
(sizeof (png_byte))));
|
||||
(png_alloc_size_t)num_palette);
|
||||
|
||||
/* Initialize the sort array */
|
||||
for (i = 0; i < num_palette; i++)
|
||||
@ -761,12 +758,11 @@ png_set_quantize(png_structrp png_ptr, png_colorp palette,
|
||||
size_t num_entries = ((size_t)1 << total_bits);
|
||||
|
||||
png_ptr->palette_lookup = (png_bytep)png_calloc(png_ptr,
|
||||
(png_alloc_size_t)(num_entries * (sizeof (png_byte))));
|
||||
(png_alloc_size_t)(num_entries));
|
||||
|
||||
distance = (png_bytep)png_malloc(png_ptr, (png_alloc_size_t)(num_entries *
|
||||
(sizeof (png_byte))));
|
||||
distance = (png_bytep)png_malloc(png_ptr, (png_alloc_size_t)num_entries);
|
||||
|
||||
memset(distance, 0xff, num_entries * (sizeof (png_byte)));
|
||||
memset(distance, 0xff, num_entries);
|
||||
|
||||
for (i = 0; i < num_palette; i++)
|
||||
{
|
||||
@ -970,7 +966,7 @@ void PNGFAPI
|
||||
png_set_rgb_to_gray_fixed(png_structrp png_ptr, int error_action,
|
||||
png_fixed_point red, png_fixed_point green)
|
||||
{
|
||||
png_debug(1, "in png_set_rgb_to_gray");
|
||||
png_debug(1, "in png_set_rgb_to_gray_fixed");
|
||||
|
||||
/* Need the IHDR here because of the check on color_type below. */
|
||||
/* TODO: fix this */
|
||||
|
49
3rdparty/libpng/pngrutil.c
vendored
49
3rdparty/libpng/pngrutil.c
vendored
@ -1,7 +1,7 @@
|
||||
|
||||
/* pngrutil.c - utilities to read a PNG file
|
||||
*
|
||||
* Copyright (c) 2018 Cosmin Truta
|
||||
* Copyright (c) 2018-2024 Cosmin Truta
|
||||
* Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson
|
||||
* Copyright (c) 1996-1997 Andreas Dilger
|
||||
* Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
|
||||
@ -26,7 +26,7 @@ png_get_uint_31(png_const_structrp png_ptr, png_const_bytep buf)
|
||||
if (uval > PNG_UINT_31_MAX)
|
||||
png_error(png_ptr, "PNG unsigned integer out of range");
|
||||
|
||||
return (uval);
|
||||
return uval;
|
||||
}
|
||||
|
||||
#if defined(PNG_READ_gAMA_SUPPORTED) || defined(PNG_READ_cHRM_SUPPORTED)
|
||||
@ -140,7 +140,7 @@ png_read_sig(png_structrp png_ptr, png_inforp info_ptr)
|
||||
if (png_sig_cmp(info_ptr->signature, num_checked, num_to_check) != 0)
|
||||
{
|
||||
if (num_checked < 4 &&
|
||||
png_sig_cmp(info_ptr->signature, num_checked, num_to_check - 4))
|
||||
png_sig_cmp(info_ptr->signature, num_checked, num_to_check - 4) != 0)
|
||||
png_error(png_ptr, "Not a PNG file");
|
||||
else
|
||||
png_error(png_ptr, "PNG file corrupted by ASCII conversion");
|
||||
@ -171,7 +171,7 @@ png_read_chunk_header(png_structrp png_ptr)
|
||||
/* Put the chunk name into png_ptr->chunk_name. */
|
||||
png_ptr->chunk_name = PNG_CHUNK_FROM_STRING(buf+4);
|
||||
|
||||
png_debug2(0, "Reading %lx chunk, length = %lu",
|
||||
png_debug2(0, "Reading chunk typeid = 0x%lx, length = %lu",
|
||||
(unsigned long)png_ptr->chunk_name, (unsigned long)length);
|
||||
|
||||
/* Reset the crc and run it over the chunk name. */
|
||||
@ -238,10 +238,10 @@ png_crc_finish(png_structrp png_ptr, png_uint_32 skip)
|
||||
else
|
||||
png_chunk_error(png_ptr, "CRC error");
|
||||
|
||||
return (1);
|
||||
return 1;
|
||||
}
|
||||
|
||||
return (0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Compare the CRC stored in the PNG file with that calculated by libpng from
|
||||
@ -277,11 +277,11 @@ png_crc_error(png_structrp png_ptr)
|
||||
if (need_crc != 0)
|
||||
{
|
||||
crc = png_get_uint_32(crc_bytes);
|
||||
return ((int)(crc != png_ptr->crc));
|
||||
return crc != png_ptr->crc;
|
||||
}
|
||||
|
||||
else
|
||||
return (0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
#if defined(PNG_READ_iCCP_SUPPORTED) || defined(PNG_READ_iTXt_SUPPORTED) ||\
|
||||
@ -301,7 +301,6 @@ png_read_buffer(png_structrp png_ptr, png_alloc_size_t new_size, int warn)
|
||||
|
||||
if (buffer != NULL && new_size > png_ptr->read_buffer_size)
|
||||
{
|
||||
png_ptr->read_buffer = NULL;
|
||||
png_ptr->read_buffer = NULL;
|
||||
png_ptr->read_buffer_size = 0;
|
||||
png_free(png_ptr, buffer);
|
||||
@ -422,8 +421,7 @@ png_inflate_claim(png_structrp png_ptr, png_uint_32 owner)
|
||||
png_ptr->flags |= PNG_FLAG_ZSTREAM_INITIALIZED;
|
||||
}
|
||||
|
||||
#if ZLIB_VERNUM >= 0x1290 && \
|
||||
defined(PNG_SET_OPTION_SUPPORTED) && defined(PNG_IGNORE_ADLER32)
|
||||
#ifdef PNG_DISABLE_ADLER32_CHECK_SUPPORTED
|
||||
if (((png_ptr->options >> PNG_IGNORE_ADLER32) & 3) == PNG_OPTION_ON)
|
||||
/* Turn off validation of the ADLER32 checksum in IDAT chunks */
|
||||
ret = inflateValidate(&png_ptr->zstream, 0);
|
||||
@ -2076,14 +2074,17 @@ png_handle_eXIf(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
|
||||
png_byte buf[1];
|
||||
png_crc_read(png_ptr, buf, 1);
|
||||
info_ptr->eXIf_buf[i] = buf[0];
|
||||
if (i == 1 && buf[0] != 'M' && buf[0] != 'I'
|
||||
&& info_ptr->eXIf_buf[0] != buf[0])
|
||||
if (i == 1)
|
||||
{
|
||||
png_crc_finish(png_ptr, length);
|
||||
png_chunk_benign_error(png_ptr, "incorrect byte-order specifier");
|
||||
png_free(png_ptr, info_ptr->eXIf_buf);
|
||||
info_ptr->eXIf_buf = NULL;
|
||||
return;
|
||||
if ((buf[0] != 'M' && buf[0] != 'I') ||
|
||||
(info_ptr->eXIf_buf[0] != buf[0]))
|
||||
{
|
||||
png_crc_finish(png_ptr, length - 2);
|
||||
png_chunk_benign_error(png_ptr, "incorrect byte-order specifier");
|
||||
png_free(png_ptr, info_ptr->eXIf_buf);
|
||||
info_ptr->eXIf_buf = NULL;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -2124,8 +2125,9 @@ png_handle_hIST(png_structrp png_ptr, png_inforp info_ptr, png_uint_32 length)
|
||||
|
||||
num = length / 2 ;
|
||||
|
||||
if (num != (unsigned int) png_ptr->num_palette ||
|
||||
num > (unsigned int) PNG_MAX_PALETTE_LENGTH)
|
||||
if (length != num * 2 ||
|
||||
num != (unsigned int)png_ptr->num_palette ||
|
||||
num > (unsigned int)PNG_MAX_PALETTE_LENGTH)
|
||||
{
|
||||
png_crc_finish(png_ptr, length);
|
||||
png_chunk_benign_error(png_ptr, "invalid");
|
||||
@ -3183,7 +3185,7 @@ png_check_chunk_length(png_const_structrp png_ptr, png_uint_32 length)
|
||||
{
|
||||
png_debug2(0," length = %lu, limit = %lu",
|
||||
(unsigned long)length,(unsigned long)limit);
|
||||
png_chunk_error(png_ptr, "chunk data is too large");
|
||||
png_benign_error(png_ptr, "chunk data is too large");
|
||||
}
|
||||
}
|
||||
|
||||
@ -4619,14 +4621,13 @@ defined(PNG_USER_TRANSFORM_PTR_SUPPORTED)
|
||||
*/
|
||||
{
|
||||
png_bytep temp = png_ptr->big_row_buf + 32;
|
||||
int extra = (int)((temp - (png_bytep)0) & 0x0f);
|
||||
size_t extra = (size_t)temp & 0x0f;
|
||||
png_ptr->row_buf = temp - extra - 1/*filter byte*/;
|
||||
|
||||
temp = png_ptr->big_prev_row + 32;
|
||||
extra = (int)((temp - (png_bytep)0) & 0x0f);
|
||||
extra = (size_t)temp & 0x0f;
|
||||
png_ptr->prev_row = temp - extra - 1/*filter byte*/;
|
||||
}
|
||||
|
||||
#else
|
||||
/* Use 31 bytes of padding before and 17 bytes after row_buf. */
|
||||
png_ptr->row_buf = png_ptr->big_row_buf + 31;
|
||||
|
91
3rdparty/libpng/pngset.c
vendored
91
3rdparty/libpng/pngset.c
vendored
@ -1,7 +1,7 @@
|
||||
|
||||
/* pngset.c - storage of image information into info struct
|
||||
*
|
||||
* Copyright (c) 2018 Cosmin Truta
|
||||
* Copyright (c) 2018-2024 Cosmin Truta
|
||||
* Copyright (c) 1998-2018 Glenn Randers-Pehrson
|
||||
* Copyright (c) 1996-1997 Andreas Dilger
|
||||
* Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
|
||||
@ -137,46 +137,40 @@ png_set_cHRM_XYZ(png_const_structrp png_ptr, png_inforp info_ptr, double red_X,
|
||||
#ifdef PNG_eXIf_SUPPORTED
|
||||
void PNGAPI
|
||||
png_set_eXIf(png_const_structrp png_ptr, png_inforp info_ptr,
|
||||
png_bytep eXIf_buf)
|
||||
png_bytep exif)
|
||||
{
|
||||
png_warning(png_ptr, "png_set_eXIf does not work; use png_set_eXIf_1");
|
||||
PNG_UNUSED(info_ptr)
|
||||
PNG_UNUSED(eXIf_buf)
|
||||
PNG_UNUSED(exif)
|
||||
}
|
||||
|
||||
void PNGAPI
|
||||
png_set_eXIf_1(png_const_structrp png_ptr, png_inforp info_ptr,
|
||||
png_uint_32 num_exif, png_bytep eXIf_buf)
|
||||
png_uint_32 num_exif, png_bytep exif)
|
||||
{
|
||||
int i;
|
||||
png_bytep new_exif;
|
||||
|
||||
png_debug1(1, "in %s storage function", "eXIf");
|
||||
|
||||
if (png_ptr == NULL || info_ptr == NULL)
|
||||
if (png_ptr == NULL || info_ptr == NULL ||
|
||||
(png_ptr->mode & PNG_WROTE_eXIf) != 0)
|
||||
return;
|
||||
|
||||
if (info_ptr->exif)
|
||||
{
|
||||
png_free(png_ptr, info_ptr->exif);
|
||||
info_ptr->exif = NULL;
|
||||
}
|
||||
new_exif = png_voidcast(png_bytep, png_malloc_warn(png_ptr, num_exif));
|
||||
|
||||
info_ptr->num_exif = num_exif;
|
||||
|
||||
info_ptr->exif = png_voidcast(png_bytep, png_malloc_warn(png_ptr,
|
||||
info_ptr->num_exif));
|
||||
|
||||
if (info_ptr->exif == NULL)
|
||||
if (new_exif == NULL)
|
||||
{
|
||||
png_warning(png_ptr, "Insufficient memory for eXIf chunk data");
|
||||
return;
|
||||
}
|
||||
|
||||
memcpy(new_exif, exif, (size_t)num_exif);
|
||||
|
||||
png_free_data(png_ptr, info_ptr, PNG_FREE_EXIF, 0);
|
||||
|
||||
info_ptr->num_exif = num_exif;
|
||||
info_ptr->exif = new_exif;
|
||||
info_ptr->free_me |= PNG_FREE_EXIF;
|
||||
|
||||
for (i = 0; i < (int) info_ptr->num_exif; i++)
|
||||
info_ptr->exif[i] = eXIf_buf[i];
|
||||
|
||||
info_ptr->valid |= PNG_INFO_eXIf;
|
||||
}
|
||||
#endif /* eXIf */
|
||||
@ -237,15 +231,13 @@ png_set_hIST(png_const_structrp png_ptr, png_inforp info_ptr,
|
||||
if (info_ptr->hist == NULL)
|
||||
{
|
||||
png_warning(png_ptr, "Insufficient memory for hIST chunk data");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
info_ptr->free_me |= PNG_FREE_HIST;
|
||||
|
||||
for (i = 0; i < info_ptr->num_palette; i++)
|
||||
info_ptr->hist[i] = hist[i];
|
||||
|
||||
info_ptr->free_me |= PNG_FREE_HIST;
|
||||
info_ptr->valid |= PNG_INFO_hIST;
|
||||
}
|
||||
#endif
|
||||
@ -367,6 +359,8 @@ png_set_pCAL(png_const_structrp png_ptr, png_inforp info_ptr,
|
||||
|
||||
memcpy(info_ptr->pcal_purpose, purpose, length);
|
||||
|
||||
info_ptr->free_me |= PNG_FREE_PCAL;
|
||||
|
||||
png_debug(3, "storing X0, X1, type, and nparams in info");
|
||||
info_ptr->pcal_X0 = X0;
|
||||
info_ptr->pcal_X1 = X1;
|
||||
@ -383,7 +377,6 @@ png_set_pCAL(png_const_structrp png_ptr, png_inforp info_ptr,
|
||||
if (info_ptr->pcal_units == NULL)
|
||||
{
|
||||
png_warning(png_ptr, "Insufficient memory for pCAL units");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@ -395,7 +388,6 @@ png_set_pCAL(png_const_structrp png_ptr, png_inforp info_ptr,
|
||||
if (info_ptr->pcal_params == NULL)
|
||||
{
|
||||
png_warning(png_ptr, "Insufficient memory for pCAL params");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@ -413,7 +405,6 @@ png_set_pCAL(png_const_structrp png_ptr, png_inforp info_ptr,
|
||||
if (info_ptr->pcal_params[i] == NULL)
|
||||
{
|
||||
png_warning(png_ptr, "Insufficient memory for pCAL parameter");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@ -421,7 +412,6 @@ png_set_pCAL(png_const_structrp png_ptr, png_inforp info_ptr,
|
||||
}
|
||||
|
||||
info_ptr->valid |= PNG_INFO_pCAL;
|
||||
info_ptr->free_me |= PNG_FREE_PCAL;
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -478,18 +468,17 @@ png_set_sCAL_s(png_const_structrp png_ptr, png_inforp info_ptr,
|
||||
|
||||
if (info_ptr->scal_s_height == NULL)
|
||||
{
|
||||
png_free (png_ptr, info_ptr->scal_s_width);
|
||||
png_free(png_ptr, info_ptr->scal_s_width);
|
||||
info_ptr->scal_s_width = NULL;
|
||||
|
||||
png_warning(png_ptr, "Memory allocation failed while processing sCAL");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
memcpy(info_ptr->scal_s_height, sheight, lengthh);
|
||||
|
||||
info_ptr->valid |= PNG_INFO_sCAL;
|
||||
info_ptr->free_me |= PNG_FREE_SCAL;
|
||||
info_ptr->valid |= PNG_INFO_sCAL;
|
||||
}
|
||||
|
||||
# ifdef PNG_FLOATING_POINT_SUPPORTED
|
||||
@ -625,11 +614,10 @@ png_set_PLTE(png_structrp png_ptr, png_inforp info_ptr,
|
||||
if (num_palette > 0)
|
||||
memcpy(png_ptr->palette, palette, (unsigned int)num_palette *
|
||||
(sizeof (png_color)));
|
||||
|
||||
info_ptr->palette = png_ptr->palette;
|
||||
info_ptr->num_palette = png_ptr->num_palette = (png_uint_16)num_palette;
|
||||
|
||||
info_ptr->free_me |= PNG_FREE_PLTE;
|
||||
|
||||
info_ptr->valid |= PNG_INFO_PLTE;
|
||||
}
|
||||
|
||||
@ -775,11 +763,11 @@ png_set_text_2(png_const_structrp png_ptr, png_inforp info_ptr,
|
||||
{
|
||||
int i;
|
||||
|
||||
png_debug1(1, "in %lx storage function", png_ptr == NULL ? 0xabadca11U :
|
||||
(unsigned long)png_ptr->chunk_name);
|
||||
png_debug1(1, "in text storage function, chunk typeid = 0x%lx",
|
||||
png_ptr == NULL ? 0xabadca11UL : (unsigned long)png_ptr->chunk_name);
|
||||
|
||||
if (png_ptr == NULL || info_ptr == NULL || num_text <= 0 || text_ptr == NULL)
|
||||
return(0);
|
||||
return 0;
|
||||
|
||||
/* Make sure we have enough space in the "text" array in info_struct
|
||||
* to hold all of the incoming text_ptr objects. This compare can't overflow
|
||||
@ -959,7 +947,7 @@ png_set_text_2(png_const_structrp png_ptr, png_inforp info_ptr,
|
||||
png_debug1(3, "transferred text chunk %d", info_ptr->num_text);
|
||||
}
|
||||
|
||||
return(0);
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -1019,6 +1007,9 @@ png_set_tRNS(png_structrp png_ptr, png_inforp info_ptr,
|
||||
info_ptr->trans_alpha = png_voidcast(png_bytep,
|
||||
png_malloc(png_ptr, PNG_MAX_PALETTE_LENGTH));
|
||||
memcpy(info_ptr->trans_alpha, trans_alpha, (size_t)num_trans);
|
||||
|
||||
info_ptr->free_me |= PNG_FREE_TRNS;
|
||||
info_ptr->valid |= PNG_INFO_tRNS;
|
||||
}
|
||||
png_ptr->trans_alpha = info_ptr->trans_alpha;
|
||||
}
|
||||
@ -1051,8 +1042,8 @@ png_set_tRNS(png_structrp png_ptr, png_inforp info_ptr,
|
||||
|
||||
if (num_trans != 0)
|
||||
{
|
||||
info_ptr->valid |= PNG_INFO_tRNS;
|
||||
info_ptr->free_me |= PNG_FREE_TRNS;
|
||||
info_ptr->valid |= PNG_INFO_tRNS;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@ -1072,6 +1063,8 @@ png_set_sPLT(png_const_structrp png_ptr,
|
||||
{
|
||||
png_sPLT_tp np;
|
||||
|
||||
png_debug1(1, "in %s storage function", "sPLT");
|
||||
|
||||
if (png_ptr == NULL || info_ptr == NULL || nentries <= 0 || entries == NULL)
|
||||
return;
|
||||
|
||||
@ -1086,11 +1079,11 @@ png_set_sPLT(png_const_structrp png_ptr,
|
||||
{
|
||||
/* Out of memory or too many chunks */
|
||||
png_chunk_report(png_ptr, "too many sPLT chunks", PNG_CHUNK_WRITE_ERROR);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
png_free(png_ptr, info_ptr->splt_palettes);
|
||||
|
||||
info_ptr->splt_palettes = np;
|
||||
info_ptr->free_me |= PNG_FREE_SPLT;
|
||||
|
||||
@ -1244,11 +1237,11 @@ png_set_unknown_chunks(png_const_structrp png_ptr,
|
||||
{
|
||||
png_chunk_report(png_ptr, "too many unknown chunks",
|
||||
PNG_CHUNK_WRITE_ERROR);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
png_free(png_ptr, info_ptr->unknown_chunks);
|
||||
|
||||
info_ptr->unknown_chunks = np; /* safe because it is initialized */
|
||||
info_ptr->free_me |= PNG_FREE_UNKN;
|
||||
|
||||
@ -1326,7 +1319,7 @@ png_set_unknown_chunk_location(png_const_structrp png_ptr, png_inforp info_ptr,
|
||||
|
||||
#ifdef PNG_MNG_FEATURES_SUPPORTED
|
||||
png_uint_32 PNGAPI
|
||||
png_permit_mng_features (png_structrp png_ptr, png_uint_32 mng_features)
|
||||
png_permit_mng_features(png_structrp png_ptr, png_uint_32 mng_features)
|
||||
{
|
||||
png_debug(1, "in png_permit_mng_features");
|
||||
|
||||
@ -1546,7 +1539,7 @@ void PNGAPI
|
||||
png_set_rows(png_const_structrp png_ptr, png_inforp info_ptr,
|
||||
png_bytepp row_pointers)
|
||||
{
|
||||
png_debug1(1, "in %s storage function", "rows");
|
||||
png_debug(1, "in png_set_rows");
|
||||
|
||||
if (png_ptr == NULL || info_ptr == NULL)
|
||||
return;
|
||||
@ -1565,6 +1558,8 @@ png_set_rows(png_const_structrp png_ptr, png_inforp info_ptr,
|
||||
void PNGAPI
|
||||
png_set_compression_buffer_size(png_structrp png_ptr, size_t size)
|
||||
{
|
||||
png_debug(1, "in png_set_compression_buffer_size");
|
||||
|
||||
if (png_ptr == NULL)
|
||||
return;
|
||||
|
||||
@ -1633,9 +1628,11 @@ png_set_invalid(png_const_structrp png_ptr, png_inforp info_ptr, int mask)
|
||||
#ifdef PNG_SET_USER_LIMITS_SUPPORTED
|
||||
/* This function was added to libpng 1.2.6 */
|
||||
void PNGAPI
|
||||
png_set_user_limits (png_structrp png_ptr, png_uint_32 user_width_max,
|
||||
png_set_user_limits(png_structrp png_ptr, png_uint_32 user_width_max,
|
||||
png_uint_32 user_height_max)
|
||||
{
|
||||
png_debug(1, "in png_set_user_limits");
|
||||
|
||||
/* Images with dimensions larger than these limits will be
|
||||
* rejected by png_set_IHDR(). To accept any PNG datastream
|
||||
* regardless of dimensions, set both limits to 0x7fffffff.
|
||||
@ -1649,17 +1646,21 @@ png_set_user_limits (png_structrp png_ptr, png_uint_32 user_width_max,
|
||||
|
||||
/* This function was added to libpng 1.4.0 */
|
||||
void PNGAPI
|
||||
png_set_chunk_cache_max (png_structrp png_ptr, png_uint_32 user_chunk_cache_max)
|
||||
png_set_chunk_cache_max(png_structrp png_ptr, png_uint_32 user_chunk_cache_max)
|
||||
{
|
||||
png_debug(1, "in png_set_chunk_cache_max");
|
||||
|
||||
if (png_ptr != NULL)
|
||||
png_ptr->user_chunk_cache_max = user_chunk_cache_max;
|
||||
}
|
||||
|
||||
/* This function was added to libpng 1.4.1 */
|
||||
void PNGAPI
|
||||
png_set_chunk_malloc_max (png_structrp png_ptr,
|
||||
png_set_chunk_malloc_max(png_structrp png_ptr,
|
||||
png_alloc_size_t user_chunk_malloc_max)
|
||||
{
|
||||
png_debug(1, "in png_set_chunk_malloc_max");
|
||||
|
||||
if (png_ptr != NULL)
|
||||
png_ptr->user_chunk_malloc_max = user_chunk_malloc_max;
|
||||
}
|
||||
|
12
3rdparty/libpng/pngstruct.h
vendored
12
3rdparty/libpng/pngstruct.h
vendored
@ -1,7 +1,7 @@
|
||||
|
||||
/* pngstruct.h - header file for PNG reference library
|
||||
*
|
||||
* Copyright (c) 2018-2019 Cosmin Truta
|
||||
* Copyright (c) 2018-2022 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.
|
||||
@ -334,18 +334,8 @@ struct png_struct_def
|
||||
size_t current_buffer_size; /* amount of data now in current_buffer */
|
||||
int process_mode; /* what push library is currently doing */
|
||||
int cur_palette; /* current push library palette index */
|
||||
|
||||
#endif /* PROGRESSIVE_READ */
|
||||
|
||||
#if defined(__TURBOC__) && !defined(_Windows) && !defined(__FLAT__)
|
||||
/* For the Borland special 64K segment handler */
|
||||
png_bytepp offset_table_ptr;
|
||||
png_bytep offset_table;
|
||||
png_uint_16 offset_table_number;
|
||||
png_uint_16 offset_table_count;
|
||||
png_uint_16 offset_table_count_free;
|
||||
#endif
|
||||
|
||||
#ifdef PNG_READ_QUANTIZE_SUPPORTED
|
||||
png_bytep palette_lookup; /* lookup table for quantizing */
|
||||
png_bytep quantize_index; /* index translation for palette files */
|
||||
|
14
3rdparty/libpng/pngtrans.c
vendored
14
3rdparty/libpng/pngtrans.c
vendored
@ -1,7 +1,7 @@
|
||||
|
||||
/* pngtrans.c - transforms the data in a row (used by both readers and writers)
|
||||
*
|
||||
* Copyright (c) 2018 Cosmin Truta
|
||||
* Copyright (c) 2018-2024 Cosmin Truta
|
||||
* Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson
|
||||
* Copyright (c) 1996-1997 Andreas Dilger
|
||||
* Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
|
||||
@ -103,10 +103,10 @@ png_set_interlace_handling(png_structrp png_ptr)
|
||||
if (png_ptr != 0 && png_ptr->interlaced != 0)
|
||||
{
|
||||
png_ptr->transformations |= PNG_INTERLACE;
|
||||
return (7);
|
||||
return 7;
|
||||
}
|
||||
|
||||
return (1);
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -498,6 +498,8 @@ png_do_strip_channel(png_row_infop row_info, png_bytep row, int at_start)
|
||||
png_bytep dp = row; /* destination pointer */
|
||||
png_bytep ep = row + row_info->rowbytes; /* One beyond end of row */
|
||||
|
||||
png_debug(1, "in png_do_strip_channel");
|
||||
|
||||
/* At the start sp will point to the first byte to copy and dp to where
|
||||
* it is copied to. ep always points just beyond the end of the row, so
|
||||
* the loop simply copies (channels-1) channels until sp reaches ep.
|
||||
@ -698,6 +700,8 @@ png_do_bgr(png_row_infop row_info, png_bytep row)
|
||||
void /* PRIVATE */
|
||||
png_do_check_palette_indexes(png_structrp png_ptr, png_row_infop row_info)
|
||||
{
|
||||
png_debug(1, "in png_do_check_palette_indexes");
|
||||
|
||||
if (png_ptr->num_palette < (1 << row_info->bit_depth) &&
|
||||
png_ptr->num_palette > 0) /* num_palette can be 0 in MNG files */
|
||||
{
|
||||
@ -708,7 +712,7 @@ png_do_check_palette_indexes(png_structrp png_ptr, png_row_infop row_info)
|
||||
* forms produced on either GCC or MSVC.
|
||||
*/
|
||||
int padding = PNG_PADBITS(row_info->pixel_depth, row_info->width);
|
||||
png_bytep rp = png_ptr->row_buf + row_info->rowbytes - 1;
|
||||
png_bytep rp = png_ptr->row_buf + row_info->rowbytes;
|
||||
|
||||
switch (row_info->bit_depth)
|
||||
{
|
||||
@ -833,7 +837,7 @@ png_voidp PNGAPI
|
||||
png_get_user_transform_ptr(png_const_structrp png_ptr)
|
||||
{
|
||||
if (png_ptr == NULL)
|
||||
return (NULL);
|
||||
return NULL;
|
||||
|
||||
return png_ptr->user_transform_ptr;
|
||||
}
|
||||
|
45
3rdparty/libpng/pngwrite.c
vendored
45
3rdparty/libpng/pngwrite.c
vendored
@ -1,7 +1,7 @@
|
||||
|
||||
/* pngwrite.c - general routines to write a PNG file
|
||||
*
|
||||
* Copyright (c) 2018-2019 Cosmin Truta
|
||||
* Copyright (c) 2018-2024 Cosmin Truta
|
||||
* Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson
|
||||
* Copyright (c) 1996-1997 Andreas Dilger
|
||||
* Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
|
||||
@ -75,10 +75,10 @@ write_unknown_chunks(png_structrp png_ptr, png_const_inforp info_ptr,
|
||||
* library. If you have a new chunk to add, make a function to write it,
|
||||
* and put it in the correct location here. If you want the chunk written
|
||||
* after the image data, put it in png_write_end(). I strongly encourage
|
||||
* you to supply a PNG_INFO_ flag, and check info_ptr->valid before writing
|
||||
* the chunk, as that will keep the code from breaking if you want to just
|
||||
* write a plain PNG file. If you have long comments, I suggest writing
|
||||
* them in png_write_end(), and compressing them.
|
||||
* you to supply a PNG_INFO_<chunk> flag, and check info_ptr->valid before
|
||||
* writing the chunk, as that will keep the code from breaking if you want
|
||||
* to just write a plain PNG file. If you have long comments, I suggest
|
||||
* writing them in png_write_end(), and compressing them.
|
||||
*/
|
||||
void PNGAPI
|
||||
png_write_info_before_PLTE(png_structrp png_ptr, png_const_inforp info_ptr)
|
||||
@ -239,7 +239,10 @@ png_write_info(png_structrp png_ptr, png_const_inforp info_ptr)
|
||||
|
||||
#ifdef PNG_WRITE_eXIf_SUPPORTED
|
||||
if ((info_ptr->valid & PNG_INFO_eXIf) != 0)
|
||||
{
|
||||
png_write_eXIf(png_ptr, info_ptr->exif, info_ptr->num_exif);
|
||||
png_ptr->mode |= PNG_WROTE_eXIf;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef PNG_WRITE_hIST_SUPPORTED
|
||||
@ -366,7 +369,8 @@ png_write_end(png_structrp png_ptr, png_inforp info_ptr)
|
||||
png_error(png_ptr, "No IDATs written into file");
|
||||
|
||||
#ifdef PNG_WRITE_CHECK_FOR_INVALID_INDEX_SUPPORTED
|
||||
if (png_ptr->num_palette_max > png_ptr->num_palette)
|
||||
if (png_ptr->color_type == PNG_COLOR_TYPE_PALETTE &&
|
||||
png_ptr->num_palette_max >= png_ptr->num_palette)
|
||||
png_benign_error(png_ptr, "Wrote palette index exceeding num_palette");
|
||||
#endif
|
||||
|
||||
@ -439,8 +443,9 @@ png_write_end(png_structrp png_ptr, png_inforp info_ptr)
|
||||
#endif
|
||||
|
||||
#ifdef PNG_WRITE_eXIf_SUPPORTED
|
||||
if ((info_ptr->valid & PNG_INFO_eXIf) != 0)
|
||||
png_write_eXIf(png_ptr, info_ptr->exif, info_ptr->num_exif);
|
||||
if ((info_ptr->valid & PNG_INFO_eXIf) != 0 &&
|
||||
(png_ptr->mode & PNG_WROTE_eXIf) == 0)
|
||||
png_write_eXIf(png_ptr, info_ptr->exif, info_ptr->num_exif);
|
||||
#endif
|
||||
|
||||
#ifdef PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED
|
||||
@ -489,6 +494,16 @@ png_convert_from_time_t(png_timep ptime, time_t ttime)
|
||||
png_debug(1, "in png_convert_from_time_t");
|
||||
|
||||
tbuf = gmtime(&ttime);
|
||||
if (tbuf == NULL)
|
||||
{
|
||||
/* TODO: add a safe function which takes a png_ptr argument and raises
|
||||
* a png_error if the ttime argument is invalid and the call to gmtime
|
||||
* fails as a consequence.
|
||||
*/
|
||||
memset(ptime, 0, sizeof(*ptime));
|
||||
return;
|
||||
}
|
||||
|
||||
png_convert_from_struct_tm(ptime, tbuf);
|
||||
}
|
||||
#endif
|
||||
@ -700,12 +715,12 @@ png_write_row(png_structrp png_ptr, png_const_bytep row)
|
||||
/* 1.5.6: moved from png_struct to be a local structure: */
|
||||
png_row_info row_info;
|
||||
|
||||
if (png_ptr == NULL)
|
||||
return;
|
||||
|
||||
png_debug2(1, "in png_write_row (row %u, pass %d)",
|
||||
png_ptr->row_number, png_ptr->pass);
|
||||
|
||||
if (png_ptr == NULL)
|
||||
return;
|
||||
|
||||
/* Initialize transformations and other stuff if first time */
|
||||
if (png_ptr->row_number == 0 && png_ptr->pass == 0)
|
||||
{
|
||||
@ -1196,6 +1211,8 @@ png_set_compression_strategy(png_structrp png_ptr, int strategy)
|
||||
void PNGAPI
|
||||
png_set_compression_window_bits(png_structrp png_ptr, int window_bits)
|
||||
{
|
||||
png_debug(1, "in png_set_compression_window_bits");
|
||||
|
||||
if (png_ptr == NULL)
|
||||
return;
|
||||
|
||||
@ -1279,6 +1296,8 @@ png_set_text_compression_strategy(png_structrp png_ptr, int strategy)
|
||||
void PNGAPI
|
||||
png_set_text_compression_window_bits(png_structrp png_ptr, int window_bits)
|
||||
{
|
||||
png_debug(1, "in png_set_text_compression_window_bits");
|
||||
|
||||
if (png_ptr == NULL)
|
||||
return;
|
||||
|
||||
@ -1316,6 +1335,8 @@ png_set_text_compression_method(png_structrp png_ptr, int method)
|
||||
void PNGAPI
|
||||
png_set_write_status_fn(png_structrp png_ptr, png_write_status_ptr write_row_fn)
|
||||
{
|
||||
png_debug(1, "in png_set_write_status_fn");
|
||||
|
||||
if (png_ptr == NULL)
|
||||
return;
|
||||
|
||||
@ -1343,6 +1364,8 @@ void PNGAPI
|
||||
png_write_png(png_structrp png_ptr, png_inforp info_ptr,
|
||||
int transforms, voidp params)
|
||||
{
|
||||
png_debug(1, "in png_write_png");
|
||||
|
||||
if (png_ptr == NULL || info_ptr == NULL)
|
||||
return;
|
||||
|
||||
|
14
3rdparty/libpng/pngwutil.c
vendored
14
3rdparty/libpng/pngwutil.c
vendored
@ -1,7 +1,7 @@
|
||||
|
||||
/* pngwutil.c - utilities to write a PNG file
|
||||
*
|
||||
* Copyright (c) 2018 Cosmin Truta
|
||||
* Copyright (c) 2018-2024 Cosmin Truta
|
||||
* Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson
|
||||
* Copyright (c) 1996-1997 Andreas Dilger
|
||||
* Copyright (c) 1995-1996 Guy Eric Schalnat, Group 42, Inc.
|
||||
@ -1747,7 +1747,7 @@ png_write_pCAL(png_structrp png_ptr, png_charp purpose, png_int_32 X0,
|
||||
{
|
||||
png_uint_32 purpose_len;
|
||||
size_t units_len, total_len;
|
||||
png_size_tp params_len;
|
||||
size_t *params_len;
|
||||
png_byte buf[10];
|
||||
png_byte new_purpose[80];
|
||||
int i;
|
||||
@ -1769,7 +1769,7 @@ png_write_pCAL(png_structrp png_ptr, png_charp purpose, png_int_32 X0,
|
||||
png_debug1(3, "pCAL units length = %d", (int)units_len);
|
||||
total_len = purpose_len + units_len + 10;
|
||||
|
||||
params_len = (png_size_tp)png_malloc(png_ptr,
|
||||
params_len = (size_t *)png_malloc(png_ptr,
|
||||
(png_alloc_size_t)((png_alloc_size_t)nparams * (sizeof (size_t))));
|
||||
|
||||
/* Find the length of each parameter, making sure we don't count the
|
||||
@ -2311,7 +2311,7 @@ png_setup_sub_row(png_structrp png_ptr, png_uint_32 bpp,
|
||||
break;
|
||||
}
|
||||
|
||||
return (sum);
|
||||
return sum;
|
||||
}
|
||||
|
||||
static void /* PRIVATE */
|
||||
@ -2361,7 +2361,7 @@ png_setup_up_row(png_structrp png_ptr, size_t row_bytes, size_t lmins)
|
||||
break;
|
||||
}
|
||||
|
||||
return (sum);
|
||||
return sum;
|
||||
}
|
||||
static void /* PRIVATE */
|
||||
png_setup_up_row_only(png_structrp png_ptr, size_t row_bytes)
|
||||
@ -2417,7 +2417,7 @@ png_setup_avg_row(png_structrp png_ptr, png_uint_32 bpp,
|
||||
break;
|
||||
}
|
||||
|
||||
return (sum);
|
||||
return sum;
|
||||
}
|
||||
static void /* PRIVATE */
|
||||
png_setup_avg_row_only(png_structrp png_ptr, png_uint_32 bpp,
|
||||
@ -2500,7 +2500,7 @@ png_setup_paeth_row(png_structrp png_ptr, png_uint_32 bpp,
|
||||
break;
|
||||
}
|
||||
|
||||
return (sum);
|
||||
return sum;
|
||||
}
|
||||
static void /* PRIVATE */
|
||||
png_setup_paeth_row_only(png_structrp png_ptr, png_uint_32 bpp,
|
||||
|
@ -1489,6 +1489,30 @@ if(WITH_SPNG)
|
||||
endif()
|
||||
elseif(WITH_PNG OR HAVE_PNG)
|
||||
status(" PNG:" PNG_FOUND THEN "${PNG_LIBRARY} (ver ${PNG_VERSION_STRING})" ELSE "build (ver ${PNG_VERSION_STRING})")
|
||||
if(BUILD_PNG AND PNG_HARDWARE_OPTIMIZATIONS)
|
||||
status(" SIMD Support Request:" "YES")
|
||||
if(PNG_INTEL_SSE)
|
||||
status(" SIMD Support:" "YES (Intel SSE)")
|
||||
elseif(PNG_POWERPC_VSX)
|
||||
status(" SIMD Support:" "YES (PowerPC VSX)")
|
||||
elseif(PNG_ARM_NEON)
|
||||
status(" SIMD Support:" "YES (Arm NEON)")
|
||||
elseif(PNG_MIPS_MSA OR PNG_MIPS_MMI)
|
||||
if(PNG_MIPS_MSA AND PNG_MIPS_MMI)
|
||||
status(" SIMD Support:" "YES (Mips MSA & MMI)")
|
||||
elseif(PNG_MIPS_MSA AND NOT PNG_MIPS_MMI)
|
||||
status(" SIMD Support:" "YES (Mips MSA)")
|
||||
else()
|
||||
status(" SIMD Support:" "YES (Mips MMI)")
|
||||
endif()
|
||||
elseif(PNG_LOONGARCH_LSX)
|
||||
status(" SIMD Support:" "YES (LoongArch LSX)")
|
||||
else()
|
||||
status(" SIMD Support:" "NO")
|
||||
endif()
|
||||
elseif(BUILD_PNG)
|
||||
status(" SIMD Support Request:" "NO")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(WITH_TIFF OR HAVE_TIFF)
|
||||
|
Loading…
Reference in New Issue
Block a user