[libpng] Update: v1.6.48 -> v1.6.49

Includes the APNG patch.
This commit is contained in:
David Korth 2025-06-15 14:25:09 -04:00
parent 72b628d8ba
commit c3643b9244
39 changed files with 979 additions and 258 deletions

View File

@ -1,5 +1,5 @@
libpng 1.6.48 - April 30, 2025
==============================
libpng 1.6.49 - June 12, 2025
=============================
This is a public release of libpng, intended for use in production code.
@ -9,13 +9,13 @@ Files available for download
Source files with LF line endings (for Unix/Linux):
* libpng-1.6.48.tar.xz (LZMA-compressed, recommended)
* libpng-1.6.48.tar.gz (deflate-compressed)
* libpng-1.6.49.tar.xz (LZMA-compressed, recommended)
* libpng-1.6.49.tar.gz (deflate-compressed)
Source files with CRLF line endings (for Windows):
* lpng1648.7z (LZMA-compressed, recommended)
* lpng1648.zip (deflate-compressed)
* lpng1649.7z (LZMA-compressed, recommended)
* lpng1649.zip (deflate-compressed)
Other information:
@ -25,17 +25,13 @@ Other information:
* TRADEMARK.md
Changes from version 1.6.47 to version 1.6.48
Changes from version 1.6.48 to version 1.6.49
---------------------------------------------
* Fixed the floating-point version of the mDCv setter `png_set_mDCv`.
(Reported by Mohit Bakshi; fixed by John Bowler)
* Added #error directives to discourage the inclusion of private
libpng implementation header files in PNG-supporting applications.
* Added the CMake build option `PNG_LIBCONF_HEADER`, to be used as an
alternative to `DFA_XTRA`.
* Removed the Travis CI configuration files, with heartfelt thanks for
their generous support of our project over the past five years!
* Added SIMD-optimized code for the RISC-V Vector Extension (RVV).
(Contributed by Manfred Schlaegl, Dragos Tiselice and Filip Wasil)
* Added various fixes and improvements to the build scripts and to
the sample code.
Send comments/corrections/commendations to png-mng-implement at lists.sf.net.

View File

@ -20,6 +20,7 @@ Authors, for copyright and licensing purposes.
* Lucas Chollet
* Magnus Holmgren
* Mandar Sahastrabuddhe
* Manfred Schlaegl
* Mans Rullgard
* Matt Sarett
* Mike Klein
@ -40,8 +41,9 @@ Authors, for copyright and licensing purposes.
- Zixu Wang (王子旭)
* Arm Holdings
- Richard Townsend
* Google Inc.
* Google LLC
- Dan Field
- Dragoș Tiselice
- Leon Scroggins III
- Matt Sarett
- Mike Klein
@ -51,6 +53,8 @@ Authors, for copyright and licensing purposes.
- GuXiWei (顾希伟)
- JinBo (金波)
- ZhangLixia (张利霞)
* Samsung Group
- Filip Wasil
The build projects, the build scripts, the test scripts, and other
files in the "projects", "scripts" and "tests" directories, have

View File

@ -6261,6 +6261,12 @@ Version 1.6.48 [April 30, 2025]
Removed the Travis CI configuration files, with heartfelt thanks for
their generous support of our project over the past five years!
Version 1.6.49 [June 12, 2025]
Added SIMD-optimized code for the RISC-V Vector Extension (RVV).
(Contributed by Manfred Schlaegl, Dragos Tiselice and Filip Wasil)
Added various fixes and improvements to the build scripts and to
the sample code.
Send comments/corrections/commendations to png-mng-implement at lists.sf.net.
Subscription is required; visit
https://lists.sourceforge.net/lists/listinfo/png-mng-implement

View File

@ -19,7 +19,7 @@
set(PNGLIB_MAJOR 1)
set(PNGLIB_MINOR 6)
set(PNGLIB_REVISION 48)
set(PNGLIB_REVISION 49)
set(PNGLIB_SUBREVISION 0)
#set(PNGLIB_SUBREVISION "git")
set(PNGLIB_VERSION ${PNGLIB_MAJOR}.${PNGLIB_MINOR}.${PNGLIB_REVISION})
@ -116,8 +116,7 @@ if(NOT PNG_EXECUTABLES)
endif()
endif()
# Allow the users to configure various compilation options.
option(PNG_DEBUG "Enable debug output" OFF)
# Allow the users to switch on/off the use of hardware (SIMD) optimized code.
option(PNG_HARDWARE_OPTIMIZATIONS "Enable hardware optimizations" ON)
ENDIF(0) # rom-properties
@ -159,6 +158,7 @@ else()
find_package(ZLIB REQUIRED)
endif()
# Find the math library (where available).
if(UNIX
AND NOT (APPLE OR BEOS OR HAIKU)
AND NOT EMSCRIPTEN)
@ -172,6 +172,13 @@ else()
# libm is not available or not needed.
endif()
# Silence function deprecation warnings on the Windows compilers that might
# use the MSVC Runtime library headers.
if(WIN32 AND (CMAKE_C_COMPILER_ID MATCHES "MSVC|Intel|Clang"))
add_definitions(-D_CRT_NONSTDC_NO_DEPRECATE)
add_definitions(-D_CRT_SECURE_NO_DEPRECATE)
endif()
if(PNG_HARDWARE_OPTIMIZATIONS)
# Set definitions and sources for ARM.
@ -360,6 +367,35 @@ if(PNG_HARDWARE_OPTIMIZATIONS)
endif()
endif()
# Set definitions and sources for RISC-V.
if(PNG_TARGET_ARCHITECTURE MATCHES "^(riscv)")
include(CheckCCompilerFlag)
set(PNG_RISCV_RVV_POSSIBLE_VALUES check on off)
set(PNG_RISCV_RVV "off"
CACHE STRING "Enable RISC-V Vector optimizations: check|on|off; off is default")
set_property(CACHE PNG_RISCV_RVV
PROPERTY STRINGS ${PNG_RISCV_RVV_POSSIBLE_VALUES})
list(FIND PNG_RISCV_RVV_POSSIBLE_VALUES ${PNG_RISCV_RVV} index)
if(index EQUAL -1)
message(FATAL_ERROR "PNG_RISCV_RVV must be one of [${PNG_RISCV_RVV_POSSIBLE_VALUES}]")
elseif(NOT PNG_RISCV_RVV STREQUAL "off")
check_c_compiler_flag("-march=rv64gv1p0" COMPILER_SUPPORTS_RVV)
if(NOT COMPILER_SUPPORTS_RVV)
message(FATAL_ERROR "Compiler does not support -march=rv64gv1p0 option")
endif()
set(libpng_riscv_sources
riscv/filter_rvv_intrinsics.c
riscv/riscv_init.c)
if(PNG_RISCV_RVV STREQUAL "on")
add_definitions(-DPNG_RISCV_RVV_OPT=2)
elseif(PNG_RISCV_RVV STREQUAL "check")
add_definitions(-DPNG_RISCV_RVV_CHECK_SUPPORTED)
endif()
else()
add_definitions(-DPNG_RISCV_RVV_OPT=0)
endif()
endif()
else(PNG_HARDWARE_OPTIMIZATIONS)
# Set definitions and sources for ARM.
@ -387,6 +423,11 @@ else(PNG_HARDWARE_OPTIMIZATIONS)
add_definitions(-DPNG_LOONGARCH_LSX_OPT=0)
endif()
# Set definitions and sources for RISC-V.
if(PNG_TARGET_ARCHITECTURE MATCHES "^(riscv)")
add_definitions(-DPNG_RISCV_RVV_OPT=0)
endif()
endif(PNG_HARDWARE_OPTIMIZATIONS)
option(ld-version-script "Enable linker version script" ON)
@ -442,13 +483,13 @@ if(PNG_LIBCONF_HEADER STREQUAL "")
endif()
# Include the internal module PNGCheckLibconf.cmake
include(${CMAKE_CURRENT_SOURCE_DIR}/scripts/cmake/PNGCheckLibconf.cmake)
include("${CMAKE_CURRENT_SOURCE_DIR}/scripts/cmake/PNGCheckLibconf.cmake")
if(NOT PNG_LIBCONF_HEADER STREQUAL "")
# Configure libpng with the user-defined pnglibconf.h file.
png_check_libconf(HEADER "${PNG_LIBCONF_HEADER}")
configure_file("${PNG_LIBCONF_HEADER}"
${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.h
"${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.h"
@ONLY)
add_custom_target(png_genfiles)
elseif(NOT AWK)
@ -456,47 +497,43 @@ elseif(NOT AWK)
# Configure libpng with pnglibconf.h.prebuilt.
png_check_libconf(HEADER "${PNG_LIBCONF_HEADER_PREBUILT}")
configure_file("${PNG_LIBCONF_HEADER_PREBUILT}"
${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.h
"${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.h"
@ONLY)
add_custom_target(png_genfiles)
else()
png_check_libconf(DFA_XTRA "${DFA_XTRA}")
# Include the internal module PNGGenConfig.cmake
include(${CMAKE_CURRENT_SOURCE_DIR}/scripts/cmake/PNGGenConfig.cmake)
include("${CMAKE_CURRENT_SOURCE_DIR}/scripts/cmake/PNGGenConfig.cmake")
# Work around a limitation of various Windows AWK programs that are
# unable to process CRLF-terminated AWK scripts.
# Copy these AWK scripts to a temporary location, converting their
# line endings from Windows (CRLF) to Unix (LF) at the destination.
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/scripts/checksym.awk
${CMAKE_CURRENT_BINARY_DIR}/scripts/checksym.awk
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/scripts/checksym.awk"
"${CMAKE_CURRENT_BINARY_DIR}/scripts/checksym.awk"
@ONLY
NEWLINE_STYLE LF)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/scripts/options.awk
${CMAKE_CURRENT_BINARY_DIR}/scripts/options.awk
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/scripts/options.awk"
"${CMAKE_CURRENT_BINARY_DIR}/scripts/options.awk"
@ONLY
NEWLINE_STYLE LF)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/scripts/dfn.awk
${CMAKE_CURRENT_BINARY_DIR}/scripts/dfn.awk
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/scripts/dfn.awk"
"${CMAKE_CURRENT_BINARY_DIR}/scripts/dfn.awk"
@ONLY
NEWLINE_STYLE LF)
# Generate scripts/pnglibconf.h
generate_source(OUTPUT "scripts/pnglibconf.c"
generate_source(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/scripts/pnglibconf.c"
DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/scripts/pnglibconf.dfa"
"${CMAKE_CURRENT_BINARY_DIR}/scripts/options.awk"
"${CMAKE_CURRENT_SOURCE_DIR}/pngconf.h")
add_custom_target(png_scripts_pnglibconf_c
DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/scripts/pnglibconf.c")
# Generate pnglibconf.c
generate_source(OUTPUT "pnglibconf.c"
generate_source(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.c"
DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/scripts/pnglibconf.dfa"
"${CMAKE_CURRENT_BINARY_DIR}/scripts/options.awk"
"${CMAKE_CURRENT_SOURCE_DIR}/pngconf.h")
add_custom_target(pnglibconf_c
DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.c")
if(PNG_PREFIX)
set(PNGLIBCONF_H_EXTRA_DEPENDS
@ -507,85 +544,53 @@ else()
endif()
generate_out(INPUT "${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.c"
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.out"
DEPENDS pnglibconf_c)
add_custom_target(pnglibconf_out
DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.out")
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.out")
# Generate pnglibconf.h
generate_source(OUTPUT "pnglibconf.h"
generate_source(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.h"
DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.out"
pnglibconf_out
${PNGLIBCONF_H_EXTRA_DEPENDS})
add_custom_target(pnglibconf_h
DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.h")
generate_out(INPUT "${CMAKE_CURRENT_SOURCE_DIR}/scripts/intprefix.c"
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/scripts/intprefix.out"
DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.h"
pnglibconf_h)
add_custom_target(png_scripts_intprefix_out
DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/scripts/intprefix.out")
DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.h")
generate_out(INPUT "${CMAKE_CURRENT_SOURCE_DIR}/scripts/prefix.c"
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/scripts/prefix.out"
DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/png.h"
"${CMAKE_CURRENT_SOURCE_DIR}/pngconf.h"
"${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.out"
pnglibconf_out)
add_custom_target(png_scripts_prefix_out
DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/scripts/prefix.out")
"${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.out")
# Generate pngprefix.h
generate_source(OUTPUT "pngprefix.h"
generate_source(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/pngprefix.h"
DEPENDS ${PNGPREFIX_H_EXTRA_DEPENDS})
add_custom_target(pngprefix_h
DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/pngprefix.h")
generate_out(INPUT "${CMAKE_CURRENT_SOURCE_DIR}/scripts/sym.c"
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/scripts/sym.out"
DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.h"
pnglibconf_h)
add_custom_target(png_scripts_sym_out
DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/scripts/sym.out")
DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.h")
generate_out(INPUT "${CMAKE_CURRENT_SOURCE_DIR}/scripts/symbols.c"
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/scripts/symbols.out"
DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/png.h"
"${CMAKE_CURRENT_SOURCE_DIR}/pngconf.h"
"${CMAKE_CURRENT_SOURCE_DIR}/scripts/pnglibconf.h.prebuilt")
add_custom_target(png_scripts_symbols_out
DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/scripts/symbols.out")
generate_out(INPUT "${CMAKE_CURRENT_SOURCE_DIR}/scripts/vers.c"
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/scripts/vers.out"
DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/png.h"
"${CMAKE_CURRENT_SOURCE_DIR}/pngconf.h"
"${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.h"
pnglibconf_h)
add_custom_target(png_scripts_vers_out
DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/scripts/vers.out")
"${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.h")
generate_chk(INPUT "${CMAKE_CURRENT_BINARY_DIR}/scripts/symbols.out"
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/scripts/symbols.chk"
DEPENDS png_scripts_symbols_out
"${CMAKE_CURRENT_BINARY_DIR}/scripts/checksym.awk"
DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/scripts/checksym.awk"
"${CMAKE_CURRENT_SOURCE_DIR}/scripts/symbols.def")
add_custom_target(png_scripts_symbols_chk
DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/scripts/symbols.chk")
generate_copy(INPUT "${CMAKE_CURRENT_BINARY_DIR}/scripts/sym.out"
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/libpng.sym"
DEPENDS png_scripts_sym_out)
generate_copy(INPUT "${CMAKE_CURRENT_BINARY_DIR}/scripts/vers.out"
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/libpng.vers"
DEPENDS png_scripts_vers_out)
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/libpng.sym")
add_custom_target(png_genvers
DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/libpng.vers")
add_custom_target(png_gensym
DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/libpng.sym")
generate_copy(INPUT "${CMAKE_CURRENT_BINARY_DIR}/scripts/vers.out"
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/libpng.vers")
add_custom_target(png_genprebuilt
COMMAND "${CMAKE_COMMAND}"
@ -596,31 +601,18 @@ else()
# A single target handles generation of all generated files.
add_custom_target(png_genfiles
DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/libpng.sym"
png_gensym
"${CMAKE_CURRENT_BINARY_DIR}/libpng.vers"
png_genvers
"${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.c"
pnglibconf_c
"${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.h"
pnglibconf_h
"${CMAKE_CURRENT_BINARY_DIR}/pnglibconf.out"
pnglibconf_out
"${CMAKE_CURRENT_BINARY_DIR}/pngprefix.h"
pngprefix_h
"${CMAKE_CURRENT_BINARY_DIR}/scripts/intprefix.out"
png_scripts_intprefix_out
"${CMAKE_CURRENT_BINARY_DIR}/scripts/pnglibconf.c"
png_scripts_pnglibconf_c
"${CMAKE_CURRENT_BINARY_DIR}/scripts/prefix.out"
png_scripts_prefix_out
"${CMAKE_CURRENT_BINARY_DIR}/scripts/sym.out"
png_scripts_sym_out
"${CMAKE_CURRENT_BINARY_DIR}/scripts/symbols.chk"
png_scripts_symbols_chk
"${CMAKE_CURRENT_BINARY_DIR}/scripts/symbols.out"
png_scripts_symbols_out
"${CMAKE_CURRENT_BINARY_DIR}/scripts/vers.out"
png_scripts_vers_out)
"${CMAKE_CURRENT_BINARY_DIR}/scripts/vers.out")
endif()
# List the source code files.
@ -661,7 +653,9 @@ set(libpng_sources
${libpng_mips_sources}
${libpng_powerpc_sources}
${libpng_loongarch_sources}
${libpng_riscv_sources}
)
set(pngtest_sources
pngtest.c
)
@ -684,11 +678,6 @@ set(png_fix_itxt_sources
contrib/tools/png-fix-itxt.c
)
if(MSVC OR (WIN32 AND (CMAKE_C_COMPILER_ID MATCHES "Clang")))
add_definitions(-D_CRT_NONSTDC_NO_DEPRECATE)
add_definitions(-D_CRT_SECURE_NO_DEPRECATE)
endif()
# rom-properties: FIXME: "/guard:cf" causes png_longjmp() to crash
# in MSVC 2022 Release builds on Windows 10.
IF(MSVC)
@ -775,12 +764,12 @@ if(PNG_SHARED)
)
endif()
target_include_directories(png_shared
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>)
PUBLIC "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>")
target_include_directories(png_shared
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>)
PUBLIC "$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>")
target_include_directories(png_shared
SYSTEM
INTERFACE $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/libpng${PNGLIB_ABI_VERSION}>)
INTERFACE "$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/libpng${PNGLIB_ABI_VERSION}>")
# rom-properties: ZLIB::ZLIB -> ${ZLIB_LIBRARY}
target_link_libraries(png_shared
PUBLIC ${ZLIB_LIBRARY} ${M_LIBRARY})
@ -799,12 +788,12 @@ if(PNG_STATIC)
PROPERTIES OUTPUT_NAME "${PNG_STATIC_OUTPUT_NAME}"
DEBUG_POSTFIX "${PNG_DEBUG_POSTFIX}")
target_include_directories(png_static
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>)
PUBLIC "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>")
target_include_directories(png_static
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>)
PUBLIC "$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>")
target_include_directories(png_static
SYSTEM
INTERFACE $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/libpng${PNGLIB_ABI_VERSION}>)
INTERFACE "$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/libpng${PNGLIB_ABI_VERSION}>")
# rom-properties: ZLIB::ZLIB -> ${ZLIB_LIBRARY}
target_link_libraries(png_static
PUBLIC ${ZLIB_LIBRARY} ${M_LIBRARY})
@ -835,12 +824,12 @@ if(PNG_FRAMEWORK)
set_target_properties(png_framework
PROPERTIES DEFINE_SYMBOL "")
target_include_directories(png_framework
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>)
PUBLIC "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>")
target_include_directories(png_framework
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>)
PUBLIC "$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>")
target_include_directories(png_framework
SYSTEM
INTERFACE $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/libpng${PNGLIB_ABI_VERSION}>)
INTERFACE "$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/libpng${PNGLIB_ABI_VERSION}>")
# rom-properties: ZLIB::ZLIB -> ${ZLIB_LIBRARY}
target_link_libraries(png_framework
PUBLIC ${ZLIB_LIBRARY} ${M_LIBRARY})
@ -856,7 +845,7 @@ if(PNG_TESTS AND PNG_SHARED)
enable_testing()
# Include the internal module PNGTest.cmake
include(${CMAKE_CURRENT_SOURCE_DIR}/scripts/cmake/PNGTest.cmake)
include("${CMAKE_CURRENT_SOURCE_DIR}/scripts/cmake/PNGTest.cmake")
# Find test PNG files by globbing, but sort lists to ensure
# consistency between different filesystems.
@ -1067,12 +1056,14 @@ function(create_symlink DEST_FILE)
if(CMAKE_HOST_WIN32 AND NOT CYGWIN)
execute_process(COMMAND "${CMAKE_COMMAND}"
-E copy_if_different
${_SYM_FILE} ${DEST_FILE}
"${_SYM_FILE}"
"${DEST_FILE}"
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}")
else()
execute_process(COMMAND "${CMAKE_COMMAND}"
-E create_symlink
${_SYM_FILE} ${DEST_FILE}
"${_SYM_FILE}"
"${DEST_FILE}"
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}")
endif()
endif()
@ -1086,28 +1077,28 @@ function(create_symlink DEST_FILE)
POST_BUILD
COMMAND "${CMAKE_COMMAND}"
-E copy_if_different
$<TARGET_LINKER_FILE_DIR:${_SYM_TARGET}>/$<TARGET_LINKER_FILE_NAME:${_SYM_TARGET}>
$<TARGET_LINKER_FILE_DIR:${_SYM_TARGET}>/${DEST_FILE})
"$<TARGET_LINKER_FILE_DIR:${_SYM_TARGET}>/$<TARGET_LINKER_FILE_NAME:${_SYM_TARGET}>"
"$<TARGET_LINKER_FILE_DIR:${_SYM_TARGET}>/${DEST_FILE}")
else()
add_custom_command(TARGET ${_SYM_TARGET}
POST_BUILD
COMMAND "${CMAKE_COMMAND}"
-E create_symlink
$<TARGET_LINKER_FILE_NAME:${_SYM_TARGET}>
$<TARGET_LINKER_FILE_DIR:${_SYM_TARGET}>/${DEST_FILE})
"$<TARGET_LINKER_FILE_NAME:${_SYM_TARGET}>"
"$<TARGET_LINKER_FILE_DIR:${_SYM_TARGET}>/${DEST_FILE}")
endif()
endif()
endfunction()
# Create source generation scripts.
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/scripts/cmake/genchk.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/scripts/cmake/genchk.cmake
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/scripts/cmake/genchk.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/scripts/cmake/genchk.cmake"
@ONLY)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/scripts/cmake/genout.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/scripts/cmake/genout.cmake
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/scripts/cmake/genout.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/scripts/cmake/genout.cmake"
@ONLY)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/scripts/cmake/gensrc.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/scripts/cmake/gensrc.cmake
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/scripts/cmake/gensrc.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/scripts/cmake/gensrc.cmake"
@ONLY)
# libpng is a library so default to 'lib'
@ -1120,17 +1111,17 @@ endif()
# Only do this on Windows for Cygwin - the files don't make much sense
# outside of a UNIX look-alike.
if(NOT WIN32 OR CYGWIN OR MINGW)
set(prefix ${CMAKE_INSTALL_PREFIX})
set(exec_prefix ${CMAKE_INSTALL_PREFIX})
set(libdir ${CMAKE_INSTALL_FULL_LIBDIR})
set(includedir ${CMAKE_INSTALL_FULL_INCLUDEDIR})
set(prefix "${CMAKE_INSTALL_PREFIX}")
set(exec_prefix "${CMAKE_INSTALL_PREFIX}")
set(libdir "${CMAKE_INSTALL_FULL_LIBDIR}")
set(includedir "${CMAKE_INSTALL_FULL_INCLUDEDIR}")
set(LIBS "-lz -lm")
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/libpng.pc.in
${CMAKE_CURRENT_BINARY_DIR}/libpng${PNGLIB_ABI_VERSION}.pc
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/libpng.pc.in"
"${CMAKE_CURRENT_BINARY_DIR}/libpng${PNGLIB_ABI_VERSION}.pc"
@ONLY)
create_symlink(libpng.pc FILE libpng${PNGLIB_ABI_VERSION}.pc)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/libpng-config.in
${CMAKE_CURRENT_BINARY_DIR}/libpng${PNGLIB_ABI_VERSION}-config
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/libpng-config.in"
"${CMAKE_CURRENT_BINARY_DIR}/libpng${PNGLIB_ABI_VERSION}-config"
@ONLY)
create_symlink(libpng-config FILE libpng${PNGLIB_ABI_VERSION}-config)
endif()
@ -1146,10 +1137,10 @@ if(NOT SKIP_INSTALL_LIBRARIES AND NOT SKIP_INSTALL_ALL)
# - Disabled the export rule
install(TARGETS ${PNG_LIBRARY_TARGETS}
#EXPORT libpng
RUNTIME DESTINATION ${INSTALL_BIN_DIR}
#LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
#ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
FRAMEWORK DESTINATION ${INSTALL_LIB_DIR})
RUNTIME DESTINATION "${INSTALL_BIN_DIR}"
#LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
#ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
FRAMEWORK DESTINATION "${INSTALL_LIB_DIR}")
IF(INSTALL_DEBUG AND PNG_SHARED)
# FIXME: Generator expression $<TARGET_PROPERTY:${_target},PDB> didn't work with CPack-3.6.1.
@ -1174,16 +1165,16 @@ if(NOT SKIP_INSTALL_LIBRARIES AND NOT SKIP_INSTALL_ALL)
# Create a symlink for libpng.dll.a => libpng16.dll.a on Cygwin
if(NOT WIN32 OR CYGWIN OR MINGW)
create_symlink(libpng${CMAKE_SHARED_LIBRARY_SUFFIX} TARGET png_shared)
install(FILES $<TARGET_LINKER_FILE_DIR:png_shared>/libpng${CMAKE_SHARED_LIBRARY_SUFFIX}
DESTINATION ${CMAKE_INSTALL_LIBDIR})
install(FILES "$<TARGET_LINKER_FILE_DIR:png_shared>/libpng${CMAKE_SHARED_LIBRARY_SUFFIX}"
DESTINATION "${CMAKE_INSTALL_LIBDIR}")
endif()
endif()
if(PNG_STATIC)
if(NOT WIN32 OR CYGWIN OR MINGW)
create_symlink(libpng${CMAKE_STATIC_LIBRARY_SUFFIX} TARGET png_static)
install(FILES $<TARGET_LINKER_FILE_DIR:png_static>/libpng${CMAKE_STATIC_LIBRARY_SUFFIX}
DESTINATION ${CMAKE_INSTALL_LIBDIR})
install(FILES "$<TARGET_LINKER_FILE_DIR:png_static>/libpng${CMAKE_STATIC_LIBRARY_SUFFIX}"
DESTINATION "${CMAKE_INSTALL_LIBDIR}")
endif()
endif()
ENDIF(0)
@ -1191,40 +1182,40 @@ endif()
if(NOT SKIP_INSTALL_HEADERS AND NOT SKIP_INSTALL_ALL)
install(FILES ${libpng_public_hdrs}
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}")
install(FILES ${libpng_public_hdrs}
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/libpng${PNGLIB_ABI_VERSION})
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/libpng${PNGLIB_ABI_VERSION}")
endif()
if(NOT SKIP_INSTALL_EXECUTABLES AND NOT SKIP_INSTALL_ALL)
if(NOT WIN32 OR CYGWIN OR MINGW)
install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/libpng-config
DESTINATION ${CMAKE_INSTALL_BINDIR})
install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/libpng${PNGLIB_ABI_VERSION}-config
DESTINATION ${CMAKE_INSTALL_BINDIR})
install(PROGRAMS "${CMAKE_CURRENT_BINARY_DIR}/libpng-config"
DESTINATION "${CMAKE_INSTALL_BINDIR}")
install(PROGRAMS "${CMAKE_CURRENT_BINARY_DIR}/libpng${PNGLIB_ABI_VERSION}-config"
DESTINATION "${CMAKE_INSTALL_BINDIR}")
endif()
endif()
if(NOT SKIP_INSTALL_PROGRAMS AND NOT SKIP_INSTALL_ALL)
install(TARGETS ${PNG_BIN_TARGETS}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}")
endif()
if(NOT SKIP_INSTALL_FILES AND NOT SKIP_INSTALL_ALL)
# Install the man pages.
install(FILES libpng.3 libpngpf.3
DESTINATION ${CMAKE_INSTALL_MANDIR}/man3)
DESTINATION "${CMAKE_INSTALL_MANDIR}/man3")
install(FILES png.5
DESTINATION ${CMAKE_INSTALL_MANDIR}/man5)
DESTINATION "${CMAKE_INSTALL_MANDIR}/man5")
# Install the pkg-config files.
if(NOT CMAKE_HOST_WIN32 OR CYGWIN OR MINGW)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libpng.pc
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/libpng-config
DESTINATION ${CMAKE_INSTALL_BINDIR})
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libpng${PNGLIB_ABI_VERSION}.pc
DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/libpng${PNGLIB_ABI_VERSION}-config
DESTINATION ${CMAKE_INSTALL_BINDIR})
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/libpng.pc"
DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
install(PROGRAMS "${CMAKE_CURRENT_BINARY_DIR}/libpng-config"
DESTINATION "${CMAKE_INSTALL_BINDIR}")
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/libpng${PNGLIB_ABI_VERSION}.pc"
DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
install(PROGRAMS "${CMAKE_CURRENT_BINARY_DIR}/libpng${PNGLIB_ABI_VERSION}-config"
DESTINATION "${CMAKE_INSTALL_BINDIR}")
endif()
endif()
@ -1233,7 +1224,7 @@ endif()
IF(0)
if(NOT SKIP_INSTALL_EXPORT AND NOT SKIP_INSTALL_ALL)
install(EXPORT libpng
DESTINATION ${CMAKE_INSTALL_LIBDIR}/libpng
DESTINATION "${CMAKE_INSTALL_LIBDIR}/libpng"
FILE libpng${PNGLIB_ABI_VERSION}.cmake)
endif()
ENDIF(0) # rom-properties
@ -1242,10 +1233,10 @@ ENDIF(0) # rom-properties
if(NOT SKIP_INSTALL_CONFIG_FILE AND NOT SKIP_INSTALL_ALL)
install(TARGETS ${PNG_LIBRARY_TARGETS}
EXPORT PNGTargets
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
FRAMEWORK DESTINATION ${CMAKE_INSTALL_LIBDIR})
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
FRAMEWORK DESTINATION "${CMAKE_INSTALL_LIBDIR}")
include(CMakePackageConfigHelpers)
write_basic_package_version_file(PNGConfigVersion.cmake
@ -1255,11 +1246,11 @@ if(NOT SKIP_INSTALL_CONFIG_FILE AND NOT SKIP_INSTALL_ALL)
install(EXPORT PNGTargets
FILE PNGTargets.cmake
NAMESPACE PNG::
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/PNG)
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/PNG")
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/scripts/cmake/PNGConfig.cmake
${CMAKE_CURRENT_BINARY_DIR}/PNGConfigVersion.cmake
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/PNG)
install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/scripts/cmake/PNGConfig.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/PNGConfigVersion.cmake"
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/PNG")
endif()
# TODO: Create MSVC import lib for MinGW-compiled shared lib.

10
extlib/libpng/INSTALL vendored
View File

@ -136,7 +136,7 @@ Your directory structure should look like this:
depcomp, install-sh, mkinstalldirs, test-pngtest.sh, etc.
contrib
arm-neon, conftest, examples, gregbook, libtests, pngminim,
pngminus, pngsuite, tools, visupng
pngminus, pngsuite, tools, visupng, riscv-rvv
projects
owatcom, visualc71, vstudio
scripts
@ -289,6 +289,7 @@ such as one of
--enable-mips-msa=yes
--enable-intel-sse=yes
--enable-powerpc-vsx=yes
--enable-riscv-rvv=yes
or enable them all at once with
@ -301,6 +302,7 @@ or more of
CPPFLAGS += "-DPNG_MIPS_MSA"
CPPFLAGS += "-DPNG_INTEL_SSE"
CPPFLAGS += "-DPNG_POWERPC_VSX"
CPPFLAGS += "-DPNG_RISCV_RVV"
See for example scripts/makefile.linux-opt
@ -317,13 +319,15 @@ to disable a particular one,
or via compiler-command options such as
CPPFLAGS += "-DPNG_ARM_NEON_OPT=0, -DPNG_MIPS_MSA_OPT=0,
-DPNG_INTEL_SSE_OPT=0, -DPNG_POWERPC_VSX_OPT=0"
-DPNG_INTEL_SSE_OPT=0, -DPNG_POWERPC_VSX_OPT=0,
-DPNG_RISCV_RVV_OPT=0"
If you are using cmake, hardware optimizations are "on"
by default. To disable them, use
cmake . -DPNG_ARM_NEON=no -DPNG_INTEL_SSE=no \
-DPNG_MIPS_MSA=no -DPNG_POWERPC_VSX=no
-DPNG_MIPS_MSA=no -DPNG_POWERPC_VSX=no \
-DPNG_RISCV_RVV=no
or disable them all at once with

View File

@ -1,4 +1,4 @@
README for libpng version 1.6.48
README for libpng version 1.6.49
================================
See the note about version numbers near the top of `png.h`.
@ -147,6 +147,7 @@ Files included in this distribution
loongarch/ => Optimized code for LoongArch LSX
mips/ => Optimized code for MIPS MSA and MIPS MMI
powerpc/ => Optimized code for PowerPC VSX
riscv/ => Optimized code for the RISC-V platform
ci/ => Scripts for continuous integration
contrib/ => External contributions
arm-neon/ => Optimized code for the ARM-NEON platform
@ -162,6 +163,7 @@ Files included in this distribution
programs demonstrating the use of pngusr.dfa
pngminus/ => Simple pnm2png and png2pnm programs
pngsuite/ => Test images
riscv-rvv/ => Optimized code for the RISC-V Vector platform
testpngs/ => Test images
tools/ => Various tools
visupng/ => VisualPng, a Windows viewer for PNG images

View File

@ -108,6 +108,15 @@
/* Enable POWERPC VSX optimizations */
#undef PNG_POWERPC_VSX_OPT
/* Turn on RISC-V Vector optimizations at run-time */
#undef PNG_RISCV_RVV_API_SUPPORTED
/* Check for RISC-V Vector support at run-time */
#undef PNG_RISCV_RVV_CHECK_SUPPORTED
/* Enable RISCV RVV optimizations */
#undef PNG_RISCV_RVV_OPT
/* Define to 1 if all of the C89 standard headers exist (not just the ones
required in a freestanding environment). This macro is provided for
backward compatibility; new code need not use it. */

85
extlib/libpng/contrib/riscv-rvv/README vendored Normal file
View File

@ -0,0 +1,85 @@
OPERATING SYSTEM SPECIFIC RISC-V RVV DETECTION
----------------------------------------------
Detection of the ability to execute RISC-V Vector on a RISC-V processor
requires operating system support. (The information is not available in user
mode.)
HOW TO USE THIS
---------------
This directory contains C code fragments that can be included in
riscv/riscv_init.c by setting the macro PNG_RISCV_RVV_FILE to the file name
in "" or <> at build time. This setting is not recorded in pnglibconf.h and
can be changed simply by rebuilding riscv/riscv_init.o with the required macro
definition.
For any of this code to be used the RISC-V Vector code must be enabled and run
time checks must be supported. I.e.:
#if PNG_RISCV_RVV_OPT > 0
#ifdef PNG_RISCV_RVV_CHECK_SUPPORTED
This is done in a 'configure' build by passing configure the argument:
--enable-riscv-rvv=check
Apart from the basic Linux implementation in contrib/riscv-rvv/linux.c this
code is unsupported. That means that it is not even compiled on a regular
basis and may be broken in any given minor release.
FILE FORMAT
-----------
Each file documents its testing status as of the last time it was tested (which
may have been a long time ago):
STATUS: one of:
SUPPORTED: This indicates that the file is included in the regularly
performed test builds and bugs are fixed when discovered.
COMPILED: This indicates that the code did compile at least once. See the
more detailed description for the extent to which the result was
successful.
TESTED: This means the code was fully compiled into the libpng test programs
and these were run at least once.
BUG REPORTS: an email address to which to send reports of problems
The file is a fragment of C code. It should not define any 'extern' symbols;
everything should be static. It must define the function:
static int png_have_rvv(png_structp png_ptr);
That function must return 1 if RISC-V Vector instructions are supported, 0 if
not. It must not execute png_error unless it detects a bug. A png_error will
prevent the reading of the PNG and in the future, writing too.
BUG REPORTS
-----------
If you mail a bug report for any file that is not SUPPORTED there may only be
limited response. Consider fixing it and sending a patch to fix the problem -
this is more likely to result in action.
CONTRIBUTIONS
-------------
You may send contributions of new implementations to
png-mng-implement@sourceforge.net. Please write code in strict C90 C where
possible. Obviously OS dependencies are to be expected. If you submit code you
must have the authors permission and it must have a license that is acceptable
to the current maintainer; in particular that license must permit modification
and redistribution.
Please try to make the contribution a single file and give the file a clear and
unambiguous name that identifies the target OS. If multiple files really are
required put them all in a sub-directory.
You must also be prepared to handle bug reports from users of the code, either
by joining the png-mng-implement mailing list or by providing an email for the
"BUG REPORTS" entry or both. Please make sure that the header of the file
contains the STATUS and BUG REPORTS fields as above.
Please list the OS requirements as precisely as possible. Ideally you should
also list the environment in which the code has been tested and certainly list
any environments where you suspect it might not work.

36
extlib/libpng/contrib/riscv-rvv/linux.c vendored Normal file
View File

@ -0,0 +1,36 @@
/* contrib/riscv-rvv/linux.c
*
* Copyright (c) 2023 Google LLC
* Written by Dragoș Tiselice <dtiselice@google.com>, May 2023.
*
* This code is released under the libpng license.
* For conditions of distribution and use, see the disclaimer
* and license in png.h
*
* SEE contrib/riscv-rvv/README before reporting bugs
*
* STATUS: SUPPORTED
* BUG REPORTS: png-mng-implement@sourceforge.net
*
* png_have_rvv implemented for Linux by looking for COMPAT_HWCAP_ISA_V
* via hardware capabilites API.
*
* This code is strict ANSI-C and is probably moderately portable; it does
* however use <stdio.h> and it assumes that /proc/cpuinfo is never localized.
*/
#if defined(__linux__)
#include <asm/hwcap.h>
#include <sys/auxv.h>
#endif
static int
png_have_rvv(png_structp png_ptr) {
#if defined(__linux__)
return getauxval (AT_HWCAP) & COMPAT_HWCAP_ISA_V ? 1 : 0;
#else
#pragma message( \
"warning: RISC-V Vector not supported for this platform")
return 0;
#endif
}

View File

@ -9,7 +9,7 @@ libpng-manual.txt - A description on how to use and modify libpng
Based on:
libpng version 1.6.36, December 2018, through 1.6.48 - April 2025
libpng version 1.6.36, December 2018, through 1.6.49 - June 2025
Updated and distributed by Cosmin Truta
Copyright (c) 2018-2025 Cosmin Truta

View File

@ -1,6 +1,6 @@
.TH LIBPNG 3 "April 30, 2025"
.TH LIBPNG 3 "June 12, 2025"
.SH NAME
libpng \- Portable Network Graphics (PNG) Reference Library 1.6.48
libpng \- Portable Network Graphics (PNG) Reference Library 1.6.49
.SH SYNOPSIS
\fB#include <png.h>\fP
@ -528,7 +528,7 @@ libpng-manual.txt - A description on how to use and modify libpng
Based on:
libpng version 1.6.36, December 2018, through 1.6.48 - April 2025
libpng version 1.6.36, December 2018, through 1.6.49 - June 2025
Updated and distributed by Cosmin Truta
Copyright (c) 2018-2025 Cosmin Truta

View File

@ -1,6 +1,6 @@
.TH LIBPNGPF 3 "April 30, 2025"
.TH LIBPNGPF 3 "June 12, 2025"
.SH NAME
libpng \- Portable Network Graphics (PNG) Reference Library 1.6.48
libpng \- Portable Network Graphics (PNG) Reference Library 1.6.49
.SH SYNOPSIS
\fB#include "pngpriv.h"\fP

6
extlib/libpng/png.5 vendored
View File

@ -1,4 +1,4 @@
.TH PNG 5 "April 30, 2025"
.TH PNG 5 "June 12, 2025"
.SH NAME
png \- Portable Network Graphics (PNG) format
@ -20,10 +20,10 @@ matching on heterogeneous platforms.
.SH "SEE ALSO"
.BR "libpng"(3), " zlib"(3), " deflate"(5), " " and " zlib"(5)
.LP
PNG Specification (Third Edition) Candidate Recommendation, March 2025:
PNG Specification (Third Edition) Proposed Recommendation, May 2025:
.IP
.br
https://www.w3.org/TR/2025/CR-png-3-20250313/
https://www.w3.org/TR/2025/PR-png-3-20250515/
.LP
PNG Specification (Second Edition), November 2003:
.IP

4
extlib/libpng/png.c vendored
View File

@ -13,7 +13,7 @@
#include "pngpriv.h"
/* Generate a compiler error if there is an old png.h in the search path. */
typedef png_libpng_version_1_6_48 Your_png_h_is_not_version_1_6_48;
typedef png_libpng_version_1_6_49 Your_png_h_is_not_version_1_6_49;
/* Sanity check the chunks definitions - PNG_KNOWN_CHUNKS from pngpriv.h and the
* corresponding macro definitions. This causes a compile time failure if
@ -815,7 +815,7 @@ png_get_copyright(png_const_structrp png_ptr)
return PNG_STRING_COPYRIGHT
#else
return PNG_STRING_NEWLINE \
"libpng version 1.6.48" PNG_STRING_NEWLINE \
"libpng version 1.6.49" PNG_STRING_NEWLINE \
"Copyright (c) 2018-2025 Cosmin Truta" PNG_STRING_NEWLINE \
"Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson" \
PNG_STRING_NEWLINE \

67
extlib/libpng/png.h vendored
View File

@ -1,6 +1,6 @@
/* png.h - header file for PNG reference library
*
* libpng version 1.6.48
* libpng version 1.6.49
*
* Copyright (c) 2018-2025 Cosmin Truta
* Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson
@ -14,7 +14,7 @@
* libpng versions 0.89, June 1996, through 0.96, May 1997: Andreas Dilger
* libpng versions 0.97, January 1998, through 1.6.35, July 2018:
* Glenn Randers-Pehrson
* libpng versions 1.6.36, December 2018, through 1.6.48, April 2025:
* libpng versions 1.6.36, December 2018, through 1.6.49, June 2025:
* Cosmin Truta
* See also "Contributing Authors", below.
*/
@ -238,7 +238,7 @@
* ...
* 1.5.30 15 10530 15.so.15.30[.0]
* ...
* 1.6.48 16 10648 16.so.16.48[.0]
* 1.6.49 16 10649 16.so.16.49[.0]
*
* Henceforth the source version will match the shared-library major and
* minor numbers; the shared-library major version number will be used for
@ -274,7 +274,7 @@
*/
/* Version information for png.h - this should match the version in png.c */
#define PNG_LIBPNG_VER_STRING "1.6.48"
#define PNG_LIBPNG_VER_STRING "1.6.49"
#define PNG_HEADER_VERSION_STRING " libpng version " PNG_LIBPNG_VER_STRING "\n"
/* The versions of shared library builds should stay in sync, going forward */
@ -285,7 +285,7 @@
/* These should match the first 3 components of PNG_LIBPNG_VER_STRING: */
#define PNG_LIBPNG_VER_MAJOR 1
#define PNG_LIBPNG_VER_MINOR 6
#define PNG_LIBPNG_VER_RELEASE 48
#define PNG_LIBPNG_VER_RELEASE 49
/* This should be zero for a public release, or non-zero for a
* development version.
@ -316,7 +316,7 @@
* From version 1.0.1 it is:
* XXYYZZ, where XX=major, YY=minor, ZZ=release
*/
#define PNG_LIBPNG_VER 10648 /* 1.6.48 */
#define PNG_LIBPNG_VER 10649 /* 1.6.49 */
/* Library configuration: these options cannot be changed after
* the library has been built.
@ -441,7 +441,7 @@ extern "C" {
/* This triggers a compiler error in png.c, if png.c and png.h
* do not agree upon the version number.
*/
typedef char* png_libpng_version_1_6_48;
typedef char* png_libpng_version_1_6_49;
/* Basic control structions. Read libpng-manual.txt or libpng.3 for more info.
*
@ -3322,26 +3322,45 @@ PNG_EXPORT(245, int, png_image_write_to_memory, (png_imagep image, void *memory,
* selected at run time.
*/
#ifdef PNG_SET_OPTION_SUPPORTED
/* HARDWARE: ARM Neon SIMD instructions supported */
#ifdef PNG_ARM_NEON_API_SUPPORTED
# define PNG_ARM_NEON 0 /* HARDWARE: ARM Neon SIMD instructions supported */
#endif
#define PNG_MAXIMUM_INFLATE_WINDOW 2 /* SOFTWARE: force maximum window */
#define PNG_SKIP_sRGB_CHECK_PROFILE 4 /* SOFTWARE: Check ICC profile for sRGB */
#ifdef PNG_MIPS_MSA_API_SUPPORTED
# define PNG_MIPS_MSA 6 /* HARDWARE: MIPS Msa SIMD instructions supported */
#endif
#ifdef PNG_DISABLE_ADLER32_CHECK_SUPPORTED
# define PNG_IGNORE_ADLER32 8 /* SOFTWARE: disable Adler32 check on IDAT */
#endif
#ifdef PNG_POWERPC_VSX_API_SUPPORTED
# define PNG_POWERPC_VSX 10 /* HARDWARE: PowerPC VSX SIMD instructions
* supported */
#endif
#ifdef PNG_MIPS_MMI_API_SUPPORTED
# define PNG_MIPS_MMI 12 /* HARDWARE: MIPS MMI SIMD instructions supported */
# define PNG_ARM_NEON 0
#endif
#define PNG_OPTION_NEXT 14 /* Next option - numbers must be even */
/* SOFTWARE: Force maximum window */
#define PNG_MAXIMUM_INFLATE_WINDOW 2
/* SOFTWARE: Check ICC profile for sRGB */
#define PNG_SKIP_sRGB_CHECK_PROFILE 4
/* HARDWARE: MIPS MSA SIMD instructions supported */
#ifdef PNG_MIPS_MSA_API_SUPPORTED
# define PNG_MIPS_MSA 6
#endif
/* SOFTWARE: Disable Adler32 check on IDAT */
#ifdef PNG_DISABLE_ADLER32_CHECK_SUPPORTED
# define PNG_IGNORE_ADLER32 8
#endif
/* HARDWARE: PowerPC VSX SIMD instructions supported */
#ifdef PNG_POWERPC_VSX_API_SUPPORTED
# define PNG_POWERPC_VSX 10
#endif
/* HARDWARE: MIPS MMI SIMD instructions supported */
#ifdef PNG_MIPS_MMI_API_SUPPORTED
# define PNG_MIPS_MMI 12
#endif
/* HARDWARE: RISC-V RVV SIMD instructions supported */
#ifdef PNG_RISCV_RVV_API_SUPPORTED
# define PNG_RISCV_RVV 14
#endif
/* Next option - numbers must be even */
#define PNG_OPTION_NEXT 16
/* Return values: NOTE: there are four values and 'off' is *not* zero */
#define PNG_OPTION_UNSET 0 /* Unset - defaults to off */

View File

@ -1,6 +1,6 @@
/* pngconf.h - machine-configurable file for libpng
*
* libpng version 1.6.48
* libpng version 1.6.49
*
* Copyright (c) 2018-2025 Cosmin Truta
* Copyright (c) 1998-2002,2004,2006-2016,2018 Glenn Randers-Pehrson

View File

@ -143,6 +143,24 @@
# endif
#endif
#ifndef PNG_RISCV_RVV_OPT
/* RISCV_RVV optimizations are being controlled by the compiler settings,
* typically the target compiler will define __riscv but the rvv extension
* availability has to be explicitly stated. This is why if no
* PNG_RISCV_RVV_OPT was defined then a runtime check will be executed.
*
* To enable RISCV_RVV optimizations unconditionally, and compile the
* associated code, pass --enable-riscv-rvv=yes or --enable-riscv-rvv=on
* to configure or put -DPNG_RISCV_RVV_OPT=2 in CPPFLAGS.
*/
# if defined(__riscv) && defined(PNG_ALIGNED_MEMORY_SUPPORTED)
# define PNG_RISCV_RVV_OPT 1
# else
# define PNG_RISCV_RVV_OPT 0
# endif
#endif
#if PNG_ARM_NEON_OPT > 0
/* NEON optimizations are to be at least considered by libpng, so enable the
* callbacks to do this.
@ -260,6 +278,16 @@
# define PNG_LOONGARCH_LSX_IMPLEMENTATION 0
#endif
#if PNG_RISCV_RVV_OPT > 0
# define PNG_FILTER_OPTIMIZATIONS png_init_filter_functions_rvv
# ifndef PNG_RISCV_RVV_IMPLEMENTATION
/* Use the intrinsics code by default. */
# define PNG_RISCV_RVV_IMPLEMENTATION 1
# endif
#else
# define PNG_RISCV_RVV_IMPLEMENTATION 0
#endif
/* 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
* so PNG_BUILD_DLL must be set.
@ -1505,6 +1533,23 @@ PNG_INTERNAL_FUNCTION(void,png_read_filter_row_paeth4_lsx,(png_row_infop
row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);
#endif
#if PNG_RISCV_RVV_OPT > 0
PNG_INTERNAL_FUNCTION(void,png_read_filter_row_up_rvv,(png_row_infop
row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);
PNG_INTERNAL_FUNCTION(void,png_read_filter_row_sub3_rvv,(png_row_infop
row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);
PNG_INTERNAL_FUNCTION(void,png_read_filter_row_sub4_rvv,(png_row_infop
row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);
PNG_INTERNAL_FUNCTION(void,png_read_filter_row_avg3_rvv,(png_row_infop
row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);
PNG_INTERNAL_FUNCTION(void,png_read_filter_row_avg4_rvv,(png_row_infop
row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);
PNG_INTERNAL_FUNCTION(void,png_read_filter_row_paeth3_rvv,(png_row_infop
row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);
PNG_INTERNAL_FUNCTION(void,png_read_filter_row_paeth4_rvv,(png_row_infop
row_info, png_bytep row, png_const_bytep prev_row),PNG_EMPTY);
#endif
/* Choose the best filter to use and filter the row data */
PNG_INTERNAL_FUNCTION(void,png_write_find_filter,(png_structrp png_ptr,
png_row_infop row_info),PNG_EMPTY);
@ -2158,6 +2203,11 @@ PNG_INTERNAL_FUNCTION(void, png_init_filter_functions_lsx,
(png_structp png_ptr, unsigned int bpp), PNG_EMPTY);
#endif
# if PNG_RISCV_RVV_OPT > 0
PNG_INTERNAL_FUNCTION(void, png_init_filter_functions_rvv,
(png_structp png_ptr, unsigned int bpp), PNG_EMPTY);
#endif
PNG_INTERNAL_FUNCTION(png_uint_32, png_check_keyword, (png_structrp png_ptr,
png_const_charp key, png_bytep new_key), PNG_EMPTY);

View File

@ -889,7 +889,8 @@ png_read_destroy(png_structrp png_ptr)
#endif
#if defined(PNG_READ_EXPAND_SUPPORTED) && \
defined(PNG_ARM_NEON_IMPLEMENTATION)
(defined(PNG_ARM_NEON_IMPLEMENTATION) || \
defined(PNG_RISCV_RVV_IMPLEMENTATION))
png_free(png_ptr, png_ptr->riffled_palette);
png_ptr->riffled_palette = NULL;
#endif

View File

@ -29,6 +29,12 @@
# endif
#endif
#ifdef PNG_RISCV_RVV_IMPLEMENTATION
# if PNG_RISCV_RVV_IMPLEMENTATION == 1
# define PNG_RISCV_RVV_INTRINSICS_AVAILABLE
# endif
#endif
#ifdef PNG_READ_SUPPORTED
/* Set the action on getting a CRC error for an ancillary or critical chunk. */

View File

@ -4434,7 +4434,6 @@ png_read_IDAT_data(png_structrp png_ptr, png_bytep output,
png_error(png_ptr, "Not enough image data");
}
#endif /* PNG_READ_APNG_SUPPORTED */
avail_in = png_ptr->IDAT_read_size;
if (avail_in > png_chunk_max(png_ptr))

View File

@ -375,7 +375,8 @@ struct png_struct_def
/* New member added in libpng-1.6.36 */
#if defined(PNG_READ_EXPAND_SUPPORTED) && \
defined(PNG_ARM_NEON_IMPLEMENTATION)
(defined(PNG_ARM_NEON_IMPLEMENTATION) || \
defined(PNG_RISCV_RVV_IMPLEMENTATION))
png_bytep riffled_palette; /* buffer for accelerated palette expansion */
#endif

View File

@ -50,7 +50,7 @@
#define STDERR stdout
/* Generate a compiler error if there is an old png.h in the search path. */
typedef png_libpng_version_1_6_48 Your_png_h_is_not_version_1_6_48;
typedef png_libpng_version_1_6_49 Your_png_h_is_not_version_1_6_49;
/* Ensure that all version numbers in png.h are consistent with one another. */
#if (PNG_LIBPNG_VER != PNG_LIBPNG_VER_MAJOR * 10000 + \

8
extlib/libpng/riscv/.editorconfig vendored Normal file
View File

@ -0,0 +1,8 @@
# https://editorconfig.org
root = false
# FIXME
[*.[ch]]
max_doc_length = unset
max_line_length = unset

View File

@ -0,0 +1,368 @@
/* filter_rvv_intrinsics.c - RISC-V Vector optimized filter functions
*
* Copyright (c) 2023 Google LLC
* Written by Manfred SCHLAEGL, 2022
* Dragoș Tiselice <dtiselice@google.com>, May 2023.
* Filip Wasil <f.wasil@samsung.com>, March 2025.
*
* 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_RISCV_RVV_IMPLEMENTATION == 1 /* intrinsics code from pngpriv.h */
#include <riscv_vector.h>
void
png_read_filter_row_up_rvv(png_row_infop row_info, png_bytep row,
png_const_bytep prev_row)
{
size_t len = row_info->rowbytes;
for (size_t vl; len > 0; len -= vl, row += vl, prev_row += vl)
{
vl = __riscv_vsetvl_e8m8(len);
vuint8m8_t prev_vals = __riscv_vle8_v_u8m8(prev_row, vl);
vuint8m8_t row_vals = __riscv_vle8_v_u8m8(row, vl);
row_vals = __riscv_vadd_vv_u8m8(row_vals, prev_vals, vl);
__riscv_vse8_v_u8m8(row, row_vals, vl);
}
}
static inline void
png_read_filter_row_sub_rvv(size_t len, size_t bpp, unsigned char* row)
{
png_bytep rp_end = row + len;
/*
* row: | a | x |
*
* a = a + x
*
* a .. [v0](e8)
* x .. [v8](e8)
*/
asm volatile ("vsetvli zero, %0, e8, m1" : : "r" (bpp));
/* a = *row */
asm volatile ("vle8.v v0, (%0)" : : "r" (row));
row += bpp;
while (row < rp_end)
{
/* x = *row */
asm volatile ("vle8.v v8, (%0)" : : "r" (row));
/* a = a + x */
asm volatile ("vadd.vv v0, v0, v8");
/* *row = a */
asm volatile ("vse8.v v0, (%0)" : : "r" (row));
row += bpp;
}
}
void
png_read_filter_row_sub3_rvv(png_row_infop row_info, png_bytep row,
png_const_bytep prev_row)
{
size_t len = row_info->rowbytes;
png_read_filter_row_sub_rvv(len, 3, row);
PNG_UNUSED(prev_row)
}
void
png_read_filter_row_sub4_rvv(png_row_infop row_info, png_bytep row,
png_const_bytep prev_row)
{
size_t len = row_info->rowbytes;
png_read_filter_row_sub_rvv(len, 4, row);
PNG_UNUSED(prev_row)
}
static inline void
png_read_filter_row_avg_rvv(size_t len, size_t bpp, unsigned char* row,
const unsigned char* prev_row)
{
png_bytep rp_end = row + len;
/*
* row: | a | x |
* prev_row: | | b |
*
* a .. [v2](e8)
* b .. [v4](e8)
* x .. [v8](e8)
* tmp .. [v12-v13](e16)
*/
/* first pixel */
asm volatile ("vsetvli zero, %0, e8, m1" : : "r" (bpp));
/* b = *prev_row */
asm volatile ("vle8.v v4, (%0)" : : "r" (prev_row));
prev_row += bpp;
/* x = *row */
asm volatile ("vle8.v v8, (%0)" : : "r" (row));
/* b = b / 2 */
asm volatile ("vsrl.vi v4, v4, 1");
/* a = x + b */
asm volatile ("vadd.vv v2, v4, v8");
/* *row = a */
asm volatile ("vse8.v v2, (%0)" : : "r" (row));
row += bpp;
/* remaining pixels */
while (row < rp_end)
{
/* b = *prev_row */
asm volatile ("vle8.v v4, (%0)" : : "r" (prev_row));
prev_row += bpp;
/* x = *row */
asm volatile ("vle8.v v8, (%0)" : : "r" (row));
/* tmp = a + b */
asm volatile ("vwaddu.vv v12, v2, v4"); /* add with widening */
/* a = tmp/2 */
asm volatile ("vnsrl.wi v2, v12, 1"); /* divide/shift with narrowing */
/* a += x */
asm volatile ("vadd.vv v2, v2, v8");
/* *row = a */
asm volatile ("vse8.v v2, (%0)" : : "r" (row));
row += bpp;
}
}
void
png_read_filter_row_avg3_rvv(png_row_infop row_info, png_bytep row,
png_const_bytep prev_row)
{
size_t len = row_info->rowbytes;
png_read_filter_row_avg_rvv(len, 3, row, prev_row);
PNG_UNUSED(prev_row)
}
void
png_read_filter_row_avg4_rvv(png_row_infop row_info, png_bytep row,
png_const_bytep prev_row)
{
size_t len = row_info->rowbytes;
png_read_filter_row_avg_rvv(len, 4, row, prev_row);
PNG_UNUSED(prev_row)
}
#define MIN_CHUNK_LEN 256
#define MAX_CHUNK_LEN 2048
static inline vuint8m1_t
prefix_sum(vuint8m1_t chunk, unsigned char* carry, size_t vl,
size_t max_chunk_len)
{
size_t r;
for (r = 1; r < MIN_CHUNK_LEN; r <<= 1)
{
vbool8_t shift_mask = __riscv_vmsgeu_vx_u8m1_b8(__riscv_vid_v_u8m1(vl), r, vl);
chunk = __riscv_vadd_vv_u8m1_mu(shift_mask, chunk, chunk, __riscv_vslideup_vx_u8m1(__riscv_vundefined_u8m1(), chunk, r, vl), vl);
}
for (r = MIN_CHUNK_LEN; r < MAX_CHUNK_LEN && r < max_chunk_len; r <<= 1)
{
vbool8_t shift_mask = __riscv_vmsgeu_vx_u8m1_b8(__riscv_vid_v_u8m1(vl), r, vl);
chunk = __riscv_vadd_vv_u8m1_mu(shift_mask, chunk, chunk, __riscv_vslideup_vx_u8m1(__riscv_vundefined_u8m1(), chunk, r, vl), vl);
}
chunk = __riscv_vadd_vx_u8m1(chunk, *carry, vl);
*carry = __riscv_vmv_x_s_u8m1_u8(__riscv_vslidedown_vx_u8m1(chunk, vl - 1, vl));
return chunk;
}
static inline vint16m1_t
abs_diff(vuint16m1_t a, vuint16m1_t b, size_t vl)
{
vint16m1_t diff = __riscv_vreinterpret_v_u16m1_i16m1(__riscv_vsub_vv_u16m1(a, b, vl));
vint16m1_t neg = __riscv_vneg_v_i16m1(diff, vl);
return __riscv_vmax_vv_i16m1(diff, neg, vl);
}
static inline vint16m1_t
abs_sum(vint16m1_t a, vint16m1_t b, size_t vl)
{
vint16m1_t sum = __riscv_vadd_vv_i16m1(a, b, vl);
vint16m1_t neg = __riscv_vneg_v_i16m1(sum, vl);
return __riscv_vmax_vv_i16m1(sum, neg, vl);
}
static inline void
png_read_filter_row_paeth_rvv(size_t len, size_t bpp, unsigned char* row,
const unsigned char* prev)
{
png_bytep rp_end = row + len;
/*
* row: | a | x |
* prev: | c | b |
*
* mask .. [v0]
* a .. [v2](e8)
* b .. [v4](e8)
* c .. [v6](e8)
* x .. [v8](e8)
* p .. [v12-v13](e16)
* pa .. [v16-v17](e16)
* pb .. [v20-v21](e16)
* pc .. [v24-v25](e16)
* tmpmask ..[v31]
*/
/* first pixel */
asm volatile ("vsetvli zero, %0, e8, m1" : : "r" (bpp));
/* a = *row + *prev_row */
asm volatile ("vle8.v v2, (%0)" : : "r" (row));
asm volatile ("vle8.v v6, (%0)" : : "r" (prev));
prev += bpp;
asm volatile ("vadd.vv v2, v2, v6");
/* *row = a */
asm volatile ("vse8.v v2, (%0)" : : "r" (row));
row += bpp;
/* remaining pixels */
while (row < rp_end)
{
/* b = *prev_row */
asm volatile ("vle8.v v4, (%0)" : : "r" (prev));
prev += bpp;
/* x = *row */
asm volatile ("vle8.v v8, (%0)" : : "r" (row));
/* sub (widening to 16bit) */
/* p = b - c */
asm volatile ("vwsubu.vv v12, v4, v6");
/* pc = a - c */
asm volatile ("vwsubu.vv v24, v2, v6");
/* switch to widened */
asm volatile ("vsetvli zero, %0, e16, m2" : : "r" (bpp));
/* pa = abs(p) -> pa = p < 0 ? -p : p */
asm volatile ("vmv.v.v v16, v12"); /* pa = p */
asm volatile ("vmslt.vx v0, v16, zero"); /* set mask[i] if pa[i] < 0 */
asm volatile ("vrsub.vx v16, v16, zero, v0.t"); /* invert negative values in pa; vd[i] = 0 - vs2[i] (if mask[i])
* could be replaced by vneg in rvv >= 1.0
*/
/* pb = abs(p) -> pb = pc < 0 ? -pc : pc */
asm volatile ("vmv.v.v v20, v24"); /* pb = pc */
asm volatile ("vmslt.vx v0, v20, zero"); /* set mask[i] if pc[i] < 0 */
asm volatile ("vrsub.vx v20, v20, zero, v0.t"); /* invert negative values in pb; vd[i] = 0 - vs2[i] (if mask[i])
* could be replaced by vneg in rvv >= 1.0
*/
/* pc = abs(p + pc) -> pc = (p + pc) < 0 ? -(p + pc) : p + pc */
asm volatile ("vadd.vv v24, v24, v12"); /* pc = p + pc */
asm volatile ("vmslt.vx v0, v24, zero"); /* set mask[i] if pc[i] < 0 */
asm volatile ("vrsub.vx v24, v24, zero, v0.t"); /* invert negative values in pc; vd[i] = 0 - vs2[i] (if mask[i])
* could be replaced by vneg in rvv >= 1.0
*/
/*
* if (pb < pa)
* {
* pa = pb;
* a = b;
* // see (*1)
* }
*/
asm volatile ("vmslt.vv v0, v20, v16"); /* set mask[i] if pb[i] < pa[i] */
asm volatile ("vmerge.vvm v16, v16, v20, v0"); /* pa[i] = pb[i] (if mask[i]) */
/*
* if (pc < pa)
* {
* a = c;
* // see (*2)
* }
*/
asm volatile ("vmslt.vv v31, v24, v16"); /* set tmpmask[i] if pc[i] < pa[i] */
/* switch to narrow */
asm volatile ("vsetvli zero, %0, e8, m1" : : "r" (bpp));
/* (*1) */
asm volatile ("vmerge.vvm v2, v2, v4, v0"); /* a = b (if mask[i]) */
/* (*2) */
asm volatile ("vmand.mm v0, v31, v31"); /* mask = tmpmask
* vmand works for rvv 0.7 up to 1.0
* could be replaced by vmcpy in 0.7.1/0.8.1
* or vmmv.m in 1.0
*/
asm volatile ("vmerge.vvm v2, v2, v6, v0"); /* a = c (if mask[i]) */
/* a += x */
asm volatile ("vadd.vv v2, v2, v8");
/* *row = a */
asm volatile ("vse8.v v2, (%0)" : : "r" (row));
row += bpp;
/* prepare next iteration (prev is already in a) */
/* c = b */
asm volatile ("vmv.v.v v6, v4");
}
}
void
png_read_filter_row_paeth3_rvv(png_row_infop row_info, png_bytep row,
png_const_bytep prev_row)
{
size_t len = row_info->rowbytes;
png_read_filter_row_paeth_rvv(len, 3, row, prev_row);
PNG_UNUSED(prev_row)
}
void
png_read_filter_row_paeth4_rvv(png_row_infop row_info, png_bytep row,
png_const_bytep prev_row)
{
size_t len = row_info->rowbytes;
png_read_filter_row_paeth_rvv(len, 4, row, prev_row);
PNG_UNUSED(prev_row)
}
#endif /* PNG_RISCV_RVV_IMPLEMENTATION */
#endif /* READ */

126
extlib/libpng/riscv/riscv_init.c vendored Normal file
View File

@ -0,0 +1,126 @@
/* riscv_init.c - RISC-V Vector optimized filter functions
*
* Copyright (c) 2023 Google LLC
* Written by Dragoș Tiselice <dtiselice@google.com>, May 2023.
* Filip Wasil <f.wasil@samsung.com>, March 2025.
* 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_RISCV_RVV_OPT > 0
#include <riscv_vector.h>
#ifdef PNG_RISCV_RVV_CHECK_SUPPORTED /* Do 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
* RISC-V Vector instructions there is no processor-specific way of detecting
* the presence of the required support, therefore run-time detection is
* extremely OS specific.
*
* You may set the macro PNG_RISCV_RVV_FILE to the file name of file containing
* a fragment of C source code which defines the png_have_rvv function. There
* are a number of implementations in contrib/riscv-rvv, but the only one that
* has partial support is contrib/riscv-rvv/linux.c - a generic Linux
* implementation which reads /proc/cpuinfo.
*/
#include <signal.h>
#ifndef PNG_RISCV_RVV_FILE
# if defined(__linux__)
# define PNG_RISCV_RVV_FILE "contrib/riscv-rvv/linux.c"
# else
# error "No support for run-time RISC-V Vector checking; use compile-time options"
# endif
#endif
static int png_have_rvv(png_structp png_ptr);
#ifdef PNG_RISCV_RVV_FILE
# include PNG_RISCV_RVV_FILE
#endif
#endif /* PNG_RISCV_RVV_CHECK_SUPPORTED */
#ifndef PNG_ALIGNED_MEMORY_SUPPORTED
# error "ALIGNED_MEMORY is required; set: -DPNG_ALIGNED_MEMORY_SUPPORTED"
#endif
void
png_init_filter_functions_rvv(png_structp pp, unsigned int bpp)
{
/* The switch statement is compiled in for RISCV_RVV_API, the call to
* png_have_rvv is compiled in for RISCV_RVV_CHECK. If both are
* defined the check is only performed if the API has not set the VECTOR
* option on or off explicitly. In this case the check controls what
* happens.
*/
png_debug(1, "in png_init_filter_functions_rvv");
#ifdef PNG_RISCV_RVV_API_SUPPORTED
switch ((pp->options >> PNG_RISCV_RVV) & 3)
{
case PNG_OPTION_UNSET:
/* Allow the run-time check to execute if it has been enabled -
* thus both API and CHECK can be turned on. If it isn't supported
* this case will fall through to the 'default' below, which just
* returns.
*/
#endif /* PNG_RISCV_RVV_API_SUPPORTED */
#ifdef PNG_RISCV_RVV_CHECK_SUPPORTED
{
static volatile sig_atomic_t no_rvv = -1; /* not checked */
if (no_rvv < 0)
no_rvv = !png_have_rvv(pp);
if (no_rvv)
return;
}
#ifdef PNG_RISCV_RVV_API_SUPPORTED
break;
#endif
#endif /* PNG_RISCV_RVV_CHECK_SUPPORTED */
#ifdef PNG_RISCV_RVV_API_SUPPORTED
default: /* OFF or INVALID */
return;
case PNG_OPTION_ON:
/* Option turned on */
break;
}
#endif /* PNG_RISCV_RVV_API_SUPPORTED */
/* 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.)
*/
pp->read_filter[PNG_FILTER_VALUE_UP-1] = png_read_filter_row_up_rvv;
if (bpp == 3)
{
pp->read_filter[PNG_FILTER_VALUE_AVG-1] = png_read_filter_row_avg3_rvv;
pp->read_filter[PNG_FILTER_VALUE_PAETH-1] = png_read_filter_row_paeth3_rvv;
pp->read_filter[PNG_FILTER_VALUE_SUB-1] = png_read_filter_row_sub3_rvv;
}
else if (bpp == 4)
{
pp->read_filter[PNG_FILTER_VALUE_AVG-1] = png_read_filter_row_avg4_rvv;
pp->read_filter[PNG_FILTER_VALUE_PAETH-1] = png_read_filter_row_paeth4_rvv;
pp->read_filter[PNG_FILTER_VALUE_SUB-1] = png_read_filter_row_sub4_rvv;
}
}
#endif /* PNG_RISCV_RVV_OPT > 0 */
#endif /* PNG_READ_SUPPORTED */

View File

@ -29,6 +29,7 @@ Author List
* Jeremy Maitin-Shepard
* John Bowler
* Jon Creighton
* Joost Nieuwenhuijse
* Kyle Bentley
* Martin Storsjö
* Owen Rudge

View File

@ -18,21 +18,21 @@ function(generate_chk)
set(options)
set(oneValueArgs INPUT OUTPUT)
set(multiValueArgs DEPENDS)
cmake_parse_arguments(_GC "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
if(NOT _GC_INPUT)
cmake_parse_arguments(_GENCHK "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
if(NOT _GENCHK_INPUT)
message(FATAL_ERROR "generate_chk: Missing INPUT argument")
endif()
if(NOT _GC_OUTPUT)
if(NOT _GENCHK_OUTPUT)
message(FATAL_ERROR "generate_chk: Missing OUTPUT argument")
endif()
# Run genchk.cmake to generate the .chk file.
add_custom_command(OUTPUT "${_GC_OUTPUT}"
add_custom_command(OUTPUT "${_GENCHK_OUTPUT}"
COMMAND "${CMAKE_COMMAND}"
"-DINPUT=${_GC_INPUT}"
"-DOUTPUT=${_GC_OUTPUT}"
"-DINPUT=${_GENCHK_INPUT}"
"-DOUTPUT=${_GENCHK_OUTPUT}"
-P "${CMAKE_CURRENT_BINARY_DIR}/scripts/cmake/genchk.cmake"
DEPENDS "${_GC_INPUT}" ${_GC_DEPENDS}
DEPENDS "${_GENCHK_INPUT}" ${_GENCHK_DEPENDS}
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}")
endfunction()
@ -42,21 +42,21 @@ function(generate_out)
set(options)
set(oneValueArgs INPUT OUTPUT)
set(multiValueArgs DEPENDS)
cmake_parse_arguments(_GO "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
if(NOT _GO_INPUT)
cmake_parse_arguments(_GENOUT "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
if(NOT _GENOUT_INPUT)
message(FATAL_ERROR "generate_out: Missing INPUT argument")
endif()
if(NOT _GO_OUTPUT)
if(NOT _GENOUT_OUTPUT)
message(FATAL_ERROR "generate_out: Missing OUTPUT argument")
endif()
# Run genout.cmake to generate the .out file.
add_custom_command(OUTPUT "${_GO_OUTPUT}"
add_custom_command(OUTPUT "${_GENOUT_OUTPUT}"
COMMAND "${CMAKE_COMMAND}"
"-DINPUT=${_GO_INPUT}"
"-DOUTPUT=${_GO_OUTPUT}"
"-DINPUT=${_GENOUT_INPUT}"
"-DOUTPUT=${_GENOUT_OUTPUT}"
-P "${CMAKE_CURRENT_BINARY_DIR}/scripts/cmake/genout.cmake"
DEPENDS "${_GO_INPUT}" ${_GO_DEPENDS}
DEPENDS "${_GENOUT_INPUT}" ${_GENOUT_DEPENDS}
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}")
endfunction()
@ -66,17 +66,17 @@ function(generate_source)
set(options)
set(oneValueArgs OUTPUT)
set(multiValueArgs DEPENDS)
cmake_parse_arguments(_GSO "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
if(NOT _GSO_OUTPUT)
cmake_parse_arguments(_GENSRC "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
if(NOT _GENSRC_OUTPUT)
message(FATAL_ERROR "generate_source: Missing OUTPUT argument")
endif()
# Run gensrc.cmake to generate the source file.
add_custom_command(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${_GSO_OUTPUT}"
add_custom_command(OUTPUT "${_GENSRC_OUTPUT}"
COMMAND "${CMAKE_COMMAND}"
"-DOUTPUT=${_GSO_OUTPUT}"
"-DOUTPUT=${_GENSRC_OUTPUT}"
-P "${CMAKE_CURRENT_BINARY_DIR}/scripts/cmake/gensrc.cmake"
DEPENDS ${_GSO_DEPENDS}
DEPENDS ${_GENSRC_DEPENDS}
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}")
endfunction()
@ -86,19 +86,19 @@ function(generate_copy)
set(options)
set(oneValueArgs INPUT OUTPUT)
set(multiValueArgs DEPENDS)
cmake_parse_arguments(_GCO "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
if(NOT _GCO_INPUT)
cmake_parse_arguments(_GENCPY "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
if(NOT _GENCPY_INPUT)
message(FATAL_ERROR "generate_copy: Missing INPUT argument")
endif()
if(NOT _GCO_OUTPUT)
if(NOT _GENCPY_OUTPUT)
message(FATAL_ERROR "generate_copy: Missing OUTPUT argument")
endif()
# Make a forced file copy, overwriting any pre-existing output file.
add_custom_command(OUTPUT "${_GCO_OUTPUT}"
add_custom_command(OUTPUT "${_GENCPY_OUTPUT}"
COMMAND "${CMAKE_COMMAND}"
-E remove "${_GCO_OUTPUT}"
-E remove "${_GENCPY_OUTPUT}"
COMMAND "${CMAKE_COMMAND}"
-E copy "${_GCO_INPUT}" "${_GCO_OUTPUT}"
DEPENDS "${source}" ${_GCO_DEPENDS})
-E copy "${_GENCPY_INPUT}" "${_GENCPY_OUTPUT}"
DEPENDS "${_GENCPY_INPUT}" ${_GENCPY_DEPENDS})
endfunction()

View File

@ -1,7 +1,7 @@
# genout.cmake.in
# Generate .out from .c with awk (generic), based upon the automake logic.
# Copyright (c) 2022-2024 Cosmin Truta
# Copyright (c) 2022-2025 Cosmin Truta
# Copyright (c) 2016 Glenn Randers-Pehrson
# Written by Roger Leigh, 2016
#
@ -16,6 +16,7 @@
set(SRCDIR "@CMAKE_CURRENT_SOURCE_DIR@")
set(BINDIR "@CMAKE_CURRENT_BINARY_DIR@")
set(APPLE "@APPLE@")
set(AWK "@AWK@")
set(CMAKE_C_COMPILER "@CMAKE_C_COMPILER@")
set(CMAKE_C_FLAGS @CMAKE_C_FLAGS@)

View File

@ -21,8 +21,8 @@ set(DFA_XTRA "@DFA_XTRA@")
set(PNG_PREFIX "@PNG_PREFIX@")
set(PNGLIB_VERSION "@PNGLIB_VERSION@")
if(OUTPUT STREQUAL "scripts/pnglibconf.c")
# Generate scripts/pnglibconf.c
if(OUTPUT MATCHES "(scripts/pnglibconf\\.c)\$")
# Generate "${BINDIR}/scripts/pnglibconf.c"
file(REMOVE "${BINDIR}/pnglibconf.tf6" "${BINDIR}/pnglibconf.tf7")
@ -49,8 +49,8 @@ if(OUTPUT STREQUAL "scripts/pnglibconf.c")
file(MAKE_DIRECTORY "${BINDIR}/scripts")
file(RENAME "pnglibconf.tf7" "${BINDIR}/scripts/pnglibconf.c")
elseif(OUTPUT STREQUAL "pnglibconf.c")
# Generate pnglibconf.c
elseif(OUTPUT MATCHES "(pnglibconf\\.c)\$")
# Generate "${BINDIR}/pnglibconf.c"
file(REMOVE "${BINDIR}/pnglibconf.tf4" "${BINDIR}/pnglibconf.tf5")
@ -76,10 +76,10 @@ elseif(OUTPUT STREQUAL "pnglibconf.c")
file(MAKE_DIRECTORY "${BINDIR}/scripts")
file(RENAME "pnglibconf.tf5" "${BINDIR}/pnglibconf.c")
elseif(OUTPUT STREQUAL "pnglibconf.h")
# Generate pnglibconf.h
elseif(OUTPUT MATCHES "(pnglibconf\\.h)\$")
# Generate "${BINDIR}/pnglibconf.h"
file(REMOVE "${BINDIR}/${OUTPUT}")
file(REMOVE "${OUTPUT}")
if(PNG_PREFIX)
file(REMOVE "pnglibconf.tf8")
@ -95,20 +95,21 @@ elseif(OUTPUT STREQUAL "pnglibconf.h")
message(FATAL_ERROR "Failed to generate pnglibconf.tf8")
endif()
file(RENAME "pnglibconf.tf8" "${BINDIR}/${OUTPUT}")
file(RENAME "pnglibconf.tf8" "${OUTPUT}")
else()
execute_process(COMMAND "${CMAKE_COMMAND}" -E copy "${BINDIR}/pnglibconf.out"
"${BINDIR}/${OUTPUT}"
execute_process(COMMAND "${CMAKE_COMMAND}" -E copy "pnglibconf.out"
"${OUTPUT}"
WORKING_DIRECTORY "${BINDIR}"
RESULT_VARIABLE COPY_FAIL)
if(COPY_FAIL)
message(FATAL_ERROR "Failed to create pnglibconf.h")
endif()
endif()
elseif(OUTPUT STREQUAL "pngprefix.h")
# Generate pngprefix.h
elseif(OUTPUT MATCHES "(pngprefix\\.h)\$")
# Generate "${BINDIR}/pngprefix.h"
file(REMOVE "${BINDIR}/${OUTPUT}")
file(REMOVE "${OUTPUT}")
if(PNG_PREFIX)
file(REMOVE "pngprefix.tf1")
@ -122,12 +123,12 @@ elseif(OUTPUT STREQUAL "pngprefix.h")
message(FATAL_ERROR "Failed to generate pngprefix.tf1")
endif()
file(RENAME "pngprefix.tf1" "${BINDIR}/${OUTPUT}")
file(RENAME "pngprefix.tf1" "${OUTPUT}")
else()
file(WRITE "${BINDIR}/${OUTPUT}" "/* No libpng symbol prefix configured. */")
file(WRITE "${OUTPUT}" "/* No libpng symbol prefix configured. */")
endif()
elseif(OUTPUT STREQUAL "scripts/pnglibconf.h.prebuilt")
elseif(OUTPUT MATCHES "(scripts/pnglibconf\\.h\\.prebuilt)\$")
# Generate scripts/pnglibconf.h.prebuilt (fails build)
message(STATUS "Attempting to build scripts/pnglibconf.h.prebuilt")

View File

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

View File

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

View File

@ -22,7 +22,8 @@ RM_F = rm -f
# Compiler and linker flags
NOHWOPT = -DPNG_ARM_NEON_OPT=0 -DPNG_MIPS_MSA_OPT=0 \
-DPNG_POWERPC_VSX_OPT=0 -DPNG_INTEL_SSE_OPT=0
-DPNG_POWERPC_VSX_OPT=0 -DPNG_INTEL_SSE_OPT=0 \
-DPNG_RISCV_RVV_OPT=0
STDC = -pedantic-errors -std=c89
WARN = -Wall -Wextra -Wundef
WARNMORE = -Wcast-align -Wconversion -Wshadow -Wpointer-arith -Wwrite-strings \

View File

@ -21,7 +21,8 @@ RM_F = rm -f
# Compiler and linker flags
NOHWOPT = -DPNG_ARM_NEON_OPT=0 -DPNG_MIPS_MSA_OPT=0 \
-DPNG_POWERPC_VSX_OPT=0 -DPNG_INTEL_SSE_OPT=0
-DPNG_POWERPC_VSX_OPT=0 -DPNG_INTEL_SSE_OPT=0 \
-DPNG_RISCV_RVV_OPT=0
STDC = -pedantic-errors # -std=c99
WARN = -Wall -Wextra -Wundef
WARNMORE = -Wcast-align -Wconversion -Wshadow -Wpointer-arith -Wwrite-strings \

View File

@ -28,7 +28,8 @@ RM_F=rm -f
# Compiler and linker flags
NOHWOPT = -DPNG_ARM_NEON_OPT=0 -DPNG_MIPS_MSA_OPT=0 \
-DPNG_POWERPC_VSX_OPT=0 -DPNG_INTEL_SSE_OPT=0
-DPNG_POWERPC_VSX_OPT=0 -DPNG_INTEL_SSE_OPT=0 \
-DPNG_RISCV_RVV_OPT=0
STDC = -pedantic-errors
WARN = -Wall -Wextra -Wundef
WARNMORE = -Wcast-align -Wconversion -Wshadow -Wpointer-arith -Wwrite-strings \

View File

@ -21,7 +21,8 @@ RM_F = rm -f
# Compiler and linker flags
NOHWOPT = -DPNG_ARM_NEON_OPT=0 -DPNG_MIPS_MSA_OPT=0 \
-DPNG_POWERPC_VSX_OPT=0 -DPNG_INTEL_SSE_OPT=0
-DPNG_POWERPC_VSX_OPT=0 -DPNG_INTEL_SSE_OPT=0 \
-DPNG_RISCV_RVV_OPT=0
STDC = -pedantic-errors # -std=c99
WARN = -Wall -Wextra -Wundef
WARNMORE = -Wcast-align -Wconversion -Wshadow -Wpointer-arith -Wwrite-strings \

View File

@ -26,7 +26,8 @@ RM_F=rm -f
# Compiler and linker flags
NOHWOPT = -DPNG_ARM_NEON_OPT=0 -DPNG_MIPS_MSA_OPT=0 \
-DPNG_POWERPC_VSX_OPT=0 -DPNG_INTEL_SSE_OPT=0
-DPNG_POWERPC_VSX_OPT=0 -DPNG_INTEL_SSE_OPT=0 \
-DPNG_RISCV_RVV_OPT=0
STDC = -pedantic-errors
WARN = -Wall -Wextra -Wundef
WARNMORE = -Wcast-align -Wconversion -Wshadow -Wpointer-arith -Wwrite-strings \

View File

@ -32,7 +32,8 @@ LN_SF = ln -sf
# Compiler and linker flags
NOHWOPT = -DPNG_ARM_NEON_OPT=0 -DPNG_MIPS_MSA_OPT=0 \
-DPNG_POWERPC_VSX_OPT=0 -DPNG_INTEL_SSE_OPT=0
-DPNG_POWERPC_VSX_OPT=0 -DPNG_INTEL_SSE_OPT=0 \
-DPNG_RISCV_RVV_OPT=0
STDC = -pedantic-errors
WARN = -Wall -Wextra -Wundef
WARNMORE = -Wcast-align -Wconversion -Wshadow -Wpointer-arith -Wwrite-strings \

View File

@ -23,7 +23,8 @@ RM_F = rm -f
AWK = awk
NOHWOPT = -DPNG_ARM_NEON_OPT=0 -DPNG_MIPS_MSA_OPT=0 \
-DPNG_POWERPC_VSX_OPT=0 -DPNG_INTEL_SSE_OPT=0
-DPNG_POWERPC_VSX_OPT=0 -DPNG_INTEL_SSE_OPT=0 \
-DPNG_RISCV_RVV_OPT=0
DFNFLAGS = # DFNFLAGS contains -D options to use in the libpng build
DFA_EXTRA = # extra files that can be used to control configuration
CPPFLAGS = -I$(ZLIBINC) $(NOHWOPT) # -DPNG_DEBUG=5

View File

@ -1,6 +1,6 @@
/* pnglibconf.h - library build configuration */
/* libpng version 1.6.48 */
/* libpng version 1.6.49 */
/* Copyright (c) 2018-2025 Cosmin Truta */
/* Copyright (c) 1998-2002,2004,2006-2018 Glenn Randers-Pehrson */